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
@@ -189,52 +189,50 @@ void MainWindow::initActions() {
189 connect(m_showQuickTaskAction, SIGNAL( toggled(bool) ), this, SLOT(slotShowQuickTask(bool) ) ); 189 connect(m_showQuickTaskAction, SIGNAL( toggled(bool) ), this, SLOT(slotShowQuickTask(bool) ) );
190 190
191 m_options->insertSeparator(); 191 m_options->insertSeparator();
192 192
193 m_bar->insertItem( tr("Data") ,m_edit ); 193 m_bar->insertItem( tr("Data") ,m_edit );
194 m_bar->insertItem( tr("Category"), m_catMenu ); 194 m_bar->insertItem( tr("Category"), m_catMenu );
195 m_bar->insertItem( tr("Options"), m_options ); 195 m_bar->insertItem( tr("Options"), m_options );
196 196
197 m_curQuick = new QuickEditImpl( this, m_quicktask ); 197 m_curQuick = new QuickEditImpl( this, m_quicktask );
198 addToolBar( (QPEToolBar *)m_curQuick->widget(), tr( "QuickEdit" ), QMainWindow::Top, TRUE ); 198 addToolBar( (QPEToolBar *)m_curQuick->widget(), tr( "QuickEdit" ), QMainWindow::Top, TRUE );
199 m_curQuick->signal()->connect( this, SLOT(slotQuickEntered() ) ); 199 m_curQuick->signal()->connect( this, SLOT(slotQuickEntered() ) );
200 200
201} 201}
202/* m_curCat from Config */ 202/* m_curCat from Config */
203void MainWindow::initConfig() { 203void MainWindow::initConfig() {
204 Config config( "todo" ); 204 Config config( "todo" );
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
225 /** QPopupMenu */ 223 /** QPopupMenu */
226 m_edit = new QPopupMenu( this ); 224 m_edit = new QPopupMenu( this );
227 m_options = new QPopupMenu( this ); 225 m_options = new QPopupMenu( this );
228 m_catMenu = new QPopupMenu( this ); 226 m_catMenu = new QPopupMenu( this );
229 m_template = new QPopupMenu( this ); 227 m_template = new QPopupMenu( this );
230 228
231 m_catMenu->setCheckable( TRUE ); 229 m_catMenu->setCheckable( TRUE );
232 m_template->setCheckable( TRUE ); 230 m_template->setCheckable( TRUE );
233 231
234 connect(m_catMenu, SIGNAL(activated(int) ), 232 connect(m_catMenu, SIGNAL(activated(int) ),
235 this, SLOT(setCategory(int) ) ); 233 this, SLOT(setCategory(int) ) );
236 connect(m_template, SIGNAL(activated(int) ), 234 connect(m_template, SIGNAL(activated(int) ),
237 this, SLOT(slotNewFromTemplate(int) ) ); 235 this, SLOT(slotNewFromTemplate(int) ) );
238} 236}
239void MainWindow::initViews() { 237void MainWindow::initViews() {
240 TableView* tableView = new TableView( this, m_stack ); 238 TableView* tableView = new TableView( this, m_stack );
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
@@ -119,55 +119,48 @@ private slots:
119 Editor* m_curEdit; 119 Editor* m_curEdit;
120 TodoShow* currentShow(); 120 TodoShow* currentShow();
121 TodoShow* m_curShow; 121 TodoShow* m_curShow;
122 TemplateEditor* currentTemplateEditor(); 122 TemplateEditor* currentTemplateEditor();
123 TemplateEditor* m_curTempEd; 123 TemplateEditor* m_curTempEd;
124 124
125 QMenuBar* m_bar; 125 QMenuBar* m_bar;
126 QToolBar* m_tool; 126 QToolBar* m_tool;
127 QAction* m_editAction, 127 QAction* m_editAction,
128 *m_deleteAction, 128 *m_deleteAction,
129 *m_findAction, 129 *m_findAction,
130 *m_completedAction, 130 *m_completedAction,
131 *m_showDeadLineAction, 131 *m_showDeadLineAction,
132 *m_deleteAllAction, 132 *m_deleteAllAction,
133 *m_deleteCompleteAction, 133 *m_deleteCompleteAction,
134 *m_duplicateAction, 134 *m_duplicateAction,
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;
158 QList<ViewBase> m_views; 151 QList<ViewBase> m_views;
159 uint m_counter; 152 uint m_counter;
160 TemplateManager* m_tempManager; 153 TemplateManager* m_tempManager;
161 154
162 155
163 private slots: 156 private slots:
164 void slotShow(int); 157 void slotShow(int);
165 void slotEdit(int); 158 void slotEdit(int);
166 void slotUpdate3( QWidget* ); 159 void slotUpdate3( QWidget* );
167 void slotComplete( int uid ); 160 void slotComplete( int uid );
168 void slotComplete( const OTodo& ev ); 161 void slotComplete( const OTodo& ev );
169 void slotNewFromTemplate(int id ); 162 void slotNewFromTemplate(int id );
170 void slotNew(); 163 void slotNew();
171 void slotDuplicate(); 164 void slotDuplicate();
172 165
173 void slotDelete(); 166 void slotDelete();
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
@@ -1,41 +1,41 @@
1#include <qaction.h> 1#include <qaction.h>
2#include <qlineedit.h> 2#include <qlineedit.h>
3 3
4#include <qpe/resource.h> 4#include <qpe/resource.h>
5 5
6#include <opie/oclickablelabel.h> 6#include <opie/oclickablelabel.h>
7 7
8#include "mainwindow.h" 8#include "mainwindow.h"
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);
26 m_lbl->setPixmap( priority3 ); 26 m_lbl->setPixmap( priority3 );
27 connect(m_lbl, SIGNAL(clicked() ), this, SLOT(slotPrio()) ); 27 connect(m_lbl, SIGNAL(clicked() ), this, SLOT(slotPrio()) );
28 28
29 m_edit = new QLineEdit( this ); 29 m_edit = new QLineEdit( this );
30 setStretchableWidget( m_edit ); 30 setStretchableWidget( m_edit );
31 31
32 QAction *a = new QAction( tr( "More" ), Resource::loadPixmap( "todo/more" ), QString::null, 0, this, 0 ); 32 QAction *a = new QAction( tr( "More" ), Resource::loadPixmap( "todo/more" ), QString::null, 0, this, 0 );
33 connect( a, SIGNAL( activated() ), this, SLOT( slotMore() ) ); 33 connect( a, SIGNAL( activated() ), this, SLOT( slotMore() ) );
34 a->addTo( this ); 34 a->addTo( this );
35 35
36 a = new QAction( tr( "Enter" ), Resource::loadPixmap( "enter" ), QString::null, 0, this, 0 ); 36 a = new QAction( tr( "Enter" ), Resource::loadPixmap( "enter" ), QString::null, 0, this, 0 );
37 connect( a, SIGNAL( activated() ), this, SLOT( slotEnter() ) ); 37 connect( a, SIGNAL( activated() ), this, SLOT( slotEnter() ) );
38 a->addTo( this ); 38 a->addTo( this );
39 39
40 a = new QAction( tr( "Cancel" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); 40 a = new QAction( tr( "Cancel" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 );
41 connect( a, SIGNAL( activated() ), this, SLOT( slotCancel() ) ); 41 connect( a, SIGNAL( activated() ), this, SLOT( slotCancel() ) );
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
@@ -14,122 +14,138 @@
14    : ..    .:,     . . . without even the implied warranty of 14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more 17..}^=.=       =       ; Library General Public License for more
18++=   -.     .`     .: details. 18++=   -.     .`     .: details.
19 :     =  ...= . :.=- 19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU 20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = Library General Public License along with 21  -_. . .   )=.  = Library General Public License along with
22    --        :-=` this library; see the file COPYING.LIB. 22    --        :-=` this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation, 23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330, 24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28#include <stdlib.h> 28#include <stdlib.h>
29#include <cmath> 29#include <cmath>
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;
46 47
47namespace { 48namespace {
48 static const int BoxSize = 14; 49 static const int BoxSize = 14;
49 static const int RowHeight = 20; 50 static const int RowHeight = 20;
50} 51}
51 52
52 53
53void TableView::initConfig() { 54void TableView::initConfig() {
54 Config config( "todo" ); 55 Config config( "todo" );
55 config.setGroup( "Options" ); 56 config.setGroup( "Options" );
56 m_completeStrokeWidth = config.readNumEntry( "CompleteStrokeWidth", 8 ); 57 m_completeStrokeWidth = config.readNumEntry( "CompleteStrokeWidth", 8 );
57} 58}
58 59
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) ),
98 this, SLOT( slotCurrentChanged(int, int) ) ); 91 this, SLOT( slotCurrentChanged(int, int) ) );
99 92
100 m_menuTimer = new QTimer( this ); 93 m_menuTimer = new QTimer( this );
101 connect( m_menuTimer, SIGNAL(timeout()), 94 connect( m_menuTimer, SIGNAL(timeout()),
102 this, SLOT(slotShowMenu()) ); 95 this, SLOT(slotShowMenu()) );
103 96
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();
120 updateView(); 136 updateView();
121} 137}
122TableView::~TableView() { 138TableView::~TableView() {
123 139
124} 140}
125void TableView::slotShowMenu() { 141void TableView::slotShowMenu() {
126 QPopupMenu *menu = todoWindow()->contextMenu( current(), sorted()[currentRow()].recurrence().doesRecur() ); 142 QPopupMenu *menu = todoWindow()->contextMenu( current(), sorted()[currentRow()].recurrence().doesRecur() );
127 menu->exec(QCursor::pos() ); 143 menu->exec(QCursor::pos() );
128 delete menu; 144 delete menu;
129} 145}
130QString TableView::type() const { 146QString TableView::type() const {
131 return QString::fromLatin1( tr("Table View") ); 147 return QString::fromLatin1( tr("Table View") );
132} 148}
133int TableView::current() { 149int TableView::current() {
134 int uid = sorted().uidAt(currentRow() ); 150 int uid = sorted().uidAt(currentRow() );
135 151
@@ -294,146 +310,133 @@ QWidget* TableView::widget() {
294 * to a sort() and update() 310 * to a sort() and update()
295 */ 311 */
296void TableView::sortColumn( int col, bool asc, bool ) { 312void TableView::sortColumn( int col, bool asc, bool ) {
297 qWarning("bool %d", asc ); 313 qWarning("bool %d", asc );
298 setSortOrder( col ); 314 setSortOrder( col );
299 setAscending( asc ); 315 setAscending( asc );
300 updateView(); 316 updateView();
301} 317}
302void TableView::viewportPaintEvent( QPaintEvent* e) { 318void TableView::viewportPaintEvent( QPaintEvent* e) {
303 if (m_enablePaint ) 319 if (m_enablePaint )
304 QTable::viewportPaintEvent( e ); 320 QTable::viewportPaintEvent( e );
305} 321}
306/* 322/*
307 * This segment is copyrighted by TT 323 * This segment is copyrighted by TT
308 * it was taken from their todolist 324 * it was taken from their todolist
309 * application this code is GPL 325 * application this code is GPL
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:
379 { 384 {
380 QString text; 385 QString text;
381 if (task.hasDueDate()) { 386 if (task.hasDueDate()) {
382 int off = QDate::currentDate().daysTo( task.dueDate() ); 387 int off = QDate::currentDate().daysTo( task.dueDate() );
383 text = tr( "%1 day(s)").arg(QString::number(off)); 388 text = tr( "%1 day(s)").arg(QString::number(off));
384 /* 389 /*
385 * set color if not completed 390 * set color if not completed
386 */ 391 */
387 if (!task.isCompleted() ) { 392 if (!task.isCompleted() ) {
388 QColor color = Qt::black; 393 QColor color = Qt::black;
389 if ( off < 0 ) 394 if ( off < 0 )
390 color = Qt::red; 395 color = Qt::red;
391 else if ( off == 0 ) 396 else if ( off == 0 )
392 color = Qt::yellow; 397 color = Qt::yellow;
393 else if ( off > 0 ) 398 else if ( off > 0 )
394 color = Qt::green; 399 color = Qt::green;
395 p->setPen(color ); 400 p->setPen(color );
396 } 401 }
397 } else { 402 } else {
398 text = tr("None"); 403 text = tr("None");
399 } 404 }
400 p->drawText(2,2 + fm.ascent(), text); 405 p->drawText(2,2 + fm.ascent(), text);
401 } 406 }
402 break; 407 break;
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;
424 } 427 }
425 case 0: 428 case 0:
426 default: 429 default:
427 return 0l; 430 return 0l;
428 } 431 }
429} 432}
430void TableView::setCellContentFromEditor(int row, int col ) { 433void TableView::setCellContentFromEditor(int row, int col ) {
431 if ( col == 1 ) { 434 if ( col == 1 ) {
432 QWidget* wid = cellWidget(row, 1 ); 435 QWidget* wid = cellWidget(row, 1 );
433 if ( wid->inherits("QComboBox") ) { 436 if ( wid->inherits("QComboBox") ) {
434 int pri = ((QComboBox*)wid)->currentItem() + 1; 437 int pri = ((QComboBox*)wid)->currentItem() + 1;
435 OTodo todo = sorted()[row]; 438 OTodo todo = sorted()[row];
436 if ( todo.priority() != pri ) { 439 if ( todo.priority() != pri ) {
437 todo.setPriority( pri ); 440 todo.setPriority( pri );
438 TodoView::update( todo.uid(), todo ); 441 TodoView::update( todo.uid(), todo );
439 updateView(); 442 updateView();
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
@@ -10,48 +10,49 @@
10     ._= =}       : or (at your option) any later version. 10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_. 11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This program is distributed in the hope that 12    .i_,=:_.      -<s. This program is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of 14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more 17..}^=.=       =       ; Library General Public License for more
18++=   -.     .`     .: details. 18++=   -.     .`     .: details.
19 :     =  ...= . :.=- 19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU 20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = Library General Public License along with 21  -_. . .   )=.  = Library General Public License along with
22    --        :-=` this library; see the file COPYING.LIB. 22    --        :-=` this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation, 23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330, 24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
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;
42 class TableView : public QTable, public TodoView { 43 class TableView : public QTable, public TodoView {
43 Q_OBJECT 44 Q_OBJECT
44 public: 45 public:
45 TableView( MainWindow*, QWidget* parent ); 46 TableView( MainWindow*, QWidget* parent );
46 ~TableView(); 47 ~TableView();
47 48
48 49
49 QString type()const; 50 QString type()const;
50 int current(); 51 int current();
51 QString currentRepresentation(); 52 QString currentRepresentation();
52 53
53 void clear(); 54 void clear();
54 void showOverDue( bool ); 55 void showOverDue( bool );
55 void updateView(); 56 void updateView();
56 void setTodo( int uid, const OTodo& ); 57 void setTodo( int uid, const OTodo& );
57 void addEvent( const OTodo& event ); 58 void addEvent( const OTodo& event );
@@ -59,48 +60,51 @@ namespace Todo {
59 void removeEvent( int uid ); 60 void removeEvent( int uid );
60 void setShowCompleted( bool ); 61 void setShowCompleted( bool );
61 void setShowDeadline( bool ); 62 void setShowDeadline( bool );
62 63
63 void setShowCategory(const QString& =QString::null ); 64 void setShowCategory(const QString& =QString::null );
64 void newDay(); 65 void newDay();
65 QWidget* widget(); 66 QWidget* widget();
66 void sortColumn(int, bool, bool ); 67 void sortColumn(int, bool, bool );
67 68
68 /* 69 /*
69 * we do our drawing ourselves 70 * we do our drawing ourselves
70 * because we don't want to have 71 * because we don't want to have
71 * 40.000 QTableItems for 10.000 72 * 40.000 QTableItems for 10.000
72 * OTodos where we only show 10 at a time! 73 * OTodos where we only show 10 at a time!
73 */ 74 */
74 void paintCell(QPainter* p, int row, int col, const QRect&, bool ); 75 void paintCell(QPainter* p, int row, int col, const QRect&, bool );
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:
91 void slotShowMenu(); 95 void slotShowMenu();
92 void slotClicked(int, int, int, 96 void slotClicked(int, int, int,
93 const QPoint& ); 97 const QPoint& );
94 void slotPressed(int, int, int, 98 void slotPressed(int, int, int,
95 const QPoint& ); 99 const QPoint& );
96 void slotValueChanged(int, int); 100 void slotValueChanged(int, int);
97 void slotCurrentChanged(int, int ); 101 void slotCurrentChanged(int, int );
98 void slotPriority(); 102 void slotPriority();
99 private: 103 private:
100 void initConfig(); 104 void initConfig();
101 int m_completeStrokeWidth; 105 int m_completeStrokeWidth;
102 bool m_row : 1; 106 bool m_row : 1;
103 QPoint m_prevP; 107 QPoint m_prevP;
104 }; 108 };
105}; 109};
106 110