summaryrefslogtreecommitdiff
path: root/core/pim/todo/mainwindow.cpp
Unidiff
Diffstat (limited to 'core/pim/todo/mainwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/todo/mainwindow.cpp106
1 files changed, 87 insertions, 19 deletions
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp
index b5cace9..883d78c 100644
--- a/core/pim/todo/mainwindow.cpp
+++ b/core/pim/todo/mainwindow.cpp
@@ -121,43 +121,66 @@ TodoWindow::TodoWindow( QWidget *parent, const char *name, WFlags f = 0 ) :
121 bar->setHorizontalStretchable( TRUE ); 121 bar->setHorizontalStretchable( TRUE );
122 122
123 QPEMenuBar *mb = new QPEMenuBar( bar ); 123 QPEMenuBar *mb = new QPEMenuBar( bar );
124 124
125 catMenu = new QPopupMenu( this ); 125 catMenu = new QPopupMenu( this );
126 QPopupMenu *edit = new QPopupMenu( this ); 126 QPopupMenu *edit = new QPopupMenu( this );
127 QPopupMenu *options = new QPopupMenu(this );
128
127 contextMenu = new QPopupMenu( this ); 129 contextMenu = new QPopupMenu( this );
128 130
129 bar = new QPEToolBar( this ); 131 bar = new QPEToolBar( this );
130 132
131 QAction *a = new QAction( tr( "New Task" ), Resource::loadPixmap( "new" ), 133 QAction *a = new QAction( tr( "New Task" ), Resource::loadPixmap( "new" ),
132 QString::null, 0, this, 0 ); 134 QString::null, 0, this, 0 );
133 connect( a, SIGNAL( activated() ), 135 connect( a, SIGNAL( activated() ),
134 this, SLOT( slotNew() ) ); 136 this, SLOT( slotNew() ) );
135 a->addTo( bar ); 137 a->addTo( bar );
136 a->addTo( edit ); 138 a->addTo( edit );
137 139
138 a = new QAction( tr( "Edit" ), Resource::loadIconSet( "edit" ), 140 a = new QAction( tr( "Edit Task" ), Resource::loadIconSet( "edit" ),
139 QString::null, 0, this, 0 ); 141 QString::null, 0, this, 0 );
140 connect( a, SIGNAL( activated() ), 142 connect( a, SIGNAL( activated() ),
141 this, SLOT( slotEdit() ) ); 143 this, SLOT( slotEdit() ) );
142 a->addTo( bar ); 144 a->addTo( bar );
143 a->addTo( edit ); 145 a->addTo( edit );
144 a->addTo( contextMenu ); 146 a->addTo( contextMenu );
145 a->setEnabled( FALSE ); 147 a->setEnabled( FALSE );
146 editAction = a; 148 editAction = a;
149 edit->insertSeparator();
147 150
148 a = new QAction( tr( "Delete" ), Resource::loadIconSet( "trash" ), 151 a = new QAction( tr( "Delete..." ), Resource::loadIconSet( "trash" ),
149 QString::null, 0, this, 0 ); 152 QString::null, 0, this, 0 );
150 connect( a, SIGNAL( activated() ), 153 connect( a, SIGNAL( activated() ),
151 this, SLOT( slotDelete() ) ); 154 this, SLOT( slotDelete() ) );
152 a->addTo( bar ); 155 a->addTo( bar );
153 a->addTo( edit ); 156 a->addTo( edit );
154 a->addTo( contextMenu ); 157 a->addTo( contextMenu );
155 a->setEnabled( FALSE ); 158 a->setEnabled( FALSE );
156 deleteAction = a; 159 deleteAction = a;
157 160
161 // delete All in category is missing....
162 // set All Done
163 // set All Done in category
164
165 a = new QAction( QString::null, tr( "Delete all..."), 0, this, 0 );
166 connect(a, SIGNAL( activated() ),
167 this, SLOT( slotDeleteAll() ) );
168 a->addTo(edit );
169 a->setEnabled( FALSE );
170 deleteAllAction = a;
171
172 edit->insertSeparator();
173 a = new QAction( QString::null, tr("Duplicate" ), 0, this, 0 );
174 connect(a, SIGNAL( activated() ),
175 this, SLOT( slotDuplicate() ) );
176 a->addTo(edit );
177 a->setEnabled( FALSE );
178 duplicateAction = a;
179
180 edit->insertSeparator();
158 if ( Ir::supported() ) { 181 if ( Ir::supported() ) {
159 a = new QAction( tr( "Beam" ), Resource::loadPixmap( "beam" ), 182 a = new QAction( tr( "Beam" ), Resource::loadPixmap( "beam" ),
160 QString::null, 0, this, 0 ); 183 QString::null, 0, this, 0 );
161 connect( a, SIGNAL( activated() ), 184 connect( a, SIGNAL( activated() ),
162 this, SLOT( slotBeam() ) ); 185 this, SLOT( slotBeam() ) );
163 a->addTo( edit ); 186 a->addTo( edit );
@@ -166,13 +189,15 @@ TodoWindow::TodoWindow( QWidget *parent, const char *name, WFlags f = 0 ) :
166 189
167 a = new QAction( tr( "Find" ), Resource::loadIconSet( "mag" ), 190 a = new QAction( tr( "Find" ), Resource::loadIconSet( "mag" ),
168 QString::null, 0, this, 0 ); 191 QString::null, 0, this, 0 );
169 connect( a, SIGNAL( activated() ), 192 connect( a, SIGNAL( activated() ),
170 this, SLOT( slotFind() ) ); 193 this, SLOT( slotFind() ) );
171 a->addTo( bar ); 194 a->addTo( bar );
172 a->addTo( edit ); 195 a->addTo( options );
196 options->insertSeparator();
197
173 if ( table->numRows() ) 198 if ( table->numRows() )
174 a->setEnabled( TRUE ); 199 a->setEnabled( TRUE );
175 else 200 else
176 a->setEnabled( FALSE ); 201 a->setEnabled( FALSE );
177 202
178 //a->setEnabled( FALSE ); 203 //a->setEnabled( FALSE );
@@ -183,15 +208,30 @@ TodoWindow::TodoWindow( QWidget *parent, const char *name, WFlags f = 0 ) :
183 208
184 showdeadlineAction = new QAction( QString::null, tr( "Show Deadline" ), 0, this, 0, TRUE ); 209 showdeadlineAction = new QAction( QString::null, tr( "Show Deadline" ), 0, this, 0, TRUE );
185 210
186 catMenu->setCheckable( true ); 211 catMenu->setCheckable( true );
187 populateCategories(); 212 populateCategories();
188 213
189 mb->insertItem( tr( "Data" ), edit ); 214
190 mb->insertItem( tr( "View" ), catMenu ); 215 completedAction->addTo( options );
216 completedAction->setOn( table->showCompleted() );
217 showdeadlineAction->addTo( options );
218 showdeadlineAction->setOn( table->showDeadline() );
219 options->insertSeparator( );
220 QList<QWidget> list;
221 list.append(table );
222 OFontMenu *menu = new OFontMenu(this, "menu",list );
223 menu->forceSize( table->horizontalHeader(), 10 );
224 //catMenu->insertItem(tr("Fonts"), menu );
225 list.clear();
226 options->insertItem( tr("Fonts"), menu );
227
191 228
229 mb->insertItem( tr( "Data" ), edit );
230 mb->insertItem( tr( "Category" ), catMenu );
231 mb->insertItem( tr( "Options"), options );
192 resize( 200, 300 ); 232 resize( 200, 300 );
193 if ( table->numRows() > 0 ) 233 if ( table->numRows() > 0 )
194 currentEntryChanged( 0, 0 ); 234 currentEntryChanged( 0, 0 );
195 connect( table, SIGNAL( signalEdit() ), 235 connect( table, SIGNAL( signalEdit() ),
196 this, SLOT( slotEdit() ) ); 236 this, SLOT( slotEdit() ) );
197 connect( table, SIGNAL(signalShowMenu(const QPoint &)), 237 connect( table, SIGNAL(signalShowMenu(const QPoint &)),
@@ -276,12 +316,36 @@ void TodoWindow::slotDelete()
276 316
277 if ( table->numRows() == 0 ) { 317 if ( table->numRows() == 0 ) {
278 currentEntryChanged( -1, 0 ); 318 currentEntryChanged( -1, 0 );
279 findAction->setEnabled( FALSE ); 319 findAction->setEnabled( FALSE );
280 } 320 }
281} 321}
322void TodoWindow::slotDeleteAll()
323{
324 if(syncing) {
325 QMessageBox::warning(this, tr("Todo"),
326 tr("Can not edit data, currently syncing"));
327 return;
328 }
329
330 //QString strName = table->text( table->currentRow(), 2 ).left( 30 );
331
332 if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("Should I delete all tasks?") ) )
333 return;
334
335
336
337 table->setPaintingEnabled( false );
338 table->removeAllEntries();
339 table->setPaintingEnabled( true );
340
341 if ( table->numRows() == 0 ) {
342 currentEntryChanged( -1, 0 );
343 findAction->setEnabled( FALSE );
344 }
345}
282 346
283void TodoWindow::slotEdit() 347void TodoWindow::slotEdit()
284{ 348{
285 if(syncing) { 349 if(syncing) {
286 QMessageBox::warning(this, tr("Todo"), 350 QMessageBox::warning(this, tr("Todo"),
287 tr("Can not edit data, currently syncing")); 351 tr("Can not edit data, currently syncing"));
@@ -304,13 +368,25 @@ void TodoWindow::slotEdit()
304 table->replaceCurrentEntry( todo ); 368 table->replaceCurrentEntry( todo );
305 table->setPaintingEnabled( true ); 369 table->setPaintingEnabled( true );
306 } 370 }
307 populateCategories(); 371 populateCategories();
308 372
309} 373}
310 374void TodoWindow::slotDuplicate()
375{
376 if(syncing) {
377 QMessageBox::warning(this, tr("Todo"),
378 tr("Can not edit data, currently syncing"));
379 return;
380 }
381 ToDoEvent ev = table->currentEntry();
382 ToDoEvent ev2 = ToDoEvent( ev );
383 table->setPaintingEnabled( false );
384 table->addEntry( ev2 );
385 table->setPaintingEnabled( true );
386}
311void TodoWindow::slotShowPopup( const QPoint &p ) 387void TodoWindow::slotShowPopup( const QPoint &p )
312{ 388{
313 contextMenu->popup( p ); 389 contextMenu->popup( p );
314} 390}
315 391
316void TodoWindow::showCompleted( bool s ) 392void TodoWindow::showCompleted( bool s )
@@ -324,15 +400,19 @@ void TodoWindow::showCompleted( bool s )
324 400
325void TodoWindow::currentEntryChanged( int r, int ) 401void TodoWindow::currentEntryChanged( int r, int )
326{ 402{
327 if ( r != -1 && table->rowHeight( r ) > 0 ) { 403 if ( r != -1 && table->rowHeight( r ) > 0 ) {
328 editAction->setEnabled( TRUE ); 404 editAction->setEnabled( TRUE );
329 deleteAction->setEnabled( TRUE ); 405 deleteAction->setEnabled( TRUE );
406 duplicateAction->setEnabled( TRUE );
407 deleteAllAction->setEnabled( TRUE );
330 } else { 408 } else {
331 editAction->setEnabled( FALSE ); 409 editAction->setEnabled( FALSE );
332 deleteAction->setEnabled( FALSE ); 410 deleteAction->setEnabled( FALSE );
411 duplicateAction->setEnabled( FALSE );
412 deleteAllAction->setEnabled( FALSE );
333 } 413 }
334} 414}
335 415
336void TodoWindow::setCategory( int c ) 416void TodoWindow::setCategory( int c )
337{ 417{
338 if ( c <= 0 ) return; 418 if ( c <= 0 ) return;
@@ -355,28 +435,16 @@ void TodoWindow::setCategory( int c )
355 table->setPaintingEnabled( true ); 435 table->setPaintingEnabled( true );
356} 436}
357 437
358void TodoWindow::populateCategories() 438void TodoWindow::populateCategories()
359{ 439{
360 catMenu->clear(); 440 catMenu->clear();
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
368 completedAction->addTo( catMenu );
369 completedAction->setOn( table->showCompleted() );
370 showdeadlineAction->addTo( catMenu );
371 showdeadlineAction->setOn( table->showDeadline() );
372 catMenu->insertSeparator();
373 int id, rememberId; 441 int id, rememberId;
374 id = 1; 442 id = 1;
375 catMenu->insertItem( tr( "All Categories" ), id++ ); 443 catMenu->insertItem( tr( "All Categories" ), id++ );
376// catMenu->insertSeparator(); 444 catMenu->insertSeparator();
377 QStringList categories = table->categories(); 445 QStringList categories = table->categories();
378 categories.append( tr( "Unfiled" ) ); 446 categories.append( tr( "Unfiled" ) );
379 for ( QStringList::Iterator it = categories.begin(); 447 for ( QStringList::Iterator it = categories.begin();
380 it != categories.end(); ++it ) { 448 it != categories.end(); ++it ) {
381 catMenu->insertItem( *it, id ); 449 catMenu->insertItem( *it, id );
382 if ( *it == table->showCategory() ) 450 if ( *it == table->showCategory() )