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