author | zecke <zecke> | 2002-04-23 12:45:20 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-04-23 12:45:20 (UTC) |
commit | e25c5384f3f3025be64ed26d244c59afc5862711 (patch) (unidiff) | |
tree | 603f32b0550ecda9cbe95a93807a2a89b32cabcd | |
parent | 367304a610dd618ad45ddce8256ba4d7d8ded442 (diff) | |
download | opie-e25c5384f3f3025be64ed26d244c59afc5862711.zip opie-e25c5384f3f3025be64ed26d244c59afc5862711.tar.gz opie-e25c5384f3f3025be64ed26d244c59afc5862711.tar.bz2 |
Patch from Stefan Eilers for overview
merged by hand
-rw-r--r-- | core/pim/todo/TODO | 3 | ||||
-rw-r--r-- | core/pim/todo/mainwindow.cpp | 68 | ||||
-rw-r--r-- | core/pim/todo/mainwindow.h | 16 | ||||
-rw-r--r-- | core/pim/todo/opie-todo.control | 2 | ||||
-rw-r--r-- | core/pim/todo/todo.pro | 6 | ||||
-rw-r--r-- | core/pim/todo/todolabel.cc | 58 | ||||
-rw-r--r-- | core/pim/todo/todolabel.h | 51 | ||||
-rw-r--r-- | core/pim/todo/todotable.cpp | 24 | ||||
-rw-r--r-- | core/pim/todo/todotable.h | 2 |
9 files changed, 202 insertions, 28 deletions
diff --git a/core/pim/todo/TODO b/core/pim/todo/TODO index 7601dd2..b00450c 100644 --- a/core/pim/todo/TODO +++ b/core/pim/todo/TODO | |||
@@ -1,4 +1 @@ | |||
1 | -fix the journal (wip ) | ||
2 | -fix day wrapping update all DueDateItems | ||
3 | -when checking the C. box update the deadline | -when checking the C. box update the deadline | |
4 | -TodoLabel : public TextView | ||
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp index fc17c5f..d3f4cb4 100644 --- a/core/pim/todo/mainwindow.cpp +++ b/core/pim/todo/mainwindow.cpp | |||
@@ -1,571 +1,621 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | Copyright (C) 2002 zecke | 3 | ** Copyright (C) 2002 zecke |
4 | Copyright (C) 2002 Stefan Eilers | 4 | ** Copyright (C) 2002 Stefan Eilers (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 | 29 | ||
29 | #include <opie/tododb.h> | 30 | #include <opie/tododb.h> |
30 | #include <opie/todovcalresource.h> | 31 | #include <opie/todovcalresource.h> |
31 | #include <opie/ofontmenu.h> | 32 | #include <opie/ofontmenu.h> |
32 | 33 | ||
33 | #include <qpe/qpeapplication.h> | 34 | #include <qpe/qpeapplication.h> |
34 | #include <qpe/config.h> | 35 | #include <qpe/config.h> |
35 | #include <qpe/finddialog.h> | 36 | #include <qpe/finddialog.h> |
36 | #include <qpe/global.h> | 37 | #include <qpe/global.h> |
37 | #include <qpe/ir.h> | 38 | #include <qpe/ir.h> |
38 | #include <qpe/qpemenubar.h> | 39 | #include <qpe/qpemenubar.h> |
39 | #include <qpe/qpemessagebox.h> | 40 | #include <qpe/qpemessagebox.h> |
40 | #include <qpe/resource.h> | 41 | #include <qpe/resource.h> |
41 | //#include <qpe/task.h> | 42 | //#include <qpe/task.h> |
42 | #include <qpe/qpetoolbar.h> | 43 | #include <qpe/qpetoolbar.h> |
43 | 44 | ||
44 | #include <qaction.h> | 45 | #include <qaction.h> |
45 | #include <qarray.h> | 46 | #include <qarray.h> |
46 | #include <qdatastream.h> | 47 | #include <qdatastream.h> |
47 | #include <qdatetime.h> | 48 | #include <qdatetime.h> |
48 | #include <qfile.h> | 49 | #include <qfile.h> |
49 | #include <qmessagebox.h> | 50 | #include <qmessagebox.h> |
50 | #include <qpopupmenu.h> | 51 | #include <qpopupmenu.h> |
52 | #include <qwidgetstack.h> | ||
51 | 53 | ||
52 | #include <sys/stat.h> | 54 | #include <sys/stat.h> |
53 | #include <sys/types.h> | 55 | #include <sys/types.h> |
54 | #include <fcntl.h> | 56 | #include <fcntl.h> |
55 | #include <unistd.h> | 57 | #include <unistd.h> |
56 | 58 | ||
57 | #include <stdlib.h> | 59 | #include <stdlib.h> |
58 | 60 | ||
59 | static QString todolistXMLFilename() | 61 | static QString todolistXMLFilename() |
60 | { | 62 | { |
61 | return Global::applicationFileName("todolist","todolist.xml"); | 63 | return Global::applicationFileName("todolist","todolist.xml"); |
62 | } | 64 | } |
63 | 65 | ||
64 | static QString categoriesXMLFilename() | 66 | static QString categoriesXMLFilename() |
65 | { | 67 | { |
66 | return Global::applicationFileName("todolist","categories.xml"); | 68 | return Global::applicationFileName("todolist","categories.xml"); |
67 | } | 69 | } |
68 | 70 | ||
69 | TodoWindow::TodoWindow( QWidget *parent, const char *name, WFlags f = 0 ) : | 71 | TodoWindow::TodoWindow( QWidget *parent, const char *name, WFlags f = 0 ) : |
70 | QMainWindow( parent, name, f ), syncing(FALSE) | 72 | QMainWindow( parent, name, f ), syncing(FALSE) |
71 | { | 73 | { |
72 | // QTime t; | 74 | // QTime t; |
73 | // t.start(); | 75 | // t.start(); |
74 | 76 | mView = 0l; | |
77 | mStack = new QWidgetStack(this, "main stack"); | ||
75 | setCaption( tr("Todo") ); | 78 | setCaption( tr("Todo") ); |
76 | QString str; | 79 | QString str; |
77 | table = new TodoTable( this ); | 80 | table = new TodoTable( this ); |
78 | table->setColumnWidth( 2, 10 ); | 81 | table->setColumnWidth( 2, 10 ); |
79 | table->setPaintingEnabled( FALSE ); | 82 | table->setPaintingEnabled( FALSE ); |
80 | table->setUpdatesEnabled( FALSE ); | 83 | table->setUpdatesEnabled( FALSE ); |
81 | table->viewport()->setUpdatesEnabled( FALSE ); | 84 | table->viewport()->setUpdatesEnabled( FALSE ); |
82 | 85 | ||
83 | { | 86 | { |
84 | str = todolistXMLFilename(); | 87 | str = todolistXMLFilename(); |
85 | if ( str.isNull() ) | 88 | if ( str.isNull() ) |
86 | QMessageBox::critical( this, | 89 | QMessageBox::critical( this, |
87 | tr("Out of Space"), | 90 | tr("Out of Space"), |
88 | tr("Unable to create startup files\n" | 91 | tr("Unable to create startup files\n" |
89 | "Free up some space\n" | 92 | "Free up some space\n" |
90 | "before you enter any data") ); | 93 | "before you enter any data") ); |
91 | else | 94 | else |
92 | table->load( str ); | 95 | table->load( str ); |
93 | } | 96 | } |
94 | 97 | ||
95 | // repeat for categories... | 98 | // repeat for categories... |
96 | str = categoriesXMLFilename(); | 99 | str = categoriesXMLFilename(); |
97 | if ( str.isNull() ) | 100 | if ( str.isNull() ) |
98 | QMessageBox::critical( this, | 101 | QMessageBox::critical( this, |
99 | tr( "Out of Space" ), | 102 | tr( "Out of Space" ), |
100 | tr( "Unable to create startup files\n" | 103 | tr( "Unable to create startup files\n" |
101 | "Free up some space\n" | 104 | "Free up some space\n" |
102 | "before you enter any data") ); | 105 | "before you enter any data") ); |
103 | 106 | ||
104 | setCentralWidget( table ); | 107 | mStack->addWidget(table, 1 ); |
108 | mStack->raiseWidget( 1 ); | ||
109 | setCentralWidget( mStack ); | ||
105 | setToolBarsMovable( FALSE ); | 110 | setToolBarsMovable( FALSE ); |
106 | 111 | ||
107 | // qDebug("after load: t=%d", t.elapsed() ); | 112 | // qDebug("after load: t=%d", t.elapsed() ); |
108 | 113 | ||
109 | Config config( "todo" ); | 114 | Config config( "todo" ); |
110 | config.setGroup( "View" ); | 115 | config.setGroup( "View" ); |
111 | bool complete = config.readBoolEntry( "ShowComplete", true ); | 116 | bool complete = config.readBoolEntry( "ShowComplete", true ); |
112 | table->setShowCompleted( complete ); | 117 | table->setShowCompleted( complete ); |
113 | 118 | ||
114 | bool showdeadline = config.readBoolEntry("ShowDeadLine", true); | 119 | bool showdeadline = config.readBoolEntry("ShowDeadLine", true); |
115 | table->setShowDeadline (showdeadline); | 120 | table->setShowDeadline (showdeadline); |
116 | 121 | ||
117 | QString category = config.readEntry( "Category", QString::null ); | 122 | QString category = config.readEntry( "Category", QString::null ); |
118 | table->setShowCategory( category ); | 123 | table->setShowCategory( category ); |
119 | 124 | ||
120 | QPEToolBar *bar = new QPEToolBar( this ); | 125 | QPEToolBar *bar = new QPEToolBar( this ); |
121 | bar->setHorizontalStretchable( TRUE ); | 126 | bar->setHorizontalStretchable( TRUE ); |
122 | 127 | ||
123 | QPEMenuBar *mb = new QPEMenuBar( bar ); | 128 | QPEMenuBar *mb = new QPEMenuBar( bar ); |
124 | 129 | ||
125 | catMenu = new QPopupMenu( this ); | 130 | catMenu = new QPopupMenu( this ); |
126 | QPopupMenu *edit = new QPopupMenu( this ); | 131 | QPopupMenu *edit = new QPopupMenu( this ); |
127 | QPopupMenu *options = new QPopupMenu(this ); | 132 | QPopupMenu *options = new QPopupMenu(this ); |
128 | 133 | ||
129 | contextMenu = new QPopupMenu( this ); | 134 | contextMenu = new QPopupMenu( this ); |
130 | 135 | ||
131 | bar = new QPEToolBar( this ); | 136 | bar = new QPEToolBar( this ); |
132 | 137 | ||
133 | QAction *a = new QAction( tr( "New Task" ), Resource::loadPixmap( "new" ), | 138 | QAction *a = new QAction( tr( "New Task" ), Resource::loadPixmap( "new" ), |
134 | QString::null, 0, this, 0 ); | 139 | QString::null, 0, this, 0 ); |
135 | connect( a, SIGNAL( activated() ), | 140 | connect( a, SIGNAL( activated() ), |
136 | this, SLOT( slotNew() ) ); | 141 | this, SLOT( slotNew() ) ); |
137 | a->addTo( bar ); | 142 | a->addTo( bar ); |
138 | a->addTo( edit ); | 143 | a->addTo( edit ); |
139 | 144 | ||
140 | a = new QAction( tr( "Edit Task" ), Resource::loadIconSet( "edit" ), | 145 | a = new QAction( tr( "Edit Task" ), Resource::loadIconSet( "edit" ), |
141 | QString::null, 0, this, 0 ); | 146 | QString::null, 0, this, 0 ); |
142 | connect( a, SIGNAL( activated() ), | 147 | connect( a, SIGNAL( activated() ), |
143 | this, SLOT( slotEdit() ) ); | 148 | this, SLOT( slotEdit() ) ); |
144 | a->addTo( bar ); | 149 | a->addTo( bar ); |
145 | a->addTo( edit ); | 150 | a->addTo( edit ); |
146 | a->addTo( contextMenu ); | 151 | a->addTo( contextMenu ); |
147 | a->setEnabled( FALSE ); | 152 | a->setEnabled( FALSE ); |
148 | editAction = a; | 153 | editAction = a; |
154 | |||
155 | a = new QAction( QString::null, tr("View Task"), 0, this, 0 ); | ||
156 | a->addTo( edit ); | ||
157 | a->addTo( contextMenu ); | ||
158 | connect( a, SIGNAL( activated() ), | ||
159 | this, SLOT(slotShowDetails() ) ); | ||
160 | |||
149 | edit->insertSeparator(); | 161 | edit->insertSeparator(); |
150 | 162 | ||
151 | a = new QAction( tr( "Delete..." ), Resource::loadIconSet( "trash" ), | 163 | a = new QAction( tr( "Delete..." ), Resource::loadIconSet( "trash" ), |
152 | QString::null, 0, this, 0 ); | 164 | QString::null, 0, this, 0 ); |
153 | connect( a, SIGNAL( activated() ), | 165 | connect( a, SIGNAL( activated() ), |
154 | this, SLOT( slotDelete() ) ); | 166 | this, SLOT( slotDelete() ) ); |
155 | a->addTo( bar ); | 167 | a->addTo( bar ); |
156 | a->addTo( edit ); | 168 | a->addTo( edit ); |
157 | a->addTo( contextMenu ); | 169 | a->addTo( contextMenu ); |
158 | a->setEnabled( FALSE ); | 170 | a->setEnabled( FALSE ); |
159 | deleteAction = a; | 171 | deleteAction = a; |
160 | 172 | ||
161 | // delete All in category is missing.... | 173 | // delete All in category is missing.... |
162 | // set All Done | 174 | // set All Done |
163 | // set All Done in category | 175 | // set All Done in category |
164 | 176 | ||
165 | a = new QAction( QString::null, tr( "Delete all..."), 0, this, 0 ); | 177 | a = new QAction( QString::null, tr( "Delete all..."), 0, this, 0 ); |
166 | connect(a, SIGNAL( activated() ), | 178 | connect(a, SIGNAL( activated() ), |
167 | this, SLOT( slotDeleteAll() ) ); | 179 | this, SLOT( slotDeleteAll() ) ); |
168 | a->addTo(edit ); | 180 | a->addTo(edit ); |
169 | a->setEnabled( FALSE ); | 181 | a->setEnabled( FALSE ); |
170 | deleteAllAction = a; | 182 | deleteAllAction = a; |
171 | 183 | ||
172 | edit->insertSeparator(); | 184 | edit->insertSeparator(); |
173 | a = new QAction( QString::null, tr("Duplicate" ), 0, this, 0 ); | 185 | a = new QAction( QString::null, tr("Duplicate" ), 0, this, 0 ); |
174 | connect(a, SIGNAL( activated() ), | 186 | connect(a, SIGNAL( activated() ), |
175 | this, SLOT( slotDuplicate() ) ); | 187 | this, SLOT( slotDuplicate() ) ); |
176 | a->addTo(edit ); | 188 | a->addTo(edit ); |
177 | a->setEnabled( FALSE ); | 189 | a->setEnabled( FALSE ); |
178 | duplicateAction = a; | 190 | duplicateAction = a; |
179 | |||
180 | edit->insertSeparator(); | 191 | edit->insertSeparator(); |
192 | |||
193 | |||
194 | |||
181 | if ( Ir::supported() ) { | 195 | if ( Ir::supported() ) { |
182 | a = new QAction( tr( "Beam" ), Resource::loadPixmap( "beam" ), | 196 | a = new QAction( tr( "Beam" ), Resource::loadPixmap( "beam" ), |
183 | QString::null, 0, this, 0 ); | 197 | QString::null, 0, this, 0 ); |
184 | connect( a, SIGNAL( activated() ), | 198 | connect( a, SIGNAL( activated() ), |
185 | this, SLOT( slotBeam() ) ); | 199 | this, SLOT( slotBeam() ) ); |
186 | a->addTo( edit ); | 200 | a->addTo( edit ); |
187 | a->addTo( bar ); | 201 | a->addTo( bar ); |
188 | } | 202 | } |
189 | 203 | ||
190 | a = new QAction( tr( "Find" ), Resource::loadIconSet( "mag" ), | 204 | a = new QAction( tr( "Find" ), Resource::loadIconSet( "mag" ), |
191 | QString::null, 0, this, 0 ); | 205 | QString::null, 0, this, 0 ); |
192 | connect( a, SIGNAL( activated() ), | 206 | connect( a, SIGNAL( activated() ), |
193 | this, SLOT( slotFind() ) ); | 207 | this, SLOT( slotFind() ) ); |
194 | a->addTo( bar ); | 208 | a->addTo( bar ); |
195 | a->addTo( options ); | 209 | a->addTo( options ); |
196 | options->insertSeparator(); | 210 | options->insertSeparator(); |
197 | 211 | ||
198 | if ( table->numRows() ) | 212 | if ( table->numRows() ) |
199 | a->setEnabled( TRUE ); | 213 | a->setEnabled( TRUE ); |
200 | else | 214 | else |
201 | a->setEnabled( FALSE ); | 215 | a->setEnabled( FALSE ); |
202 | 216 | ||
203 | //a->setEnabled( FALSE ); | 217 | //a->setEnabled( FALSE ); |
204 | findAction = a; | 218 | findAction = a; |
205 | // qDebug("mainwindow #2: t=%d", t.elapsed() ); | 219 | // qDebug("mainwindow #2: t=%d", t.elapsed() ); |
206 | 220 | ||
207 | 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 ); |
208 | 222 | ||
209 | 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 ); |
210 | 224 | ||
211 | catMenu->setCheckable( true ); | 225 | catMenu->setCheckable( true ); |
212 | populateCategories(); | 226 | populateCategories(); |
213 | 227 | ||
214 | 228 | ||
215 | completedAction->addTo( options ); | 229 | completedAction->addTo( options ); |
216 | completedAction->setOn( table->showCompleted() ); | 230 | completedAction->setOn( table->showCompleted() ); |
217 | showdeadlineAction->addTo( options ); | 231 | showdeadlineAction->addTo( options ); |
218 | showdeadlineAction->setOn( table->showDeadline() ); | 232 | showdeadlineAction->setOn( table->showDeadline() ); |
219 | options->insertSeparator( ); | 233 | options->insertSeparator( ); |
220 | QList<QWidget> list; | 234 | QList<QWidget> list; |
221 | list.append(table ); | 235 | list.append(table ); |
222 | OFontMenu *menu = new OFontMenu(this, "menu",list ); | 236 | OFontMenu *menu = new OFontMenu(this, "menu",list ); |
223 | menu->forceSize( table->horizontalHeader(), 10 ); | 237 | menu->forceSize( table->horizontalHeader(), 10 ); |
224 | //catMenu->insertItem(tr("Fonts"), menu ); | 238 | //catMenu->insertItem(tr("Fonts"), menu ); |
225 | list.clear(); | 239 | list.clear(); |
226 | options->insertItem( tr("Fonts"), menu ); | 240 | options->insertItem( tr("Fonts"), menu ); |
227 | 241 | ||
228 | 242 | ||
229 | mb->insertItem( tr( "Data" ), edit ); | 243 | mb->insertItem( tr( "Data" ), edit ); |
230 | mb->insertItem( tr( "Category" ), catMenu ); | 244 | mb->insertItem( tr( "Category" ), catMenu ); |
231 | mb->insertItem( tr( "Options"), options ); | 245 | mb->insertItem( tr( "Options"), options ); |
232 | resize( 200, 300 ); | 246 | resize( 200, 300 ); |
233 | if ( table->numRows() > 0 ) | 247 | if ( table->numRows() > 0 ) |
234 | currentEntryChanged( 0, 0 ); | 248 | currentEntryChanged( 0, 0 ); |
235 | connect( table, SIGNAL( signalEdit() ), | 249 | connect( table, SIGNAL( signalEdit() ), |
236 | this, SLOT( slotEdit() ) ); | 250 | this, SLOT( slotEdit() ) ); |
237 | connect( table, SIGNAL(signalShowMenu(const QPoint &)), | 251 | connect( table, SIGNAL(signalShowMenu(const QPoint &)), |
238 | this, SLOT( slotShowPopup(const QPoint &)) ); | 252 | this, SLOT( slotShowPopup(const QPoint &)) ); |
239 | 253 | ||
240 | // qDebug("mainwindow #3: t=%d", t.elapsed() ); | 254 | // qDebug("mainwindow #3: t=%d", t.elapsed() ); |
241 | table->updateVisible(); | 255 | table->updateVisible(); |
242 | table->setUpdatesEnabled( TRUE ); | 256 | table->setUpdatesEnabled( TRUE ); |
243 | table->setPaintingEnabled( TRUE ); | 257 | table->setPaintingEnabled( TRUE ); |
244 | table->viewport()->setUpdatesEnabled( TRUE ); | 258 | table->viewport()->setUpdatesEnabled( TRUE ); |
245 | 259 | ||
246 | connect( completedAction, SIGNAL( toggled(bool) ), this, SLOT( showCompleted(bool) ) ); | 260 | connect( completedAction, SIGNAL( toggled(bool) ), this, SLOT( showCompleted(bool) ) ); |
247 | connect( showdeadlineAction, SIGNAL( toggled(bool) ), this, SLOT( showDeadline(bool) ) ); | 261 | connect( showdeadlineAction, SIGNAL( toggled(bool) ), this, SLOT( showDeadline(bool) ) ); |
248 | connect( catMenu, SIGNAL(activated(int)), this, SLOT(setCategory(int)) ); | 262 | connect( catMenu, SIGNAL(activated(int)), this, SLOT(setCategory(int)) ); |
249 | connect( table, SIGNAL( currentChanged( int, int ) ), | 263 | connect( table, SIGNAL( currentChanged( int, int ) ), |
250 | this, SLOT( currentEntryChanged( int, int ) ) ); | 264 | this, SLOT( currentEntryChanged( int, int ) ) ); |
251 | 265 | ||
266 | connect( table, SIGNAL(showDetails(const ToDoEvent &) ), | ||
267 | this, SLOT(slotShowDetails(const ToDoEvent & ) ) ); | ||
252 | // qDebug("done: t=%d", t.elapsed() ); | 268 | // qDebug("done: t=%d", t.elapsed() ); |
253 | } | 269 | } |
254 | 270 | ||
255 | void TodoWindow::slotNew() | 271 | void TodoWindow::slotNew() |
256 | { | 272 | { |
257 | if(syncing) { | 273 | if(syncing) { |
258 | QMessageBox::warning(this, tr("Todo"), | 274 | QMessageBox::warning(this, tr("Todo"), |
259 | tr("Can not edit data, currently syncing")); | 275 | tr("Can not edit data, currently syncing")); |
260 | return; | 276 | return; |
261 | } | 277 | } |
262 | 278 | ||
263 | int id; | 279 | int id; |
264 | id = -1; | 280 | id = -1; |
265 | QArray<int> ids; | 281 | QArray<int> ids; |
266 | ids = table->currentEntry().categories(); | 282 | ids = table->currentEntry().categories(); |
267 | if ( ids.count() ) | 283 | if ( ids.count() ) |
268 | id = ids[0]; | 284 | id = ids[0]; |
269 | NewTaskDialog e( id, this, 0, TRUE ); | 285 | NewTaskDialog e( id, this, 0, TRUE ); |
270 | 286 | ||
271 | ToDoEvent todo; | 287 | ToDoEvent todo; |
272 | 288 | ||
273 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 289 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
274 | e.showMaximized(); | 290 | e.showMaximized(); |
275 | #endif | 291 | #endif |
276 | int ret = e.exec(); | 292 | int ret = e.exec(); |
277 | // qWarning("finished" ); | 293 | // qWarning("finished" ); |
278 | if ( ret == QDialog::Accepted ) { | 294 | if ( ret == QDialog::Accepted ) { |
279 | table->setPaintingEnabled( false ); | 295 | table->setPaintingEnabled( false ); |
280 | todo = e.todoEntry(); | 296 | todo = e.todoEntry(); |
281 | //todo.assignUid(); | 297 | //todo.assignUid(); |
282 | table->addEntry( todo ); | 298 | table->addEntry( todo ); |
283 | table->setPaintingEnabled( true ); | 299 | table->setPaintingEnabled( true ); |
284 | findAction->setEnabled( TRUE ); | 300 | findAction->setEnabled( TRUE ); |
285 | } | 301 | } |
286 | // I'm afraid we must call this every time now, otherwise | 302 | // I'm afraid we must call this every time now, otherwise |
287 | // spend expensive time comparing all these strings... | 303 | // spend expensive time comparing all these strings... |
288 | populateCategories(); | 304 | populateCategories(); |
305 | mStack->raiseWidget(1 ); | ||
289 | } | 306 | } |
290 | 307 | ||
291 | TodoWindow::~TodoWindow() | 308 | TodoWindow::~TodoWindow() |
292 | { | 309 | { |
293 | } | 310 | } |
294 | 311 | ||
295 | void TodoWindow::slotDelete() | 312 | void TodoWindow::slotDelete() |
296 | { | 313 | { |
297 | if(syncing) { | 314 | if(syncing) { |
298 | QMessageBox::warning(this, tr("Todo"), | 315 | QMessageBox::warning(this, tr("Todo"), |
299 | tr("Can not edit data, currently syncing")); | 316 | tr("Can not edit data, currently syncing")); |
300 | return; | 317 | return; |
301 | } | 318 | } |
302 | 319 | ||
303 | if ( table->currentRow() == -1 ) | 320 | if ( table->currentRow() == -1 ) |
304 | return; | 321 | return; |
305 | 322 | ||
306 | QString strName = table->text( table->currentRow(), 2 ).left( 30 ); | 323 | QString strName = table->text( table->currentRow(), 2 ).left( 30 ); |
307 | 324 | ||
308 | if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), strName ) ) | 325 | if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), strName ) ) |
309 | return; | 326 | return; |
310 | 327 | ||
311 | 328 | ||
312 | 329 | ||
313 | table->setPaintingEnabled( false ); | 330 | table->setPaintingEnabled( false ); |
314 | table->removeCurrentEntry(); | 331 | table->removeCurrentEntry(); |
315 | table->setPaintingEnabled( true ); | 332 | table->setPaintingEnabled( true ); |
316 | 333 | ||
317 | if ( table->numRows() == 0 ) { | 334 | if ( table->numRows() == 0 ) { |
318 | currentEntryChanged( -1, 0 ); | 335 | currentEntryChanged( -1, 0 ); |
319 | findAction->setEnabled( FALSE ); | 336 | findAction->setEnabled( FALSE ); |
320 | } | 337 | } |
338 | mStack->raiseWidget(1); | ||
321 | } | 339 | } |
322 | void TodoWindow::slotDeleteAll() | 340 | void TodoWindow::slotDeleteAll() |
323 | { | 341 | { |
324 | if(syncing) { | 342 | if(syncing) { |
325 | QMessageBox::warning(this, tr("Todo"), | 343 | QMessageBox::warning(this, tr("Todo"), |
326 | tr("Can not edit data, currently syncing")); | 344 | tr("Can not edit data, currently syncing")); |
327 | return; | 345 | return; |
328 | } | 346 | } |
329 | 347 | ||
330 | //QString strName = table->text( table->currentRow(), 2 ).left( 30 ); | 348 | //QString strName = table->text( table->currentRow(), 2 ).left( 30 ); |
331 | 349 | ||
332 | if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("Should I delete all tasks?") ) ) | 350 | if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("Delete all tasks?") ) ) |
333 | return; | 351 | return; |
334 | 352 | ||
335 | 353 | ||
336 | 354 | ||
337 | table->setPaintingEnabled( false ); | 355 | table->setPaintingEnabled( false ); |
338 | table->removeAllEntries(); | 356 | table->removeAllEntries(); |
339 | table->setPaintingEnabled( true ); | 357 | table->setPaintingEnabled( true ); |
340 | 358 | ||
341 | if ( table->numRows() == 0 ) { | 359 | if ( table->numRows() == 0 ) { |
342 | currentEntryChanged( -1, 0 ); | 360 | currentEntryChanged( -1, 0 ); |
343 | findAction->setEnabled( FALSE ); | 361 | findAction->setEnabled( FALSE ); |
344 | } | 362 | } |
363 | mStack->raiseWidget(1 ); | ||
345 | } | 364 | } |
346 | 365 | ||
347 | void TodoWindow::slotEdit() | 366 | void TodoWindow::slotEdit() |
348 | { | 367 | { |
349 | if(syncing) { | 368 | if(syncing) { |
350 | QMessageBox::warning(this, tr("Todo"), | 369 | QMessageBox::warning(this, tr("Todo"), |
351 | tr("Can not edit data, currently syncing")); | 370 | tr("Can not edit data, currently syncing")); |
352 | return; | 371 | return; |
353 | } | 372 | } |
354 | 373 | ||
355 | ToDoEvent todo = table->currentEntry(); | 374 | ToDoEvent todo = table->currentEntry(); |
356 | 375 | ||
357 | NewTaskDialog e( todo, this, 0, TRUE ); | 376 | NewTaskDialog e( todo, this, 0, TRUE ); |
358 | e.setCaption( tr( "Edit Task" ) ); | 377 | e.setCaption( tr( "Edit Task" ) ); |
359 | 378 | ||
360 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 379 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
361 | e.showMaximized(); | 380 | e.showMaximized(); |
362 | #endif | 381 | #endif |
363 | int ret = e.exec(); | 382 | int ret = e.exec(); |
364 | 383 | ||
365 | if ( ret == QDialog::Accepted ) { | 384 | if ( ret == QDialog::Accepted ) { |
366 | table->setPaintingEnabled( false ); | 385 | table->setPaintingEnabled( false ); |
367 | todo = e.todoEntry(); | 386 | todo = e.todoEntry(); |
368 | table->replaceCurrentEntry( todo ); | 387 | table->replaceCurrentEntry( todo ); |
369 | table->setPaintingEnabled( true ); | 388 | table->setPaintingEnabled( true ); |
370 | } | 389 | } |
371 | populateCategories(); | 390 | populateCategories(); |
372 | 391 | mStack->raiseWidget( 1 ); | |
373 | } | 392 | } |
374 | void TodoWindow::slotDuplicate() | 393 | void TodoWindow::slotDuplicate() |
375 | { | 394 | { |
376 | if(syncing) { | 395 | if(syncing) { |
377 | QMessageBox::warning(this, tr("Todo"), | 396 | QMessageBox::warning(this, tr("Todo"), |
378 | tr("Can not edit data, currently syncing")); | 397 | tr("Can not edit data, currently syncing")); |
379 | return; | 398 | return; |
380 | } | 399 | } |
381 | ToDoEvent ev = table->currentEntry(); | 400 | ToDoEvent ev = table->currentEntry(); |
382 | ToDoEvent ev2 = ToDoEvent( ev ); | 401 | ToDoEvent ev2 = ToDoEvent( ev ); // what about the uid |
402 | int uid; | ||
403 | { // uid | ||
404 | Qtopia::UidGen *uidgen = new Qtopia::UidGen(); | ||
405 | uid = uidgen->generate(); | ||
406 | delete uidgen; | ||
407 | } | ||
408 | ev2.setUid( uid ); | ||
383 | table->setPaintingEnabled( false ); | 409 | table->setPaintingEnabled( false ); |
384 | table->addEntry( ev2 ); | 410 | table->addEntry( ev2 ); |
385 | table->setPaintingEnabled( true ); | 411 | table->setPaintingEnabled( true ); |
412 | |||
413 | mStack->raiseWidget( 1 ); | ||
386 | } | 414 | } |
387 | void TodoWindow::slotShowPopup( const QPoint &p ) | 415 | void TodoWindow::slotShowPopup( const QPoint &p ) |
388 | { | 416 | { |
389 | contextMenu->popup( p ); | 417 | contextMenu->popup( p ); |
390 | } | 418 | } |
391 | 419 | ||
392 | void TodoWindow::showCompleted( bool s ) | 420 | void TodoWindow::showCompleted( bool s ) |
393 | { | 421 | { |
394 | if ( !table->isUpdatesEnabled() ) | 422 | if ( !table->isUpdatesEnabled() ) |
395 | return; | 423 | return; |
396 | table->setPaintingEnabled( false ); | 424 | table->setPaintingEnabled( false ); |
397 | table->setShowCompleted( s ); | 425 | table->setShowCompleted( s ); |
398 | table->setPaintingEnabled( true ); | 426 | table->setPaintingEnabled( true ); |
399 | } | 427 | } |
400 | 428 | ||
401 | void TodoWindow::currentEntryChanged( int r, int ) | 429 | void TodoWindow::currentEntryChanged( int r, int ) |
402 | { | 430 | { |
403 | if ( r != -1 && table->rowHeight( r ) > 0 ) { | 431 | if ( r != -1 && table->rowHeight( r ) > 0 ) { |
404 | editAction->setEnabled( TRUE ); | 432 | editAction->setEnabled( TRUE ); |
405 | deleteAction->setEnabled( TRUE ); | 433 | deleteAction->setEnabled( TRUE ); |
406 | duplicateAction->setEnabled( TRUE ); | 434 | duplicateAction->setEnabled( TRUE ); |
407 | deleteAllAction->setEnabled( TRUE ); | 435 | deleteAllAction->setEnabled( TRUE ); |
408 | } else { | 436 | } else { |
409 | editAction->setEnabled( FALSE ); | 437 | editAction->setEnabled( FALSE ); |
410 | deleteAction->setEnabled( FALSE ); | 438 | deleteAction->setEnabled( FALSE ); |
411 | duplicateAction->setEnabled( FALSE ); | 439 | duplicateAction->setEnabled( FALSE ); |
412 | deleteAllAction->setEnabled( FALSE ); | 440 | deleteAllAction->setEnabled( FALSE ); |
413 | } | 441 | } |
414 | } | 442 | } |
415 | 443 | ||
416 | void TodoWindow::setCategory( int c ) | 444 | void TodoWindow::setCategory( int c ) |
417 | { | 445 | { |
418 | if ( c <= 0 ) return; | 446 | if ( c <= 0 ) return; |
419 | if ( !table->isUpdatesEnabled() ) | 447 | if ( !table->isUpdatesEnabled() ) |
420 | return; | 448 | return; |
421 | table->setPaintingEnabled( false ); | 449 | table->setPaintingEnabled( false ); |
422 | for ( unsigned int i = 1; i < catMenu->count(); i++ ) | 450 | for ( unsigned int i = 1; i < catMenu->count(); i++ ) |
423 | catMenu->setItemChecked( i, c == (int)i ); | 451 | catMenu->setItemChecked( i, c == (int)i ); |
424 | if ( c == 1 ) { | 452 | if ( c == 1 ) { |
425 | table->setShowCategory( QString::null ); | 453 | table->setShowCategory( QString::null ); |
426 | setCaption( tr("Todo") + " - " + tr( "All Categories" ) ); | 454 | setCaption( tr("Todo") + " - " + tr( "All Categories" ) ); |
427 | } else if ( c == (int)catMenu->count() - 1 ) { | 455 | } else if ( c == (int)catMenu->count() - 1 ) { |
428 | table->setShowCategory( tr( "Unfiled" ) ); | 456 | table->setShowCategory( tr( "Unfiled" ) ); |
429 | setCaption( tr("Todo") + " - " + tr( "Unfiled" ) ); | 457 | setCaption( tr("Todo") + " - " + tr( "Unfiled" ) ); |
430 | } else { | 458 | } else { |
431 | QString cat = table->categories()[c - 2]; | 459 | QString cat = table->categories()[c - 2]; |
432 | table->setShowCategory( cat ); | 460 | table->setShowCategory( cat ); |
433 | setCaption( tr("Todo") + " - " + cat ); | 461 | setCaption( tr("Todo") + " - " + cat ); |
434 | } | 462 | } |
435 | table->setPaintingEnabled( true ); | 463 | table->setPaintingEnabled( true ); |
464 | |||
465 | mStack->raiseWidget( 1 ); | ||
436 | } | 466 | } |
437 | 467 | ||
438 | void TodoWindow::populateCategories() | 468 | void TodoWindow::populateCategories() |
439 | { | 469 | { |
440 | catMenu->clear(); | 470 | catMenu->clear(); |
441 | int id, rememberId; | 471 | int id, rememberId; |
442 | id = 1; | 472 | id = 1; |
473 | rememberId = 0; | ||
443 | catMenu->insertItem( tr( "All Categories" ), id++ ); | 474 | catMenu->insertItem( tr( "All Categories" ), id++ ); |
444 | catMenu->insertSeparator(); | 475 | catMenu->insertSeparator(); |
445 | QStringList categories = table->categories(); | 476 | QStringList categories = table->categories(); |
446 | categories.append( tr( "Unfiled" ) ); | 477 | categories.append( tr( "Unfiled" ) ); |
447 | for ( QStringList::Iterator it = categories.begin(); | 478 | for ( QStringList::Iterator it = categories.begin(); |
448 | it != categories.end(); ++it ) { | 479 | it != categories.end(); ++it ) { |
449 | catMenu->insertItem( *it, id ); | 480 | catMenu->insertItem( *it, id ); |
450 | if ( *it == table->showCategory() ) | 481 | if ( *it == table->showCategory() ) |
451 | rememberId = id; | 482 | rememberId = id; |
452 | ++id; | 483 | ++id; |
453 | } | 484 | } |
454 | if ( table->showCategory().isEmpty() ) | 485 | if ( table->showCategory().isEmpty() ) |
455 | setCategory( 1 ); | 486 | setCategory( 1 ); |
456 | else | 487 | else |
457 | setCategory( rememberId ); | 488 | setCategory( rememberId ); |
458 | } | 489 | } |
459 | 490 | ||
460 | void TodoWindow::reload() | 491 | void TodoWindow::reload() |
461 | { | 492 | { |
462 | table->clear(); | 493 | table->clear(); |
463 | table->load( todolistXMLFilename() ); | 494 | table->load( todolistXMLFilename() ); |
464 | syncing = FALSE; | 495 | syncing = FALSE; |
465 | } | 496 | } |
466 | 497 | ||
467 | void TodoWindow::flush() | 498 | void TodoWindow::flush() |
468 | { | 499 | { |
469 | syncing = TRUE; | 500 | syncing = TRUE; |
470 | table->save( todolistXMLFilename() ); | 501 | table->save( todolistXMLFilename() ); |
471 | } | 502 | } |
472 | 503 | ||
473 | void TodoWindow::closeEvent( QCloseEvent *e ) | 504 | void TodoWindow::closeEvent( QCloseEvent *e ) |
474 | { | 505 | { |
506 | if( mStack->visibleWidget() != table ){ | ||
507 | mStack->raiseWidget( 1 ); | ||
508 | e->ignore(); | ||
509 | return; | ||
510 | } | ||
475 | if(syncing) { | 511 | if(syncing) { |
476 | /* no need to save if in the middle of syncing */ | 512 | /* no need to save if in the middle of syncing */ |
477 | e->accept(); | 513 | e->accept(); |
478 | return; | 514 | return; |
479 | } | 515 | } |
480 | 516 | ||
481 | if ( table->save( todolistXMLFilename() ) ) { | 517 | if ( table->save( todolistXMLFilename() ) ) { |
482 | e->accept(); | 518 | e->accept(); |
483 | // repeat for categories... | 519 | // repeat for categories... |
484 | // if writing configs fail, it will emit an | 520 | // if writing configs fail, it will emit an |
485 | // error, but I feel that it is "ok" for us to exit | 521 | // error, but I feel that it is "ok" for us to exit |
486 | // espically since we aren't told if the write succeeded... | 522 | // espically since we aren't told if the write succeeded... |
487 | Config config( "todo" ); | 523 | Config config( "todo" ); |
488 | config.setGroup( "View" ); | 524 | config.setGroup( "View" ); |
489 | config.writeEntry( "ShowComplete", table->showCompleted() ); | 525 | config.writeEntry( "ShowComplete", table->showCompleted() ); |
490 | config.writeEntry( "Category", table->showCategory() ); | 526 | config.writeEntry( "Category", table->showCategory() ); |
491 | /* added 20.01.2k2 by se */ | 527 | /* added 20.01.2k2 by se */ |
492 | config.writeEntry( "ShowDeadLine", table->showDeadline()); | 528 | config.writeEntry( "ShowDeadLine", table->showDeadline()); |
493 | } else { | 529 | } else { |
494 | if ( QMessageBox::critical( this, tr("Out of space"), | 530 | if ( QMessageBox::critical( this, tr("Out of space"), |
495 | tr("Todo was unable\n" | 531 | tr("Todo was unable\n" |
496 | "to save your changes.\n" | 532 | "to save your changes.\n" |
497 | "Free up some space\n" | 533 | "Free up some space\n" |
498 | "and try again.\n" | 534 | "and try again.\n" |
499 | "\nQuit Anyway?"), | 535 | "\nQuit Anyway?"), |
500 | QMessageBox::Yes|QMessageBox::Escape, | 536 | QMessageBox::Yes|QMessageBox::Escape, |
501 | QMessageBox::No|QMessageBox::Default) | 537 | QMessageBox::No|QMessageBox::Default) |
502 | != QMessageBox::No ) | 538 | != QMessageBox::No ) |
503 | e->accept(); | 539 | e->accept(); |
504 | else | 540 | else |
505 | e->ignore(); | 541 | e->ignore(); |
506 | } | 542 | } |
507 | } | 543 | } |
508 | 544 | ||
509 | void TodoWindow::slotFind() | 545 | void TodoWindow::slotFind() |
510 | { | 546 | { |
511 | // put everything back to view all for searching... | 547 | // put everything back to view all for searching... |
512 | if ( !catMenu->isItemChecked( 0 ) ) | 548 | if ( !catMenu->isItemChecked( 0 ) ) |
513 | setCategory( 0 ); | 549 | setCategory( 0 ); |
514 | 550 | ||
515 | FindDialog dlg( "Todo List", this ); | 551 | FindDialog dlg( "Todo List", this ); |
516 | QObject::connect( &dlg, | 552 | QObject::connect( &dlg, |
517 | SIGNAL(signalFindClicked(const QString &, | 553 | SIGNAL(signalFindClicked(const QString &, |
518 | bool, bool, int)), | 554 | bool, bool, int)), |
519 | table, | 555 | table, |
520 | SLOT(slotDoFind(const QString&, bool, bool, int)) ); | 556 | SLOT(slotDoFind(const QString&, bool, bool, int)) ); |
521 | QObject::connect( table, SIGNAL(signalNotFound()), &dlg, | 557 | QObject::connect( table, SIGNAL(signalNotFound()), &dlg, |
522 | SLOT(slotNotFound()) ); | 558 | SLOT(slotNotFound()) ); |
523 | QObject::connect( table, SIGNAL(signalWrapAround()), &dlg, | 559 | QObject::connect( table, SIGNAL(signalWrapAround()), &dlg, |
524 | SLOT(slotWrapAround()) ); | 560 | SLOT(slotWrapAround()) ); |
525 | dlg.exec(); | 561 | dlg.exec(); |
526 | if ( table->numSelections() ) | 562 | if ( table->numSelections() ) |
527 | table->clearSelection(); | 563 | table->clearSelection(); |
528 | table->clearFindRow(); | 564 | table->clearFindRow(); |
529 | } | 565 | } |
530 | 566 | ||
531 | 567 | ||
532 | void TodoWindow::setDocument( const QString &filename ) | 568 | void TodoWindow::setDocument( const QString &filename ) |
533 | { | 569 | { |
534 | if ( filename.find(".vcs") != int(filename.length()) - 4 ) return; | 570 | if ( filename.find(".vcs") != int(filename.length()) - 4 ) return; |
535 | 571 | ||
536 | ToDoDB todoDB(filename, new ToDoVCalResource() ); | 572 | ToDoDB todoDB(filename, new ToDoVCalResource() ); |
537 | QValueList<ToDoEvent> tl = todoDB.rawToDos(); | 573 | QValueList<ToDoEvent> tl = todoDB.rawToDos(); |
538 | for( QValueList<ToDoEvent>::Iterator it = tl.begin(); it != tl.end(); ++it ) { | 574 | for( QValueList<ToDoEvent>::Iterator it = tl.begin(); it != tl.end(); ++it ) { |
539 | table->addEntry( *it ); | 575 | table->addEntry( *it ); |
540 | } | 576 | } |
541 | } | 577 | } |
542 | 578 | ||
543 | static const char * beamfile = "/tmp/obex/todo.vcs"; | 579 | static const char * beamfile = "/tmp/obex/todo.vcs"; |
544 | 580 | ||
545 | void TodoWindow::slotBeam() | 581 | void TodoWindow::slotBeam() |
546 | { | 582 | { |
547 | unlink( beamfile ); // delete if exists | 583 | unlink( beamfile ); // delete if exists |
548 | ToDoEvent c = table->currentEntry(); | 584 | ToDoEvent c = table->currentEntry(); |
549 | mkdir("/tmp/obex/", 0755); | 585 | mkdir("/tmp/obex/", 0755); |
550 | ToDoDB todoDB( beamfile, new ToDoVCalResource() ); | 586 | ToDoDB todoDB( beamfile, new ToDoVCalResource() ); |
551 | todoDB.addEvent( c ); | 587 | todoDB.addEvent( c ); |
552 | todoDB.save(); | 588 | todoDB.save(); |
553 | Ir *ir = new Ir( this ); | 589 | Ir *ir = new Ir( this ); |
554 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 590 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
555 | QString description = c.description(); | 591 | QString description = c.description(); |
556 | ir->send( beamfile, description, "text/x-vCalendar" ); | 592 | ir->send( beamfile, description, "text/x-vCalendar" ); |
557 | } | 593 | } |
558 | 594 | ||
559 | void TodoWindow::beamDone( Ir *ir ) | 595 | void TodoWindow::beamDone( Ir *ir ) |
560 | { | 596 | { |
561 | delete ir; | 597 | delete ir; |
562 | unlink( beamfile ); | 598 | unlink( beamfile ); |
563 | } | 599 | } |
564 | 600 | ||
565 | /* added 20.01.2k2 by se */ | ||
566 | void TodoWindow::showDeadline( bool s ) | 601 | void TodoWindow::showDeadline( bool s ) |
567 | { | 602 | { |
568 | table->setPaintingEnabled( false ); | 603 | table->setPaintingEnabled( false ); |
569 | table->setShowDeadline( s ); | 604 | table->setShowDeadline( s ); |
570 | table->setPaintingEnabled( true ); | 605 | table->setPaintingEnabled( true ); |
571 | } | 606 | } |
607 | void TodoWindow::slotShowDetails() | ||
608 | { | ||
609 | ToDoEvent event = table->currentEntry(); | ||
610 | slotShowDetails( event ); | ||
611 | } | ||
612 | void TodoWindow::slotShowDetails( const ToDoEvent &event ) | ||
613 | { | ||
614 | if( mView == 0l ){ | ||
615 | mView = new TodoLabel(mStack); | ||
616 | mStack->addWidget( mView, 2 ); | ||
617 | } | ||
618 | mView->init( event ); | ||
619 | mView->sync(); | ||
620 | mStack->raiseWidget( 2); | ||
621 | } | ||
diff --git a/core/pim/todo/mainwindow.h b/core/pim/todo/mainwindow.h index b9172e1..f62ec6e 100644 --- a/core/pim/todo/mainwindow.h +++ b/core/pim/todo/mainwindow.h | |||
@@ -1,86 +1,96 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | Copyright (C) 2002 Holger 'zecke' Freyther <freyther@kde.org> | 2 | ** Copyright (C) 2002 Holger 'zecke' Freyther <freyther@kde.org> |
3 | ** Copyright (C) 2002 by Stefan Eilers (se, eilers.stefan@epost.de) | ||
3 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 4 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
4 | ** | 5 | ** |
5 | ** This file is part of Qtopia and Opi Environment. | 6 | ** This file is part of Qtopia and Opi Environment. |
6 | ** | 7 | ** |
7 | ** 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 |
8 | ** 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 |
9 | ** Foundation and appearing in the file LICENSE.GPL included in the | 10 | ** Foundation and appearing in the file LICENSE.GPL included in the |
10 | ** packaging of this file. | 11 | ** packaging of this file. |
11 | ** | 12 | ** |
12 | ** 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 |
13 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 14 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
14 | ** | 15 | ** |
15 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 16 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
16 | ** | 17 | ** |
17 | ** Contact info@trolltech.com if any conditions of this licensing are | 18 | ** Contact info@trolltech.com if any conditions of this licensing are |
18 | ** not clear to you. | 19 | ** not clear to you. |
19 | ** | 20 | ** |
20 | **********************************************************************/ | 21 | **********************************************************************/ |
21 | 22 | ||
22 | #ifndef MAINWINDOW_H | 23 | #ifndef MAINWINDOW_H |
23 | #define MAINWINDOW_H | 24 | #define MAINWINDOW_H |
24 | 25 | ||
25 | #include <qmainwindow.h> | 26 | #include <qmainwindow.h> |
26 | 27 | ||
27 | class TodoTable; | 28 | class TodoTable; |
28 | class QAction; | 29 | class QAction; |
29 | class QPopupMenu; | 30 | class QPopupMenu; |
30 | class Ir; | 31 | class Ir; |
31 | class OFontMenu; | 32 | class OFontMenu; |
33 | class TodoLabel; | ||
34 | class ToDoDB; | ||
35 | class QWidgetStack; | ||
36 | class ToDoEvent; | ||
32 | 37 | ||
33 | class TodoWindow : public QMainWindow | 38 | class TodoWindow : public QMainWindow |
34 | { | 39 | { |
35 | Q_OBJECT | 40 | Q_OBJECT |
36 | 41 | ||
37 | public: | 42 | public: |
38 | TodoWindow( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); | 43 | TodoWindow( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); |
39 | ~TodoWindow(); | 44 | ~TodoWindow(); |
40 | 45 | ||
41 | public slots: | 46 | public slots: |
42 | void flush(); | 47 | void flush(); |
43 | void reload(); | 48 | void reload(); |
44 | 49 | ||
45 | protected slots: | 50 | protected slots: |
46 | void slotNew(); | 51 | void slotNew(); |
47 | void slotDelete(); | 52 | void slotDelete(); |
48 | void slotEdit(); | 53 | void slotEdit(); |
49 | void slotShowPopup( const QPoint & ); | 54 | void slotShowPopup( const QPoint & ); |
50 | void showCompleted( bool ); | 55 | void showCompleted( bool ); |
51 | 56 | ||
52 | /* added 20.01.2k2 by se */ | ||
53 | void showDeadline( bool ); | 57 | void showDeadline( bool ); |
54 | 58 | ||
59 | void slotShowDetails(const ToDoEvent &event ); | ||
60 | void slotShowDetails(); | ||
61 | |||
55 | void currentEntryChanged( int r, int c ); | 62 | void currentEntryChanged( int r, int c ); |
56 | void setCategory( int ); | 63 | void setCategory( int ); |
57 | void slotFind(); | 64 | void slotFind(); |
58 | void setDocument( const QString & ); | 65 | void setDocument( const QString & ); |
59 | void slotBeam(); | 66 | void slotBeam(); |
60 | void beamDone( Ir * ); | 67 | void beamDone( Ir * ); |
61 | void slotDeleteAll(); | 68 | void slotDeleteAll(); |
62 | void slotDuplicate(); | 69 | void slotDuplicate(); |
63 | 70 | ||
64 | protected: | 71 | protected: |
65 | void closeEvent( QCloseEvent *e ); | 72 | void closeEvent( QCloseEvent *e ); |
66 | 73 | ||
67 | private: | 74 | private: |
68 | void populateCategories(); | 75 | void populateCategories(); |
76 | //inline void switchToTable(); // move back to the normal view | ||
69 | 77 | ||
70 | private: | 78 | private: |
71 | TodoTable *table; | 79 | TodoTable *table; |
80 | TodoLabel *mView; | ||
72 | QAction *editAction, | 81 | QAction *editAction, |
73 | *deleteAction, | 82 | *deleteAction, |
74 | *findAction, | 83 | *findAction, |
75 | *completedAction, | 84 | *completedAction, |
76 | *showdeadlineAction, | 85 | *showdeadlineAction, |
77 | *deleteAllAction, | 86 | *deleteAllAction, |
78 | *duplicateAction; | 87 | *duplicateAction; |
79 | QPopupMenu *contextMenu, *catMenu; | 88 | QPopupMenu *contextMenu, *catMenu; |
89 | QWidgetStack *mStack; | ||
80 | 90 | ||
81 | bool syncing; | 91 | bool syncing; |
82 | }; | 92 | }; |
83 | 93 | ||
84 | #endif | 94 | #endif |
85 | 95 | ||
86 | 96 | ||
diff --git a/core/pim/todo/opie-todo.control b/core/pim/todo/opie-todo.control index cb9b110..71929af 100644 --- a/core/pim/todo/opie-todo.control +++ b/core/pim/todo/opie-todo.control | |||
@@ -1,9 +1,9 @@ | |||
1 | Files: bin/todolist apps/Applications/todo.desktop | 1 | Files: bin/todolist apps/Applications/todo.desktop |
2 | Priority: optional | 2 | Priority: optional |
3 | Section: opie/applications | 3 | Section: opie/applications |
4 | Maintainer: Warwick Allison <warwick@trolltech.com> | 4 | Maintainer: Holger 'zecke' Freyther <zecke@handhelds.org> |
5 | Architecture: arm | 5 | Architecture: arm |
6 | Version: $QPE_VERSION-$SUB_VERSION | 6 | Version: $QPE_VERSION-$SUB_VERSION |
7 | Depends: opie-base ($QPE_VERSION) | 7 | Depends: opie-base ($QPE_VERSION) |
8 | Description: TODO-list manager | 8 | Description: TODO-list manager |
9 | A Todo-list manager for the Opie environment. | 9 | A Todo-list manager for the Opie environment. |
diff --git a/core/pim/todo/todo.pro b/core/pim/todo/todo.pro index a46fb47..a365081 100644 --- a/core/pim/todo/todo.pro +++ b/core/pim/todo/todo.pro | |||
@@ -1,30 +1,32 @@ | |||
1 | TEMPLATE= app | 1 | TEMPLATE= app |
2 | CONFIG = qt warn_on release | 2 | CONFIG = qt warn_on release |
3 | DESTDIR = $(OPIEDIR)/bin | 3 | DESTDIR = $(OPIEDIR)/bin |
4 | HEADERS= mainwindow.h \ | 4 | HEADERS= mainwindow.h \ |
5 | todotable.h \ | 5 | todotable.h \ |
6 | todoentryimpl.h | 6 | todoentryimpl.h \ |
7 | todolabel.h | ||
7 | SOURCES= main.cpp \ | 8 | SOURCES= main.cpp \ |
8 | mainwindow.cpp \ | 9 | mainwindow.cpp \ |
9 | todotable.cpp \ | 10 | todotable.cpp \ |
10 | todoentryimpl.cpp | 11 | todoentryimpl.cpp \ |
12 | todolabel.cc | ||
11 | 13 | ||
12 | INTERFACES= todoentry.ui | 14 | INTERFACES= todoentry.ui |
13 | 15 | ||
14 | TARGET = todolist | 16 | TARGET = todolist |
15 | INCLUDEPATH += $(OPIEDIR)/include | 17 | INCLUDEPATH += $(OPIEDIR)/include |
16 | DEPENDPATH+= $(OPIEDIR)/include | 18 | DEPENDPATH+= $(OPIEDIR)/include |
17 | LIBS += -lqpe -lopie | 19 | LIBS += -lqpe -lopie |
18 | 20 | ||
19 | TRANSLATIONS = ../i18n/pt_BR/todolist.ts | 21 | TRANSLATIONS = ../i18n/pt_BR/todolist.ts |
20 | TRANSLATIONS += ../i18n/de/todolist.ts | 22 | TRANSLATIONS += ../i18n/de/todolist.ts |
21 | TRANSLATIONS += ../i18n/en/todolist.ts | 23 | TRANSLATIONS += ../i18n/en/todolist.ts |
22 | TRANSLATIONS += ../i18n/hu/todolist.ts | 24 | TRANSLATIONS += ../i18n/hu/todolist.ts |
23 | TRANSLATIONS += ../i18n/sl/todolist.ts | 25 | TRANSLATIONS += ../i18n/sl/todolist.ts |
24 | TRANSLATIONS += ../i18n/pl/todolist.ts | 26 | TRANSLATIONS += ../i18n/pl/todolist.ts |
25 | TRANSLATIONS += ../i18n/ja/todolist.ts | 27 | TRANSLATIONS += ../i18n/ja/todolist.ts |
26 | TRANSLATIONS += ../i18n/ko/todolist.ts | 28 | TRANSLATIONS += ../i18n/ko/todolist.ts |
27 | TRANSLATIONS += ../i18n/no/todolist.ts | 29 | TRANSLATIONS += ../i18n/no/todolist.ts |
28 | TRANSLATIONS += ../i18n/zh_CN/todolist.ts | 30 | TRANSLATIONS += ../i18n/zh_CN/todolist.ts |
29 | TRANSLATIONS += ../i18n/zh_TW/todolist.ts | 31 | TRANSLATIONS += ../i18n/zh_TW/todolist.ts |
30 | TRANSLATIONS += ../i18n/fr/todolist.ts | 32 | TRANSLATIONS += ../i18n/fr/todolist.ts |
diff --git a/core/pim/todo/todolabel.cc b/core/pim/todo/todolabel.cc new file mode 100644 index 0000000..4ce3499 --- a/dev/null +++ b/core/pim/todo/todolabel.cc | |||
@@ -0,0 +1,58 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2002 by Stefan Eilers (se, eilers.stefan@epost.de) | ||
3 | ** Copyright (C) 2002 Holger 'zecke' Freyther <freyther@kde.org> | ||
4 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | ||
5 | ** | ||
6 | ** This file is part of the Qtopia Environment. | ||
7 | ** | ||
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 | ||
10 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
11 | ** packaging of this file. | ||
12 | ** | ||
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. | ||
15 | ** | ||
16 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
17 | ** | ||
18 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
19 | ** not clear to you. | ||
20 | ** | ||
21 | **********************************************************************/ | ||
22 | |||
23 | |||
24 | |||
25 | #include <qpe/stringutil.h> | ||
26 | |||
27 | #include <qregexp.h> | ||
28 | #include <qstylesheet.h> | ||
29 | |||
30 | |||
31 | #include "todolabel.h" | ||
32 | |||
33 | TodoLabel::TodoLabel( QWidget *parent, const char *name ) | ||
34 | : QTextView( parent, name ) | ||
35 | { | ||
36 | } | ||
37 | |||
38 | TodoLabel::~TodoLabel() | ||
39 | { | ||
40 | } | ||
41 | |||
42 | void TodoLabel::init( const ToDoEvent &item ) | ||
43 | { | ||
44 | m_item = item; | ||
45 | } | ||
46 | |||
47 | void TodoLabel::sync() | ||
48 | { | ||
49 | QString text = m_item.richText(); | ||
50 | setText( text ); | ||
51 | } | ||
52 | |||
53 | void TodoLabel::keyPressEvent( QKeyEvent *e ) | ||
54 | { | ||
55 | if ( e->key() == Qt::Key_F33 ) { | ||
56 | emit okPressed(); | ||
57 | } | ||
58 | } | ||
diff --git a/core/pim/todo/todolabel.h b/core/pim/todo/todolabel.h new file mode 100644 index 0000000..b6d67af --- a/dev/null +++ b/core/pim/todo/todolabel.h | |||
@@ -0,0 +1,51 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2002 by Stefan Eilers (se, eilers.stefan@epost.de) | ||
3 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | ||
4 | ** | ||
5 | ** This file is part of the Qtopia Environment. | ||
6 | ** | ||
7 | ** This file may be distributed and/or modified under the terms of the | ||
8 | ** GNU General Public License version 2 as published by the Free Software | ||
9 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
10 | ** packaging of this file. | ||
11 | ** | ||
12 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
13 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
14 | ** | ||
15 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
16 | ** | ||
17 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
18 | ** not clear to you. | ||
19 | ** | ||
20 | **********************************************************************/ | ||
21 | #ifndef TODOLABEL_H | ||
22 | #define TODOLABEL_H | ||
23 | |||
24 | #include <opie/todoevent.h> | ||
25 | |||
26 | #include <qtextview.h> | ||
27 | |||
28 | class TodoLabel : public QTextView | ||
29 | { | ||
30 | Q_OBJECT | ||
31 | |||
32 | public: | ||
33 | TodoLabel( QWidget *parent, const char *name = 0 ); | ||
34 | ~TodoLabel(); | ||
35 | |||
36 | public slots: | ||
37 | void init( const ToDoEvent &item); | ||
38 | void sync(); | ||
39 | |||
40 | signals: | ||
41 | void okPressed(); | ||
42 | |||
43 | protected: | ||
44 | void keyPressEvent( QKeyEvent * ); | ||
45 | |||
46 | private: | ||
47 | ToDoEvent m_item; | ||
48 | |||
49 | }; | ||
50 | |||
51 | #endif | ||
diff --git a/core/pim/todo/todotable.cpp b/core/pim/todo/todotable.cpp index d0bc61c..753c036 100644 --- a/core/pim/todo/todotable.cpp +++ b/core/pim/todo/todotable.cpp | |||
@@ -180,297 +180,303 @@ QString DueTextItem::key() const | |||
180 | }else if( m_off < 0 ){ | 180 | }else if( m_off < 0 ){ |
181 | key.append("a"); | 181 | key.append("a"); |
182 | } | 182 | } |
183 | key.append(QString::number(m_off ) ); | 183 | key.append(QString::number(m_off ) ); |
184 | }else{ | 184 | }else{ |
185 | key.append("d"); | 185 | key.append("d"); |
186 | } | 186 | } |
187 | return key; | 187 | return key; |
188 | } | 188 | } |
189 | void DueTextItem::setToDoEvent( const ToDoEvent *ev ) | 189 | void DueTextItem::setToDoEvent( const ToDoEvent *ev ) |
190 | { | 190 | { |
191 | m_hasDate = ev->hasDate(); | 191 | m_hasDate = ev->hasDate(); |
192 | m_completed = ev->isCompleted(); | 192 | m_completed = ev->isCompleted(); |
193 | if( ev->hasDate() ){ | 193 | if( ev->hasDate() ){ |
194 | QDate today = QDate::currentDate(); | 194 | QDate today = QDate::currentDate(); |
195 | m_off = today.daysTo(ev->date() ); | 195 | m_off = today.daysTo(ev->date() ); |
196 | //qWarning("DueText m_off=%d", m_off ); | 196 | //qWarning("DueText m_off=%d", m_off ); |
197 | setText( QString::number(m_off) + " day(s) " ); | 197 | setText( QString::number(m_off) + " day(s) " ); |
198 | }else{ | 198 | }else{ |
199 | setText("n.d." ); | 199 | setText("n.d." ); |
200 | m_off = 0; | 200 | m_off = 0; |
201 | } | 201 | } |
202 | //qWarning("m_off=%d", m_off ); | 202 | //qWarning("m_off=%d", m_off ); |
203 | } | 203 | } |
204 | void DueTextItem::paint( QPainter *p, const QColorGroup &cg, const QRect &cr, bool selected ) | 204 | void DueTextItem::paint( QPainter *p, const QColorGroup &cg, const QRect &cr, bool selected ) |
205 | { | 205 | { |
206 | //qWarning ("paint m_off=%d", m_off ); | 206 | //qWarning ("paint m_off=%d", m_off ); |
207 | QColorGroup cg2(cg); | 207 | QColorGroup cg2(cg); |
208 | QColor text = cg.text(); | 208 | QColor text = cg.text(); |
209 | if( m_hasDate && !m_completed ){ | 209 | if( m_hasDate && !m_completed ){ |
210 | if( m_off < 0 ){ | 210 | if( m_off < 0 ){ |
211 | cg2.setColor(QColorGroup::Text, QColor(red ) ); | 211 | cg2.setColor(QColorGroup::Text, QColor(red ) ); |
212 | }else if( m_off == 0 ){ | 212 | }else if( m_off == 0 ){ |
213 | cg2.setColor(QColorGroup::Text, QColor(yellow) ); // orange isn't predefined | 213 | cg2.setColor(QColorGroup::Text, QColor(yellow) ); // orange isn't predefined |
214 | }else if( m_off > 0){ | 214 | }else if( m_off > 0){ |
215 | cg2.setColor(QColorGroup::Text, QColor(green ) ); | 215 | cg2.setColor(QColorGroup::Text, QColor(green ) ); |
216 | } | 216 | } |
217 | } | 217 | } |
218 | QTableItem::paint(p, cg2, cr, selected ); | 218 | QTableItem::paint(p, cg2, cr, selected ); |
219 | cg2.setColor(QColorGroup::Text, text ); | 219 | cg2.setColor(QColorGroup::Text, text ); |
220 | } | 220 | } |
221 | TodoTable::TodoTable( QWidget *parent, const char *name ) | 221 | TodoTable::TodoTable( QWidget *parent, const char *name ) |
222 | // #ifdef QT_QTABLE_NOHEADER_CONSTRUCTOR | 222 | // #ifdef QT_QTABLE_NOHEADER_CONSTRUCTOR |
223 | // : QTable( 0, 3, parent, name, TRUE ), | 223 | // : QTable( 0, 3, parent, name, TRUE ), |
224 | // #else | 224 | // #else |
225 | : QTable( 0, 4, parent, name ), | 225 | : QTable( 0, 4, parent, name ), |
226 | // #endif | 226 | // #endif |
227 | showComp( true ), | 227 | showComp( true ), |
228 | enablePainting( true ), | 228 | enablePainting( true ), |
229 | mCat( 0 ), | 229 | mCat( 0 ), |
230 | currFindRow( -2 ), | 230 | currFindRow( -2 ), |
231 | showDeadl( true) | 231 | showDeadl( true) |
232 | { | 232 | { |
233 | mCat.load( categoryFileName() ); | 233 | mCat.load( categoryFileName() ); |
234 | setSorting( TRUE ); | 234 | setSorting( TRUE ); |
235 | setSelectionMode( NoSelection ); | 235 | setSelectionMode( NoSelection ); |
236 | setColumnStretchable( 2, TRUE ); | 236 | setColumnStretchable( 2, TRUE ); |
237 | setColumnWidth( 0, 20 ); | 237 | setColumnWidth( 0, 20 ); |
238 | setColumnWidth( 1, 35 ); | 238 | setColumnWidth( 1, 35 ); |
239 | 239 | ||
240 | setLeftMargin( 0 ); | 240 | setLeftMargin( 0 ); |
241 | verticalHeader()->hide(); | 241 | verticalHeader()->hide(); |
242 | horizontalHeader()->setLabel( 0, tr( "C." ) ); | 242 | horizontalHeader()->setLabel( 0, tr( "C." ) ); |
243 | horizontalHeader()->setLabel( 1, tr( "Prior." ) ); | 243 | horizontalHeader()->setLabel( 1, tr( "Prior." ) ); |
244 | horizontalHeader()->setLabel( 2, tr( "Description" ) ); | 244 | horizontalHeader()->setLabel( 2, tr( "Description" ) ); |
245 | 245 | ||
246 | setColumnStretchable( 3, FALSE ); | 246 | setColumnStretchable( 3, FALSE ); |
247 | setColumnWidth( 3, 20 ); | 247 | setColumnWidth( 3, 20 ); |
248 | horizontalHeader()->setLabel( 3, tr( "Deadline" ) ); | 248 | horizontalHeader()->setLabel( 3, tr( "Deadline" ) ); |
249 | 249 | ||
250 | if (showDeadl){ | 250 | if (showDeadl){ |
251 | showColumn (3); | 251 | showColumn (3); |
252 | }else{ | 252 | }else{ |
253 | hideColumn (3); | 253 | hideColumn (3); |
254 | } | 254 | } |
255 | 255 | ||
256 | connect( this, SIGNAL( clicked( int, int, int, const QPoint & ) ), | 256 | connect( this, SIGNAL( clicked( int, int, int, const QPoint & ) ), |
257 | this, SLOT( slotClicked( int, int, int, const QPoint & ) ) ); | 257 | this, SLOT( slotClicked( int, int, int, const QPoint & ) ) ); |
258 | connect( this, SIGNAL( pressed( int, int, int, const QPoint & ) ), | 258 | connect( this, SIGNAL( pressed( int, int, int, const QPoint & ) ), |
259 | this, SLOT( slotPressed( int, int, int, const QPoint & ) ) ); | 259 | this, SLOT( slotPressed( int, int, int, const QPoint & ) ) ); |
260 | connect( this, SIGNAL( valueChanged( int, int ) ), | 260 | connect( this, SIGNAL( valueChanged( int, int ) ), |
261 | this, SLOT( slotCheckPriority( int, int ) ) ); | 261 | this, SLOT( slotCheckPriority( int, int ) ) ); |
262 | connect( this, SIGNAL( currentChanged( int, int ) ), | 262 | connect( this, SIGNAL( currentChanged( int, int ) ), |
263 | this, SLOT( slotCurrentChanged( int, int ) ) ); | 263 | this, SLOT( slotCurrentChanged( int, int ) ) ); |
264 | 264 | ||
265 | menuTimer = new QTimer( this ); | 265 | menuTimer = new QTimer( this ); |
266 | connect( menuTimer, SIGNAL(timeout()), this, SLOT(slotShowMenu()) ); | 266 | connect( menuTimer, SIGNAL(timeout()), this, SLOT(slotShowMenu()) ); |
267 | 267 | ||
268 | mDayTimer = new QTimer( this ); | 268 | mDayTimer = new QTimer( this ); |
269 | connect( mDayTimer, SIGNAL(timeout()), this, SLOT(slotCheckDay() ) ); | 269 | connect( mDayTimer, SIGNAL(timeout()), this, SLOT(slotCheckDay() ) ); |
270 | mDay = QDate::currentDate(); | 270 | mDay = QDate::currentDate(); |
271 | } | 271 | } |
272 | 272 | ||
273 | void TodoTable::addEntry( const ToDoEvent &todo ) | 273 | void TodoTable::addEntry( const ToDoEvent &todo ) |
274 | { | 274 | { |
275 | int row = numRows(); | 275 | int row = numRows(); |
276 | setNumRows( row + 1 ); | 276 | setNumRows( row + 1 ); |
277 | updateJournal( todo, ACTION_ADD ); | 277 | updateJournal( todo, ACTION_ADD ); |
278 | insertIntoTable( new ToDoEvent(todo), row ); | 278 | insertIntoTable( new ToDoEvent(todo), row ); |
279 | setCurrentCell(row, currentColumn()); | 279 | setCurrentCell(row, currentColumn()); |
280 | updateVisible(); | 280 | updateVisible(); |
281 | } | 281 | } |
282 | 282 | ||
283 | void TodoTable::slotClicked( int row, int col, int, const QPoint &pos ) | 283 | void TodoTable::slotClicked( int row, int col, int, const QPoint &pos ) |
284 | { | 284 | { |
285 | if ( !cellGeometry( row, col ).contains(pos) ) | 285 | if ( !cellGeometry( row, col ).contains(pos) ) |
286 | return; | 286 | return; |
287 | // let's switch on the column number... | 287 | // let's switch on the column number... |
288 | switch ( col ) | 288 | switch ( col ) |
289 | { | 289 | { |
290 | case 0: { | 290 | case 0: { |
291 | CheckItem *i = static_cast<CheckItem*>(item( row, col )); | 291 | CheckItem *i = static_cast<CheckItem*>(item( row, col )); |
292 | if ( i ) { | 292 | if ( i ) { |
293 | int x = pos.x() - columnPos( col ); | 293 | int x = pos.x() - columnPos( col ); |
294 | int y = pos.y() - rowPos( row ); | 294 | int y = pos.y() - rowPos( row ); |
295 | int w = columnWidth( col ); | 295 | int w = columnWidth( col ); |
296 | int h = rowHeight( row ); | 296 | int h = rowHeight( row ); |
297 | if ( i && x >= ( w - BoxSize ) / 2 && x <= ( w - BoxSize ) / 2 + BoxSize && | 297 | if ( i && x >= ( w - BoxSize ) / 2 && x <= ( w - BoxSize ) / 2 + BoxSize && |
298 | y >= ( h - BoxSize ) / 2 && y <= ( h - BoxSize ) / 2 + BoxSize ) { | 298 | y >= ( h - BoxSize ) / 2 && y <= ( h - BoxSize ) / 2 + BoxSize ) { |
299 | i->toggle(); | 299 | i->toggle(); |
300 | } | 300 | } |
301 | emit signalDoneChanged( i->isChecked() ); | 301 | emit signalDoneChanged( i->isChecked() ); |
302 | } | 302 | } |
303 | } | 303 | } |
304 | break; | 304 | break; |
305 | case 1: | 305 | case 1: |
306 | break; | 306 | break; |
307 | case 2: | 307 | case 2: |
308 | // may as well edit it... | 308 | // may as well edit it... |
309 | // menuTimer->stop(); | 309 | // menuTimer->stop(); |
310 | // emit signalEdit(); | 310 | // emit signalEdit(); |
311 | // fall through | 311 | // Show detailed view of the selected entry |
312 | case 3: | 312 | { |
313 | // may as well edit it... | ||
314 | menuTimer->stop(); | 313 | menuTimer->stop(); |
315 | // emit signalEdit(); | 314 | ToDoEvent *todo = todoList[static_cast<CheckItem*>(item(row, 0))]; |
316 | break; | 315 | emit showDetails( *todo ); |
316 | } | ||
317 | break; | ||
318 | case 3: | ||
319 | // may as well edit it... | ||
320 | menuTimer->stop(); | ||
321 | // emit signalEdit(); | ||
322 | break; | ||
317 | } | 323 | } |
318 | } | 324 | } |
319 | 325 | ||
320 | void TodoTable::slotPressed( int row, int col, int, const QPoint &pos ) | 326 | void TodoTable::slotPressed( int row, int col, int, const QPoint &pos ) |
321 | { | 327 | { |
322 | if ( col == 2 && cellGeometry( row, col ).contains(pos) ) | 328 | if ( col == 2 && cellGeometry( row, col ).contains(pos) ) |
323 | menuTimer->start( 750, TRUE ); | 329 | menuTimer->start( 750, TRUE ); |
324 | } | 330 | } |
325 | 331 | ||
326 | void TodoTable::slotShowMenu() | 332 | void TodoTable::slotShowMenu() |
327 | { | 333 | { |
328 | emit signalShowMenu( QCursor::pos() ); | 334 | emit signalShowMenu( QCursor::pos() ); |
329 | } | 335 | } |
330 | 336 | ||
331 | void TodoTable::slotCurrentChanged( int, int ) | 337 | void TodoTable::slotCurrentChanged( int, int ) |
332 | { | 338 | { |
333 | menuTimer->stop(); | 339 | menuTimer->stop(); |
334 | } | 340 | } |
335 | 341 | ||
336 | void TodoTable::internalAddEntries( QList<ToDoEvent> &list ) | 342 | void TodoTable::internalAddEntries( QList<ToDoEvent> &list ) |
337 | { | 343 | { |
338 | setNumRows( list.count() ); | 344 | setNumRows( list.count() ); |
339 | int row = 0; | 345 | int row = 0; |
340 | ToDoEvent *it; | 346 | ToDoEvent *it; |
341 | for ( it = list.first(); it; it = list.next() ) | 347 | for ( it = list.first(); it; it = list.next() ) |
342 | insertIntoTable( it, row++ ); | 348 | insertIntoTable( it, row++ ); |
343 | } | 349 | } |
344 | 350 | ||
345 | 351 | ||
346 | ToDoEvent TodoTable::currentEntry() const | 352 | ToDoEvent TodoTable::currentEntry() const |
347 | { | 353 | { |
348 | printf ("in currentEntry\n"); | 354 | //qWarning ("in currentEntry\n"); |
349 | 355 | ||
350 | QTableItem *i = item( currentRow(), 0 ); | 356 | QTableItem *i = item( currentRow(), 0 ); |
351 | if ( !i || rowHeight( currentRow() ) <= 0 ) | 357 | if ( !i || rowHeight( currentRow() ) <= 0 ) |
352 | return ToDoEvent(); | 358 | return ToDoEvent(); |
353 | ToDoEvent *todo = todoList[(CheckItem*)i]; | 359 | ToDoEvent *todo = todoList[(CheckItem*)i]; |
354 | todo->setCompleted( ( (CheckItem*)item( currentRow(), 0 ) )->isChecked() ); | 360 | todo->setCompleted( ( (CheckItem*)item( currentRow(), 0 ) )->isChecked() ); |
355 | todo->setPriority( ( (ComboItem*)item( currentRow(), 1 ) )->text().toInt() ); | 361 | todo->setPriority( ( (ComboItem*)item( currentRow(), 1 ) )->text().toInt() ); |
356 | return *todo; | 362 | return *todo; |
357 | } | 363 | } |
358 | 364 | ||
359 | void TodoTable::replaceCurrentEntry( const ToDoEvent &todo, bool fromTableItem ) | 365 | void TodoTable::replaceCurrentEntry( const ToDoEvent &todo, bool fromTableItem ) |
360 | { | 366 | { |
361 | int row = currentRow(); | 367 | int row = currentRow(); |
362 | updateJournal( todo, ACTION_REPLACE); | 368 | updateJournal( todo, ACTION_REPLACE); |
363 | 369 | ||
364 | if ( !fromTableItem ) { | 370 | if ( !fromTableItem ) { |
365 | journalFreeReplaceEntry( todo, row ); | 371 | journalFreeReplaceEntry( todo, row ); |
366 | updateVisible(); | 372 | updateVisible(); |
367 | } | 373 | } |
368 | } | 374 | } |
369 | 375 | ||
370 | void TodoTable::removeCurrentEntry() | 376 | void TodoTable::removeCurrentEntry() |
371 | { | 377 | { |
372 | ToDoEvent *oldTodo; | 378 | ToDoEvent *oldTodo; |
373 | int row = currentRow(); | 379 | int row = currentRow(); |
374 | CheckItem *chk; | 380 | CheckItem *chk; |
375 | 381 | ||
376 | chk = static_cast<CheckItem*>(item(row, 0 )); | 382 | chk = static_cast<CheckItem*>(item(row, 0 )); |
377 | if ( !chk ) | 383 | if ( !chk ) |
378 | return; | 384 | return; |
379 | oldTodo = todoList[chk]; | 385 | oldTodo = todoList[chk]; |
380 | todoList.remove( chk ); | 386 | todoList.remove( chk ); |
381 | oldTodo->setCompleted( chk->isChecked() ); | 387 | oldTodo->setCompleted( chk->isChecked() ); |
382 | oldTodo->setPriority( static_cast<ComboItem*>(item(row, 1))->text().toInt() ); | 388 | oldTodo->setPriority( static_cast<ComboItem*>(item(row, 1))->text().toInt() ); |
383 | realignTable( row ); | 389 | realignTable( row ); |
384 | updateVisible(); | 390 | updateVisible(); |
385 | updateJournal( *oldTodo, ACTION_REMOVE); | 391 | updateJournal( *oldTodo, ACTION_REMOVE); |
386 | delete oldTodo; | 392 | delete oldTodo; |
387 | } | 393 | } |
388 | 394 | ||
389 | 395 | ||
390 | bool TodoTable::save( const QString &fn ) | 396 | bool TodoTable::save( const QString &fn ) |
391 | { | 397 | { |
392 | QString strNewFile = fn + ".new"; | 398 | QString strNewFile = fn + ".new"; |
393 | QFile::remove( strNewFile ); // just to be sure | 399 | QFile::remove( strNewFile ); // just to be sure |
394 | ToDoDB todoDB( strNewFile ); | 400 | ToDoDB todoDB( strNewFile ); |
395 | for ( QMap<CheckItem*, ToDoEvent *>::Iterator it = todoList.begin(); | 401 | for ( QMap<CheckItem*, ToDoEvent *>::Iterator it = todoList.begin(); |
396 | it != todoList.end(); ++it ) { | 402 | it != todoList.end(); ++it ) { |
397 | if ( !item( it.key()->row(), 0 ) ) | 403 | if ( !item( it.key()->row(), 0 ) ) |
398 | continue; | 404 | continue; |
399 | ToDoEvent *todo = *it; | 405 | ToDoEvent *todo = *it; |
400 | // sync item with table | 406 | // sync item with table |
401 | todo->setCompleted( ((CheckItem*)item(it.key()->row(), 0))->isChecked() ); | 407 | todo->setCompleted( ((CheckItem*)item(it.key()->row(), 0))->isChecked() ); |
402 | todo->setPriority( ((ComboItem*)item( it.key()->row(), 1))->text().toInt() ); | 408 | todo->setPriority( ((ComboItem*)item( it.key()->row(), 1))->text().toInt() ); |
403 | todoDB.addEvent( *todo ); | 409 | todoDB.addEvent( *todo ); |
404 | } | 410 | } |
405 | if(!todoDB.save() ){ | 411 | if(!todoDB.save() ){ |
406 | QFile::remove( strNewFile ); | 412 | QFile::remove( strNewFile ); |
407 | return false; | 413 | return false; |
408 | }; | 414 | }; |
409 | // now do the rename | 415 | // now do the rename |
410 | if ( ::rename( strNewFile, fn ) < 0 ) | 416 | if ( ::rename( strNewFile, fn ) < 0 ) |
411 | qWarning( "problem renaming file %s to %s errno %d", | 417 | qWarning( "problem renaming file %s to %s errno %d", |
412 | strNewFile.latin1(), fn.latin1(), errno ); | 418 | strNewFile.latin1(), fn.latin1(), errno ); |
413 | 419 | ||
414 | // remove the journal | 420 | // remove the journal |
415 | QFile::remove( journalFileName() ); | 421 | QFile::remove( journalFileName() ); |
416 | return true; | 422 | return true; |
417 | } | 423 | } |
418 | 424 | ||
419 | void TodoTable::load( const QString &fn ) | 425 | void TodoTable::load( const QString &fn ) |
420 | { | 426 | { |
421 | if ( QFile::exists(journalFileName()) ) { | 427 | if ( QFile::exists(journalFileName()) ) { |
422 | applyJournal(); | 428 | applyJournal(); |
423 | QFile::remove(journalFileName() ); | 429 | QFile::remove(journalFileName() ); |
424 | } | 430 | } |
425 | loadFile( fn ); | 431 | loadFile( fn ); |
426 | // QTable::sortColumn(2,TRUE,TRUE); | 432 | // QTable::sortColumn(2,TRUE,TRUE); |
427 | // QTable::sortColumn(1,TRUE,TRUE); | 433 | // QTable::sortColumn(1,TRUE,TRUE); |
428 | QTable::sortColumn(0,TRUE,TRUE); | 434 | QTable::sortColumn(0,TRUE,TRUE); |
429 | setCurrentCell( 0, 2 ); | 435 | setCurrentCell( 0, 2 ); |
430 | setSorting(true ); | 436 | setSorting(true ); |
431 | mDayTimer->start( 60 * 1000 ); // gone in 60 seconds? | 437 | mDayTimer->start( 60 * 1000 ); // gone in 60 seconds? |
432 | } | 438 | } |
433 | void TodoTable::updateVisible() | 439 | void TodoTable::updateVisible() |
434 | { | 440 | { |
435 | if ( !isUpdatesEnabled() ) | 441 | if ( !isUpdatesEnabled() ) |
436 | return; | 442 | return; |
437 | 443 | ||
438 | if (showDeadl){ | 444 | if (showDeadl){ |
439 | showColumn (3); | 445 | showColumn (3); |
440 | adjustColumn(3); | 446 | adjustColumn(3); |
441 | }else{ | 447 | }else{ |
442 | hideColumn (3); | 448 | hideColumn (3); |
443 | adjustColumn(2); | 449 | adjustColumn(2); |
444 | } | 450 | } |
445 | 451 | ||
446 | int visible = 0; | 452 | int visible = 0; |
447 | int id = mCat.id( "Todo List", showCat ); | 453 | int id = mCat.id( "Todo List", showCat ); |
448 | for ( int row = 0; row < numRows(); row++ ) { | 454 | for ( int row = 0; row < numRows(); row++ ) { |
449 | CheckItem *ci = (CheckItem *)item( row, 0 ); | 455 | CheckItem *ci = (CheckItem *)item( row, 0 ); |
450 | ToDoEvent *t = todoList[ci]; | 456 | ToDoEvent *t = todoList[ci]; |
451 | QArray<int> vlCats = t->categories(); | 457 | QArray<int> vlCats = t->categories(); |
452 | bool hide = false; | 458 | bool hide = false; |
453 | if ( !showComp && ci->isChecked() ) | 459 | if ( !showComp && ci->isChecked() ) |
454 | hide = true; | 460 | hide = true; |
455 | if ( !showCat.isEmpty() ) { | 461 | if ( !showCat.isEmpty() ) { |
456 | if ( showCat == tr( "Unfiled" ) ) { | 462 | if ( showCat == tr( "Unfiled" ) ) { |
457 | if ( vlCats.count() > 0 ) | 463 | if ( vlCats.count() > 0 ) |
458 | hide = true; | 464 | hide = true; |
459 | } else { | 465 | } else { |
460 | // do some comparing, we have to reverse our idea here... which idea? - zecke | 466 | // do some comparing, we have to reverse our idea here... which idea? - zecke |
461 | if ( !hide ) { | 467 | if ( !hide ) { |
462 | hide = true; | 468 | hide = true; |
463 | for ( uint it = 0; it < vlCats.count(); ++it ) { | 469 | for ( uint it = 0; it < vlCats.count(); ++it ) { |
464 | if ( vlCats[it] == id ) { | 470 | if ( vlCats[it] == id ) { |
465 | hide = false; | 471 | hide = false; |
466 | break; | 472 | break; |
467 | } | 473 | } |
468 | } | 474 | } |
469 | } | 475 | } |
470 | } | 476 | } |
471 | } | 477 | } |
472 | if ( hide ) { | 478 | if ( hide ) { |
473 | if ( currentRow() == row ) | 479 | if ( currentRow() == row ) |
474 | setCurrentCell( -1, 0 ); | 480 | setCurrentCell( -1, 0 ); |
475 | if ( rowHeight( row ) > 0 ) | 481 | if ( rowHeight( row ) > 0 ) |
476 | hideRow( row ); | 482 | hideRow( row ); |
diff --git a/core/pim/todo/todotable.h b/core/pim/todo/todotable.h index 458e07a..2f6e635 100644 --- a/core/pim/todo/todotable.h +++ b/core/pim/todo/todotable.h | |||
@@ -17,224 +17,224 @@ | |||
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #ifndef TODOTABLE_H | 21 | #ifndef TODOTABLE_H |
22 | #define TODOTABLE_H | 22 | #define TODOTABLE_H |
23 | 23 | ||
24 | #include <qpe/categories.h> | 24 | #include <qpe/categories.h> |
25 | #include <qpe/stringutil.h> | 25 | #include <qpe/stringutil.h> |
26 | //#include <qpe/task.h> | 26 | //#include <qpe/task.h> |
27 | #include <opie/todoevent.h> | 27 | #include <opie/todoevent.h> |
28 | 28 | ||
29 | #include <qtable.h> | 29 | #include <qtable.h> |
30 | #include <qmap.h> | 30 | #include <qmap.h> |
31 | #include <qguardedptr.h> | 31 | #include <qguardedptr.h> |
32 | 32 | ||
33 | class Node; | 33 | class Node; |
34 | class QComboBox; | 34 | class QComboBox; |
35 | class QTimer; | 35 | class QTimer; |
36 | 36 | ||
37 | class CheckItem : public QTableItem | 37 | class CheckItem : public QTableItem |
38 | { | 38 | { |
39 | public: | 39 | public: |
40 | CheckItem( QTable *t, const QString &sortkey ); | 40 | CheckItem( QTable *t, const QString &sortkey ); |
41 | 41 | ||
42 | void setChecked( bool b ); | 42 | void setChecked( bool b ); |
43 | void toggle(); | 43 | void toggle(); |
44 | bool isChecked() const; | 44 | bool isChecked() const; |
45 | void setKey( const QString &key ) { sortKey = key; } | 45 | void setKey( const QString &key ) { sortKey = key; } |
46 | QString key() const; | 46 | QString key() const; |
47 | 47 | ||
48 | void paint( QPainter *p, const QColorGroup &cg, const QRect &cr, bool selected ); | 48 | void paint( QPainter *p, const QColorGroup &cg, const QRect &cr, bool selected ); |
49 | 49 | ||
50 | private: | 50 | private: |
51 | bool checked; | 51 | bool checked; |
52 | QString sortKey; | 52 | QString sortKey; |
53 | }; | 53 | }; |
54 | 54 | ||
55 | class ComboItem : public QTableItem | 55 | class ComboItem : public QTableItem |
56 | { | 56 | { |
57 | public: | 57 | public: |
58 | ComboItem( QTable *t, EditType et ); | 58 | ComboItem( QTable *t, EditType et ); |
59 | QWidget *createEditor() const; | 59 | QWidget *createEditor() const; |
60 | void setContentFromEditor( QWidget *w ); | 60 | void setContentFromEditor( QWidget *w ); |
61 | void setText( const QString &s ); | 61 | void setText( const QString &s ); |
62 | int alignment() const { return Qt::AlignCenter; } | 62 | int alignment() const { return Qt::AlignCenter; } |
63 | 63 | ||
64 | QString text() const; | 64 | QString text() const; |
65 | 65 | ||
66 | private: | 66 | private: |
67 | QGuardedPtr<QComboBox> cb; | 67 | QGuardedPtr<QComboBox> cb; |
68 | 68 | ||
69 | }; | 69 | }; |
70 | 70 | ||
71 | class TodoTextItem : public QTableItem | 71 | class TodoTextItem : public QTableItem |
72 | { | 72 | { |
73 | public: | 73 | public: |
74 | TodoTextItem( QTable *t, const QString & str ) | 74 | TodoTextItem( QTable *t, const QString & str ) |
75 | :QTableItem( t, QTableItem::Never, str ) {} | 75 | :QTableItem( t, QTableItem::Never, str ) {} |
76 | 76 | ||
77 | QString key () const { return Qtopia::buildSortKey( text() ); } | 77 | QString key () const { return Qtopia::buildSortKey( text() ); } |
78 | }; | 78 | }; |
79 | 79 | ||
80 | class DueTextItem : public QTableItem | 80 | class DueTextItem : public QTableItem |
81 | { | 81 | { |
82 | public: | 82 | public: |
83 | DueTextItem( QTable *t, ToDoEvent *ev ); | 83 | DueTextItem( QTable *t, ToDoEvent *ev ); |
84 | QString key() const; | 84 | QString key() const; |
85 | void setToDoEvent( const ToDoEvent *ev ); | 85 | void setToDoEvent( const ToDoEvent *ev ); |
86 | void paint( QPainter *p, const QColorGroup &cg, const QRect &cr, bool selected ); | 86 | void paint( QPainter *p, const QColorGroup &cg, const QRect &cr, bool selected ); |
87 | private: | 87 | private: |
88 | int m_off; | 88 | int m_off; |
89 | bool m_hasDate:1; | 89 | bool m_hasDate:1; |
90 | bool m_completed:1; | 90 | bool m_completed:1; |
91 | 91 | ||
92 | }; | 92 | }; |
93 | 93 | ||
94 | 94 | ||
95 | enum journal_action { ACTION_ADD=0, ACTION_REMOVE, ACTION_REPLACE }; | 95 | enum journal_action { ACTION_ADD=0, ACTION_REMOVE, ACTION_REPLACE }; |
96 | 96 | ||
97 | class XMLElement; | 97 | class XMLElement; |
98 | class TodoTable : public QTable | 98 | class TodoTable : public QTable |
99 | { | 99 | { |
100 | Q_OBJECT | 100 | Q_OBJECT |
101 | 101 | ||
102 | public: | 102 | public: |
103 | TodoTable( QWidget *parent = 0, const char * name = 0 ); | 103 | TodoTable( QWidget *parent = 0, const char * name = 0 ); |
104 | void addEntry( const ToDoEvent &todo ); | 104 | void addEntry( const ToDoEvent &todo ); |
105 | void clearFindRow() { currFindRow = -2; } | 105 | void clearFindRow() { currFindRow = -2; } |
106 | 106 | ||
107 | ToDoEvent currentEntry() const; | 107 | ToDoEvent currentEntry() const; |
108 | void replaceCurrentEntry( const ToDoEvent &todo, bool fromTableItem = false ); | 108 | void replaceCurrentEntry( const ToDoEvent &todo, bool fromTableItem = false ); |
109 | 109 | ||
110 | QStringList categories(); | 110 | QStringList categories(); |
111 | 111 | ||
112 | void setShowCompleted( bool sc ) { showComp = sc; updateVisible(); } | 112 | void setShowCompleted( bool sc ) { showComp = sc; updateVisible(); } |
113 | bool showCompleted() const { return showComp; } | 113 | bool showCompleted() const { return showComp; } |
114 | 114 | ||
115 | void setShowDeadline (bool sd) {showDeadl = sd; updateVisible();} | 115 | void setShowDeadline (bool sd) {showDeadl = sd; updateVisible();} |
116 | bool showDeadline() const { return showDeadl;} | 116 | bool showDeadline() const { return showDeadl;} |
117 | 117 | ||
118 | void setShowCategory( const QString &c ) { showCat = c; updateVisible(); } | 118 | void setShowCategory( const QString &c ) { showCat = c; updateVisible(); } |
119 | const QString &showCategory() const { return showCat; } | 119 | const QString &showCategory() const { return showCat; } |
120 | int showCategoryId() const; | 120 | int showCategoryId() const; |
121 | 121 | ||
122 | bool save( const QString &fn ); | 122 | bool save( const QString &fn ); |
123 | void load( const QString &fn ); | 123 | void load( const QString &fn ); |
124 | void applyJournal( ); | 124 | void applyJournal( ); |
125 | void clear(); | 125 | void clear(); |
126 | void removeCurrentEntry(); | 126 | void removeCurrentEntry(); |
127 | void removeAllEntries() { clear(); }; | 127 | void removeAllEntries() { clear(); }; |
128 | //void removeAllEntriesInCategory(const QString &category ); | 128 | //void removeAllEntriesInCategory(const QString &category ); |
129 | 129 | ||
130 | void setPaintingEnabled( bool e ); | 130 | void setPaintingEnabled( bool e ); |
131 | 131 | ||
132 | virtual void sortColumn( int col, bool ascending, bool /*wholeRows*/ ); | 132 | virtual void sortColumn( int col, bool ascending, bool /*wholeRows*/ ); |
133 | 133 | ||
134 | // int rowHeight( int ) const; | 134 | // int rowHeight( int ) const; |
135 | // int rowPos( int row ) const; | 135 | // int rowPos( int row ) const; |
136 | // virtual int rowAt( int pos ) const; | 136 | // virtual int rowAt( int pos ) const; |
137 | 137 | ||
138 | signals: | 138 | signals: |
139 | void signalEdit(); | 139 | void signalEdit(); |
140 | void signalDoneChanged( bool b ); | 140 | void signalDoneChanged( bool b ); |
141 | void signalPriorityChanged( int i ); | 141 | void signalPriorityChanged( int i ); |
142 | void signalShowMenu( const QPoint & ); | 142 | void signalShowMenu( const QPoint & ); |
143 | void signalNotFound(); | 143 | void signalNotFound(); |
144 | void signalWrapAround(); | 144 | void signalWrapAround(); |
145 | 145 | void showDetails( const ToDoEvent & ); | |
146 | protected: | 146 | protected: |
147 | void keyPressEvent( QKeyEvent *e ); | 147 | void keyPressEvent( QKeyEvent *e ); |
148 | 148 | ||
149 | private: | 149 | private: |
150 | void updateVisible(); | 150 | void updateVisible(); |
151 | void viewportPaintEvent( QPaintEvent * ); | 151 | void viewportPaintEvent( QPaintEvent * ); |
152 | void internalAddEntries( QList<ToDoEvent> &list); | 152 | void internalAddEntries( QList<ToDoEvent> &list); |
153 | inline void insertIntoTable( ToDoEvent *todo, int row ); | 153 | inline void insertIntoTable( ToDoEvent *todo, int row ); |
154 | void updateJournal( const ToDoEvent &todo, journal_action action); | 154 | void updateJournal( const ToDoEvent &todo, journal_action action); |
155 | void mergeJournal(); | 155 | void mergeJournal(); |
156 | void journalFreeReplaceEntry( const ToDoEvent &todo, int row ); | 156 | void journalFreeReplaceEntry( const ToDoEvent &todo, int row ); |
157 | void journalFreeRemoveEntry( int row ); | 157 | void journalFreeRemoveEntry( int row ); |
158 | inline void realignTable( int row ); | 158 | inline void realignTable( int row ); |
159 | void loadFile( const QString &strFile); | 159 | void loadFile( const QString &strFile); |
160 | 160 | ||
161 | private slots: | 161 | private slots: |
162 | void slotClicked( int row, int col, int button, const QPoint &pos ); | 162 | void slotClicked( int row, int col, int button, const QPoint &pos ); |
163 | void slotPressed( int row, int col, int button, const QPoint &pos ); | 163 | void slotPressed( int row, int col, int button, const QPoint &pos ); |
164 | void slotCheckPriority(int row, int col ); | 164 | void slotCheckPriority(int row, int col ); |
165 | void slotCurrentChanged(int row, int col ); | 165 | void slotCurrentChanged(int row, int col ); |
166 | void slotDoFind( const QString &findString, bool caseSensetive, | 166 | void slotDoFind( const QString &findString, bool caseSensetive, |
167 | bool backwards, int category ); | 167 | bool backwards, int category ); |
168 | void slotShowMenu(); | 168 | void slotShowMenu(); |
169 | void rowHeightChanged( int row ); | 169 | void rowHeightChanged( int row ); |
170 | void slotCheckDay(); // check the day | 170 | void slotCheckDay(); // check the day |
171 | 171 | ||
172 | private: | 172 | private: |
173 | friend class TodoWindow; | 173 | friend class TodoWindow; |
174 | 174 | ||
175 | QMap<CheckItem*, ToDoEvent *> todoList; | 175 | QMap<CheckItem*, ToDoEvent *> todoList; |
176 | QStringList categoryList; | 176 | QStringList categoryList; |
177 | bool showComp; | 177 | bool showComp; |
178 | QString showCat; | 178 | QString showCat; |
179 | QTimer *menuTimer; | 179 | QTimer *menuTimer; |
180 | QDate mDay; | 180 | QDate mDay; |
181 | QTimer *mDayTimer; // see if the day changed | 181 | QTimer *mDayTimer; // see if the day changed |
182 | bool enablePainting; | 182 | bool enablePainting; |
183 | Categories mCat; | 183 | Categories mCat; |
184 | int currFindRow; | 184 | int currFindRow; |
185 | bool showDeadl:1; | 185 | bool showDeadl:1; |
186 | }; | 186 | }; |
187 | 187 | ||
188 | 188 | ||
189 | inline void TodoTable::insertIntoTable( ToDoEvent *todo, int row ) | 189 | inline void TodoTable::insertIntoTable( ToDoEvent *todo, int row ) |
190 | { | 190 | { |
191 | QString sortKey = (char) ((todo->isCompleted() ? 'a' : 'A') | 191 | QString sortKey = (char) ((todo->isCompleted() ? 'a' : 'A') |
192 | + todo->priority() ) | 192 | + todo->priority() ) |
193 | + Qtopia::buildSortKey( todo->description() ); | 193 | + Qtopia::buildSortKey( todo->description() ); |
194 | CheckItem *chk = new CheckItem( this, sortKey ); | 194 | CheckItem *chk = new CheckItem( this, sortKey ); |
195 | chk->setChecked( todo->isCompleted() ); | 195 | chk->setChecked( todo->isCompleted() ); |
196 | ComboItem *cmb = new ComboItem( this, QTableItem::WhenCurrent ); | 196 | ComboItem *cmb = new ComboItem( this, QTableItem::WhenCurrent ); |
197 | cmb->setText( QString::number( todo->priority() ) ); | 197 | cmb->setText( QString::number( todo->priority() ) ); |
198 | QTableItem *ti = new TodoTextItem( this, todo->description().left(40).simplifyWhiteSpace() ); | 198 | QTableItem *ti = new TodoTextItem( this, todo->description().left(40).simplifyWhiteSpace() ); |
199 | ti->setReplaceable( false ); | 199 | ti->setReplaceable( false ); |
200 | 200 | ||
201 | DueTextItem *due = new DueTextItem(this, todo ); | 201 | DueTextItem *due = new DueTextItem(this, todo ); |
202 | setItem( row, 3, due); | 202 | setItem( row, 3, due); |
203 | 203 | ||
204 | setItem( row, 0, chk ); | 204 | setItem( row, 0, chk ); |
205 | setItem( row, 1, cmb ); | 205 | setItem( row, 1, cmb ); |
206 | setItem( row, 2, ti ); | 206 | setItem( row, 2, ti ); |
207 | 207 | ||
208 | 208 | ||
209 | todoList.insert( chk, todo ); | 209 | todoList.insert( chk, todo ); |
210 | } | 210 | } |
211 | 211 | ||
212 | inline void TodoTable::realignTable( int row ) | 212 | inline void TodoTable::realignTable( int row ) |
213 | { | 213 | { |
214 | QTableItem *ti1, | 214 | QTableItem *ti1, |
215 | *ti2, | 215 | *ti2, |
216 | *ti3, | 216 | *ti3, |
217 | *ti4; | 217 | *ti4; |
218 | int totalRows = numRows(); | 218 | int totalRows = numRows(); |
219 | for ( int curr = row; curr < totalRows - 1; curr++ ) { | 219 | for ( int curr = row; curr < totalRows - 1; curr++ ) { |
220 | // this is bad, we must take the item out and then | 220 | // this is bad, we must take the item out and then |
221 | // set it. In the end, it behaves no worse (time wise) | 221 | // set it. In the end, it behaves no worse (time wise) |
222 | // then the old way of saving the entries to file, clearing | 222 | // then the old way of saving the entries to file, clearing |
223 | // the table re-reading in the file and resetting the table | 223 | // the table re-reading in the file and resetting the table |
224 | ti1 = item( curr + 1, 0 ); | 224 | ti1 = item( curr + 1, 0 ); |
225 | ti2 = item( curr + 1, 1 ); | 225 | ti2 = item( curr + 1, 1 ); |
226 | ti3 = item( curr + 1, 2 ); | 226 | ti3 = item( curr + 1, 2 ); |
227 | ti4 = item( curr + 1, 3 ); | 227 | ti4 = item( curr + 1, 3 ); |
228 | takeItem( ti1 ); | 228 | takeItem( ti1 ); |
229 | takeItem( ti2 ); | 229 | takeItem( ti2 ); |
230 | takeItem( ti3 ); | 230 | takeItem( ti3 ); |
231 | takeItem( ti4 ); | 231 | takeItem( ti4 ); |
232 | setItem( curr, 0, ti1 ); | 232 | setItem( curr, 0, ti1 ); |
233 | setItem( curr, 1, ti2 ); | 233 | setItem( curr, 1, ti2 ); |
234 | setItem( curr, 2, ti3 ); | 234 | setItem( curr, 2, ti3 ); |
235 | setItem( curr, 3, ti4 ); | 235 | setItem( curr, 3, ti4 ); |
236 | } | 236 | } |
237 | setNumRows( totalRows - 1 ); | 237 | setNumRows( totalRows - 1 ); |
238 | } | 238 | } |
239 | 239 | ||
240 | #endif | 240 | #endif |