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
@@ -117,196 +117,194 @@ void MainWindow::initActions() {
117 a = new QAction( tr("Delete..."), Resource::loadIconSet( "trash" ), 117 a = new QAction( tr("Delete..."), Resource::loadIconSet( "trash" ),
118 QString::null, 0, this, 0 ); 118 QString::null, 0, this, 0 );
119 connect(a, SIGNAL(activated() ), 119 connect(a, SIGNAL(activated() ),
120 this, SLOT(slotDelete() ) ); 120 this, SLOT(slotDelete() ) );
121 a->addTo( m_tool ); 121 a->addTo( m_tool );
122 a->addTo( m_edit ); 122 a->addTo( m_edit );
123 m_deleteAction = a; 123 m_deleteAction = a;
124 124
125 a = new QAction( QString::null, tr("Delete all..."), 0, this, 0 ); 125 a = new QAction( QString::null, tr("Delete all..."), 0, this, 0 );
126 connect(a, SIGNAL( activated() ), 126 connect(a, SIGNAL( activated() ),
127 this, SLOT( slotDeleteAll() ) ); 127 this, SLOT( slotDeleteAll() ) );
128 a->addTo(m_edit ); 128 a->addTo(m_edit );
129 m_deleteAllAction = a; 129 m_deleteAllAction = a;
130 130
131 a = new QAction( QString::null, tr("Delete completed"), 131 a = new QAction( QString::null, tr("Delete completed"),
132 0, this, 0 ); 132 0, this, 0 );
133 connect(a, SIGNAL( activated() ), 133 connect(a, SIGNAL( activated() ),
134 this, SLOT( slotDeleteCompleted() ) ); 134 this, SLOT( slotDeleteCompleted() ) );
135 a->addTo(m_edit ); 135 a->addTo(m_edit );
136 a->setEnabled( TRUE ); 136 a->setEnabled( TRUE );
137 m_deleteCompleteAction = a; 137 m_deleteCompleteAction = a;
138 138
139 m_edit->insertSeparator(); 139 m_edit->insertSeparator();
140 140
141 a = new QAction( QString::null, tr("Duplicate"), 0, this, 0 ); 141 a = new QAction( QString::null, tr("Duplicate"), 0, this, 0 );
142 connect(a, SIGNAL( activated() ), 142 connect(a, SIGNAL( activated() ),
143 this, SLOT( slotDuplicate() ) ); 143 this, SLOT( slotDuplicate() ) );
144 a->addTo(m_edit ); 144 a->addTo(m_edit );
145 m_duplicateAction = a; 145 m_duplicateAction = a;
146 146
147 m_edit->insertSeparator(); 147 m_edit->insertSeparator();
148 148
149 if ( Ir::supported() ) { 149 if ( Ir::supported() ) {
150 a = new QAction( tr( "Beam" ), Resource::loadPixmap( "beam" ), 150 a = new QAction( tr( "Beam" ), Resource::loadPixmap( "beam" ),
151 QString::null, 0, this, 0 ); 151 QString::null, 0, this, 0 );
152 connect( a, SIGNAL( activated() ), 152 connect( a, SIGNAL( activated() ),
153 this, SLOT( slotBeam() ) ); 153 this, SLOT( slotBeam() ) );
154 a->addTo( m_edit ); 154 a->addTo( m_edit );
155 a->addTo( m_tool ); 155 a->addTo( m_tool );
156 } 156 }
157 157
158 // Options menu 158 // Options menu
159 a = new QAction( tr("Find"), Resource::loadIconSet( "mag" ), 159 a = new QAction( tr("Find"), Resource::loadIconSet( "mag" ),
160 QString::null, 0, this, 0 ); 160 QString::null, 0, this, 0 );
161 connect(a, SIGNAL( activated() ), this, SLOT( slotFind() ) ); 161 connect(a, SIGNAL( activated() ), this, SLOT( slotFind() ) );
162 a->addTo( m_options ); 162 a->addTo( m_options );
163 m_findAction = a; 163 m_findAction = a;
164 164
165 m_options->insertSeparator(); 165 m_options->insertSeparator();
166 166
167 m_completedAction = new QAction( QString::null, tr("Show completed tasks"), 167 m_completedAction = new QAction( QString::null, tr("Show completed tasks"),
168 0, this, 0, TRUE ); 168 0, this, 0, TRUE );
169 m_completedAction->addTo( m_options ); 169 m_completedAction->addTo( m_options );
170 m_completedAction->setOn( showCompleted() ); 170 m_completedAction->setOn( showCompleted() );
171 connect(m_completedAction, SIGNAL( toggled(bool) ), this, SLOT(slotShowCompleted(bool) ) ); 171 connect(m_completedAction, SIGNAL( toggled(bool) ), this, SLOT(slotShowCompleted(bool) ) );
172 172
173 a = new QAction( QString::null, tr("Show only over-due tasks"), 173 a = new QAction( QString::null, tr("Show only over-due tasks"),
174 0, this, 0, TRUE ); 174 0, this, 0, TRUE );
175 a->addTo( m_options ); 175 a->addTo( m_options );
176 a->setOn( showOverDue() ); 176 a->setOn( showOverDue() );
177 connect(a, SIGNAL(toggled(bool)), this, SLOT(slotShowDue(bool) ) ); 177 connect(a, SIGNAL(toggled(bool)), this, SLOT(slotShowDue(bool) ) );
178 178
179 m_showDeadLineAction = new QAction( QString::null, tr("Show task deadlines"), 179 m_showDeadLineAction = new QAction( QString::null, tr("Show task deadlines"),
180 0, this, 0, TRUE ); 180 0, this, 0, TRUE );
181 m_showDeadLineAction->addTo( m_options ); 181 m_showDeadLineAction->addTo( m_options );
182 m_showDeadLineAction->setOn( showDeadline() ); 182 m_showDeadLineAction->setOn( showDeadline() );
183 connect(m_showDeadLineAction, SIGNAL(toggled(bool) ), this, SLOT( slotShowDeadLine( bool ) ) ); 183 connect(m_showDeadLineAction, SIGNAL(toggled(bool) ), this, SLOT( slotShowDeadLine( bool ) ) );
184 184
185 m_showQuickTaskAction = new QAction( QString::null, tr("Show quick task bar"), 185 m_showQuickTaskAction = new QAction( QString::null, tr("Show quick task bar"),
186 0, this, 0, TRUE ); 186 0, this, 0, TRUE );
187 m_showQuickTaskAction->addTo( m_options ); 187 m_showQuickTaskAction->addTo( m_options );
188 m_showQuickTaskAction->setOn( showQuickTask() ); 188 m_showQuickTaskAction->setOn( showQuickTask() );
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 );
241 m_stack->addWidget( tableView, m_counter++ ); 239 m_stack->addWidget( tableView, m_counter++ );
242 m_views.append( tableView ); 240 m_views.append( tableView );
243 m_curView = tableView; 241 m_curView = tableView;
244 connectBase( tableView ); 242 connectBase( tableView );
245 /* add QString type + QString configname to 243 /* add QString type + QString configname to
246 * the View menu 244 * the View menu
247 * and subdirs for multiple views 245 * and subdirs for multiple views
248 */ 246 */
249} 247}
250void MainWindow::initEditor() { 248void MainWindow::initEditor() {
251 m_curEdit = new Editor(); 249 m_curEdit = new Editor();
252} 250}
253void MainWindow::initShow() { 251void MainWindow::initShow() {
254 m_curShow = new TextViewShow(this); 252 m_curShow = new TextViewShow(this);
255 m_stack->addWidget( m_curShow->widget() , m_counter++ ); 253 m_stack->addWidget( m_curShow->widget() , m_counter++ );
256} 254}
257MainWindow::~MainWindow() { 255MainWindow::~MainWindow() {
258 delete templateManager(); 256 delete templateManager();
259} 257}
260void MainWindow::connectBase( ViewBase* ) { 258void MainWindow::connectBase( ViewBase* ) {
261 // once templates and signals mix we'll use it again 259 // once templates and signals mix we'll use it again
262} 260}
263QPopupMenu* MainWindow::contextMenu( int , bool recur ) { 261QPopupMenu* MainWindow::contextMenu( int , bool recur ) {
264 QPopupMenu* menu = new QPopupMenu(); 262 QPopupMenu* menu = new QPopupMenu();
265 263
266 m_editAction->addTo( menu ); 264 m_editAction->addTo( menu );
267 m_deleteAction->addTo( menu ); 265 m_deleteAction->addTo( menu );
268 m_duplicateAction->addTo( menu ); 266 m_duplicateAction->addTo( menu );
269 267
270 menu->insertSeparator(); 268 menu->insertSeparator();
271 269
272 /* 270 /*
273 * if this event recurs we allow 271 * if this event recurs we allow
274 * to detach it. 272 * to detach it.
275 * remove all 273 * remove all
276 */ 274 */
277 if ( recur ) { 275 if ( recur ) {
278 ; // FIXME 276 ; // FIXME
279 } 277 }
280 278
281 return menu; 279 return menu;
282} 280}
283QPopupMenu* MainWindow::options() { 281QPopupMenu* MainWindow::options() {
284 qWarning("Options"); 282 qWarning("Options");
285 return m_options; 283 return m_options;
286} 284}
287QPopupMenu* MainWindow::edit() { 285QPopupMenu* MainWindow::edit() {
288 return m_edit; 286 return m_edit;
289} 287}
290QToolBar* MainWindow::toolbar() { 288QToolBar* MainWindow::toolbar() {
291 return m_tool; 289 return m_tool;
292} 290}
293OTodoAccess::List MainWindow::list()const { 291OTodoAccess::List MainWindow::list()const {
294 return m_todoMgr.list(); 292 return m_todoMgr.list();
295} 293}
296OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder ) { 294OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder ) {
297 int cat = 0; 295 int cat = 0;
298 if ( m_curCat != tr("All Categories") ) 296 if ( m_curCat != tr("All Categories") )
299 cat = currentCatId(); 297 cat = currentCatId();
300 298
301 int filter = 1; 299 int filter = 1;
302 300
303 if (!m_completed ) 301 if (!m_completed )
304 filter |= 4; 302 filter |= 4;
305 if (m_overdue) 303 if (m_overdue)
306 filter |= 2; 304 filter |= 2;
307 305
308 return m_todoMgr.sorted( asc, sortOrder, filter, cat ); 306 return m_todoMgr.sorted( asc, sortOrder, filter, cat );
309} 307}
310OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder, int addFilter) { 308OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder, int addFilter) {
311 int cat = 0; 309 int cat = 0;
312 if ( m_curCat != tr("All Categories") ) 310 if ( m_curCat != tr("All Categories") )
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
@@ -47,160 +47,153 @@ class QAction;
47class QWidgetStack; 47class QWidgetStack;
48class Ir; 48class Ir;
49class QVBox; 49class QVBox;
50class QLineEdit; 50class QLineEdit;
51 51
52namespace Todo { 52namespace Todo {
53 typedef TodoView View; 53 typedef TodoView View;
54 class TemplateManager; 54 class TemplateManager;
55 class Editor; 55 class Editor;
56 class TodoShow; 56 class TodoShow;
57 class TemplateEditor; 57 class TemplateEditor;
58 struct QuickEditBase; 58 struct QuickEditBase;
59 59
60 class MainWindow : public OPimMainWindow { 60 class MainWindow : public OPimMainWindow {
61 Q_OBJECT 61 Q_OBJECT
62 friend class TodoView; // avoid QObject here.... 62 friend class TodoView; // avoid QObject here....
63 public: 63 public:
64 MainWindow( QWidget *parent = 0, 64 MainWindow( QWidget *parent = 0,
65 const char* name = 0 ); 65 const char* name = 0 );
66 ~MainWindow(); 66 ~MainWindow();
67 67
68 /** return a context menu for an OTodo */ 68 /** return a context menu for an OTodo */
69 QPopupMenu* contextMenu(int uid, bool doesRecur = FALSE ); 69 QPopupMenu* contextMenu(int uid, bool doesRecur = FALSE );
70 QPopupMenu* options(); 70 QPopupMenu* options();
71 QPopupMenu* edit(); 71 QPopupMenu* edit();
72 QToolBar* toolbar(); 72 QToolBar* toolbar();
73 73
74 74
75 void updateList(); 75 void updateList();
76 OTodoAccess::List list()const; 76 OTodoAccess::List list()const;
77 OTodoAccess::List sorted( bool asc, int sortOrder ); 77 OTodoAccess::List sorted( bool asc, int sortOrder );
78 OTodoAccess::List sorted( bool asc, int sortOrder, int addFilter ); 78 OTodoAccess::List sorted( bool asc, int sortOrder, int addFilter );
79 79
80 OTodo event(int uid ); 80 OTodo event(int uid );
81 81
82 bool isSyncing()const; 82 bool isSyncing()const;
83 bool showCompleted()const; 83 bool showCompleted()const;
84 bool showDeadline()const; 84 bool showDeadline()const;
85 bool showOverDue()const; 85 bool showOverDue()const;
86 bool showQuickTask()const; 86 bool showQuickTask()const;
87 QString currentCategory()const; 87 QString currentCategory()const;
88 int currentCatId(); 88 int currentCatId();
89 TemplateManager* templateManager(); 89 TemplateManager* templateManager();
90 QuickEditBase* quickEditor(); 90 QuickEditBase* quickEditor();
91 91
92 void updateTodo( const OTodo& ); 92 void updateTodo( const OTodo& );
93 void populateTemplates(); 93 void populateTemplates();
94 Editor* currentEditor(); 94 Editor* currentEditor();
95 void setReadAhead(uint count ); 95 void setReadAhead(uint count );
96private slots: 96private slots:
97 void slotQuickEntered(); 97 void slotQuickEntered();
98 void populateCategories(); 98 void populateCategories();
99 void slotReload(); 99 void slotReload();
100 void slotFlush(); 100 void slotFlush();
101 101
102 protected: 102 protected:
103 void closeEvent( QCloseEvent* e ); 103 void closeEvent( QCloseEvent* e );
104 104
105 private: 105 private:
106 void receiveFile( const QString& filename ); 106 void receiveFile( const QString& filename );
107 void connectBase( ViewBase* ); 107 void connectBase( ViewBase* );
108 void initUI(); 108 void initUI();
109 void initActions(); 109 void initActions();
110 void initConfig(); 110 void initConfig();
111 void initViews(); 111 void initViews();
112 void initEditor(); 112 void initEditor();
113 void initShow(); 113 void initShow();
114 void initTemplate(); 114 void initTemplate();
115 void raiseCurrentView(); 115 void raiseCurrentView();
116 ViewBase* currentView(); 116 ViewBase* currentView();
117 ViewBase* m_curView; 117 ViewBase* m_curView;
118 QuickEditBase* m_curQuick; 118 QuickEditBase* m_curQuick;
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();
174 void slotDeleteAll(); 167 void slotDeleteAll();
175 void slotDeleteCompleted(); 168 void slotDeleteCompleted();
176 169
177 void slotEdit(); 170 void slotEdit();
178 void slotFind(); 171 void slotFind();
179 172
180 void setCategory( int ); 173 void setCategory( int );
181 174
182 void slotShowDeadLine( bool ); 175 void slotShowDeadLine( bool );
183 void slotShowCompleted( bool ); 176 void slotShowCompleted( bool );
184 void slotShowQuickTask( bool ); 177 void slotShowQuickTask( bool );
185 178
186 void setDocument( const QString& ); 179 void setDocument( const QString& );
187 180
188 181
189 void slotBeam(); 182 void slotBeam();
190 void beamDone( Ir* ); 183 void beamDone( Ir* );
191 void slotShowDetails(); 184 void slotShowDetails();
192 void slotShowDue( bool ); 185 void slotShowDue( bool );
193 /* reimplementation from opimmainwindow */ 186 /* reimplementation from opimmainwindow */
194 protected slots: 187 protected slots:
195 void flush(); 188 void flush();
196 void reload(); 189 void reload();
197 int create(); 190 int create();
198 bool remove( int uid ); 191 bool remove( int uid );
199 void beam(int uid, int transport = IrDa ); 192 void beam(int uid, int transport = IrDa );
200 void show( int uid ); 193 void show( int uid );
201 void edit( int uid ); 194 void edit( int uid );
202 void add( const OPimRecord& ); 195 void add( const OPimRecord& );
203 }; 196 };
204}; 197};
205 198
206#endif 199#endif
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,106 +1,106 @@
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() ) );
42 a->addTo( this ); 42 a->addTo( this );
43 43
44 m_visible = visible; 44 m_visible = visible;
45 if ( !m_visible ) { 45 if ( !m_visible ) {
46 hide(); 46 hide();
47 } 47 }
48 48
49 m_menu = 0l; 49 m_menu = 0l;
50 reinit(); 50 reinit();
51} 51}
52QuickEditImpl::~QuickEditImpl() { 52QuickEditImpl::~QuickEditImpl() {
53 53
54} 54}
55OTodo QuickEditImpl::todo()const { 55OTodo QuickEditImpl::todo()const {
56 return m_todo; 56 return m_todo;
57} 57}
58QWidget* QuickEditImpl::widget() { 58QWidget* QuickEditImpl::widget() {
59 return this; 59 return this;
60} 60}
61void QuickEditImpl::slotEnter() { 61void QuickEditImpl::slotEnter() {
62 OTodo todo; 62 OTodo todo;
63 63
64 64
65 if (!m_edit->text().isEmpty() ) { 65 if (!m_edit->text().isEmpty() ) {
66 todo.setUid(1 ); // new uid 66 todo.setUid(1 ); // new uid
67 todo.setPriority( m_state ); 67 todo.setPriority( m_state );
68 todo.setSummary( m_edit->text() ); 68 todo.setSummary( m_edit->text() );
69 if ( ((Todo::MainWindow *)parent())->currentCatId() != 0 ) 69 if ( ((Todo::MainWindow *)parent())->currentCatId() != 0 )
70 todo.setCategories( ((Todo::MainWindow *)parent())->currentCatId() ); 70 todo.setCategories( ((Todo::MainWindow *)parent())->currentCatId() );
71 71
72 m_todo = todo; 72 m_todo = todo;
73 commit(); 73 commit();
74 } 74 }
75 m_todo = todo; 75 m_todo = todo;
76 reinit(); 76 reinit();
77} 77}
78void QuickEditImpl::slotPrio() { 78void QuickEditImpl::slotPrio() {
79 m_state -= 2; 79 m_state -= 2;
80 if ( m_state < 1 ) 80 if ( m_state < 1 )
81 m_state = 5; 81 m_state = 5;
82 82
83 switch( m_state ) { 83 switch( m_state ) {
84 case 1: 84 case 1:
85 m_lbl->setPixmap( priority1 ); 85 m_lbl->setPixmap( priority1 );
86 break; 86 break;
87 case 5: 87 case 5:
88 m_lbl->setPixmap( priority5 ); 88 m_lbl->setPixmap( priority5 );
89 break; 89 break;
90 case 3: 90 case 3:
91 default: 91 default:
92 m_lbl->setPixmap( priority3 ); 92 m_lbl->setPixmap( priority3 );
93 break; 93 break;
94 } 94 }
95} 95}
96void QuickEditImpl::slotMore() { 96void QuickEditImpl::slotMore() {
97 // TODO - implement 97 // TODO - implement
98} 98}
99void QuickEditImpl::slotCancel() { 99void QuickEditImpl::slotCancel() {
100 reinit(); 100 reinit();
101} 101}
102void QuickEditImpl::reinit() { 102void QuickEditImpl::reinit() {
103 m_state = 3; 103 m_state = 3;
104 m_lbl->setPixmap( priority3 ); 104 m_lbl->setPixmap( priority3 );
105 m_edit->clear(); 105 m_edit->clear();
106} 106}
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
@@ -1,207 +1,223 @@
1/* 1/*
2               =. This file is part of the OPIE Project 2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 <zecke> 3             .=l. Copyright (c) 2002 <zecke>
4           .>+-= 4           .>+-=
5 _;:,     .>    :=|. This program is free software; you can 5 _;:,     .>    :=|. This program is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under 6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU General Public 7:`=1 )Y*s>-.--   : the terms of the GNU General Public
8.="- .-=="i,     .._ License as published by the Free Software 8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License, 9 - .   .-<_>     .<> Foundation; either version 2 of the License,
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#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
136 return uid; 152 return uid;
137} 153}
138QString TableView::currentRepresentation() { 154QString TableView::currentRepresentation() {
139 OTodo to = sorted()[currentRow()]; 155 OTodo to = sorted()[currentRow()];
140 return to.summary().isEmpty() ? to.description().left(20) : to.summary() ; 156 return to.summary().isEmpty() ? to.description().left(20) : to.summary() ;
141} 157}
142/* show overdue */ 158/* show overdue */
143void TableView::showOverDue( bool ) { 159void TableView::showOverDue( bool ) {
144 clear(); 160 clear();
145 updateView(); 161 updateView();
146} 162}
147 163
148void TableView::updateView( ) { 164void TableView::updateView( ) {
149 qWarning("update view"); 165 qWarning("update view");
150 m_row = false; 166 m_row = false;
151 static int id; 167 static int id;
152 id = startTimer(4000 ); 168 id = startTimer(4000 );
153 /* FIXME we want one page to be read! 169 /* FIXME we want one page to be read!
154 * 170 *
155 * Calculate that screensize 171 * Calculate that screensize
156 */ 172 */
157 todoWindow()->setReadAhead( 4 ); 173 todoWindow()->setReadAhead( 4 );
158 sort(); 174 sort();
159 OTodoAccess::List::Iterator it, end; 175 OTodoAccess::List::Iterator it, end;
160 it = sorted().begin(); 176 it = sorted().begin();
161 end = sorted().end(); 177 end = sorted().end();
162 178
163 qWarning("setTodos"); 179 qWarning("setTodos");
164 QTime time; 180 QTime time;
165 time.start(); 181 time.start();
166 m_enablePaint = false; 182 m_enablePaint = false;
167 setUpdatesEnabled( false ); 183 setUpdatesEnabled( false );
168 viewport()->setUpdatesEnabled( false ); 184 viewport()->setUpdatesEnabled( false );
169 185
170 setNumRows( it.count() ); 186 setNumRows( it.count() );
171 if ( it.count() == 0 ) 187 if ( it.count() == 0 )
172 killTimer(id); 188 killTimer(id);
173 189
174// int elc = time.elapsed(); 190// int elc = time.elapsed();
175 setUpdatesEnabled( true ); 191 setUpdatesEnabled( true );
176 viewport()->setUpdatesEnabled( true ); 192 viewport()->setUpdatesEnabled( true );
177 viewport()->update(); 193 viewport()->update();
178 194
179 m_enablePaint = true; 195 m_enablePaint = true;
180// int el = time.elapsed(); 196// int el = time.elapsed();
181} 197}
182void TableView::setTodo( int, const OTodo&) { 198void TableView::setTodo( int, const OTodo&) {
183 sort(); 199 sort();
184 200
185 /* repaint */ 201 /* repaint */
186 repaint(); 202 repaint();
187} 203}
188void TableView::addEvent( const OTodo&) { 204void TableView::addEvent( const OTodo&) {
189 205
190 /* fix problems of not showing the 'Haken' */ 206 /* fix problems of not showing the 'Haken' */
191 updateView(); 207 updateView();
192} 208}
193/* 209/*
194 * find the event 210 * find the event
195 * and then replace the complete row 211 * and then replace the complete row
196 */ 212 */
197void TableView::replaceEvent( const OTodo& ev) { 213void TableView::replaceEvent( const OTodo& ev) {
198 addEvent( ev ); 214 addEvent( ev );
199} 215}
200/* 216/*
201 * re aligning table can be slow too 217 * re aligning table can be slow too
202 * FIXME: look what performs better 218 * FIXME: look what performs better
203 * either this or the old align table 219 * either this or the old align table
204 */ 220 */
205void TableView::removeEvent( int ) { 221void TableView::removeEvent( int ) {
206 updateView(); 222 updateView();
207} 223}
@@ -222,290 +238,277 @@ void TableView::setShowCategory( const QString& str) {
222 updateView(); 238 updateView();
223 239
224 m_oleCat = str; 240 m_oleCat = str;
225 m_first = false; 241 m_first = false;
226 242
227} 243}
228void TableView::clear() { 244void TableView::clear() {
229 setNumRows(0); 245 setNumRows(0);
230} 246}
231void TableView::slotClicked(int row, int col, int, 247void TableView::slotClicked(int row, int col, int,
232 const QPoint& point) { 248 const QPoint& point) {
233 if ( !cellGeometry(row, col ).contains(point ) ) 249 if ( !cellGeometry(row, col ).contains(point ) )
234 return; 250 return;
235 251
236 int ui= sorted().uidAt( row ); 252 int ui= sorted().uidAt( row );
237 253
238 254
239 switch( col ) { 255 switch( col ) {
240 case 0:{ 256 case 0:{
241 int x = point.x() -columnPos( col ); 257 int x = point.x() -columnPos( col );
242 int y = point.y() -rowPos( row ); 258 int y = point.y() -rowPos( row );
243 int w = columnWidth( col ); 259 int w = columnWidth( col );
244 int h = rowHeight( row ); 260 int h = rowHeight( row );
245 if ( x >= ( w - BoxSize ) / 2 && 261 if ( x >= ( w - BoxSize ) / 2 &&
246 x <= ( w - BoxSize ) / 2 + BoxSize && 262 x <= ( w - BoxSize ) / 2 + BoxSize &&
247 y >= ( h - BoxSize ) / 2 && 263 y >= ( h - BoxSize ) / 2 &&
248 y <= ( h - BoxSize ) / 2 + BoxSize ) { 264 y <= ( h - BoxSize ) / 2 + BoxSize ) {
249 TodoView::complete(sorted()[row] ); 265 TodoView::complete(sorted()[row] );
250 } 266 }
251 } 267 }
252 break; 268 break;
253 269
254 case 1: 270 case 1:
255 break; 271 break;
256 272
257 case 2: { 273 case 2: {
258 m_menuTimer->stop(); 274 m_menuTimer->stop();
259 showTodo( ui ); 275 showTodo( ui );
260 break; 276 break;
261 } 277 }
262 case 3: { 278 case 3: {
263 m_menuTimer->stop(); 279 m_menuTimer->stop();
264 TodoView::edit( ui ); 280 TodoView::edit( ui );
265 break; 281 break;
266 } 282 }
267 } 283 }
268 284
269 285
270} 286}
271void TableView::slotPressed(int row, int col, int, 287void TableView::slotPressed(int row, int col, int,
272 const QPoint& point) { 288 const QPoint& point) {
273 289
274 qWarning("pressed row %d col %d x:%d+y:%d", row,col,point.x(),point.y() ); 290 qWarning("pressed row %d col %d x:%d+y:%d", row,col,point.x(),point.y() );
275 m_prevP = point; 291 m_prevP = point;
276 /* TextColumn column */ 292 /* TextColumn column */
277 if ( col == 2 && cellGeometry( row, col ).contains( point ) ) 293 if ( col == 2 && cellGeometry( row, col ).contains( point ) )
278 m_menuTimer->start( 750, TRUE ); 294 m_menuTimer->start( 750, TRUE );
279} 295}
280void TableView::slotValueChanged( int, int ) { 296void TableView::slotValueChanged( int, int ) {
281 qWarning("Value Changed"); 297 qWarning("Value Changed");
282} 298}
283void TableView::slotCurrentChanged(int, int ) { 299void TableView::slotCurrentChanged(int, int ) {
284 m_menuTimer->stop(); 300 m_menuTimer->stop();
285} 301}
286QWidget* TableView::widget() { 302QWidget* TableView::widget() {
287 return this; 303 return this;
288} 304}
289/* 305/*
290 * We need to overwrite sortColumn 306 * We need to overwrite sortColumn
291 * because we want to sort whole row 307 * because we want to sort whole row
292 * based 308 * based
293 * We event want to set the setOrder 309 * We event want to set the setOrder
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();
440 } 443 }
441 } 444 }
442 }else if ( col == 2) { 445 }else if ( col == 2) {
443 QWidget* wid = cellWidget(row, 2); 446 QWidget* wid = cellWidget(row, 2);
444 if ( wid->inherits("QLineEdit") ) { 447 if ( wid->inherits("QLineEdit") ) {
445 QString text = ((QLineEdit*)wid)->text(); 448 QString text = ((QLineEdit*)wid)->text();
446 OTodo todo = sorted()[row]; 449 OTodo todo = sorted()[row];
447 if ( todo.summary() != text ) { 450 if ( todo.summary() != text ) {
448 todo.setSummary( text ); 451 todo.setSummary( text );
449 TodoView::update( todo.uid(), todo ); 452 TodoView::update( todo.uid(), todo );
450 updateView(); 453 updateView();
451 } 454 }
452 } 455 }
453 } 456 }
454} 457}
455void TableView::slotPriority() { 458void TableView::slotPriority() {
456 setCellContentFromEditor( currentRow(), currentColumn() ); 459 setCellContentFromEditor( currentRow(), currentColumn() );
457} 460}
458/* 461/*
459 * We'll use the TimerEvent to read ahead or to keep the cahce always 462 * We'll use the TimerEvent to read ahead or to keep the cahce always
460 * filled enough. 463 * filled enough.
461 * We will try to read ahead 4 items in both ways 464 * We will try to read ahead 4 items in both ways
462 * up and down. On odd or even we will currentRow()+-4 or +-9 465 * up and down. On odd or even we will currentRow()+-4 or +-9
463 * 466 *
464 */ 467 */
465void TableView::timerEvent( QTimerEvent* ev ) { 468void TableView::timerEvent( QTimerEvent* ev ) {
466// qWarning("sorted %d", sorted().count() ); 469// qWarning("sorted %d", sorted().count() );
467 if (sorted().count() == 0 ) 470 if (sorted().count() == 0 )
468 return; 471 return;
469 472
470 int row = currentRow(); 473 int row = currentRow();
471 if ( m_row ) { 474 if ( m_row ) {
472 int ro = row-4; 475 int ro = row-4;
473 if (ro < 0 ) ro = 0; 476 if (ro < 0 ) ro = 0;
474 sorted()[ro]; 477 sorted()[ro];
475 478
476 ro = row+4; 479 ro = row+4;
477 sorted()[ro]; 480 sorted()[ro];
478 } else { 481 } else {
479 int ro = row + 8; 482 int ro = row + 8;
480 sorted()[ro]; 483 sorted()[ro];
481 484
482 ro = row-8; 485 ro = row-8;
483 if (ro < 0 ) ro = 0; 486 if (ro < 0 ) ro = 0;
484 sorted()[ro]; 487 sorted()[ro];
485 } 488 }
486 489
487 m_row = !m_row; 490 m_row = !m_row;
488} 491}
489 492
490// We want a strike through completed ;) 493// We want a strike through completed ;)
491// durchstreichen to complete 494// durchstreichen to complete
492/* 495/*
493 * MouseTracking is off this mean we only receive 496 * MouseTracking is off this mean we only receive
494 * these events if the mouse button is pressed 497 * these events if the mouse button is pressed
495 * We've the previous point saved 498 * We've the previous point saved
496 * We check if the previous and current Point are 499 * We check if the previous and current Point are
497 * in the same row. 500 * in the same row.
498 * Then we check if they're some pixel horizontal away 501 * Then we check if they're some pixel horizontal away
499 * if the distance between the two points is greater than 502 * if the distance between the two points is greater than
500 * 8 we mark the underlying todo as completed and do a repaint 503 * 8 we mark the underlying todo as completed and do a repaint
501 * 504 *
502 * BUG: When clicking on the Due column and it's scrollable 505 * BUG: When clicking on the Due column and it's scrollable
503 * the todo is marked as completed... 506 * the todo is marked as completed...
504 * REASON: QTable is doing auto scrolling which leads to a move 507 * REASON: QTable is doing auto scrolling which leads to a move
505 * in the x coordinate and this way it's able to pass the 508 * in the x coordinate and this way it's able to pass the
506 * m_completeStrokeWidth criteria 509 * m_completeStrokeWidth criteria
507 * WORKAROUND: strike through needs to strike through the same 510 * WORKAROUND: strike through needs to strike through the same
508 * row and two columns! 511 * row and two columns!
509 */ 512 */
510void TableView::contentsMouseReleaseEvent( QMouseEvent* e) { 513void TableView::contentsMouseReleaseEvent( QMouseEvent* e) {
511 int row = rowAt(m_prevP.y()); 514 int row = rowAt(m_prevP.y());
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
@@ -1,107 +1,111 @@
1/* 1/*
2               =. This file is part of the OPIE Project 2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 <> 3             .=l. Copyright (c) 2002 <>
4           .>+-= 4           .>+-=
5 _;:,     .>    :=|. This program is free software; you can 5 _;:,     .>    :=|. This program is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under 6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU General Public 7:`=1 )Y*s>-.--   : the terms of the GNU General Public
8.="- .-=="i,     .._ License as published by the Free Software 8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License, 9 - .   .-<_>     .<> Foundation; either version 2 of the License,
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 );
58 void replaceEvent( const OTodo& ); 59 void replaceEvent( const OTodo& );
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
107#endif 111#endif