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