summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/notes/mainwindow.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/core/pim/notes/mainwindow.cpp b/core/pim/notes/mainwindow.cpp
index d10578a..68cb28b 100644
--- a/core/pim/notes/mainwindow.cpp
+++ b/core/pim/notes/mainwindow.cpp
@@ -7,53 +7,83 @@
7 * 7 *
8 * History: 8 * History:
9 * - 2005.10.12 - started work 9 * - 2005.10.12 - started work
10 * - 2005.10.19 - version 0.2: 10 * - 2005.10.19 - version 0.2:
11 * - first working version 11 * - first working version
12 * - info sent to NoteZ author and to OPIE devel 12 * - info sent to NoteZ author and to OPIE devel
13 * 13 *
14 * - 2005.10.20 - version 0.3: 14 * - 2005.10.20 - version 0.3:
15 * - load/save in UTF-8 15 * - load/save in UTF-8
16 * - load all files from Documents/text/plain 16 * - load all files from Documents/text/plain
17 * - create .txt files not .ntz - timestamp used as name 17 * - create .txt files not .ntz - timestamp used as name
18 * - one variable (documentsDirName) keep location of notes 18 * - one variable (documentsDirName) keep location of notes
19 * - code (re)indented and converted to spaces 19 * - code (re)indented and converted to spaces
20 * - variables translated to English (were in German) 20 * - variables translated to English (were in German)
21 * - started work on beaming 21 * - started work on beaming
22 * 22 *
23 * - 2005.10.26 - version 0.4:
24 * - added check does Documents/text/plain exist and create it if not
25 *
23 * ToDo: 26 * ToDo:
24 * - beaming 27 * - beaming
25 * - moving to SQLite database 28 * - moving to SQLite database
26 * - category support 29 * - category support
27 * - searching 30 * - searching
28 * 31 *
29 */ 32 */
30 33
31#include "mainwindow.h" 34#include "mainwindow.h"
32#include "editwindow.h" 35#include "editwindow.h"
33#include <qpe/ir.h> 36#include <qpe/ir.h>
34 37
35mainWindowWidget::mainWindowWidget( QWidget *parent, const char *name, WFlags) 38mainWindowWidget::mainWindowWidget( QWidget *parent, const char *name, WFlags)
36 : Opie::OPimMainWindow( "Notes", "Notes", tr( "Note" ), "notes", 39 : Opie::OPimMainWindow( "Notes", "Notes", tr( "Note" ), "notes",
37 parent, name, WType_TopLevel | WStyle_ContextHelp ) 40 parent, name, WType_TopLevel | WStyle_ContextHelp )
38{ 41{
39 setCaption( tr("Notes")); 42 setCaption( tr("Notes"));
40 notesList = new QListBox(this, "notesList"); 43 notesList = new QListBox(this, "notesList");
41 setCentralWidget(notesList); 44 setCentralWidget(notesList);
42 45
43 documentsDirName = QPEApplication::documentDir() + "/text/plain/"; 46 documentsDirName = QPEApplication::documentDir() + "/text/plain/";
47
48 fileList.setPath(documentsDirName);
49
50 if(!fileList.exists())
51 {
52 fileList.setPath(QPEApplication::documentDir() + "/text/");
53
54 if(!fileList.exists())
55 {
56 QString text;
57
58 if(!fileList.mkdir(fileList.absPath()))
59 {
60 QMessageBox::critical(0, tr("i/o error"), text.sprintf(tr("Could not create directory '%s'"), fileList.absPath()));
61 }
62 else
63 {
64 fileList.setPath(documentsDirName);
65
66 if(!fileList.mkdir(fileList.absPath()))
67 {
68 QMessageBox::critical(0, tr("i/o error"), text.sprintf(tr("Could not create directory '%s'"), fileList.absPath()));
69 }
70 }
71 }
72 }
73
44 this->selected = -1; 74 this->selected = -1;
45 refreshList(); 75 refreshList();
46 76
47 QObject::connect(notesList, SIGNAL(returnPressed(QListBoxItem*)), this, SLOT(slotItemEdit())); 77 QObject::connect(notesList, SIGNAL(returnPressed(QListBoxItem*)), this, SLOT(slotItemEdit()));
48 QObject::connect(notesList, SIGNAL(doubleClicked(QListBoxItem*)), this, SLOT(slotItemEdit())); 78 QObject::connect(notesList, SIGNAL(doubleClicked(QListBoxItem*)), this, SLOT(slotItemEdit()));
49} 79}
50 80
51void mainWindowWidget::deleteFile() 81void mainWindowWidget::deleteFile()
52{ 82{
53 if( notesList->count() > 0 ) 83 if( notesList->count() > 0 )
54 { 84 {
55 switch (QMessageBox::warning(0, tr("Delete note"), tr("Really delete\n'") + notesList->currentText() + "'?", 85 switch (QMessageBox::warning(0, tr("Delete note"), tr("Really delete\n'") + notesList->currentText() + "'?",
56 QMessageBox::Yes, QMessageBox::No)) 86 QMessageBox::Yes, QMessageBox::No))
57 { 87 {
58 case QMessageBox::Yes: 88 case QMessageBox::Yes:
59 this->selected = notesList->currentItem(); 89 this->selected = notesList->currentItem();