author | zecke <zecke> | 2002-05-09 15:51:20 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-05-09 15:51:20 (UTC) |
commit | 168d7dcdaee8555365af4c918dc941d8cc0dcb68 (patch) (unidiff) | |
tree | ce5b6b357c4247345797ae7c8c059532b3aa142d | |
parent | 7999411de407eaaf57cae9e2d0cb3767c714d161 (diff) | |
download | opie-168d7dcdaee8555365af4c918dc941d8cc0dcb68.zip opie-168d7dcdaee8555365af4c918dc941d8cc0dcb68.tar.gz opie-168d7dcdaee8555365af4c918dc941d8cc0dcb68.tar.bz2 |
Patch from Stefan Eilers to make the Table align better and the viewing of events more easy
-rw-r--r-- | core/pim/todo/mainwindow.cpp | 3 | ||||
-rw-r--r-- | core/pim/todo/todotable.cpp | 49 |
2 files changed, 29 insertions, 23 deletions
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp index 5609211..b7b1da0 100644 --- a/core/pim/todo/mainwindow.cpp +++ b/core/pim/todo/mainwindow.cpp | |||
@@ -1,624 +1,627 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** Copyright (C) 2002 zecke | 3 | ** Copyright (C) 2002 zecke |
4 | ** Copyright (C) 2002 Stefan Eilers (se, eilers.stefan@epost.de) | 4 | ** Copyright (C) 2002 Stefan Eilers (se, eilers.stefan@epost.de) |
5 | ** | 5 | ** |
6 | ** This file is part of Qtopia Environment. | 6 | ** This file is part of Qtopia Environment. |
7 | ** | 7 | ** |
8 | ** This file may be distributed and/or modified under the terms of the | 8 | ** This file may be distributed and/or modified under the terms of the |
9 | ** GNU General Public License version 2 as published by the Free Software | 9 | ** GNU General Public License version 2 as published by the Free Software |
10 | ** Foundation and appearing in the file LICENSE.GPL included in the | 10 | ** Foundation and appearing in the file LICENSE.GPL included in the |
11 | ** packaging of this file. | 11 | ** packaging of this file. |
12 | ** | 12 | ** |
13 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 13 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
14 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 14 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
15 | ** | 15 | ** |
16 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 16 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
17 | ** | 17 | ** |
18 | ** Contact info@trolltech.com if any conditions of this licensing are | 18 | ** Contact info@trolltech.com if any conditions of this licensing are |
19 | ** not clear to you. | 19 | ** not clear to you. |
20 | ** | 20 | ** |
21 | **********************************************************************/ | 21 | **********************************************************************/ |
22 | 22 | ||
23 | #define QTOPIA_INTERNAL_FD | 23 | #define QTOPIA_INTERNAL_FD |
24 | 24 | ||
25 | #include "mainwindow.h" | 25 | #include "mainwindow.h" |
26 | #include "todoentryimpl.h" | 26 | #include "todoentryimpl.h" |
27 | #include "todotable.h" | 27 | #include "todotable.h" |
28 | #include "todolabel.h" | 28 | #include "todolabel.h" |
29 | 29 | ||
30 | #include <opie/tododb.h> | 30 | #include <opie/tododb.h> |
31 | #include <opie/todovcalresource.h> | 31 | #include <opie/todovcalresource.h> |
32 | #include <opie/ofontmenu.h> | 32 | #include <opie/ofontmenu.h> |
33 | 33 | ||
34 | #include <qpe/qpeapplication.h> | 34 | #include <qpe/qpeapplication.h> |
35 | #include <qpe/config.h> | 35 | #include <qpe/config.h> |
36 | #include <qpe/finddialog.h> | 36 | #include <qpe/finddialog.h> |
37 | #include <qpe/global.h> | 37 | #include <qpe/global.h> |
38 | #include <qpe/ir.h> | 38 | #include <qpe/ir.h> |
39 | #include <qpe/qpemenubar.h> | 39 | #include <qpe/qpemenubar.h> |
40 | #include <qpe/qpemessagebox.h> | 40 | #include <qpe/qpemessagebox.h> |
41 | #include <qpe/resource.h> | 41 | #include <qpe/resource.h> |
42 | //#include <qpe/task.h> | 42 | //#include <qpe/task.h> |
43 | #include <qpe/qpetoolbar.h> | 43 | #include <qpe/qpetoolbar.h> |
44 | 44 | ||
45 | #include <qaction.h> | 45 | #include <qaction.h> |
46 | #include <qarray.h> | 46 | #include <qarray.h> |
47 | #include <qdatastream.h> | 47 | #include <qdatastream.h> |
48 | #include <qdatetime.h> | 48 | #include <qdatetime.h> |
49 | #include <qfile.h> | 49 | #include <qfile.h> |
50 | #include <qmessagebox.h> | 50 | #include <qmessagebox.h> |
51 | #include <qpopupmenu.h> | 51 | #include <qpopupmenu.h> |
52 | #include <qwidgetstack.h> | 52 | #include <qwidgetstack.h> |
53 | 53 | ||
54 | #include <sys/stat.h> | 54 | #include <sys/stat.h> |
55 | #include <sys/types.h> | 55 | #include <sys/types.h> |
56 | #include <fcntl.h> | 56 | #include <fcntl.h> |
57 | #include <unistd.h> | 57 | #include <unistd.h> |
58 | 58 | ||
59 | #include <stdlib.h> | 59 | #include <stdlib.h> |
60 | 60 | ||
61 | static QString todolistXMLFilename() | 61 | static QString todolistXMLFilename() |
62 | { | 62 | { |
63 | return Global::applicationFileName("todolist","todolist.xml"); | 63 | return Global::applicationFileName("todolist","todolist.xml"); |
64 | } | 64 | } |
65 | 65 | ||
66 | static QString categoriesXMLFilename() | 66 | static QString categoriesXMLFilename() |
67 | { | 67 | { |
68 | return Global::applicationFileName("todolist","categories.xml"); | 68 | return Global::applicationFileName("todolist","categories.xml"); |
69 | } | 69 | } |
70 | 70 | ||
71 | TodoWindow::TodoWindow( QWidget *parent, const char *name, WFlags f ) : | 71 | TodoWindow::TodoWindow( QWidget *parent, const char *name, WFlags f ) : |
72 | QMainWindow( parent, name, f ), syncing(FALSE) | 72 | QMainWindow( parent, name, f ), syncing(FALSE) |
73 | { | 73 | { |
74 | // QTime t; | 74 | // QTime t; |
75 | // t.start(); | 75 | // t.start(); |
76 | mView = 0l; | 76 | mView = 0l; |
77 | mStack = new QWidgetStack(this, "main stack"); | 77 | mStack = new QWidgetStack(this, "main stack"); |
78 | setCaption( tr("Todo") ); | 78 | setCaption( tr("Todo") ); |
79 | QString str; | 79 | QString str; |
80 | table = new TodoTable( this ); | 80 | table = new TodoTable( this ); |
81 | table->setColumnWidth( 2, 10 ); | 81 | table->setColumnWidth( 2, 10 ); |
82 | table->setPaintingEnabled( FALSE ); | 82 | table->setPaintingEnabled( FALSE ); |
83 | table->setUpdatesEnabled( FALSE ); | 83 | table->setUpdatesEnabled( FALSE ); |
84 | table->viewport()->setUpdatesEnabled( FALSE ); | 84 | table->viewport()->setUpdatesEnabled( FALSE ); |
85 | 85 | ||
86 | { | 86 | { |
87 | str = todolistXMLFilename(); | 87 | str = todolistXMLFilename(); |
88 | if ( str.isNull() ) | 88 | if ( str.isNull() ) |
89 | QMessageBox::critical( this, | 89 | QMessageBox::critical( this, |
90 | tr("Out of Space"), | 90 | tr("Out of Space"), |
91 | tr("Unable to create startup files\n" | 91 | tr("Unable to create startup files\n" |
92 | "Free up some space\n" | 92 | "Free up some space\n" |
93 | "before you enter any data") ); | 93 | "before you enter any data") ); |
94 | else | 94 | else |
95 | table->load( str ); | 95 | table->load( str ); |
96 | } | 96 | } |
97 | 97 | ||
98 | // repeat for categories... | 98 | // repeat for categories... |
99 | str = categoriesXMLFilename(); | 99 | str = categoriesXMLFilename(); |
100 | if ( str.isNull() ) | 100 | if ( str.isNull() ) |
101 | QMessageBox::critical( this, | 101 | QMessageBox::critical( this, |
102 | tr( "Out of Space" ), | 102 | tr( "Out of Space" ), |
103 | tr( "Unable to create startup files\n" | 103 | tr( "Unable to create startup files\n" |
104 | "Free up some space\n" | 104 | "Free up some space\n" |
105 | "before you enter any data") ); | 105 | "before you enter any data") ); |
106 | 106 | ||
107 | mStack->addWidget(table, 1 ); | 107 | mStack->addWidget(table, 1 ); |
108 | mStack->raiseWidget( 1 ); | 108 | mStack->raiseWidget( 1 ); |
109 | setCentralWidget( mStack ); | 109 | setCentralWidget( mStack ); |
110 | setToolBarsMovable( FALSE ); | 110 | setToolBarsMovable( FALSE ); |
111 | 111 | ||
112 | // qDebug("after load: t=%d", t.elapsed() ); | 112 | // qDebug("after load: t=%d", t.elapsed() ); |
113 | 113 | ||
114 | Config config( "todo" ); | 114 | Config config( "todo" ); |
115 | config.setGroup( "View" ); | 115 | config.setGroup( "View" ); |
116 | bool complete = config.readBoolEntry( "ShowComplete", true ); | 116 | bool complete = config.readBoolEntry( "ShowComplete", true ); |
117 | table->setShowCompleted( complete ); | 117 | table->setShowCompleted( complete ); |
118 | 118 | ||
119 | bool showdeadline = config.readBoolEntry("ShowDeadLine", true); | 119 | bool showdeadline = config.readBoolEntry("ShowDeadLine", true); |
120 | table->setShowDeadline (showdeadline); | 120 | table->setShowDeadline (showdeadline); |
121 | 121 | ||
122 | QString category = config.readEntry( "Category", QString::null ); | 122 | QString category = config.readEntry( "Category", QString::null ); |
123 | table->setShowCategory( category ); | 123 | table->setShowCategory( category ); |
124 | 124 | ||
125 | QPEToolBar *bar = new QPEToolBar( this ); | 125 | QPEToolBar *bar = new QPEToolBar( this ); |
126 | bar->setHorizontalStretchable( TRUE ); | 126 | bar->setHorizontalStretchable( TRUE ); |
127 | 127 | ||
128 | QPEMenuBar *mb = new QPEMenuBar( bar ); | 128 | QPEMenuBar *mb = new QPEMenuBar( bar ); |
129 | 129 | ||
130 | catMenu = new QPopupMenu( this ); | 130 | catMenu = new QPopupMenu( this ); |
131 | QPopupMenu *edit = new QPopupMenu( this ); | 131 | QPopupMenu *edit = new QPopupMenu( this ); |
132 | QPopupMenu *options = new QPopupMenu(this ); | 132 | QPopupMenu *options = new QPopupMenu(this ); |
133 | 133 | ||
134 | contextMenu = new QPopupMenu( this ); | 134 | contextMenu = new QPopupMenu( this ); |
135 | 135 | ||
136 | bar = new QPEToolBar( this ); | 136 | bar = new QPEToolBar( this ); |
137 | 137 | ||
138 | QAction *a = new QAction( tr( "New Task" ), Resource::loadPixmap( "new" ), | 138 | QAction *a = new QAction( tr( "New Task" ), Resource::loadPixmap( "new" ), |
139 | QString::null, 0, this, 0 ); | 139 | QString::null, 0, this, 0 ); |
140 | connect( a, SIGNAL( activated() ), | 140 | connect( a, SIGNAL( activated() ), |
141 | this, SLOT( slotNew() ) ); | 141 | this, SLOT( slotNew() ) ); |
142 | a->addTo( bar ); | 142 | a->addTo( bar ); |
143 | a->addTo( edit ); | 143 | a->addTo( edit ); |
144 | 144 | ||
145 | a = new QAction( tr( "Edit Task" ), Resource::loadIconSet( "edit" ), | 145 | a = new QAction( tr( "Edit Task" ), Resource::loadIconSet( "edit" ), |
146 | QString::null, 0, this, 0 ); | 146 | QString::null, 0, this, 0 ); |
147 | connect( a, SIGNAL( activated() ), | 147 | connect( a, SIGNAL( activated() ), |
148 | this, SLOT( slotEdit() ) ); | 148 | this, SLOT( slotEdit() ) ); |
149 | a->addTo( bar ); | 149 | a->addTo( bar ); |
150 | a->addTo( edit ); | 150 | a->addTo( edit ); |
151 | a->addTo( contextMenu ); | 151 | a->addTo( contextMenu ); |
152 | a->setEnabled( FALSE ); | 152 | a->setEnabled( FALSE ); |
153 | editAction = a; | 153 | editAction = a; |
154 | 154 | ||
155 | a = new QAction( QString::null, tr("View Task"), 0, this, 0 ); | 155 | a = new QAction( QString::null, tr("View Task"), 0, this, 0 ); |
156 | a->addTo( edit ); | 156 | a->addTo( edit ); |
157 | a->addTo( contextMenu ); | 157 | a->addTo( contextMenu ); |
158 | connect( a, SIGNAL( activated() ), | 158 | connect( a, SIGNAL( activated() ), |
159 | this, SLOT(slotShowDetails() ) ); | 159 | this, SLOT(slotShowDetails() ) ); |
160 | 160 | ||
161 | edit->insertSeparator(); | 161 | edit->insertSeparator(); |
162 | 162 | ||
163 | a = new QAction( tr( "Delete..." ), Resource::loadIconSet( "trash" ), | 163 | a = new QAction( tr( "Delete..." ), Resource::loadIconSet( "trash" ), |
164 | QString::null, 0, this, 0 ); | 164 | QString::null, 0, this, 0 ); |
165 | connect( a, SIGNAL( activated() ), | 165 | connect( a, SIGNAL( activated() ), |
166 | this, SLOT( slotDelete() ) ); | 166 | this, SLOT( slotDelete() ) ); |
167 | a->addTo( bar ); | 167 | a->addTo( bar ); |
168 | a->addTo( edit ); | 168 | a->addTo( edit ); |
169 | a->addTo( contextMenu ); | 169 | a->addTo( contextMenu ); |
170 | a->setEnabled( FALSE ); | 170 | a->setEnabled( FALSE ); |
171 | deleteAction = a; | 171 | deleteAction = a; |
172 | 172 | ||
173 | // delete All in category is missing.... | 173 | // delete All in category is missing.... |
174 | // set All Done | 174 | // set All Done |
175 | // set All Done in category | 175 | // set All Done in category |
176 | 176 | ||
177 | a = new QAction( QString::null, tr( "Delete all..."), 0, this, 0 ); | 177 | a = new QAction( QString::null, tr( "Delete all..."), 0, this, 0 ); |
178 | connect(a, SIGNAL( activated() ), | 178 | connect(a, SIGNAL( activated() ), |
179 | this, SLOT( slotDeleteAll() ) ); | 179 | this, SLOT( slotDeleteAll() ) ); |
180 | a->addTo(edit ); | 180 | a->addTo(edit ); |
181 | a->setEnabled( FALSE ); | 181 | a->setEnabled( FALSE ); |
182 | deleteAllAction = a; | 182 | deleteAllAction = a; |
183 | 183 | ||
184 | edit->insertSeparator(); | 184 | edit->insertSeparator(); |
185 | a = new QAction( QString::null, tr("Duplicate" ), 0, this, 0 ); | 185 | a = new QAction( QString::null, tr("Duplicate" ), 0, this, 0 ); |
186 | connect(a, SIGNAL( activated() ), | 186 | connect(a, SIGNAL( activated() ), |
187 | this, SLOT( slotDuplicate() ) ); | 187 | this, SLOT( slotDuplicate() ) ); |
188 | a->addTo(edit ); | 188 | a->addTo(edit ); |
189 | a->setEnabled( FALSE ); | 189 | a->setEnabled( FALSE ); |
190 | duplicateAction = a; | 190 | duplicateAction = a; |
191 | edit->insertSeparator(); | 191 | edit->insertSeparator(); |
192 | 192 | ||
193 | 193 | ||
194 | 194 | ||
195 | if ( Ir::supported() ) { | 195 | if ( Ir::supported() ) { |
196 | a = new QAction( tr( "Beam" ), Resource::loadPixmap( "beam" ), | 196 | a = new QAction( tr( "Beam" ), Resource::loadPixmap( "beam" ), |
197 | QString::null, 0, this, 0 ); | 197 | QString::null, 0, this, 0 ); |
198 | connect( a, SIGNAL( activated() ), | 198 | connect( a, SIGNAL( activated() ), |
199 | this, SLOT( slotBeam() ) ); | 199 | this, SLOT( slotBeam() ) ); |
200 | a->addTo( edit ); | 200 | a->addTo( edit ); |
201 | a->addTo( bar ); | 201 | a->addTo( bar ); |
202 | } | 202 | } |
203 | 203 | ||
204 | a = new QAction( tr( "Find" ), Resource::loadIconSet( "mag" ), | 204 | a = new QAction( tr( "Find" ), Resource::loadIconSet( "mag" ), |
205 | QString::null, 0, this, 0 ); | 205 | QString::null, 0, this, 0 ); |
206 | connect( a, SIGNAL( activated() ), | 206 | connect( a, SIGNAL( activated() ), |
207 | this, SLOT( slotFind() ) ); | 207 | this, SLOT( slotFind() ) ); |
208 | a->addTo( bar ); | 208 | a->addTo( bar ); |
209 | a->addTo( options ); | 209 | a->addTo( options ); |
210 | options->insertSeparator(); | 210 | options->insertSeparator(); |
211 | 211 | ||
212 | if ( table->numRows() ) | 212 | if ( table->numRows() ) |
213 | a->setEnabled( TRUE ); | 213 | a->setEnabled( TRUE ); |
214 | else | 214 | else |
215 | a->setEnabled( FALSE ); | 215 | a->setEnabled( FALSE ); |
216 | 216 | ||
217 | //a->setEnabled( FALSE ); | 217 | //a->setEnabled( FALSE ); |
218 | findAction = a; | 218 | findAction = a; |
219 | // qDebug("mainwindow #2: t=%d", t.elapsed() ); | 219 | // qDebug("mainwindow #2: t=%d", t.elapsed() ); |
220 | 220 | ||
221 | completedAction = new QAction( QString::null, tr("Completed tasks"), 0, this, 0, TRUE ); | 221 | completedAction = new QAction( QString::null, tr("Completed tasks"), 0, this, 0, TRUE ); |
222 | 222 | ||
223 | showdeadlineAction = new QAction( QString::null, tr( "Show Deadline" ), 0, this, 0, TRUE ); | 223 | showdeadlineAction = new QAction( QString::null, tr( "Show Deadline" ), 0, this, 0, TRUE ); |
224 | 224 | ||
225 | catMenu->setCheckable( true ); | 225 | catMenu->setCheckable( true ); |
226 | populateCategories(); | 226 | populateCategories(); |
227 | 227 | ||
228 | 228 | ||
229 | completedAction->addTo( options ); | 229 | completedAction->addTo( options ); |
230 | completedAction->setOn( table->showCompleted() ); | 230 | completedAction->setOn( table->showCompleted() ); |
231 | showdeadlineAction->addTo( options ); | 231 | showdeadlineAction->addTo( options ); |
232 | showdeadlineAction->setOn( table->showDeadline() ); | 232 | showdeadlineAction->setOn( table->showDeadline() ); |
233 | options->insertSeparator( ); | 233 | options->insertSeparator( ); |
234 | QList<QWidget> list; | 234 | QList<QWidget> list; |
235 | list.append(table ); | 235 | list.append(table ); |
236 | OFontMenu *menu = new OFontMenu(this, "menu",list ); | 236 | OFontMenu *menu = new OFontMenu(this, "menu",list ); |
237 | menu->forceSize( table->horizontalHeader(), 10 ); | 237 | menu->forceSize( table->horizontalHeader(), 10 ); |
238 | //catMenu->insertItem(tr("Fonts"), menu ); | 238 | //catMenu->insertItem(tr("Fonts"), menu ); |
239 | list.clear(); | 239 | list.clear(); |
240 | options->insertItem( tr("Fonts"), menu ); | 240 | options->insertItem( tr("Fonts"), menu ); |
241 | 241 | ||
242 | 242 | ||
243 | mb->insertItem( tr( "Data" ), edit ); | 243 | mb->insertItem( tr( "Data" ), edit ); |
244 | mb->insertItem( tr( "Category" ), catMenu ); | 244 | mb->insertItem( tr( "Category" ), catMenu ); |
245 | mb->insertItem( tr( "Options"), options ); | 245 | mb->insertItem( tr( "Options"), options ); |
246 | resize( 200, 300 ); | 246 | resize( 200, 300 ); |
247 | if ( table->numRows() > 0 ) | 247 | if ( table->numRows() > 0 ) |
248 | currentEntryChanged( 0, 0 ); | 248 | currentEntryChanged( 0, 0 ); |
249 | connect( table, SIGNAL( signalEdit() ), | 249 | connect( table, SIGNAL( signalEdit() ), |
250 | this, SLOT( slotEdit() ) ); | 250 | this, SLOT( slotEdit() ) ); |
251 | connect( table, SIGNAL(signalShowMenu(const QPoint &)), | 251 | connect( table, SIGNAL(signalShowMenu(const QPoint &)), |
252 | this, SLOT( slotShowPopup(const QPoint &)) ); | 252 | this, SLOT( slotShowPopup(const QPoint &)) ); |
253 | 253 | ||
254 | // qDebug("mainwindow #3: t=%d", t.elapsed() ); | 254 | // qDebug("mainwindow #3: t=%d", t.elapsed() ); |
255 | table->updateVisible(); | 255 | table->updateVisible(); |
256 | table->setUpdatesEnabled( TRUE ); | 256 | table->setUpdatesEnabled( TRUE ); |
257 | table->setPaintingEnabled( TRUE ); | 257 | table->setPaintingEnabled( TRUE ); |
258 | table->viewport()->setUpdatesEnabled( TRUE ); | 258 | table->viewport()->setUpdatesEnabled( TRUE ); |
259 | 259 | ||
260 | // Initialize the table | ||
261 | table->updateVisible(); | ||
262 | |||
260 | connect( completedAction, SIGNAL( toggled(bool) ), this, SLOT( showCompleted(bool) ) ); | 263 | connect( completedAction, SIGNAL( toggled(bool) ), this, SLOT( showCompleted(bool) ) ); |
261 | connect( showdeadlineAction, SIGNAL( toggled(bool) ), this, SLOT( showDeadline(bool) ) ); | 264 | connect( showdeadlineAction, SIGNAL( toggled(bool) ), this, SLOT( showDeadline(bool) ) ); |
262 | connect( catMenu, SIGNAL(activated(int)), this, SLOT(setCategory(int)) ); | 265 | connect( catMenu, SIGNAL(activated(int)), this, SLOT(setCategory(int)) ); |
263 | connect( table, SIGNAL( currentChanged( int, int ) ), | 266 | connect( table, SIGNAL( currentChanged( int, int ) ), |
264 | this, SLOT( currentEntryChanged( int, int ) ) ); | 267 | this, SLOT( currentEntryChanged( int, int ) ) ); |
265 | 268 | ||
266 | connect( table, SIGNAL(showDetails(const ToDoEvent &) ), | 269 | connect( table, SIGNAL(showDetails(const ToDoEvent &) ), |
267 | this, SLOT(slotShowDetails(const ToDoEvent & ) ) ); | 270 | this, SLOT(slotShowDetails(const ToDoEvent & ) ) ); |
268 | // qDebug("done: t=%d", t.elapsed() ); | 271 | // qDebug("done: t=%d", t.elapsed() ); |
269 | } | 272 | } |
270 | 273 | ||
271 | void TodoWindow::slotNew() | 274 | void TodoWindow::slotNew() |
272 | { | 275 | { |
273 | if(syncing) { | 276 | if(syncing) { |
274 | QMessageBox::warning(this, tr("Todo"), | 277 | QMessageBox::warning(this, tr("Todo"), |
275 | tr("Can not edit data, currently syncing")); | 278 | tr("Can not edit data, currently syncing")); |
276 | return; | 279 | return; |
277 | } | 280 | } |
278 | 281 | ||
279 | int id; | 282 | int id; |
280 | id = -1; | 283 | id = -1; |
281 | QArray<int> ids; | 284 | QArray<int> ids; |
282 | ids = table->currentEntry().categories(); | 285 | ids = table->currentEntry().categories(); |
283 | if ( ids.count() ) | 286 | if ( ids.count() ) |
284 | id = ids[0]; | 287 | id = ids[0]; |
285 | NewTaskDialog e( id, this, 0, TRUE ); | 288 | NewTaskDialog e( id, this, 0, TRUE ); |
286 | 289 | ||
287 | ToDoEvent todo; | 290 | ToDoEvent todo; |
288 | 291 | ||
289 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 292 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
290 | e.showMaximized(); | 293 | e.showMaximized(); |
291 | #endif | 294 | #endif |
292 | int ret = e.exec(); | 295 | int ret = e.exec(); |
293 | // qWarning("finished" ); | 296 | // qWarning("finished" ); |
294 | if ( ret == QDialog::Accepted ) { | 297 | if ( ret == QDialog::Accepted ) { |
295 | table->setPaintingEnabled( false ); | 298 | table->setPaintingEnabled( false ); |
296 | todo = e.todoEntry(); | 299 | todo = e.todoEntry(); |
297 | //todo.assignUid(); | 300 | //todo.assignUid(); |
298 | table->addEntry( todo ); | 301 | table->addEntry( todo ); |
299 | table->setPaintingEnabled( true ); | 302 | table->setPaintingEnabled( true ); |
300 | findAction->setEnabled( TRUE ); | 303 | findAction->setEnabled( TRUE ); |
301 | } | 304 | } |
302 | // I'm afraid we must call this every time now, otherwise | 305 | // I'm afraid we must call this every time now, otherwise |
303 | // spend expensive time comparing all these strings... | 306 | // spend expensive time comparing all these strings... |
304 | populateCategories(); | 307 | populateCategories(); |
305 | mStack->raiseWidget(1 ); | 308 | mStack->raiseWidget(1 ); |
306 | } | 309 | } |
307 | 310 | ||
308 | TodoWindow::~TodoWindow() | 311 | TodoWindow::~TodoWindow() |
309 | { | 312 | { |
310 | } | 313 | } |
311 | 314 | ||
312 | void TodoWindow::slotDelete() | 315 | void TodoWindow::slotDelete() |
313 | { | 316 | { |
314 | if(syncing) { | 317 | if(syncing) { |
315 | QMessageBox::warning(this, tr("Todo"), | 318 | QMessageBox::warning(this, tr("Todo"), |
316 | tr("Can not edit data, currently syncing")); | 319 | tr("Can not edit data, currently syncing")); |
317 | return; | 320 | return; |
318 | } | 321 | } |
319 | 322 | ||
320 | if ( table->currentRow() == -1 ) | 323 | if ( table->currentRow() == -1 ) |
321 | return; | 324 | return; |
322 | 325 | ||
323 | QString strName = table->text( table->currentRow(), 2 ).left( 30 ); | 326 | QString strName = table->text( table->currentRow(), 2 ).left( 30 ); |
324 | 327 | ||
325 | if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), strName ) ) | 328 | if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), strName ) ) |
326 | return; | 329 | return; |
327 | 330 | ||
328 | 331 | ||
329 | 332 | ||
330 | table->setPaintingEnabled( false ); | 333 | table->setPaintingEnabled( false ); |
331 | table->removeCurrentEntry(); | 334 | table->removeCurrentEntry(); |
332 | table->setPaintingEnabled( true ); | 335 | table->setPaintingEnabled( true ); |
333 | 336 | ||
334 | if ( table->numRows() == 0 ) { | 337 | if ( table->numRows() == 0 ) { |
335 | currentEntryChanged( -1, 0 ); | 338 | currentEntryChanged( -1, 0 ); |
336 | findAction->setEnabled( FALSE ); | 339 | findAction->setEnabled( FALSE ); |
337 | } | 340 | } |
338 | mStack->raiseWidget(1); | 341 | mStack->raiseWidget(1); |
339 | } | 342 | } |
340 | void TodoWindow::slotDeleteAll() | 343 | void TodoWindow::slotDeleteAll() |
341 | { | 344 | { |
342 | if(syncing) { | 345 | if(syncing) { |
343 | QMessageBox::warning(this, tr("Todo"), | 346 | QMessageBox::warning(this, tr("Todo"), |
344 | tr("Can not edit data, currently syncing")); | 347 | tr("Can not edit data, currently syncing")); |
345 | return; | 348 | return; |
346 | } | 349 | } |
347 | 350 | ||
348 | //QString strName = table->text( table->currentRow(), 2 ).left( 30 ); | 351 | //QString strName = table->text( table->currentRow(), 2 ).left( 30 ); |
349 | 352 | ||
350 | if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("Delete all tasks?") ) ) | 353 | if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("Delete all tasks?") ) ) |
351 | return; | 354 | return; |
352 | 355 | ||
353 | 356 | ||
354 | 357 | ||
355 | table->setPaintingEnabled( false ); | 358 | table->setPaintingEnabled( false ); |
356 | table->removeAllEntries(); | 359 | table->removeAllEntries(); |
357 | table->setPaintingEnabled( true ); | 360 | table->setPaintingEnabled( true ); |
358 | 361 | ||
359 | if ( table->numRows() == 0 ) { | 362 | if ( table->numRows() == 0 ) { |
360 | currentEntryChanged( -1, 0 ); | 363 | currentEntryChanged( -1, 0 ); |
361 | findAction->setEnabled( FALSE ); | 364 | findAction->setEnabled( FALSE ); |
362 | } | 365 | } |
363 | mStack->raiseWidget(1 ); | 366 | mStack->raiseWidget(1 ); |
364 | } | 367 | } |
365 | 368 | ||
366 | void TodoWindow::slotEdit() | 369 | void TodoWindow::slotEdit() |
367 | { | 370 | { |
368 | if(syncing) { | 371 | if(syncing) { |
369 | QMessageBox::warning(this, tr("Todo"), | 372 | QMessageBox::warning(this, tr("Todo"), |
370 | tr("Can not edit data, currently syncing")); | 373 | tr("Can not edit data, currently syncing")); |
371 | return; | 374 | return; |
372 | } | 375 | } |
373 | 376 | ||
374 | ToDoEvent todo = table->currentEntry(); | 377 | ToDoEvent todo = table->currentEntry(); |
375 | qWarning("slotEdit" ); | 378 | qWarning("slotEdit" ); |
376 | NewTaskDialog e( todo, this, 0, TRUE ); | 379 | NewTaskDialog e( todo, this, 0, TRUE ); |
377 | e.setCaption( tr( "Edit Task" ) ); | 380 | e.setCaption( tr( "Edit Task" ) ); |
378 | 381 | ||
379 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 382 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
380 | e.showMaximized(); | 383 | e.showMaximized(); |
381 | #endif | 384 | #endif |
382 | int ret = e.exec(); | 385 | int ret = e.exec(); |
383 | 386 | ||
384 | if ( ret == QDialog::Accepted ) { | 387 | if ( ret == QDialog::Accepted ) { |
385 | qWarning("Replacing now" ); | 388 | qWarning("Replacing now" ); |
386 | table->setPaintingEnabled( false ); | 389 | table->setPaintingEnabled( false ); |
387 | todo = e.todoEntry(); | 390 | todo = e.todoEntry(); |
388 | table->replaceCurrentEntry( todo ); | 391 | table->replaceCurrentEntry( todo ); |
389 | table->setPaintingEnabled( true ); | 392 | table->setPaintingEnabled( true ); |
390 | } | 393 | } |
391 | populateCategories(); | 394 | populateCategories(); |
392 | mStack->raiseWidget( 1 ); | 395 | mStack->raiseWidget( 1 ); |
393 | } | 396 | } |
394 | void TodoWindow::slotDuplicate() | 397 | void TodoWindow::slotDuplicate() |
395 | { | 398 | { |
396 | if(syncing) { | 399 | if(syncing) { |
397 | QMessageBox::warning(this, tr("Todo"), | 400 | QMessageBox::warning(this, tr("Todo"), |
398 | tr("Can not edit data, currently syncing")); | 401 | tr("Can not edit data, currently syncing")); |
399 | return; | 402 | return; |
400 | } | 403 | } |
401 | ToDoEvent ev = table->currentEntry(); | 404 | ToDoEvent ev = table->currentEntry(); |
402 | ToDoEvent ev2 = ToDoEvent( ev ); // what about the uid | 405 | ToDoEvent ev2 = ToDoEvent( ev ); // what about the uid |
403 | int uid; | 406 | int uid; |
404 | { // uid | 407 | { // uid |
405 | Qtopia::UidGen *uidgen = new Qtopia::UidGen(); | 408 | Qtopia::UidGen *uidgen = new Qtopia::UidGen(); |
406 | uid = uidgen->generate(); | 409 | uid = uidgen->generate(); |
407 | delete uidgen; | 410 | delete uidgen; |
408 | } | 411 | } |
409 | ev2.setUid( uid ); | 412 | ev2.setUid( uid ); |
410 | table->setPaintingEnabled( false ); | 413 | table->setPaintingEnabled( false ); |
411 | table->addEntry( ev2 ); | 414 | table->addEntry( ev2 ); |
412 | table->setPaintingEnabled( true ); | 415 | table->setPaintingEnabled( true ); |
413 | 416 | ||
414 | mStack->raiseWidget( 1 ); | 417 | mStack->raiseWidget( 1 ); |
415 | } | 418 | } |
416 | void TodoWindow::slotShowPopup( const QPoint &p ) | 419 | void TodoWindow::slotShowPopup( const QPoint &p ) |
417 | { | 420 | { |
418 | contextMenu->popup( p ); | 421 | contextMenu->popup( p ); |
419 | } | 422 | } |
420 | 423 | ||
421 | void TodoWindow::showCompleted( bool s ) | 424 | void TodoWindow::showCompleted( bool s ) |
422 | { | 425 | { |
423 | if ( !table->isUpdatesEnabled() ) | 426 | if ( !table->isUpdatesEnabled() ) |
424 | return; | 427 | return; |
425 | table->setPaintingEnabled( false ); | 428 | table->setPaintingEnabled( false ); |
426 | table->setShowCompleted( s ); | 429 | table->setShowCompleted( s ); |
427 | table->setPaintingEnabled( true ); | 430 | table->setPaintingEnabled( true ); |
428 | mStack->raiseWidget( 1 ); | 431 | mStack->raiseWidget( 1 ); |
429 | } | 432 | } |
430 | 433 | ||
431 | void TodoWindow::currentEntryChanged( int r, int ) | 434 | void TodoWindow::currentEntryChanged( int r, int ) |
432 | { | 435 | { |
433 | if ( r != -1 && table->rowHeight( r ) > 0 ) { | 436 | if ( r != -1 && table->rowHeight( r ) > 0 ) { |
434 | editAction->setEnabled( TRUE ); | 437 | editAction->setEnabled( TRUE ); |
435 | deleteAction->setEnabled( TRUE ); | 438 | deleteAction->setEnabled( TRUE ); |
436 | duplicateAction->setEnabled( TRUE ); | 439 | duplicateAction->setEnabled( TRUE ); |
437 | deleteAllAction->setEnabled( TRUE ); | 440 | deleteAllAction->setEnabled( TRUE ); |
438 | } else { | 441 | } else { |
439 | editAction->setEnabled( FALSE ); | 442 | editAction->setEnabled( FALSE ); |
440 | deleteAction->setEnabled( FALSE ); | 443 | deleteAction->setEnabled( FALSE ); |
441 | duplicateAction->setEnabled( FALSE ); | 444 | duplicateAction->setEnabled( FALSE ); |
442 | deleteAllAction->setEnabled( FALSE ); | 445 | deleteAllAction->setEnabled( FALSE ); |
443 | } | 446 | } |
444 | } | 447 | } |
445 | 448 | ||
446 | void TodoWindow::setCategory( int c ) | 449 | void TodoWindow::setCategory( int c ) |
447 | { | 450 | { |
448 | if ( c <= 0 ) return; | 451 | if ( c <= 0 ) return; |
449 | if ( !table->isUpdatesEnabled() ) | 452 | if ( !table->isUpdatesEnabled() ) |
450 | return; | 453 | return; |
451 | table->setPaintingEnabled( false ); | 454 | table->setPaintingEnabled( false ); |
452 | for ( unsigned int i = 1; i < catMenu->count(); i++ ) | 455 | for ( unsigned int i = 1; i < catMenu->count(); i++ ) |
453 | catMenu->setItemChecked( i, c == (int)i ); | 456 | catMenu->setItemChecked( i, c == (int)i ); |
454 | if ( c == 1 ) { | 457 | if ( c == 1 ) { |
455 | table->setShowCategory( QString::null ); | 458 | table->setShowCategory( QString::null ); |
456 | setCaption( tr("Todo") + " - " + tr( "All Categories" ) ); | 459 | setCaption( tr("Todo") + " - " + tr( "All Categories" ) ); |
457 | } else if ( c == (int)catMenu->count() - 1 ) { | 460 | } else if ( c == (int)catMenu->count() - 1 ) { |
458 | table->setShowCategory( tr( "Unfiled" ) ); | 461 | table->setShowCategory( tr( "Unfiled" ) ); |
459 | setCaption( tr("Todo") + " - " + tr( "Unfiled" ) ); | 462 | setCaption( tr("Todo") + " - " + tr( "Unfiled" ) ); |
460 | } else { | 463 | } else { |
461 | QString cat = table->categories()[c - 2]; | 464 | QString cat = table->categories()[c - 2]; |
462 | table->setShowCategory( cat ); | 465 | table->setShowCategory( cat ); |
463 | setCaption( tr("Todo") + " - " + cat ); | 466 | setCaption( tr("Todo") + " - " + cat ); |
464 | } | 467 | } |
465 | table->setPaintingEnabled( true ); | 468 | table->setPaintingEnabled( true ); |
466 | 469 | ||
467 | mStack->raiseWidget( 1 ); | 470 | mStack->raiseWidget( 1 ); |
468 | } | 471 | } |
469 | 472 | ||
470 | void TodoWindow::populateCategories() | 473 | void TodoWindow::populateCategories() |
471 | { | 474 | { |
472 | catMenu->clear(); | 475 | catMenu->clear(); |
473 | int id, rememberId; | 476 | int id, rememberId; |
474 | id = 1; | 477 | id = 1; |
475 | rememberId = 0; | 478 | rememberId = 0; |
476 | catMenu->insertItem( tr( "All Categories" ), id++ ); | 479 | catMenu->insertItem( tr( "All Categories" ), id++ ); |
477 | catMenu->insertSeparator(); | 480 | catMenu->insertSeparator(); |
478 | QStringList categories = table->categories(); | 481 | QStringList categories = table->categories(); |
479 | categories.append( tr( "Unfiled" ) ); | 482 | categories.append( tr( "Unfiled" ) ); |
480 | for ( QStringList::Iterator it = categories.begin(); | 483 | for ( QStringList::Iterator it = categories.begin(); |
481 | it != categories.end(); ++it ) { | 484 | it != categories.end(); ++it ) { |
482 | catMenu->insertItem( *it, id ); | 485 | catMenu->insertItem( *it, id ); |
483 | if ( *it == table->showCategory() ) | 486 | if ( *it == table->showCategory() ) |
484 | rememberId = id; | 487 | rememberId = id; |
485 | ++id; | 488 | ++id; |
486 | } | 489 | } |
487 | if ( table->showCategory().isEmpty() ) | 490 | if ( table->showCategory().isEmpty() ) |
488 | setCategory( 1 ); | 491 | setCategory( 1 ); |
489 | else | 492 | else |
490 | setCategory( rememberId ); | 493 | setCategory( rememberId ); |
491 | } | 494 | } |
492 | 495 | ||
493 | void TodoWindow::reload() | 496 | void TodoWindow::reload() |
494 | { | 497 | { |
495 | table->clear(); | 498 | table->clear(); |
496 | table->load( todolistXMLFilename() ); | 499 | table->load( todolistXMLFilename() ); |
497 | syncing = FALSE; | 500 | syncing = FALSE; |
498 | } | 501 | } |
499 | 502 | ||
500 | void TodoWindow::flush() | 503 | void TodoWindow::flush() |
501 | { | 504 | { |
502 | syncing = TRUE; | 505 | syncing = TRUE; |
503 | table->save( todolistXMLFilename() ); | 506 | table->save( todolistXMLFilename() ); |
504 | } | 507 | } |
505 | 508 | ||
506 | void TodoWindow::closeEvent( QCloseEvent *e ) | 509 | void TodoWindow::closeEvent( QCloseEvent *e ) |
507 | { | 510 | { |
508 | if( mStack->visibleWidget() != table ){ | 511 | if( mStack->visibleWidget() != table ){ |
509 | mStack->raiseWidget( 1 ); | 512 | mStack->raiseWidget( 1 ); |
510 | e->ignore(); | 513 | e->ignore(); |
511 | return; | 514 | return; |
512 | } | 515 | } |
513 | if(syncing) { | 516 | if(syncing) { |
514 | /* no need to save if in the middle of syncing */ | 517 | /* no need to save if in the middle of syncing */ |
515 | e->accept(); | 518 | e->accept(); |
516 | return; | 519 | return; |
517 | } | 520 | } |
518 | 521 | ||
519 | if ( table->save( todolistXMLFilename() ) ) { | 522 | if ( table->save( todolistXMLFilename() ) ) { |
520 | e->accept(); | 523 | e->accept(); |
521 | // repeat for categories... | 524 | // repeat for categories... |
522 | // if writing configs fail, it will emit an | 525 | // if writing configs fail, it will emit an |
523 | // error, but I feel that it is "ok" for us to exit | 526 | // error, but I feel that it is "ok" for us to exit |
524 | // espically since we aren't told if the write succeeded... | 527 | // espically since we aren't told if the write succeeded... |
525 | Config config( "todo" ); | 528 | Config config( "todo" ); |
526 | config.setGroup( "View" ); | 529 | config.setGroup( "View" ); |
527 | config.writeEntry( "ShowComplete", table->showCompleted() ); | 530 | config.writeEntry( "ShowComplete", table->showCompleted() ); |
528 | config.writeEntry( "Category", table->showCategory() ); | 531 | config.writeEntry( "Category", table->showCategory() ); |
529 | /* added 20.01.2k2 by se */ | 532 | /* added 20.01.2k2 by se */ |
530 | config.writeEntry( "ShowDeadLine", table->showDeadline()); | 533 | config.writeEntry( "ShowDeadLine", table->showDeadline()); |
531 | } else { | 534 | } else { |
532 | if ( QMessageBox::critical( this, tr("Out of space"), | 535 | if ( QMessageBox::critical( this, tr("Out of space"), |
533 | tr("Todo was unable\n" | 536 | tr("Todo was unable\n" |
534 | "to save your changes.\n" | 537 | "to save your changes.\n" |
535 | "Free up some space\n" | 538 | "Free up some space\n" |
536 | "and try again.\n" | 539 | "and try again.\n" |
537 | "\nQuit Anyway?"), | 540 | "\nQuit Anyway?"), |
538 | QMessageBox::Yes|QMessageBox::Escape, | 541 | QMessageBox::Yes|QMessageBox::Escape, |
539 | QMessageBox::No|QMessageBox::Default) | 542 | QMessageBox::No|QMessageBox::Default) |
540 | != QMessageBox::No ) | 543 | != QMessageBox::No ) |
541 | e->accept(); | 544 | e->accept(); |
542 | else | 545 | else |
543 | e->ignore(); | 546 | e->ignore(); |
544 | } | 547 | } |
545 | } | 548 | } |
546 | 549 | ||
547 | void TodoWindow::slotFind() | 550 | void TodoWindow::slotFind() |
548 | { | 551 | { |
549 | // put everything back to view all for searching... | 552 | // put everything back to view all for searching... |
550 | mStack->raiseWidget( 1 ); | 553 | mStack->raiseWidget( 1 ); |
551 | if ( !catMenu->isItemChecked( 0 ) ) | 554 | if ( !catMenu->isItemChecked( 0 ) ) |
552 | setCategory( 0 ); | 555 | setCategory( 0 ); |
553 | 556 | ||
554 | FindDialog dlg( "Todo List", this ); | 557 | FindDialog dlg( "Todo List", this ); |
555 | QObject::connect( &dlg, | 558 | QObject::connect( &dlg, |
556 | SIGNAL(signalFindClicked(const QString &, | 559 | SIGNAL(signalFindClicked(const QString &, |
557 | bool, bool, int)), | 560 | bool, bool, int)), |
558 | table, | 561 | table, |
559 | SLOT(slotDoFind(const QString&, bool, bool, int)) ); | 562 | SLOT(slotDoFind(const QString&, bool, bool, int)) ); |
560 | QObject::connect( table, SIGNAL(signalNotFound()), &dlg, | 563 | QObject::connect( table, SIGNAL(signalNotFound()), &dlg, |
561 | SLOT(slotNotFound()) ); | 564 | SLOT(slotNotFound()) ); |
562 | QObject::connect( table, SIGNAL(signalWrapAround()), &dlg, | 565 | QObject::connect( table, SIGNAL(signalWrapAround()), &dlg, |
563 | SLOT(slotWrapAround()) ); | 566 | SLOT(slotWrapAround()) ); |
564 | dlg.exec(); | 567 | dlg.exec(); |
565 | if ( table->numSelections() ) | 568 | if ( table->numSelections() ) |
566 | table->clearSelection(); | 569 | table->clearSelection(); |
567 | table->clearFindRow(); | 570 | table->clearFindRow(); |
568 | } | 571 | } |
569 | 572 | ||
570 | 573 | ||
571 | void TodoWindow::setDocument( const QString &filename ) | 574 | void TodoWindow::setDocument( const QString &filename ) |
572 | { | 575 | { |
573 | if ( filename.find(".vcs") != int(filename.length()) - 4 ) return; | 576 | if ( filename.find(".vcs") != int(filename.length()) - 4 ) return; |
574 | 577 | ||
575 | ToDoDB todoDB(filename, new ToDoVCalResource() ); | 578 | ToDoDB todoDB(filename, new ToDoVCalResource() ); |
576 | QValueList<ToDoEvent> tl = todoDB.rawToDos(); | 579 | QValueList<ToDoEvent> tl = todoDB.rawToDos(); |
577 | for( QValueList<ToDoEvent>::Iterator it = tl.begin(); it != tl.end(); ++it ) { | 580 | for( QValueList<ToDoEvent>::Iterator it = tl.begin(); it != tl.end(); ++it ) { |
578 | table->addEntry( *it ); | 581 | table->addEntry( *it ); |
579 | } | 582 | } |
580 | } | 583 | } |
581 | 584 | ||
582 | static const char * beamfile = "/tmp/obex/todo.vcs"; | 585 | static const char * beamfile = "/tmp/obex/todo.vcs"; |
583 | 586 | ||
584 | void TodoWindow::slotBeam() | 587 | void TodoWindow::slotBeam() |
585 | { | 588 | { |
586 | unlink( beamfile ); // delete if exists | 589 | unlink( beamfile ); // delete if exists |
587 | ToDoEvent c = table->currentEntry(); | 590 | ToDoEvent c = table->currentEntry(); |
588 | mkdir("/tmp/obex/", 0755); | 591 | mkdir("/tmp/obex/", 0755); |
589 | ToDoDB todoDB( beamfile, new ToDoVCalResource() ); | 592 | ToDoDB todoDB( beamfile, new ToDoVCalResource() ); |
590 | todoDB.addEvent( c ); | 593 | todoDB.addEvent( c ); |
591 | todoDB.save(); | 594 | todoDB.save(); |
592 | Ir *ir = new Ir( this ); | 595 | Ir *ir = new Ir( this ); |
593 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 596 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
594 | QString description = c.description(); | 597 | QString description = c.description(); |
595 | ir->send( beamfile, description, "text/x-vCalendar" ); | 598 | ir->send( beamfile, description, "text/x-vCalendar" ); |
596 | } | 599 | } |
597 | 600 | ||
598 | void TodoWindow::beamDone( Ir *ir ) | 601 | void TodoWindow::beamDone( Ir *ir ) |
599 | { | 602 | { |
600 | delete ir; | 603 | delete ir; |
601 | unlink( beamfile ); | 604 | unlink( beamfile ); |
602 | } | 605 | } |
603 | 606 | ||
604 | void TodoWindow::showDeadline( bool s ) | 607 | void TodoWindow::showDeadline( bool s ) |
605 | { | 608 | { |
606 | table->setPaintingEnabled( false ); | 609 | table->setPaintingEnabled( false ); |
607 | table->setShowDeadline( s ); | 610 | table->setShowDeadline( s ); |
608 | table->setPaintingEnabled( true ); | 611 | table->setPaintingEnabled( true ); |
609 | } | 612 | } |
610 | void TodoWindow::slotShowDetails() | 613 | void TodoWindow::slotShowDetails() |
611 | { | 614 | { |
612 | ToDoEvent event = table->currentEntry(); | 615 | ToDoEvent event = table->currentEntry(); |
613 | slotShowDetails( event ); | 616 | slotShowDetails( event ); |
614 | } | 617 | } |
615 | void TodoWindow::slotShowDetails( const ToDoEvent &event ) | 618 | void TodoWindow::slotShowDetails( const ToDoEvent &event ) |
616 | { | 619 | { |
617 | if( mView == 0l ){ | 620 | if( mView == 0l ){ |
618 | mView = new TodoLabel(mStack); | 621 | mView = new TodoLabel(mStack); |
619 | mStack->addWidget( mView, 2 ); | 622 | mStack->addWidget( mView, 2 ); |
620 | } | 623 | } |
621 | mView->init( event ); | 624 | mView->init( event ); |
622 | mView->sync(); | 625 | mView->sync(); |
623 | mStack->raiseWidget( 2); | 626 | mStack->raiseWidget( 2); |
624 | } | 627 | } |
diff --git a/core/pim/todo/todotable.cpp b/core/pim/todo/todotable.cpp index 877308a..52a3087 100644 --- a/core/pim/todo/todotable.cpp +++ b/core/pim/todo/todotable.cpp | |||
@@ -1,935 +1,938 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | /* Show Deadline was added by Stefan Eilers (se, eilers.stefan@epost.de) | 20 | /* Show Deadline was added by Stefan Eilers (se, eilers.stefan@epost.de) |
21 | */ | 21 | */ |
22 | #include "todotable.h" | 22 | #include "todotable.h" |
23 | 23 | ||
24 | #include <opie/tododb.h> | 24 | #include <opie/tododb.h> |
25 | #include <opie/xmltree.h> | 25 | #include <opie/xmltree.h> |
26 | 26 | ||
27 | #include <qpe/categoryselect.h> | 27 | #include <qpe/categoryselect.h> |
28 | #include <qpe/xmlreader.h> | 28 | #include <qpe/xmlreader.h> |
29 | 29 | ||
30 | #include <qasciidict.h> | 30 | #include <qasciidict.h> |
31 | #include <qcombobox.h> | 31 | #include <qcombobox.h> |
32 | #include <qfile.h> | 32 | #include <qfile.h> |
33 | #include <qpainter.h> | 33 | #include <qpainter.h> |
34 | #include <qtextcodec.h> | 34 | #include <qtextcodec.h> |
35 | #include <qtimer.h> | 35 | #include <qtimer.h> |
36 | #include <qdatetime.h> | 36 | #include <qdatetime.h> |
37 | #include <qtextstream.h> | 37 | #include <qtextstream.h> |
38 | 38 | ||
39 | #include <qcursor.h> | 39 | #include <qcursor.h> |
40 | #include <qregexp.h> | 40 | #include <qregexp.h> |
41 | 41 | ||
42 | #include <errno.h> | 42 | #include <errno.h> |
43 | #include <stdlib.h> | 43 | #include <stdlib.h> |
44 | 44 | ||
45 | #include <stdio.h> | 45 | #include <stdio.h> |
46 | 46 | ||
47 | using namespace Opie; | 47 | using namespace Opie; |
48 | 48 | ||
49 | namespace { | 49 | namespace { |
50 | 50 | ||
51 | static bool taskCompare( const ToDoEvent &task, const QRegExp &r, int category ); | 51 | static bool taskCompare( const ToDoEvent &task, const QRegExp &r, int category ); |
52 | static QString journalFileName(); | 52 | static QString journalFileName(); |
53 | static ToDoEvent xmlToEvent( XMLElement *ev ); | 53 | static ToDoEvent xmlToEvent( XMLElement *ev ); |
54 | } | 54 | } |
55 | CheckItem::CheckItem( QTable *t, const QString &key ) | 55 | CheckItem::CheckItem( QTable *t, const QString &key ) |
56 | : QTableItem( t, Never, "" ), checked( FALSE ), sortKey( key ) | 56 | : QTableItem( t, Never, "" ), checked( FALSE ), sortKey( key ) |
57 | { | 57 | { |
58 | } | 58 | } |
59 | 59 | ||
60 | QString CheckItem::key() const | 60 | QString CheckItem::key() const |
61 | { | 61 | { |
62 | return sortKey; | 62 | return sortKey; |
63 | } | 63 | } |
64 | 64 | ||
65 | void CheckItem::setChecked( bool b ) | 65 | void CheckItem::setChecked( bool b ) |
66 | { | 66 | { |
67 | checked = b; | 67 | checked = b; |
68 | table()->updateCell( row(), col() ); | 68 | table()->updateCell( row(), col() ); |
69 | } | 69 | } |
70 | 70 | ||
71 | void CheckItem::toggle() | 71 | void CheckItem::toggle() |
72 | { | 72 | { |
73 | TodoTable *parent = static_cast<TodoTable*>(table()); | 73 | TodoTable *parent = static_cast<TodoTable*>(table()); |
74 | ToDoEvent newTodo = parent->currentEntry(); | 74 | ToDoEvent newTodo = parent->currentEntry(); |
75 | checked = !checked; | 75 | checked = !checked; |
76 | newTodo.setCompleted( checked ); | 76 | newTodo.setCompleted( checked ); |
77 | table()->updateCell( row(), col() ); | 77 | table()->updateCell( row(), col() ); |
78 | parent->replaceCurrentEntry( newTodo, true ); | 78 | parent->replaceCurrentEntry( newTodo, true ); |
79 | } | 79 | } |
80 | 80 | ||
81 | bool CheckItem::isChecked() const | 81 | bool CheckItem::isChecked() const |
82 | { | 82 | { |
83 | return checked; | 83 | return checked; |
84 | } | 84 | } |
85 | 85 | ||
86 | static const int BoxSize = 10; | 86 | static const int BoxSize = 10; |
87 | 87 | ||
88 | void CheckItem::paint( QPainter *p, const QColorGroup &cg, const QRect &cr, | 88 | void CheckItem::paint( QPainter *p, const QColorGroup &cg, const QRect &cr, |
89 | bool ) | 89 | bool ) |
90 | { | 90 | { |
91 | p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Base ) ); | 91 | p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Base ) ); |
92 | 92 | ||
93 | int marg = ( cr.width() - BoxSize ) / 2; | 93 | int marg = ( cr.width() - BoxSize ) / 2; |
94 | int x = 0; | 94 | int x = 0; |
95 | int y = ( cr.height() - BoxSize ) / 2; | 95 | int y = ( cr.height() - BoxSize ) / 2; |
96 | p->setPen( QPen( cg.text() ) ); | 96 | p->setPen( QPen( cg.text() ) ); |
97 | p->drawRect( x + marg, y, BoxSize, BoxSize ); | 97 | p->drawRect( x + marg, y, BoxSize, BoxSize ); |
98 | p->drawRect( x + marg+1, y+1, BoxSize-2, BoxSize-2 ); | 98 | p->drawRect( x + marg+1, y+1, BoxSize-2, BoxSize-2 ); |
99 | p->setPen( darkGreen ); | 99 | p->setPen( darkGreen ); |
100 | x += 1; | 100 | x += 1; |
101 | y += 1; | 101 | y += 1; |
102 | if ( checked ) { | 102 | if ( checked ) { |
103 | QPointArray a( 7*2 ); | 103 | QPointArray a( 7*2 ); |
104 | int i, xx, yy; | 104 | int i, xx, yy; |
105 | xx = x+1+marg; | 105 | xx = x+1+marg; |
106 | yy = y+2; | 106 | yy = y+2; |
107 | for ( i=0; i<3; i++ ) { | 107 | for ( i=0; i<3; i++ ) { |
108 | a.setPoint( 2*i, xx, yy ); | 108 | a.setPoint( 2*i, xx, yy ); |
109 | a.setPoint( 2*i+1, xx, yy+2 ); | 109 | a.setPoint( 2*i+1, xx, yy+2 ); |
110 | xx++; yy++; | 110 | xx++; yy++; |
111 | } | 111 | } |
112 | yy -= 2; | 112 | yy -= 2; |
113 | for ( i=3; i<7; i++ ) { | 113 | for ( i=3; i<7; i++ ) { |
114 | a.setPoint( 2*i, xx, yy ); | 114 | a.setPoint( 2*i, xx, yy ); |
115 | a.setPoint( 2*i+1, xx, yy+2 ); | 115 | a.setPoint( 2*i+1, xx, yy+2 ); |
116 | xx++; yy--; | 116 | xx++; yy--; |
117 | } | 117 | } |
118 | p->drawLineSegments( a ); | 118 | p->drawLineSegments( a ); |
119 | } | 119 | } |
120 | } | 120 | } |
121 | 121 | ||
122 | 122 | ||
123 | ComboItem::ComboItem( QTable *t, EditType et ) | 123 | ComboItem::ComboItem( QTable *t, EditType et ) |
124 | : QTableItem( t, et, "3" ), cb( 0 ) | 124 | : QTableItem( t, et, "3" ), cb( 0 ) |
125 | { | 125 | { |
126 | setReplaceable( FALSE ); | 126 | setReplaceable( FALSE ); |
127 | } | 127 | } |
128 | 128 | ||
129 | QWidget *ComboItem::createEditor() const | 129 | QWidget *ComboItem::createEditor() const |
130 | { | 130 | { |
131 | QString txt = text(); | 131 | QString txt = text(); |
132 | ( (ComboItem*)this )->cb = new QComboBox( table()->viewport() ); | 132 | ( (ComboItem*)this )->cb = new QComboBox( table()->viewport() ); |
133 | cb->insertItem( "1" ); | 133 | cb->insertItem( "1" ); |
134 | cb->insertItem( "2" ); | 134 | cb->insertItem( "2" ); |
135 | cb->insertItem( "3" ); | 135 | cb->insertItem( "3" ); |
136 | cb->insertItem( "4" ); | 136 | cb->insertItem( "4" ); |
137 | cb->insertItem( "5" ); | 137 | cb->insertItem( "5" ); |
138 | cb->setCurrentItem( txt.toInt() - 1 ); | 138 | cb->setCurrentItem( txt.toInt() - 1 ); |
139 | return cb; | 139 | return cb; |
140 | } | 140 | } |
141 | 141 | ||
142 | void ComboItem::setContentFromEditor( QWidget *w ) | 142 | void ComboItem::setContentFromEditor( QWidget *w ) |
143 | { | 143 | { |
144 | TodoTable *parent = static_cast<TodoTable*>(table()); | 144 | TodoTable *parent = static_cast<TodoTable*>(table()); |
145 | ToDoEvent newTodo = parent->currentEntry(); | 145 | ToDoEvent newTodo = parent->currentEntry(); |
146 | 146 | ||
147 | if ( w->inherits( "QComboBox" ) ) | 147 | if ( w->inherits( "QComboBox" ) ) |
148 | setText( ( (QComboBox*)w )->currentText() ); | 148 | setText( ( (QComboBox*)w )->currentText() ); |
149 | else | 149 | else |
150 | QTableItem::setContentFromEditor( w ); | 150 | QTableItem::setContentFromEditor( w ); |
151 | newTodo.setPriority( text().toInt() ); | 151 | newTodo.setPriority( text().toInt() ); |
152 | parent->replaceCurrentEntry( newTodo, true ); | 152 | parent->replaceCurrentEntry( newTodo, true ); |
153 | } | 153 | } |
154 | 154 | ||
155 | void ComboItem::setText( const QString &s ) | 155 | void ComboItem::setText( const QString &s ) |
156 | { | 156 | { |
157 | if ( cb ) | 157 | if ( cb ) |
158 | cb->setCurrentItem( s.toInt() - 1 ); | 158 | cb->setCurrentItem( s.toInt() - 1 ); |
159 | QTableItem::setText( s ); | 159 | QTableItem::setText( s ); |
160 | } | 160 | } |
161 | 161 | ||
162 | QString ComboItem::text() const | 162 | QString ComboItem::text() const |
163 | { | 163 | { |
164 | if ( cb ) | 164 | if ( cb ) |
165 | return cb->currentText(); | 165 | return cb->currentText(); |
166 | return QTableItem::text(); | 166 | return QTableItem::text(); |
167 | } | 167 | } |
168 | DueTextItem::DueTextItem( QTable *t, ToDoEvent *ev ) | 168 | DueTextItem::DueTextItem( QTable *t, ToDoEvent *ev ) |
169 | : QTableItem(t, Never, QString::null ) | 169 | : QTableItem(t, Never, QString::null ) |
170 | { | 170 | { |
171 | setToDoEvent( ev ); | 171 | setToDoEvent( ev ); |
172 | } | 172 | } |
173 | QString DueTextItem::key() const | 173 | QString DueTextItem::key() const |
174 | { | 174 | { |
175 | QString key; | 175 | QString key; |
176 | if( m_hasDate ){ | 176 | if( m_hasDate ){ |
177 | if(m_off == 0 ){ | 177 | if(m_off == 0 ){ |
178 | key.append("b"); | 178 | key.append("b"); |
179 | }else if( m_off > 0 ){ | 179 | }else if( m_off > 0 ){ |
180 | key.append("c"); | 180 | key.append("c"); |
181 | }else if( m_off < 0 ){ | 181 | }else if( m_off < 0 ){ |
182 | key.append("a"); | 182 | key.append("a"); |
183 | } | 183 | } |
184 | key.append(QString::number(m_off ) ); | 184 | key.append(QString::number(m_off ) ); |
185 | }else{ | 185 | }else{ |
186 | key.append("d"); | 186 | key.append("d"); |
187 | } | 187 | } |
188 | return key; | 188 | return key; |
189 | } | 189 | } |
190 | void DueTextItem::setToDoEvent( const ToDoEvent *ev ) | 190 | void DueTextItem::setToDoEvent( const ToDoEvent *ev ) |
191 | { | 191 | { |
192 | m_hasDate = ev->hasDate(); | 192 | m_hasDate = ev->hasDate(); |
193 | m_completed = ev->isCompleted(); | 193 | m_completed = ev->isCompleted(); |
194 | if( ev->hasDate() ){ | 194 | if( ev->hasDate() ){ |
195 | QDate today = QDate::currentDate(); | 195 | QDate today = QDate::currentDate(); |
196 | m_off = today.daysTo(ev->date() ); | 196 | m_off = today.daysTo(ev->date() ); |
197 | //qWarning("DueText m_off=%d", m_off ); | 197 | //qWarning("DueText m_off=%d", m_off ); |
198 | setText( QString::number(m_off) + " day(s) " ); | 198 | setText( QString::number(m_off) + " day(s) " ); |
199 | }else{ | 199 | }else{ |
200 | setText("n.d." ); | 200 | setText("n.d." ); |
201 | m_off = 0; | 201 | m_off = 0; |
202 | } | 202 | } |
203 | //qWarning("m_off=%d", m_off ); | 203 | //qWarning("m_off=%d", m_off ); |
204 | } | 204 | } |
205 | void DueTextItem::paint( QPainter *p, const QColorGroup &cg, const QRect &cr, bool selected ) | 205 | void DueTextItem::paint( QPainter *p, const QColorGroup &cg, const QRect &cr, bool selected ) |
206 | { | 206 | { |
207 | //qWarning ("paint m_off=%d", m_off ); | 207 | //qWarning ("paint m_off=%d", m_off ); |
208 | QColorGroup cg2(cg); | 208 | QColorGroup cg2(cg); |
209 | QColor text = cg.text(); | 209 | QColor text = cg.text(); |
210 | if( m_hasDate && !m_completed ){ | 210 | if( m_hasDate && !m_completed ){ |
211 | if( m_off < 0 ){ | 211 | if( m_off < 0 ){ |
212 | cg2.setColor(QColorGroup::Text, QColor(red ) ); | 212 | cg2.setColor(QColorGroup::Text, QColor(red ) ); |
213 | }else if( m_off == 0 ){ | 213 | }else if( m_off == 0 ){ |
214 | cg2.setColor(QColorGroup::Text, QColor(yellow) ); // orange isn't predefined | 214 | cg2.setColor(QColorGroup::Text, QColor(yellow) ); // orange isn't predefined |
215 | }else if( m_off > 0){ | 215 | }else if( m_off > 0){ |
216 | cg2.setColor(QColorGroup::Text, QColor(green ) ); | 216 | cg2.setColor(QColorGroup::Text, QColor(green ) ); |
217 | } | 217 | } |
218 | } | 218 | } |
219 | QTableItem::paint(p, cg2, cr, selected ); | 219 | QTableItem::paint(p, cg2, cr, selected ); |
220 | cg2.setColor(QColorGroup::Text, text ); | 220 | cg2.setColor(QColorGroup::Text, text ); |
221 | } | 221 | } |
222 | TodoTable::TodoTable( QWidget *parent, const char *name ) | 222 | TodoTable::TodoTable( QWidget *parent, const char *name ) |
223 | // #ifdef QT_QTABLE_NOHEADER_CONSTRUCTOR | 223 | // #ifdef QT_QTABLE_NOHEADER_CONSTRUCTOR |
224 | // : QTable( 0, 3, parent, name, TRUE ), | 224 | // : QTable( 0, 3, parent, name, TRUE ), |
225 | // #else | 225 | // #else |
226 | : QTable( 0, 4, parent, name ), | 226 | : QTable( 0, 4, parent, name ), |
227 | // #endif | 227 | // #endif |
228 | showComp( true ), | 228 | showComp( true ), |
229 | enablePainting( true ), | 229 | enablePainting( true ), |
230 | mCat( 0 ), | 230 | mCat( 0 ), |
231 | currFindRow( -2 ), | 231 | currFindRow( -2 ), |
232 | showDeadl( true) | 232 | showDeadl( true) |
233 | { | 233 | { |
234 | mCat.load( categoryFileName() ); | 234 | mCat.load( categoryFileName() ); |
235 | setSorting( TRUE ); | 235 | setSorting( TRUE ); |
236 | setSelectionMode( NoSelection ); | 236 | setSelectionMode( NoSelection ); |
237 | setColumnStretchable( 2, TRUE ); | 237 | setColumnStretchable( 2, TRUE ); |
238 | setColumnWidth( 0, 20 ); | 238 | setColumnWidth( 0, 20 ); |
239 | setColumnWidth( 1, 35 ); | 239 | setColumnWidth( 1, 35 ); |
240 | 240 | ||
241 | setLeftMargin( 0 ); | 241 | setLeftMargin( 0 ); |
242 | verticalHeader()->hide(); | 242 | verticalHeader()->hide(); |
243 | horizontalHeader()->setLabel( 0, tr( "C." ) ); | 243 | horizontalHeader()->setLabel( 0, tr( "C." ) ); |
244 | horizontalHeader()->setLabel( 1, tr( "Prior." ) ); | 244 | horizontalHeader()->setLabel( 1, tr( "Prior." ) ); |
245 | horizontalHeader()->setLabel( 2, tr( "Description" ) ); | 245 | horizontalHeader()->setLabel( 2, tr( "Description" ) ); |
246 | 246 | ||
247 | setColumnStretchable( 3, FALSE ); | 247 | setColumnStretchable( 3, FALSE ); |
248 | setColumnWidth( 3, 20 ); | 248 | setColumnWidth( 3, 20 ); |
249 | horizontalHeader()->setLabel( 3, tr( "Deadline" ) ); | 249 | horizontalHeader()->setLabel( 3, tr( "Deadline" ) ); |
250 | 250 | ||
251 | if (showDeadl){ | 251 | if (showDeadl){ |
252 | showColumn (3); | 252 | showColumn (3); |
253 | }else{ | 253 | }else{ |
254 | hideColumn (3); | 254 | hideColumn (3); |
255 | } | 255 | } |
256 | 256 | ||
257 | connect( this, SIGNAL( clicked( int, int, int, const QPoint & ) ), | 257 | connect( this, SIGNAL( clicked( int, int, int, const QPoint & ) ), |
258 | this, SLOT( slotClicked( int, int, int, const QPoint & ) ) ); | 258 | this, SLOT( slotClicked( int, int, int, const QPoint & ) ) ); |
259 | connect( this, SIGNAL( pressed( int, int, int, const QPoint & ) ), | 259 | connect( this, SIGNAL( pressed( int, int, int, const QPoint & ) ), |
260 | this, SLOT( slotPressed( int, int, int, const QPoint & ) ) ); | 260 | this, SLOT( slotPressed( int, int, int, const QPoint & ) ) ); |
261 | connect( this, SIGNAL( valueChanged( int, int ) ), | 261 | connect( this, SIGNAL( valueChanged( int, int ) ), |
262 | this, SLOT( slotCheckPriority( int, int ) ) ); | 262 | this, SLOT( slotCheckPriority( int, int ) ) ); |
263 | connect( this, SIGNAL( currentChanged( int, int ) ), | 263 | connect( this, SIGNAL( currentChanged( int, int ) ), |
264 | this, SLOT( slotCurrentChanged( int, int ) ) ); | 264 | this, SLOT( slotCurrentChanged( int, int ) ) ); |
265 | 265 | ||
266 | menuTimer = new QTimer( this ); | 266 | menuTimer = new QTimer( this ); |
267 | connect( menuTimer, SIGNAL(timeout()), this, SLOT(slotShowMenu()) ); | 267 | connect( menuTimer, SIGNAL(timeout()), this, SLOT(slotShowMenu()) ); |
268 | 268 | ||
269 | mDayTimer = new QTimer( this ); | 269 | mDayTimer = new QTimer( this ); |
270 | connect( mDayTimer, SIGNAL(timeout()), this, SLOT(slotCheckDay() ) ); | 270 | connect( mDayTimer, SIGNAL(timeout()), this, SLOT(slotCheckDay() ) ); |
271 | mDay = QDate::currentDate(); | 271 | mDay = QDate::currentDate(); |
272 | } | 272 | } |
273 | 273 | ||
274 | void TodoTable::addEntry( const ToDoEvent &todo ) | 274 | void TodoTable::addEntry( const ToDoEvent &todo ) |
275 | { | 275 | { |
276 | int row = numRows(); | 276 | int row = numRows(); |
277 | setNumRows( row + 1 ); | 277 | setNumRows( row + 1 ); |
278 | updateJournal( todo, ACTION_ADD ); | 278 | updateJournal( todo, ACTION_ADD ); |
279 | insertIntoTable( new ToDoEvent(todo), row ); | 279 | insertIntoTable( new ToDoEvent(todo), row ); |
280 | setCurrentCell(row, currentColumn()); | 280 | setCurrentCell(row, currentColumn()); |
281 | updateVisible(); | 281 | updateVisible(); |
282 | } | 282 | } |
283 | 283 | ||
284 | void TodoTable::slotClicked( int row, int col, int, const QPoint &pos ) | 284 | void TodoTable::slotClicked( int row, int col, int, const QPoint &pos ) |
285 | { | 285 | { |
286 | if ( !cellGeometry( row, col ).contains(pos) ) | 286 | if ( !cellGeometry( row, col ).contains(pos) ) |
287 | return; | 287 | return; |
288 | // let's switch on the column number... | 288 | // let's switch on the column number... |
289 | switch ( col ) | 289 | switch ( col ) |
290 | { | 290 | { |
291 | case 0: { | 291 | case 0: { |
292 | CheckItem *i = static_cast<CheckItem*>(item( row, col )); | 292 | CheckItem *i = static_cast<CheckItem*>(item( row, col )); |
293 | if ( i ) { | 293 | if ( i ) { |
294 | int x = pos.x() - columnPos( col ); | 294 | int x = pos.x() - columnPos( col ); |
295 | int y = pos.y() - rowPos( row ); | 295 | int y = pos.y() - rowPos( row ); |
296 | int w = columnWidth( col ); | 296 | int w = columnWidth( col ); |
297 | int h = rowHeight( row ); | 297 | int h = rowHeight( row ); |
298 | if ( i && x >= ( w - BoxSize ) / 2 && x <= ( w - BoxSize ) / 2 + BoxSize && | 298 | if ( i && x >= ( w - BoxSize ) / 2 && x <= ( w - BoxSize ) / 2 + BoxSize && |
299 | y >= ( h - BoxSize ) / 2 && y <= ( h - BoxSize ) / 2 + BoxSize ) { | 299 | y >= ( h - BoxSize ) / 2 && y <= ( h - BoxSize ) / 2 + BoxSize ) { |
300 | i->toggle(); | 300 | i->toggle(); |
301 | } | 301 | } |
302 | emit signalDoneChanged( i->isChecked() ); | 302 | emit signalDoneChanged( i->isChecked() ); |
303 | } | 303 | } |
304 | } | 304 | } |
305 | break; | 305 | break; |
306 | case 1: | 306 | case 1: |
307 | break; | 307 | break; |
308 | case 2: | 308 | case 2: |
309 | // may as well edit it... | ||
310 | // menuTimer->stop(); | ||
311 | // emit signalEdit(); | ||
312 | // Show detailed view of the selected entry | 309 | // Show detailed view of the selected entry |
313 | { | 310 | { |
314 | menuTimer->stop(); | 311 | menuTimer->stop(); |
315 | ToDoEvent *todo = todoList[static_cast<CheckItem*>(item(row, 0))]; | 312 | ToDoEvent *todo = todoList[static_cast<CheckItem*>(item(row, 0))]; |
316 | emit showDetails( *todo ); | 313 | emit showDetails( *todo ); |
317 | } | 314 | } |
318 | break; | 315 | break; |
319 | case 3: | 316 | case 3: |
320 | // may as well edit it... | 317 | // may as well edit it... |
321 | menuTimer->stop(); | 318 | menuTimer->stop(); |
322 | // emit signalEdit(); | 319 | emit signalEdit(); |
323 | break; | 320 | break; |
324 | } | 321 | } |
325 | } | 322 | } |
326 | 323 | ||
327 | void TodoTable::slotPressed( int row, int col, int, const QPoint &pos ) | 324 | void TodoTable::slotPressed( int row, int col, int, const QPoint &pos ) |
328 | { | 325 | { |
329 | if ( col == 2 && cellGeometry( row, col ).contains(pos) ) | 326 | if ( col == 2 && cellGeometry( row, col ).contains(pos) ) |
330 | menuTimer->start( 750, TRUE ); | 327 | menuTimer->start( 750, TRUE ); |
331 | } | 328 | } |
332 | 329 | ||
333 | void TodoTable::slotShowMenu() | 330 | void TodoTable::slotShowMenu() |
334 | { | 331 | { |
335 | emit signalShowMenu( QCursor::pos() ); | 332 | emit signalShowMenu( QCursor::pos() ); |
336 | } | 333 | } |
337 | 334 | ||
338 | void TodoTable::slotCurrentChanged( int, int ) | 335 | void TodoTable::slotCurrentChanged( int, int ) |
339 | { | 336 | { |
340 | menuTimer->stop(); | 337 | menuTimer->stop(); |
341 | } | 338 | } |
342 | 339 | ||
343 | void TodoTable::internalAddEntries( QList<ToDoEvent> &list ) | 340 | void TodoTable::internalAddEntries( QList<ToDoEvent> &list ) |
344 | { | 341 | { |
345 | setNumRows( list.count() ); | 342 | setNumRows( list.count() ); |
346 | int row = 0; | 343 | int row = 0; |
347 | ToDoEvent *it; | 344 | ToDoEvent *it; |
348 | for ( it = list.first(); it; it = list.next() ) | 345 | for ( it = list.first(); it; it = list.next() ) |
349 | insertIntoTable( it, row++ ); | 346 | insertIntoTable( it, row++ ); |
350 | } | 347 | } |
351 | 348 | ||
352 | 349 | ||
353 | ToDoEvent TodoTable::currentEntry() const | 350 | ToDoEvent TodoTable::currentEntry() const |
354 | { | 351 | { |
355 | //qWarning ("in currentEntry\n"); | 352 | //qWarning ("in currentEntry\n"); |
356 | 353 | ||
357 | QTableItem *i = item( currentRow(), 0 ); | 354 | QTableItem *i = item( currentRow(), 0 ); |
358 | if ( !i || rowHeight( currentRow() ) <= 0 ) | 355 | if ( !i || rowHeight( currentRow() ) <= 0 ) |
359 | return ToDoEvent(); | 356 | return ToDoEvent(); |
360 | ToDoEvent *todo = todoList[(CheckItem*)i]; | 357 | ToDoEvent *todo = todoList[(CheckItem*)i]; |
361 | todo->setCompleted( ( (CheckItem*)item( currentRow(), 0 ) )->isChecked() ); | 358 | todo->setCompleted( ( (CheckItem*)item( currentRow(), 0 ) )->isChecked() ); |
362 | todo->setPriority( ( (ComboItem*)item( currentRow(), 1 ) )->text().toInt() ); | 359 | todo->setPriority( ( (ComboItem*)item( currentRow(), 1 ) )->text().toInt() ); |
363 | return *todo; | 360 | return *todo; |
364 | } | 361 | } |
365 | 362 | ||
366 | void TodoTable::replaceCurrentEntry( const ToDoEvent &todo, bool fromTableItem ) | 363 | void TodoTable::replaceCurrentEntry( const ToDoEvent &todo, bool fromTableItem ) |
367 | { | 364 | { |
368 | int row = currentRow(); | 365 | int row = currentRow(); |
369 | updateJournal( todo, ACTION_REPLACE); | 366 | updateJournal( todo, ACTION_REPLACE); |
370 | 367 | ||
371 | if ( !fromTableItem ) { | 368 | if ( !fromTableItem ) { |
372 | journalFreeReplaceEntry( todo, row ); | 369 | journalFreeReplaceEntry( todo, row ); |
373 | updateVisible(); | 370 | updateVisible(); |
374 | } | 371 | } |
375 | } | 372 | } |
376 | 373 | ||
377 | void TodoTable::removeCurrentEntry() | 374 | void TodoTable::removeCurrentEntry() |
378 | { | 375 | { |
379 | ToDoEvent *oldTodo; | 376 | ToDoEvent *oldTodo; |
380 | int row = currentRow(); | 377 | int row = currentRow(); |
381 | CheckItem *chk; | 378 | CheckItem *chk; |
382 | 379 | ||
383 | chk = static_cast<CheckItem*>(item(row, 0 )); | 380 | chk = static_cast<CheckItem*>(item(row, 0 )); |
384 | if ( !chk ) | 381 | if ( !chk ) |
385 | return; | 382 | return; |
386 | oldTodo = todoList[chk]; | 383 | oldTodo = todoList[chk]; |
387 | todoList.remove( chk ); | 384 | todoList.remove( chk ); |
388 | oldTodo->setCompleted( chk->isChecked() ); | 385 | oldTodo->setCompleted( chk->isChecked() ); |
389 | oldTodo->setPriority( static_cast<ComboItem*>(item(row, 1))->text().toInt() ); | 386 | oldTodo->setPriority( static_cast<ComboItem*>(item(row, 1))->text().toInt() ); |
390 | realignTable( row ); | 387 | realignTable( row ); |
391 | updateVisible(); | 388 | updateVisible(); |
392 | updateJournal( *oldTodo, ACTION_REMOVE); | 389 | updateJournal( *oldTodo, ACTION_REMOVE); |
393 | delete oldTodo; | 390 | delete oldTodo; |
394 | } | 391 | } |
395 | 392 | ||
396 | 393 | ||
397 | bool TodoTable::save( const QString &fn ) | 394 | bool TodoTable::save( const QString &fn ) |
398 | { | 395 | { |
399 | QString strNewFile = fn + ".new"; | 396 | QString strNewFile = fn + ".new"; |
400 | QFile::remove( strNewFile ); // just to be sure | 397 | QFile::remove( strNewFile ); // just to be sure |
401 | ToDoDB todoDB( strNewFile ); | 398 | ToDoDB todoDB( strNewFile ); |
402 | for ( QMap<CheckItem*, ToDoEvent *>::Iterator it = todoList.begin(); | 399 | for ( QMap<CheckItem*, ToDoEvent *>::Iterator it = todoList.begin(); |
403 | it != todoList.end(); ++it ) { | 400 | it != todoList.end(); ++it ) { |
404 | if ( !item( it.key()->row(), 0 ) ) | 401 | if ( !item( it.key()->row(), 0 ) ) |
405 | continue; | 402 | continue; |
406 | ToDoEvent *todo = *it; | 403 | ToDoEvent *todo = *it; |
407 | // sync item with table | 404 | // sync item with table |
408 | todo->setCompleted( ((CheckItem*)item(it.key()->row(), 0))->isChecked() ); | 405 | todo->setCompleted( ((CheckItem*)item(it.key()->row(), 0))->isChecked() ); |
409 | todo->setPriority( ((ComboItem*)item( it.key()->row(), 1))->text().toInt() ); | 406 | todo->setPriority( ((ComboItem*)item( it.key()->row(), 1))->text().toInt() ); |
410 | todoDB.addEvent( *todo ); | 407 | todoDB.addEvent( *todo ); |
411 | } | 408 | } |
412 | if(!todoDB.save() ){ | 409 | if(!todoDB.save() ){ |
413 | QFile::remove( strNewFile ); | 410 | QFile::remove( strNewFile ); |
414 | return false; | 411 | return false; |
415 | }; | 412 | }; |
416 | // now do the rename | 413 | // now do the rename |
417 | if ( ::rename( strNewFile, fn ) < 0 ) | 414 | if ( ::rename( strNewFile, fn ) < 0 ) |
418 | qWarning( "problem renaming file %s to %s errno %d", | 415 | qWarning( "problem renaming file %s to %s errno %d", |
419 | strNewFile.latin1(), fn.latin1(), errno ); | 416 | strNewFile.latin1(), fn.latin1(), errno ); |
420 | 417 | ||
421 | // remove the journal | 418 | // remove the journal |
422 | QFile::remove( journalFileName() ); | 419 | QFile::remove( journalFileName() ); |
423 | return true; | 420 | return true; |
424 | } | 421 | } |
425 | 422 | ||
426 | void TodoTable::load( const QString &fn ) | 423 | void TodoTable::load( const QString &fn ) |
427 | { | 424 | { |
428 | if ( QFile::exists(journalFileName()) ) { | 425 | if ( QFile::exists(journalFileName()) ) { |
429 | applyJournal(); | 426 | applyJournal(); |
430 | QFile::remove(journalFileName() ); | 427 | QFile::remove(journalFileName() ); |
431 | } | 428 | } |
432 | loadFile( fn ); | 429 | loadFile( fn ); |
433 | // QTable::sortColumn(2,TRUE,TRUE); | 430 | // QTable::sortColumn(2,TRUE,TRUE); |
434 | // QTable::sortColumn(1,TRUE,TRUE); | 431 | // QTable::sortColumn(1,TRUE,TRUE); |
435 | QTable::sortColumn(0,TRUE,TRUE); | 432 | QTable::sortColumn(0,TRUE,TRUE); |
436 | setCurrentCell( 0, 2 ); | 433 | setCurrentCell( 0, 2 ); |
437 | setSorting(true ); | 434 | setSorting(true ); |
438 | mDayTimer->start( 60 * 1000 ); // gone in 60 seconds? | 435 | mDayTimer->start( 60 * 1000 ); // gone in 60 seconds? |
439 | } | 436 | } |
440 | void TodoTable::updateVisible() | 437 | void TodoTable::updateVisible() |
441 | { | 438 | { |
442 | if ( !isUpdatesEnabled() ) | 439 | if ( !isUpdatesEnabled() ) |
443 | return; | 440 | return; |
444 | 441 | ||
445 | if (showDeadl){ | 442 | if (showDeadl){ |
446 | showColumn (3); | 443 | showColumn (3); |
447 | adjustColumn(3); | 444 | adjustColumn(3); |
448 | }else{ | 445 | }else{ |
449 | hideColumn (3); | 446 | hideColumn (3); |
450 | adjustColumn(2); | 447 | adjustColumn(2); |
451 | } | 448 | } |
452 | 449 | ||
453 | int visible = 0; | 450 | int visible = 0; |
454 | int id = mCat.id( "Todo List", showCat ); | 451 | int id = mCat.id( "Todo List", showCat ); |
455 | for ( int row = 0; row < numRows(); row++ ) { | 452 | for ( int row = 0; row < numRows(); row++ ) { |
456 | CheckItem *ci = (CheckItem *)item( row, 0 ); | 453 | CheckItem *ci = (CheckItem *)item( row, 0 ); |
457 | ToDoEvent *t = todoList[ci]; | 454 | ToDoEvent *t = todoList[ci]; |
458 | QArray<int> vlCats = t->categories(); | 455 | QArray<int> vlCats = t->categories(); |
459 | bool hide = false; | 456 | bool hide = false; |
460 | if ( !showComp && ci->isChecked() ) | 457 | if ( !showComp && ci->isChecked() ) |
461 | hide = true; | 458 | hide = true; |
462 | if ( !showCat.isEmpty() ) { | 459 | if ( !showCat.isEmpty() ) { |
463 | if ( showCat == tr( "Unfiled" ) ) { | 460 | if ( showCat == tr( "Unfiled" ) ) { |
464 | if ( vlCats.count() > 0 ) | 461 | if ( vlCats.count() > 0 ) |
465 | hide = true; | 462 | hide = true; |
466 | } else { | 463 | } else { |
467 | // do some comparing, we have to reverse our idea here... which idea? - zecke | 464 | // do some comparing, we have to reverse our idea here... which idea? - zecke |
468 | if ( !hide ) { | 465 | if ( !hide ) { |
469 | hide = true; | 466 | hide = true; |
470 | for ( uint it = 0; it < vlCats.count(); ++it ) { | 467 | for ( uint it = 0; it < vlCats.count(); ++it ) { |
471 | if ( vlCats[it] == id ) { | 468 | if ( vlCats[it] == id ) { |
472 | hide = false; | 469 | hide = false; |
473 | break; | 470 | break; |
474 | } | 471 | } |
475 | } | 472 | } |
476 | } | 473 | } |
477 | } | 474 | } |
478 | } | 475 | } |
479 | if ( hide ) { | 476 | if ( hide ) { |
480 | if ( currentRow() == row ) | 477 | if ( currentRow() == row ) |
481 | setCurrentCell( -1, 0 ); | 478 | setCurrentCell( -1, 0 ); |
482 | if ( rowHeight( row ) > 0 ) | 479 | if ( rowHeight( row ) > 0 ) |
483 | hideRow( row ); | 480 | hideRow( row ); |
484 | } else { | 481 | } else { |
485 | if ( rowHeight( row ) == 0 ) { | 482 | if ( rowHeight( row ) == 0 ) { |
486 | showRow( row ); | 483 | showRow( row ); |
487 | adjustRow( row ); | 484 | adjustRow( row ); |
488 | } | 485 | } |
489 | visible++; | 486 | visible++; |
490 | } | 487 | } |
491 | } | 488 | } |
492 | if ( !visible ) | 489 | if ( !visible ) |
493 | setCurrentCell( -1, 0 ); | 490 | setCurrentCell( -1, 0 ); |
494 | } | 491 | } |
495 | 492 | ||
496 | void TodoTable::viewportPaintEvent( QPaintEvent *pe ) | 493 | void TodoTable::viewportPaintEvent( QPaintEvent *pe ) |
497 | { | 494 | { |
498 | if ( enablePainting ) | 495 | if ( enablePainting ) |
499 | QTable::viewportPaintEvent( pe ); | 496 | QTable::viewportPaintEvent( pe ); |
500 | } | 497 | } |
501 | 498 | ||
502 | void TodoTable::setPaintingEnabled( bool e ) | 499 | void TodoTable::setPaintingEnabled( bool e ) |
503 | { | 500 | { |
504 | if ( e != enablePainting ) { | 501 | if ( e != enablePainting ) { |
505 | if ( !enablePainting ) { | 502 | if ( !enablePainting ) { |
506 | enablePainting = true; | 503 | enablePainting = true; |
507 | rowHeightChanged( 0 ); | 504 | rowHeightChanged( 0 ); |
508 | viewport()->update(); | 505 | viewport()->update(); |
509 | } else { | 506 | } else { |
510 | enablePainting = false; | 507 | enablePainting = false; |
511 | } | 508 | } |
512 | } | 509 | } |
513 | } | 510 | } |
514 | 511 | ||
515 | void TodoTable::clear() | 512 | void TodoTable::clear() |
516 | { | 513 | { |
517 | for ( QMap<CheckItem*, ToDoEvent *>::Iterator it = todoList.begin(); | 514 | for ( QMap<CheckItem*, ToDoEvent *>::Iterator it = todoList.begin(); |
518 | it != todoList.end(); ++it ) { | 515 | it != todoList.end(); ++it ) { |
519 | ToDoEvent *todo = it.data(); | 516 | ToDoEvent *todo = it.data(); |
520 | updateJournal( *todo, ACTION_REMOVE ); | 517 | updateJournal( *todo, ACTION_REMOVE ); |
521 | delete todo; | 518 | delete todo; |
522 | } | 519 | } |
523 | todoList.clear(); | 520 | todoList.clear(); |
524 | for ( int r = 0; r < numRows(); ++r ) { | 521 | for ( int r = 0; r < numRows(); ++r ) { |
525 | for ( int c = 0; c < numCols(); ++c ) { | 522 | for ( int c = 0; c < numCols(); ++c ) { |
526 | if ( cellWidget( r, c ) ) | 523 | if ( cellWidget( r, c ) ) |
527 | clearCellWidget( r, c ); | 524 | clearCellWidget( r, c ); |
528 | clearCell( r, c ); | 525 | clearCell( r, c ); |
529 | } | 526 | } |
530 | } | 527 | } |
531 | setNumRows( 0 ); | 528 | setNumRows( 0 ); |
532 | } | 529 | } |
533 | 530 | ||
534 | void TodoTable::sortColumn( int col, bool ascending, bool /*wholeRows*/ ) | 531 | void TodoTable::sortColumn( int col, bool ascending, bool /*wholeRows*/ ) |
535 | { | 532 | { |
536 | // The default for wholeRows is false, however | 533 | // The default for wholeRows is false, however |
537 | // for this todo table we want to exchange complete | 534 | // for this todo table we want to exchange complete |
538 | // rows when sorting. Also, we always want ascending, since | 535 | // rows when sorting. Also, we always want ascending, since |
539 | // the values have a logical order. | 536 | // the values have a logical order. |
540 | QTable::sortColumn( col, ascending, TRUE ); | 537 | QTable::sortColumn( col, ascending, TRUE ); |
541 | updateVisible(); | 538 | updateVisible(); |
542 | } | 539 | } |
543 | 540 | ||
544 | void TodoTable::slotCheckPriority(int row, int col ) | 541 | void TodoTable::slotCheckPriority(int row, int col ) |
545 | { | 542 | { |
546 | // kludgey work around to make forward along the updated priority... | 543 | // kludgey work around to make forward along the updated priority... |
547 | if ( col == 1 ) { | 544 | if ( col == 1 ) { |
548 | // let everyone know!! | 545 | // let everyone know!! |
549 | ComboItem* i = static_cast<ComboItem*>( item( row, col ) ); | 546 | ComboItem* i = static_cast<ComboItem*>( item( row, col ) ); |
550 | emit signalPriorityChanged( i->text().toInt() ); | 547 | emit signalPriorityChanged( i->text().toInt() ); |
551 | } | 548 | } |
552 | } | 549 | } |
553 | 550 | ||
554 | 551 | ||
555 | void TodoTable::updateJournal( const ToDoEvent &todo, journal_action action ) | 552 | void TodoTable::updateJournal( const ToDoEvent &todo, journal_action action ) |
556 | { | 553 | { |
557 | QFile f( journalFileName() ); | 554 | QFile f( journalFileName() ); |
558 | if ( !f.open(IO_WriteOnly|IO_Append) ) | 555 | if ( !f.open(IO_WriteOnly|IO_Append) ) |
559 | return; | 556 | return; |
560 | QString buf; | 557 | QString buf; |
561 | QCString str; | 558 | QCString str; |
562 | buf = "<Task"; | 559 | buf = "<Task"; |
563 | // todo.save( buf ); | 560 | // todo.save( buf ); |
564 | buf += " Action=\"" + QString::number( int(action) ) + "\""; | 561 | buf += " Action=\"" + QString::number( int(action) ) + "\""; |
565 | buf += " Uid=\"" + QString::number( todo.uid() ) + "\""; // better write the id | 562 | buf += " Uid=\"" + QString::number( todo.uid() ) + "\""; // better write the id |
566 | buf += " Completed=\""+ QString::number((int)todo.isCompleted() ) + "\""; | 563 | buf += " Completed=\""+ QString::number((int)todo.isCompleted() ) + "\""; |
567 | buf += " HasDate=\""+ QString::number((int)todo.hasDate() ) +"\""; | 564 | buf += " HasDate=\""+ QString::number((int)todo.hasDate() ) +"\""; |
568 | buf += " Priority=\"" + QString::number( todo.priority() ) + "\""; | 565 | buf += " Priority=\"" + QString::number( todo.priority() ) + "\""; |
569 | QArray<int> arrat = todo.categories(); | 566 | QArray<int> arrat = todo.categories(); |
570 | QString attr; | 567 | QString attr; |
571 | for(uint i=0; i < arrat.count(); i++ ){ | 568 | for(uint i=0; i < arrat.count(); i++ ){ |
572 | attr.append(QString::number(arrat[i])+";" ); | 569 | attr.append(QString::number(arrat[i])+";" ); |
573 | } | 570 | } |
574 | if(!attr.isEmpty() ) // remove the last ; | 571 | if(!attr.isEmpty() ) // remove the last ; |
575 | attr.remove(attr.length()-1, 1 ); | 572 | attr.remove(attr.length()-1, 1 ); |
576 | buf += " Categories=\"" + attr + "\""; | 573 | buf += " Categories=\"" + attr + "\""; |
577 | buf += " Description=\"" + todo.description() + "\""; | 574 | buf += " Description=\"" + todo.description() + "\""; |
578 | if(todo.hasDate() ) { | 575 | if(todo.hasDate() ) { |
579 | buf += " DateYear=\""+QString::number( todo.date().year() ) + "\""; | 576 | buf += " DateYear=\""+QString::number( todo.date().year() ) + "\""; |
580 | buf += " DateMonth=\"" + QString::number( todo.date().month() ) + "\""; | 577 | buf += " DateMonth=\"" + QString::number( todo.date().month() ) + "\""; |
581 | buf += " DateDay=\"" + QString::number( todo.date().day() ) + "\""; | 578 | buf += " DateDay=\"" + QString::number( todo.date().day() ) + "\""; |
582 | } | 579 | } |
583 | buf += "/>\n"; | 580 | buf += "/>\n"; |
584 | str = buf.utf8(); | 581 | str = buf.utf8(); |
585 | f.writeBlock( str.data(), str.length() ); | 582 | f.writeBlock( str.data(), str.length() ); |
586 | f.close(); | 583 | f.close(); |
587 | } | 584 | } |
588 | 585 | ||
589 | void TodoTable::rowHeightChanged( int row ) | 586 | void TodoTable::rowHeightChanged( int row ) |
590 | { | 587 | { |
591 | if ( enablePainting ) | 588 | if ( enablePainting ) |
592 | QTable::rowHeightChanged( row ); | 589 | QTable::rowHeightChanged( row ); |
593 | } | 590 | } |
594 | 591 | ||
595 | void TodoTable::loadFile( const QString &/*we use the standard*/ ) | 592 | void TodoTable::loadFile( const QString &/*we use the standard*/ ) |
596 | { | 593 | { |
597 | 594 | ||
598 | QList<ToDoEvent> list; | 595 | QList<ToDoEvent> list; |
599 | ToDoDB todoDB; | 596 | ToDoDB todoDB; |
600 | QValueList<ToDoEvent> vaList = todoDB.rawToDos(); | 597 | QValueList<ToDoEvent> vaList = todoDB.rawToDos(); |
601 | for(QValueList<ToDoEvent>::ConstIterator it = vaList.begin(); it != vaList.end(); ++it ){ | 598 | for(QValueList<ToDoEvent>::ConstIterator it = vaList.begin(); it != vaList.end(); ++it ){ |
602 | ToDoEvent *event = new ToDoEvent( (*it) ); | 599 | ToDoEvent *event = new ToDoEvent( (*it) ); |
603 | list.append( event ); | 600 | list.append( event ); |
604 | } | 601 | } |
605 | vaList.clear(); | 602 | vaList.clear(); |
606 | // qDebug("parsing done=%d", t.elapsed() ); | 603 | // qDebug("parsing done=%d", t.elapsed() ); |
607 | if ( list.count() > 0 ) { | 604 | if ( list.count() > 0 ) { |
608 | internalAddEntries( list ); | 605 | internalAddEntries( list ); |
609 | list.clear(); | 606 | list.clear(); |
610 | } | 607 | } |
611 | // qDebug("loading done: t=%d", t.elapsed() ); | 608 | // qDebug("loading done: t=%d", t.elapsed() ); |
612 | } | 609 | } |
613 | 610 | ||
614 | void TodoTable::journalFreeReplaceEntry( const ToDoEvent &todo, int row ) | 611 | void TodoTable::journalFreeReplaceEntry( const ToDoEvent &todo, int row ) |
615 | { | 612 | { |
616 | QString strTodo; | 613 | QString strTodo; |
617 | strTodo = todo.description().left(40).simplifyWhiteSpace(); | 614 | strTodo = todo.description().left(40).simplifyWhiteSpace(); |
618 | if ( row == -1 ) { | 615 | if ( row == -1 ) { |
619 | QMapIterator<CheckItem*, ToDoEvent *> it; | 616 | QMapIterator<CheckItem*, ToDoEvent *> it; |
620 | for ( it = todoList.begin(); it != todoList.end(); ++it ) { | 617 | for ( it = todoList.begin(); it != todoList.end(); ++it ) { |
621 | if ( *(*it) == todo ) { | 618 | if ( *(*it) == todo ) { |
622 | row = it.key()->row(); | 619 | row = it.key()->row(); |
623 | it.key()->setChecked( todo.isCompleted() ); | 620 | it.key()->setChecked( todo.isCompleted() ); |
624 | static_cast<ComboItem*>(item(row, 1))->setText( QString::number(todo.priority()) ); | 621 | static_cast<ComboItem*>(item(row, 1))->setText( QString::number(todo.priority()) ); |
625 | item( row, 2 )->setText( strTodo ); | 622 | item( row, 2 )->setText( strTodo ); |
626 | 623 | ||
627 | if (showDeadl){ | 624 | if (showDeadl){ |
628 | static_cast<DueTextItem*>(item(row,3))->setToDoEvent(&todo ); | 625 | static_cast<DueTextItem*>(item(row,3))->setToDoEvent(&todo ); |
629 | } | 626 | } |
630 | 627 | ||
631 | *(*it) = todo; | 628 | *(*it) = todo; |
632 | } | 629 | } |
633 | } | 630 | } |
634 | } else { | 631 | } else { |
635 | ToDoEvent *t = todoList[static_cast<CheckItem*>(item(row, 0))]; | 632 | ToDoEvent *t = todoList[static_cast<CheckItem*>(item(row, 0))]; |
636 | todoList.remove( static_cast<CheckItem*>(item(row, 0)) ); | 633 | todoList.remove( static_cast<CheckItem*>(item(row, 0)) ); |
637 | delete t; | 634 | delete t; |
638 | static_cast<CheckItem*>(item(row, 0))->setChecked( todo.isCompleted() ); | 635 | static_cast<CheckItem*>(item(row, 0))->setChecked( todo.isCompleted() ); |
639 | static_cast<ComboItem*>(item(row, 1))->setText( QString::number(todo.priority()) ); | 636 | static_cast<ComboItem*>(item(row, 1))->setText( QString::number(todo.priority()) ); |
640 | item( row, 2 )->setText( strTodo ); | 637 | item( row, 2 )->setText( strTodo ); |
641 | 638 | ||
642 | if (showDeadl){ | 639 | if (showDeadl){ |
643 | static_cast<DueTextItem*>(item(row,3))->setToDoEvent(&todo ); | 640 | static_cast<DueTextItem*>(item(row,3))->setToDoEvent(&todo ); |
644 | } | 641 | } |
645 | todoList.insert( static_cast<CheckItem*>(item(row,0)), new ToDoEvent(todo) ); | 642 | todoList.insert( static_cast<CheckItem*>(item(row,0)), new ToDoEvent(todo) ); |
646 | } | 643 | } |
647 | } | 644 | } |
648 | 645 | ||
649 | void TodoTable::journalFreeRemoveEntry( int row ) | 646 | void TodoTable::journalFreeRemoveEntry( int row ) |
650 | { | 647 | { |
651 | CheckItem *chk; | 648 | CheckItem *chk; |
652 | chk = static_cast<CheckItem*>(item(row, 0 )); | 649 | chk = static_cast<CheckItem*>(item(row, 0 )); |
653 | if ( !chk ) | 650 | if ( !chk ) |
654 | return; | 651 | return; |
655 | todoList.remove( chk ); | 652 | todoList.remove( chk ); |
656 | 653 | ||
657 | realignTable( row ); | 654 | realignTable( row ); |
658 | } | 655 | } |
659 | 656 | ||
660 | void TodoTable::keyPressEvent( QKeyEvent *e ) | 657 | void TodoTable::keyPressEvent( QKeyEvent *e ) |
661 | { | 658 | { |
662 | if ( e->key() == Key_Space || e->key() == Key_Return ) { | 659 | if ( e->key() == Key_Space || e->key() == Key_Return ) { |
663 | switch ( currentColumn() ) { | 660 | switch ( currentColumn() ) { |
664 | case 0: { | 661 | case 0: { |
665 | CheckItem *i = static_cast<CheckItem*>(item(currentRow(), | 662 | CheckItem *i = static_cast<CheckItem*>(item(currentRow(), |
666 | currentColumn())); | 663 | currentColumn())); |
667 | if ( i ) | 664 | if ( i ) |
668 | i->toggle(); | 665 | i->toggle(); |
669 | break; | 666 | break; |
670 | } | 667 | } |
671 | case 1: | 668 | case 1: |
672 | break; | 669 | break; |
673 | case 2: | 670 | case 2:{ |
674 | emit signalEdit(); | 671 | ToDoEvent *todo = todoList[static_cast<CheckItem*>(item(currentRow(), 0))]; |
675 | default: | 672 | emit showDetails(*todo); |
676 | break; | 673 | break; |
677 | } | 674 | } |
678 | } else { | 675 | case 3: |
679 | QTable::keyPressEvent( e ); | 676 | // Future: Let us change the dueDate directly... |
680 | } | 677 | emit signalEdit(); |
678 | default: | ||
679 | break; | ||
680 | } | ||
681 | } else | ||
682 | QTable::keyPressEvent( e ); | ||
681 | } | 683 | } |
682 | 684 | ||
685 | |||
683 | QStringList TodoTable::categories() | 686 | QStringList TodoTable::categories() |
684 | { | 687 | { |
685 | // This is called seldom, so calling a load in here | 688 | // This is called seldom, so calling a load in here |
686 | // should be fine. | 689 | // should be fine. |
687 | mCat.load( categoryFileName() ); | 690 | mCat.load( categoryFileName() ); |
688 | QStringList categoryList = mCat.labels( "Todo List" ); | 691 | QStringList categoryList = mCat.labels( "Todo List" ); |
689 | return categoryList; | 692 | return categoryList; |
690 | } | 693 | } |
691 | 694 | ||
692 | void TodoTable::slotDoFind( const QString &findString, bool caseSensitive, | 695 | void TodoTable::slotDoFind( const QString &findString, bool caseSensitive, |
693 | bool backwards, int category ) | 696 | bool backwards, int category ) |
694 | { | 697 | { |
695 | // we have to iterate through the table, this gives the illusion that | 698 | // we have to iterate through the table, this gives the illusion that |
696 | // sorting is actually being used. | 699 | // sorting is actually being used. |
697 | if ( currFindRow < -1 ) | 700 | if ( currFindRow < -1 ) |
698 | currFindRow = currentRow() - 1; | 701 | currFindRow = currentRow() - 1; |
699 | clearSelection( TRUE ); | 702 | clearSelection( TRUE ); |
700 | int rows, | 703 | int rows, |
701 | row; | 704 | row; |
702 | CheckItem *chk; | 705 | CheckItem *chk; |
703 | QRegExp r( findString ); | 706 | QRegExp r( findString ); |
704 | 707 | ||
705 | r.setCaseSensitive( caseSensitive ); | 708 | r.setCaseSensitive( caseSensitive ); |
706 | rows = numRows(); | 709 | rows = numRows(); |
707 | static bool wrapAround = true; | 710 | static bool wrapAround = true; |
708 | 711 | ||
709 | if ( !backwards ) { | 712 | if ( !backwards ) { |
710 | for ( row = currFindRow + 1; row < rows; row++ ) { | 713 | for ( row = currFindRow + 1; row < rows; row++ ) { |
711 | chk = static_cast<CheckItem*>( item(row, 0) ); | 714 | chk = static_cast<CheckItem*>( item(row, 0) ); |
712 | if ( taskCompare(*(todoList[chk]), r, category) ) | 715 | if ( taskCompare(*(todoList[chk]), r, category) ) |
713 | break; | 716 | break; |
714 | } | 717 | } |
715 | } else { | 718 | } else { |
716 | for ( row = currFindRow - 1; row > -1; row-- ) { | 719 | for ( row = currFindRow - 1; row > -1; row-- ) { |
717 | chk = static_cast<CheckItem*>( item(row, 0) ); | 720 | chk = static_cast<CheckItem*>( item(row, 0) ); |
718 | if ( taskCompare(*(todoList[chk]), r, category) ) | 721 | if ( taskCompare(*(todoList[chk]), r, category) ) |
719 | break; | 722 | break; |
720 | } | 723 | } |
721 | } | 724 | } |
722 | if ( row >= rows || row < 0 ) { | 725 | if ( row >= rows || row < 0 ) { |
723 | if ( row < 0 ) | 726 | if ( row < 0 ) |
724 | currFindRow = rows; | 727 | currFindRow = rows; |
725 | else | 728 | else |
726 | currFindRow = -1; | 729 | currFindRow = -1; |
727 | if ( wrapAround ) | 730 | if ( wrapAround ) |
728 | emit signalWrapAround(); | 731 | emit signalWrapAround(); |
729 | else | 732 | else |
730 | emit signalNotFound(); | 733 | emit signalNotFound(); |
731 | wrapAround = !wrapAround; | 734 | wrapAround = !wrapAround; |
732 | } else { | 735 | } else { |
733 | currFindRow = row; | 736 | currFindRow = row; |
734 | QTableSelection foundSelection; | 737 | QTableSelection foundSelection; |
735 | foundSelection.init( currFindRow, 0 ); | 738 | foundSelection.init( currFindRow, 0 ); |
736 | foundSelection.expandTo( currFindRow, numCols() - 1 ); | 739 | foundSelection.expandTo( currFindRow, numCols() - 1 ); |
737 | addSelection( foundSelection ); | 740 | addSelection( foundSelection ); |
738 | setCurrentCell( currFindRow, numCols() - 1 ); | 741 | setCurrentCell( currFindRow, numCols() - 1 ); |
739 | // we should always be able to wrap around and find this again, | 742 | // we should always be able to wrap around and find this again, |
740 | // so don't give confusing not found message... | 743 | // so don't give confusing not found message... |
741 | wrapAround = true; | 744 | wrapAround = true; |
742 | } | 745 | } |
743 | } | 746 | } |
744 | 747 | ||
745 | int TodoTable::showCategoryId() const | 748 | int TodoTable::showCategoryId() const |
746 | { | 749 | { |
747 | int id; | 750 | int id; |
748 | id = -1; | 751 | id = -1; |
749 | // if allcategories are selected, you get unfiled... | 752 | // if allcategories are selected, you get unfiled... |
750 | if ( showCat != tr( "Unfiled" ) && showCat != tr( "All" ) ) | 753 | if ( showCat != tr( "Unfiled" ) && showCat != tr( "All" ) ) |
751 | id = mCat.id( "Todo List", showCat ); | 754 | id = mCat.id( "Todo List", showCat ); |
752 | return id; | 755 | return id; |
753 | } | 756 | } |
754 | void TodoTable::applyJournal() | 757 | void TodoTable::applyJournal() |
755 | { | 758 | { |
756 | // we need to hack | 759 | // we need to hack |
757 | QFile file( journalFileName() ); | 760 | QFile file( journalFileName() ); |
758 | if( file.open(IO_ReadOnly ) ) { | 761 | if( file.open(IO_ReadOnly ) ) { |
759 | QByteArray ar = file.readAll(); | 762 | QByteArray ar = file.readAll(); |
760 | file.close(); | 763 | file.close(); |
761 | QFile file2( journalFileName() + "_new" ); | 764 | QFile file2( journalFileName() + "_new" ); |
762 | if( file2.open(IO_WriteOnly ) ){ | 765 | if( file2.open(IO_WriteOnly ) ){ |
763 | QTextStream str(&file2 ); | 766 | QTextStream str(&file2 ); |
764 | str << QString::fromLatin1("<Tasks>") << endl; | 767 | str << QString::fromLatin1("<Tasks>") << endl; |
765 | str << ar.data(); | 768 | str << ar.data(); |
766 | str << QString::fromLatin1("</Tasks>") << endl; | 769 | str << QString::fromLatin1("</Tasks>") << endl; |
767 | file2.close(); | 770 | file2.close(); |
768 | } | 771 | } |
769 | XMLElement *root = XMLElement::load(journalFileName()+ "_new"); | 772 | XMLElement *root = XMLElement::load(journalFileName()+ "_new"); |
770 | XMLElement *el = root->firstChild(); | 773 | XMLElement *el = root->firstChild(); |
771 | el = el->firstChild(); | 774 | el = el->firstChild(); |
772 | ToDoDB tododb; // allready loaded ;) | 775 | ToDoDB tododb; // allready loaded ;) |
773 | bool ok; | 776 | bool ok; |
774 | int action; | 777 | int action; |
775 | QString dummy; | 778 | QString dummy; |
776 | while( el ){ | 779 | while( el ){ |
777 | dummy = el->attribute("Action" ); | 780 | dummy = el->attribute("Action" ); |
778 | action = dummy.toInt(&ok ); | 781 | action = dummy.toInt(&ok ); |
779 | ToDoEvent ev = xmlToEvent( el ); | 782 | ToDoEvent ev = xmlToEvent( el ); |
780 | if(ok ){ | 783 | if(ok ){ |
781 | switch( action){ | 784 | switch( action){ |
782 | case ACTION_ADD: | 785 | case ACTION_ADD: |
783 | tododb.addEvent(ev ); | 786 | tododb.addEvent(ev ); |
784 | break; | 787 | break; |
785 | case ACTION_REMOVE: | 788 | case ACTION_REMOVE: |
786 | tododb.removeEvent( ev ); | 789 | tododb.removeEvent( ev ); |
787 | break; | 790 | break; |
788 | case ACTION_REPLACE: | 791 | case ACTION_REPLACE: |
789 | tododb.replaceEvent( ev ); | 792 | tododb.replaceEvent( ev ); |
790 | break; | 793 | break; |
791 | } | 794 | } |
792 | } | 795 | } |
793 | el = el->nextChild(); | 796 | el = el->nextChild(); |
794 | } | 797 | } |
795 | QFile::remove(journalFileName()+ "_new" ); | 798 | QFile::remove(journalFileName()+ "_new" ); |
796 | tododb.save(); | 799 | tododb.save(); |
797 | } | 800 | } |
798 | } | 801 | } |
799 | void TodoTable::slotCheckDay() | 802 | void TodoTable::slotCheckDay() |
800 | { | 803 | { |
801 | QDate date = QDate::currentDate(); | 804 | QDate date = QDate::currentDate(); |
802 | if( mDay.daysTo(date )!= 0 ){ | 805 | if( mDay.daysTo(date )!= 0 ){ |
803 | setPaintingEnabled( FALSE ); | 806 | setPaintingEnabled( FALSE ); |
804 | for(int i=0; i < numRows(); i++ ){ | 807 | for(int i=0; i < numRows(); i++ ){ |
805 | ToDoEvent *t = todoList[static_cast<CheckItem*>(item(i, 0))]; | 808 | ToDoEvent *t = todoList[static_cast<CheckItem*>(item(i, 0))]; |
806 | static_cast<DueTextItem*>(item(i, 3) )->setToDoEvent( t ); | 809 | static_cast<DueTextItem*>(item(i, 3) )->setToDoEvent( t ); |
807 | 810 | ||
808 | } | 811 | } |
809 | setPaintingEnabled( TRUE ); | 812 | setPaintingEnabled( TRUE ); |
810 | mDay = date; | 813 | mDay = date; |
811 | } | 814 | } |
812 | mDayTimer->start( 60 * 1000 ); // 60 seconds | 815 | mDayTimer->start( 60 * 1000 ); // 60 seconds |
813 | } | 816 | } |
814 | // check Action and decide | 817 | // check Action and decide |
815 | /* | 818 | /* |
816 | void TodoTable::doApply(XMLElement *el ) | 819 | void TodoTable::doApply(XMLElement *el ) |
817 | { | 820 | { |
818 | QString dummy; | 821 | QString dummy; |
819 | bool ok; | 822 | bool ok; |
820 | int action; | 823 | int action; |
821 | dummy = el->attribute("Action" ); | 824 | dummy = el->attribute("Action" ); |
822 | action = dummy.toInt(&ok ); | 825 | action = dummy.toInt(&ok ); |
823 | ToDoEvent ev = xmlToEvent( el ); | 826 | ToDoEvent ev = xmlToEvent( el ); |
824 | if( ok ){ | 827 | if( ok ){ |
825 | switch( action ){ | 828 | switch( action ){ |
826 | case ACTION_ADD: | 829 | case ACTION_ADD: |
827 | addEntry( ev ); | 830 | addEntry( ev ); |
828 | break; | 831 | break; |
829 | case ACTION_REMOVE:{ // find an entry with the same uid and remove it then | 832 | case ACTION_REMOVE:{ // find an entry with the same uid and remove it then |
830 | break; | 833 | break; |
831 | } | 834 | } |
832 | case ACTION_REPLACE: | 835 | case ACTION_REPLACE: |
833 | break; | 836 | break; |
834 | } | 837 | } |
835 | } | 838 | } |
836 | } | 839 | } |
837 | */ | 840 | */ |
838 | namespace { | 841 | namespace { |
839 | static bool taskCompare( const ToDoEvent &task, const QRegExp &r, int category ) | 842 | static bool taskCompare( const ToDoEvent &task, const QRegExp &r, int category ) |
840 | { | 843 | { |
841 | bool returnMe; | 844 | bool returnMe; |
842 | QArray<int> cats; | 845 | QArray<int> cats; |
843 | cats = task.categories(); | 846 | cats = task.categories(); |
844 | 847 | ||
845 | returnMe = false; | 848 | returnMe = false; |
846 | if ( (category == -1 && cats.count() == 0) || category == -2 ) | 849 | if ( (category == -1 && cats.count() == 0) || category == -2 ) |
847 | returnMe = task.match( r ); | 850 | returnMe = task.match( r ); |
848 | else { | 851 | else { |
849 | int i; | 852 | int i; |
850 | for ( i = 0; i < int(cats.count()); i++ ) { | 853 | for ( i = 0; i < int(cats.count()); i++ ) { |
851 | if ( cats[i] == category ) { | 854 | if ( cats[i] == category ) { |
852 | returnMe = task.match( r ); | 855 | returnMe = task.match( r ); |
853 | break; | 856 | break; |
854 | } | 857 | } |
855 | } | 858 | } |
856 | } | 859 | } |
857 | return returnMe; | 860 | return returnMe; |
858 | } | 861 | } |
859 | 862 | ||
860 | static QString journalFileName() | 863 | static QString journalFileName() |
861 | { | 864 | { |
862 | QString str; | 865 | QString str; |
863 | str = getenv( "HOME" ); | 866 | str = getenv( "HOME" ); |
864 | str += "/.opie_todojournal"; | 867 | str += "/.opie_todojournal"; |
865 | return str; | 868 | return str; |
866 | } | 869 | } |
867 | static ToDoEvent xmlToEvent( XMLElement *element ) | 870 | static ToDoEvent xmlToEvent( XMLElement *element ) |
868 | { | 871 | { |
869 | QString dummy; | 872 | QString dummy; |
870 | ToDoEvent event; | 873 | ToDoEvent event; |
871 | bool ok; | 874 | bool ok; |
872 | int dumInt; | 875 | int dumInt; |
873 | // completed | 876 | // completed |
874 | dummy = element->attribute("Completed" ); | 877 | dummy = element->attribute("Completed" ); |
875 | dumInt = dummy.toInt(&ok ); | 878 | dumInt = dummy.toInt(&ok ); |
876 | if(ok ) event.setCompleted( dumInt == 0 ? false : true ); | 879 | if(ok ) event.setCompleted( dumInt == 0 ? false : true ); |
877 | // hasDate | 880 | // hasDate |
878 | dummy = element->attribute("HasDate" ); | 881 | dummy = element->attribute("HasDate" ); |
879 | dumInt = dummy.toInt(&ok ); | 882 | dumInt = dummy.toInt(&ok ); |
880 | if(ok ) event.setHasDate( dumInt == 0 ? false: true ); | 883 | if(ok ) event.setHasDate( dumInt == 0 ? false: true ); |
881 | // set the date | 884 | // set the date |
882 | bool hasDa = dumInt; | 885 | bool hasDa = dumInt; |
883 | if ( hasDa ) { //parse the date | 886 | if ( hasDa ) { //parse the date |
884 | int year, day, month = 0; | 887 | int year, day, month = 0; |
885 | year = day = month; | 888 | year = day = month; |
886 | // year | 889 | // year |
887 | dummy = element->attribute("DateYear" ); | 890 | dummy = element->attribute("DateYear" ); |
888 | dumInt = dummy.toInt(&ok ); | 891 | dumInt = dummy.toInt(&ok ); |
889 | if( ok ) year = dumInt; | 892 | if( ok ) year = dumInt; |
890 | // month | 893 | // month |
891 | dummy = element->attribute("DateMonth" ); | 894 | dummy = element->attribute("DateMonth" ); |
892 | dumInt = dummy.toInt(&ok ); | 895 | dumInt = dummy.toInt(&ok ); |
893 | if(ok ) month = dumInt; | 896 | if(ok ) month = dumInt; |
894 | dummy = element->attribute("DateDay" ); | 897 | dummy = element->attribute("DateDay" ); |
895 | dumInt = dummy.toInt(&ok ); | 898 | dumInt = dummy.toInt(&ok ); |
896 | if(ok ) day = dumInt; | 899 | if(ok ) day = dumInt; |
897 | // set the date | 900 | // set the date |
898 | QDate date( year, month, day ); | 901 | QDate date( year, month, day ); |
899 | event.setDate( date); | 902 | event.setDate( date); |
900 | } | 903 | } |
901 | dummy = element->attribute("Priority" ); | 904 | dummy = element->attribute("Priority" ); |
902 | dumInt = dummy.toInt(&ok ); | 905 | dumInt = dummy.toInt(&ok ); |
903 | if(!ok ) dumInt = ToDoEvent::NORMAL; | 906 | if(!ok ) dumInt = ToDoEvent::NORMAL; |
904 | event.setPriority( dumInt ); | 907 | event.setPriority( dumInt ); |
905 | //description | 908 | //description |
906 | dummy = element->attribute("Description" ); | 909 | dummy = element->attribute("Description" ); |
907 | event.setDescription( dummy ); | 910 | event.setDescription( dummy ); |
908 | // category | 911 | // category |
909 | dummy = element->attribute("Categories" ); | 912 | dummy = element->attribute("Categories" ); |
910 | QStringList ids = QStringList::split(";", dummy ); | 913 | QStringList ids = QStringList::split(";", dummy ); |
911 | event.setCategories( ids ); | 914 | event.setCategories( ids ); |
912 | 915 | ||
913 | //uid | 916 | //uid |
914 | dummy = element->attribute("Uid" ); | 917 | dummy = element->attribute("Uid" ); |
915 | dumInt = dummy.toInt(&ok ); | 918 | dumInt = dummy.toInt(&ok ); |
916 | if(ok ) event.setUid( dumInt ); | 919 | if(ok ) event.setUid( dumInt ); |
917 | return event; | 920 | return event; |
918 | } | 921 | } |
919 | 922 | ||
920 | } | 923 | } |
921 | // int TodoTable::rowHeight( int ) const | 924 | // int TodoTable::rowHeight( int ) const |
922 | // { | 925 | // { |
923 | // return 18; | 926 | // return 18; |
924 | // } | 927 | // } |
925 | 928 | ||
926 | // int TodoTable::rowPos( int row ) const | 929 | // int TodoTable::rowPos( int row ) const |
927 | // { | 930 | // { |
928 | // return 18*row; | 931 | // return 18*row; |
929 | // } | 932 | // } |
930 | 933 | ||
931 | // int TodoTable::rowAt( int pos ) const | 934 | // int TodoTable::rowAt( int pos ) const |
932 | // { | 935 | // { |
933 | // return QMIN( pos/18, numRows()-1 ); | 936 | // return QMIN( pos/18, numRows()-1 ); |
934 | // } | 937 | // } |
935 | 938 | ||