-rw-r--r-- | core/pim/todo/TODO | 3 | ||||
-rw-r--r-- | core/pim/todo/mainwindow.cpp | 9 | ||||
-rw-r--r-- | core/pim/todo/mainwindow.h | 3 |
3 files changed, 13 insertions, 2 deletions
diff --git a/core/pim/todo/TODO b/core/pim/todo/TODO index e5d2f9d..040f163 100644 --- a/core/pim/todo/TODO +++ b/core/pim/todo/TODO | |||
@@ -1,3 +1,4 @@ | |||
1 | -fix the journal | 1 | -fix the journal |
2 | -fix day wrapping update all DueDateItems | 2 | -fix day wrapping update all DueDateItems |
3 | -when checking the C. box update the deadline \ No newline at end of file | 3 | -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 a34bcf2..b5cace9 100644 --- a/core/pim/todo/mainwindow.cpp +++ b/core/pim/todo/mainwindow.cpp | |||
@@ -1,456 +1,463 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | Copyright (C) 2002 zecke | 3 | Copyright (C) 2002 zecke |
4 | Copyright (C) 2002 Stefan Eilers | 4 | Copyright (C) 2002 Stefan Eilers |
5 | ** | 5 | ** |
6 | ** This file is part of Qtopia Environment. | 6 | ** This file is part of Qtopia Environment. |
7 | ** | 7 | ** |
8 | ** This file may be distributed and/or modified under the terms of the | 8 | ** This file may be distributed and/or modified under the terms of the |
9 | ** GNU General Public License version 2 as published by the Free Software | 9 | ** GNU General Public License version 2 as published by the Free Software |
10 | ** Foundation and appearing in the file LICENSE.GPL included in the | 10 | ** Foundation and appearing in the file LICENSE.GPL included in the |
11 | ** packaging of this file. | 11 | ** packaging of this file. |
12 | ** | 12 | ** |
13 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 13 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
14 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 14 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
15 | ** | 15 | ** |
16 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 16 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
17 | ** | 17 | ** |
18 | ** Contact info@trolltech.com if any conditions of this licensing are | 18 | ** Contact info@trolltech.com if any conditions of this licensing are |
19 | ** not clear to you. | 19 | ** not clear to you. |
20 | ** | 20 | ** |
21 | **********************************************************************/ | 21 | **********************************************************************/ |
22 | 22 | ||
23 | #define QTOPIA_INTERNAL_FD | 23 | #define QTOPIA_INTERNAL_FD |
24 | 24 | ||
25 | #include "mainwindow.h" | 25 | #include "mainwindow.h" |
26 | #include "todoentryimpl.h" | 26 | #include "todoentryimpl.h" |
27 | #include "todotable.h" | 27 | #include "todotable.h" |
28 | 28 | ||
29 | #include <opie/tododb.h> | 29 | #include <opie/tododb.h> |
30 | #include <opie/todovcalresource.h> | 30 | #include <opie/todovcalresource.h> |
31 | #include <opie/ofontmenu.h> | ||
31 | 32 | ||
32 | #include <qpe/qpeapplication.h> | 33 | #include <qpe/qpeapplication.h> |
33 | #include <qpe/config.h> | 34 | #include <qpe/config.h> |
34 | #include <qpe/finddialog.h> | 35 | #include <qpe/finddialog.h> |
35 | #include <qpe/global.h> | 36 | #include <qpe/global.h> |
36 | #include <qpe/ir.h> | 37 | #include <qpe/ir.h> |
37 | #include <qpe/qpemenubar.h> | 38 | #include <qpe/qpemenubar.h> |
38 | #include <qpe/qpemessagebox.h> | 39 | #include <qpe/qpemessagebox.h> |
39 | #include <qpe/resource.h> | 40 | #include <qpe/resource.h> |
40 | //#include <qpe/task.h> | 41 | //#include <qpe/task.h> |
41 | #include <qpe/qpetoolbar.h> | 42 | #include <qpe/qpetoolbar.h> |
42 | 43 | ||
43 | #include <qaction.h> | 44 | #include <qaction.h> |
44 | #include <qarray.h> | 45 | #include <qarray.h> |
45 | #include <qdatastream.h> | 46 | #include <qdatastream.h> |
46 | #include <qdatetime.h> | 47 | #include <qdatetime.h> |
47 | #include <qfile.h> | 48 | #include <qfile.h> |
48 | #include <qmessagebox.h> | 49 | #include <qmessagebox.h> |
49 | #include <qpopupmenu.h> | 50 | #include <qpopupmenu.h> |
50 | 51 | ||
51 | #include <sys/stat.h> | 52 | #include <sys/stat.h> |
52 | #include <sys/types.h> | 53 | #include <sys/types.h> |
53 | #include <fcntl.h> | 54 | #include <fcntl.h> |
54 | #include <unistd.h> | 55 | #include <unistd.h> |
55 | 56 | ||
56 | #include <stdlib.h> | 57 | #include <stdlib.h> |
57 | 58 | ||
58 | static QString todolistXMLFilename() | 59 | static QString todolistXMLFilename() |
59 | { | 60 | { |
60 | return Global::applicationFileName("todolist","todolist.xml"); | 61 | return Global::applicationFileName("todolist","todolist.xml"); |
61 | } | 62 | } |
62 | 63 | ||
63 | static QString categoriesXMLFilename() | 64 | static QString categoriesXMLFilename() |
64 | { | 65 | { |
65 | return Global::applicationFileName("todolist","categories.xml"); | 66 | return Global::applicationFileName("todolist","categories.xml"); |
66 | } | 67 | } |
67 | 68 | ||
68 | TodoWindow::TodoWindow( QWidget *parent, const char *name, WFlags f = 0 ) : | 69 | TodoWindow::TodoWindow( QWidget *parent, const char *name, WFlags f = 0 ) : |
69 | QMainWindow( parent, name, f ), syncing(FALSE) | 70 | QMainWindow( parent, name, f ), syncing(FALSE) |
70 | { | 71 | { |
71 | // QTime t; | 72 | // QTime t; |
72 | // t.start(); | 73 | // t.start(); |
73 | 74 | ||
74 | setCaption( tr("Todo") ); | 75 | setCaption( tr("Todo") ); |
75 | QString str; | 76 | QString str; |
76 | table = new TodoTable( this ); | 77 | table = new TodoTable( this ); |
77 | table->setColumnWidth( 2, 10 ); | 78 | table->setColumnWidth( 2, 10 ); |
78 | table->setPaintingEnabled( FALSE ); | 79 | table->setPaintingEnabled( FALSE ); |
79 | table->setUpdatesEnabled( FALSE ); | 80 | table->setUpdatesEnabled( FALSE ); |
80 | table->viewport()->setUpdatesEnabled( FALSE ); | 81 | table->viewport()->setUpdatesEnabled( FALSE ); |
81 | 82 | ||
82 | { | 83 | { |
83 | str = todolistXMLFilename(); | 84 | str = todolistXMLFilename(); |
84 | if ( str.isNull() ) | 85 | if ( str.isNull() ) |
85 | QMessageBox::critical( this, | 86 | QMessageBox::critical( this, |
86 | tr("Out of Space"), | 87 | tr("Out of Space"), |
87 | tr("Unable to create startup files\n" | 88 | tr("Unable to create startup files\n" |
88 | "Free up some space\n" | 89 | "Free up some space\n" |
89 | "before you enter any data") ); | 90 | "before you enter any data") ); |
90 | else | 91 | else |
91 | table->load( str ); | 92 | table->load( str ); |
92 | } | 93 | } |
93 | 94 | ||
94 | // repeat for categories... | 95 | // repeat for categories... |
95 | str = categoriesXMLFilename(); | 96 | str = categoriesXMLFilename(); |
96 | if ( str.isNull() ) | 97 | if ( str.isNull() ) |
97 | QMessageBox::critical( this, | 98 | QMessageBox::critical( this, |
98 | tr( "Out of Space" ), | 99 | tr( "Out of Space" ), |
99 | tr( "Unable to create startup files\n" | 100 | tr( "Unable to create startup files\n" |
100 | "Free up some space\n" | 101 | "Free up some space\n" |
101 | "before you enter any data") ); | 102 | "before you enter any data") ); |
102 | 103 | ||
103 | setCentralWidget( table ); | 104 | setCentralWidget( table ); |
104 | setToolBarsMovable( FALSE ); | 105 | setToolBarsMovable( FALSE ); |
105 | 106 | ||
106 | // qDebug("after load: t=%d", t.elapsed() ); | 107 | // qDebug("after load: t=%d", t.elapsed() ); |
107 | 108 | ||
108 | Config config( "todo" ); | 109 | Config config( "todo" ); |
109 | config.setGroup( "View" ); | 110 | config.setGroup( "View" ); |
110 | bool complete = config.readBoolEntry( "ShowComplete", true ); | 111 | bool complete = config.readBoolEntry( "ShowComplete", true ); |
111 | table->setShowCompleted( complete ); | 112 | table->setShowCompleted( complete ); |
112 | 113 | ||
113 | bool showdeadline = config.readBoolEntry("ShowDeadLine", true); | 114 | bool showdeadline = config.readBoolEntry("ShowDeadLine", true); |
114 | table->setShowDeadline (showdeadline); | 115 | table->setShowDeadline (showdeadline); |
115 | 116 | ||
116 | QString category = config.readEntry( "Category", QString::null ); | 117 | QString category = config.readEntry( "Category", QString::null ); |
117 | table->setShowCategory( category ); | 118 | table->setShowCategory( category ); |
118 | 119 | ||
119 | QPEToolBar *bar = new QPEToolBar( this ); | 120 | QPEToolBar *bar = new QPEToolBar( this ); |
120 | bar->setHorizontalStretchable( TRUE ); | 121 | bar->setHorizontalStretchable( TRUE ); |
121 | 122 | ||
122 | QPEMenuBar *mb = new QPEMenuBar( bar ); | 123 | QPEMenuBar *mb = new QPEMenuBar( bar ); |
123 | 124 | ||
124 | catMenu = new QPopupMenu( this ); | 125 | catMenu = new QPopupMenu( this ); |
125 | QPopupMenu *edit = new QPopupMenu( this ); | 126 | QPopupMenu *edit = new QPopupMenu( this ); |
126 | contextMenu = new QPopupMenu( this ); | 127 | contextMenu = new QPopupMenu( this ); |
127 | 128 | ||
128 | bar = new QPEToolBar( this ); | 129 | bar = new QPEToolBar( this ); |
129 | 130 | ||
130 | QAction *a = new QAction( tr( "New Task" ), Resource::loadPixmap( "new" ), | 131 | QAction *a = new QAction( tr( "New Task" ), Resource::loadPixmap( "new" ), |
131 | QString::null, 0, this, 0 ); | 132 | QString::null, 0, this, 0 ); |
132 | connect( a, SIGNAL( activated() ), | 133 | connect( a, SIGNAL( activated() ), |
133 | this, SLOT( slotNew() ) ); | 134 | this, SLOT( slotNew() ) ); |
134 | a->addTo( bar ); | 135 | a->addTo( bar ); |
135 | a->addTo( edit ); | 136 | a->addTo( edit ); |
136 | 137 | ||
137 | a = new QAction( tr( "Edit" ), Resource::loadIconSet( "edit" ), | 138 | a = new QAction( tr( "Edit" ), Resource::loadIconSet( "edit" ), |
138 | QString::null, 0, this, 0 ); | 139 | QString::null, 0, this, 0 ); |
139 | connect( a, SIGNAL( activated() ), | 140 | connect( a, SIGNAL( activated() ), |
140 | this, SLOT( slotEdit() ) ); | 141 | this, SLOT( slotEdit() ) ); |
141 | a->addTo( bar ); | 142 | a->addTo( bar ); |
142 | a->addTo( edit ); | 143 | a->addTo( edit ); |
143 | a->addTo( contextMenu ); | 144 | a->addTo( contextMenu ); |
144 | a->setEnabled( FALSE ); | 145 | a->setEnabled( FALSE ); |
145 | editAction = a; | 146 | editAction = a; |
146 | 147 | ||
147 | a = new QAction( tr( "Delete" ), Resource::loadIconSet( "trash" ), | 148 | a = new QAction( tr( "Delete" ), Resource::loadIconSet( "trash" ), |
148 | QString::null, 0, this, 0 ); | 149 | QString::null, 0, this, 0 ); |
149 | connect( a, SIGNAL( activated() ), | 150 | connect( a, SIGNAL( activated() ), |
150 | this, SLOT( slotDelete() ) ); | 151 | this, SLOT( slotDelete() ) ); |
151 | a->addTo( bar ); | 152 | a->addTo( bar ); |
152 | a->addTo( edit ); | 153 | a->addTo( edit ); |
153 | a->addTo( contextMenu ); | 154 | a->addTo( contextMenu ); |
154 | a->setEnabled( FALSE ); | 155 | a->setEnabled( FALSE ); |
155 | deleteAction = a; | 156 | deleteAction = a; |
156 | 157 | ||
157 | if ( Ir::supported() ) { | 158 | if ( Ir::supported() ) { |
158 | a = new QAction( tr( "Beam" ), Resource::loadPixmap( "beam" ), | 159 | a = new QAction( tr( "Beam" ), Resource::loadPixmap( "beam" ), |
159 | QString::null, 0, this, 0 ); | 160 | QString::null, 0, this, 0 ); |
160 | connect( a, SIGNAL( activated() ), | 161 | connect( a, SIGNAL( activated() ), |
161 | this, SLOT( slotBeam() ) ); | 162 | this, SLOT( slotBeam() ) ); |
162 | a->addTo( edit ); | 163 | a->addTo( edit ); |
163 | a->addTo( bar ); | 164 | a->addTo( bar ); |
164 | } | 165 | } |
165 | 166 | ||
166 | a = new QAction( tr( "Find" ), Resource::loadIconSet( "mag" ), | 167 | a = new QAction( tr( "Find" ), Resource::loadIconSet( "mag" ), |
167 | QString::null, 0, this, 0 ); | 168 | QString::null, 0, this, 0 ); |
168 | connect( a, SIGNAL( activated() ), | 169 | connect( a, SIGNAL( activated() ), |
169 | this, SLOT( slotFind() ) ); | 170 | this, SLOT( slotFind() ) ); |
170 | a->addTo( bar ); | 171 | a->addTo( bar ); |
171 | a->addTo( edit ); | 172 | a->addTo( edit ); |
172 | if ( table->numRows() ) | 173 | if ( table->numRows() ) |
173 | a->setEnabled( TRUE ); | 174 | a->setEnabled( TRUE ); |
174 | else | 175 | else |
175 | a->setEnabled( FALSE ); | 176 | a->setEnabled( FALSE ); |
176 | 177 | ||
177 | //a->setEnabled( FALSE ); | 178 | //a->setEnabled( FALSE ); |
178 | findAction = a; | 179 | findAction = a; |
179 | // qDebug("mainwindow #2: t=%d", t.elapsed() ); | 180 | // qDebug("mainwindow #2: t=%d", t.elapsed() ); |
180 | 181 | ||
181 | completedAction = new QAction( QString::null, tr("Completed tasks"), 0, this, 0, TRUE ); | 182 | completedAction = new QAction( QString::null, tr("Completed tasks"), 0, this, 0, TRUE ); |
182 | 183 | ||
183 | showdeadlineAction = new QAction( QString::null, tr( "Show Deadline" ), 0, this, 0, TRUE ); | 184 | showdeadlineAction = new QAction( QString::null, tr( "Show Deadline" ), 0, this, 0, TRUE ); |
184 | 185 | ||
185 | catMenu->setCheckable( true ); | 186 | catMenu->setCheckable( true ); |
186 | populateCategories(); | 187 | populateCategories(); |
187 | 188 | ||
188 | mb->insertItem( tr( "Task" ), edit ); | 189 | mb->insertItem( tr( "Data" ), edit ); |
189 | mb->insertItem( tr( "View" ), catMenu ); | 190 | mb->insertItem( tr( "View" ), catMenu ); |
190 | 191 | ||
191 | resize( 200, 300 ); | 192 | resize( 200, 300 ); |
192 | if ( table->numRows() > 0 ) | 193 | if ( table->numRows() > 0 ) |
193 | currentEntryChanged( 0, 0 ); | 194 | currentEntryChanged( 0, 0 ); |
194 | connect( table, SIGNAL( signalEdit() ), | 195 | connect( table, SIGNAL( signalEdit() ), |
195 | this, SLOT( slotEdit() ) ); | 196 | this, SLOT( slotEdit() ) ); |
196 | connect( table, SIGNAL(signalShowMenu(const QPoint &)), | 197 | connect( table, SIGNAL(signalShowMenu(const QPoint &)), |
197 | this, SLOT( slotShowPopup(const QPoint &)) ); | 198 | this, SLOT( slotShowPopup(const QPoint &)) ); |
198 | 199 | ||
199 | // qDebug("mainwindow #3: t=%d", t.elapsed() ); | 200 | // qDebug("mainwindow #3: t=%d", t.elapsed() ); |
200 | table->updateVisible(); | 201 | table->updateVisible(); |
201 | table->setUpdatesEnabled( TRUE ); | 202 | table->setUpdatesEnabled( TRUE ); |
202 | table->setPaintingEnabled( TRUE ); | 203 | table->setPaintingEnabled( TRUE ); |
203 | table->viewport()->setUpdatesEnabled( TRUE ); | 204 | table->viewport()->setUpdatesEnabled( TRUE ); |
204 | 205 | ||
205 | connect( completedAction, SIGNAL( toggled(bool) ), this, SLOT( showCompleted(bool) ) ); | 206 | connect( completedAction, SIGNAL( toggled(bool) ), this, SLOT( showCompleted(bool) ) ); |
206 | connect( showdeadlineAction, SIGNAL( toggled(bool) ), this, SLOT( showDeadline(bool) ) ); | 207 | connect( showdeadlineAction, SIGNAL( toggled(bool) ), this, SLOT( showDeadline(bool) ) ); |
207 | connect( catMenu, SIGNAL(activated(int)), this, SLOT(setCategory(int)) ); | 208 | connect( catMenu, SIGNAL(activated(int)), this, SLOT(setCategory(int)) ); |
208 | connect( table, SIGNAL( currentChanged( int, int ) ), | 209 | connect( table, SIGNAL( currentChanged( int, int ) ), |
209 | this, SLOT( currentEntryChanged( int, int ) ) ); | 210 | this, SLOT( currentEntryChanged( int, int ) ) ); |
210 | 211 | ||
211 | // qDebug("done: t=%d", t.elapsed() ); | 212 | // qDebug("done: t=%d", t.elapsed() ); |
212 | } | 213 | } |
213 | 214 | ||
214 | void TodoWindow::slotNew() | 215 | void TodoWindow::slotNew() |
215 | { | 216 | { |
216 | if(syncing) { | 217 | if(syncing) { |
217 | QMessageBox::warning(this, tr("Todo"), | 218 | QMessageBox::warning(this, tr("Todo"), |
218 | tr("Can not edit data, currently syncing")); | 219 | tr("Can not edit data, currently syncing")); |
219 | return; | 220 | return; |
220 | } | 221 | } |
221 | 222 | ||
222 | int id; | 223 | int id; |
223 | id = -1; | 224 | id = -1; |
224 | QArray<int> ids; | 225 | QArray<int> ids; |
225 | ids = table->currentEntry().categories(); | 226 | ids = table->currentEntry().categories(); |
226 | if ( ids.count() ) | 227 | if ( ids.count() ) |
227 | id = ids[0]; | 228 | id = ids[0]; |
228 | NewTaskDialog e( id, this, 0, TRUE ); | 229 | NewTaskDialog e( id, this, 0, TRUE ); |
229 | 230 | ||
230 | ToDoEvent todo; | 231 | ToDoEvent todo; |
231 | 232 | ||
232 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 233 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
233 | e.showMaximized(); | 234 | e.showMaximized(); |
234 | #endif | 235 | #endif |
235 | int ret = e.exec(); | 236 | int ret = e.exec(); |
236 | qWarning("finished" ); | 237 | qWarning("finished" ); |
237 | if ( ret == QDialog::Accepted ) { | 238 | if ( ret == QDialog::Accepted ) { |
238 | table->setPaintingEnabled( false ); | 239 | table->setPaintingEnabled( false ); |
239 | todo = e.todoEntry(); | 240 | todo = e.todoEntry(); |
240 | //todo.assignUid(); | 241 | //todo.assignUid(); |
241 | table->addEntry( todo ); | 242 | table->addEntry( todo ); |
242 | table->setPaintingEnabled( true ); | 243 | table->setPaintingEnabled( true ); |
243 | findAction->setEnabled( TRUE ); | 244 | findAction->setEnabled( TRUE ); |
244 | } | 245 | } |
245 | // I'm afraid we must call this every time now, otherwise | 246 | // I'm afraid we must call this every time now, otherwise |
246 | // spend expensive time comparing all these strings... | 247 | // spend expensive time comparing all these strings... |
247 | populateCategories(); | 248 | populateCategories(); |
248 | } | 249 | } |
249 | 250 | ||
250 | TodoWindow::~TodoWindow() | 251 | TodoWindow::~TodoWindow() |
251 | { | 252 | { |
252 | } | 253 | } |
253 | 254 | ||
254 | void TodoWindow::slotDelete() | 255 | void TodoWindow::slotDelete() |
255 | { | 256 | { |
256 | if(syncing) { | 257 | if(syncing) { |
257 | QMessageBox::warning(this, tr("Todo"), | 258 | QMessageBox::warning(this, tr("Todo"), |
258 | tr("Can not edit data, currently syncing")); | 259 | tr("Can not edit data, currently syncing")); |
259 | return; | 260 | return; |
260 | } | 261 | } |
261 | 262 | ||
262 | if ( table->currentRow() == -1 ) | 263 | if ( table->currentRow() == -1 ) |
263 | return; | 264 | return; |
264 | 265 | ||
265 | QString strName = table->text( table->currentRow(), 2 ).left( 30 ); | 266 | QString strName = table->text( table->currentRow(), 2 ).left( 30 ); |
266 | 267 | ||
267 | if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), strName ) ) | 268 | if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), strName ) ) |
268 | return; | 269 | return; |
269 | 270 | ||
270 | 271 | ||
271 | 272 | ||
272 | table->setPaintingEnabled( false ); | 273 | table->setPaintingEnabled( false ); |
273 | table->removeCurrentEntry(); | 274 | table->removeCurrentEntry(); |
274 | table->setPaintingEnabled( true ); | 275 | table->setPaintingEnabled( true ); |
275 | 276 | ||
276 | if ( table->numRows() == 0 ) { | 277 | if ( table->numRows() == 0 ) { |
277 | currentEntryChanged( -1, 0 ); | 278 | currentEntryChanged( -1, 0 ); |
278 | findAction->setEnabled( FALSE ); | 279 | findAction->setEnabled( FALSE ); |
279 | } | 280 | } |
280 | } | 281 | } |
281 | 282 | ||
282 | void TodoWindow::slotEdit() | 283 | void TodoWindow::slotEdit() |
283 | { | 284 | { |
284 | if(syncing) { | 285 | if(syncing) { |
285 | QMessageBox::warning(this, tr("Todo"), | 286 | QMessageBox::warning(this, tr("Todo"), |
286 | tr("Can not edit data, currently syncing")); | 287 | tr("Can not edit data, currently syncing")); |
287 | return; | 288 | return; |
288 | } | 289 | } |
289 | 290 | ||
290 | ToDoEvent todo = table->currentEntry(); | 291 | ToDoEvent todo = table->currentEntry(); |
291 | 292 | ||
292 | NewTaskDialog e( todo, this, 0, TRUE ); | 293 | NewTaskDialog e( todo, this, 0, TRUE ); |
293 | e.setCaption( tr( "Edit Task" ) ); | 294 | e.setCaption( tr( "Edit Task" ) ); |
294 | 295 | ||
295 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 296 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
296 | e.showMaximized(); | 297 | e.showMaximized(); |
297 | #endif | 298 | #endif |
298 | int ret = e.exec(); | 299 | int ret = e.exec(); |
299 | 300 | ||
300 | if ( ret == QDialog::Accepted ) { | 301 | if ( ret == QDialog::Accepted ) { |
301 | table->setPaintingEnabled( false ); | 302 | table->setPaintingEnabled( false ); |
302 | todo = e.todoEntry(); | 303 | todo = e.todoEntry(); |
303 | table->replaceCurrentEntry( todo ); | 304 | table->replaceCurrentEntry( todo ); |
304 | table->setPaintingEnabled( true ); | 305 | table->setPaintingEnabled( true ); |
305 | } | 306 | } |
306 | populateCategories(); | 307 | populateCategories(); |
307 | 308 | ||
308 | } | 309 | } |
309 | 310 | ||
310 | void TodoWindow::slotShowPopup( const QPoint &p ) | 311 | void TodoWindow::slotShowPopup( const QPoint &p ) |
311 | { | 312 | { |
312 | contextMenu->popup( p ); | 313 | contextMenu->popup( p ); |
313 | } | 314 | } |
314 | 315 | ||
315 | void TodoWindow::showCompleted( bool s ) | 316 | void TodoWindow::showCompleted( bool s ) |
316 | { | 317 | { |
317 | if ( !table->isUpdatesEnabled() ) | 318 | if ( !table->isUpdatesEnabled() ) |
318 | return; | 319 | return; |
319 | table->setPaintingEnabled( false ); | 320 | table->setPaintingEnabled( false ); |
320 | table->setShowCompleted( s ); | 321 | table->setShowCompleted( s ); |
321 | table->setPaintingEnabled( true ); | 322 | table->setPaintingEnabled( true ); |
322 | } | 323 | } |
323 | 324 | ||
324 | void TodoWindow::currentEntryChanged( int r, int ) | 325 | void TodoWindow::currentEntryChanged( int r, int ) |
325 | { | 326 | { |
326 | if ( r != -1 && table->rowHeight( r ) > 0 ) { | 327 | if ( r != -1 && table->rowHeight( r ) > 0 ) { |
327 | editAction->setEnabled( TRUE ); | 328 | editAction->setEnabled( TRUE ); |
328 | deleteAction->setEnabled( TRUE ); | 329 | deleteAction->setEnabled( TRUE ); |
329 | } else { | 330 | } else { |
330 | editAction->setEnabled( FALSE ); | 331 | editAction->setEnabled( FALSE ); |
331 | deleteAction->setEnabled( FALSE ); | 332 | deleteAction->setEnabled( FALSE ); |
332 | } | 333 | } |
333 | } | 334 | } |
334 | 335 | ||
335 | void TodoWindow::setCategory( int c ) | 336 | void TodoWindow::setCategory( int c ) |
336 | { | 337 | { |
337 | if ( c <= 0 ) return; | 338 | if ( c <= 0 ) return; |
338 | if ( !table->isUpdatesEnabled() ) | 339 | if ( !table->isUpdatesEnabled() ) |
339 | return; | 340 | return; |
340 | table->setPaintingEnabled( false ); | 341 | table->setPaintingEnabled( false ); |
341 | for ( unsigned int i = 1; i < catMenu->count(); i++ ) | 342 | for ( unsigned int i = 1; i < catMenu->count(); i++ ) |
342 | catMenu->setItemChecked( i, c == (int)i ); | 343 | catMenu->setItemChecked( i, c == (int)i ); |
343 | if ( c == 1 ) { | 344 | if ( c == 1 ) { |
344 | table->setShowCategory( QString::null ); | 345 | table->setShowCategory( QString::null ); |
345 | setCaption( tr("Todo") + " - " + tr( "All Categories" ) ); | 346 | setCaption( tr("Todo") + " - " + tr( "All Categories" ) ); |
346 | } else if ( c == (int)catMenu->count() - 1 ) { | 347 | } else if ( c == (int)catMenu->count() - 1 ) { |
347 | table->setShowCategory( tr( "Unfiled" ) ); | 348 | table->setShowCategory( tr( "Unfiled" ) ); |
348 | setCaption( tr("Todo") + " - " + tr( "Unfiled" ) ); | 349 | setCaption( tr("Todo") + " - " + tr( "Unfiled" ) ); |
349 | } else { | 350 | } else { |
350 | QString cat = table->categories()[c - 2]; | 351 | QString cat = table->categories()[c - 2]; |
351 | table->setShowCategory( cat ); | 352 | table->setShowCategory( cat ); |
352 | setCaption( tr("Todo") + " - " + cat ); | 353 | setCaption( tr("Todo") + " - " + cat ); |
353 | } | 354 | } |
354 | table->setPaintingEnabled( true ); | 355 | table->setPaintingEnabled( true ); |
355 | } | 356 | } |
356 | 357 | ||
357 | void TodoWindow::populateCategories() | 358 | void TodoWindow::populateCategories() |
358 | { | 359 | { |
359 | catMenu->clear(); | 360 | catMenu->clear(); |
360 | 361 | ||
362 | QList<QWidget> list; | ||
363 | list.append(table ); | ||
364 | OFontMenu *menu = new OFontMenu(this, "menu",list ); | ||
365 | menu->forceSize( table->horizontalHeader(), 10 ); | ||
366 | catMenu->insertItem(tr("Fonts"), menu ); | ||
367 | |||
361 | completedAction->addTo( catMenu ); | 368 | completedAction->addTo( catMenu ); |
362 | completedAction->setOn( table->showCompleted() ); | 369 | completedAction->setOn( table->showCompleted() ); |
363 | showdeadlineAction->addTo( catMenu ); | 370 | showdeadlineAction->addTo( catMenu ); |
364 | showdeadlineAction->setOn( table->showDeadline() ); | 371 | showdeadlineAction->setOn( table->showDeadline() ); |
365 | catMenu->insertSeparator(); | 372 | catMenu->insertSeparator(); |
366 | int id, rememberId; | 373 | int id, rememberId; |
367 | id = 1; | 374 | id = 1; |
368 | catMenu->insertItem( tr( "All Categories" ), id++ ); | 375 | catMenu->insertItem( tr( "All Categories" ), id++ ); |
369 | // catMenu->insertSeparator(); | 376 | // catMenu->insertSeparator(); |
370 | QStringList categories = table->categories(); | 377 | QStringList categories = table->categories(); |
371 | categories.append( tr( "Unfiled" ) ); | 378 | categories.append( tr( "Unfiled" ) ); |
372 | for ( QStringList::Iterator it = categories.begin(); | 379 | for ( QStringList::Iterator it = categories.begin(); |
373 | it != categories.end(); ++it ) { | 380 | it != categories.end(); ++it ) { |
374 | catMenu->insertItem( *it, id ); | 381 | catMenu->insertItem( *it, id ); |
375 | if ( *it == table->showCategory() ) | 382 | if ( *it == table->showCategory() ) |
376 | rememberId = id; | 383 | rememberId = id; |
377 | ++id; | 384 | ++id; |
378 | } | 385 | } |
379 | if ( table->showCategory().isEmpty() ) | 386 | if ( table->showCategory().isEmpty() ) |
380 | setCategory( 1 ); | 387 | setCategory( 1 ); |
381 | else | 388 | else |
382 | setCategory( rememberId ); | 389 | setCategory( rememberId ); |
383 | } | 390 | } |
384 | 391 | ||
385 | void TodoWindow::reload() | 392 | void TodoWindow::reload() |
386 | { | 393 | { |
387 | table->clear(); | 394 | table->clear(); |
388 | table->load( todolistXMLFilename() ); | 395 | table->load( todolistXMLFilename() ); |
389 | syncing = FALSE; | 396 | syncing = FALSE; |
390 | } | 397 | } |
391 | 398 | ||
392 | void TodoWindow::flush() | 399 | void TodoWindow::flush() |
393 | { | 400 | { |
394 | syncing = TRUE; | 401 | syncing = TRUE; |
395 | table->save( todolistXMLFilename() ); | 402 | table->save( todolistXMLFilename() ); |
396 | } | 403 | } |
397 | 404 | ||
398 | void TodoWindow::closeEvent( QCloseEvent *e ) | 405 | void TodoWindow::closeEvent( QCloseEvent *e ) |
399 | { | 406 | { |
400 | if(syncing) { | 407 | if(syncing) { |
401 | /* no need to save if in the middle of syncing */ | 408 | /* no need to save if in the middle of syncing */ |
402 | e->accept(); | 409 | e->accept(); |
403 | return; | 410 | return; |
404 | } | 411 | } |
405 | 412 | ||
406 | if ( table->save( todolistXMLFilename() ) ) { | 413 | if ( table->save( todolistXMLFilename() ) ) { |
407 | e->accept(); | 414 | e->accept(); |
408 | // repeat for categories... | 415 | // repeat for categories... |
409 | // if writing configs fail, it will emit an | 416 | // if writing configs fail, it will emit an |
410 | // error, but I feel that it is "ok" for us to exit | 417 | // error, but I feel that it is "ok" for us to exit |
411 | // espically since we aren't told if the write succeeded... | 418 | // espically since we aren't told if the write succeeded... |
412 | Config config( "todo" ); | 419 | Config config( "todo" ); |
413 | config.setGroup( "View" ); | 420 | config.setGroup( "View" ); |
414 | config.writeEntry( "ShowComplete", table->showCompleted() ); | 421 | config.writeEntry( "ShowComplete", table->showCompleted() ); |
415 | config.writeEntry( "Category", table->showCategory() ); | 422 | config.writeEntry( "Category", table->showCategory() ); |
416 | /* added 20.01.2k2 by se */ | 423 | /* added 20.01.2k2 by se */ |
417 | config.writeEntry( "ShowDeadLine", table->showDeadline()); | 424 | config.writeEntry( "ShowDeadLine", table->showDeadline()); |
418 | } else { | 425 | } else { |
419 | if ( QMessageBox::critical( this, tr("Out of space"), | 426 | if ( QMessageBox::critical( this, tr("Out of space"), |
420 | tr("Todo was unable\n" | 427 | tr("Todo was unable\n" |
421 | "to save your changes.\n" | 428 | "to save your changes.\n" |
422 | "Free up some space\n" | 429 | "Free up some space\n" |
423 | "and try again.\n" | 430 | "and try again.\n" |
424 | "\nQuit Anyway?"), | 431 | "\nQuit Anyway?"), |
425 | QMessageBox::Yes|QMessageBox::Escape, | 432 | QMessageBox::Yes|QMessageBox::Escape, |
426 | QMessageBox::No|QMessageBox::Default) | 433 | QMessageBox::No|QMessageBox::Default) |
427 | != QMessageBox::No ) | 434 | != QMessageBox::No ) |
428 | e->accept(); | 435 | e->accept(); |
429 | else | 436 | else |
430 | e->ignore(); | 437 | e->ignore(); |
431 | } | 438 | } |
432 | } | 439 | } |
433 | 440 | ||
434 | void TodoWindow::slotFind() | 441 | void TodoWindow::slotFind() |
435 | { | 442 | { |
436 | // put everything back to view all for searching... | 443 | // put everything back to view all for searching... |
437 | if ( !catMenu->isItemChecked( 0 ) ) | 444 | if ( !catMenu->isItemChecked( 0 ) ) |
438 | setCategory( 0 ); | 445 | setCategory( 0 ); |
439 | 446 | ||
440 | FindDialog dlg( "Todo List", this ); | 447 | FindDialog dlg( "Todo List", this ); |
441 | QObject::connect( &dlg, | 448 | QObject::connect( &dlg, |
442 | SIGNAL(signalFindClicked(const QString &, | 449 | SIGNAL(signalFindClicked(const QString &, |
443 | bool, bool, int)), | 450 | bool, bool, int)), |
444 | table, | 451 | table, |
445 | SLOT(slotDoFind(const QString&, bool, bool, int)) ); | 452 | SLOT(slotDoFind(const QString&, bool, bool, int)) ); |
446 | QObject::connect( table, SIGNAL(signalNotFound()), &dlg, | 453 | QObject::connect( table, SIGNAL(signalNotFound()), &dlg, |
447 | SLOT(slotNotFound()) ); | 454 | SLOT(slotNotFound()) ); |
448 | QObject::connect( table, SIGNAL(signalWrapAround()), &dlg, | 455 | QObject::connect( table, SIGNAL(signalWrapAround()), &dlg, |
449 | SLOT(slotWrapAround()) ); | 456 | SLOT(slotWrapAround()) ); |
450 | dlg.exec(); | 457 | dlg.exec(); |
451 | if ( table->numSelections() ) | 458 | if ( table->numSelections() ) |
452 | table->clearSelection(); | 459 | table->clearSelection(); |
453 | table->clearFindRow(); | 460 | table->clearFindRow(); |
454 | } | 461 | } |
455 | 462 | ||
456 | 463 | ||
diff --git a/core/pim/todo/mainwindow.h b/core/pim/todo/mainwindow.h index a81c27c..9be7c66 100644 --- a/core/pim/todo/mainwindow.h +++ b/core/pim/todo/mainwindow.h | |||
@@ -1,79 +1,82 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | Copyright (C) 2002 Holger 'zecke' Freyther <freyther@kde.org> | 2 | Copyright (C) 2002 Holger 'zecke' Freyther <freyther@kde.org> |
3 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 3 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
4 | ** | 4 | ** |
5 | ** This file is part of Qtopia and Opi Environment. | 5 | ** This file is part of Qtopia and Opi Environment. |
6 | ** | 6 | ** |
7 | ** This file may be distributed and/or modified under the terms of the | 7 | ** This file may be distributed and/or modified under the terms of the |
8 | ** GNU General Public License version 2 as published by the Free Software | 8 | ** GNU General Public License version 2 as published by the Free Software |
9 | ** Foundation and appearing in the file LICENSE.GPL included in the | 9 | ** Foundation and appearing in the file LICENSE.GPL included in the |
10 | ** packaging of this file. | 10 | ** packaging of this file. |
11 | ** | 11 | ** |
12 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 12 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
13 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 13 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
14 | ** | 14 | ** |
15 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 15 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
16 | ** | 16 | ** |
17 | ** Contact info@trolltech.com if any conditions of this licensing are | 17 | ** Contact info@trolltech.com if any conditions of this licensing are |
18 | ** not clear to you. | 18 | ** not clear to you. |
19 | ** | 19 | ** |
20 | **********************************************************************/ | 20 | **********************************************************************/ |
21 | 21 | ||
22 | #ifndef MAINWINDOW_H | 22 | #ifndef MAINWINDOW_H |
23 | #define MAINWINDOW_H | 23 | #define MAINWINDOW_H |
24 | 24 | ||
25 | #include <qmainwindow.h> | 25 | #include <qmainwindow.h> |
26 | 26 | ||
27 | class TodoTable; | 27 | class TodoTable; |
28 | class QAction; | 28 | class QAction; |
29 | class QPopupMenu; | 29 | class QPopupMenu; |
30 | class Ir; | 30 | class Ir; |
31 | class OFontMenu; | ||
31 | 32 | ||
32 | class TodoWindow : public QMainWindow | 33 | class TodoWindow : public QMainWindow |
33 | { | 34 | { |
34 | Q_OBJECT | 35 | Q_OBJECT |
35 | 36 | ||
36 | public: | 37 | public: |
37 | TodoWindow( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); | 38 | TodoWindow( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); |
38 | ~TodoWindow(); | 39 | ~TodoWindow(); |
39 | 40 | ||
40 | public slots: | 41 | public slots: |
41 | void flush(); | 42 | void flush(); |
42 | void reload(); | 43 | void reload(); |
43 | 44 | ||
44 | protected slots: | 45 | protected slots: |
45 | void slotNew(); | 46 | void slotNew(); |
46 | void slotDelete(); | 47 | void slotDelete(); |
47 | void slotEdit(); | 48 | void slotEdit(); |
48 | void slotShowPopup( const QPoint & ); | 49 | void slotShowPopup( const QPoint & ); |
49 | void showCompleted( bool ); | 50 | void showCompleted( bool ); |
50 | 51 | ||
51 | /* added 20.01.2k2 by se */ | 52 | /* added 20.01.2k2 by se */ |
52 | void showDeadline( bool ); | 53 | void showDeadline( bool ); |
53 | 54 | ||
54 | void currentEntryChanged( int r, int c ); | 55 | void currentEntryChanged( int r, int c ); |
55 | void setCategory( int ); | 56 | void setCategory( int ); |
56 | void slotFind(); | 57 | void slotFind(); |
57 | void setDocument( const QString & ); | 58 | void setDocument( const QString & ); |
58 | void slotBeam(); | 59 | void slotBeam(); |
59 | void beamDone( Ir * ); | 60 | void beamDone( Ir * ); |
60 | 61 | ||
61 | protected: | 62 | protected: |
62 | void closeEvent( QCloseEvent *e ); | 63 | void closeEvent( QCloseEvent *e ); |
63 | 64 | ||
64 | private: | 65 | private: |
65 | void populateCategories(); | 66 | void populateCategories(); |
66 | 67 | ||
67 | private: | 68 | private: |
68 | TodoTable *table; | 69 | TodoTable *table; |
69 | QAction *editAction, | 70 | QAction *editAction, |
70 | *deleteAction, | 71 | *deleteAction, |
71 | *findAction, | 72 | *findAction, |
72 | * completedAction, | 73 | * completedAction, |
73 | *showdeadlineAction ; | 74 | *showdeadlineAction ; |
74 | QPopupMenu *contextMenu, *catMenu; | 75 | QPopupMenu *contextMenu, *catMenu; |
75 | 76 | ||
76 | bool syncing; | 77 | bool syncing; |
77 | }; | 78 | }; |
78 | 79 | ||
79 | #endif | 80 | #endif |
81 | |||
82 | |||