summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/todo/mainwindow.cpp2
-rw-r--r--libopie/colorpopupmenu.cpp2
2 files changed, 2 insertions, 2 deletions
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp
index 294f37c..5609211 100644
--- a/core/pim/todo/mainwindow.cpp
+++ b/core/pim/todo/mainwindow.cpp
@@ -1,455 +1,455 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** Copyright (C) 2002 zecke 3** Copyright (C) 2002 zecke
4** Copyright (C) 2002 Stefan Eilers (se, eilers.stefan@epost.de) 4** Copyright (C) 2002 Stefan Eilers (se, eilers.stefan@epost.de)
5** 5**
6** This file is part of Qtopia Environment. 6** This file is part of Qtopia Environment.
7** 7**
8** This file may be distributed and/or modified under the terms of the 8** This file may be distributed and/or modified under the terms of the
9** GNU General Public License version 2 as published by the Free Software 9** GNU General Public License version 2 as published by the Free Software
10** Foundation and appearing in the file LICENSE.GPL included in the 10** Foundation and appearing in the file LICENSE.GPL included in the
11** packaging of this file. 11** packaging of this file.
12** 12**
13** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 13** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
14** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 14** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
15** 15**
16** See http://www.trolltech.com/gpl/ for GPL licensing information. 16** See http://www.trolltech.com/gpl/ for GPL licensing information.
17** 17**
18** Contact info@trolltech.com if any conditions of this licensing are 18** Contact info@trolltech.com if any conditions of this licensing are
19** not clear to you. 19** not clear to you.
20** 20**
21**********************************************************************/ 21**********************************************************************/
22 22
23#define QTOPIA_INTERNAL_FD 23#define QTOPIA_INTERNAL_FD
24 24
25#include "mainwindow.h" 25#include "mainwindow.h"
26#include "todoentryimpl.h" 26#include "todoentryimpl.h"
27#include "todotable.h" 27#include "todotable.h"
28#include "todolabel.h" 28#include "todolabel.h"
29 29
30#include <opie/tododb.h> 30#include <opie/tododb.h>
31#include <opie/todovcalresource.h> 31#include <opie/todovcalresource.h>
32#include <opie/ofontmenu.h> 32#include <opie/ofontmenu.h>
33 33
34#include <qpe/qpeapplication.h> 34#include <qpe/qpeapplication.h>
35#include <qpe/config.h> 35#include <qpe/config.h>
36#include <qpe/finddialog.h> 36#include <qpe/finddialog.h>
37#include <qpe/global.h> 37#include <qpe/global.h>
38#include <qpe/ir.h> 38#include <qpe/ir.h>
39#include <qpe/qpemenubar.h> 39#include <qpe/qpemenubar.h>
40#include <qpe/qpemessagebox.h> 40#include <qpe/qpemessagebox.h>
41#include <qpe/resource.h> 41#include <qpe/resource.h>
42//#include <qpe/task.h> 42//#include <qpe/task.h>
43#include <qpe/qpetoolbar.h> 43#include <qpe/qpetoolbar.h>
44 44
45#include <qaction.h> 45#include <qaction.h>
46#include <qarray.h> 46#include <qarray.h>
47#include <qdatastream.h> 47#include <qdatastream.h>
48#include <qdatetime.h> 48#include <qdatetime.h>
49#include <qfile.h> 49#include <qfile.h>
50#include <qmessagebox.h> 50#include <qmessagebox.h>
51#include <qpopupmenu.h> 51#include <qpopupmenu.h>
52#include <qwidgetstack.h> 52#include <qwidgetstack.h>
53 53
54#include <sys/stat.h> 54#include <sys/stat.h>
55#include <sys/types.h> 55#include <sys/types.h>
56#include <fcntl.h> 56#include <fcntl.h>
57#include <unistd.h> 57#include <unistd.h>
58 58
59#include <stdlib.h> 59#include <stdlib.h>
60 60
61static QString todolistXMLFilename() 61static QString todolistXMLFilename()
62{ 62{
63 return Global::applicationFileName("todolist","todolist.xml"); 63 return Global::applicationFileName("todolist","todolist.xml");
64} 64}
65 65
66static QString categoriesXMLFilename() 66static QString categoriesXMLFilename()
67{ 67{
68 return Global::applicationFileName("todolist","categories.xml"); 68 return Global::applicationFileName("todolist","categories.xml");
69} 69}
70 70
71TodoWindow::TodoWindow( QWidget *parent, const char *name, WFlags f = 0 ) : 71TodoWindow::TodoWindow( QWidget *parent, const char *name, WFlags f ) :
72 QMainWindow( parent, name, f ), syncing(FALSE) 72 QMainWindow( parent, name, f ), syncing(FALSE)
73{ 73{
74// QTime t; 74// QTime t;
75// t.start(); 75// t.start();
76 mView = 0l; 76 mView = 0l;
77 mStack = new QWidgetStack(this, "main stack"); 77 mStack = new QWidgetStack(this, "main stack");
78 setCaption( tr("Todo") ); 78 setCaption( tr("Todo") );
79 QString str; 79 QString str;
80 table = new TodoTable( this ); 80 table = new TodoTable( this );
81 table->setColumnWidth( 2, 10 ); 81 table->setColumnWidth( 2, 10 );
82 table->setPaintingEnabled( FALSE ); 82 table->setPaintingEnabled( FALSE );
83 table->setUpdatesEnabled( FALSE ); 83 table->setUpdatesEnabled( FALSE );
84 table->viewport()->setUpdatesEnabled( FALSE ); 84 table->viewport()->setUpdatesEnabled( FALSE );
85 85
86 { 86 {
87 str = todolistXMLFilename(); 87 str = todolistXMLFilename();
88 if ( str.isNull() ) 88 if ( str.isNull() )
89 QMessageBox::critical( this, 89 QMessageBox::critical( this,
90 tr("Out of Space"), 90 tr("Out of Space"),
91 tr("Unable to create startup files\n" 91 tr("Unable to create startup files\n"
92 "Free up some space\n" 92 "Free up some space\n"
93 "before you enter any data") ); 93 "before you enter any data") );
94 else 94 else
95 table->load( str ); 95 table->load( str );
96 } 96 }
97 97
98 // repeat for categories... 98 // repeat for categories...
99 str = categoriesXMLFilename(); 99 str = categoriesXMLFilename();
100 if ( str.isNull() ) 100 if ( str.isNull() )
101 QMessageBox::critical( this, 101 QMessageBox::critical( this,
102 tr( "Out of Space" ), 102 tr( "Out of Space" ),
103 tr( "Unable to create startup files\n" 103 tr( "Unable to create startup files\n"
104 "Free up some space\n" 104 "Free up some space\n"
105 "before you enter any data") ); 105 "before you enter any data") );
106 106
107 mStack->addWidget(table, 1 ); 107 mStack->addWidget(table, 1 );
108 mStack->raiseWidget( 1 ); 108 mStack->raiseWidget( 1 );
109 setCentralWidget( mStack ); 109 setCentralWidget( mStack );
110 setToolBarsMovable( FALSE ); 110 setToolBarsMovable( FALSE );
111 111
112// qDebug("after load: t=%d", t.elapsed() ); 112// qDebug("after load: t=%d", t.elapsed() );
113 113
114 Config config( "todo" ); 114 Config config( "todo" );
115 config.setGroup( "View" ); 115 config.setGroup( "View" );
116 bool complete = config.readBoolEntry( "ShowComplete", true ); 116 bool complete = config.readBoolEntry( "ShowComplete", true );
117 table->setShowCompleted( complete ); 117 table->setShowCompleted( complete );
118 118
119 bool showdeadline = config.readBoolEntry("ShowDeadLine", true); 119 bool showdeadline = config.readBoolEntry("ShowDeadLine", true);
120 table->setShowDeadline (showdeadline); 120 table->setShowDeadline (showdeadline);
121 121
122 QString category = config.readEntry( "Category", QString::null ); 122 QString category = config.readEntry( "Category", QString::null );
123 table->setShowCategory( category ); 123 table->setShowCategory( category );
124 124
125 QPEToolBar *bar = new QPEToolBar( this ); 125 QPEToolBar *bar = new QPEToolBar( this );
126 bar->setHorizontalStretchable( TRUE ); 126 bar->setHorizontalStretchable( TRUE );
127 127
128 QPEMenuBar *mb = new QPEMenuBar( bar ); 128 QPEMenuBar *mb = new QPEMenuBar( bar );
129 129
130 catMenu = new QPopupMenu( this ); 130 catMenu = new QPopupMenu( this );
131 QPopupMenu *edit = new QPopupMenu( this ); 131 QPopupMenu *edit = new QPopupMenu( this );
132 QPopupMenu *options = new QPopupMenu(this ); 132 QPopupMenu *options = new QPopupMenu(this );
133 133
134 contextMenu = new QPopupMenu( this ); 134 contextMenu = new QPopupMenu( this );
135 135
136 bar = new QPEToolBar( this ); 136 bar = new QPEToolBar( this );
137 137
138 QAction *a = new QAction( tr( "New Task" ), Resource::loadPixmap( "new" ), 138 QAction *a = new QAction( tr( "New Task" ), Resource::loadPixmap( "new" ),
139 QString::null, 0, this, 0 ); 139 QString::null, 0, this, 0 );
140 connect( a, SIGNAL( activated() ), 140 connect( a, SIGNAL( activated() ),
141 this, SLOT( slotNew() ) ); 141 this, SLOT( slotNew() ) );
142 a->addTo( bar ); 142 a->addTo( bar );
143 a->addTo( edit ); 143 a->addTo( edit );
144 144
145 a = new QAction( tr( "Edit Task" ), Resource::loadIconSet( "edit" ), 145 a = new QAction( tr( "Edit Task" ), Resource::loadIconSet( "edit" ),
146 QString::null, 0, this, 0 ); 146 QString::null, 0, this, 0 );
147 connect( a, SIGNAL( activated() ), 147 connect( a, SIGNAL( activated() ),
148 this, SLOT( slotEdit() ) ); 148 this, SLOT( slotEdit() ) );
149 a->addTo( bar ); 149 a->addTo( bar );
150 a->addTo( edit ); 150 a->addTo( edit );
151 a->addTo( contextMenu ); 151 a->addTo( contextMenu );
152 a->setEnabled( FALSE ); 152 a->setEnabled( FALSE );
153 editAction = a; 153 editAction = a;
154 154
155 a = new QAction( QString::null, tr("View Task"), 0, this, 0 ); 155 a = new QAction( QString::null, tr("View Task"), 0, this, 0 );
156 a->addTo( edit ); 156 a->addTo( edit );
157 a->addTo( contextMenu ); 157 a->addTo( contextMenu );
158 connect( a, SIGNAL( activated() ), 158 connect( a, SIGNAL( activated() ),
159 this, SLOT(slotShowDetails() ) ); 159 this, SLOT(slotShowDetails() ) );
160 160
161 edit->insertSeparator(); 161 edit->insertSeparator();
162 162
163 a = new QAction( tr( "Delete..." ), Resource::loadIconSet( "trash" ), 163 a = new QAction( tr( "Delete..." ), Resource::loadIconSet( "trash" ),
164 QString::null, 0, this, 0 ); 164 QString::null, 0, this, 0 );
165 connect( a, SIGNAL( activated() ), 165 connect( a, SIGNAL( activated() ),
166 this, SLOT( slotDelete() ) ); 166 this, SLOT( slotDelete() ) );
167 a->addTo( bar ); 167 a->addTo( bar );
168 a->addTo( edit ); 168 a->addTo( edit );
169 a->addTo( contextMenu ); 169 a->addTo( contextMenu );
170 a->setEnabled( FALSE ); 170 a->setEnabled( FALSE );
171 deleteAction = a; 171 deleteAction = a;
172 172
173 // delete All in category is missing.... 173 // delete All in category is missing....
174 // set All Done 174 // set All Done
175 // set All Done in category 175 // set All Done in category
176 176
177 a = new QAction( QString::null, tr( "Delete all..."), 0, this, 0 ); 177 a = new QAction( QString::null, tr( "Delete all..."), 0, this, 0 );
178 connect(a, SIGNAL( activated() ), 178 connect(a, SIGNAL( activated() ),
179 this, SLOT( slotDeleteAll() ) ); 179 this, SLOT( slotDeleteAll() ) );
180 a->addTo(edit ); 180 a->addTo(edit );
181 a->setEnabled( FALSE ); 181 a->setEnabled( FALSE );
182 deleteAllAction = a; 182 deleteAllAction = a;
183 183
184 edit->insertSeparator(); 184 edit->insertSeparator();
185 a = new QAction( QString::null, tr("Duplicate" ), 0, this, 0 ); 185 a = new QAction( QString::null, tr("Duplicate" ), 0, this, 0 );
186 connect(a, SIGNAL( activated() ), 186 connect(a, SIGNAL( activated() ),
187 this, SLOT( slotDuplicate() ) ); 187 this, SLOT( slotDuplicate() ) );
188 a->addTo(edit ); 188 a->addTo(edit );
189 a->setEnabled( FALSE ); 189 a->setEnabled( FALSE );
190 duplicateAction = a; 190 duplicateAction = a;
191 edit->insertSeparator(); 191 edit->insertSeparator();
192 192
193 193
194 194
195 if ( Ir::supported() ) { 195 if ( Ir::supported() ) {
196 a = new QAction( tr( "Beam" ), Resource::loadPixmap( "beam" ), 196 a = new QAction( tr( "Beam" ), Resource::loadPixmap( "beam" ),
197 QString::null, 0, this, 0 ); 197 QString::null, 0, this, 0 );
198 connect( a, SIGNAL( activated() ), 198 connect( a, SIGNAL( activated() ),
199 this, SLOT( slotBeam() ) ); 199 this, SLOT( slotBeam() ) );
200 a->addTo( edit ); 200 a->addTo( edit );
201 a->addTo( bar ); 201 a->addTo( bar );
202 } 202 }
203 203
204 a = new QAction( tr( "Find" ), Resource::loadIconSet( "mag" ), 204 a = new QAction( tr( "Find" ), Resource::loadIconSet( "mag" ),
205 QString::null, 0, this, 0 ); 205 QString::null, 0, this, 0 );
206 connect( a, SIGNAL( activated() ), 206 connect( a, SIGNAL( activated() ),
207 this, SLOT( slotFind() ) ); 207 this, SLOT( slotFind() ) );
208 a->addTo( bar ); 208 a->addTo( bar );
209 a->addTo( options ); 209 a->addTo( options );
210 options->insertSeparator(); 210 options->insertSeparator();
211 211
212 if ( table->numRows() ) 212 if ( table->numRows() )
213 a->setEnabled( TRUE ); 213 a->setEnabled( TRUE );
214 else 214 else
215 a->setEnabled( FALSE ); 215 a->setEnabled( FALSE );
216 216
217 //a->setEnabled( FALSE ); 217 //a->setEnabled( FALSE );
218 findAction = a; 218 findAction = a;
219// qDebug("mainwindow #2: t=%d", t.elapsed() ); 219// qDebug("mainwindow #2: t=%d", t.elapsed() );
220 220
221 completedAction = new QAction( QString::null, tr("Completed tasks"), 0, this, 0, TRUE ); 221 completedAction = new QAction( QString::null, tr("Completed tasks"), 0, this, 0, TRUE );
222 222
223 showdeadlineAction = new QAction( QString::null, tr( "Show Deadline" ), 0, this, 0, TRUE ); 223 showdeadlineAction = new QAction( QString::null, tr( "Show Deadline" ), 0, this, 0, TRUE );
224 224
225 catMenu->setCheckable( true ); 225 catMenu->setCheckable( true );
226 populateCategories(); 226 populateCategories();
227 227
228 228
229 completedAction->addTo( options ); 229 completedAction->addTo( options );
230 completedAction->setOn( table->showCompleted() ); 230 completedAction->setOn( table->showCompleted() );
231 showdeadlineAction->addTo( options ); 231 showdeadlineAction->addTo( options );
232 showdeadlineAction->setOn( table->showDeadline() ); 232 showdeadlineAction->setOn( table->showDeadline() );
233 options->insertSeparator( ); 233 options->insertSeparator( );
234 QList<QWidget> list; 234 QList<QWidget> list;
235 list.append(table ); 235 list.append(table );
236 OFontMenu *menu = new OFontMenu(this, "menu",list ); 236 OFontMenu *menu = new OFontMenu(this, "menu",list );
237 menu->forceSize( table->horizontalHeader(), 10 ); 237 menu->forceSize( table->horizontalHeader(), 10 );
238 //catMenu->insertItem(tr("Fonts"), menu ); 238 //catMenu->insertItem(tr("Fonts"), menu );
239 list.clear(); 239 list.clear();
240 options->insertItem( tr("Fonts"), menu ); 240 options->insertItem( tr("Fonts"), menu );
241 241
242 242
243 mb->insertItem( tr( "Data" ), edit ); 243 mb->insertItem( tr( "Data" ), edit );
244 mb->insertItem( tr( "Category" ), catMenu ); 244 mb->insertItem( tr( "Category" ), catMenu );
245 mb->insertItem( tr( "Options"), options ); 245 mb->insertItem( tr( "Options"), options );
246 resize( 200, 300 ); 246 resize( 200, 300 );
247 if ( table->numRows() > 0 ) 247 if ( table->numRows() > 0 )
248 currentEntryChanged( 0, 0 ); 248 currentEntryChanged( 0, 0 );
249 connect( table, SIGNAL( signalEdit() ), 249 connect( table, SIGNAL( signalEdit() ),
250 this, SLOT( slotEdit() ) ); 250 this, SLOT( slotEdit() ) );
251 connect( table, SIGNAL(signalShowMenu(const QPoint &)), 251 connect( table, SIGNAL(signalShowMenu(const QPoint &)),
252 this, SLOT( slotShowPopup(const QPoint &)) ); 252 this, SLOT( slotShowPopup(const QPoint &)) );
253 253
254// qDebug("mainwindow #3: t=%d", t.elapsed() ); 254// qDebug("mainwindow #3: t=%d", t.elapsed() );
255 table->updateVisible(); 255 table->updateVisible();
256 table->setUpdatesEnabled( TRUE ); 256 table->setUpdatesEnabled( TRUE );
257 table->setPaintingEnabled( TRUE ); 257 table->setPaintingEnabled( TRUE );
258 table->viewport()->setUpdatesEnabled( TRUE ); 258 table->viewport()->setUpdatesEnabled( TRUE );
259 259
260 connect( completedAction, SIGNAL( toggled(bool) ), this, SLOT( showCompleted(bool) ) ); 260 connect( completedAction, SIGNAL( toggled(bool) ), this, SLOT( showCompleted(bool) ) );
261 connect( showdeadlineAction, SIGNAL( toggled(bool) ), this, SLOT( showDeadline(bool) ) ); 261 connect( showdeadlineAction, SIGNAL( toggled(bool) ), this, SLOT( showDeadline(bool) ) );
262 connect( catMenu, SIGNAL(activated(int)), this, SLOT(setCategory(int)) ); 262 connect( catMenu, SIGNAL(activated(int)), this, SLOT(setCategory(int)) );
263 connect( table, SIGNAL( currentChanged( int, int ) ), 263 connect( table, SIGNAL( currentChanged( int, int ) ),
264 this, SLOT( currentEntryChanged( int, int ) ) ); 264 this, SLOT( currentEntryChanged( int, int ) ) );
265 265
266 connect( table, SIGNAL(showDetails(const ToDoEvent &) ), 266 connect( table, SIGNAL(showDetails(const ToDoEvent &) ),
267 this, SLOT(slotShowDetails(const ToDoEvent & ) ) ); 267 this, SLOT(slotShowDetails(const ToDoEvent & ) ) );
268// qDebug("done: t=%d", t.elapsed() ); 268// qDebug("done: t=%d", t.elapsed() );
269} 269}
270 270
271void TodoWindow::slotNew() 271void TodoWindow::slotNew()
272{ 272{
273 if(syncing) { 273 if(syncing) {
274 QMessageBox::warning(this, tr("Todo"), 274 QMessageBox::warning(this, tr("Todo"),
275 tr("Can not edit data, currently syncing")); 275 tr("Can not edit data, currently syncing"));
276 return; 276 return;
277 } 277 }
278 278
279 int id; 279 int id;
280 id = -1; 280 id = -1;
281 QArray<int> ids; 281 QArray<int> ids;
282 ids = table->currentEntry().categories(); 282 ids = table->currentEntry().categories();
283 if ( ids.count() ) 283 if ( ids.count() )
284 id = ids[0]; 284 id = ids[0];
285 NewTaskDialog e( id, this, 0, TRUE ); 285 NewTaskDialog e( id, this, 0, TRUE );
286 286
287 ToDoEvent todo; 287 ToDoEvent todo;
288 288
289#if defined(Q_WS_QWS) || defined(_WS_QWS_) 289#if defined(Q_WS_QWS) || defined(_WS_QWS_)
290 e.showMaximized(); 290 e.showMaximized();
291#endif 291#endif
292 int ret = e.exec(); 292 int ret = e.exec();
293// qWarning("finished" ); 293// qWarning("finished" );
294 if ( ret == QDialog::Accepted ) { 294 if ( ret == QDialog::Accepted ) {
295 table->setPaintingEnabled( false ); 295 table->setPaintingEnabled( false );
296 todo = e.todoEntry(); 296 todo = e.todoEntry();
297 //todo.assignUid(); 297 //todo.assignUid();
298 table->addEntry( todo ); 298 table->addEntry( todo );
299 table->setPaintingEnabled( true ); 299 table->setPaintingEnabled( true );
300 findAction->setEnabled( TRUE ); 300 findAction->setEnabled( TRUE );
301 } 301 }
302 // I'm afraid we must call this every time now, otherwise 302 // I'm afraid we must call this every time now, otherwise
303 // spend expensive time comparing all these strings... 303 // spend expensive time comparing all these strings...
304 populateCategories(); 304 populateCategories();
305 mStack->raiseWidget(1 ); 305 mStack->raiseWidget(1 );
306} 306}
307 307
308TodoWindow::~TodoWindow() 308TodoWindow::~TodoWindow()
309{ 309{
310} 310}
311 311
312void TodoWindow::slotDelete() 312void TodoWindow::slotDelete()
313{ 313{
314 if(syncing) { 314 if(syncing) {
315 QMessageBox::warning(this, tr("Todo"), 315 QMessageBox::warning(this, tr("Todo"),
316 tr("Can not edit data, currently syncing")); 316 tr("Can not edit data, currently syncing"));
317 return; 317 return;
318 } 318 }
319 319
320 if ( table->currentRow() == -1 ) 320 if ( table->currentRow() == -1 )
321 return; 321 return;
322 322
323 QString strName = table->text( table->currentRow(), 2 ).left( 30 ); 323 QString strName = table->text( table->currentRow(), 2 ).left( 30 );
324 324
325 if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), strName ) ) 325 if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), strName ) )
326 return; 326 return;
327 327
328 328
329 329
330 table->setPaintingEnabled( false ); 330 table->setPaintingEnabled( false );
331 table->removeCurrentEntry(); 331 table->removeCurrentEntry();
332 table->setPaintingEnabled( true ); 332 table->setPaintingEnabled( true );
333 333
334 if ( table->numRows() == 0 ) { 334 if ( table->numRows() == 0 ) {
335 currentEntryChanged( -1, 0 ); 335 currentEntryChanged( -1, 0 );
336 findAction->setEnabled( FALSE ); 336 findAction->setEnabled( FALSE );
337 } 337 }
338 mStack->raiseWidget(1); 338 mStack->raiseWidget(1);
339} 339}
340void TodoWindow::slotDeleteAll() 340void TodoWindow::slotDeleteAll()
341{ 341{
342 if(syncing) { 342 if(syncing) {
343 QMessageBox::warning(this, tr("Todo"), 343 QMessageBox::warning(this, tr("Todo"),
344 tr("Can not edit data, currently syncing")); 344 tr("Can not edit data, currently syncing"));
345 return; 345 return;
346 } 346 }
347 347
348 //QString strName = table->text( table->currentRow(), 2 ).left( 30 ); 348 //QString strName = table->text( table->currentRow(), 2 ).left( 30 );
349 349
350 if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("Delete all tasks?") ) ) 350 if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("Delete all tasks?") ) )
351 return; 351 return;
352 352
353 353
354 354
355 table->setPaintingEnabled( false ); 355 table->setPaintingEnabled( false );
356 table->removeAllEntries(); 356 table->removeAllEntries();
357 table->setPaintingEnabled( true ); 357 table->setPaintingEnabled( true );
358 358
359 if ( table->numRows() == 0 ) { 359 if ( table->numRows() == 0 ) {
360 currentEntryChanged( -1, 0 ); 360 currentEntryChanged( -1, 0 );
361 findAction->setEnabled( FALSE ); 361 findAction->setEnabled( FALSE );
362 } 362 }
363 mStack->raiseWidget(1 ); 363 mStack->raiseWidget(1 );
364} 364}
365 365
366void TodoWindow::slotEdit() 366void TodoWindow::slotEdit()
367{ 367{
368 if(syncing) { 368 if(syncing) {
369 QMessageBox::warning(this, tr("Todo"), 369 QMessageBox::warning(this, tr("Todo"),
370 tr("Can not edit data, currently syncing")); 370 tr("Can not edit data, currently syncing"));
371 return; 371 return;
372 } 372 }
373 373
374 ToDoEvent todo = table->currentEntry(); 374 ToDoEvent todo = table->currentEntry();
375 qWarning("slotEdit" ); 375 qWarning("slotEdit" );
376 NewTaskDialog e( todo, this, 0, TRUE ); 376 NewTaskDialog e( todo, this, 0, TRUE );
377 e.setCaption( tr( "Edit Task" ) ); 377 e.setCaption( tr( "Edit Task" ) );
378 378
379#if defined(Q_WS_QWS) || defined(_WS_QWS_) 379#if defined(Q_WS_QWS) || defined(_WS_QWS_)
380 e.showMaximized(); 380 e.showMaximized();
381#endif 381#endif
382 int ret = e.exec(); 382 int ret = e.exec();
383 383
384 if ( ret == QDialog::Accepted ) { 384 if ( ret == QDialog::Accepted ) {
385 qWarning("Replacing now" ); 385 qWarning("Replacing now" );
386 table->setPaintingEnabled( false ); 386 table->setPaintingEnabled( false );
387 todo = e.todoEntry(); 387 todo = e.todoEntry();
388 table->replaceCurrentEntry( todo ); 388 table->replaceCurrentEntry( todo );
389 table->setPaintingEnabled( true ); 389 table->setPaintingEnabled( true );
390 } 390 }
391 populateCategories(); 391 populateCategories();
392 mStack->raiseWidget( 1 ); 392 mStack->raiseWidget( 1 );
393} 393}
394void TodoWindow::slotDuplicate() 394void TodoWindow::slotDuplicate()
395{ 395{
396 if(syncing) { 396 if(syncing) {
397 QMessageBox::warning(this, tr("Todo"), 397 QMessageBox::warning(this, tr("Todo"),
398 tr("Can not edit data, currently syncing")); 398 tr("Can not edit data, currently syncing"));
399 return; 399 return;
400 } 400 }
401 ToDoEvent ev = table->currentEntry(); 401 ToDoEvent ev = table->currentEntry();
402 ToDoEvent ev2 = ToDoEvent( ev ); // what about the uid 402 ToDoEvent ev2 = ToDoEvent( ev ); // what about the uid
403 int uid; 403 int uid;
404 { // uid 404 { // uid
405 Qtopia::UidGen *uidgen = new Qtopia::UidGen(); 405 Qtopia::UidGen *uidgen = new Qtopia::UidGen();
406 uid = uidgen->generate(); 406 uid = uidgen->generate();
407 delete uidgen; 407 delete uidgen;
408 } 408 }
409 ev2.setUid( uid ); 409 ev2.setUid( uid );
410 table->setPaintingEnabled( false ); 410 table->setPaintingEnabled( false );
411 table->addEntry( ev2 ); 411 table->addEntry( ev2 );
412 table->setPaintingEnabled( true ); 412 table->setPaintingEnabled( true );
413 413
414 mStack->raiseWidget( 1 ); 414 mStack->raiseWidget( 1 );
415} 415}
416void TodoWindow::slotShowPopup( const QPoint &p ) 416void TodoWindow::slotShowPopup( const QPoint &p )
417{ 417{
418 contextMenu->popup( p ); 418 contextMenu->popup( p );
419} 419}
420 420
421void TodoWindow::showCompleted( bool s ) 421void TodoWindow::showCompleted( bool s )
422{ 422{
423 if ( !table->isUpdatesEnabled() ) 423 if ( !table->isUpdatesEnabled() )
424 return; 424 return;
425 table->setPaintingEnabled( false ); 425 table->setPaintingEnabled( false );
426 table->setShowCompleted( s ); 426 table->setShowCompleted( s );
427 table->setPaintingEnabled( true ); 427 table->setPaintingEnabled( true );
428 mStack->raiseWidget( 1 ); 428 mStack->raiseWidget( 1 );
429} 429}
430 430
431void TodoWindow::currentEntryChanged( int r, int ) 431void TodoWindow::currentEntryChanged( int r, int )
432{ 432{
433 if ( r != -1 && table->rowHeight( r ) > 0 ) { 433 if ( r != -1 && table->rowHeight( r ) > 0 ) {
434 editAction->setEnabled( TRUE ); 434 editAction->setEnabled( TRUE );
435 deleteAction->setEnabled( TRUE ); 435 deleteAction->setEnabled( TRUE );
436 duplicateAction->setEnabled( TRUE ); 436 duplicateAction->setEnabled( TRUE );
437 deleteAllAction->setEnabled( TRUE ); 437 deleteAllAction->setEnabled( TRUE );
438 } else { 438 } else {
439 editAction->setEnabled( FALSE ); 439 editAction->setEnabled( FALSE );
440 deleteAction->setEnabled( FALSE ); 440 deleteAction->setEnabled( FALSE );
441 duplicateAction->setEnabled( FALSE ); 441 duplicateAction->setEnabled( FALSE );
442 deleteAllAction->setEnabled( FALSE ); 442 deleteAllAction->setEnabled( FALSE );
443 } 443 }
444} 444}
445 445
446void TodoWindow::setCategory( int c ) 446void TodoWindow::setCategory( int c )
447{ 447{
448 if ( c <= 0 ) return; 448 if ( c <= 0 ) return;
449 if ( !table->isUpdatesEnabled() ) 449 if ( !table->isUpdatesEnabled() )
450 return; 450 return;
451 table->setPaintingEnabled( false ); 451 table->setPaintingEnabled( false );
452 for ( unsigned int i = 1; i < catMenu->count(); i++ ) 452 for ( unsigned int i = 1; i < catMenu->count(); i++ )
453 catMenu->setItemChecked( i, c == (int)i ); 453 catMenu->setItemChecked( i, c == (int)i );
454 if ( c == 1 ) { 454 if ( c == 1 ) {
455 table->setShowCategory( QString::null ); 455 table->setShowCategory( QString::null );
diff --git a/libopie/colorpopupmenu.cpp b/libopie/colorpopupmenu.cpp
index 9b50a8b..17e2c0a 100644
--- a/libopie/colorpopupmenu.cpp
+++ b/libopie/colorpopupmenu.cpp
@@ -1,165 +1,165 @@
1/********************************************************************** 1/**********************************************************************
2** ColorPopupMenu 2** ColorPopupMenu
3** 3**
4** Popup menu for selecting colors 4** Popup menu for selecting colors
5** 5**
6** Based on colorpanel by S. Prud'homme <prudhomme@laposte.net> 6** Based on colorpanel by S. Prud'homme <prudhomme@laposte.net>
7** 7**
8** Copyright (C) 2002, Dan Williams 8** Copyright (C) 2002, Dan Williams
9** williamsdr@acm.org 9** williamsdr@acm.org
10** http://draknor.net 10** http://draknor.net
11** 11**
12** This file may be distributed and/or modified under the terms of the 12** This file may be distributed and/or modified under the terms of the
13** GNU General Public License version 2 as published by the Free Software 13** GNU General Public License version 2 as published by the Free Software
14** Foundation and appearing in the file LICENSE.GPL included in the 14** Foundation and appearing in the file LICENSE.GPL included in the
15** packaging of this file. 15** packaging of this file.
16** 16**
17** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 17** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
18** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 18** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19** 19**
20**********************************************************************/ 20**********************************************************************/
21 21
22#include "colorpopupmenu.h" 22#include "colorpopupmenu.h"
23#include "colordialog.h" 23#include "colordialog.h"
24 24
25#include <qaction.h> 25#include <qaction.h>
26#include <qlayout.h> 26#include <qlayout.h>
27#include <qpainter.h> 27#include <qpainter.h>
28 28
29ColorPanelButton::ColorPanelButton( const QColor& color, QWidget* parent, const char* name ) 29ColorPanelButton::ColorPanelButton( const QColor& color, QWidget* parent, const char* name )
30 : QFrame( parent, name ) 30 : QFrame( parent, name )
31{ 31{
32 m_color = color; 32 m_color = color;
33 33
34 setFixedSize( 16, 16 ); 34 setFixedSize( 16, 16 );
35 setActive( FALSE ); 35 setActive( FALSE );
36} 36}
37 37
38ColorPanelButton::~ColorPanelButton() 38ColorPanelButton::~ColorPanelButton()
39{ 39{
40} 40}
41 41
42void ColorPanelButton::setActive( bool active ) 42void ColorPanelButton::setActive( bool active )
43{ 43{
44 m_active = active; 44 m_active = active;
45 45
46 if ( m_active ) { 46 if ( m_active ) {
47 setFrameStyle( Panel | Sunken ); 47 setFrameStyle( Panel | Sunken );
48 } else { 48 } else {
49 setFrameStyle( NoFrame ); 49 setFrameStyle( NoFrame );
50 } 50 }
51} 51}
52 52
53void ColorPanelButton::enterEvent( QEvent* e ) 53void ColorPanelButton::enterEvent( QEvent* e )
54{ 54{
55 Q_UNUSED( e ) 55 Q_UNUSED( e )
56 56
57 if ( !m_active ) { 57 if ( !m_active ) {
58 setFrameStyle( Panel | Sunken ); 58 setFrameStyle( Panel | Sunken );
59 } 59 }
60} 60}
61 61
62void ColorPanelButton::leaveEvent( QEvent* e ) 62void ColorPanelButton::leaveEvent( QEvent* e )
63{ 63{
64 Q_UNUSED( e ) 64 Q_UNUSED( e )
65 65
66 if ( !m_active ) { 66 if ( !m_active ) {
67 setFrameStyle( NoFrame ); 67 setFrameStyle( NoFrame );
68 } 68 }
69} 69}
70 70
71void ColorPanelButton::paintEvent( QPaintEvent* e ) 71void ColorPanelButton::paintEvent( QPaintEvent* e )
72{ 72{
73 QFrame::paintEvent( e ); 73 QFrame::paintEvent( e );
74 74
75 QPainter painter; 75 QPainter painter;
76 painter.begin( this ); 76 painter.begin( this );
77 painter.fillRect( 2, 2, 12, 12, m_color ); 77 painter.fillRect( 2, 2, 12, 12, m_color );
78 painter.setPen( Qt::black ); 78 painter.setPen( Qt::black );
79 painter.drawRect( 2, 2, 12, 12 ); 79 painter.drawRect( 2, 2, 12, 12 );
80 painter.end(); 80 painter.end();
81} 81}
82 82
83void ColorPanelButton::mouseReleaseEvent( QMouseEvent* e ) 83void ColorPanelButton::mouseReleaseEvent( QMouseEvent* e )
84{ 84{
85 Q_UNUSED( e ) 85 Q_UNUSED( e )
86 86
87 emit selected( m_color ); 87 emit selected( m_color );
88} 88}
89 89
90ColorPopupMenu::ColorPopupMenu( const QColor& color, QWidget* parent = 0, const char* name = 0 ) 90ColorPopupMenu::ColorPopupMenu( const QColor& color, QWidget* parent, const char* name )
91 : QPopupMenu( parent, name ) 91 : QPopupMenu( parent, name )
92{ 92{
93 m_color = color; 93 m_color = color;
94 94
95 colorPanel = new QWidget( this ); 95 colorPanel = new QWidget( this );
96 96
97 colorLayout = new QGridLayout(colorPanel, 5, 6); 97 colorLayout = new QGridLayout(colorPanel, 5, 6);
98 98
99 addColor(QColor(255, 255, 255), 0, 1); 99 addColor(QColor(255, 255, 255), 0, 1);
100 addColor(QColor(192, 192, 192), 0, 2); 100 addColor(QColor(192, 192, 192), 0, 2);
101 addColor(QColor(128, 128, 128), 0, 3); 101 addColor(QColor(128, 128, 128), 0, 3);
102 addColor(QColor(64, 64, 64), 0, 4); 102 addColor(QColor(64, 64, 64), 0, 4);
103 addColor(QColor(0, 0, 0), 0, 5); 103 addColor(QColor(0, 0, 0), 0, 5);
104 104
105 addColor(QColor(255, 0, 0), 1, 0); 105 addColor(QColor(255, 0, 0), 1, 0);
106 addColor(QColor(255, 128, 0), 1, 1); 106 addColor(QColor(255, 128, 0), 1, 1);
107 addColor(QColor(255, 255, 0), 1, 2); 107 addColor(QColor(255, 255, 0), 1, 2);
108 addColor(QColor(128, 255, 0), 1, 3); 108 addColor(QColor(128, 255, 0), 1, 3);
109 addColor(QColor(0, 255, 0), 1, 4); 109 addColor(QColor(0, 255, 0), 1, 4);
110 addColor(QColor(0, 255, 128), 1, 5); 110 addColor(QColor(0, 255, 128), 1, 5);
111 111
112 addColor(QColor(128, 0, 0), 2, 0); 112 addColor(QColor(128, 0, 0), 2, 0);
113 addColor(QColor(128, 64, 0), 2, 1); 113 addColor(QColor(128, 64, 0), 2, 1);
114 addColor(QColor(128, 128, 0), 2, 2); 114 addColor(QColor(128, 128, 0), 2, 2);
115 addColor(QColor(64, 128, 0), 2, 3); 115 addColor(QColor(64, 128, 0), 2, 3);
116 addColor(QColor(0, 128, 0), 2, 4); 116 addColor(QColor(0, 128, 0), 2, 4);
117 addColor(QColor(0, 128, 64), 2, 5); 117 addColor(QColor(0, 128, 64), 2, 5);
118 118
119 addColor(QColor(0, 255, 255), 3, 0); 119 addColor(QColor(0, 255, 255), 3, 0);
120 addColor(QColor(0, 128, 255), 3, 1); 120 addColor(QColor(0, 128, 255), 3, 1);
121 addColor(QColor(0, 0, 255), 3, 2); 121 addColor(QColor(0, 0, 255), 3, 2);
122 addColor(QColor(128, 0, 255), 3, 3); 122 addColor(QColor(128, 0, 255), 3, 3);
123 addColor(QColor(255, 0, 255), 3, 4); 123 addColor(QColor(255, 0, 255), 3, 4);
124 addColor(QColor(255, 0, 128), 3, 5); 124 addColor(QColor(255, 0, 128), 3, 5);
125 125
126 addColor(QColor(0, 128, 128), 4, 0); 126 addColor(QColor(0, 128, 128), 4, 0);
127 addColor(QColor(0, 64, 128), 4, 1); 127 addColor(QColor(0, 64, 128), 4, 1);
128 addColor(QColor(0, 0, 128), 4, 2); 128 addColor(QColor(0, 0, 128), 4, 2);
129 addColor(QColor(64, 0, 128), 4, 3); 129 addColor(QColor(64, 0, 128), 4, 3);
130 addColor(QColor(128, 0, 128), 4, 4); 130 addColor(QColor(128, 0, 128), 4, 4);
131 addColor(QColor(128, 0, 64), 4, 5); 131 addColor(QColor(128, 0, 64), 4, 5);
132 132
133 insertItem( colorPanel ); 133 insertItem( colorPanel );
134 insertSeparator(); 134 insertSeparator();
135 QAction* chooseColorAction = new QAction( tr( "More" ), tr( "More..." ), 0, colorPanel, "More" ); 135 QAction* chooseColorAction = new QAction( tr( "More" ), tr( "More..." ), 0, colorPanel, "More" );
136 connect( chooseColorAction, SIGNAL( activated() ), this, SLOT( moreColorClicked() ) ); 136 connect( chooseColorAction, SIGNAL( activated() ), this, SLOT( moreColorClicked() ) );
137 chooseColorAction->addTo( this ); 137 chooseColorAction->addTo( this );
138 activateItemAt( 0 ); 138 activateItemAt( 0 );
139} 139}
140 140
141ColorPopupMenu::~ColorPopupMenu() 141ColorPopupMenu::~ColorPopupMenu()
142{ 142{
143} 143}
144 144
145void ColorPopupMenu::addColor( const QColor& color, int row, int col ) 145void ColorPopupMenu::addColor( const QColor& color, int row, int col )
146{ 146{
147 ColorPanelButton* panelButton = new ColorPanelButton( color, colorPanel ); 147 ColorPanelButton* panelButton = new ColorPanelButton( color, colorPanel );
148 connect( panelButton, SIGNAL( selected( const QColor& ) ), this, SLOT( buttonSelected( const QColor& ) ) ); 148 connect( panelButton, SIGNAL( selected( const QColor& ) ), this, SLOT( buttonSelected( const QColor& ) ) );
149 colorLayout->addWidget( panelButton, row, col ); 149 colorLayout->addWidget( panelButton, row, col );
150} 150}
151 151
152void ColorPopupMenu::buttonSelected( const QColor& color ) 152void ColorPopupMenu::buttonSelected( const QColor& color )
153{ 153{
154 m_color = color; 154 m_color = color;
155 emit colorSelected( color ); 155 emit colorSelected( color );
156 hide(); 156 hide();
157} 157}
158 158
159void ColorPopupMenu::moreColorClicked() 159void ColorPopupMenu::moreColorClicked()
160{ 160{
161 QColor color = OColorDialog::getColor( m_color ); 161 QColor color = OColorDialog::getColor( m_color );
162 m_color = color; 162 m_color = color;
163 emit colorSelected( color ); 163 emit colorSelected( color );
164 hide(); 164 hide();
165} 165}