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