summaryrefslogtreecommitdiff
authordrw <drw>2002-12-21 17:29:01 (UTC)
committer drw <drw>2002-12-21 17:29:01 (UTC)
commit491ac1e10a2caceb5003b0649f0cb0131e9b81fd (patch) (unidiff)
tree17e44a870b7ccb3ea200d370ebf782bb64d53fb5
parent4700aa526ff4869486c23b3cfddcfa9b39ef9ae4 (diff)
downloadopie-491ac1e10a2caceb5003b0649f0cb0131e9b81fd.zip
opie-491ac1e10a2caceb5003b0649f0cb0131e9b81fd.tar.gz
opie-491ac1e10a2caceb5003b0649f0cb0131e9b81fd.tar.bz2
Main task view updates.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/todo/mainwindow.cpp6
-rw-r--r--core/pim/todo/mainwindow.h7
-rw-r--r--core/pim/todo/quickeditimpl.cpp2
-rw-r--r--core/pim/todo/tableview.cpp133
-rw-r--r--core/pim/todo/tableview.h4
5 files changed, 75 insertions, 77 deletions
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp
index f0aa455..0ccf73e 100644
--- a/core/pim/todo/mainwindow.cpp
+++ b/core/pim/todo/mainwindow.cpp
@@ -205,20 +205,18 @@ void MainWindow::initConfig() {
205 config.setGroup( "View" ); 205 config.setGroup( "View" );
206 m_completed = config.readBoolEntry( "ShowComplete", TRUE ); 206 m_completed = config.readBoolEntry( "ShowComplete", TRUE );
207 m_curCat = config.readEntry( "Category", QString::null ); 207 m_curCat = config.readEntry( "Category", QString::null );
208 m_deadline = config.readBoolEntry( "ShowDeadLine", TRUE); 208 m_deadline = config.readBoolEntry( "ShowDeadLine", TRUE);
209 m_overdue = config.readBoolEntry("ShowOverDue", FALSE ); 209 m_overdue = config.readBoolEntry("ShowOverDue", FALSE );
210 m_quicktask = config.readBoolEntry("ShowQuickTask", TRUE); 210 m_quicktask = config.readBoolEntry("ShowQuickTask", TRUE);
211} 211}
212void MainWindow::initUI() { 212void MainWindow::initUI() {
213 m_mainBox = new QVBox(this, "main box "); 213 m_stack = new QWidgetStack(this, "main stack");
214 214 setCentralWidget( m_stack );
215 m_stack = new QWidgetStack(m_mainBox, "main stack");
216 setCentralWidget( m_mainBox );
217 215
218 setToolBarsMovable( FALSE ); 216 setToolBarsMovable( FALSE );
219 217
220 m_tool = new QPEToolBar( this ); 218 m_tool = new QPEToolBar( this );
221 m_tool->setHorizontalStretchable( TRUE ); 219 m_tool->setHorizontalStretchable( TRUE );
222 220
223 m_bar = new QMenuBar( m_tool ); 221 m_bar = new QMenuBar( m_tool );
224 222
diff --git a/core/pim/todo/mainwindow.h b/core/pim/todo/mainwindow.h
index 86b9ac2..d756d64 100644
--- a/core/pim/todo/mainwindow.h
+++ b/core/pim/todo/mainwindow.h
@@ -135,23 +135,16 @@ private slots:
135 *m_showOverDueAction, 135 *m_showOverDueAction,
136 *m_showQuickTaskAction, 136 *m_showQuickTaskAction,
137 *m_effectiveAction; 137 *m_effectiveAction;
138 QWidgetStack *m_stack; 138 QWidgetStack *m_stack;
139 QPopupMenu* m_catMenu, 139 QPopupMenu* m_catMenu,
140 *m_edit, 140 *m_edit,
141 *m_options, 141 *m_options,
142 *m_template; 142 *m_template;
143 /* box with two rows
144 * top will be the quick edit
145 * this will bite my ass once
146 * we want to have all parts
147 * exchangeable
148 */
149 QVBox* m_mainBox;
150 143
151 bool m_syncing:1; 144 bool m_syncing:1;
152 bool m_deadline:1; 145 bool m_deadline:1;
153 bool m_completed:1; 146 bool m_completed:1;
154 bool m_overdue:1; 147 bool m_overdue:1;
155 bool m_quicktask:1; 148 bool m_quicktask:1;
156 TodoManager m_todoMgr; 149 TodoManager m_todoMgr;
157 QString m_curCat; 150 QString m_curCat;
diff --git a/core/pim/todo/quickeditimpl.cpp b/core/pim/todo/quickeditimpl.cpp
index 8d0a9fd..cadec03 100644
--- a/core/pim/todo/quickeditimpl.cpp
+++ b/core/pim/todo/quickeditimpl.cpp
@@ -9,17 +9,17 @@
9#include "quickeditimpl.h" 9#include "quickeditimpl.h"
10 10
11 11
12QuickEditImpl::QuickEditImpl( QWidget* parent, bool visible ) 12QuickEditImpl::QuickEditImpl( QWidget* parent, bool visible )
13 : QPEToolBar( (QMainWindow *)parent ), Todo::QuickEdit( (Todo::MainWindow *)parent ) { 13 : QPEToolBar( (QMainWindow *)parent ), Todo::QuickEdit( (Todo::MainWindow *)parent ) {
14 setHorizontalStretchable( TRUE ); 14 setHorizontalStretchable( TRUE );
15 15
16 // Load priority icons 16 // Load priority icons
17 // TODO - probably should be done globally somewhere else 17 // TODO - probably should be done globally somewhere else, see also tableview.cpp/h
18 priority1 = Resource::loadPixmap( "todo/priority1" ); 18 priority1 = Resource::loadPixmap( "todo/priority1" );
19 priority3 = Resource::loadPixmap( "todo/priority3" ); 19 priority3 = Resource::loadPixmap( "todo/priority3" );
20 priority5 = Resource::loadPixmap( "todo/priority5" ); 20 priority5 = Resource::loadPixmap( "todo/priority5" );
21 21
22 22
23 // TODO - come up with icons and replace text priority values 23 // TODO - come up with icons and replace text priority values
24 m_lbl = new OClickableLabel( this ); 24 m_lbl = new OClickableLabel( this );
25 m_lbl->setMinimumWidth(15); 25 m_lbl->setMinimumWidth(15);
diff --git a/core/pim/todo/tableview.cpp b/core/pim/todo/tableview.cpp
index a8cc271..faf4611 100644
--- a/core/pim/todo/tableview.cpp
+++ b/core/pim/todo/tableview.cpp
@@ -30,16 +30,17 @@
30 30
31#include <qcombobox.h> 31#include <qcombobox.h>
32#include <qlineedit.h> 32#include <qlineedit.h>
33#include <qtimer.h> 33#include <qtimer.h>
34#include <qpoint.h> 34#include <qpoint.h>
35#include <qpopupmenu.h> 35#include <qpopupmenu.h>
36 36
37#include <qpe/config.h> 37#include <qpe/config.h>
38#include <qpe/resource.h>
38 39
39#include <opie/orecur.h> 40#include <opie/orecur.h>
40 41
41#include "mainwindow.h" 42#include "mainwindow.h"
42//#include "tableitems.h" 43//#include "tableitems.h"
43#include "tableview.h" 44#include "tableview.h"
44 45
45using namespace Todo; 46using namespace Todo;
@@ -59,39 +60,31 @@ void TableView::initConfig() {
59TableView::TableView( MainWindow* window, QWidget* wid ) 60TableView::TableView( MainWindow* window, QWidget* wid )
60 : QTable( wid ), TodoView( window ) { 61 : QTable( wid ), TodoView( window ) {
61 setUpdatesEnabled( false ); 62 setUpdatesEnabled( false );
62 viewport()->setUpdatesEnabled( false ); 63 viewport()->setUpdatesEnabled( false );
63 m_enablePaint = false; 64 m_enablePaint = false;
64 setNumRows(0); 65 setNumRows(0);
65 setNumCols(4); 66 setNumCols(4);
66 67
68 horizontalHeader()->setLabel( 0, tr("C.") );
69 horizontalHeader()->setLabel( 1, tr("Prior.") );
70 horizontalHeader()->setLabel( 2, tr("Description" ) );
71 horizontalHeader()->setLabel( 3, tr("Deadline") );
72
67 setSorting( TRUE ); 73 setSorting( TRUE );
68 setSelectionMode( NoSelection ); 74 setSelectionMode( NoSelection );
69// setColumnStretchable( 2, TRUE ); 75
70 setColumnStretchable( 3, FALSE );
71 setColumnWidth(0, 20 );
72 setColumnWidth(1, 35 );
73 setColumnWidth(3, 18 );
74
75 setLeftMargin( 0 ); 76 setLeftMargin( 0 );
76 verticalHeader()->hide(); 77 verticalHeader()->hide();
77 78
78 horizontalHeader()->setLabel(0, tr("C.") );
79 horizontalHeader()->setLabel(1, tr("Prior.") );
80 horizontalHeader()->setLabel(2, tr("Description" ) );
81
82// setColumnStretchable(3, FALSE );
83
84 horizontalHeader()->setLabel(3, tr("Deadline") );
85
86 if ( todoWindow()->showDeadline() ) 79 if ( todoWindow()->showDeadline() )
87 showColumn( 3); 80 showColumn( 3 );
88 else 81 else
89 hideColumn(3 ); 82 hideColumn( 3 );
90 83
91 connect((QTable*)this, SIGNAL( clicked( int, int, int, const QPoint& ) ), 84 connect((QTable*)this, SIGNAL( clicked( int, int, int, const QPoint& ) ),
92 this, SLOT( slotClicked(int, int, int, const QPoint& ) ) ); 85 this, SLOT( slotClicked(int, int, int, const QPoint& ) ) );
93 connect((QTable*)this, SIGNAL( pressed( int, int, int, const QPoint& ) ), 86 connect((QTable*)this, SIGNAL( pressed( int, int, int, const QPoint& ) ),
94 this, SLOT( slotPressed(int, int, int, const QPoint& ) ) ); 87 this, SLOT( slotPressed(int, int, int, const QPoint& ) ) );
95 connect((QTable*)this, SIGNAL(valueChanged(int, int) ), 88 connect((QTable*)this, SIGNAL(valueChanged(int, int) ),
96 this, SLOT( slotValueChanged(int, int) ) ); 89 this, SLOT( slotValueChanged(int, int) ) );
97 connect((QTable*)this, SIGNAL(currentChanged(int, int) ), 90 connect((QTable*)this, SIGNAL(currentChanged(int, int) ),
@@ -104,16 +97,39 @@ TableView::TableView( MainWindow* window, QWidget* wid )
104 m_enablePaint = true; 97 m_enablePaint = true;
105 setUpdatesEnabled( true ); 98 setUpdatesEnabled( true );
106 viewport()->setUpdatesEnabled( true ); 99 viewport()->setUpdatesEnabled( true );
107 viewport()->update(); 100 viewport()->update();
108 setSortOrder( 0 ); 101 setSortOrder( 0 );
109 setAscending( TRUE ); 102 setAscending( TRUE );
110 m_first = true; 103 m_first = true;
111 104
105 // Load icons
106 // TODO - probably should be done globally somewhere else, see also quickeditimpl.cpp/h
107 m_pic_completed = Resource::loadPixmap( "todo/completed" );
108 QString namestr;
109 for ( unsigned int i = 1; i < 6; i++ ) {
110 namestr = "todo/priority";
111 namestr.append( QString::number( i ) );
112 m_pic_priority[ i - 1 ] = Resource::loadPixmap( namestr );
113 }
114
115 // Try to intelligently size columns
116 int col2width = 240;
117 int width = m_pic_completed.width();
118 setColumnWidth( 0, width );
119 col2width -= width;
120 width = fontMetrics().boundingRect( horizontalHeader()->label( 1 ) ).width()+8;
121 setColumnWidth( 1, width );
122 col2width -= width;
123 width = fontMetrics().boundingRect( horizontalHeader()->label( 3 ) ).width()+8;
124 setColumnWidth( 3, width );
125 col2width -= width;
126 setColumnWidth( 2, col2width - 2 );
127
112 /* now let's init the config */ 128 /* now let's init the config */
113 initConfig(); 129 initConfig();
114} 130}
115/* a new day has started 131/* a new day has started
116 * update the day 132 * update the day
117 */ 133 */
118void TableView::newDay() { 134void TableView::newDay() {
119 clear(); 135 clear();
@@ -310,69 +326,58 @@ void TableView::viewportPaintEvent( QPaintEvent* e) {
310 */ 326 */
311void TableView::paintCell(QPainter* p, int row, int col, const QRect& cr, bool ) { 327void TableView::paintCell(QPainter* p, int row, int col, const QRect& cr, bool ) {
312 const QColorGroup &cg = colorGroup(); 328 const QColorGroup &cg = colorGroup();
313 329
314 p->save(); 330 p->save();
315 331
316 OTodo task = sorted()[row]; 332 OTodo task = sorted()[row];
317 333
318 p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Base ) ); 334 // TODO - give user option for grid or bars?
335
336 // Paint alternating background bars
337 if ( (row % 2 ) == 0 ) {
338 p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Base ) );
339 }
340 else {
341 p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Background ) );
342 }
319 343
320 QPen op = p->pen(); 344 // Paint grid
321 p->setPen(cg.mid()); 345 //p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Base ) );
322 p->drawLine( 0, cr.height() - 1, cr.width() - 1, cr.height() - 1 ); 346 //QPen op = p->pen();
323 p->drawLine( cr.width() - 1, 0, cr.width() - 1, cr.height() - 1 ); 347 //p->setPen(cg.mid());
324 p->setPen(op); 348 //p->drawLine( 0, cr.height() - 1, cr.width() - 1, cr.height() - 1 );
349 //p->drawLine( cr.width() - 1, 0, cr.width() - 1, cr.height() - 1 );
350 //p->setPen(op);
325 351
326 QFont f = p->font(); 352 QFont f = p->font();
327 QFontMetrics fm(f); 353 QFontMetrics fm(f);
328 354
355 int marg = ( cr.width() - BoxSize ) / 2;
356 int x = 0;
357 int y = ( cr.height() - BoxSize ) / 2;
358
329 switch(col) { 359 switch(col) {
330 case 0: 360 case 0: // completed field
331 {
332 // completed field
333 int marg = ( cr.width() - BoxSize ) / 2;
334 int x = 0;
335 int y = ( cr.height() - BoxSize ) / 2;
336 p->setPen( QPen( cg.text() ) );
337 p->drawRect( x + marg, y, BoxSize, BoxSize );
338 p->drawRect( x + marg+1, y+1, BoxSize-2, BoxSize-2 );
339 p->setPen( darkGreen );
340 x += 1;
341 y += 1;
342 if ( task.isCompleted() ) {
343 QPointArray a( 9*2 );
344 int i, xx, yy;
345 xx = x+2+marg;
346 yy = y+4;
347 for ( i=0; i<4; i++ ) {
348 a.setPoint( 2*i, xx, yy );
349 a.setPoint( 2*i+1, xx, yy+2 );
350 xx++; yy++;
351 }
352 yy -= 2;
353 for ( i=4; i<9; i++ ) {
354 a.setPoint( 2*i, xx, yy );
355 a.setPoint( 2*i+1, xx, yy+2 );
356 xx++; yy--;
357 }
358 p->drawLineSegments( a );
359 }
360 }
361 break;
362 case 1:
363 // priority field
364 { 361 {
365 QString text = QString::number(task.priority()); 362 //p->setPen( QPen( cg.text() ) );
366 p->drawText(2,2 + fm.ascent(), text); 363 //p->drawRect( x + marg, y, BoxSize, BoxSize );
364 //p->drawRect( x + marg+1, y+1, BoxSize-2, BoxSize-2 );
365 if ( task.isCompleted() ) {
366 p->drawPixmap( x + marg, y, m_pic_completed );
367 }
367 } 368 }
368 break; 369 break;
369 case 2: 370 case 1: // priority field
370 // description field 371 {
372 p->drawPixmap( x + marg, y, m_pic_priority[ task.priority() - 1 ] );
373 }
374 break;
375 case 2: // description field
371 { 376 {
372 QString text = task.summary().isEmpty() ? 377 QString text = task.summary().isEmpty() ?
373 task.description().left(20) : 378 task.description().left(20) :
374 task.summary(); 379 task.summary();
375 p->drawText(2,2 + fm.ascent(), text); 380 p->drawText(2,2 + fm.ascent(), text);
376 } 381 }
377 break; 382 break;
378 case 3: 383 case 3:
@@ -403,21 +408,19 @@ void TableView::paintCell(QPainter* p, int row, int col, const QRect& cr, bool
403 } 408 }
404 p->restore(); 409 p->restore();
405} 410}
406QWidget* TableView::createEditor(int row, int col, bool )const { 411QWidget* TableView::createEditor(int row, int col, bool )const {
407 switch( col ) { 412 switch( col ) {
408 case 1: { 413 case 1: {
409 /* the priority stuff */ 414 /* the priority stuff */
410 QComboBox* combo = new QComboBox( viewport() ); 415 QComboBox* combo = new QComboBox( viewport() );
411 combo->insertItem( "1" ); 416 for ( int i = 0; i < 5; i++ ) {
412 combo->insertItem( "2" ); 417 combo->insertItem( m_pic_priority[ i ] );
413 combo->insertItem( "3" ); 418 }
414 combo->insertItem( "4" );
415 combo->insertItem( "5" );
416 combo->setCurrentItem( sorted()[row].priority()-1 ); 419 combo->setCurrentItem( sorted()[row].priority()-1 );
417 return combo; 420 return combo;
418 } 421 }
419 /* summary */ 422 /* summary */
420 case 2:{ 423 case 2:{
421 QLineEdit* edit = new QLineEdit( viewport() ); 424 QLineEdit* edit = new QLineEdit( viewport() );
422 edit->setText( sorted()[row].summary() ); 425 edit->setText( sorted()[row].summary() );
423 return edit; 426 return edit;
diff --git a/core/pim/todo/tableview.h b/core/pim/todo/tableview.h
index a27c698..2b6ea2b 100644
--- a/core/pim/todo/tableview.h
+++ b/core/pim/todo/tableview.h
@@ -26,16 +26,17 @@
26 26
27*/ 27*/
28 28
29#ifndef OPIE_TABLE_VIEW_H 29#ifndef OPIE_TABLE_VIEW_H
30#define OPIE_TABLE_VIEW_H 30#define OPIE_TABLE_VIEW_H
31 31
32#include <qtable.h> 32#include <qtable.h>
33#include <qmap.h> 33#include <qmap.h>
34#include <qpixmap.h>
34 35
35#include "todoview.h" 36#include "todoview.h"
36 37
37class QTimer; 38class QTimer;
38 39
39namespace Todo { 40namespace Todo {
40 class CheckItem; 41 class CheckItem;
41 class DueTextItem; 42 class DueTextItem;
@@ -75,16 +76,19 @@ namespace Todo {
75 private: 76 private:
76 /* reimplented for internal reasons */ 77 /* reimplented for internal reasons */
77 void viewportPaintEvent( QPaintEvent* ); 78 void viewportPaintEvent( QPaintEvent* );
78 QTimer *m_menuTimer; 79 QTimer *m_menuTimer;
79 bool m_enablePaint:1; 80 bool m_enablePaint:1;
80 QString m_oleCat; 81 QString m_oleCat;
81 bool m_first : 1; 82 bool m_first : 1;
82 83
84 QPixmap m_pic_completed;
85 QPixmap m_pic_priority[ 5 ];
86
83 protected: 87 protected:
84 void contentsMouseReleaseEvent( QMouseEvent* ); 88 void contentsMouseReleaseEvent( QMouseEvent* );
85 void contentsMouseMoveEvent( QMouseEvent* ); 89 void contentsMouseMoveEvent( QMouseEvent* );
86 void timerEvent( QTimerEvent* e ); 90 void timerEvent( QTimerEvent* e );
87 QWidget* createEditor(int row, int col, bool initFromCell )const; 91 QWidget* createEditor(int row, int col, bool initFromCell )const;
88 void setCellContentFromEditor( int row, int col ); 92 void setCellContentFromEditor( int row, int col );
89 93
90private slots: 94private slots: