-rw-r--r-- | core/pim/todo/mainwindow.cpp | 2 | ||||
-rw-r--r-- | core/pim/todo/todoentry.ui | 370 | ||||
-rw-r--r-- | core/pim/todo/todoentryimpl.cpp | 7 | ||||
-rw-r--r-- | core/pim/todo/todotable.cpp | 11 | ||||
-rw-r--r-- | core/pim/todo/todotable.h | 3 | ||||
-rw-r--r-- | libopie/tododb.cpp | 12 | ||||
-rw-r--r-- | libopie/todoevent.cpp | 43 | ||||
-rw-r--r-- | libopie/todoevent.h | 67 | ||||
-rw-r--r-- | libopie/todovcalresource.cpp | 23 |
9 files changed, 353 insertions, 185 deletions
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp index b7b1da0..1358f1c 100644 --- a/core/pim/todo/mainwindow.cpp +++ b/core/pim/todo/mainwindow.cpp | |||
@@ -1,627 +1,627 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** Copyright (C) 2002 zecke | 3 | ** Copyright (C) 2002 zecke |
4 | ** Copyright (C) 2002 Stefan Eilers (se, eilers.stefan@epost.de) | 4 | ** Copyright (C) 2002 Stefan Eilers (se, eilers.stefan@epost.de) |
5 | ** | 5 | ** |
6 | ** This file is part of Qtopia Environment. | 6 | ** This file is part of Qtopia Environment. |
7 | ** | 7 | ** |
8 | ** This file may be distributed and/or modified under the terms of the | 8 | ** This file may be distributed and/or modified under the terms of the |
9 | ** GNU General Public License version 2 as published by the Free Software | 9 | ** GNU General Public License version 2 as published by the Free Software |
10 | ** Foundation and appearing in the file LICENSE.GPL included in the | 10 | ** Foundation and appearing in the file LICENSE.GPL included in the |
11 | ** packaging of this file. | 11 | ** packaging of this file. |
12 | ** | 12 | ** |
13 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 13 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
14 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 14 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
15 | ** | 15 | ** |
16 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 16 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
17 | ** | 17 | ** |
18 | ** Contact info@trolltech.com if any conditions of this licensing are | 18 | ** Contact info@trolltech.com if any conditions of this licensing are |
19 | ** not clear to you. | 19 | ** not clear to you. |
20 | ** | 20 | ** |
21 | **********************************************************************/ | 21 | **********************************************************************/ |
22 | 22 | ||
23 | #define QTOPIA_INTERNAL_FD | 23 | #define QTOPIA_INTERNAL_FD |
24 | 24 | ||
25 | #include "mainwindow.h" | 25 | #include "mainwindow.h" |
26 | #include "todoentryimpl.h" | 26 | #include "todoentryimpl.h" |
27 | #include "todotable.h" | 27 | #include "todotable.h" |
28 | #include "todolabel.h" | 28 | #include "todolabel.h" |
29 | 29 | ||
30 | #include <opie/tododb.h> | 30 | #include <opie/tododb.h> |
31 | #include <opie/todovcalresource.h> | 31 | #include <opie/todovcalresource.h> |
32 | #include <opie/ofontmenu.h> | 32 | #include <opie/ofontmenu.h> |
33 | 33 | ||
34 | #include <qpe/qpeapplication.h> | 34 | #include <qpe/qpeapplication.h> |
35 | #include <qpe/config.h> | 35 | #include <qpe/config.h> |
36 | #include <qpe/finddialog.h> | 36 | #include <qpe/finddialog.h> |
37 | #include <qpe/global.h> | 37 | #include <qpe/global.h> |
38 | #include <qpe/ir.h> | 38 | #include <qpe/ir.h> |
39 | #include <qpe/qpemenubar.h> | 39 | #include <qpe/qpemenubar.h> |
40 | #include <qpe/qpemessagebox.h> | 40 | #include <qpe/qpemessagebox.h> |
41 | #include <qpe/resource.h> | 41 | #include <qpe/resource.h> |
42 | //#include <qpe/task.h> | 42 | //#include <qpe/task.h> |
43 | #include <qpe/qpetoolbar.h> | 43 | #include <qpe/qpetoolbar.h> |
44 | 44 | ||
45 | #include <qaction.h> | 45 | #include <qaction.h> |
46 | #include <qarray.h> | 46 | #include <qarray.h> |
47 | #include <qdatastream.h> | 47 | #include <qdatastream.h> |
48 | #include <qdatetime.h> | 48 | #include <qdatetime.h> |
49 | #include <qfile.h> | 49 | #include <qfile.h> |
50 | #include <qmessagebox.h> | 50 | #include <qmessagebox.h> |
51 | #include <qpopupmenu.h> | 51 | #include <qpopupmenu.h> |
52 | #include <qwidgetstack.h> | 52 | #include <qwidgetstack.h> |
53 | 53 | ||
54 | #include <sys/stat.h> | 54 | #include <sys/stat.h> |
55 | #include <sys/types.h> | 55 | #include <sys/types.h> |
56 | #include <fcntl.h> | 56 | #include <fcntl.h> |
57 | #include <unistd.h> | 57 | #include <unistd.h> |
58 | 58 | ||
59 | #include <stdlib.h> | 59 | #include <stdlib.h> |
60 | 60 | ||
61 | static QString todolistXMLFilename() | 61 | static QString todolistXMLFilename() |
62 | { | 62 | { |
63 | return Global::applicationFileName("todolist","todolist.xml"); | 63 | return Global::applicationFileName("todolist","todolist.xml"); |
64 | } | 64 | } |
65 | 65 | ||
66 | static QString categoriesXMLFilename() | 66 | static QString categoriesXMLFilename() |
67 | { | 67 | { |
68 | return Global::applicationFileName("todolist","categories.xml"); | 68 | return Global::applicationFileName("todolist","categories.xml"); |
69 | } | 69 | } |
70 | 70 | ||
71 | TodoWindow::TodoWindow( QWidget *parent, const char *name, WFlags f ) : | 71 | TodoWindow::TodoWindow( QWidget *parent, const char *name, WFlags f ) : |
72 | QMainWindow( parent, name, f ), syncing(FALSE) | 72 | QMainWindow( parent, name, f ), syncing(FALSE) |
73 | { | 73 | { |
74 | // QTime t; | 74 | // QTime t; |
75 | // t.start(); | 75 | // t.start(); |
76 | mView = 0l; | 76 | mView = 0l; |
77 | mStack = new QWidgetStack(this, "main stack"); | 77 | mStack = new QWidgetStack(this, "main stack"); |
78 | setCaption( tr("Todo") ); | 78 | setCaption( tr("Todo") ); |
79 | QString str; | 79 | QString str; |
80 | table = new TodoTable( this ); | 80 | table = new TodoTable( this ); |
81 | table->setColumnWidth( 2, 10 ); | 81 | table->setColumnWidth( 2, 10 ); |
82 | table->setPaintingEnabled( FALSE ); | 82 | table->setPaintingEnabled( FALSE ); |
83 | table->setUpdatesEnabled( FALSE ); | 83 | table->setUpdatesEnabled( FALSE ); |
84 | table->viewport()->setUpdatesEnabled( FALSE ); | 84 | table->viewport()->setUpdatesEnabled( FALSE ); |
85 | 85 | ||
86 | { | 86 | { |
87 | str = todolistXMLFilename(); | 87 | str = todolistXMLFilename(); |
88 | if ( str.isNull() ) | 88 | if ( str.isNull() ) |
89 | QMessageBox::critical( this, | 89 | QMessageBox::critical( this, |
90 | tr("Out of Space"), | 90 | tr("Out of Space"), |
91 | tr("Unable to create startup files\n" | 91 | tr("Unable to create startup files\n" |
92 | "Free up some space\n" | 92 | "Free up some space\n" |
93 | "before you enter any data") ); | 93 | "before you enter any data") ); |
94 | else | 94 | else |
95 | table->load( str ); | 95 | table->load( str ); |
96 | } | 96 | } |
97 | 97 | ||
98 | // repeat for categories... | 98 | // repeat for categories... |
99 | str = categoriesXMLFilename(); | 99 | str = categoriesXMLFilename(); |
100 | if ( str.isNull() ) | 100 | if ( str.isNull() ) |
101 | QMessageBox::critical( this, | 101 | QMessageBox::critical( this, |
102 | tr( "Out of Space" ), | 102 | tr( "Out of Space" ), |
103 | tr( "Unable to create startup files\n" | 103 | tr( "Unable to create startup files\n" |
104 | "Free up some space\n" | 104 | "Free up some space\n" |
105 | "before you enter any data") ); | 105 | "before you enter any data") ); |
106 | 106 | ||
107 | mStack->addWidget(table, 1 ); | 107 | mStack->addWidget(table, 1 ); |
108 | mStack->raiseWidget( 1 ); | 108 | mStack->raiseWidget( 1 ); |
109 | setCentralWidget( mStack ); | 109 | setCentralWidget( mStack ); |
110 | setToolBarsMovable( FALSE ); | 110 | setToolBarsMovable( FALSE ); |
111 | 111 | ||
112 | // qDebug("after load: t=%d", t.elapsed() ); | 112 | // qDebug("after load: t=%d", t.elapsed() ); |
113 | 113 | ||
114 | Config config( "todo" ); | 114 | Config config( "todo" ); |
115 | config.setGroup( "View" ); | 115 | config.setGroup( "View" ); |
116 | bool complete = config.readBoolEntry( "ShowComplete", true ); | 116 | bool complete = config.readBoolEntry( "ShowComplete", true ); |
117 | table->setShowCompleted( complete ); | 117 | table->setShowCompleted( complete ); |
118 | 118 | ||
119 | bool showdeadline = config.readBoolEntry("ShowDeadLine", true); | 119 | bool showdeadline = config.readBoolEntry("ShowDeadLine", true); |
120 | table->setShowDeadline (showdeadline); | 120 | table->setShowDeadline (showdeadline); |
121 | 121 | ||
122 | QString category = config.readEntry( "Category", QString::null ); | 122 | QString category = config.readEntry( "Category", QString::null ); |
123 | table->setShowCategory( category ); | 123 | table->setShowCategory( category ); |
124 | 124 | ||
125 | QPEToolBar *bar = new QPEToolBar( this ); | 125 | QPEToolBar *bar = new QPEToolBar( this ); |
126 | bar->setHorizontalStretchable( TRUE ); | 126 | bar->setHorizontalStretchable( TRUE ); |
127 | 127 | ||
128 | QPEMenuBar *mb = new QPEMenuBar( bar ); | 128 | QPEMenuBar *mb = new QPEMenuBar( bar ); |
129 | 129 | ||
130 | catMenu = new QPopupMenu( this ); | 130 | catMenu = new QPopupMenu( this ); |
131 | QPopupMenu *edit = new QPopupMenu( this ); | 131 | QPopupMenu *edit = new QPopupMenu( this ); |
132 | QPopupMenu *options = new QPopupMenu(this ); | 132 | QPopupMenu *options = new QPopupMenu(this ); |
133 | 133 | ||
134 | contextMenu = new QPopupMenu( this ); | 134 | contextMenu = new QPopupMenu( this ); |
135 | 135 | ||
136 | bar = new QPEToolBar( this ); | 136 | bar = new QPEToolBar( this ); |
137 | 137 | ||
138 | QAction *a = new QAction( tr( "New Task" ), Resource::loadPixmap( "new" ), | 138 | QAction *a = new QAction( tr( "New Task" ), Resource::loadPixmap( "new" ), |
139 | QString::null, 0, this, 0 ); | 139 | QString::null, 0, this, 0 ); |
140 | connect( a, SIGNAL( activated() ), | 140 | connect( a, SIGNAL( activated() ), |
141 | this, SLOT( slotNew() ) ); | 141 | this, SLOT( slotNew() ) ); |
142 | a->addTo( bar ); | 142 | a->addTo( bar ); |
143 | a->addTo( edit ); | 143 | a->addTo( edit ); |
144 | 144 | ||
145 | a = new QAction( tr( "Edit Task" ), Resource::loadIconSet( "edit" ), | 145 | a = new QAction( tr( "Edit Task" ), Resource::loadIconSet( "edit" ), |
146 | QString::null, 0, this, 0 ); | 146 | QString::null, 0, this, 0 ); |
147 | connect( a, SIGNAL( activated() ), | 147 | connect( a, SIGNAL( activated() ), |
148 | this, SLOT( slotEdit() ) ); | 148 | this, SLOT( slotEdit() ) ); |
149 | a->addTo( bar ); | 149 | a->addTo( bar ); |
150 | a->addTo( edit ); | 150 | a->addTo( edit ); |
151 | a->addTo( contextMenu ); | 151 | a->addTo( contextMenu ); |
152 | a->setEnabled( FALSE ); | 152 | a->setEnabled( FALSE ); |
153 | editAction = a; | 153 | editAction = a; |
154 | 154 | ||
155 | a = new QAction( QString::null, tr("View Task"), 0, this, 0 ); | 155 | a = new QAction( QString::null, tr("View Task"), 0, this, 0 ); |
156 | a->addTo( edit ); | 156 | a->addTo( edit ); |
157 | a->addTo( contextMenu ); | 157 | a->addTo( contextMenu ); |
158 | connect( a, SIGNAL( activated() ), | 158 | connect( a, SIGNAL( activated() ), |
159 | this, SLOT(slotShowDetails() ) ); | 159 | this, SLOT(slotShowDetails() ) ); |
160 | 160 | ||
161 | edit->insertSeparator(); | 161 | edit->insertSeparator(); |
162 | 162 | ||
163 | a = new QAction( tr( "Delete..." ), Resource::loadIconSet( "trash" ), | 163 | a = new QAction( tr( "Delete..." ), Resource::loadIconSet( "trash" ), |
164 | QString::null, 0, this, 0 ); | 164 | QString::null, 0, this, 0 ); |
165 | connect( a, SIGNAL( activated() ), | 165 | connect( a, SIGNAL( activated() ), |
166 | this, SLOT( slotDelete() ) ); | 166 | this, SLOT( slotDelete() ) ); |
167 | a->addTo( bar ); | 167 | a->addTo( bar ); |
168 | a->addTo( edit ); | 168 | a->addTo( edit ); |
169 | a->addTo( contextMenu ); | 169 | a->addTo( contextMenu ); |
170 | a->setEnabled( FALSE ); | 170 | a->setEnabled( FALSE ); |
171 | deleteAction = a; | 171 | deleteAction = a; |
172 | 172 | ||
173 | // delete All in category is missing.... | 173 | // delete All in category is missing.... |
174 | // set All Done | 174 | // set All Done |
175 | // set All Done in category | 175 | // set All Done in category |
176 | 176 | ||
177 | a = new QAction( QString::null, tr( "Delete all..."), 0, this, 0 ); | 177 | a = new QAction( QString::null, tr( "Delete all..."), 0, this, 0 ); |
178 | connect(a, SIGNAL( activated() ), | 178 | connect(a, SIGNAL( activated() ), |
179 | this, SLOT( slotDeleteAll() ) ); | 179 | this, SLOT( slotDeleteAll() ) ); |
180 | a->addTo(edit ); | 180 | a->addTo(edit ); |
181 | a->setEnabled( FALSE ); | 181 | a->setEnabled( FALSE ); |
182 | deleteAllAction = a; | 182 | deleteAllAction = a; |
183 | 183 | ||
184 | edit->insertSeparator(); | 184 | edit->insertSeparator(); |
185 | a = new QAction( QString::null, tr("Duplicate" ), 0, this, 0 ); | 185 | a = new QAction( QString::null, tr("Duplicate" ), 0, this, 0 ); |
186 | connect(a, SIGNAL( activated() ), | 186 | connect(a, SIGNAL( activated() ), |
187 | this, SLOT( slotDuplicate() ) ); | 187 | this, SLOT( slotDuplicate() ) ); |
188 | a->addTo(edit ); | 188 | a->addTo(edit ); |
189 | a->setEnabled( FALSE ); | 189 | a->setEnabled( FALSE ); |
190 | duplicateAction = a; | 190 | duplicateAction = a; |
191 | edit->insertSeparator(); | 191 | edit->insertSeparator(); |
192 | 192 | ||
193 | 193 | ||
194 | 194 | ||
195 | if ( Ir::supported() ) { | 195 | if ( Ir::supported() ) { |
196 | a = new QAction( tr( "Beam" ), Resource::loadPixmap( "beam" ), | 196 | a = new QAction( tr( "Beam" ), Resource::loadPixmap( "beam" ), |
197 | QString::null, 0, this, 0 ); | 197 | QString::null, 0, this, 0 ); |
198 | connect( a, SIGNAL( activated() ), | 198 | connect( a, SIGNAL( activated() ), |
199 | this, SLOT( slotBeam() ) ); | 199 | this, SLOT( slotBeam() ) ); |
200 | a->addTo( edit ); | 200 | a->addTo( edit ); |
201 | a->addTo( bar ); | 201 | a->addTo( bar ); |
202 | } | 202 | } |
203 | 203 | ||
204 | a = new QAction( tr( "Find" ), Resource::loadIconSet( "mag" ), | 204 | a = new QAction( tr( "Find" ), Resource::loadIconSet( "mag" ), |
205 | QString::null, 0, this, 0 ); | 205 | QString::null, 0, this, 0 ); |
206 | connect( a, SIGNAL( activated() ), | 206 | connect( a, SIGNAL( activated() ), |
207 | this, SLOT( slotFind() ) ); | 207 | this, SLOT( slotFind() ) ); |
208 | a->addTo( bar ); | 208 | a->addTo( bar ); |
209 | a->addTo( options ); | 209 | a->addTo( options ); |
210 | options->insertSeparator(); | 210 | options->insertSeparator(); |
211 | 211 | ||
212 | if ( table->numRows() ) | 212 | if ( table->numRows() ) |
213 | a->setEnabled( TRUE ); | 213 | a->setEnabled( TRUE ); |
214 | else | 214 | else |
215 | a->setEnabled( FALSE ); | 215 | a->setEnabled( FALSE ); |
216 | 216 | ||
217 | //a->setEnabled( FALSE ); | 217 | //a->setEnabled( FALSE ); |
218 | findAction = a; | 218 | findAction = a; |
219 | // qDebug("mainwindow #2: t=%d", t.elapsed() ); | 219 | // qDebug("mainwindow #2: t=%d", t.elapsed() ); |
220 | 220 | ||
221 | completedAction = new QAction( QString::null, tr("Completed tasks"), 0, this, 0, TRUE ); | 221 | completedAction = new QAction( QString::null, tr("Completed tasks"), 0, this, 0, TRUE ); |
222 | 222 | ||
223 | showdeadlineAction = new QAction( QString::null, tr( "Show Deadline" ), 0, this, 0, TRUE ); | 223 | showdeadlineAction = new QAction( QString::null, tr( "Show Deadline" ), 0, this, 0, TRUE ); |
224 | 224 | ||
225 | catMenu->setCheckable( true ); | 225 | catMenu->setCheckable( true ); |
226 | populateCategories(); | 226 | populateCategories(); |
227 | 227 | ||
228 | 228 | ||
229 | completedAction->addTo( options ); | 229 | completedAction->addTo( options ); |
230 | completedAction->setOn( table->showCompleted() ); | 230 | completedAction->setOn( table->showCompleted() ); |
231 | showdeadlineAction->addTo( options ); | 231 | showdeadlineAction->addTo( options ); |
232 | showdeadlineAction->setOn( table->showDeadline() ); | 232 | showdeadlineAction->setOn( table->showDeadline() ); |
233 | options->insertSeparator( ); | 233 | options->insertSeparator( ); |
234 | QList<QWidget> list; | 234 | QList<QWidget> list; |
235 | list.append(table ); | 235 | list.append(table ); |
236 | OFontMenu *menu = new OFontMenu(this, "menu",list ); | 236 | OFontMenu *menu = new OFontMenu(this, "menu",list ); |
237 | menu->forceSize( table->horizontalHeader(), 10 ); | 237 | menu->forceSize( table->horizontalHeader(), 10 ); |
238 | //catMenu->insertItem(tr("Fonts"), menu ); | 238 | //catMenu->insertItem(tr("Fonts"), menu ); |
239 | list.clear(); | 239 | list.clear(); |
240 | options->insertItem( tr("Fonts"), menu ); | 240 | options->insertItem( tr("Fonts"), menu ); |
241 | 241 | ||
242 | 242 | ||
243 | mb->insertItem( tr( "Data" ), edit ); | 243 | mb->insertItem( tr( "Data" ), edit ); |
244 | mb->insertItem( tr( "Category" ), catMenu ); | 244 | mb->insertItem( tr( "Category" ), catMenu ); |
245 | mb->insertItem( tr( "Options"), options ); | 245 | mb->insertItem( tr( "Options"), options ); |
246 | resize( 200, 300 ); | 246 | resize( 200, 300 ); |
247 | if ( table->numRows() > 0 ) | 247 | if ( table->numRows() > 0 ) |
248 | currentEntryChanged( 0, 0 ); | 248 | currentEntryChanged( 0, 0 ); |
249 | connect( table, SIGNAL( signalEdit() ), | 249 | connect( table, SIGNAL( signalEdit() ), |
250 | this, SLOT( slotEdit() ) ); | 250 | this, SLOT( slotEdit() ) ); |
251 | connect( table, SIGNAL(signalShowMenu(const QPoint &)), | 251 | connect( table, SIGNAL(signalShowMenu(const QPoint &)), |
252 | this, SLOT( slotShowPopup(const QPoint &)) ); | 252 | this, SLOT( slotShowPopup(const QPoint &)) ); |
253 | 253 | ||
254 | // qDebug("mainwindow #3: t=%d", t.elapsed() ); | 254 | // qDebug("mainwindow #3: t=%d", t.elapsed() ); |
255 | table->updateVisible(); | 255 | table->updateVisible(); |
256 | table->setUpdatesEnabled( TRUE ); | 256 | table->setUpdatesEnabled( TRUE ); |
257 | table->setPaintingEnabled( TRUE ); | 257 | table->setPaintingEnabled( TRUE ); |
258 | table->viewport()->setUpdatesEnabled( TRUE ); | 258 | table->viewport()->setUpdatesEnabled( TRUE ); |
259 | 259 | ||
260 | // Initialize the table | 260 | // Initialize the table |
261 | table->updateVisible(); | 261 | table->updateVisible(); |
262 | 262 | ||
263 | connect( completedAction, SIGNAL( toggled(bool) ), this, SLOT( showCompleted(bool) ) ); | 263 | connect( completedAction, SIGNAL( toggled(bool) ), this, SLOT( showCompleted(bool) ) ); |
264 | connect( showdeadlineAction, SIGNAL( toggled(bool) ), this, SLOT( showDeadline(bool) ) ); | 264 | connect( showdeadlineAction, SIGNAL( toggled(bool) ), this, SLOT( showDeadline(bool) ) ); |
265 | connect( catMenu, SIGNAL(activated(int)), this, SLOT(setCategory(int)) ); | 265 | connect( catMenu, SIGNAL(activated(int)), this, SLOT(setCategory(int)) ); |
266 | connect( table, SIGNAL( currentChanged( int, int ) ), | 266 | connect( table, SIGNAL( currentChanged( int, int ) ), |
267 | this, SLOT( currentEntryChanged( int, int ) ) ); | 267 | this, SLOT( currentEntryChanged( int, int ) ) ); |
268 | 268 | ||
269 | connect( table, SIGNAL(showDetails(const ToDoEvent &) ), | 269 | connect( table, SIGNAL(showDetails(const ToDoEvent &) ), |
270 | this, SLOT(slotShowDetails(const ToDoEvent & ) ) ); | 270 | this, SLOT(slotShowDetails(const ToDoEvent & ) ) ); |
271 | // qDebug("done: t=%d", t.elapsed() ); | 271 | // qDebug("done: t=%d", t.elapsed() ); |
272 | } | 272 | } |
273 | 273 | ||
274 | void TodoWindow::slotNew() | 274 | void TodoWindow::slotNew() |
275 | { | 275 | { |
276 | if(syncing) { | 276 | if(syncing) { |
277 | QMessageBox::warning(this, tr("Todo"), | 277 | QMessageBox::warning(this, tr("Todo"), |
278 | tr("Can not edit data, currently syncing")); | 278 | tr("Can not edit data, currently syncing")); |
279 | return; | 279 | return; |
280 | } | 280 | } |
281 | 281 | ||
282 | int id; | 282 | int id; |
283 | id = -1; | 283 | id = -1; |
284 | QArray<int> ids; | 284 | QArray<int> ids; |
285 | ids = table->currentEntry().categories(); | 285 | ids = table->currentEntry().categories(); |
286 | if ( ids.count() ) | 286 | if ( ids.count() ) |
287 | id = ids[0]; | 287 | id = ids[0]; |
288 | NewTaskDialog e( id, this, 0, TRUE ); | 288 | NewTaskDialog e( id, this, 0, TRUE ); |
289 | 289 | ||
290 | ToDoEvent todo; | 290 | ToDoEvent todo; |
291 | 291 | ||
292 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 292 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
293 | e.showMaximized(); | 293 | e.showMaximized(); |
294 | #endif | 294 | #endif |
295 | int ret = e.exec(); | 295 | int ret = e.exec(); |
296 | // qWarning("finished" ); | 296 | // qWarning("finished" ); |
297 | if ( ret == QDialog::Accepted ) { | 297 | if ( ret == QDialog::Accepted ) { |
298 | table->setPaintingEnabled( false ); | 298 | table->setPaintingEnabled( false ); |
299 | todo = e.todoEntry(); | 299 | todo = e.todoEntry(); |
300 | //todo.assignUid(); | 300 | //todo.assignUid(); |
301 | table->addEntry( todo ); | 301 | table->addEntry( todo ); |
302 | table->setPaintingEnabled( true ); | 302 | table->setPaintingEnabled( true ); |
303 | findAction->setEnabled( TRUE ); | 303 | findAction->setEnabled( TRUE ); |
304 | } | 304 | } |
305 | // I'm afraid we must call this every time now, otherwise | 305 | // I'm afraid we must call this every time now, otherwise |
306 | // spend expensive time comparing all these strings... | 306 | // spend expensive time comparing all these strings... |
307 | populateCategories(); | 307 | populateCategories(); |
308 | mStack->raiseWidget(1 ); | 308 | mStack->raiseWidget(1 ); |
309 | } | 309 | } |
310 | 310 | ||
311 | TodoWindow::~TodoWindow() | 311 | TodoWindow::~TodoWindow() |
312 | { | 312 | { |
313 | } | 313 | } |
314 | 314 | ||
315 | void TodoWindow::slotDelete() | 315 | void TodoWindow::slotDelete() |
316 | { | 316 | { |
317 | if(syncing) { | 317 | if(syncing) { |
318 | QMessageBox::warning(this, tr("Todo"), | 318 | QMessageBox::warning(this, tr("Todo"), |
319 | tr("Can not edit data, currently syncing")); | 319 | tr("Can not edit data, currently syncing")); |
320 | return; | 320 | return; |
321 | } | 321 | } |
322 | 322 | ||
323 | if ( table->currentRow() == -1 ) | 323 | if ( table->currentRow() == -1 ) |
324 | return; | 324 | return; |
325 | 325 | ||
326 | QString strName = table->text( table->currentRow(), 2 ).left( 30 ); | 326 | QString strName = table->text( table->currentRow(), 2 ).left( 30 ); |
327 | 327 | ||
328 | if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), strName ) ) | 328 | if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), strName ) ) |
329 | return; | 329 | return; |
330 | 330 | ||
331 | 331 | ||
332 | 332 | ||
333 | table->setPaintingEnabled( false ); | 333 | table->setPaintingEnabled( false ); |
334 | table->removeCurrentEntry(); | 334 | table->removeCurrentEntry(); |
335 | table->setPaintingEnabled( true ); | 335 | table->setPaintingEnabled( true ); |
336 | 336 | ||
337 | if ( table->numRows() == 0 ) { | 337 | if ( table->numRows() == 0 ) { |
338 | currentEntryChanged( -1, 0 ); | 338 | currentEntryChanged( -1, 0 ); |
339 | findAction->setEnabled( FALSE ); | 339 | findAction->setEnabled( FALSE ); |
340 | } | 340 | } |
341 | mStack->raiseWidget(1); | 341 | mStack->raiseWidget(1); |
342 | } | 342 | } |
343 | void TodoWindow::slotDeleteAll() | 343 | void TodoWindow::slotDeleteAll() |
344 | { | 344 | { |
345 | if(syncing) { | 345 | if(syncing) { |
346 | QMessageBox::warning(this, tr("Todo"), | 346 | QMessageBox::warning(this, tr("Todo"), |
347 | tr("Can not edit data, currently syncing")); | 347 | tr("Can not edit data, currently syncing")); |
348 | return; | 348 | return; |
349 | } | 349 | } |
350 | 350 | ||
351 | //QString strName = table->text( table->currentRow(), 2 ).left( 30 ); | 351 | //QString strName = table->text( table->currentRow(), 2 ).left( 30 ); |
352 | 352 | ||
353 | if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("Delete all tasks?") ) ) | 353 | if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("Delete all tasks?") ) ) |
354 | return; | 354 | return; |
355 | 355 | ||
356 | 356 | ||
357 | 357 | ||
358 | table->setPaintingEnabled( false ); | 358 | table->setPaintingEnabled( false ); |
359 | table->removeAllEntries(); | 359 | table->removeAllEntries(); |
360 | table->setPaintingEnabled( true ); | 360 | table->setPaintingEnabled( true ); |
361 | 361 | ||
362 | if ( table->numRows() == 0 ) { | 362 | if ( table->numRows() == 0 ) { |
363 | currentEntryChanged( -1, 0 ); | 363 | currentEntryChanged( -1, 0 ); |
364 | findAction->setEnabled( FALSE ); | 364 | findAction->setEnabled( FALSE ); |
365 | } | 365 | } |
366 | mStack->raiseWidget(1 ); | 366 | mStack->raiseWidget(1 ); |
367 | } | 367 | } |
368 | 368 | ||
369 | void TodoWindow::slotEdit() | 369 | void TodoWindow::slotEdit() |
370 | { | 370 | { |
371 | if(syncing) { | 371 | if(syncing) { |
372 | QMessageBox::warning(this, tr("Todo"), | 372 | QMessageBox::warning(this, tr("Todo"), |
373 | tr("Can not edit data, currently syncing")); | 373 | tr("Can not edit data, currently syncing")); |
374 | return; | 374 | return; |
375 | } | 375 | } |
376 | 376 | ||
377 | ToDoEvent todo = table->currentEntry(); | 377 | ToDoEvent todo = table->currentEntry(); |
378 | qWarning("slotEdit" ); | 378 | qWarning("slotEdit" ); |
379 | NewTaskDialog e( todo, this, 0, TRUE ); | 379 | NewTaskDialog e( todo, this, 0, TRUE ); |
380 | e.setCaption( tr( "Edit Task" ) ); | 380 | e.setCaption( tr( "Edit Task" ) ); |
381 | 381 | ||
382 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 382 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
383 | e.showMaximized(); | 383 | e.showMaximized(); |
384 | #endif | 384 | #endif |
385 | int ret = e.exec(); | 385 | int ret = e.exec(); |
386 | 386 | ||
387 | if ( ret == QDialog::Accepted ) { | 387 | if ( ret == QDialog::Accepted ) { |
388 | qWarning("Replacing now" ); | 388 | qWarning("Replacing now" ); |
389 | table->setPaintingEnabled( false ); | 389 | table->setPaintingEnabled( false ); |
390 | todo = e.todoEntry(); | 390 | todo = e.todoEntry(); |
391 | table->replaceCurrentEntry( todo ); | 391 | table->replaceCurrentEntry( todo ); |
392 | table->setPaintingEnabled( true ); | 392 | table->setPaintingEnabled( true ); |
393 | } | 393 | } |
394 | populateCategories(); | 394 | populateCategories(); |
395 | mStack->raiseWidget( 1 ); | 395 | mStack->raiseWidget( 1 ); |
396 | } | 396 | } |
397 | void TodoWindow::slotDuplicate() | 397 | void TodoWindow::slotDuplicate() |
398 | { | 398 | { |
399 | if(syncing) { | 399 | if(syncing) { |
400 | QMessageBox::warning(this, tr("Todo"), | 400 | QMessageBox::warning(this, tr("Todo"), |
401 | tr("Can not edit data, currently syncing")); | 401 | tr("Can not edit data, currently syncing")); |
402 | return; | 402 | return; |
403 | } | 403 | } |
404 | ToDoEvent ev = table->currentEntry(); | 404 | ToDoEvent ev = table->currentEntry(); |
405 | ToDoEvent ev2 = ToDoEvent( ev ); // what about the uid | 405 | ToDoEvent ev2 = ToDoEvent( ev ); // what about the uid |
406 | int uid; | 406 | int uid; |
407 | { // uid | 407 | { // uid |
408 | Qtopia::UidGen *uidgen = new Qtopia::UidGen(); | 408 | Qtopia::UidGen *uidgen = new Qtopia::UidGen(); |
409 | uid = uidgen->generate(); | 409 | uid = uidgen->generate(); |
410 | delete uidgen; | 410 | delete uidgen; |
411 | } | 411 | } |
412 | ev2.setUid( uid ); | 412 | ev2.setUid( uid ); |
413 | table->setPaintingEnabled( false ); | 413 | table->setPaintingEnabled( false ); |
414 | table->addEntry( ev2 ); | 414 | table->addEntry( ev2 ); |
415 | table->setPaintingEnabled( true ); | 415 | table->setPaintingEnabled( true ); |
416 | 416 | ||
417 | mStack->raiseWidget( 1 ); | 417 | mStack->raiseWidget( 1 ); |
418 | } | 418 | } |
419 | void TodoWindow::slotShowPopup( const QPoint &p ) | 419 | void TodoWindow::slotShowPopup( const QPoint &p ) |
420 | { | 420 | { |
421 | contextMenu->popup( p ); | 421 | contextMenu->popup( p ); |
422 | } | 422 | } |
423 | 423 | ||
424 | void TodoWindow::showCompleted( bool s ) | 424 | void TodoWindow::showCompleted( bool s ) |
425 | { | 425 | { |
426 | if ( !table->isUpdatesEnabled() ) | 426 | if ( !table->isUpdatesEnabled() ) |
427 | return; | 427 | return; |
428 | table->setPaintingEnabled( false ); | 428 | table->setPaintingEnabled( false ); |
429 | table->setShowCompleted( s ); | 429 | table->setShowCompleted( s ); |
430 | table->setPaintingEnabled( true ); | 430 | table->setPaintingEnabled( true ); |
431 | mStack->raiseWidget( 1 ); | 431 | mStack->raiseWidget( 1 ); |
432 | } | 432 | } |
433 | 433 | ||
434 | void TodoWindow::currentEntryChanged( int r, int ) | 434 | void TodoWindow::currentEntryChanged( int r, int ) |
435 | { | 435 | { |
436 | if ( r != -1 && table->rowHeight( r ) > 0 ) { | 436 | if ( r != -1 && table->rowHeight( r ) > 0 ) { |
437 | editAction->setEnabled( TRUE ); | 437 | editAction->setEnabled( TRUE ); |
438 | deleteAction->setEnabled( TRUE ); | 438 | deleteAction->setEnabled( TRUE ); |
439 | duplicateAction->setEnabled( TRUE ); | 439 | duplicateAction->setEnabled( TRUE ); |
440 | deleteAllAction->setEnabled( TRUE ); | 440 | deleteAllAction->setEnabled( TRUE ); |
441 | } else { | 441 | } else { |
442 | editAction->setEnabled( FALSE ); | 442 | editAction->setEnabled( FALSE ); |
443 | deleteAction->setEnabled( FALSE ); | 443 | deleteAction->setEnabled( FALSE ); |
444 | duplicateAction->setEnabled( FALSE ); | 444 | duplicateAction->setEnabled( FALSE ); |
445 | deleteAllAction->setEnabled( FALSE ); | 445 | deleteAllAction->setEnabled( FALSE ); |
446 | } | 446 | } |
447 | } | 447 | } |
448 | 448 | ||
449 | void TodoWindow::setCategory( int c ) | 449 | void TodoWindow::setCategory( int c ) |
450 | { | 450 | { |
451 | if ( c <= 0 ) return; | 451 | if ( c <= 0 ) return; |
452 | if ( !table->isUpdatesEnabled() ) | 452 | if ( !table->isUpdatesEnabled() ) |
453 | return; | 453 | return; |
454 | table->setPaintingEnabled( false ); | 454 | table->setPaintingEnabled( false ); |
455 | for ( unsigned int i = 1; i < catMenu->count(); i++ ) | 455 | for ( unsigned int i = 1; i < catMenu->count(); i++ ) |
456 | catMenu->setItemChecked( i, c == (int)i ); | 456 | catMenu->setItemChecked( i, c == (int)i ); |
457 | if ( c == 1 ) { | 457 | if ( c == 1 ) { |
458 | table->setShowCategory( QString::null ); | 458 | table->setShowCategory( QString::null ); |
459 | setCaption( tr("Todo") + " - " + tr( "All Categories" ) ); | 459 | setCaption( tr("Todo") + " - " + tr( "All Categories" ) ); |
460 | } else if ( c == (int)catMenu->count() - 1 ) { | 460 | } else if ( c == (int)catMenu->count() - 1 ) { |
461 | table->setShowCategory( tr( "Unfiled" ) ); | 461 | table->setShowCategory( tr( "Unfiled" ) ); |
462 | setCaption( tr("Todo") + " - " + tr( "Unfiled" ) ); | 462 | setCaption( tr("Todo") + " - " + tr( "Unfiled" ) ); |
463 | } else { | 463 | } else { |
464 | QString cat = table->categories()[c - 2]; | 464 | QString cat = table->categories()[c - 2]; |
465 | table->setShowCategory( cat ); | 465 | table->setShowCategory( cat ); |
466 | setCaption( tr("Todo") + " - " + cat ); | 466 | setCaption( tr("Todo") + " - " + cat ); |
467 | } | 467 | } |
468 | table->setPaintingEnabled( true ); | 468 | table->setPaintingEnabled( true ); |
469 | 469 | ||
470 | mStack->raiseWidget( 1 ); | 470 | mStack->raiseWidget( 1 ); |
471 | } | 471 | } |
472 | 472 | ||
473 | void TodoWindow::populateCategories() | 473 | void TodoWindow::populateCategories() |
474 | { | 474 | { |
475 | catMenu->clear(); | 475 | catMenu->clear(); |
476 | int id, rememberId; | 476 | int id, rememberId; |
477 | id = 1; | 477 | id = 1; |
478 | rememberId = 0; | 478 | rememberId = 0; |
479 | catMenu->insertItem( tr( "All Categories" ), id++ ); | 479 | catMenu->insertItem( tr( "All Categories" ), id++ ); |
480 | catMenu->insertSeparator(); | 480 | catMenu->insertSeparator(); |
481 | QStringList categories = table->categories(); | 481 | QStringList categories = table->categories(); |
482 | categories.append( tr( "Unfiled" ) ); | 482 | categories.append( tr( "Unfiled" ) ); |
483 | for ( QStringList::Iterator it = categories.begin(); | 483 | for ( QStringList::Iterator it = categories.begin(); |
484 | it != categories.end(); ++it ) { | 484 | it != categories.end(); ++it ) { |
485 | catMenu->insertItem( *it, id ); | 485 | catMenu->insertItem( *it, id ); |
486 | if ( *it == table->showCategory() ) | 486 | if ( *it == table->showCategory() ) |
487 | rememberId = id; | 487 | rememberId = id; |
488 | ++id; | 488 | ++id; |
489 | } | 489 | } |
490 | if ( table->showCategory().isEmpty() ) | 490 | if ( table->showCategory().isEmpty() ) |
491 | setCategory( 1 ); | 491 | setCategory( 1 ); |
492 | else | 492 | else |
493 | setCategory( rememberId ); | 493 | setCategory( rememberId ); |
494 | } | 494 | } |
495 | 495 | ||
496 | void TodoWindow::reload() | 496 | void TodoWindow::reload() |
497 | { | 497 | { |
498 | table->clear(); | 498 | table->clear(); |
499 | table->load( todolistXMLFilename() ); | 499 | table->load( todolistXMLFilename() ); |
500 | syncing = FALSE; | 500 | syncing = FALSE; |
501 | } | 501 | } |
502 | 502 | ||
503 | void TodoWindow::flush() | 503 | void TodoWindow::flush() |
504 | { | 504 | { |
505 | syncing = TRUE; | 505 | syncing = TRUE; |
506 | table->save( todolistXMLFilename() ); | 506 | table->save( todolistXMLFilename() ); |
507 | } | 507 | } |
508 | 508 | ||
509 | void TodoWindow::closeEvent( QCloseEvent *e ) | 509 | void TodoWindow::closeEvent( QCloseEvent *e ) |
510 | { | 510 | { |
511 | if( mStack->visibleWidget() != table ){ | 511 | if( mStack->visibleWidget() != table ){ |
512 | mStack->raiseWidget( 1 ); | 512 | mStack->raiseWidget( 1 ); |
513 | e->ignore(); | 513 | e->ignore(); |
514 | return; | 514 | return; |
515 | } | 515 | } |
516 | if(syncing) { | 516 | if(syncing) { |
517 | /* no need to save if in the middle of syncing */ | 517 | /* no need to save if in the middle of syncing */ |
518 | e->accept(); | 518 | e->accept(); |
519 | return; | 519 | return; |
520 | } | 520 | } |
521 | 521 | ||
522 | if ( table->save( todolistXMLFilename() ) ) { | 522 | if ( table->save( todolistXMLFilename() ) ) { |
523 | e->accept(); | 523 | e->accept(); |
524 | // repeat for categories... | 524 | // repeat for categories... |
525 | // if writing configs fail, it will emit an | 525 | // if writing configs fail, it will emit an |
526 | // error, but I feel that it is "ok" for us to exit | 526 | // error, but I feel that it is "ok" for us to exit |
527 | // espically since we aren't told if the write succeeded... | 527 | // espically since we aren't told if the write succeeded... |
528 | Config config( "todo" ); | 528 | Config config( "todo" ); |
529 | config.setGroup( "View" ); | 529 | config.setGroup( "View" ); |
530 | config.writeEntry( "ShowComplete", table->showCompleted() ); | 530 | config.writeEntry( "ShowComplete", table->showCompleted() ); |
531 | config.writeEntry( "Category", table->showCategory() ); | 531 | config.writeEntry( "Category", table->showCategory() ); |
532 | /* added 20.01.2k2 by se */ | 532 | /* added 20.01.2k2 by se */ |
533 | config.writeEntry( "ShowDeadLine", table->showDeadline()); | 533 | config.writeEntry( "ShowDeadLine", table->showDeadline()); |
534 | } else { | 534 | } else { |
535 | if ( QMessageBox::critical( this, tr("Out of space"), | 535 | if ( QMessageBox::critical( this, tr("Out of space"), |
536 | tr("Todo was unable\n" | 536 | tr("Todo was unable\n" |
537 | "to save your changes.\n" | 537 | "to save your changes.\n" |
538 | "Free up some space\n" | 538 | "Free up some space\n" |
539 | "and try again.\n" | 539 | "and try again.\n" |
540 | "\nQuit Anyway?"), | 540 | "\nQuit Anyway?"), |
541 | QMessageBox::Yes|QMessageBox::Escape, | 541 | QMessageBox::Yes|QMessageBox::Escape, |
542 | QMessageBox::No|QMessageBox::Default) | 542 | QMessageBox::No|QMessageBox::Default) |
543 | != QMessageBox::No ) | 543 | != QMessageBox::No ) |
544 | e->accept(); | 544 | e->accept(); |
545 | else | 545 | else |
546 | e->ignore(); | 546 | e->ignore(); |
547 | } | 547 | } |
548 | } | 548 | } |
549 | 549 | ||
550 | void TodoWindow::slotFind() | 550 | void TodoWindow::slotFind() |
551 | { | 551 | { |
552 | // put everything back to view all for searching... | 552 | // put everything back to view all for searching... |
553 | mStack->raiseWidget( 1 ); | 553 | mStack->raiseWidget( 1 ); |
554 | if ( !catMenu->isItemChecked( 0 ) ) | 554 | if ( !catMenu->isItemChecked( 0 ) ) |
555 | setCategory( 0 ); | 555 | setCategory( 0 ); |
556 | 556 | ||
557 | FindDialog dlg( "Todo List", this ); | 557 | FindDialog dlg( "Todo List", this ); |
558 | QObject::connect( &dlg, | 558 | QObject::connect( &dlg, |
559 | SIGNAL(signalFindClicked(const QString &, | 559 | SIGNAL(signalFindClicked(const QString &, |
560 | bool, bool, int)), | 560 | bool, bool, int)), |
561 | table, | 561 | table, |
562 | SLOT(slotDoFind(const QString&, bool, bool, int)) ); | 562 | SLOT(slotDoFind(const QString&, bool, bool, int)) ); |
563 | QObject::connect( table, SIGNAL(signalNotFound()), &dlg, | 563 | QObject::connect( table, SIGNAL(signalNotFound()), &dlg, |
564 | SLOT(slotNotFound()) ); | 564 | SLOT(slotNotFound()) ); |
565 | QObject::connect( table, SIGNAL(signalWrapAround()), &dlg, | 565 | QObject::connect( table, SIGNAL(signalWrapAround()), &dlg, |
566 | SLOT(slotWrapAround()) ); | 566 | SLOT(slotWrapAround()) ); |
567 | dlg.exec(); | 567 | dlg.exec(); |
568 | if ( table->numSelections() ) | 568 | if ( table->numSelections() ) |
569 | table->clearSelection(); | 569 | table->clearSelection(); |
570 | table->clearFindRow(); | 570 | table->clearFindRow(); |
571 | } | 571 | } |
572 | 572 | ||
573 | 573 | ||
574 | void TodoWindow::setDocument( const QString &filename ) | 574 | void TodoWindow::setDocument( const QString &filename ) |
575 | { | 575 | { |
576 | if ( filename.find(".vcs") != int(filename.length()) - 4 ) return; | 576 | if ( filename.find(".vcs") != int(filename.length()) - 4 ) return; |
577 | 577 | ||
578 | ToDoDB todoDB(filename, new ToDoVCalResource() ); | 578 | ToDoDB todoDB(filename, new ToDoVCalResource() ); |
579 | QValueList<ToDoEvent> tl = todoDB.rawToDos(); | 579 | QValueList<ToDoEvent> tl = todoDB.rawToDos(); |
580 | for( QValueList<ToDoEvent>::Iterator it = tl.begin(); it != tl.end(); ++it ) { | 580 | for( QValueList<ToDoEvent>::Iterator it = tl.begin(); it != tl.end(); ++it ) { |
581 | table->addEntry( *it ); | 581 | table->addEntry( *it ); |
582 | } | 582 | } |
583 | } | 583 | } |
584 | 584 | ||
585 | static const char * beamfile = "/tmp/obex/todo.vcs"; | 585 | static const char * beamfile = "/tmp/obex/todo.vcs"; |
586 | 586 | ||
587 | void TodoWindow::slotBeam() | 587 | void TodoWindow::slotBeam() |
588 | { | 588 | { |
589 | unlink( beamfile ); // delete if exists | 589 | unlink( beamfile ); // delete if exists |
590 | ToDoEvent c = table->currentEntry(); | 590 | ToDoEvent c = table->currentEntry(); |
591 | mkdir("/tmp/obex/", 0755); | 591 | mkdir("/tmp/obex/", 0755); |
592 | ToDoDB todoDB( beamfile, new ToDoVCalResource() ); | 592 | ToDoDB todoDB( beamfile, new ToDoVCalResource() ); |
593 | todoDB.addEvent( c ); | 593 | todoDB.addEvent( c ); |
594 | todoDB.save(); | 594 | todoDB.save(); |
595 | Ir *ir = new Ir( this ); | 595 | Ir *ir = new Ir( this ); |
596 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 596 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
597 | QString description = c.description(); | 597 | QString description = c.summary(); |
598 | ir->send( beamfile, description, "text/x-vCalendar" ); | 598 | ir->send( beamfile, description, "text/x-vCalendar" ); |
599 | } | 599 | } |
600 | 600 | ||
601 | void TodoWindow::beamDone( Ir *ir ) | 601 | void TodoWindow::beamDone( Ir *ir ) |
602 | { | 602 | { |
603 | delete ir; | 603 | delete ir; |
604 | unlink( beamfile ); | 604 | unlink( beamfile ); |
605 | } | 605 | } |
606 | 606 | ||
607 | void TodoWindow::showDeadline( bool s ) | 607 | void TodoWindow::showDeadline( bool s ) |
608 | { | 608 | { |
609 | table->setPaintingEnabled( false ); | 609 | table->setPaintingEnabled( false ); |
610 | table->setShowDeadline( s ); | 610 | table->setShowDeadline( s ); |
611 | table->setPaintingEnabled( true ); | 611 | table->setPaintingEnabled( true ); |
612 | } | 612 | } |
613 | void TodoWindow::slotShowDetails() | 613 | void TodoWindow::slotShowDetails() |
614 | { | 614 | { |
615 | ToDoEvent event = table->currentEntry(); | 615 | ToDoEvent event = table->currentEntry(); |
616 | slotShowDetails( event ); | 616 | slotShowDetails( event ); |
617 | } | 617 | } |
618 | void TodoWindow::slotShowDetails( const ToDoEvent &event ) | 618 | void TodoWindow::slotShowDetails( const ToDoEvent &event ) |
619 | { | 619 | { |
620 | if( mView == 0l ){ | 620 | if( mView == 0l ){ |
621 | mView = new TodoLabel(mStack); | 621 | mView = new TodoLabel(mStack); |
622 | mStack->addWidget( mView, 2 ); | 622 | mStack->addWidget( mView, 2 ); |
623 | } | 623 | } |
624 | mView->init( event ); | 624 | mView->init( event ); |
625 | mView->sync(); | 625 | mView->sync(); |
626 | mStack->raiseWidget( 2); | 626 | mStack->raiseWidget( 2); |
627 | } | 627 | } |
diff --git a/core/pim/todo/todoentry.ui b/core/pim/todo/todoentry.ui index c735e76..87ee68c 100644 --- a/core/pim/todo/todoentry.ui +++ b/core/pim/todo/todoentry.ui | |||
@@ -1,266 +1,326 @@ | |||
1 | <!DOCTYPE UI><UI> | 1 | <!DOCTYPE UI><UI> |
2 | <class>NewTaskDialogBase</class> | 2 | <class>NewTaskDialogBase</class> |
3 | <comment>********************************************************************* | 3 | <comment>********************************************************************* |
4 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 4 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
5 | ** | 5 | ** |
6 | ** This file is part of Qtopia Environment. | 6 | ** This file is part of Qtopia Environment. |
7 | ** | 7 | ** |
8 | ** This file may be distributed and/or modified under the terms of the | 8 | ** This file may be distributed and/or modified under the terms of the |
9 | ** GNU General Public License version 2 as published by the Free Software | 9 | ** GNU General Public License version 2 as published by the Free Software |
10 | ** Foundation and appearing in the file LICENSE.GPL included in the | 10 | ** Foundation and appearing in the file LICENSE.GPL included in the |
11 | ** packaging of this file. | 11 | ** packaging of this file. |
12 | ** | 12 | ** |
13 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 13 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
14 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 14 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
15 | ** | 15 | ** |
16 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 16 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
17 | ** | 17 | ** |
18 | ** Contact info@trolltech.com if any conditions of this licensing are | 18 | ** Contact info@trolltech.com if any conditions of this licensing are |
19 | ** not clear to you. | 19 | ** not clear to you. |
20 | ** | 20 | ** |
21 | *********************************************************************</comment> | 21 | *********************************************************************</comment> |
22 | <widget> | 22 | <widget> |
23 | <class>QDialog</class> | 23 | <class>QDialog</class> |
24 | <property stdset="1"> | 24 | <property stdset="1"> |
25 | <name>name</name> | 25 | <name>name</name> |
26 | <cstring>NewTaskDialogBase</cstring> | 26 | <cstring>NewTaskDialogBase</cstring> |
27 | </property> | 27 | </property> |
28 | <property stdset="1"> | 28 | <property stdset="1"> |
29 | <name>geometry</name> | 29 | <name>geometry</name> |
30 | <rect> | 30 | <rect> |
31 | <x>0</x> | 31 | <x>0</x> |
32 | <y>0</y> | 32 | <y>0</y> |
33 | <width>249</width> | 33 | <width>245</width> |
34 | <height>321</height> | 34 | <height>321</height> |
35 | </rect> | 35 | </rect> |
36 | </property> | 36 | </property> |
37 | <property stdset="1"> | 37 | <property stdset="1"> |
38 | <name>caption</name> | 38 | <name>caption</name> |
39 | <string>New Task</string> | 39 | <string>New Task</string> |
40 | </property> | 40 | </property> |
41 | <property> | 41 | <property> |
42 | <name>layoutMargin</name> | 42 | <name>layoutMargin</name> |
43 | </property> | 43 | </property> |
44 | <property> | 44 | <property> |
45 | <name>layoutSpacing</name> | 45 | <name>layoutSpacing</name> |
46 | </property> | 46 | </property> |
47 | <vbox> | 47 | <widget> |
48 | <class>QLayoutWidget</class> | ||
48 | <property stdset="1"> | 49 | <property stdset="1"> |
49 | <name>margin</name> | 50 | <name>name</name> |
50 | <number>0</number> | 51 | <cstring>Layout3</cstring> |
51 | </property> | 52 | </property> |
52 | <property stdset="1"> | 53 | <property stdset="1"> |
53 | <name>spacing</name> | 54 | <name>geometry</name> |
54 | <number>0</number> | 55 | <rect> |
56 | <x>1</x> | ||
57 | <y>25</y> | ||
58 | <width>243</width> | ||
59 | <height>17</height> | ||
60 | </rect> | ||
55 | </property> | 61 | </property> |
56 | <widget> | 62 | <hbox> |
57 | <class>QLayoutWidget</class> | ||
58 | <property stdset="1"> | 63 | <property stdset="1"> |
59 | <name>name</name> | 64 | <name>margin</name> |
60 | <cstring>Layout4</cstring> | 65 | <number>0</number> |
61 | </property> | 66 | </property> |
62 | <hbox> | 67 | <property stdset="1"> |
68 | <name>spacing</name> | ||
69 | <number>6</number> | ||
70 | </property> | ||
71 | <widget> | ||
72 | <class>QLabel</class> | ||
63 | <property stdset="1"> | 73 | <property stdset="1"> |
64 | <name>margin</name> | 74 | <name>name</name> |
65 | <number>0</number> | 75 | <cstring>TextLabel3</cstring> |
66 | </property> | 76 | </property> |
67 | <property stdset="1"> | 77 | <property stdset="1"> |
68 | <name>spacing</name> | 78 | <name>frameShape</name> |
69 | <number>6</number> | 79 | <enum>NoFrame</enum> |
70 | </property> | 80 | </property> |
71 | <widget> | 81 | <property stdset="1"> |
72 | <class>QLabel</class> | 82 | <name>text</name> |
83 | <string>Category:</string> | ||
84 | </property> | ||
85 | </widget> | ||
86 | <widget> | ||
87 | <class>CategorySelect</class> | ||
88 | <property stdset="1"> | ||
89 | <name>name</name> | ||
90 | <cstring>comboCategory</cstring> | ||
91 | </property> | ||
92 | </widget> | ||
93 | </hbox> | ||
94 | </widget> | ||
95 | <widget> | ||
96 | <class>QLayoutWidget</class> | ||
97 | <property stdset="1"> | ||
98 | <name>name</name> | ||
99 | <cstring>Layout6</cstring> | ||
100 | </property> | ||
101 | <property stdset="1"> | ||
102 | <name>geometry</name> | ||
103 | <rect> | ||
104 | <x>0</x> | ||
105 | <y>0</y> | ||
106 | <width>240</width> | ||
107 | <height>320</height> | ||
108 | </rect> | ||
109 | </property> | ||
110 | <grid> | ||
111 | <property stdset="1"> | ||
112 | <name>margin</name> | ||
113 | <number>0</number> | ||
114 | </property> | ||
115 | <property stdset="1"> | ||
116 | <name>spacing</name> | ||
117 | <number>6</number> | ||
118 | </property> | ||
119 | <widget row="2" column="0" > | ||
120 | <class>QLayoutWidget</class> | ||
121 | <property stdset="1"> | ||
122 | <name>name</name> | ||
123 | <cstring>Layout4</cstring> | ||
124 | </property> | ||
125 | <hbox> | ||
73 | <property stdset="1"> | 126 | <property stdset="1"> |
74 | <name>name</name> | 127 | <name>margin</name> |
75 | <cstring>TextLabel2</cstring> | 128 | <number>0</number> |
76 | </property> | 129 | </property> |
77 | <property stdset="1"> | 130 | <property stdset="1"> |
78 | <name>text</name> | 131 | <name>spacing</name> |
79 | <string>Priority:</string> | 132 | <number>6</number> |
80 | </property> | 133 | </property> |
81 | </widget> | 134 | <widget> |
82 | <widget> | 135 | <class>QLabel</class> |
83 | <class>QComboBox</class> | 136 | <property stdset="1"> |
84 | <item> | 137 | <name>name</name> |
85 | <property> | 138 | <cstring>TextLabel1</cstring> |
86 | <name>text</name> | ||
87 | <string>1 - Very High</string> | ||
88 | </property> | 139 | </property> |
89 | </item> | 140 | <property stdset="1"> |
90 | <item> | ||
91 | <property> | ||
92 | <name>text</name> | 141 | <name>text</name> |
93 | <string>2 - High</string> | 142 | <string>Summary:</string> |
94 | </property> | 143 | </property> |
95 | </item> | 144 | </widget> |
96 | <item> | 145 | <widget> |
97 | <property> | 146 | <class>QLineEdit</class> |
98 | <name>text</name> | 147 | <property stdset="1"> |
99 | <string>3 - Normal</string> | 148 | <name>name</name> |
100 | </property> | 149 | <cstring>lneSum</cstring> |
101 | </item> | ||
102 | <item> | ||
103 | <property> | ||
104 | <name>text</name> | ||
105 | <string>4 - Low</string> | ||
106 | </property> | ||
107 | </item> | ||
108 | <item> | ||
109 | <property> | ||
110 | <name>text</name> | ||
111 | <string>5 - Very Low</string> | ||
112 | </property> | 150 | </property> |
113 | </item> | 151 | </widget> |
114 | <property stdset="1"> | 152 | </hbox> |
115 | <name>name</name> | 153 | </widget> |
116 | <cstring>comboPriority</cstring> | 154 | <widget row="3" column="0" > |
117 | </property> | 155 | <class>QMultiLineEdit</class> |
118 | <property stdset="1"> | ||
119 | <name>sizePolicy</name> | ||
120 | <sizepolicy> | ||
121 | <hsizetype>7</hsizetype> | ||
122 | <vsizetype>0</vsizetype> | ||
123 | </sizepolicy> | ||
124 | </property> | ||
125 | <property stdset="1"> | ||
126 | <name>currentItem</name> | ||
127 | <number>2</number> | ||
128 | </property> | ||
129 | </widget> | ||
130 | </hbox> | ||
131 | </widget> | ||
132 | <widget> | ||
133 | <class>QLayoutWidget</class> | ||
134 | <property stdset="1"> | ||
135 | <name>name</name> | ||
136 | <cstring>Layout3</cstring> | ||
137 | </property> | ||
138 | <hbox> | ||
139 | <property stdset="1"> | 156 | <property stdset="1"> |
140 | <name>margin</name> | 157 | <name>name</name> |
141 | <number>0</number> | 158 | <cstring>txtTodo</cstring> |
142 | </property> | 159 | </property> |
160 | </widget> | ||
161 | <widget row="1" column="0" > | ||
162 | <class>QLayoutWidget</class> | ||
143 | <property stdset="1"> | 163 | <property stdset="1"> |
144 | <name>spacing</name> | 164 | <name>name</name> |
145 | <number>6</number> | 165 | <cstring>Layout4</cstring> |
146 | </property> | 166 | </property> |
147 | <widget> | 167 | <hbox> |
148 | <class>QLabel</class> | ||
149 | <property stdset="1"> | ||
150 | <name>name</name> | ||
151 | <cstring>TextLabel3</cstring> | ||
152 | </property> | ||
153 | <property stdset="1"> | ||
154 | <name>frameShape</name> | ||
155 | <enum>NoFrame</enum> | ||
156 | </property> | ||
157 | <property stdset="1"> | 168 | <property stdset="1"> |
158 | <name>text</name> | 169 | <name>margin</name> |
159 | <string>Category:</string> | 170 | <number>0</number> |
160 | </property> | 171 | </property> |
161 | </widget> | ||
162 | <widget> | ||
163 | <class>CategorySelect</class> | ||
164 | <property stdset="1"> | 172 | <property stdset="1"> |
165 | <name>name</name> | 173 | <name>spacing</name> |
166 | <cstring>comboCategory</cstring> | 174 | <number>6</number> |
167 | </property> | 175 | </property> |
168 | </widget> | 176 | <widget> |
169 | </hbox> | 177 | <class>QCheckBox</class> |
170 | </widget> | 178 | <property stdset="1"> |
171 | <widget> | 179 | <name>name</name> |
172 | <class>QLayoutWidget</class> | 180 | <cstring>checkCompleted</cstring> |
173 | <property stdset="1"> | 181 | </property> |
174 | <name>name</name> | 182 | <property stdset="1"> |
175 | <cstring>Layout4</cstring> | 183 | <name>text</name> |
176 | </property> | 184 | <string>&Completed</string> |
177 | <hbox> | 185 | </property> |
178 | <property stdset="1"> | 186 | </widget> |
179 | <name>margin</name> | 187 | <widget> |
180 | <number>0</number> | 188 | <class>QCheckBox</class> |
181 | </property> | 189 | <property stdset="1"> |
190 | <name>name</name> | ||
191 | <cstring>checkDate</cstring> | ||
192 | </property> | ||
193 | <property stdset="1"> | ||
194 | <name>text</name> | ||
195 | <string>D&ue</string> | ||
196 | </property> | ||
197 | </widget> | ||
198 | <widget> | ||
199 | <class>QPushButton</class> | ||
200 | <property stdset="1"> | ||
201 | <name>name</name> | ||
202 | <cstring>buttonDate</cstring> | ||
203 | </property> | ||
204 | <property stdset="1"> | ||
205 | <name>enabled</name> | ||
206 | <bool>false</bool> | ||
207 | </property> | ||
208 | <property stdset="1"> | ||
209 | <name>text</name> | ||
210 | <string>1 Jan 2001</string> | ||
211 | </property> | ||
212 | </widget> | ||
213 | </hbox> | ||
214 | </widget> | ||
215 | <widget row="0" column="0" > | ||
216 | <class>QLayoutWidget</class> | ||
182 | <property stdset="1"> | 217 | <property stdset="1"> |
183 | <name>spacing</name> | 218 | <name>name</name> |
184 | <number>6</number> | 219 | <cstring>Layout4</cstring> |
185 | </property> | 220 | </property> |
186 | <widget> | 221 | <hbox> |
187 | <class>QCheckBox</class> | ||
188 | <property stdset="1"> | ||
189 | <name>name</name> | ||
190 | <cstring>checkCompleted</cstring> | ||
191 | </property> | ||
192 | <property stdset="1"> | 222 | <property stdset="1"> |
193 | <name>text</name> | 223 | <name>margin</name> |
194 | <string>&Completed</string> | 224 | <number>0</number> |
195 | </property> | 225 | </property> |
196 | </widget> | ||
197 | <widget> | ||
198 | <class>QCheckBox</class> | ||
199 | <property stdset="1"> | 226 | <property stdset="1"> |
200 | <name>name</name> | 227 | <name>spacing</name> |
201 | <cstring>checkDate</cstring> | 228 | <number>6</number> |
202 | </property> | 229 | </property> |
203 | <property stdset="1"> | 230 | <widget> |
204 | <name>text</name> | 231 | <class>QLabel</class> |
205 | <string>D&ue</string> | 232 | <property stdset="1"> |
206 | </property> | 233 | <name>name</name> |
207 | </widget> | 234 | <cstring>TextLabel2</cstring> |
208 | <widget> | 235 | </property> |
209 | <class>QPushButton</class> | 236 | <property stdset="1"> |
210 | <property stdset="1"> | 237 | <name>text</name> |
211 | <name>name</name> | 238 | <string>Priority:</string> |
212 | <cstring>buttonDate</cstring> | 239 | </property> |
213 | </property> | 240 | </widget> |
214 | <property stdset="1"> | 241 | <widget> |
215 | <name>enabled</name> | 242 | <class>QComboBox</class> |
216 | <bool>false</bool> | 243 | <item> |
217 | </property> | 244 | <property> |
218 | <property stdset="1"> | 245 | <name>text</name> |
219 | <name>text</name> | 246 | <string>1 - Very High</string> |
220 | <string>1 Jan 2001</string> | 247 | </property> |
221 | </property> | 248 | </item> |
222 | </widget> | 249 | <item> |
223 | </hbox> | 250 | <property> |
224 | </widget> | 251 | <name>text</name> |
225 | <widget> | 252 | <string>2 - High</string> |
226 | <class>QMultiLineEdit</class> | 253 | </property> |
227 | <property stdset="1"> | 254 | </item> |
228 | <name>name</name> | 255 | <item> |
229 | <cstring>txtTodo</cstring> | 256 | <property> |
230 | </property> | 257 | <name>text</name> |
231 | </widget> | 258 | <string>3 - Normal</string> |
232 | </vbox> | 259 | </property> |
260 | </item> | ||
261 | <item> | ||
262 | <property> | ||
263 | <name>text</name> | ||
264 | <string>4 - Low</string> | ||
265 | </property> | ||
266 | </item> | ||
267 | <item> | ||
268 | <property> | ||
269 | <name>text</name> | ||
270 | <string>5 - Very Low</string> | ||
271 | </property> | ||
272 | </item> | ||
273 | <property stdset="1"> | ||
274 | <name>name</name> | ||
275 | <cstring>comboPriority</cstring> | ||
276 | </property> | ||
277 | <property stdset="1"> | ||
278 | <name>sizePolicy</name> | ||
279 | <sizepolicy> | ||
280 | <hsizetype>7</hsizetype> | ||
281 | <vsizetype>0</vsizetype> | ||
282 | </sizepolicy> | ||
283 | </property> | ||
284 | <property stdset="1"> | ||
285 | <name>currentItem</name> | ||
286 | <number>2</number> | ||
287 | </property> | ||
288 | </widget> | ||
289 | </hbox> | ||
290 | </widget> | ||
291 | </grid> | ||
292 | </widget> | ||
233 | </widget> | 293 | </widget> |
234 | <customwidgets> | 294 | <customwidgets> |
235 | <customwidget> | 295 | <customwidget> |
236 | <class>CategorySelect</class> | 296 | <class>CategorySelect</class> |
237 | <header location="global">qpe/categoryselect.h</header> | 297 | <header location="global">qpe/categoryselect.h</header> |
238 | <sizehint> | 298 | <sizehint> |
239 | <width>-1</width> | 299 | <width>-1</width> |
240 | <height>-1</height> | 300 | <height>-1</height> |
241 | </sizehint> | 301 | </sizehint> |
242 | <container>0</container> | 302 | <container>0</container> |
243 | <sizepolicy> | 303 | <sizepolicy> |
244 | <hordata>7</hordata> | 304 | <hordata>7</hordata> |
245 | <verdata>1</verdata> | 305 | <verdata>1</verdata> |
246 | </sizepolicy> | 306 | </sizepolicy> |
247 | <pixmap>image0</pixmap> | 307 | <pixmap>image0</pixmap> |
248 | </customwidget> | 308 | </customwidget> |
249 | </customwidgets> | 309 | </customwidgets> |
250 | <images> | 310 | <images> |
251 | <image> | 311 | <image> |
252 | <name>image0</name> | 312 | <name>image0</name> |
253 | <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1be245fc04c5a3201e4615f430059d0711ff5ddb2e6bb236ec90eed134cb5a19d8ef36602af5ecdbfeeac05dda0798d3abebde87e3faa374d3807fa0d633a52d38d8de6f679fe33fc776e196f53cd010188256a3600a292882096246517815ca99884606e18044a3a40d91824820924265a7923a2e8bcd05f33db1173e002913175f2a6be6d3294871a2d95fa00e8a94ee017b69d339d90df1e77c57ea072ede6758</data> | 313 | <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1be245fc04c5a3201e4615f430059d0711ff5ddb2e6bb236ec90eed134cb5a19d8ef36602af5ecdbfeeac05dda0798d3abebde87e3faa374d3807fa0d633a52d38d8de6f679fe33fc776e196f53cd010188256a3600a292882096246517815ca99884606e18044a3a40d91824820924265a7923a2e8bcd05f33db1173e002913175f2a6be6d3294871a2d95fa00e8a94ee017b69d339d90df1e77c57ea072ede6758</data> |
254 | </image> | 314 | </image> |
255 | </images> | 315 | </images> |
256 | <connections> | 316 | <connections> |
257 | <connection> | 317 | <connection> |
258 | <sender>checkDate</sender> | 318 | <sender>checkDate</sender> |
259 | <signal>toggled(bool)</signal> | 319 | <signal>toggled(bool)</signal> |
260 | <receiver>buttonDate</receiver> | 320 | <receiver>buttonDate</receiver> |
261 | <slot>setEnabled(bool)</slot> | 321 | <slot>setEnabled(bool)</slot> |
262 | </connection> | 322 | </connection> |
263 | <slot access="protected">dateChanged( const QString & )</slot> | 323 | <slot access="protected">dateChanged( const QString & )</slot> |
264 | <slot access="protected">dateChanged( int, int, int )</slot> | 324 | <slot access="protected">dateChanged( int, int, int )</slot> |
265 | </connections> | 325 | </connections> |
266 | </UI> | 326 | </UI> |
diff --git a/core/pim/todo/todoentryimpl.cpp b/core/pim/todo/todoentryimpl.cpp index 26a685c..dfaf9b4 100644 --- a/core/pim/todo/todoentryimpl.cpp +++ b/core/pim/todo/todoentryimpl.cpp | |||
@@ -1,153 +1,156 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** Copyright (C) 2002 zecke | ||
3 | ** | 4 | ** |
4 | ** This file is part of Qtopia Environment. | 5 | ** This file is part of Qtopia Environment. |
5 | ** | 6 | ** |
6 | ** 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 |
7 | ** 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 |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 9 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 10 | ** packaging of this file. |
10 | ** | 11 | ** |
11 | ** 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 |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 13 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 14 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 15 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 16 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 17 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 18 | ** not clear to you. |
18 | ** | 19 | ** |
19 | **********************************************************************/ | 20 | **********************************************************************/ |
20 | 21 | ||
21 | #include "todoentryimpl.h" | 22 | #include "todoentryimpl.h" |
22 | 23 | ||
23 | #include <opie/todoevent.h> | 24 | #include <opie/todoevent.h> |
24 | #include <opie/tododb.h> | 25 | #include <opie/tododb.h> |
25 | 26 | ||
26 | #include <qpe/categoryselect.h> | 27 | #include <qpe/categoryselect.h> |
27 | #include <qpe/datebookmonth.h> | 28 | #include <qpe/datebookmonth.h> |
28 | #include <qpe/global.h> | 29 | #include <qpe/global.h> |
29 | #include <qpe/imageedit.h> | 30 | #include <qpe/imageedit.h> |
30 | #include <qpe/timestring.h> | 31 | #include <qpe/timestring.h> |
31 | #include <qpe/palmtoprecord.h> | 32 | #include <qpe/palmtoprecord.h> |
32 | 33 | ||
33 | #include <qmessagebox.h> | 34 | #include <qmessagebox.h> |
34 | #include <qpopupmenu.h> | 35 | #include <qpopupmenu.h> |
35 | #include <qtoolbutton.h> | 36 | #include <qtoolbutton.h> |
36 | #include <qcombobox.h> | 37 | #include <qcombobox.h> |
37 | #include <qcheckbox.h> | 38 | #include <qcheckbox.h> |
38 | #include <qlineedit.h> | 39 | #include <qlineedit.h> |
39 | #include <qmultilineedit.h> | 40 | #include <qmultilineedit.h> |
40 | #include <qlabel.h> | 41 | #include <qlabel.h> |
41 | #include <qtimer.h> | 42 | #include <qtimer.h> |
42 | #include <qapplication.h> | 43 | #include <qapplication.h> |
43 | 44 | ||
44 | 45 | ||
45 | NewTaskDialog::NewTaskDialog( const ToDoEvent& task, QWidget *parent, | 46 | NewTaskDialog::NewTaskDialog( const ToDoEvent& task, QWidget *parent, |
46 | const char *name, bool modal, WFlags fl ) | 47 | const char *name, bool modal, WFlags fl ) |
47 | : NewTaskDialogBase( parent, name, modal, fl ), | 48 | : NewTaskDialogBase( parent, name, modal, fl ), |
48 | todo( task ) | 49 | todo( task ) |
49 | { | 50 | { |
50 | todo.setCategories( task.allCategories() ); | 51 | todo.setCategories( task.allCategories() ); |
51 | if ( todo.hasDate() ) | 52 | if ( todo.hasDate() ) |
52 | date = todo.date(); | 53 | date = todo.date(); |
53 | else | 54 | else |
54 | date = QDate::currentDate(); | 55 | date = QDate::currentDate(); |
55 | 56 | ||
56 | init(); | 57 | init(); |
57 | comboPriority->setCurrentItem( task.priority() - 1 ); | 58 | comboPriority->setCurrentItem( task.priority() - 1 ); |
58 | 59 | ||
59 | checkCompleted->setChecked( task.isCompleted() ); | 60 | checkCompleted->setChecked( task.isCompleted() ); |
60 | checkDate->setChecked( task.hasDate() ); | 61 | checkDate->setChecked( task.hasDate() ); |
61 | buttonDate->setText( TimeString::longDateString( date ) ); | 62 | buttonDate->setText( TimeString::longDateString( date ) ); |
62 | 63 | ||
63 | txtTodo->setText( task.description() ); | 64 | txtTodo->setText( task.description() ); |
65 | lneSum->setText( task.summary() ); | ||
64 | } | 66 | } |
65 | 67 | ||
66 | /* | 68 | /* |
67 | * Constructs a NewTaskDialog which is a child of 'parent', with the | 69 | * Constructs a NewTaskDialog which is a child of 'parent', with the |
68 | * name 'name' and widget flags set to 'f' | 70 | * name 'name' and widget flags set to 'f' |
69 | * | 71 | * |
70 | * The dialog will by default be modeless, unless you set 'modal' to | 72 | * The dialog will by default be modeless, unless you set 'modal' to |
71 | * TRUE to construct a modal dialog. | 73 | * TRUE to construct a modal dialog. |
72 | */ | 74 | */ |
73 | NewTaskDialog::NewTaskDialog( int id, QWidget* parent, const char* name, bool modal, | 75 | NewTaskDialog::NewTaskDialog( int id, QWidget* parent, const char* name, bool modal, |
74 | WFlags fl ) | 76 | WFlags fl ) |
75 | : NewTaskDialogBase( parent, name, modal, fl ), | 77 | : NewTaskDialogBase( parent, name, modal, fl ), |
76 | date( QDate::currentDate() ) | 78 | date( QDate::currentDate() ) |
77 | { | 79 | { |
78 | if ( id != -1 ) { | 80 | if ( id != -1 ) { |
79 | QArray<int> ids( 1 ); | 81 | QArray<int> ids( 1 ); |
80 | ids[0] = id; | 82 | ids[0] = id; |
81 | todo.setCategory( Qtopia::Record::idsToString( ids ) ); | 83 | todo.setCategory( Qtopia::Record::idsToString( ids ) ); |
82 | } | 84 | } |
83 | init(); | 85 | init(); |
84 | } | 86 | } |
85 | 87 | ||
86 | void NewTaskDialog::init() | 88 | void NewTaskDialog::init() |
87 | { | 89 | { |
88 | QPopupMenu *m1 = new QPopupMenu( this ); | 90 | QPopupMenu *m1 = new QPopupMenu( this ); |
89 | picker = new DateBookMonth( m1, 0, TRUE ); | 91 | picker = new DateBookMonth( m1, 0, TRUE ); |
90 | m1->insertItem( picker ); | 92 | m1->insertItem( picker ); |
91 | buttonDate->setPopup( m1 ); | 93 | buttonDate->setPopup( m1 ); |
92 | comboCategory->setCategories( todo.categories(), "Todo List", tr("Todo List") ); | 94 | comboCategory->setCategories( todo.categories(), "Todo List", tr("Todo List") ); |
93 | 95 | ||
94 | connect( picker, SIGNAL( dateClicked( int, int, int ) ), | 96 | connect( picker, SIGNAL( dateClicked( int, int, int ) ), |
95 | this, SLOT( dateChanged( int, int, int ) ) ); | 97 | this, SLOT( dateChanged( int, int, int ) ) ); |
96 | 98 | ||
97 | buttonDate->setText( TimeString::longDateString( date ) ); | 99 | buttonDate->setText( TimeString::longDateString( date ) ); |
98 | picker->setDate( date.year(), date.month(), date.day() ); | 100 | picker->setDate( date.year(), date.month(), date.day() ); |
99 | } | 101 | } |
100 | 102 | ||
101 | /* | 103 | /* |
102 | * Destroys the object and frees any allocated resources | 104 | * Destroys the object and frees any allocated resources |
103 | */ | 105 | */ |
104 | NewTaskDialog::~NewTaskDialog() | 106 | NewTaskDialog::~NewTaskDialog() |
105 | { | 107 | { |
106 | // 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 |
107 | } | 109 | } |
108 | void NewTaskDialog::dateChanged( int y, int m, int d ) | 110 | void NewTaskDialog::dateChanged( int y, int m, int d ) |
109 | { | 111 | { |
110 | date = QDate( y, m, d ); | 112 | date = QDate( y, m, d ); |
111 | buttonDate->setText( TimeString::longDateString( date ) ); | 113 | buttonDate->setText( TimeString::longDateString( date ) ); |
112 | } | 114 | } |
113 | 115 | ||
114 | /*! | 116 | /*! |
115 | */ | 117 | */ |
116 | 118 | ||
117 | ToDoEvent NewTaskDialog::todoEntry() | 119 | ToDoEvent NewTaskDialog::todoEntry() |
118 | { | 120 | { |
119 | if( checkDate->isChecked() ){ | 121 | if( checkDate->isChecked() ){ |
120 | todo.setDate( date ); | 122 | todo.setDate( date ); |
121 | todo.setHasDate( true ); | 123 | todo.setHasDate( true ); |
122 | }else{ | 124 | }else{ |
123 | todo.setHasDate( false ); | 125 | todo.setHasDate( false ); |
124 | } | 126 | } |
125 | if ( comboCategory->currentCategory() != -1 ) { | 127 | if ( comboCategory->currentCategory() != -1 ) { |
126 | QArray<int> arr = comboCategory->currentCategories(); | 128 | QArray<int> arr = comboCategory->currentCategories(); |
127 | QStringList list; | 129 | QStringList list; |
128 | list = QStringList::split(";", Qtopia::Record::idsToString( arr )) ; | 130 | list = QStringList::split(";", Qtopia::Record::idsToString( arr )) ; |
129 | todo.setCategories( list ); | 131 | todo.setCategories( list ); |
130 | } | 132 | } |
131 | todo.setPriority( comboPriority->currentItem() + 1 ); | 133 | todo.setPriority( comboPriority->currentItem() + 1 ); |
132 | todo.setCompleted( checkCompleted->isChecked() ); | 134 | todo.setCompleted( checkCompleted->isChecked() ); |
133 | 135 | ||
134 | todo.setDescription( txtTodo->text() ); | 136 | todo.setDescription( txtTodo->text() ); |
135 | 137 | todo.setSummary( lneSum->text() ); | |
138 | |||
136 | return todo; | 139 | return todo; |
137 | } | 140 | } |
138 | 141 | ||
139 | 142 | ||
140 | /*! | 143 | /*! |
141 | 144 | ||
142 | */ | 145 | */ |
143 | 146 | ||
144 | void NewTaskDialog::accept() | 147 | void NewTaskDialog::accept() |
145 | { | 148 | { |
146 | QString strText = txtTodo->text(); | 149 | QString strText = txtTodo->text(); |
147 | if ( strText.isEmpty() ) { | 150 | if ( strText.isEmpty() ) { |
148 | // hmm... just decline it then, the user obviously didn't care about it | 151 | // hmm... just decline it then, the user obviously didn't care about it |
149 | QDialog::reject(); | 152 | QDialog::reject(); |
150 | return; | 153 | return; |
151 | } | 154 | } |
152 | QDialog::accept(); | 155 | QDialog::accept(); |
153 | } | 156 | } |
diff --git a/core/pim/todo/todotable.cpp b/core/pim/todo/todotable.cpp index 52a3087..779b28c 100644 --- a/core/pim/todo/todotable.cpp +++ b/core/pim/todo/todotable.cpp | |||
@@ -1,938 +1,945 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | /* Show Deadline was added by Stefan Eilers (se, eilers.stefan@epost.de) | 20 | /* Show Deadline was added by Stefan Eilers (se, eilers.stefan@epost.de) |
21 | */ | 21 | */ |
22 | #include "todotable.h" | 22 | #include "todotable.h" |
23 | 23 | ||
24 | #include <opie/tododb.h> | 24 | #include <opie/tododb.h> |
25 | #include <opie/xmltree.h> | 25 | #include <opie/xmltree.h> |
26 | 26 | ||
27 | #include <qpe/categoryselect.h> | 27 | #include <qpe/categoryselect.h> |
28 | #include <qpe/xmlreader.h> | 28 | #include <qpe/xmlreader.h> |
29 | 29 | ||
30 | #include <qasciidict.h> | 30 | #include <qasciidict.h> |
31 | #include <qcombobox.h> | 31 | #include <qcombobox.h> |
32 | #include <qfile.h> | 32 | #include <qfile.h> |
33 | #include <qpainter.h> | 33 | #include <qpainter.h> |
34 | #include <qtextcodec.h> | 34 | #include <qtextcodec.h> |
35 | #include <qtimer.h> | 35 | #include <qtimer.h> |
36 | #include <qdatetime.h> | 36 | #include <qdatetime.h> |
37 | #include <qtextstream.h> | 37 | #include <qtextstream.h> |
38 | 38 | ||
39 | #include <qcursor.h> | 39 | #include <qcursor.h> |
40 | #include <qregexp.h> | 40 | #include <qregexp.h> |
41 | 41 | ||
42 | #include <errno.h> | 42 | #include <errno.h> |
43 | #include <stdlib.h> | 43 | #include <stdlib.h> |
44 | 44 | ||
45 | #include <stdio.h> | 45 | #include <stdio.h> |
46 | 46 | ||
47 | using namespace Opie; | 47 | using namespace Opie; |
48 | 48 | ||
49 | namespace { | 49 | namespace { |
50 | 50 | ||
51 | static bool taskCompare( const ToDoEvent &task, const QRegExp &r, int category ); | 51 | static bool taskCompare( const ToDoEvent &task, const QRegExp &r, int category ); |
52 | static QString journalFileName(); | 52 | static QString journalFileName(); |
53 | static ToDoEvent xmlToEvent( XMLElement *ev ); | 53 | static ToDoEvent xmlToEvent( XMLElement *ev ); |
54 | } | 54 | } |
55 | CheckItem::CheckItem( QTable *t, const QString &key ) | 55 | CheckItem::CheckItem( QTable *t, const QString &key ) |
56 | : QTableItem( t, Never, "" ), checked( FALSE ), sortKey( key ) | 56 | : QTableItem( t, Never, "" ), checked( FALSE ), sortKey( key ) |
57 | { | 57 | { |
58 | } | 58 | } |
59 | 59 | ||
60 | QString CheckItem::key() const | 60 | QString CheckItem::key() const |
61 | { | 61 | { |
62 | return sortKey; | 62 | return sortKey; |
63 | } | 63 | } |
64 | 64 | ||
65 | void CheckItem::setChecked( bool b ) | 65 | void CheckItem::setChecked( bool b ) |
66 | { | 66 | { |
67 | checked = b; | 67 | checked = b; |
68 | table()->updateCell( row(), col() ); | 68 | table()->updateCell( row(), col() ); |
69 | } | 69 | } |
70 | 70 | ||
71 | void CheckItem::toggle() | 71 | void CheckItem::toggle() |
72 | { | 72 | { |
73 | TodoTable *parent = static_cast<TodoTable*>(table()); | 73 | TodoTable *parent = static_cast<TodoTable*>(table()); |
74 | ToDoEvent newTodo = parent->currentEntry(); | 74 | ToDoEvent newTodo = parent->currentEntry(); |
75 | checked = !checked; | 75 | checked = !checked; |
76 | newTodo.setCompleted( checked ); | 76 | newTodo.setCompleted( checked ); |
77 | table()->updateCell( row(), col() ); | 77 | table()->updateCell( row(), col() ); |
78 | parent->replaceCurrentEntry( newTodo, true ); | 78 | parent->replaceCurrentEntry( newTodo, true ); |
79 | } | 79 | } |
80 | 80 | ||
81 | bool CheckItem::isChecked() const | 81 | bool CheckItem::isChecked() const |
82 | { | 82 | { |
83 | return checked; | 83 | return checked; |
84 | } | 84 | } |
85 | 85 | ||
86 | static const int BoxSize = 10; | 86 | static const int BoxSize = 10; |
87 | 87 | ||
88 | void CheckItem::paint( QPainter *p, const QColorGroup &cg, const QRect &cr, | 88 | void CheckItem::paint( QPainter *p, const QColorGroup &cg, const QRect &cr, |
89 | bool ) | 89 | bool ) |
90 | { | 90 | { |
91 | p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Base ) ); | 91 | p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Base ) ); |
92 | 92 | ||
93 | int marg = ( cr.width() - BoxSize ) / 2; | 93 | int marg = ( cr.width() - BoxSize ) / 2; |
94 | int x = 0; | 94 | int x = 0; |
95 | int y = ( cr.height() - BoxSize ) / 2; | 95 | int y = ( cr.height() - BoxSize ) / 2; |
96 | p->setPen( QPen( cg.text() ) ); | 96 | p->setPen( QPen( cg.text() ) ); |
97 | p->drawRect( x + marg, y, BoxSize, BoxSize ); | 97 | p->drawRect( x + marg, y, BoxSize, BoxSize ); |
98 | p->drawRect( x + marg+1, y+1, BoxSize-2, BoxSize-2 ); | 98 | p->drawRect( x + marg+1, y+1, BoxSize-2, BoxSize-2 ); |
99 | p->setPen( darkGreen ); | 99 | p->setPen( darkGreen ); |
100 | x += 1; | 100 | x += 1; |
101 | y += 1; | 101 | y += 1; |
102 | if ( checked ) { | 102 | if ( checked ) { |
103 | QPointArray a( 7*2 ); | 103 | QPointArray a( 7*2 ); |
104 | int i, xx, yy; | 104 | int i, xx, yy; |
105 | xx = x+1+marg; | 105 | xx = x+1+marg; |
106 | yy = y+2; | 106 | yy = y+2; |
107 | for ( i=0; i<3; i++ ) { | 107 | for ( i=0; i<3; i++ ) { |
108 | a.setPoint( 2*i, xx, yy ); | 108 | a.setPoint( 2*i, xx, yy ); |
109 | a.setPoint( 2*i+1, xx, yy+2 ); | 109 | a.setPoint( 2*i+1, xx, yy+2 ); |
110 | xx++; yy++; | 110 | xx++; yy++; |
111 | } | 111 | } |
112 | yy -= 2; | 112 | yy -= 2; |
113 | for ( i=3; i<7; i++ ) { | 113 | for ( i=3; i<7; i++ ) { |
114 | a.setPoint( 2*i, xx, yy ); | 114 | a.setPoint( 2*i, xx, yy ); |
115 | a.setPoint( 2*i+1, xx, yy+2 ); | 115 | a.setPoint( 2*i+1, xx, yy+2 ); |
116 | xx++; yy--; | 116 | xx++; yy--; |
117 | } | 117 | } |
118 | p->drawLineSegments( a ); | 118 | p->drawLineSegments( a ); |
119 | } | 119 | } |
120 | } | 120 | } |
121 | 121 | ||
122 | 122 | ||
123 | ComboItem::ComboItem( QTable *t, EditType et ) | 123 | ComboItem::ComboItem( QTable *t, EditType et ) |
124 | : QTableItem( t, et, "3" ), cb( 0 ) | 124 | : QTableItem( t, et, "3" ), cb( 0 ) |
125 | { | 125 | { |
126 | setReplaceable( FALSE ); | 126 | setReplaceable( FALSE ); |
127 | } | 127 | } |
128 | 128 | ||
129 | QWidget *ComboItem::createEditor() const | 129 | QWidget *ComboItem::createEditor() const |
130 | { | 130 | { |
131 | QString txt = text(); | 131 | QString txt = text(); |
132 | ( (ComboItem*)this )->cb = new QComboBox( table()->viewport() ); | 132 | ( (ComboItem*)this )->cb = new QComboBox( table()->viewport() ); |
133 | cb->insertItem( "1" ); | 133 | cb->insertItem( "1" ); |
134 | cb->insertItem( "2" ); | 134 | cb->insertItem( "2" ); |
135 | cb->insertItem( "3" ); | 135 | cb->insertItem( "3" ); |
136 | cb->insertItem( "4" ); | 136 | cb->insertItem( "4" ); |
137 | cb->insertItem( "5" ); | 137 | cb->insertItem( "5" ); |
138 | cb->setCurrentItem( txt.toInt() - 1 ); | 138 | cb->setCurrentItem( txt.toInt() - 1 ); |
139 | return cb; | 139 | return cb; |
140 | } | 140 | } |
141 | 141 | ||
142 | void ComboItem::setContentFromEditor( QWidget *w ) | 142 | void ComboItem::setContentFromEditor( QWidget *w ) |
143 | { | 143 | { |
144 | TodoTable *parent = static_cast<TodoTable*>(table()); | 144 | TodoTable *parent = static_cast<TodoTable*>(table()); |
145 | ToDoEvent newTodo = parent->currentEntry(); | 145 | ToDoEvent newTodo = parent->currentEntry(); |
146 | 146 | ||
147 | if ( w->inherits( "QComboBox" ) ) | 147 | if ( w->inherits( "QComboBox" ) ) |
148 | setText( ( (QComboBox*)w )->currentText() ); | 148 | setText( ( (QComboBox*)w )->currentText() ); |
149 | else | 149 | else |
150 | QTableItem::setContentFromEditor( w ); | 150 | QTableItem::setContentFromEditor( w ); |
151 | newTodo.setPriority( text().toInt() ); | 151 | newTodo.setPriority( text().toInt() ); |
152 | parent->replaceCurrentEntry( newTodo, true ); | 152 | parent->replaceCurrentEntry( newTodo, true ); |
153 | } | 153 | } |
154 | 154 | ||
155 | void ComboItem::setText( const QString &s ) | 155 | void ComboItem::setText( const QString &s ) |
156 | { | 156 | { |
157 | if ( cb ) | 157 | if ( cb ) |
158 | cb->setCurrentItem( s.toInt() - 1 ); | 158 | cb->setCurrentItem( s.toInt() - 1 ); |
159 | QTableItem::setText( s ); | 159 | QTableItem::setText( s ); |
160 | } | 160 | } |
161 | 161 | ||
162 | QString ComboItem::text() const | 162 | QString ComboItem::text() const |
163 | { | 163 | { |
164 | if ( cb ) | 164 | if ( cb ) |
165 | return cb->currentText(); | 165 | return cb->currentText(); |
166 | return QTableItem::text(); | 166 | return QTableItem::text(); |
167 | } | 167 | } |
168 | DueTextItem::DueTextItem( QTable *t, ToDoEvent *ev ) | 168 | DueTextItem::DueTextItem( QTable *t, ToDoEvent *ev ) |
169 | : QTableItem(t, Never, QString::null ) | 169 | : QTableItem(t, Never, QString::null ) |
170 | { | 170 | { |
171 | setToDoEvent( ev ); | 171 | setToDoEvent( ev ); |
172 | } | 172 | } |
173 | QString DueTextItem::key() const | 173 | QString DueTextItem::key() const |
174 | { | 174 | { |
175 | QString key; | 175 | QString key; |
176 | if( m_hasDate ){ | 176 | if( m_hasDate ){ |
177 | if(m_off == 0 ){ | 177 | if(m_off == 0 ){ |
178 | key.append("b"); | 178 | key.append("b"); |
179 | }else if( m_off > 0 ){ | 179 | }else if( m_off > 0 ){ |
180 | key.append("c"); | 180 | key.append("c"); |
181 | }else if( m_off < 0 ){ | 181 | }else if( m_off < 0 ){ |
182 | key.append("a"); | 182 | key.append("a"); |
183 | } | 183 | } |
184 | key.append(QString::number(m_off ) ); | 184 | key.append(QString::number(m_off ) ); |
185 | }else{ | 185 | }else{ |
186 | key.append("d"); | 186 | key.append("d"); |
187 | } | 187 | } |
188 | return key; | 188 | return key; |
189 | } | 189 | } |
190 | void DueTextItem::setToDoEvent( const ToDoEvent *ev ) | 190 | void DueTextItem::setToDoEvent( const ToDoEvent *ev ) |
191 | { | 191 | { |
192 | m_hasDate = ev->hasDate(); | 192 | m_hasDate = ev->hasDate(); |
193 | m_completed = ev->isCompleted(); | 193 | m_completed = ev->isCompleted(); |
194 | if( ev->hasDate() ){ | 194 | if( ev->hasDate() ){ |
195 | QDate today = QDate::currentDate(); | 195 | QDate today = QDate::currentDate(); |
196 | m_off = today.daysTo(ev->date() ); | 196 | m_off = today.daysTo(ev->date() ); |
197 | //qWarning("DueText m_off=%d", m_off ); | 197 | //qWarning("DueText m_off=%d", m_off ); |
198 | setText( QString::number(m_off) + " day(s) " ); | 198 | setText( QString::number(m_off) + " day(s) " ); |
199 | }else{ | 199 | }else{ |
200 | setText("n.d." ); | 200 | setText("n.d." ); |
201 | m_off = 0; | 201 | m_off = 0; |
202 | } | 202 | } |
203 | //qWarning("m_off=%d", m_off ); | 203 | //qWarning("m_off=%d", m_off ); |
204 | } | 204 | } |
205 | void DueTextItem::paint( QPainter *p, const QColorGroup &cg, const QRect &cr, bool selected ) | 205 | void DueTextItem::paint( QPainter *p, const QColorGroup &cg, const QRect &cr, bool selected ) |
206 | { | 206 | { |
207 | //qWarning ("paint m_off=%d", m_off ); | 207 | //qWarning ("paint m_off=%d", m_off ); |
208 | QColorGroup cg2(cg); | 208 | QColorGroup cg2(cg); |
209 | QColor text = cg.text(); | 209 | QColor text = cg.text(); |
210 | if( m_hasDate && !m_completed ){ | 210 | if( m_hasDate && !m_completed ){ |
211 | if( m_off < 0 ){ | 211 | if( m_off < 0 ){ |
212 | cg2.setColor(QColorGroup::Text, QColor(red ) ); | 212 | cg2.setColor(QColorGroup::Text, QColor(red ) ); |
213 | }else if( m_off == 0 ){ | 213 | }else if( m_off == 0 ){ |
214 | cg2.setColor(QColorGroup::Text, QColor(yellow) ); // orange isn't predefined | 214 | cg2.setColor(QColorGroup::Text, QColor(yellow) ); // orange isn't predefined |
215 | }else if( m_off > 0){ | 215 | }else if( m_off > 0){ |
216 | cg2.setColor(QColorGroup::Text, QColor(green ) ); | 216 | cg2.setColor(QColorGroup::Text, QColor(green ) ); |
217 | } | 217 | } |
218 | } | 218 | } |
219 | QTableItem::paint(p, cg2, cr, selected ); | 219 | QTableItem::paint(p, cg2, cr, selected ); |
220 | cg2.setColor(QColorGroup::Text, text ); | 220 | cg2.setColor(QColorGroup::Text, text ); |
221 | } | 221 | } |
222 | TodoTable::TodoTable( QWidget *parent, const char *name ) | 222 | TodoTable::TodoTable( QWidget *parent, const char *name ) |
223 | // #ifdef QT_QTABLE_NOHEADER_CONSTRUCTOR | 223 | // #ifdef QT_QTABLE_NOHEADER_CONSTRUCTOR |
224 | // : QTable( 0, 3, parent, name, TRUE ), | 224 | // : QTable( 0, 3, parent, name, TRUE ), |
225 | // #else | 225 | // #else |
226 | : QTable( 0, 4, parent, name ), | 226 | : QTable( 0, 4, parent, name ), |
227 | // #endif | 227 | // #endif |
228 | showComp( true ), | 228 | showComp( true ), |
229 | enablePainting( true ), | 229 | enablePainting( true ), |
230 | mCat( 0 ), | 230 | mCat( 0 ), |
231 | currFindRow( -2 ), | 231 | currFindRow( -2 ), |
232 | showDeadl( true) | 232 | showDeadl( true) |
233 | { | 233 | { |
234 | mCat.load( categoryFileName() ); | 234 | mCat.load( categoryFileName() ); |
235 | setSorting( TRUE ); | 235 | setSorting( TRUE ); |
236 | setSelectionMode( NoSelection ); | 236 | setSelectionMode( NoSelection ); |
237 | setColumnStretchable( 2, TRUE ); | 237 | setColumnStretchable( 2, TRUE ); |
238 | setColumnWidth( 0, 20 ); | 238 | setColumnWidth( 0, 20 ); |
239 | setColumnWidth( 1, 35 ); | 239 | setColumnWidth( 1, 35 ); |
240 | 240 | ||
241 | setLeftMargin( 0 ); | 241 | setLeftMargin( 0 ); |
242 | verticalHeader()->hide(); | 242 | verticalHeader()->hide(); |
243 | horizontalHeader()->setLabel( 0, tr( "C." ) ); | 243 | horizontalHeader()->setLabel( 0, tr( "C." ) ); |
244 | horizontalHeader()->setLabel( 1, tr( "Prior." ) ); | 244 | horizontalHeader()->setLabel( 1, tr( "Prior." ) ); |
245 | horizontalHeader()->setLabel( 2, tr( "Description" ) ); | 245 | horizontalHeader()->setLabel( 2, tr( "Description" ) ); |
246 | 246 | ||
247 | setColumnStretchable( 3, FALSE ); | 247 | setColumnStretchable( 3, FALSE ); |
248 | setColumnWidth( 3, 20 ); | 248 | setColumnWidth( 3, 20 ); |
249 | horizontalHeader()->setLabel( 3, tr( "Deadline" ) ); | 249 | horizontalHeader()->setLabel( 3, tr( "Deadline" ) ); |
250 | 250 | ||
251 | if (showDeadl){ | 251 | if (showDeadl){ |
252 | showColumn (3); | 252 | showColumn (3); |
253 | }else{ | 253 | }else{ |
254 | hideColumn (3); | 254 | hideColumn (3); |
255 | } | 255 | } |
256 | 256 | ||
257 | connect( this, SIGNAL( clicked( int, int, int, const QPoint & ) ), | 257 | connect( this, SIGNAL( clicked( int, int, int, const QPoint & ) ), |
258 | this, SLOT( slotClicked( int, int, int, const QPoint & ) ) ); | 258 | this, SLOT( slotClicked( int, int, int, const QPoint & ) ) ); |
259 | connect( this, SIGNAL( pressed( int, int, int, const QPoint & ) ), | 259 | connect( this, SIGNAL( pressed( int, int, int, const QPoint & ) ), |
260 | this, SLOT( slotPressed( int, int, int, const QPoint & ) ) ); | 260 | this, SLOT( slotPressed( int, int, int, const QPoint & ) ) ); |
261 | connect( this, SIGNAL( valueChanged( int, int ) ), | 261 | connect( this, SIGNAL( valueChanged( int, int ) ), |
262 | this, SLOT( slotCheckPriority( int, int ) ) ); | 262 | this, SLOT( slotCheckPriority( int, int ) ) ); |
263 | connect( this, SIGNAL( currentChanged( int, int ) ), | 263 | connect( this, SIGNAL( currentChanged( int, int ) ), |
264 | this, SLOT( slotCurrentChanged( int, int ) ) ); | 264 | this, SLOT( slotCurrentChanged( int, int ) ) ); |
265 | 265 | ||
266 | menuTimer = new QTimer( this ); | 266 | menuTimer = new QTimer( this ); |
267 | connect( menuTimer, SIGNAL(timeout()), this, SLOT(slotShowMenu()) ); | 267 | connect( menuTimer, SIGNAL(timeout()), this, SLOT(slotShowMenu()) ); |
268 | 268 | ||
269 | mDayTimer = new QTimer( this ); | 269 | mDayTimer = new QTimer( this ); |
270 | connect( mDayTimer, SIGNAL(timeout()), this, SLOT(slotCheckDay() ) ); | 270 | connect( mDayTimer, SIGNAL(timeout()), this, SLOT(slotCheckDay() ) ); |
271 | mDay = QDate::currentDate(); | 271 | mDay = QDate::currentDate(); |
272 | } | 272 | } |
273 | 273 | ||
274 | void TodoTable::addEntry( const ToDoEvent &todo ) | 274 | void TodoTable::addEntry( const ToDoEvent &todo ) |
275 | { | 275 | { |
276 | int row = numRows(); | 276 | int row = numRows(); |
277 | setNumRows( row + 1 ); | 277 | setNumRows( row + 1 ); |
278 | updateJournal( todo, ACTION_ADD ); | 278 | updateJournal( todo, ACTION_ADD ); |
279 | insertIntoTable( new ToDoEvent(todo), row ); | 279 | insertIntoTable( new ToDoEvent(todo), row ); |
280 | setCurrentCell(row, currentColumn()); | 280 | setCurrentCell(row, currentColumn()); |
281 | updateVisible(); | 281 | updateVisible(); |
282 | } | 282 | } |
283 | 283 | ||
284 | void TodoTable::slotClicked( int row, int col, int, const QPoint &pos ) | 284 | void TodoTable::slotClicked( int row, int col, int, const QPoint &pos ) |
285 | { | 285 | { |
286 | if ( !cellGeometry( row, col ).contains(pos) ) | 286 | if ( !cellGeometry( row, col ).contains(pos) ) |
287 | return; | 287 | return; |
288 | // let's switch on the column number... | 288 | // let's switch on the column number... |
289 | switch ( col ) | 289 | switch ( col ) |
290 | { | 290 | { |
291 | case 0: { | 291 | case 0: { |
292 | CheckItem *i = static_cast<CheckItem*>(item( row, col )); | 292 | CheckItem *i = static_cast<CheckItem*>(item( row, col )); |
293 | if ( i ) { | 293 | if ( i ) { |
294 | int x = pos.x() - columnPos( col ); | 294 | int x = pos.x() - columnPos( col ); |
295 | int y = pos.y() - rowPos( row ); | 295 | int y = pos.y() - rowPos( row ); |
296 | int w = columnWidth( col ); | 296 | int w = columnWidth( col ); |
297 | int h = rowHeight( row ); | 297 | int h = rowHeight( row ); |
298 | if ( i && x >= ( w - BoxSize ) / 2 && x <= ( w - BoxSize ) / 2 + BoxSize && | 298 | if ( i && x >= ( w - BoxSize ) / 2 && x <= ( w - BoxSize ) / 2 + BoxSize && |
299 | y >= ( h - BoxSize ) / 2 && y <= ( h - BoxSize ) / 2 + BoxSize ) { | 299 | y >= ( h - BoxSize ) / 2 && y <= ( h - BoxSize ) / 2 + BoxSize ) { |
300 | i->toggle(); | 300 | i->toggle(); |
301 | } | 301 | } |
302 | emit signalDoneChanged( i->isChecked() ); | 302 | emit signalDoneChanged( i->isChecked() ); |
303 | } | 303 | } |
304 | } | 304 | } |
305 | break; | 305 | break; |
306 | case 1: | 306 | case 1: |
307 | break; | 307 | break; |
308 | case 2: | 308 | case 2: |
309 | // Show detailed view of the selected entry | 309 | // Show detailed view of the selected entry |
310 | { | 310 | { |
311 | menuTimer->stop(); | 311 | menuTimer->stop(); |
312 | ToDoEvent *todo = todoList[static_cast<CheckItem*>(item(row, 0))]; | 312 | ToDoEvent *todo = todoList[static_cast<CheckItem*>(item(row, 0))]; |
313 | emit showDetails( *todo ); | 313 | emit showDetails( *todo ); |
314 | } | 314 | } |
315 | break; | 315 | break; |
316 | case 3: | 316 | case 3: |
317 | // may as well edit it... | 317 | // may as well edit it... |
318 | menuTimer->stop(); | 318 | menuTimer->stop(); |
319 | emit signalEdit(); | 319 | emit signalEdit(); |
320 | break; | 320 | break; |
321 | } | 321 | } |
322 | } | 322 | } |
323 | 323 | ||
324 | void TodoTable::slotPressed( int row, int col, int, const QPoint &pos ) | 324 | void TodoTable::slotPressed( int row, int col, int, const QPoint &pos ) |
325 | { | 325 | { |
326 | if ( col == 2 && cellGeometry( row, col ).contains(pos) ) | 326 | if ( col == 2 && cellGeometry( row, col ).contains(pos) ) |
327 | menuTimer->start( 750, TRUE ); | 327 | menuTimer->start( 750, TRUE ); |
328 | } | 328 | } |
329 | 329 | ||
330 | void TodoTable::slotShowMenu() | 330 | void TodoTable::slotShowMenu() |
331 | { | 331 | { |
332 | emit signalShowMenu( QCursor::pos() ); | 332 | emit signalShowMenu( QCursor::pos() ); |
333 | } | 333 | } |
334 | 334 | ||
335 | void TodoTable::slotCurrentChanged( int, int ) | 335 | void TodoTable::slotCurrentChanged( int, int ) |
336 | { | 336 | { |
337 | menuTimer->stop(); | 337 | menuTimer->stop(); |
338 | } | 338 | } |
339 | 339 | ||
340 | void TodoTable::internalAddEntries( QList<ToDoEvent> &list ) | 340 | void TodoTable::internalAddEntries( QList<ToDoEvent> &list ) |
341 | { | 341 | { |
342 | setNumRows( list.count() ); | 342 | setNumRows( list.count() ); |
343 | int row = 0; | 343 | int row = 0; |
344 | ToDoEvent *it; | 344 | ToDoEvent *it; |
345 | for ( it = list.first(); it; it = list.next() ) | 345 | for ( it = list.first(); it; it = list.next() ) |
346 | insertIntoTable( it, row++ ); | 346 | insertIntoTable( it, row++ ); |
347 | } | 347 | } |
348 | 348 | ||
349 | 349 | ||
350 | ToDoEvent TodoTable::currentEntry() const | 350 | ToDoEvent TodoTable::currentEntry() const |
351 | { | 351 | { |
352 | //qWarning ("in currentEntry\n"); | 352 | //qWarning ("in currentEntry\n"); |
353 | 353 | ||
354 | QTableItem *i = item( currentRow(), 0 ); | 354 | QTableItem *i = item( currentRow(), 0 ); |
355 | if ( !i || rowHeight( currentRow() ) <= 0 ) | 355 | if ( !i || rowHeight( currentRow() ) <= 0 ) |
356 | return ToDoEvent(); | 356 | return ToDoEvent(); |
357 | ToDoEvent *todo = todoList[(CheckItem*)i]; | 357 | ToDoEvent *todo = todoList[(CheckItem*)i]; |
358 | todo->setCompleted( ( (CheckItem*)item( currentRow(), 0 ) )->isChecked() ); | 358 | todo->setCompleted( ( (CheckItem*)item( currentRow(), 0 ) )->isChecked() ); |
359 | todo->setPriority( ( (ComboItem*)item( currentRow(), 1 ) )->text().toInt() ); | 359 | todo->setPriority( ( (ComboItem*)item( currentRow(), 1 ) )->text().toInt() ); |
360 | return *todo; | 360 | return *todo; |
361 | } | 361 | } |
362 | 362 | ||
363 | void TodoTable::replaceCurrentEntry( const ToDoEvent &todo, bool fromTableItem ) | 363 | void TodoTable::replaceCurrentEntry( const ToDoEvent &todo, bool fromTableItem ) |
364 | { | 364 | { |
365 | int row = currentRow(); | 365 | int row = currentRow(); |
366 | updateJournal( todo, ACTION_REPLACE); | 366 | updateJournal( todo, ACTION_REPLACE); |
367 | 367 | ||
368 | if ( !fromTableItem ) { | 368 | if ( !fromTableItem ) { |
369 | journalFreeReplaceEntry( todo, row ); | 369 | journalFreeReplaceEntry( todo, row ); |
370 | updateVisible(); | 370 | updateVisible(); |
371 | } | 371 | } |
372 | } | 372 | } |
373 | 373 | ||
374 | void TodoTable::removeCurrentEntry() | 374 | void TodoTable::removeCurrentEntry() |
375 | { | 375 | { |
376 | ToDoEvent *oldTodo; | 376 | ToDoEvent *oldTodo; |
377 | int row = currentRow(); | 377 | int row = currentRow(); |
378 | CheckItem *chk; | 378 | CheckItem *chk; |
379 | 379 | ||
380 | chk = static_cast<CheckItem*>(item(row, 0 )); | 380 | chk = static_cast<CheckItem*>(item(row, 0 )); |
381 | if ( !chk ) | 381 | if ( !chk ) |
382 | return; | 382 | return; |
383 | oldTodo = todoList[chk]; | 383 | oldTodo = todoList[chk]; |
384 | todoList.remove( chk ); | 384 | todoList.remove( chk ); |
385 | oldTodo->setCompleted( chk->isChecked() ); | 385 | oldTodo->setCompleted( chk->isChecked() ); |
386 | oldTodo->setPriority( static_cast<ComboItem*>(item(row, 1))->text().toInt() ); | 386 | oldTodo->setPriority( static_cast<ComboItem*>(item(row, 1))->text().toInt() ); |
387 | realignTable( row ); | 387 | realignTable( row ); |
388 | updateVisible(); | 388 | updateVisible(); |
389 | updateJournal( *oldTodo, ACTION_REMOVE); | 389 | updateJournal( *oldTodo, ACTION_REMOVE); |
390 | delete oldTodo; | 390 | delete oldTodo; |
391 | } | 391 | } |
392 | 392 | ||
393 | 393 | ||
394 | bool TodoTable::save( const QString &fn ) | 394 | bool TodoTable::save( const QString &fn ) |
395 | { | 395 | { |
396 | QString strNewFile = fn + ".new"; | 396 | QString strNewFile = fn + ".new"; |
397 | QFile::remove( strNewFile ); // just to be sure | 397 | QFile::remove( strNewFile ); // just to be sure |
398 | ToDoDB todoDB( strNewFile ); | 398 | ToDoDB todoDB( strNewFile ); |
399 | for ( QMap<CheckItem*, ToDoEvent *>::Iterator it = todoList.begin(); | 399 | for ( QMap<CheckItem*, ToDoEvent *>::Iterator it = todoList.begin(); |
400 | it != todoList.end(); ++it ) { | 400 | it != todoList.end(); ++it ) { |
401 | if ( !item( it.key()->row(), 0 ) ) | 401 | if ( !item( it.key()->row(), 0 ) ) |
402 | continue; | 402 | continue; |
403 | ToDoEvent *todo = *it; | 403 | ToDoEvent *todo = *it; |
404 | // sync item with table | 404 | // sync item with table |
405 | todo->setCompleted( ((CheckItem*)item(it.key()->row(), 0))->isChecked() ); | 405 | todo->setCompleted( ((CheckItem*)item(it.key()->row(), 0))->isChecked() ); |
406 | todo->setPriority( ((ComboItem*)item( it.key()->row(), 1))->text().toInt() ); | 406 | todo->setPriority( ((ComboItem*)item( it.key()->row(), 1))->text().toInt() ); |
407 | todoDB.addEvent( *todo ); | 407 | todoDB.addEvent( *todo ); |
408 | } | 408 | } |
409 | if(!todoDB.save() ){ | 409 | if(!todoDB.save() ){ |
410 | QFile::remove( strNewFile ); | 410 | QFile::remove( strNewFile ); |
411 | return false; | 411 | return false; |
412 | }; | 412 | }; |
413 | // now do the rename | 413 | // now do the rename |
414 | if ( ::rename( strNewFile, fn ) < 0 ) | 414 | if ( ::rename( strNewFile, fn ) < 0 ) |
415 | qWarning( "problem renaming file %s to %s errno %d", | 415 | qWarning( "problem renaming file %s to %s errno %d", |
416 | strNewFile.latin1(), fn.latin1(), errno ); | 416 | strNewFile.latin1(), fn.latin1(), errno ); |
417 | 417 | ||
418 | // remove the journal | 418 | // remove the journal |
419 | QFile::remove( journalFileName() ); | 419 | QFile::remove( journalFileName() ); |
420 | return true; | 420 | return true; |
421 | } | 421 | } |
422 | 422 | ||
423 | void TodoTable::load( const QString &fn ) | 423 | void TodoTable::load( const QString &fn ) |
424 | { | 424 | { |
425 | if ( QFile::exists(journalFileName()) ) { | 425 | if ( QFile::exists(journalFileName()) ) { |
426 | applyJournal(); | 426 | applyJournal(); |
427 | QFile::remove(journalFileName() ); | 427 | QFile::remove(journalFileName() ); |
428 | } | 428 | } |
429 | loadFile( fn ); | 429 | loadFile( fn ); |
430 | // QTable::sortColumn(2,TRUE,TRUE); | 430 | // QTable::sortColumn(2,TRUE,TRUE); |
431 | // QTable::sortColumn(1,TRUE,TRUE); | 431 | // QTable::sortColumn(1,TRUE,TRUE); |
432 | QTable::sortColumn(0,TRUE,TRUE); | 432 | QTable::sortColumn(0,TRUE,TRUE); |
433 | setCurrentCell( 0, 2 ); | 433 | setCurrentCell( 0, 2 ); |
434 | setSorting(true ); | 434 | setSorting(true ); |
435 | mDayTimer->start( 60 * 1000 ); // gone in 60 seconds? | 435 | mDayTimer->start( 60 * 1000 ); // gone in 60 seconds? |
436 | } | 436 | } |
437 | void TodoTable::updateVisible() | 437 | void TodoTable::updateVisible() |
438 | { | 438 | { |
439 | if ( !isUpdatesEnabled() ) | 439 | if ( !isUpdatesEnabled() ) |
440 | return; | 440 | return; |
441 | 441 | ||
442 | if (showDeadl){ | 442 | if (showDeadl){ |
443 | showColumn (3); | 443 | showColumn (3); |
444 | adjustColumn(3); | 444 | adjustColumn(3); |
445 | }else{ | 445 | }else{ |
446 | hideColumn (3); | 446 | hideColumn (3); |
447 | adjustColumn(2); | 447 | adjustColumn(2); |
448 | } | 448 | } |
449 | 449 | ||
450 | int visible = 0; | 450 | int visible = 0; |
451 | int id = mCat.id( "Todo List", showCat ); | 451 | int id = mCat.id( "Todo List", showCat ); |
452 | for ( int row = 0; row < numRows(); row++ ) { | 452 | for ( int row = 0; row < numRows(); row++ ) { |
453 | CheckItem *ci = (CheckItem *)item( row, 0 ); | 453 | CheckItem *ci = (CheckItem *)item( row, 0 ); |
454 | ToDoEvent *t = todoList[ci]; | 454 | ToDoEvent *t = todoList[ci]; |
455 | QArray<int> vlCats = t->categories(); | 455 | QArray<int> vlCats = t->categories(); |
456 | bool hide = false; | 456 | bool hide = false; |
457 | if ( !showComp && ci->isChecked() ) | 457 | if ( !showComp && ci->isChecked() ) |
458 | hide = true; | 458 | hide = true; |
459 | if ( !showCat.isEmpty() ) { | 459 | if ( !showCat.isEmpty() ) { |
460 | if ( showCat == tr( "Unfiled" ) ) { | 460 | if ( showCat == tr( "Unfiled" ) ) { |
461 | if ( vlCats.count() > 0 ) | 461 | if ( vlCats.count() > 0 ) |
462 | hide = true; | 462 | hide = true; |
463 | } else { | 463 | } else { |
464 | // do some comparing, we have to reverse our idea here... which idea? - zecke | 464 | // do some comparing, we have to reverse our idea here... which idea? - zecke |
465 | if ( !hide ) { | 465 | if ( !hide ) { |
466 | hide = true; | 466 | hide = true; |
467 | for ( uint it = 0; it < vlCats.count(); ++it ) { | 467 | for ( uint it = 0; it < vlCats.count(); ++it ) { |
468 | if ( vlCats[it] == id ) { | 468 | if ( vlCats[it] == id ) { |
469 | hide = false; | 469 | hide = false; |
470 | break; | 470 | break; |
471 | } | 471 | } |
472 | } | 472 | } |
473 | } | 473 | } |
474 | } | 474 | } |
475 | } | 475 | } |
476 | if ( hide ) { | 476 | if ( hide ) { |
477 | if ( currentRow() == row ) | 477 | if ( currentRow() == row ) |
478 | setCurrentCell( -1, 0 ); | 478 | setCurrentCell( -1, 0 ); |
479 | if ( rowHeight( row ) > 0 ) | 479 | if ( rowHeight( row ) > 0 ) |
480 | hideRow( row ); | 480 | hideRow( row ); |
481 | } else { | 481 | } else { |
482 | if ( rowHeight( row ) == 0 ) { | 482 | if ( rowHeight( row ) == 0 ) { |
483 | showRow( row ); | 483 | showRow( row ); |
484 | adjustRow( row ); | 484 | adjustRow( row ); |
485 | } | 485 | } |
486 | visible++; | 486 | visible++; |
487 | } | 487 | } |
488 | } | 488 | } |
489 | if ( !visible ) | 489 | if ( !visible ) |
490 | setCurrentCell( -1, 0 ); | 490 | setCurrentCell( -1, 0 ); |
491 | } | 491 | } |
492 | 492 | ||
493 | void TodoTable::viewportPaintEvent( QPaintEvent *pe ) | 493 | void TodoTable::viewportPaintEvent( QPaintEvent *pe ) |
494 | { | 494 | { |
495 | if ( enablePainting ) | 495 | if ( enablePainting ) |
496 | QTable::viewportPaintEvent( pe ); | 496 | QTable::viewportPaintEvent( pe ); |
497 | } | 497 | } |
498 | 498 | ||
499 | void TodoTable::setPaintingEnabled( bool e ) | 499 | void TodoTable::setPaintingEnabled( bool e ) |
500 | { | 500 | { |
501 | if ( e != enablePainting ) { | 501 | if ( e != enablePainting ) { |
502 | if ( !enablePainting ) { | 502 | if ( !enablePainting ) { |
503 | enablePainting = true; | 503 | enablePainting = true; |
504 | rowHeightChanged( 0 ); | 504 | rowHeightChanged( 0 ); |
505 | viewport()->update(); | 505 | viewport()->update(); |
506 | } else { | 506 | } else { |
507 | enablePainting = false; | 507 | enablePainting = false; |
508 | } | 508 | } |
509 | } | 509 | } |
510 | } | 510 | } |
511 | 511 | ||
512 | void TodoTable::clear() | 512 | void TodoTable::clear() |
513 | { | 513 | { |
514 | for ( QMap<CheckItem*, ToDoEvent *>::Iterator it = todoList.begin(); | 514 | for ( QMap<CheckItem*, ToDoEvent *>::Iterator it = todoList.begin(); |
515 | it != todoList.end(); ++it ) { | 515 | it != todoList.end(); ++it ) { |
516 | ToDoEvent *todo = it.data(); | 516 | ToDoEvent *todo = it.data(); |
517 | updateJournal( *todo, ACTION_REMOVE ); | 517 | updateJournal( *todo, ACTION_REMOVE ); |
518 | delete todo; | 518 | delete todo; |
519 | } | 519 | } |
520 | todoList.clear(); | 520 | todoList.clear(); |
521 | for ( int r = 0; r < numRows(); ++r ) { | 521 | for ( int r = 0; r < numRows(); ++r ) { |
522 | for ( int c = 0; c < numCols(); ++c ) { | 522 | for ( int c = 0; c < numCols(); ++c ) { |
523 | if ( cellWidget( r, c ) ) | 523 | if ( cellWidget( r, c ) ) |
524 | clearCellWidget( r, c ); | 524 | clearCellWidget( r, c ); |
525 | clearCell( r, c ); | 525 | clearCell( r, c ); |
526 | } | 526 | } |
527 | } | 527 | } |
528 | setNumRows( 0 ); | 528 | setNumRows( 0 ); |
529 | } | 529 | } |
530 | 530 | ||
531 | void TodoTable::sortColumn( int col, bool ascending, bool /*wholeRows*/ ) | 531 | void TodoTable::sortColumn( int col, bool ascending, bool /*wholeRows*/ ) |
532 | { | 532 | { |
533 | // The default for wholeRows is false, however | 533 | // The default for wholeRows is false, however |
534 | // for this todo table we want to exchange complete | 534 | // for this todo table we want to exchange complete |
535 | // rows when sorting. Also, we always want ascending, since | 535 | // rows when sorting. Also, we always want ascending, since |
536 | // the values have a logical order. | 536 | // the values have a logical order. |
537 | QTable::sortColumn( col, ascending, TRUE ); | 537 | QTable::sortColumn( col, ascending, TRUE ); |
538 | updateVisible(); | 538 | updateVisible(); |
539 | } | 539 | } |
540 | 540 | ||
541 | void TodoTable::slotCheckPriority(int row, int col ) | 541 | void TodoTable::slotCheckPriority(int row, int col ) |
542 | { | 542 | { |
543 | // kludgey work around to make forward along the updated priority... | 543 | // kludgey work around to make forward along the updated priority... |
544 | if ( col == 1 ) { | 544 | if ( col == 1 ) { |
545 | // let everyone know!! | 545 | // let everyone know!! |
546 | ComboItem* i = static_cast<ComboItem*>( item( row, col ) ); | 546 | ComboItem* i = static_cast<ComboItem*>( item( row, col ) ); |
547 | emit signalPriorityChanged( i->text().toInt() ); | 547 | emit signalPriorityChanged( i->text().toInt() ); |
548 | } | 548 | } |
549 | } | 549 | } |
550 | 550 | ||
551 | 551 | ||
552 | void TodoTable::updateJournal( const ToDoEvent &todo, journal_action action ) | 552 | void TodoTable::updateJournal( const ToDoEvent &todo, journal_action action ) |
553 | { | 553 | { |
554 | QFile f( journalFileName() ); | 554 | QFile f( journalFileName() ); |
555 | if ( !f.open(IO_WriteOnly|IO_Append) ) | 555 | if ( !f.open(IO_WriteOnly|IO_Append) ) |
556 | return; | 556 | return; |
557 | QString buf; | 557 | QString buf; |
558 | QCString str; | 558 | QCString str; |
559 | buf = "<Task"; | 559 | buf = "<Task"; |
560 | // todo.save( buf ); | 560 | // todo.save( buf ); |
561 | buf += " Action=\"" + QString::number( int(action) ) + "\""; | 561 | buf += " Action=\"" + QString::number( int(action) ) + "\""; |
562 | buf += " Uid=\"" + QString::number( todo.uid() ) + "\""; // better write the id | 562 | buf += " Uid=\"" + QString::number( todo.uid() ) + "\""; // better write the id |
563 | buf += " Completed=\""+ QString::number((int)todo.isCompleted() ) + "\""; | 563 | buf += " Completed=\""+ QString::number((int)todo.isCompleted() ) + "\""; |
564 | buf += " HasDate=\""+ QString::number((int)todo.hasDate() ) +"\""; | 564 | buf += " HasDate=\""+ QString::number((int)todo.hasDate() ) +"\""; |
565 | buf += " Priority=\"" + QString::number( todo.priority() ) + "\""; | 565 | buf += " Priority=\"" + QString::number( todo.priority() ) + "\""; |
566 | QArray<int> arrat = todo.categories(); | 566 | QArray<int> arrat = todo.categories(); |
567 | QString attr; | 567 | QString attr; |
568 | for(uint i=0; i < arrat.count(); i++ ){ | 568 | for(uint i=0; i < arrat.count(); i++ ){ |
569 | attr.append(QString::number(arrat[i])+";" ); | 569 | attr.append(QString::number(arrat[i])+";" ); |
570 | } | 570 | } |
571 | if(!attr.isEmpty() ) // remove the last ; | 571 | if(!attr.isEmpty() ) // remove the last ; |
572 | attr.remove(attr.length()-1, 1 ); | 572 | attr.remove(attr.length()-1, 1 ); |
573 | buf += " Categories=\"" + attr + "\""; | 573 | buf += " Categories=\"" + attr + "\""; |
574 | buf += " Description=\"" + todo.description() + "\""; | 574 | buf += " Description=\"" + todo.description() + "\""; |
575 | buf += " Summary=\"" + todo.summary() + "\""; | ||
575 | if(todo.hasDate() ) { | 576 | if(todo.hasDate() ) { |
576 | buf += " DateYear=\""+QString::number( todo.date().year() ) + "\""; | 577 | buf += " DateYear=\""+QString::number( todo.date().year() ) + "\""; |
577 | buf += " DateMonth=\"" + QString::number( todo.date().month() ) + "\""; | 578 | buf += " DateMonth=\"" + QString::number( todo.date().month() ) + "\""; |
578 | buf += " DateDay=\"" + QString::number( todo.date().day() ) + "\""; | 579 | buf += " DateDay=\"" + QString::number( todo.date().day() ) + "\""; |
579 | } | 580 | } |
580 | buf += "/>\n"; | 581 | buf += "/>\n"; |
581 | str = buf.utf8(); | 582 | str = buf.utf8(); |
582 | f.writeBlock( str.data(), str.length() ); | 583 | f.writeBlock( str.data(), str.length() ); |
583 | f.close(); | 584 | f.close(); |
584 | } | 585 | } |
585 | 586 | ||
586 | void TodoTable::rowHeightChanged( int row ) | 587 | void TodoTable::rowHeightChanged( int row ) |
587 | { | 588 | { |
588 | if ( enablePainting ) | 589 | if ( enablePainting ) |
589 | QTable::rowHeightChanged( row ); | 590 | QTable::rowHeightChanged( row ); |
590 | } | 591 | } |
591 | 592 | ||
592 | void TodoTable::loadFile( const QString &/*we use the standard*/ ) | 593 | void TodoTable::loadFile( const QString &/*we use the standard*/ ) |
593 | { | 594 | { |
594 | 595 | ||
595 | QList<ToDoEvent> list; | 596 | QList<ToDoEvent> list; |
596 | ToDoDB todoDB; | 597 | ToDoDB todoDB; |
597 | QValueList<ToDoEvent> vaList = todoDB.rawToDos(); | 598 | QValueList<ToDoEvent> vaList = todoDB.rawToDos(); |
598 | for(QValueList<ToDoEvent>::ConstIterator it = vaList.begin(); it != vaList.end(); ++it ){ | 599 | for(QValueList<ToDoEvent>::ConstIterator it = vaList.begin(); it != vaList.end(); ++it ){ |
599 | ToDoEvent *event = new ToDoEvent( (*it) ); | 600 | ToDoEvent *event = new ToDoEvent( (*it) ); |
600 | list.append( event ); | 601 | list.append( event ); |
601 | } | 602 | } |
602 | vaList.clear(); | 603 | vaList.clear(); |
603 | // qDebug("parsing done=%d", t.elapsed() ); | 604 | // qDebug("parsing done=%d", t.elapsed() ); |
604 | if ( list.count() > 0 ) { | 605 | if ( list.count() > 0 ) { |
605 | internalAddEntries( list ); | 606 | internalAddEntries( list ); |
606 | list.clear(); | 607 | list.clear(); |
607 | } | 608 | } |
608 | // qDebug("loading done: t=%d", t.elapsed() ); | 609 | // qDebug("loading done: t=%d", t.elapsed() ); |
609 | } | 610 | } |
610 | 611 | ||
611 | void TodoTable::journalFreeReplaceEntry( const ToDoEvent &todo, int row ) | 612 | void TodoTable::journalFreeReplaceEntry( const ToDoEvent &todo, int row ) |
612 | { | 613 | { |
613 | QString strTodo; | 614 | QString strTodo = todo.summary(); |
614 | strTodo = todo.description().left(40).simplifyWhiteSpace(); | 615 | if( strTodo.isEmpty() ){ |
616 | strTodo = todo.description().left(40).simplifyWhiteSpace(); | ||
617 | //todo.setSummary(strTodo ); | ||
618 | } | ||
615 | if ( row == -1 ) { | 619 | if ( row == -1 ) { |
616 | QMapIterator<CheckItem*, ToDoEvent *> it; | 620 | QMapIterator<CheckItem*, ToDoEvent *> it; |
617 | for ( it = todoList.begin(); it != todoList.end(); ++it ) { | 621 | for ( it = todoList.begin(); it != todoList.end(); ++it ) { |
618 | if ( *(*it) == todo ) { | 622 | if ( *(*it) == todo ) { |
619 | row = it.key()->row(); | 623 | row = it.key()->row(); |
620 | it.key()->setChecked( todo.isCompleted() ); | 624 | it.key()->setChecked( todo.isCompleted() ); |
621 | static_cast<ComboItem*>(item(row, 1))->setText( QString::number(todo.priority()) ); | 625 | static_cast<ComboItem*>(item(row, 1))->setText( QString::number(todo.priority()) ); |
622 | item( row, 2 )->setText( strTodo ); | 626 | item( row, 2 )->setText( strTodo ); |
623 | 627 | ||
624 | if (showDeadl){ | 628 | if (showDeadl){ |
625 | static_cast<DueTextItem*>(item(row,3))->setToDoEvent(&todo ); | 629 | static_cast<DueTextItem*>(item(row,3))->setToDoEvent(&todo ); |
626 | } | 630 | } |
627 | 631 | ||
628 | *(*it) = todo; | 632 | *(*it) = todo; |
629 | } | 633 | } |
630 | } | 634 | } |
631 | } else { | 635 | } else { |
632 | ToDoEvent *t = todoList[static_cast<CheckItem*>(item(row, 0))]; | 636 | ToDoEvent *t = todoList[static_cast<CheckItem*>(item(row, 0))]; |
633 | todoList.remove( static_cast<CheckItem*>(item(row, 0)) ); | 637 | todoList.remove( static_cast<CheckItem*>(item(row, 0)) ); |
634 | delete t; | 638 | delete t; |
635 | static_cast<CheckItem*>(item(row, 0))->setChecked( todo.isCompleted() ); | 639 | static_cast<CheckItem*>(item(row, 0))->setChecked( todo.isCompleted() ); |
636 | static_cast<ComboItem*>(item(row, 1))->setText( QString::number(todo.priority()) ); | 640 | static_cast<ComboItem*>(item(row, 1))->setText( QString::number(todo.priority()) ); |
637 | item( row, 2 )->setText( strTodo ); | 641 | item( row, 2 )->setText( strTodo ); |
638 | 642 | ||
639 | if (showDeadl){ | 643 | if (showDeadl){ |
640 | static_cast<DueTextItem*>(item(row,3))->setToDoEvent(&todo ); | 644 | static_cast<DueTextItem*>(item(row,3))->setToDoEvent(&todo ); |
641 | } | 645 | } |
642 | todoList.insert( static_cast<CheckItem*>(item(row,0)), new ToDoEvent(todo) ); | 646 | todoList.insert( static_cast<CheckItem*>(item(row,0)), new ToDoEvent(todo) ); |
643 | } | 647 | } |
644 | } | 648 | } |
645 | 649 | ||
646 | void TodoTable::journalFreeRemoveEntry( int row ) | 650 | void TodoTable::journalFreeRemoveEntry( int row ) |
647 | { | 651 | { |
648 | CheckItem *chk; | 652 | CheckItem *chk; |
649 | chk = static_cast<CheckItem*>(item(row, 0 )); | 653 | chk = static_cast<CheckItem*>(item(row, 0 )); |
650 | if ( !chk ) | 654 | if ( !chk ) |
651 | return; | 655 | return; |
652 | todoList.remove( chk ); | 656 | todoList.remove( chk ); |
653 | 657 | ||
654 | realignTable( row ); | 658 | realignTable( row ); |
655 | } | 659 | } |
656 | 660 | ||
657 | void TodoTable::keyPressEvent( QKeyEvent *e ) | 661 | void TodoTable::keyPressEvent( QKeyEvent *e ) |
658 | { | 662 | { |
659 | if ( e->key() == Key_Space || e->key() == Key_Return ) { | 663 | if ( e->key() == Key_Space || e->key() == Key_Return ) { |
660 | switch ( currentColumn() ) { | 664 | switch ( currentColumn() ) { |
661 | case 0: { | 665 | case 0: { |
662 | CheckItem *i = static_cast<CheckItem*>(item(currentRow(), | 666 | CheckItem *i = static_cast<CheckItem*>(item(currentRow(), |
663 | currentColumn())); | 667 | currentColumn())); |
664 | if ( i ) | 668 | if ( i ) |
665 | i->toggle(); | 669 | i->toggle(); |
666 | break; | 670 | break; |
667 | } | 671 | } |
668 | case 1: | 672 | case 1: |
669 | break; | 673 | break; |
670 | case 2:{ | 674 | case 2:{ |
671 | ToDoEvent *todo = todoList[static_cast<CheckItem*>(item(currentRow(), 0))]; | 675 | ToDoEvent *todo = todoList[static_cast<CheckItem*>(item(currentRow(), 0))]; |
672 | emit showDetails(*todo); | 676 | emit showDetails(*todo); |
673 | break; | 677 | break; |
674 | } | 678 | } |
675 | case 3: | 679 | case 3: |
676 | // Future: Let us change the dueDate directly... | 680 | // Future: Let us change the dueDate directly... |
677 | emit signalEdit(); | 681 | emit signalEdit(); |
678 | default: | 682 | default: |
679 | break; | 683 | break; |
680 | } | 684 | } |
681 | } else | 685 | } else |
682 | QTable::keyPressEvent( e ); | 686 | QTable::keyPressEvent( e ); |
683 | } | 687 | } |
684 | 688 | ||
685 | 689 | ||
686 | QStringList TodoTable::categories() | 690 | QStringList TodoTable::categories() |
687 | { | 691 | { |
688 | // This is called seldom, so calling a load in here | 692 | // This is called seldom, so calling a load in here |
689 | // should be fine. | 693 | // should be fine. |
690 | mCat.load( categoryFileName() ); | 694 | mCat.load( categoryFileName() ); |
691 | QStringList categoryList = mCat.labels( "Todo List" ); | 695 | QStringList categoryList = mCat.labels( "Todo List" ); |
692 | return categoryList; | 696 | return categoryList; |
693 | } | 697 | } |
694 | 698 | ||
695 | void TodoTable::slotDoFind( const QString &findString, bool caseSensitive, | 699 | void TodoTable::slotDoFind( const QString &findString, bool caseSensitive, |
696 | bool backwards, int category ) | 700 | bool backwards, int category ) |
697 | { | 701 | { |
698 | // we have to iterate through the table, this gives the illusion that | 702 | // we have to iterate through the table, this gives the illusion that |
699 | // sorting is actually being used. | 703 | // sorting is actually being used. |
700 | if ( currFindRow < -1 ) | 704 | if ( currFindRow < -1 ) |
701 | currFindRow = currentRow() - 1; | 705 | currFindRow = currentRow() - 1; |
702 | clearSelection( TRUE ); | 706 | clearSelection( TRUE ); |
703 | int rows, | 707 | int rows, |
704 | row; | 708 | row; |
705 | CheckItem *chk; | 709 | CheckItem *chk; |
706 | QRegExp r( findString ); | 710 | QRegExp r( findString ); |
707 | 711 | ||
708 | r.setCaseSensitive( caseSensitive ); | 712 | r.setCaseSensitive( caseSensitive ); |
709 | rows = numRows(); | 713 | rows = numRows(); |
710 | static bool wrapAround = true; | 714 | static bool wrapAround = true; |
711 | 715 | ||
712 | if ( !backwards ) { | 716 | if ( !backwards ) { |
713 | for ( row = currFindRow + 1; row < rows; row++ ) { | 717 | for ( row = currFindRow + 1; row < rows; row++ ) { |
714 | chk = static_cast<CheckItem*>( item(row, 0) ); | 718 | chk = static_cast<CheckItem*>( item(row, 0) ); |
715 | if ( taskCompare(*(todoList[chk]), r, category) ) | 719 | if ( taskCompare(*(todoList[chk]), r, category) ) |
716 | break; | 720 | break; |
717 | } | 721 | } |
718 | } else { | 722 | } else { |
719 | for ( row = currFindRow - 1; row > -1; row-- ) { | 723 | for ( row = currFindRow - 1; row > -1; row-- ) { |
720 | chk = static_cast<CheckItem*>( item(row, 0) ); | 724 | chk = static_cast<CheckItem*>( item(row, 0) ); |
721 | if ( taskCompare(*(todoList[chk]), r, category) ) | 725 | if ( taskCompare(*(todoList[chk]), r, category) ) |
722 | break; | 726 | break; |
723 | } | 727 | } |
724 | } | 728 | } |
725 | if ( row >= rows || row < 0 ) { | 729 | if ( row >= rows || row < 0 ) { |
726 | if ( row < 0 ) | 730 | if ( row < 0 ) |
727 | currFindRow = rows; | 731 | currFindRow = rows; |
728 | else | 732 | else |
729 | currFindRow = -1; | 733 | currFindRow = -1; |
730 | if ( wrapAround ) | 734 | if ( wrapAround ) |
731 | emit signalWrapAround(); | 735 | emit signalWrapAround(); |
732 | else | 736 | else |
733 | emit signalNotFound(); | 737 | emit signalNotFound(); |
734 | wrapAround = !wrapAround; | 738 | wrapAround = !wrapAround; |
735 | } else { | 739 | } else { |
736 | currFindRow = row; | 740 | currFindRow = row; |
737 | QTableSelection foundSelection; | 741 | QTableSelection foundSelection; |
738 | foundSelection.init( currFindRow, 0 ); | 742 | foundSelection.init( currFindRow, 0 ); |
739 | foundSelection.expandTo( currFindRow, numCols() - 1 ); | 743 | foundSelection.expandTo( currFindRow, numCols() - 1 ); |
740 | addSelection( foundSelection ); | 744 | addSelection( foundSelection ); |
741 | setCurrentCell( currFindRow, numCols() - 1 ); | 745 | setCurrentCell( currFindRow, numCols() - 1 ); |
742 | // we should always be able to wrap around and find this again, | 746 | // we should always be able to wrap around and find this again, |
743 | // so don't give confusing not found message... | 747 | // so don't give confusing not found message... |
744 | wrapAround = true; | 748 | wrapAround = true; |
745 | } | 749 | } |
746 | } | 750 | } |
747 | 751 | ||
748 | int TodoTable::showCategoryId() const | 752 | int TodoTable::showCategoryId() const |
749 | { | 753 | { |
750 | int id; | 754 | int id; |
751 | id = -1; | 755 | id = -1; |
752 | // if allcategories are selected, you get unfiled... | 756 | // if allcategories are selected, you get unfiled... |
753 | if ( showCat != tr( "Unfiled" ) && showCat != tr( "All" ) ) | 757 | if ( showCat != tr( "Unfiled" ) && showCat != tr( "All" ) ) |
754 | id = mCat.id( "Todo List", showCat ); | 758 | id = mCat.id( "Todo List", showCat ); |
755 | return id; | 759 | return id; |
756 | } | 760 | } |
757 | void TodoTable::applyJournal() | 761 | void TodoTable::applyJournal() |
758 | { | 762 | { |
759 | // we need to hack | 763 | // we need to hack |
760 | QFile file( journalFileName() ); | 764 | QFile file( journalFileName() ); |
761 | if( file.open(IO_ReadOnly ) ) { | 765 | if( file.open(IO_ReadOnly ) ) { |
762 | QByteArray ar = file.readAll(); | 766 | QByteArray ar = file.readAll(); |
763 | file.close(); | 767 | file.close(); |
764 | QFile file2( journalFileName() + "_new" ); | 768 | QFile file2( journalFileName() + "_new" ); |
765 | if( file2.open(IO_WriteOnly ) ){ | 769 | if( file2.open(IO_WriteOnly ) ){ |
766 | QTextStream str(&file2 ); | 770 | QTextStream str(&file2 ); |
767 | str << QString::fromLatin1("<Tasks>") << endl; | 771 | str << QString::fromLatin1("<Tasks>") << endl; |
768 | str << ar.data(); | 772 | str << ar.data(); |
769 | str << QString::fromLatin1("</Tasks>") << endl; | 773 | str << QString::fromLatin1("</Tasks>") << endl; |
770 | file2.close(); | 774 | file2.close(); |
771 | } | 775 | } |
772 | XMLElement *root = XMLElement::load(journalFileName()+ "_new"); | 776 | XMLElement *root = XMLElement::load(journalFileName()+ "_new"); |
773 | XMLElement *el = root->firstChild(); | 777 | XMLElement *el = root->firstChild(); |
774 | el = el->firstChild(); | 778 | el = el->firstChild(); |
775 | ToDoDB tododb; // allready loaded ;) | 779 | ToDoDB tododb; // allready loaded ;) |
776 | bool ok; | 780 | bool ok; |
777 | int action; | 781 | int action; |
778 | QString dummy; | 782 | QString dummy; |
779 | while( el ){ | 783 | while( el ){ |
780 | dummy = el->attribute("Action" ); | 784 | dummy = el->attribute("Action" ); |
781 | action = dummy.toInt(&ok ); | 785 | action = dummy.toInt(&ok ); |
782 | ToDoEvent ev = xmlToEvent( el ); | 786 | ToDoEvent ev = xmlToEvent( el ); |
783 | if(ok ){ | 787 | if(ok ){ |
784 | switch( action){ | 788 | switch( action){ |
785 | case ACTION_ADD: | 789 | case ACTION_ADD: |
786 | tododb.addEvent(ev ); | 790 | tododb.addEvent(ev ); |
787 | break; | 791 | break; |
788 | case ACTION_REMOVE: | 792 | case ACTION_REMOVE: |
789 | tododb.removeEvent( ev ); | 793 | tododb.removeEvent( ev ); |
790 | break; | 794 | break; |
791 | case ACTION_REPLACE: | 795 | case ACTION_REPLACE: |
792 | tododb.replaceEvent( ev ); | 796 | tododb.replaceEvent( ev ); |
793 | break; | 797 | break; |
794 | } | 798 | } |
795 | } | 799 | } |
796 | el = el->nextChild(); | 800 | el = el->nextChild(); |
797 | } | 801 | } |
798 | QFile::remove(journalFileName()+ "_new" ); | 802 | QFile::remove(journalFileName()+ "_new" ); |
799 | tododb.save(); | 803 | tododb.save(); |
800 | } | 804 | } |
801 | } | 805 | } |
802 | void TodoTable::slotCheckDay() | 806 | void TodoTable::slotCheckDay() |
803 | { | 807 | { |
804 | QDate date = QDate::currentDate(); | 808 | QDate date = QDate::currentDate(); |
805 | if( mDay.daysTo(date )!= 0 ){ | 809 | if( mDay.daysTo(date )!= 0 ){ |
806 | setPaintingEnabled( FALSE ); | 810 | setPaintingEnabled( FALSE ); |
807 | for(int i=0; i < numRows(); i++ ){ | 811 | for(int i=0; i < numRows(); i++ ){ |
808 | ToDoEvent *t = todoList[static_cast<CheckItem*>(item(i, 0))]; | 812 | ToDoEvent *t = todoList[static_cast<CheckItem*>(item(i, 0))]; |
809 | static_cast<DueTextItem*>(item(i, 3) )->setToDoEvent( t ); | 813 | static_cast<DueTextItem*>(item(i, 3) )->setToDoEvent( t ); |
810 | 814 | ||
811 | } | 815 | } |
812 | setPaintingEnabled( TRUE ); | 816 | setPaintingEnabled( TRUE ); |
813 | mDay = date; | 817 | mDay = date; |
814 | } | 818 | } |
815 | mDayTimer->start( 60 * 1000 ); // 60 seconds | 819 | mDayTimer->start( 60 * 1000 ); // 60 seconds |
816 | } | 820 | } |
817 | // check Action and decide | 821 | // check Action and decide |
818 | /* | 822 | /* |
819 | void TodoTable::doApply(XMLElement *el ) | 823 | void TodoTable::doApply(XMLElement *el ) |
820 | { | 824 | { |
821 | QString dummy; | 825 | QString dummy; |
822 | bool ok; | 826 | bool ok; |
823 | int action; | 827 | int action; |
824 | dummy = el->attribute("Action" ); | 828 | dummy = el->attribute("Action" ); |
825 | action = dummy.toInt(&ok ); | 829 | action = dummy.toInt(&ok ); |
826 | ToDoEvent ev = xmlToEvent( el ); | 830 | ToDoEvent ev = xmlToEvent( el ); |
827 | if( ok ){ | 831 | if( ok ){ |
828 | switch( action ){ | 832 | switch( action ){ |
829 | case ACTION_ADD: | 833 | case ACTION_ADD: |
830 | addEntry( ev ); | 834 | addEntry( ev ); |
831 | break; | 835 | break; |
832 | case ACTION_REMOVE:{ // find an entry with the same uid and remove it then | 836 | case ACTION_REMOVE:{ // find an entry with the same uid and remove it then |
833 | break; | 837 | break; |
834 | } | 838 | } |
835 | case ACTION_REPLACE: | 839 | case ACTION_REPLACE: |
836 | break; | 840 | break; |
837 | } | 841 | } |
838 | } | 842 | } |
839 | } | 843 | } |
840 | */ | 844 | */ |
841 | namespace { | 845 | namespace { |
842 | static bool taskCompare( const ToDoEvent &task, const QRegExp &r, int category ) | 846 | static bool taskCompare( const ToDoEvent &task, const QRegExp &r, int category ) |
843 | { | 847 | { |
844 | bool returnMe; | 848 | bool returnMe; |
845 | QArray<int> cats; | 849 | QArray<int> cats; |
846 | cats = task.categories(); | 850 | cats = task.categories(); |
847 | 851 | ||
848 | returnMe = false; | 852 | returnMe = false; |
849 | if ( (category == -1 && cats.count() == 0) || category == -2 ) | 853 | if ( (category == -1 && cats.count() == 0) || category == -2 ) |
850 | returnMe = task.match( r ); | 854 | returnMe = task.match( r ); |
851 | else { | 855 | else { |
852 | int i; | 856 | int i; |
853 | for ( i = 0; i < int(cats.count()); i++ ) { | 857 | for ( i = 0; i < int(cats.count()); i++ ) { |
854 | if ( cats[i] == category ) { | 858 | if ( cats[i] == category ) { |
855 | returnMe = task.match( r ); | 859 | returnMe = task.match( r ); |
856 | break; | 860 | break; |
857 | } | 861 | } |
858 | } | 862 | } |
859 | } | 863 | } |
860 | return returnMe; | 864 | return returnMe; |
861 | } | 865 | } |
862 | 866 | ||
863 | static QString journalFileName() | 867 | static QString journalFileName() |
864 | { | 868 | { |
865 | QString str; | 869 | QString str; |
866 | str = getenv( "HOME" ); | 870 | str = getenv( "HOME" ); |
867 | str += "/.opie_todojournal"; | 871 | str += "/.opie_todojournal"; |
868 | return str; | 872 | return str; |
869 | } | 873 | } |
870 | static ToDoEvent xmlToEvent( XMLElement *element ) | 874 | static ToDoEvent xmlToEvent( XMLElement *element ) |
871 | { | 875 | { |
872 | QString dummy; | 876 | QString dummy; |
873 | ToDoEvent event; | 877 | ToDoEvent event; |
874 | bool ok; | 878 | bool ok; |
875 | int dumInt; | 879 | int dumInt; |
876 | // completed | 880 | // completed |
877 | dummy = element->attribute("Completed" ); | 881 | dummy = element->attribute("Completed" ); |
878 | dumInt = dummy.toInt(&ok ); | 882 | dumInt = dummy.toInt(&ok ); |
879 | if(ok ) event.setCompleted( dumInt == 0 ? false : true ); | 883 | if(ok ) event.setCompleted( dumInt == 0 ? false : true ); |
880 | // hasDate | 884 | // hasDate |
881 | dummy = element->attribute("HasDate" ); | 885 | dummy = element->attribute("HasDate" ); |
882 | dumInt = dummy.toInt(&ok ); | 886 | dumInt = dummy.toInt(&ok ); |
883 | if(ok ) event.setHasDate( dumInt == 0 ? false: true ); | 887 | if(ok ) event.setHasDate( dumInt == 0 ? false: true ); |
884 | // set the date | 888 | // set the date |
885 | bool hasDa = dumInt; | 889 | bool hasDa = dumInt; |
886 | if ( hasDa ) { //parse the date | 890 | if ( hasDa ) { //parse the date |
887 | int year, day, month = 0; | 891 | int year, day, month = 0; |
888 | year = day = month; | 892 | year = day = month; |
889 | // year | 893 | // year |
890 | dummy = element->attribute("DateYear" ); | 894 | dummy = element->attribute("DateYear" ); |
891 | dumInt = dummy.toInt(&ok ); | 895 | dumInt = dummy.toInt(&ok ); |
892 | if( ok ) year = dumInt; | 896 | if( ok ) year = dumInt; |
893 | // month | 897 | // month |
894 | dummy = element->attribute("DateMonth" ); | 898 | dummy = element->attribute("DateMonth" ); |
895 | dumInt = dummy.toInt(&ok ); | 899 | dumInt = dummy.toInt(&ok ); |
896 | if(ok ) month = dumInt; | 900 | if(ok ) month = dumInt; |
897 | dummy = element->attribute("DateDay" ); | 901 | dummy = element->attribute("DateDay" ); |
898 | dumInt = dummy.toInt(&ok ); | 902 | dumInt = dummy.toInt(&ok ); |
899 | if(ok ) day = dumInt; | 903 | if(ok ) day = dumInt; |
900 | // set the date | 904 | // set the date |
901 | QDate date( year, month, day ); | 905 | QDate date( year, month, day ); |
902 | event.setDate( date); | 906 | event.setDate( date); |
903 | } | 907 | } |
904 | dummy = element->attribute("Priority" ); | 908 | dummy = element->attribute("Priority" ); |
905 | dumInt = dummy.toInt(&ok ); | 909 | dumInt = dummy.toInt(&ok ); |
906 | if(!ok ) dumInt = ToDoEvent::NORMAL; | 910 | if(!ok ) dumInt = ToDoEvent::NORMAL; |
907 | event.setPriority( dumInt ); | 911 | event.setPriority( dumInt ); |
908 | //description | 912 | //description |
909 | dummy = element->attribute("Description" ); | 913 | dummy = element->attribute("Description" ); |
910 | event.setDescription( dummy ); | 914 | event.setDescription( dummy ); |
915 | // summary | ||
916 | dummy = element->attribute("Summary" ); | ||
917 | event.setSummary( dummy ); | ||
911 | // category | 918 | // category |
912 | dummy = element->attribute("Categories" ); | 919 | dummy = element->attribute("Categories" ); |
913 | QStringList ids = QStringList::split(";", dummy ); | 920 | QStringList ids = QStringList::split(";", dummy ); |
914 | event.setCategories( ids ); | 921 | event.setCategories( ids ); |
915 | 922 | ||
916 | //uid | 923 | //uid |
917 | dummy = element->attribute("Uid" ); | 924 | dummy = element->attribute("Uid" ); |
918 | dumInt = dummy.toInt(&ok ); | 925 | dumInt = dummy.toInt(&ok ); |
919 | if(ok ) event.setUid( dumInt ); | 926 | if(ok ) event.setUid( dumInt ); |
920 | return event; | 927 | return event; |
921 | } | 928 | } |
922 | 929 | ||
923 | } | 930 | } |
924 | // int TodoTable::rowHeight( int ) const | 931 | // int TodoTable::rowHeight( int ) const |
925 | // { | 932 | // { |
926 | // return 18; | 933 | // return 18; |
927 | // } | 934 | // } |
928 | 935 | ||
929 | // int TodoTable::rowPos( int row ) const | 936 | // int TodoTable::rowPos( int row ) const |
930 | // { | 937 | // { |
931 | // return 18*row; | 938 | // return 18*row; |
932 | // } | 939 | // } |
933 | 940 | ||
934 | // int TodoTable::rowAt( int pos ) const | 941 | // int TodoTable::rowAt( int pos ) const |
935 | // { | 942 | // { |
936 | // return QMIN( pos/18, numRows()-1 ); | 943 | // return QMIN( pos/18, numRows()-1 ); |
937 | // } | 944 | // } |
938 | 945 | ||
diff --git a/core/pim/todo/todotable.h b/core/pim/todo/todotable.h index 7672f21..39e00d1 100644 --- a/core/pim/todo/todotable.h +++ b/core/pim/todo/todotable.h | |||
@@ -1,244 +1,245 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #ifndef TODOTABLE_H | 21 | #ifndef TODOTABLE_H |
22 | #define TODOTABLE_H | 22 | #define TODOTABLE_H |
23 | 23 | ||
24 | #include <qpe/categories.h> | 24 | #include <qpe/categories.h> |
25 | #include <qpe/stringutil.h> | 25 | #include <qpe/stringutil.h> |
26 | //#include <qpe/task.h> | 26 | //#include <qpe/task.h> |
27 | #include <opie/todoevent.h> | 27 | #include <opie/todoevent.h> |
28 | 28 | ||
29 | #include <qtable.h> | 29 | #include <qtable.h> |
30 | #include <qmap.h> | 30 | #include <qmap.h> |
31 | #include <qguardedptr.h> | 31 | #include <qguardedptr.h> |
32 | 32 | ||
33 | class Node; | 33 | class Node; |
34 | class QComboBox; | 34 | class QComboBox; |
35 | class QTimer; | 35 | class QTimer; |
36 | 36 | ||
37 | class CheckItem : public QTableItem | 37 | class CheckItem : public QTableItem |
38 | { | 38 | { |
39 | public: | 39 | public: |
40 | CheckItem( QTable *t, const QString &sortkey ); | 40 | CheckItem( QTable *t, const QString &sortkey ); |
41 | 41 | ||
42 | void setChecked( bool b ); | 42 | void setChecked( bool b ); |
43 | void toggle(); | 43 | void toggle(); |
44 | bool isChecked() const; | 44 | bool isChecked() const; |
45 | void setKey( const QString &key ) { sortKey = key; } | 45 | void setKey( const QString &key ) { sortKey = key; } |
46 | QString key() const; | 46 | QString key() const; |
47 | 47 | ||
48 | void paint( QPainter *p, const QColorGroup &cg, const QRect &cr, bool selected ); | 48 | void paint( QPainter *p, const QColorGroup &cg, const QRect &cr, bool selected ); |
49 | 49 | ||
50 | private: | 50 | private: |
51 | bool checked; | 51 | bool checked; |
52 | QString sortKey; | 52 | QString sortKey; |
53 | }; | 53 | }; |
54 | 54 | ||
55 | class ComboItem : public QTableItem | 55 | class ComboItem : public QTableItem |
56 | { | 56 | { |
57 | public: | 57 | public: |
58 | ComboItem( QTable *t, EditType et ); | 58 | ComboItem( QTable *t, EditType et ); |
59 | QWidget *createEditor() const; | 59 | QWidget *createEditor() const; |
60 | void setContentFromEditor( QWidget *w ); | 60 | void setContentFromEditor( QWidget *w ); |
61 | void setText( const QString &s ); | 61 | void setText( const QString &s ); |
62 | int alignment() const { return Qt::AlignCenter; } | 62 | int alignment() const { return Qt::AlignCenter; } |
63 | 63 | ||
64 | QString text() const; | 64 | QString text() const; |
65 | 65 | ||
66 | private: | 66 | private: |
67 | QGuardedPtr<QComboBox> cb; | 67 | QGuardedPtr<QComboBox> cb; |
68 | 68 | ||
69 | }; | 69 | }; |
70 | 70 | ||
71 | class TodoTextItem : public QTableItem | 71 | class TodoTextItem : public QTableItem |
72 | { | 72 | { |
73 | public: | 73 | public: |
74 | TodoTextItem( QTable *t, const QString & str ) | 74 | TodoTextItem( QTable *t, const QString & str ) |
75 | :QTableItem( t, QTableItem::Never, str ) {} | 75 | :QTableItem( t, QTableItem::Never, str ) {} |
76 | 76 | ||
77 | QString key () const { return Qtopia::buildSortKey( text() ); } | 77 | QString key () const { return Qtopia::buildSortKey( text() ); } |
78 | }; | 78 | }; |
79 | 79 | ||
80 | class DueTextItem : public QTableItem | 80 | class DueTextItem : public QTableItem |
81 | { | 81 | { |
82 | public: | 82 | public: |
83 | DueTextItem( QTable *t, ToDoEvent *ev ); | 83 | DueTextItem( QTable *t, ToDoEvent *ev ); |
84 | QString key() const; | 84 | QString key() const; |
85 | void setToDoEvent( const ToDoEvent *ev ); | 85 | void setToDoEvent( const ToDoEvent *ev ); |
86 | void paint( QPainter *p, const QColorGroup &cg, const QRect &cr, bool selected ); | 86 | void paint( QPainter *p, const QColorGroup &cg, const QRect &cr, bool selected ); |
87 | private: | 87 | private: |
88 | int m_off; | 88 | int m_off; |
89 | bool m_hasDate:1; | 89 | bool m_hasDate:1; |
90 | bool m_completed:1; | 90 | bool m_completed:1; |
91 | 91 | ||
92 | }; | 92 | }; |
93 | 93 | ||
94 | 94 | ||
95 | enum journal_action { ACTION_ADD=0, ACTION_REMOVE, ACTION_REPLACE }; | 95 | enum journal_action { ACTION_ADD=0, ACTION_REMOVE, ACTION_REPLACE }; |
96 | 96 | ||
97 | namespace Opie | 97 | namespace Opie |
98 | { | 98 | { |
99 | class XMLElement; | 99 | class XMLElement; |
100 | }; | 100 | }; |
101 | 101 | ||
102 | class TodoTable : public QTable | 102 | class TodoTable : public QTable |
103 | { | 103 | { |
104 | Q_OBJECT | 104 | Q_OBJECT |
105 | 105 | ||
106 | public: | 106 | public: |
107 | TodoTable( QWidget *parent = 0, const char * name = 0 ); | 107 | TodoTable( QWidget *parent = 0, const char * name = 0 ); |
108 | void addEntry( const ToDoEvent &todo ); | 108 | void addEntry( const ToDoEvent &todo ); |
109 | void clearFindRow() { currFindRow = -2; } | 109 | void clearFindRow() { currFindRow = -2; } |
110 | 110 | ||
111 | ToDoEvent currentEntry() const; | 111 | ToDoEvent currentEntry() const; |
112 | void replaceCurrentEntry( const ToDoEvent &todo, bool fromTableItem = false ); | 112 | void replaceCurrentEntry( const ToDoEvent &todo, bool fromTableItem = false ); |
113 | 113 | ||
114 | QStringList categories(); | 114 | QStringList categories(); |
115 | 115 | ||
116 | void setShowCompleted( bool sc ) { showComp = sc; updateVisible(); } | 116 | void setShowCompleted( bool sc ) { showComp = sc; updateVisible(); } |
117 | bool showCompleted() const { return showComp; } | 117 | bool showCompleted() const { return showComp; } |
118 | 118 | ||
119 | void setShowDeadline (bool sd) {showDeadl = sd; updateVisible();} | 119 | void setShowDeadline (bool sd) {showDeadl = sd; updateVisible();} |
120 | bool showDeadline() const { return showDeadl;} | 120 | bool showDeadline() const { return showDeadl;} |
121 | 121 | ||
122 | void setShowCategory( const QString &c ) { showCat = c; updateVisible(); } | 122 | void setShowCategory( const QString &c ) { showCat = c; updateVisible(); } |
123 | const QString &showCategory() const { return showCat; } | 123 | const QString &showCategory() const { return showCat; } |
124 | int showCategoryId() const; | 124 | int showCategoryId() const; |
125 | 125 | ||
126 | bool save( const QString &fn ); | 126 | bool save( const QString &fn ); |
127 | void load( const QString &fn ); | 127 | void load( const QString &fn ); |
128 | void applyJournal( ); | 128 | void applyJournal( ); |
129 | void clear(); | 129 | void clear(); |
130 | void removeCurrentEntry(); | 130 | void removeCurrentEntry(); |
131 | void removeAllEntries() { clear(); }; | 131 | void removeAllEntries() { clear(); }; |
132 | //void removeAllEntriesInCategory(const QString &category ); | 132 | //void removeAllEntriesInCategory(const QString &category ); |
133 | 133 | ||
134 | void setPaintingEnabled( bool e ); | 134 | void setPaintingEnabled( bool e ); |
135 | 135 | ||
136 | virtual void sortColumn( int col, bool ascending, bool /*wholeRows*/ ); | 136 | virtual void sortColumn( int col, bool ascending, bool /*wholeRows*/ ); |
137 | 137 | ||
138 | // int rowHeight( int ) const; | 138 | // int rowHeight( int ) const; |
139 | // int rowPos( int row ) const; | 139 | // int rowPos( int row ) const; |
140 | // virtual int rowAt( int pos ) const; | 140 | // virtual int rowAt( int pos ) const; |
141 | 141 | ||
142 | signals: | 142 | signals: |
143 | void signalEdit(); | 143 | void signalEdit(); |
144 | void signalDoneChanged( bool b ); | 144 | void signalDoneChanged( bool b ); |
145 | void signalPriorityChanged( int i ); | 145 | void signalPriorityChanged( int i ); |
146 | void signalShowMenu( const QPoint & ); | 146 | void signalShowMenu( const QPoint & ); |
147 | void signalNotFound(); | 147 | void signalNotFound(); |
148 | void signalWrapAround(); | 148 | void signalWrapAround(); |
149 | void showDetails( const ToDoEvent & ); | 149 | void showDetails( const ToDoEvent & ); |
150 | protected: | 150 | protected: |
151 | void keyPressEvent( QKeyEvent *e ); | 151 | void keyPressEvent( QKeyEvent *e ); |
152 | 152 | ||
153 | private: | 153 | private: |
154 | void updateVisible(); | 154 | void updateVisible(); |
155 | void viewportPaintEvent( QPaintEvent * ); | 155 | void viewportPaintEvent( QPaintEvent * ); |
156 | void internalAddEntries( QList<ToDoEvent> &list); | 156 | void internalAddEntries( QList<ToDoEvent> &list); |
157 | inline void insertIntoTable( ToDoEvent *todo, int row ); | 157 | inline void insertIntoTable( ToDoEvent *todo, int row ); |
158 | void updateJournal( const ToDoEvent &todo, journal_action action); | 158 | void updateJournal( const ToDoEvent &todo, journal_action action); |
159 | void mergeJournal(); | 159 | void mergeJournal(); |
160 | void journalFreeReplaceEntry( const ToDoEvent &todo, int row ); | 160 | void journalFreeReplaceEntry( const ToDoEvent &todo, int row ); |
161 | void journalFreeRemoveEntry( int row ); | 161 | void journalFreeRemoveEntry( int row ); |
162 | inline void realignTable( int row ); | 162 | inline void realignTable( int row ); |
163 | void loadFile( const QString &strFile); | 163 | void loadFile( const QString &strFile); |
164 | 164 | ||
165 | private slots: | 165 | private slots: |
166 | void slotClicked( int row, int col, int button, const QPoint &pos ); | 166 | void slotClicked( int row, int col, int button, const QPoint &pos ); |
167 | void slotPressed( int row, int col, int button, const QPoint &pos ); | 167 | void slotPressed( int row, int col, int button, const QPoint &pos ); |
168 | void slotCheckPriority(int row, int col ); | 168 | void slotCheckPriority(int row, int col ); |
169 | void slotCurrentChanged(int row, int col ); | 169 | void slotCurrentChanged(int row, int col ); |
170 | void slotDoFind( const QString &findString, bool caseSensetive, | 170 | void slotDoFind( const QString &findString, bool caseSensetive, |
171 | bool backwards, int category ); | 171 | bool backwards, int category ); |
172 | void slotShowMenu(); | 172 | void slotShowMenu(); |
173 | void rowHeightChanged( int row ); | 173 | void rowHeightChanged( int row ); |
174 | void slotCheckDay(); // check the day | 174 | void slotCheckDay(); // check the day |
175 | 175 | ||
176 | private: | 176 | private: |
177 | friend class TodoWindow; | 177 | friend class TodoWindow; |
178 | 178 | ||
179 | QMap<CheckItem*, ToDoEvent *> todoList; | 179 | QMap<CheckItem*, ToDoEvent *> todoList; |
180 | QStringList categoryList; | 180 | QStringList categoryList; |
181 | bool showComp; | 181 | bool showComp; |
182 | QString showCat; | 182 | QString showCat; |
183 | QTimer *menuTimer; | 183 | QTimer *menuTimer; |
184 | QDate mDay; | 184 | QDate mDay; |
185 | QTimer *mDayTimer; // see if the day changed | 185 | QTimer *mDayTimer; // see if the day changed |
186 | bool enablePainting; | 186 | bool enablePainting; |
187 | Categories mCat; | 187 | Categories mCat; |
188 | int currFindRow; | 188 | int currFindRow; |
189 | bool showDeadl:1; | 189 | bool showDeadl:1; |
190 | }; | 190 | }; |
191 | 191 | ||
192 | 192 | ||
193 | inline void TodoTable::insertIntoTable( ToDoEvent *todo, int row ) | 193 | inline void TodoTable::insertIntoTable( ToDoEvent *todo, int row ) |
194 | { | 194 | { |
195 | QString sortKey = (char) ((todo->isCompleted() ? 'a' : 'A') | 195 | QString sortKey = (char) ((todo->isCompleted() ? 'a' : 'A') |
196 | + todo->priority() ) | 196 | + todo->priority() ) |
197 | + Qtopia::buildSortKey( todo->description() ); | 197 | + Qtopia::buildSortKey( todo->description() ); |
198 | CheckItem *chk = new CheckItem( this, sortKey ); | 198 | CheckItem *chk = new CheckItem( this, sortKey ); |
199 | chk->setChecked( todo->isCompleted() ); | 199 | chk->setChecked( todo->isCompleted() ); |
200 | ComboItem *cmb = new ComboItem( this, QTableItem::WhenCurrent ); | 200 | ComboItem *cmb = new ComboItem( this, QTableItem::WhenCurrent ); |
201 | cmb->setText( QString::number( todo->priority() ) ); | 201 | cmb->setText( QString::number( todo->priority() ) ); |
202 | QTableItem *ti = new TodoTextItem( this, todo->description().left(40).simplifyWhiteSpace() ); | 202 | QString sum = todo->summary(); |
203 | QTableItem *ti = new TodoTextItem( this, sum.isEmpty() ? todo->description().left(40).simplifyWhiteSpace() : sum ); | ||
203 | ti->setReplaceable( false ); | 204 | ti->setReplaceable( false ); |
204 | 205 | ||
205 | DueTextItem *due = new DueTextItem(this, todo ); | 206 | DueTextItem *due = new DueTextItem(this, todo ); |
206 | setItem( row, 3, due); | 207 | setItem( row, 3, due); |
207 | 208 | ||
208 | setItem( row, 0, chk ); | 209 | setItem( row, 0, chk ); |
209 | setItem( row, 1, cmb ); | 210 | setItem( row, 1, cmb ); |
210 | setItem( row, 2, ti ); | 211 | setItem( row, 2, ti ); |
211 | 212 | ||
212 | 213 | ||
213 | todoList.insert( chk, todo ); | 214 | todoList.insert( chk, todo ); |
214 | } | 215 | } |
215 | 216 | ||
216 | inline void TodoTable::realignTable( int row ) | 217 | inline void TodoTable::realignTable( int row ) |
217 | { | 218 | { |
218 | QTableItem *ti1, | 219 | QTableItem *ti1, |
219 | *ti2, | 220 | *ti2, |
220 | *ti3, | 221 | *ti3, |
221 | *ti4; | 222 | *ti4; |
222 | int totalRows = numRows(); | 223 | int totalRows = numRows(); |
223 | for ( int curr = row; curr < totalRows - 1; curr++ ) { | 224 | for ( int curr = row; curr < totalRows - 1; curr++ ) { |
224 | // this is bad, we must take the item out and then | 225 | // this is bad, we must take the item out and then |
225 | // set it. In the end, it behaves no worse (time wise) | 226 | // set it. In the end, it behaves no worse (time wise) |
226 | // then the old way of saving the entries to file, clearing | 227 | // then the old way of saving the entries to file, clearing |
227 | // the table re-reading in the file and resetting the table | 228 | // the table re-reading in the file and resetting the table |
228 | ti1 = item( curr + 1, 0 ); | 229 | ti1 = item( curr + 1, 0 ); |
229 | ti2 = item( curr + 1, 1 ); | 230 | ti2 = item( curr + 1, 1 ); |
230 | ti3 = item( curr + 1, 2 ); | 231 | ti3 = item( curr + 1, 2 ); |
231 | ti4 = item( curr + 1, 3 ); | 232 | ti4 = item( curr + 1, 3 ); |
232 | takeItem( ti1 ); | 233 | takeItem( ti1 ); |
233 | takeItem( ti2 ); | 234 | takeItem( ti2 ); |
234 | takeItem( ti3 ); | 235 | takeItem( ti3 ); |
235 | takeItem( ti4 ); | 236 | takeItem( ti4 ); |
236 | setItem( curr, 0, ti1 ); | 237 | setItem( curr, 0, ti1 ); |
237 | setItem( curr, 1, ti2 ); | 238 | setItem( curr, 1, ti2 ); |
238 | setItem( curr, 2, ti3 ); | 239 | setItem( curr, 2, ti3 ); |
239 | setItem( curr, 3, ti4 ); | 240 | setItem( curr, 3, ti4 ); |
240 | } | 241 | } |
241 | setNumRows( totalRows - 1 ); | 242 | setNumRows( totalRows - 1 ); |
242 | } | 243 | } |
243 | 244 | ||
244 | #endif | 245 | #endif |
diff --git a/libopie/tododb.cpp b/libopie/tododb.cpp index fe8b8bf..6b10ec2 100644 --- a/libopie/tododb.cpp +++ b/libopie/tododb.cpp | |||
@@ -1,254 +1,258 @@ | |||
1 | 1 | ||
2 | #include <qdir.h> | 2 | #include <qdir.h> |
3 | #include <opie/tododb.h> | 3 | #include <opie/tododb.h> |
4 | #include <opie/xmltree.h> | 4 | #include <opie/xmltree.h> |
5 | #include <opie/todoresource.h> | 5 | #include <opie/todoresource.h> |
6 | #include <qpe/palmtoprecord.h> | 6 | #include <qpe/palmtoprecord.h> |
7 | #include <qpe/global.h> | 7 | #include <qpe/global.h> |
8 | 8 | ||
9 | using namespace Opie; | 9 | using namespace Opie; |
10 | 10 | ||
11 | namespace { | 11 | namespace { |
12 | 12 | ||
13 | class FileToDoResource : public ToDoResource { | 13 | class FileToDoResource : public ToDoResource { |
14 | public: | 14 | public: |
15 | FileToDoResource() {}; | 15 | FileToDoResource() {}; |
16 | // FIXME better parsing | ||
16 | bool save(const QString &name, const QValueList<ToDoEvent> &m_todos ){ | 17 | bool save(const QString &name, const QValueList<ToDoEvent> &m_todos ){ |
17 | // prepare the XML | 18 | // prepare the XML |
18 | XMLElement *tasks = new XMLElement( ); | 19 | XMLElement *tasks = new XMLElement( ); |
19 | tasks->setTagName("Tasks" ); | 20 | tasks->setTagName("Tasks" ); |
20 | for( QValueList<ToDoEvent>::ConstIterator it = m_todos.begin(); it != m_todos.end(); ++it ){ | 21 | for( QValueList<ToDoEvent>::ConstIterator it = m_todos.begin(); it != m_todos.end(); ++it ){ |
21 | XMLElement::AttributeMap map; | 22 | XMLElement::AttributeMap map; |
22 | XMLElement *task = new XMLElement(); | 23 | XMLElement *task = new XMLElement(); |
23 | map.insert( "Completed", QString::number((int)(*it).isCompleted() ) ); | 24 | map.insert( "Completed", QString::number((int)(*it).isCompleted() ) ); |
24 | map.insert( "HasDate", QString::number((int)(*it).hasDate() ) ); | 25 | map.insert( "HasDate", QString::number((int)(*it).hasDate() ) ); |
25 | map.insert( "Priority", QString::number( (*it).priority() ) ); | 26 | map.insert( "Priority", QString::number( (*it).priority() ) ); |
27 | map.insert( "Summary", (*it).summary() ); | ||
26 | QArray<int> arrat = (*it).categories(); | 28 | QArray<int> arrat = (*it).categories(); |
27 | QString attr; | 29 | QString attr; |
28 | for(uint i=0; i < arrat.count(); i++ ){ | 30 | for(uint i=0; i < arrat.count(); i++ ){ |
29 | attr.append(QString::number(arrat[i])+";" ); | 31 | attr.append(QString::number(arrat[i])+";" ); |
30 | } | 32 | } |
31 | if(!attr.isEmpty() ) // remove the last ; | 33 | if(!attr.isEmpty() ) // remove the last ; |
32 | attr.remove(attr.length()-1, 1 ); | 34 | attr.remove(attr.length()-1, 1 ); |
33 | map.insert( "Categories", attr ); | 35 | map.insert( "Categories", attr ); |
34 | //else | 36 | //else |
35 | //map.insert( "Categories", QString::null ); | 37 | //map.insert( "Categories", QString::null ); |
36 | map.insert( "Description", (*it).description() ); | 38 | map.insert( "Description", (*it).description() ); |
37 | if( (*it).hasDate() ){ | 39 | if( (*it).hasDate() ){ |
38 | map.insert("DateYear", QString::number( (*it).date().year() ) ); | 40 | map.insert("DateYear", QString::number( (*it).date().year() ) ); |
39 | map.insert("DateMonth", QString::number( (*it).date().month() ) ); | 41 | map.insert("DateMonth", QString::number( (*it).date().month() ) ); |
40 | map.insert("DateDay", QString::number( (*it).date().day() ) ); | 42 | map.insert("DateDay", QString::number( (*it).date().day() ) ); |
41 | } | 43 | } |
42 | map.insert("Uid", QString::number( (*it).uid() ) ); | 44 | map.insert("Uid", QString::number( (*it).uid() ) ); |
43 | task->setTagName("Task" ); | 45 | task->setTagName("Task" ); |
44 | task->setAttributes( map ); | 46 | task->setAttributes( map ); |
45 | tasks->appendChild(task); | 47 | tasks->appendChild(task); |
46 | } | 48 | } |
47 | QFile file( name); | 49 | QFile file( name); |
48 | if( file.open(IO_WriteOnly ) ){ | 50 | if( file.open(IO_WriteOnly ) ){ |
49 | QTextStream stream(&file ); | 51 | QTextStream stream(&file ); |
50 | stream.setEncoding( QTextStream::UnicodeUTF8 ); | 52 | stream.setEncoding( QTextStream::UnicodeUTF8 ); |
51 | stream << "<!DOCTYPE Tasks>" << endl; | 53 | stream << "<!DOCTYPE Tasks>" << endl; |
52 | tasks->save(stream ); | 54 | tasks->save(stream ); |
53 | delete tasks; | 55 | delete tasks; |
54 | stream << "</Tasks>" << endl; | 56 | stream << "</Tasks>" << endl; |
55 | file.close(); | 57 | file.close(); |
56 | return true; | 58 | return true; |
57 | } | 59 | } |
58 | return false; | 60 | return false; |
59 | } | 61 | } |
60 | QValueList<ToDoEvent> load( const QString &name ){ | 62 | QValueList<ToDoEvent> load( const QString &name ){ |
61 | qWarning("loading tododb" ); | 63 | qWarning("loading tododb" ); |
62 | QValueList<ToDoEvent> m_todos; | 64 | QValueList<ToDoEvent> m_todos; |
63 | XMLElement *root = XMLElement::load( name ); | 65 | XMLElement *root = XMLElement::load( name ); |
64 | if(root != 0l ){ // start parsing | 66 | if(root != 0l ){ // start parsing |
65 | qWarning("ToDoDB::load tagName(): %s", root->tagName().latin1() ); | 67 | qWarning("ToDoDB::load tagName(): %s", root->tagName().latin1() ); |
66 | //if( root->tagName() == QString::fromLatin1("Tasks" ) ){// Start | 68 | //if( root->tagName() == QString::fromLatin1("Tasks" ) ){// Start |
67 | XMLElement *element = root->firstChild(); | 69 | XMLElement *element = root->firstChild(); |
68 | element = element->firstChild(); | 70 | element = element->firstChild(); |
69 | while( element ){ | 71 | while( element ){ |
70 | if( element->tagName() != QString::fromLatin1("Task") ){ | 72 | if( element->tagName() != QString::fromLatin1("Task") ){ |
71 | element = element->nextChild(); | 73 | element = element->nextChild(); |
72 | continue; | 74 | continue; |
73 | } | 75 | } |
74 | qWarning("ToDoDB::load element tagName() : %s", element->tagName().latin1() ); | 76 | qWarning("ToDoDB::load element tagName() : %s", element->tagName().latin1() ); |
75 | QString dummy; | 77 | QString dummy; |
76 | ToDoEvent event; | 78 | ToDoEvent event; |
77 | bool ok; | 79 | bool ok; |
78 | int dumInt; | 80 | int dumInt; |
79 | // completed | 81 | // completed |
80 | dummy = element->attribute("Completed" ); | 82 | dummy = element->attribute("Completed" ); |
81 | dumInt = dummy.toInt(&ok ); | 83 | dumInt = dummy.toInt(&ok ); |
82 | if(ok ) event.setCompleted( dumInt == 0 ? false : true ); | 84 | if(ok ) event.setCompleted( dumInt == 0 ? false : true ); |
83 | // hasDate | 85 | // hasDate |
84 | dummy = element->attribute("HasDate" ); | 86 | dummy = element->attribute("HasDate" ); |
85 | dumInt = dummy.toInt(&ok ); | 87 | dumInt = dummy.toInt(&ok ); |
86 | if(ok ) event.setHasDate( dumInt == 0 ? false: true ); | 88 | if(ok ) event.setHasDate( dumInt == 0 ? false: true ); |
87 | // set the date | 89 | // set the date |
88 | bool hasDa = dumInt; | 90 | bool hasDa = dumInt; |
89 | if ( hasDa ) { //parse the date | 91 | if ( hasDa ) { //parse the date |
90 | int year, day, month = 0; | 92 | int year, day, month = 0; |
91 | year = day = month; | 93 | year = day = month; |
92 | // year | 94 | // year |
93 | dummy = element->attribute("DateYear" ); | 95 | dummy = element->attribute("DateYear" ); |
94 | dumInt = dummy.toInt(&ok ); | 96 | dumInt = dummy.toInt(&ok ); |
95 | if( ok ) year = dumInt; | 97 | if( ok ) year = dumInt; |
96 | // month | 98 | // month |
97 | dummy = element->attribute("DateMonth" ); | 99 | dummy = element->attribute("DateMonth" ); |
98 | dumInt = dummy.toInt(&ok ); | 100 | dumInt = dummy.toInt(&ok ); |
99 | if(ok ) month = dumInt; | 101 | if(ok ) month = dumInt; |
100 | dummy = element->attribute("DateDay" ); | 102 | dummy = element->attribute("DateDay" ); |
101 | dumInt = dummy.toInt(&ok ); | 103 | dumInt = dummy.toInt(&ok ); |
102 | if(ok ) day = dumInt; | 104 | if(ok ) day = dumInt; |
103 | // set the date | 105 | // set the date |
104 | QDate date( year, month, day ); | 106 | QDate date( year, month, day ); |
105 | event.setDate( date); | 107 | event.setDate( date); |
106 | } | 108 | } |
107 | dummy = element->attribute("Priority" ); | 109 | dummy = element->attribute("Priority" ); |
108 | dumInt = dummy.toInt(&ok ); | 110 | dumInt = dummy.toInt(&ok ); |
109 | if(!ok ) dumInt = ToDoEvent::NORMAL; | 111 | if(!ok ) dumInt = ToDoEvent::NORMAL; |
110 | event.setPriority( dumInt ); | 112 | event.setPriority( dumInt ); |
111 | //description | 113 | //description |
112 | dummy = element->attribute("Description" ); | 114 | dummy = element->attribute("Description" ); |
113 | event.setDescription( dummy ); | 115 | event.setDescription( dummy ); |
116 | dummy = element->attribute("Summary" ); | ||
117 | event.setSummary( dummy ); | ||
114 | // category | 118 | // category |
115 | dummy = element->attribute("Categories" ); | 119 | dummy = element->attribute("Categories" ); |
116 | QStringList ids = QStringList::split(";", dummy ); | 120 | QStringList ids = QStringList::split(";", dummy ); |
117 | event.setCategories( ids ); | 121 | event.setCategories( ids ); |
118 | 122 | ||
119 | //uid | 123 | //uid |
120 | dummy = element->attribute("Uid" ); | 124 | dummy = element->attribute("Uid" ); |
121 | dumInt = dummy.toInt(&ok ); | 125 | dumInt = dummy.toInt(&ok ); |
122 | if(ok ) event.setUid( dumInt ); | 126 | if(ok ) event.setUid( dumInt ); |
123 | m_todos.append( event ); | 127 | m_todos.append( event ); |
124 | element = element->nextChild(); // next element | 128 | element = element->nextChild(); // next element |
125 | } | 129 | } |
126 | //} | 130 | //} |
127 | }else { | 131 | }else { |
128 | qWarning("could not load" ); | 132 | qWarning("could not load" ); |
129 | } | 133 | } |
130 | delete root; | 134 | delete root; |
131 | qWarning("returning" ); | 135 | qWarning("returning" ); |
132 | return m_todos; | 136 | return m_todos; |
133 | } | 137 | } |
134 | }; | 138 | }; |
135 | 139 | ||
136 | } | 140 | } |
137 | 141 | ||
138 | ToDoDB::ToDoDB(const QString &fileName, ToDoResource *res ){ | 142 | ToDoDB::ToDoDB(const QString &fileName, ToDoResource *res ){ |
139 | m_fileName = fileName; | 143 | m_fileName = fileName; |
140 | if( fileName.isEmpty() && res == 0 ){ | 144 | if( fileName.isEmpty() && res == 0 ){ |
141 | m_fileName = Global::applicationFileName("todolist","todolist.xml"); | 145 | m_fileName = Global::applicationFileName("todolist","todolist.xml"); |
142 | res = new FileToDoResource(); | 146 | res = new FileToDoResource(); |
143 | //qWarning("%s", m_fileName.latin1() ); | 147 | //qWarning("%s", m_fileName.latin1() ); |
144 | }else if(res == 0 ){ // let's create a ToDoResource for xml | 148 | }else if(res == 0 ){ // let's create a ToDoResource for xml |
145 | res = new FileToDoResource(); | 149 | res = new FileToDoResource(); |
146 | } | 150 | } |
147 | m_res = res; | 151 | m_res = res; |
148 | load(); | 152 | load(); |
149 | } | 153 | } |
150 | ToDoResource* ToDoDB::resource(){ | 154 | ToDoResource* ToDoDB::resource(){ |
151 | return m_res; | 155 | return m_res; |
152 | }; | 156 | }; |
153 | void ToDoDB::setResource( ToDoResource *res ) | 157 | void ToDoDB::setResource( ToDoResource *res ) |
154 | { | 158 | { |
155 | delete m_res; | 159 | delete m_res; |
156 | m_res = res; | 160 | m_res = res; |
157 | } | 161 | } |
158 | ToDoDB::~ToDoDB() | 162 | ToDoDB::~ToDoDB() |
159 | { | 163 | { |
160 | delete m_res; | 164 | delete m_res; |
161 | } | 165 | } |
162 | QValueList<ToDoEvent> ToDoDB::effectiveToDos(const QDate &from, const QDate &to, | 166 | QValueList<ToDoEvent> ToDoDB::effectiveToDos(const QDate &from, const QDate &to, |
163 | bool all ) | 167 | bool all ) |
164 | { | 168 | { |
165 | QValueList<ToDoEvent> events; | 169 | QValueList<ToDoEvent> events; |
166 | for( QValueList<ToDoEvent>::Iterator it = m_todos.begin(); it!= m_todos.end(); ++it ){ | 170 | for( QValueList<ToDoEvent>::Iterator it = m_todos.begin(); it!= m_todos.end(); ++it ){ |
167 | if( (*it).hasDate() ){ | 171 | if( (*it).hasDate() ){ |
168 | if( (*it).date() >= from && (*it).date() <= to ) | 172 | if( (*it).date() >= from && (*it).date() <= to ) |
169 | events.append( (*it) ); | 173 | events.append( (*it) ); |
170 | }else if( all ){ | 174 | }else if( all ){ |
171 | events.append( (*it) ); | 175 | events.append( (*it) ); |
172 | } | 176 | } |
173 | } | 177 | } |
174 | return events; | 178 | return events; |
175 | } | 179 | } |
176 | QValueList<ToDoEvent> ToDoDB::effectiveToDos(const QDate &from, | 180 | QValueList<ToDoEvent> ToDoDB::effectiveToDos(const QDate &from, |
177 | bool all) | 181 | bool all) |
178 | { | 182 | { |
179 | return effectiveToDos( from, QDate::currentDate(), all ); | 183 | return effectiveToDos( from, QDate::currentDate(), all ); |
180 | } | 184 | } |
181 | QValueList<ToDoEvent> ToDoDB::overDue() | 185 | QValueList<ToDoEvent> ToDoDB::overDue() |
182 | { | 186 | { |
183 | QValueList<ToDoEvent> events; | 187 | QValueList<ToDoEvent> events; |
184 | for( QValueList<ToDoEvent>::Iterator it = m_todos.begin(); it!= m_todos.end(); ++it ){ | 188 | for( QValueList<ToDoEvent>::Iterator it = m_todos.begin(); it!= m_todos.end(); ++it ){ |
185 | if( (*it).isOverdue() ) | 189 | if( (*it).isOverdue() ) |
186 | events.append((*it) ); | 190 | events.append((*it) ); |
187 | } | 191 | } |
188 | return events; | 192 | return events; |
189 | } | 193 | } |
190 | QValueList<ToDoEvent> ToDoDB::rawToDos() | 194 | QValueList<ToDoEvent> ToDoDB::rawToDos() |
191 | { | 195 | { |
192 | return m_todos; | 196 | return m_todos; |
193 | } | 197 | } |
194 | void ToDoDB::addEvent( const ToDoEvent &event ) | 198 | void ToDoDB::addEvent( const ToDoEvent &event ) |
195 | { | 199 | { |
196 | m_todos.append( event ); | 200 | m_todos.append( event ); |
197 | } | 201 | } |
198 | void ToDoDB::editEvent( const ToDoEvent &event ) | 202 | void ToDoDB::editEvent( const ToDoEvent &event ) |
199 | { | 203 | { |
200 | m_todos.remove( event ); | 204 | m_todos.remove( event ); |
201 | m_todos.append( event ); | 205 | m_todos.append( event ); |
202 | } | 206 | } |
203 | void ToDoDB::removeEvent( const ToDoEvent &event ) | 207 | void ToDoDB::removeEvent( const ToDoEvent &event ) |
204 | { | 208 | { |
205 | m_todos.remove( event ); | 209 | m_todos.remove( event ); |
206 | } | 210 | } |
207 | void ToDoDB::replaceEvent(const ToDoEvent &event ) | 211 | void ToDoDB::replaceEvent(const ToDoEvent &event ) |
208 | { | 212 | { |
209 | QValueList<ToDoEvent>::Iterator it; | 213 | QValueList<ToDoEvent>::Iterator it; |
210 | int uid = event.uid(); | 214 | int uid = event.uid(); |
211 | // == is not overloaded as we would like :( so let's search for the uid | 215 | // == is not overloaded as we would like :( so let's search for the uid |
212 | for(it = m_todos.begin(); it != m_todos.end(); ++it ){ | 216 | for(it = m_todos.begin(); it != m_todos.end(); ++it ){ |
213 | if( (*it).uid() == uid ){ | 217 | if( (*it).uid() == uid ){ |
214 | m_todos.remove( (*it) ); | 218 | m_todos.remove( (*it) ); |
215 | break; // should save us the iterate is now borked | 219 | break; // should save us the iterate is now borked |
216 | } | 220 | } |
217 | } | 221 | } |
218 | m_todos.append(event); | 222 | m_todos.append(event); |
219 | } | 223 | } |
220 | void ToDoDB::reload() | 224 | void ToDoDB::reload() |
221 | { | 225 | { |
222 | load(); | 226 | load(); |
223 | } | 227 | } |
224 | void ToDoDB::mergeWith(const QValueList<ToDoEvent>& events ) | 228 | void ToDoDB::mergeWith(const QValueList<ToDoEvent>& events ) |
225 | { | 229 | { |
226 | QValueList<ToDoEvent>::ConstIterator it; | 230 | QValueList<ToDoEvent>::ConstIterator it; |
227 | for( it = events.begin(); it != events.end(); ++it ){ | 231 | for( it = events.begin(); it != events.end(); ++it ){ |
228 | replaceEvent( (*it) ); | 232 | replaceEvent( (*it) ); |
229 | } | 233 | } |
230 | } | 234 | } |
231 | void ToDoDB::setFileName(const QString &file ) | 235 | void ToDoDB::setFileName(const QString &file ) |
232 | { | 236 | { |
233 | m_fileName =file; | 237 | m_fileName =file; |
234 | } | 238 | } |
235 | QString ToDoDB::fileName()const | 239 | QString ToDoDB::fileName()const |
236 | { | 240 | { |
237 | return m_fileName; | 241 | return m_fileName; |
238 | } | 242 | } |
239 | void ToDoDB::load() | 243 | void ToDoDB::load() |
240 | { | 244 | { |
241 | m_todos = m_res->load( m_fileName ); | 245 | m_todos = m_res->load( m_fileName ); |
242 | } | 246 | } |
243 | bool ToDoDB::save() | 247 | bool ToDoDB::save() |
244 | { | 248 | { |
245 | return m_res->save( m_fileName, m_todos ); | 249 | return m_res->save( m_fileName, m_todos ); |
246 | } | 250 | } |
247 | 251 | ||
248 | 252 | ||
249 | 253 | ||
250 | 254 | ||
251 | 255 | ||
252 | 256 | ||
253 | 257 | ||
254 | 258 | ||
diff --git a/libopie/todoevent.cpp b/libopie/todoevent.cpp index aa348a2..fb7073c 100644 --- a/libopie/todoevent.cpp +++ b/libopie/todoevent.cpp | |||
@@ -1,240 +1,269 @@ | |||
1 | 1 | ||
2 | #include <opie/todoevent.h> | 2 | #include <opie/todoevent.h> |
3 | 3 | ||
4 | 4 | ||
5 | #include <qpe/palmtopuidgen.h> | 5 | #include <qpe/palmtopuidgen.h> |
6 | #include <qpe/stringutil.h> | 6 | #include <qpe/stringutil.h> |
7 | #include <qpe/palmtoprecord.h> | 7 | #include <qpe/palmtoprecord.h> |
8 | 8 | ||
9 | #include <qpe/stringutil.h> | 9 | #include <qpe/stringutil.h> |
10 | #include <qpe/categories.h> | 10 | #include <qpe/categories.h> |
11 | #include <qpe/categoryselect.h> | 11 | #include <qpe/categoryselect.h> |
12 | 12 | ||
13 | #include <qobject.h> | 13 | #include <qobject.h> |
14 | 14 | ||
15 | ToDoEvent::ToDoEvent(const ToDoEvent &event ) | 15 | ToDoEvent::ToDoEvent(const ToDoEvent &event ) |
16 | { | 16 | { |
17 | *this = event; | 17 | *this = event; |
18 | } | 18 | } |
19 | 19 | ||
20 | ToDoEvent::ToDoEvent(bool completed, int priority, const QStringList &category, | 20 | ToDoEvent::ToDoEvent(bool completed, int priority, |
21 | const QString &description, bool hasDate, QDate date, int uid ) | 21 | const QStringList &category, |
22 | const QString& summary, | ||
23 | const QString &description, | ||
24 | bool hasDate, QDate date, int uid ) | ||
22 | { | 25 | { |
23 | m_date = date; | 26 | m_date = date; |
24 | m_isCompleted = completed; | 27 | m_isCompleted = completed; |
25 | m_hasDate = hasDate; | 28 | m_hasDate = hasDate; |
26 | m_priority = priority; | 29 | m_priority = priority; |
27 | m_category = category; | 30 | m_category = category; |
31 | m_sum = summary; | ||
28 | m_desc = Qtopia::simplifyMultiLineSpace(description ); | 32 | m_desc = Qtopia::simplifyMultiLineSpace(description ); |
29 | if (uid == -1 ) { | 33 | if (uid == -1 ) { |
30 | Qtopia::UidGen *uidgen = new Qtopia::UidGen(); | 34 | Qtopia::UidGen *uidgen = new Qtopia::UidGen(); |
31 | uid = uidgen->generate(); | 35 | uid = uidgen->generate(); |
32 | delete uidgen; | 36 | delete uidgen; |
33 | }// generate the ids | 37 | }// generate the ids |
34 | m_uid = uid; | 38 | m_uid = uid; |
35 | } | 39 | } |
36 | QArray<int> ToDoEvent::categories()const | 40 | QArray<int> ToDoEvent::categories()const |
37 | { | 41 | { |
38 | QArray<int> array(m_category.count() ); // currently the datebook can be only in one category | 42 | QArray<int> array(m_category.count() ); // currently the datebook can be only in one category |
39 | array = Qtopia::Record::idsFromString( m_category.join(";") ); | 43 | array = Qtopia::Record::idsFromString( m_category.join(";") ); |
40 | return array; | 44 | return array; |
41 | } | 45 | } |
42 | bool ToDoEvent::match( const QRegExp ®Exp )const | 46 | bool ToDoEvent::match( const QRegExp ®Exp )const |
43 | { | 47 | { |
44 | if( QString::number( m_priority ).find( regExp ) != -1 ){ | 48 | if( QString::number( m_priority ).find( regExp ) != -1 ){ |
45 | return true; | 49 | return true; |
46 | }else if( m_hasDate && m_date.toString().find( regExp) != -1 ){ | 50 | }else if( m_hasDate && m_date.toString().find( regExp) != -1 ){ |
47 | return true; | 51 | return true; |
48 | }else if(m_desc.find( regExp ) != -1 ){ | 52 | }else if(m_desc.find( regExp ) != -1 ){ |
49 | return true; | 53 | return true; |
50 | } | 54 | } |
51 | return false; | 55 | return false; |
52 | } | 56 | } |
53 | bool ToDoEvent::isCompleted() const | 57 | bool ToDoEvent::isCompleted() const |
54 | { | 58 | { |
55 | return m_isCompleted; | 59 | return m_isCompleted; |
56 | } | 60 | } |
57 | bool ToDoEvent::hasDate() const | 61 | bool ToDoEvent::hasDate() const |
58 | { | 62 | { |
59 | return m_hasDate; | 63 | return m_hasDate; |
60 | } | 64 | } |
61 | int ToDoEvent::priority()const | 65 | int ToDoEvent::priority()const |
62 | { | 66 | { |
63 | return m_priority; | 67 | return m_priority; |
64 | } | 68 | } |
65 | QStringList ToDoEvent::allCategories()const | 69 | QStringList ToDoEvent::allCategories()const |
66 | { | 70 | { |
67 | return m_category; | 71 | return m_category; |
68 | } | 72 | } |
73 | QString ToDoEvent::extra(const QString& )const | ||
74 | { | ||
75 | return QString::null; | ||
76 | } | ||
77 | QString ToDoEvent::summary() const | ||
78 | { | ||
79 | return m_sum; | ||
80 | } | ||
69 | void ToDoEvent::insertCategory(const QString &str ) | 81 | void ToDoEvent::insertCategory(const QString &str ) |
70 | { | 82 | { |
71 | m_category.append( str ); | 83 | m_category.append( str ); |
72 | } | 84 | } |
73 | void ToDoEvent::clearCategories() | 85 | void ToDoEvent::clearCategories() |
74 | { | 86 | { |
75 | m_category.clear(); | 87 | m_category.clear(); |
76 | } | 88 | } |
77 | void ToDoEvent::setCategories(const QStringList &list ) | 89 | void ToDoEvent::setCategories(const QStringList &list ) |
78 | { | 90 | { |
79 | m_category = list; | 91 | m_category = list; |
80 | } | 92 | } |
81 | QDate ToDoEvent::date()const | 93 | QDate ToDoEvent::date()const |
82 | { | 94 | { |
83 | return m_date; | 95 | return m_date; |
84 | } | 96 | } |
85 | 97 | ||
86 | QString ToDoEvent::description()const | 98 | QString ToDoEvent::description()const |
87 | { | 99 | { |
88 | return m_desc; | 100 | return m_desc; |
89 | } | 101 | } |
90 | void ToDoEvent::setCompleted( bool completed ) | 102 | void ToDoEvent::setCompleted( bool completed ) |
91 | { | 103 | { |
92 | m_isCompleted = completed; | 104 | m_isCompleted = completed; |
93 | } | 105 | } |
94 | void ToDoEvent::setHasDate( bool hasDate ) | 106 | void ToDoEvent::setHasDate( bool hasDate ) |
95 | { | 107 | { |
96 | m_hasDate = hasDate; | 108 | m_hasDate = hasDate; |
97 | } | 109 | } |
98 | void ToDoEvent::setDescription(const QString &desc ) | 110 | void ToDoEvent::setDescription(const QString &desc ) |
99 | { | 111 | { |
100 | m_desc = Qtopia::simplifyMultiLineSpace(desc ); | 112 | m_desc = Qtopia::simplifyMultiLineSpace(desc ); |
101 | } | 113 | } |
114 | void ToDoEvent::setExtra( const QString&, const QString& ) | ||
115 | { | ||
116 | |||
117 | } | ||
118 | void ToDoEvent::setSummary( const QString& sum ) | ||
119 | { | ||
120 | m_sum = sum; | ||
121 | } | ||
102 | void ToDoEvent::setCategory( const QString &cat ) | 122 | void ToDoEvent::setCategory( const QString &cat ) |
103 | { | 123 | { |
104 | qWarning("setCategory %s", cat.latin1() ); | 124 | qWarning("setCategory %s", cat.latin1() ); |
105 | m_category.clear(); | 125 | m_category.clear(); |
106 | m_category << cat; | 126 | m_category << cat; |
107 | } | 127 | } |
108 | void ToDoEvent::setPriority(int prio ) | 128 | void ToDoEvent::setPriority(int prio ) |
109 | { | 129 | { |
110 | m_priority = prio; | 130 | m_priority = prio; |
111 | } | 131 | } |
112 | void ToDoEvent::setDate( QDate date ) | 132 | void ToDoEvent::setDate( QDate date ) |
113 | { | 133 | { |
114 | m_date = date; | 134 | m_date = date; |
115 | } | 135 | } |
116 | bool ToDoEvent::isOverdue( ) | 136 | bool ToDoEvent::isOverdue( ) |
117 | { | 137 | { |
118 | if( m_hasDate ) | 138 | if( m_hasDate ) |
119 | return QDate::currentDate() > m_date; | 139 | return QDate::currentDate() > m_date; |
120 | return false; | 140 | return false; |
121 | } | 141 | } |
122 | 142 | ||
123 | /*! | 143 | /*! |
124 | Returns a richt text string | 144 | Returns a richt text string |
125 | */ | 145 | */ |
126 | QString ToDoEvent::richText() const | 146 | QString ToDoEvent::richText() const |
127 | { | 147 | { |
128 | QString text; | 148 | QString text; |
129 | QStringList catlist; | 149 | QStringList catlist; |
130 | 150 | ||
131 | // Description of the todo | 151 | // Description of the todo |
132 | if ( !description().isEmpty() ){ | 152 | if ( !description().isEmpty() ){ |
153 | text += "<b>" + QObject::tr( "Summary:") + "</b><br>"; | ||
154 | text += Qtopia::escapeString(summary() ).replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; | ||
133 | text += "<b>" + QObject::tr( "Description:" ) + "</b><br>"; | 155 | text += "<b>" + QObject::tr( "Description:" ) + "</b><br>"; |
134 | text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; | 156 | text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; |
135 | } | 157 | } |
136 | text += "<b>" + QObject::tr( "Priority:") +" </b>" | 158 | text += "<b>" + QObject::tr( "Priority:") +" </b>" |
137 | + QString::number( priority() ) + "<br>"; | 159 | + QString::number( priority() ) + "<br>"; |
138 | if (hasDate() ){ | 160 | if (hasDate() ){ |
139 | text += "<b>" + QObject::tr( "Deadline:") + " </b>"; | 161 | text += "<b>" + QObject::tr( "Deadline:") + " </b>"; |
140 | text += date().toString(); | 162 | text += date().toString(); |
141 | text += "<br>"; | 163 | text += "<br>"; |
142 | } | 164 | } |
143 | 165 | ||
144 | // Open database of all categories and get the list of | 166 | // Open database of all categories and get the list of |
145 | // the categories this todoevent belongs to. | 167 | // the categories this todoevent belongs to. |
146 | // Then print them... | 168 | // Then print them... |
147 | // I am not sure whether there is no better way doing this !? | 169 | // I am not sure whether there is no better way doing this !? |
148 | Categories catdb; | 170 | Categories catdb; |
149 | bool firstloop = true; | 171 | bool firstloop = true; |
150 | catdb.load( categoryFileName() ); | 172 | catdb.load( categoryFileName() ); |
151 | catlist = allCategories(); | 173 | catlist = allCategories(); |
152 | 174 | ||
153 | text += "<b>" + QObject::tr( "Category:") + "</b> "; | 175 | text += "<b>" + QObject::tr( "Category:") + "</b> "; |
154 | for ( QStringList::Iterator it = catlist.begin(); it != catlist.end(); ++it ) { | 176 | for ( QStringList::Iterator it = catlist.begin(); it != catlist.end(); ++it ) { |
155 | if (!firstloop){ | 177 | if (!firstloop){ |
156 | text += ", "; | 178 | text += ", "; |
157 | } | 179 | } |
158 | firstloop = false; | 180 | firstloop = false; |
159 | text += catdb.label ("todo", (*it).toInt()); | 181 | text += catdb.label ("todo", (*it).toInt()); |
160 | } | 182 | } |
161 | text += "<br>"; | 183 | text += "<br>"; |
162 | return text; | 184 | return text; |
163 | } | 185 | } |
164 | 186 | ||
165 | bool ToDoEvent::operator<( const ToDoEvent &toDoEvent )const{ | 187 | bool ToDoEvent::operator<( const ToDoEvent &toDoEvent )const{ |
166 | if( !hasDate() && !toDoEvent.hasDate() ) return true; | 188 | if( !hasDate() && !toDoEvent.hasDate() ) return true; |
167 | if( !hasDate() && toDoEvent.hasDate() ) return true; | 189 | if( !hasDate() && toDoEvent.hasDate() ) return true; |
168 | if( hasDate() && toDoEvent.hasDate() ){ | 190 | if( hasDate() && toDoEvent.hasDate() ){ |
169 | if( date() == toDoEvent.date() ){ // let's the priority decide | 191 | if( date() == toDoEvent.date() ){ // let's the priority decide |
170 | return priority() < toDoEvent.priority(); | 192 | return priority() < toDoEvent.priority(); |
171 | }else{ | 193 | }else{ |
172 | return date() < toDoEvent.date(); | 194 | return date() < toDoEvent.date(); |
173 | } | 195 | } |
174 | } | 196 | } |
175 | return false; | 197 | return false; |
176 | } | 198 | } |
177 | bool ToDoEvent::operator<=(const ToDoEvent &toDoEvent )const | 199 | bool ToDoEvent::operator<=(const ToDoEvent &toDoEvent )const |
178 | { | 200 | { |
179 | if( !hasDate() && !toDoEvent.hasDate() ) return true; | 201 | if( !hasDate() && !toDoEvent.hasDate() ) return true; |
180 | if( !hasDate() && toDoEvent.hasDate() ) return true; | 202 | if( !hasDate() && toDoEvent.hasDate() ) return true; |
181 | if( hasDate() && toDoEvent.hasDate() ){ | 203 | if( hasDate() && toDoEvent.hasDate() ){ |
182 | if( date() == toDoEvent.date() ){ // let's the priority decide | 204 | if( date() == toDoEvent.date() ){ // let's the priority decide |
183 | return priority() <= toDoEvent.priority(); | 205 | return priority() <= toDoEvent.priority(); |
184 | }else{ | 206 | }else{ |
185 | return date() <= toDoEvent.date(); | 207 | return date() <= toDoEvent.date(); |
186 | } | 208 | } |
187 | } | 209 | } |
188 | return true; | 210 | return true; |
189 | } | 211 | } |
190 | bool ToDoEvent::operator>(const ToDoEvent &toDoEvent )const | 212 | bool ToDoEvent::operator>(const ToDoEvent &toDoEvent )const |
191 | { | 213 | { |
192 | if( !hasDate() && !toDoEvent.hasDate() ) return false; | 214 | if( !hasDate() && !toDoEvent.hasDate() ) return false; |
193 | if( !hasDate() && toDoEvent.hasDate() ) return false; | 215 | if( !hasDate() && toDoEvent.hasDate() ) return false; |
194 | if( hasDate() && toDoEvent.hasDate() ){ | 216 | if( hasDate() && toDoEvent.hasDate() ){ |
195 | if( date() == toDoEvent.date() ){ // let's the priority decide | 217 | if( date() == toDoEvent.date() ){ // let's the priority decide |
196 | return priority() > toDoEvent.priority(); | 218 | return priority() > toDoEvent.priority(); |
197 | }else{ | 219 | }else{ |
198 | return date() > toDoEvent.date(); | 220 | return date() > toDoEvent.date(); |
199 | } | 221 | } |
200 | } | 222 | } |
201 | return false; | 223 | return false; |
202 | } | 224 | } |
203 | bool ToDoEvent::operator>=(const ToDoEvent &toDoEvent )const | 225 | bool ToDoEvent::operator>=(const ToDoEvent &toDoEvent )const |
204 | { | 226 | { |
205 | if( !hasDate() && !toDoEvent.hasDate() ) return true; | 227 | if( !hasDate() && !toDoEvent.hasDate() ) return true; |
206 | if( !hasDate() && toDoEvent.hasDate() ) return false; | 228 | if( !hasDate() && toDoEvent.hasDate() ) return false; |
207 | if( hasDate() && toDoEvent.hasDate() ){ | 229 | if( hasDate() && toDoEvent.hasDate() ){ |
208 | if( date() == toDoEvent.date() ){ // let's the priority decide | 230 | if( date() == toDoEvent.date() ){ // let's the priority decide |
209 | return priority() > toDoEvent.priority(); | 231 | return priority() > toDoEvent.priority(); |
210 | }else{ | 232 | }else{ |
211 | return date() > toDoEvent.date(); | 233 | return date() > toDoEvent.date(); |
212 | } | 234 | } |
213 | } | 235 | } |
214 | return true; | 236 | return true; |
215 | } | 237 | } |
216 | bool ToDoEvent::operator==(const ToDoEvent &toDoEvent )const | 238 | bool ToDoEvent::operator==(const ToDoEvent &toDoEvent )const |
217 | { | 239 | { |
218 | if( m_date == toDoEvent.m_date && m_isCompleted == toDoEvent.m_isCompleted && m_hasDate == toDoEvent.m_hasDate && m_priority == toDoEvent.m_priority && m_category == toDoEvent.m_category && m_desc == toDoEvent.m_desc ) | 240 | if( m_priority == toDoEvent.m_priority && |
241 | m_isCompleted == toDoEvent.m_isCompleted && | ||
242 | m_hasDate == toDoEvent.m_hasDate && | ||
243 | m_date == toDoEvent.m_date && | ||
244 | m_category == toDoEvent.m_category && | ||
245 | m_sum == toDoEvent.m_sum && | ||
246 | m_desc == toDoEvent.m_desc ) | ||
219 | return true; | 247 | return true; |
220 | return false; | 248 | return false; |
221 | } | 249 | } |
222 | ToDoEvent &ToDoEvent::operator=(const ToDoEvent &item ) | 250 | ToDoEvent &ToDoEvent::operator=(const ToDoEvent &item ) |
223 | { | 251 | { |
224 | m_date = item.m_date; | 252 | m_date = item.m_date; |
225 | m_isCompleted = item.m_isCompleted; | 253 | m_isCompleted = item.m_isCompleted; |
226 | m_hasDate = item.m_hasDate; | 254 | m_hasDate = item.m_hasDate; |
227 | m_priority = item.m_priority; | 255 | m_priority = item.m_priority; |
228 | m_category = item.m_category; | 256 | m_category = item.m_category; |
229 | m_desc = item.m_desc; | 257 | m_desc = item.m_desc; |
230 | m_uid = item.m_uid; | 258 | m_uid = item.m_uid; |
259 | m_sum = item.m_sum; | ||
231 | return *this; | 260 | return *this; |
232 | } | 261 | } |
233 | 262 | ||
234 | 263 | ||
235 | 264 | ||
236 | 265 | ||
237 | 266 | ||
238 | 267 | ||
239 | 268 | ||
240 | 269 | ||
diff --git a/libopie/todoevent.h b/libopie/todoevent.h index 8a00f99..7454241 100644 --- a/libopie/todoevent.h +++ b/libopie/todoevent.h | |||
@@ -1,92 +1,151 @@ | |||
1 | 1 | ||
2 | #ifndef todoevent_h | 2 | #ifndef todoevent_h |
3 | #define todoevent_h | 3 | #define todoevent_h |
4 | 4 | ||
5 | #include <qmap.h> | ||
5 | #include <qregexp.h> | 6 | #include <qregexp.h> |
6 | #include <qstringlist.h> | 7 | #include <qstringlist.h> |
7 | #include <qdatetime.h> | 8 | #include <qdatetime.h> |
8 | 9 | ||
9 | class ToDoEvent { | 10 | class ToDoEvent { |
10 | friend class ToDoDB; | 11 | friend class ToDoDB; |
11 | public: | 12 | public: |
12 | // priorities from Very low to very high | 13 | // priorities from Very low to very high |
13 | enum Priority { VERYHIGH=1, HIGH, NORMAL, LOW, VERYLOW }; | 14 | enum Priority { VERYHIGH=1, HIGH, NORMAL, LOW, VERYLOW }; |
14 | /* Constructs a new ToDoEvent | 15 | /* Constructs a new ToDoEvent |
15 | @param completed Is the TodoEvent completed | 16 | @param completed Is the TodoEvent completed |
16 | @param priority What is the priority of this ToDoEvent | 17 | @param priority What is the priority of this ToDoEvent |
17 | @param category Which category does it belong( uid ) | 18 | @param category Which category does it belong( uid ) |
19 | @param summary A small summary of the todo | ||
18 | @param description What is this ToDoEvent about | 20 | @param description What is this ToDoEvent about |
19 | @param hasDate Does this Event got a deadline | 21 | @param hasDate Does this Event got a deadline |
20 | @param date what is the deadline? | 22 | @param date what is the deadline? |
21 | @param uid what is the UUID of this Event | 23 | @param uid what is the UUID of this Event |
22 | **/ | 24 | **/ |
23 | ToDoEvent( bool completed = false, int priority = NORMAL, | 25 | ToDoEvent( bool completed = false, int priority = NORMAL, |
24 | const QStringList &category = QStringList(), | 26 | const QStringList &category = QStringList(), |
25 | const QString &description = QString::null , | 27 | const QString &summary = QString::null , |
28 | const QString &description = QString::null, | ||
26 | bool hasDate = false, QDate date = QDate::currentDate(), int uid = -1 ); | 29 | bool hasDate = false, QDate date = QDate::currentDate(), int uid = -1 ); |
27 | /* Copy c'tor | 30 | /* Copy c'tor |
28 | 31 | ||
29 | **/ | 32 | **/ |
30 | ToDoEvent(const ToDoEvent & ); | 33 | ToDoEvent(const ToDoEvent & ); |
31 | 34 | ||
32 | /* | 35 | /* |
33 | Is this event completed? | 36 | Is this event completed? |
34 | **/ | 37 | **/ |
35 | bool isCompleted() const; | 38 | bool isCompleted() const; |
36 | 39 | ||
37 | /* | 40 | /* |
38 | Does this Event have a deadline | 41 | Does this Event have a deadline |
39 | **/ | 42 | **/ |
40 | bool hasDate() const; | 43 | bool hasDate() const; |
41 | 44 | ||
42 | /* | 45 | /* |
43 | What is the priority? | 46 | What is the priority? |
44 | **/ | 47 | **/ |
45 | int priority()const ; | 48 | int priority()const ; |
49 | |||
50 | /* | ||
51 | All category numbers as QString in a List | ||
52 | **/ | ||
46 | QStringList allCategories()const; | 53 | QStringList allCategories()const; |
54 | |||
55 | /* | ||
56 | * Same as above but with QArray<int> | ||
57 | */ | ||
47 | QArray<int> categories() const; | 58 | QArray<int> categories() const; |
59 | |||
60 | /** | ||
61 | * The end Date | ||
62 | */ | ||
48 | QDate date()const; | 63 | QDate date()const; |
64 | |||
65 | /** | ||
66 | * The description of the todo | ||
67 | */ | ||
49 | QString description()const; | 68 | QString description()const; |
50 | 69 | ||
70 | /** | ||
71 | * A small summary of the todo | ||
72 | */ | ||
73 | QString summary() const; | ||
74 | |||
75 | /** | ||
76 | * Return this todoevent in a RichText formatted QString | ||
77 | */ | ||
51 | QString richText() const; | 78 | QString richText() const; |
52 | 79 | ||
80 | /** | ||
81 | * Returns the UID of the Todo | ||
82 | */ | ||
53 | int uid()const { return m_uid;}; | 83 | int uid()const { return m_uid;}; |
84 | |||
85 | |||
86 | QString extra(const QString& )const; | ||
87 | /** | ||
88 | * Set if this Todo is completed | ||
89 | */ | ||
54 | void setCompleted(bool completed ); | 90 | void setCompleted(bool completed ); |
91 | |||
92 | /** | ||
93 | * set if this todo got an end data | ||
94 | */ | ||
55 | void setHasDate( bool hasDate ); | 95 | void setHasDate( bool hasDate ); |
56 | // if the category doesn't exist we will create it | 96 | // if the category doesn't exist we will create it |
57 | // this sets the the Category after this call category will be the only category | 97 | // this sets the the Category after this call category will be the only category |
58 | void setCategory( const QString &category ); | 98 | void setCategory( const QString &category ); |
59 | // adds a category to the Categories of this event | 99 | // adds a category to the Categories of this event |
60 | void insertCategory(const QString &category ); | 100 | void insertCategory(const QString &category ); |
101 | |||
102 | /** | ||
103 | * Removes this event from all categories | ||
104 | */ | ||
61 | void clearCategories(); | 105 | void clearCategories(); |
106 | |||
107 | /** | ||
108 | * This todo belongs to xxx categories | ||
109 | */ | ||
62 | void setCategories(const QStringList& ); | 110 | void setCategories(const QStringList& ); |
63 | 111 | ||
112 | /** | ||
113 | * Set the priority of the Todo | ||
114 | */ | ||
64 | void setPriority(int priority ); | 115 | void setPriority(int priority ); |
116 | |||
117 | /** | ||
118 | * set the end date | ||
119 | */ | ||
65 | void setDate( QDate date ); | 120 | void setDate( QDate date ); |
66 | void setDescription(const QString& ); | 121 | void setDescription(const QString& ); |
122 | void setSummary(const QString& ); | ||
123 | void setExtra( const QString&, const QString& ); | ||
67 | bool isOverdue(); | 124 | bool isOverdue(); |
68 | 125 | ||
69 | bool match( const QRegExp &r )const; | 126 | bool match( const QRegExp &r )const; |
70 | 127 | ||
71 | void setUid(int id) {m_uid = id; }; | 128 | void setUid(int id) {m_uid = id; }; |
72 | bool operator<(const ToDoEvent &toDoEvent )const; | 129 | bool operator<(const ToDoEvent &toDoEvent )const; |
73 | bool operator<=(const ToDoEvent &toDoEvent )const; | 130 | bool operator<=(const ToDoEvent &toDoEvent )const; |
74 | bool operator!=(const ToDoEvent &toDoEvent )const { return !(*this == toDoEvent); }; | 131 | bool operator!=(const ToDoEvent &toDoEvent )const { return !(*this == toDoEvent); }; |
75 | bool operator>(const ToDoEvent &toDoEvent )const; | 132 | bool operator>(const ToDoEvent &toDoEvent )const; |
76 | bool operator>=(const ToDoEvent &toDoEvent)const; | 133 | bool operator>=(const ToDoEvent &toDoEvent)const; |
77 | bool operator==(const ToDoEvent &toDoEvent )const; | 134 | bool operator==(const ToDoEvent &toDoEvent )const; |
78 | ToDoEvent &operator=(const ToDoEvent &toDoEvent ); | 135 | ToDoEvent &operator=(const ToDoEvent &toDoEvent ); |
79 | private: | 136 | private: |
80 | class ToDoEventPrivate; | 137 | class ToDoEventPrivate; |
81 | ToDoEventPrivate *d; | 138 | ToDoEventPrivate *d; |
82 | QDate m_date; | 139 | QDate m_date; |
83 | bool m_isCompleted:1; | 140 | bool m_isCompleted:1; |
84 | bool m_hasDate:1; | 141 | bool m_hasDate:1; |
85 | int m_priority; | 142 | int m_priority; |
86 | QStringList m_category; | 143 | QStringList m_category; |
87 | QString m_desc; | 144 | QString m_desc; |
145 | QString m_sum; | ||
146 | QMap<QString, QString> m_extra; | ||
88 | int m_uid; | 147 | int m_uid; |
89 | }; | 148 | }; |
90 | 149 | ||
91 | 150 | ||
92 | #endif | 151 | #endif |
diff --git a/libopie/todovcalresource.cpp b/libopie/todovcalresource.cpp index 75f2197..80f8c60 100644 --- a/libopie/todovcalresource.cpp +++ b/libopie/todovcalresource.cpp | |||
@@ -1,153 +1,158 @@ | |||
1 | /* | 1 | /* |
2 | =. This file is part of the OPIE Project | 2 | =. This file is part of the OPIE Project |
3 | .=l. Copyright (c) 2002 Holger Freyther <freyther@kde.org> | 3 | .=l. Copyright (c) 2002 Holger Freyther <freyther@kde.org> |
4 | .>+-= the use of vobject was inspired by libkcal | 4 | .>+-= the use of vobject was inspired by libkcal |
5 | _;:, .> :=|. This library is free software; you can | 5 | _;:, .> :=|. This library is free software; you can |
6 | .> <`_, > . <= redistribute it and/or modify it under | 6 | .> <`_, > . <= redistribute it and/or modify it under |
7 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 7 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
8 | .="- .-=="i, .._ License as published by the Free Software | 8 | .="- .-=="i, .._ License as published by the Free Software |
9 | - . .-<_> .<> Foundation; either version 2 of the License, | 9 | - . .-<_> .<> Foundation; either version 2 of the License, |
10 | ._= =} : or (at your option) any later version. | 10 | ._= =} : or (at your option) any later version. |
11 | .%`+i> _;_. | 11 | .%`+i> _;_. |
12 | .i_,=:_. -<s. This library is distributed in the hope that | 12 | .i_,=:_. -<s. This library is distributed in the hope that |
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
14 | : .. .:, . . . without even the implied warranty of | 14 | : .. .:, . . . without even the implied warranty of |
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
17 | ..}^=.= = ; Library General Public License for more | 17 | ..}^=.= = ; Library General Public License for more |
18 | ++= -. .` .: details. | 18 | ++= -. .` .: details. |
19 | : = ...= . :.=- | 19 | : = ...= . :.=- |
20 | -. .:....=;==+<; You should have received a copy of the GNU | 20 | -. .:....=;==+<; You should have received a copy of the GNU |
21 | -_. . . )=. = Library General Public License along with | 21 | -_. . . )=. = Library General Public License along with |
22 | -- :-=` this library; see the file COPYING.LIB. | 22 | -- :-=` this library; see the file COPYING.LIB. |
23 | If not, write to the Free Software Foundation, | 23 | If not, write to the Free Software Foundation, |
24 | Inc., 59 Temple Place - Suite 330, | 24 | Inc., 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include <qfile.h> | 29 | #include <qfile.h> |
30 | #include <qvaluelist.h> | 30 | #include <qvaluelist.h> |
31 | #include <opie/todoevent.h> | 31 | #include <opie/todoevent.h> |
32 | #include <opie/todovcalresource.h> | 32 | #include <opie/todovcalresource.h> |
33 | 33 | ||
34 | #include "../library/backend/vobject_p.h" | 34 | #include "../library/backend/vobject_p.h" |
35 | #include "../library/backend/timeconversion.h" | 35 | #include "../library/backend/timeconversion.h" |
36 | #include "../library/backend/qfiledirect_p.h" | 36 | #include "../library/backend/qfiledirect_p.h" |
37 | 37 | ||
38 | static VObject *vobjByEvent( const ToDoEvent &event ) | 38 | static VObject *vobjByEvent( const ToDoEvent &event ) |
39 | { | 39 | { |
40 | VObject *task = newVObject( VCTodoProp ); | 40 | VObject *task = newVObject( VCTodoProp ); |
41 | if( task == 0 ) | 41 | if( task == 0 ) |
42 | return 0l; | 42 | return 0l; |
43 | if( event.hasDate() ) | 43 | if( event.hasDate() ) |
44 | addPropValue( task, VCDueProp, TimeConversion::toISO8601( event.date() ) ); | 44 | addPropValue( task, VCDueProp, TimeConversion::toISO8601( event.date() ) ); |
45 | 45 | ||
46 | if( event.isCompleted() ) | 46 | if( event.isCompleted() ) |
47 | addPropValue( task, VCStatusProp, "COMPLETED"); | 47 | addPropValue( task, VCStatusProp, "COMPLETED"); |
48 | 48 | ||
49 | QString string = QString::number(event.priority() ); | 49 | QString string = QString::number(event.priority() ); |
50 | addPropValue( task, VCPriorityProp, string.local8Bit() ); | 50 | addPropValue( task, VCPriorityProp, string.local8Bit() ); |
51 | addPropValue( task, VCCategoriesProp, event.allCategories().join(";").local8Bit() ); | 51 | addPropValue( task, VCCategoriesProp, event.allCategories().join(";").local8Bit() ); |
52 | addPropValue( task, VCDescriptionProp, event.description().local8Bit() ); | 52 | addPropValue( task, VCDescriptionProp, event.description().local8Bit() ); |
53 | addPropValue( task, VCSummaryProp, event.description().left(15).local8Bit() ); | 53 | addPropValue( task, VCSummaryProp, event.summary().left(15).local8Bit() ); |
54 | return task; | 54 | return task; |
55 | }; | 55 | }; |
56 | 56 | ||
57 | static ToDoEvent eventByVObj( VObject *obj ){ | 57 | static ToDoEvent eventByVObj( VObject *obj ){ |
58 | ToDoEvent event; | 58 | ToDoEvent event; |
59 | VObject *ob; | 59 | VObject *ob; |
60 | QCString name; | 60 | QCString name; |
61 | // no uid, attendees, ... and no fun | 61 | // no uid, attendees, ... and no fun |
62 | // description | 62 | // description |
63 | if( ( ob = isAPropertyOf( obj, VCDescriptionProp )) != 0 ){ | 63 | if( ( ob = isAPropertyOf( obj, VCDescriptionProp )) != 0 ){ |
64 | name = vObjectStringZValue( ob ); | 64 | name = vObjectStringZValue( ob ); |
65 | event.setDescription( name ); | 65 | event.setDescription( name ); |
66 | } | 66 | } |
67 | // summary | ||
68 | if ( ( ob = isAPropertyOf( obj, VCSummaryProp ) ) != 0 ) { | ||
69 | name = vObjectStringZValue( ob ); | ||
70 | event.setSummary( name ); | ||
71 | } | ||
67 | // completed | 72 | // completed |
68 | if( ( ob = isAPropertyOf( obj, VCStatusProp )) != 0 ){ | 73 | if( ( ob = isAPropertyOf( obj, VCStatusProp )) != 0 ){ |
69 | name = vObjectStringZValue( ob ); | 74 | name = vObjectStringZValue( ob ); |
70 | if( name == "COMPLETED" ){ | 75 | if( name == "COMPLETED" ){ |
71 | event.setCompleted( true ); | 76 | event.setCompleted( true ); |
72 | }else{ | 77 | }else{ |
73 | event.setCompleted( false ); | 78 | event.setCompleted( false ); |
74 | } | 79 | } |
75 | }else | 80 | }else |
76 | event.setCompleted( false ); | 81 | event.setCompleted( false ); |
77 | // priority | 82 | // priority |
78 | if ((ob = isAPropertyOf(obj, VCPriorityProp))) { | 83 | if ((ob = isAPropertyOf(obj, VCPriorityProp))) { |
79 | name = vObjectStringZValue( ob ); | 84 | name = vObjectStringZValue( ob ); |
80 | bool ok; | 85 | bool ok; |
81 | event.setPriority(name.toInt(&ok) ); | 86 | event.setPriority(name.toInt(&ok) ); |
82 | } | 87 | } |
83 | //due date | 88 | //due date |
84 | if((ob = isAPropertyOf(obj, VCDueProp)) ){ | 89 | if((ob = isAPropertyOf(obj, VCDueProp)) ){ |
85 | event.setHasDate( true ); | 90 | event.setHasDate( true ); |
86 | name = vObjectStringZValue( ob ); | 91 | name = vObjectStringZValue( ob ); |
87 | event.setDate( TimeConversion::fromISO8601( name).date() ); | 92 | event.setDate( TimeConversion::fromISO8601( name).date() ); |
88 | } | 93 | } |
89 | // categories | 94 | // categories |
90 | if((ob = isAPropertyOf( obj, VCCategoriesProp )) != 0 ){ | 95 | if((ob = isAPropertyOf( obj, VCCategoriesProp )) != 0 ){ |
91 | name = vObjectStringZValue( ob ); | 96 | name = vObjectStringZValue( ob ); |
92 | qWarning("Categories:%s", name.data() ); | 97 | qWarning("Categories:%s", name.data() ); |
93 | } | 98 | } |
94 | 99 | ||
95 | return event; | 100 | return event; |
96 | }; | 101 | }; |
97 | 102 | ||
98 | 103 | ||
99 | QValueList<ToDoEvent> ToDoVCalResource::load(const QString &file) | 104 | QValueList<ToDoEvent> ToDoVCalResource::load(const QString &file) |
100 | { | 105 | { |
101 | QValueList<ToDoEvent> events; | 106 | QValueList<ToDoEvent> events; |
102 | VObject *vcal = 0l; | 107 | VObject *vcal = 0l; |
103 | vcal = Parse_MIME_FromFileName( (char *)file.utf8().data() ); // from vobject | 108 | vcal = Parse_MIME_FromFileName( (char *)file.utf8().data() ); // from vobject |
104 | if(!vcal ) | 109 | if(!vcal ) |
105 | return events; | 110 | return events; |
106 | // start parsing | 111 | // start parsing |
107 | 112 | ||
108 | VObjectIterator it; | 113 | VObjectIterator it; |
109 | VObject *vobj; | 114 | VObject *vobj; |
110 | initPropIterator(&it, vcal); | 115 | initPropIterator(&it, vcal); |
111 | 116 | ||
112 | while( moreIteration( &it ) ) { | 117 | while( moreIteration( &it ) ) { |
113 | vobj = ::nextVObject( &it ); | 118 | vobj = ::nextVObject( &it ); |
114 | QCString name = ::vObjectName( vobj ); | 119 | QCString name = ::vObjectName( vobj ); |
115 | //QCString objVal = ::vObjectStringZValue( vobj ); | 120 | //QCString objVal = ::vObjectStringZValue( vobj ); |
116 | // let's find out the type | 121 | // let's find out the type |
117 | if( name == VCTodoProp ){ | 122 | if( name == VCTodoProp ){ |
118 | events.append( eventByVObj( vobj ) ); | 123 | events.append( eventByVObj( vobj ) ); |
119 | 124 | ||
120 | } // parse the value | 125 | } // parse the value |
121 | } | 126 | } |
122 | return events; | 127 | return events; |
123 | } | 128 | } |
124 | bool ToDoVCalResource::save(const QString &fileName, const QValueList<ToDoEvent>&list ) | 129 | bool ToDoVCalResource::save(const QString &fileName, const QValueList<ToDoEvent>&list ) |
125 | { | 130 | { |
126 | QFileDirect file ( fileName ); | 131 | QFileDirect file ( fileName ); |
127 | if(!file.open(IO_WriteOnly ) ) | 132 | if(!file.open(IO_WriteOnly ) ) |
128 | return false; | 133 | return false; |
129 | // obj | 134 | // obj |
130 | VObject *obj; | 135 | VObject *obj; |
131 | obj = newVObject( VCCalProp ); | 136 | obj = newVObject( VCCalProp ); |
132 | addPropValue( obj, VCVersionProp, "1.0" ); | 137 | addPropValue( obj, VCVersionProp, "1.0" ); |
133 | VObject *vo; | 138 | VObject *vo; |
134 | for(QValueList<ToDoEvent>::ConstIterator it = list.begin(); it != list.end(); ++it ){ | 139 | for(QValueList<ToDoEvent>::ConstIterator it = list.begin(); it != list.end(); ++it ){ |
135 | vo = vobjByEvent( (*it) ); | 140 | vo = vobjByEvent( (*it) ); |
136 | addVObjectProp(obj, vo ); | 141 | addVObjectProp(obj, vo ); |
137 | } | 142 | } |
138 | writeVObject( file.directHandle(), obj ); | 143 | writeVObject( file.directHandle(), obj ); |
139 | cleanVObject( obj ); | 144 | cleanVObject( obj ); |
140 | cleanStrTbl(); | 145 | cleanStrTbl(); |
141 | 146 | ||
142 | return true; | 147 | return true; |
143 | } | 148 | } |
144 | 149 | ||
145 | 150 | ||
146 | 151 | ||
147 | 152 | ||
148 | 153 | ||
149 | 154 | ||
150 | 155 | ||
151 | 156 | ||
152 | 157 | ||
153 | 158 | ||