summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/todo/mainwindow.cpp29
-rw-r--r--core/pim/todo/mainwindow.h16
-rw-r--r--core/pim/todo/quickedit.cpp22
-rw-r--r--core/pim/todo/quickedit.h45
-rw-r--r--core/pim/todo/quickeditimpl.cpp89
-rw-r--r--core/pim/todo/quickeditimpl.h34
-rw-r--r--core/pim/todo/tableview.cpp14
-rw-r--r--core/pim/todo/todo.pro8
8 files changed, 247 insertions, 10 deletions
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp
index a6d657c..8377573 100644
--- a/core/pim/todo/mainwindow.cpp
+++ b/core/pim/todo/mainwindow.cpp
@@ -1,355 +1,365 @@
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  -_. . .   )=.  = General Public License along with 21  -_. . .   )=.  = 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#include <unistd.h> 29#include <unistd.h>
30 30
31#include <qmenubar.h> 31#include <qmenubar.h>
32#include <qmessagebox.h> 32#include <qmessagebox.h>
33#include <qtoolbar.h> 33#include <qtoolbar.h>
34#include <qpopupmenu.h> 34#include <qpopupmenu.h>
35#include <qwidgetstack.h> 35#include <qwidgetstack.h>
36#include <qaction.h> 36#include <qaction.h>
37#include <qtimer.h> 37#include <qtimer.h>
38#include <qvbox.h>
39#include <qlineedit.h>
38 40
39#include <qpe/applnk.h> 41#include <qpe/applnk.h>
40#include <qpe/config.h> 42#include <qpe/config.h>
41#include <qpe/ir.h> 43#include <qpe/ir.h>
42#include <qpe/resource.h> 44#include <qpe/resource.h>
43#include <qpe/qpemessagebox.h> 45#include <qpe/qpemessagebox.h>
44 46
45#include <opie/otodoaccessvcal.h> 47#include <opie/otodoaccessvcal.h>
46 48
49#include "quickeditimpl.h"
47#include "todotemplatemanager.h" 50#include "todotemplatemanager.h"
48#include "templateeditor.h" 51#include "templateeditor.h"
49#include "todoentryimpl.h" 52#include "todoentryimpl.h"
50#include "tableview.h" 53#include "tableview.h"
51 54
52#include "textviewshow.h" 55#include "textviewshow.h"
53#include "todoeditor.h" 56#include "todoeditor.h"
54#include "mainwindow.h" 57#include "mainwindow.h"
55 58
56 59
57using namespace Todo; 60using namespace Todo;
58 61
59MainWindow::MainWindow( QWidget* parent, 62MainWindow::MainWindow( QWidget* parent,
60 const char* name ) { 63 const char* name ) {
61 64
62 m_syncing = false; 65 m_syncing = false;
63 m_counter = 0; 66 m_counter = 0;
64 m_tempManager = new TemplateManager(); 67 m_tempManager = new TemplateManager();
65 m_tempManager->load(); 68 m_tempManager->load();
66 69
67 initUI(); 70 initUI();
68 initConfig(); 71 initConfig();
69 initViews(); 72 initViews();
70 initActions(); 73 initActions();
71 initEditor(); 74 initEditor();
72 initShow(); 75 initShow();
73 initTemplate(); 76 initTemplate();
74 77
75 populateTemplates(); 78 populateTemplates();
76 raiseCurrentView(); 79 raiseCurrentView();
77 QTimer::singleShot(0, this, SLOT(populateCategories() ) ); 80 QTimer::singleShot(0, this, SLOT(populateCategories() ) );
78} 81}
79void MainWindow::initTemplate() { 82void MainWindow::initTemplate() {
80 m_curTempEd = new TemplateEditor( this, templateManager() ); 83 m_curTempEd = new TemplateEditor( this, templateManager() );
81} 84}
82void MainWindow::initActions() { 85void MainWindow::initActions() {
83 QAction* a = new QAction( tr("New Task" ), Resource::loadPixmap( "new" ), 86 QAction* a = new QAction( tr("New Task" ), Resource::loadPixmap( "new" ),
84 QString::null, 0, this, 0 ); 87 QString::null, 0, this, 0 );
85 connect(a, SIGNAL( activated() ), 88 connect(a, SIGNAL( activated() ),
86 this, SLOT( slotNew() ) ); 89 this, SLOT( slotNew() ) );
87 a->addTo(m_tool ); 90 a->addTo(m_tool );
88 a->addTo(m_edit ); 91 a->addTo(m_edit );
89 92
90 a = new QAction( tr("Edit Task"), Resource::loadIconSet( "edit" ), 93 a = new QAction( tr("Edit Task"), Resource::loadIconSet( "edit" ),
91 QString::null, 0, this, 0 ); 94 QString::null, 0, this, 0 );
92 connect(a, SIGNAL(activated() ), 95 connect(a, SIGNAL(activated() ),
93 this, SLOT( slotEdit() ) ); 96 this, SLOT( slotEdit() ) );
94 a->addTo( m_tool ); 97 a->addTo( m_tool );
95 a->addTo( m_edit ); 98 a->addTo( m_edit );
96 m_editAction = a; 99 m_editAction = a;
97 100
98 a = new QAction( QString::null, tr("View Task"), 0, this, 0 ); 101 a = new QAction( QString::null, tr("View Task"), 0, this, 0 );
99 connect(a, SIGNAL( activated() ), 102 connect(a, SIGNAL( activated() ),
100 this, SLOT( slotShowDetails() ) ); 103 this, SLOT( slotShowDetails() ) );
101 a->addTo( m_edit ); 104 a->addTo( m_edit );
102 105
103 m_edit->insertSeparator(); 106 m_edit->insertSeparator();
104 107
105 a = new QAction( tr("Delete..."), Resource::loadIconSet( "trash" ), 108 a = new QAction( tr("Delete..."), Resource::loadIconSet( "trash" ),
106 QString::null, 0, this, 0 ); 109 QString::null, 0, this, 0 );
107 connect(a, SIGNAL(activated() ), 110 connect(a, SIGNAL(activated() ),
108 this, SLOT(slotDelete() ) ); 111 this, SLOT(slotDelete() ) );
109 a->addTo( m_tool ); 112 a->addTo( m_tool );
110 a->addTo( m_edit ); 113 a->addTo( m_edit );
111 m_deleteAction = a; 114 m_deleteAction = a;
112 115
113 a = new QAction( QString::null, tr("Delete all..."), 0, this, 0 ); 116 a = new QAction( QString::null, tr("Delete all..."), 0, this, 0 );
114 connect(a, SIGNAL( activated() ), 117 connect(a, SIGNAL( activated() ),
115 this, SLOT( slotDeleteAll() ) ); 118 this, SLOT( slotDeleteAll() ) );
116 a->addTo(m_edit ); 119 a->addTo(m_edit );
117 m_deleteAllAction = a; 120 m_deleteAllAction = a;
118 121
119 a = new QAction( QString::null, tr("Delete completed"), 122 a = new QAction( QString::null, tr("Delete completed"),
120 0, this, 0 ); 123 0, this, 0 );
121 connect(a, SIGNAL( activated() ), 124 connect(a, SIGNAL( activated() ),
122 this, SLOT( slotDeleteCompleted() ) ); 125 this, SLOT( slotDeleteCompleted() ) );
123 a->addTo(m_edit ); 126 a->addTo(m_edit );
124 a->setEnabled( TRUE ); 127 a->setEnabled( TRUE );
125 m_deleteCompleteAction = a; 128 m_deleteCompleteAction = a;
126 129
127 m_edit->insertSeparator(); 130 m_edit->insertSeparator();
128 131
129 a = new QAction( QString::null, tr("Duplicate"), 0, this, 0 ); 132 a = new QAction( QString::null, tr("Duplicate"), 0, this, 0 );
130 connect(a, SIGNAL( activated() ), 133 connect(a, SIGNAL( activated() ),
131 this, SLOT( slotDuplicate() ) ); 134 this, SLOT( slotDuplicate() ) );
132 a->addTo(m_edit ); 135 a->addTo(m_edit );
133 m_duplicateAction = a; 136 m_duplicateAction = a;
134 137
135 m_edit->insertSeparator(); 138 m_edit->insertSeparator();
136 139
137 if ( Ir::supported() ) { 140 if ( Ir::supported() ) {
138 a = new QAction( tr( "Beam" ), Resource::loadPixmap( "beam" ), 141 a = new QAction( tr( "Beam" ), Resource::loadPixmap( "beam" ),
139 QString::null, 0, this, 0 ); 142 QString::null, 0, this, 0 );
140 connect( a, SIGNAL( activated() ), 143 connect( a, SIGNAL( activated() ),
141 this, SLOT( slotBeam() ) ); 144 this, SLOT( slotBeam() ) );
142 a->addTo( m_edit ); 145 a->addTo( m_edit );
143 a->addTo( m_tool ); 146 a->addTo( m_tool );
144 } 147 }
145 148
146 a = new QAction( tr("Find"), Resource::loadIconSet( "mag" ), 149 a = new QAction( tr("Find"), Resource::loadIconSet( "mag" ),
147 QString::null, 0, this, 0 ); 150 QString::null, 0, this, 0 );
148 connect(a, SIGNAL( activated() ), 151 connect(a, SIGNAL( activated() ),
149 this, SLOT( slotFind() ) ); 152 this, SLOT( slotFind() ) );
150 a->addTo( m_options ); 153 a->addTo( m_options );
151 m_findAction = a; 154 m_findAction = a;
152 155
153 m_options->insertSeparator(); 156 m_options->insertSeparator();
154 157
155 m_completedAction = new QAction( QString::null, tr("Completed tasks"), 158 m_completedAction = new QAction( QString::null, tr("Completed tasks"),
156 0, this, 0, TRUE ); 159 0, this, 0, TRUE );
157 m_completedAction->addTo( m_options ); 160 m_completedAction->addTo( m_options );
158 m_completedAction->setOn( showCompleted() ); 161 m_completedAction->setOn( showCompleted() );
159 connect(m_completedAction, SIGNAL( toggled(bool) ), 162 connect(m_completedAction, SIGNAL( toggled(bool) ),
160 this, SLOT(slotShowCompleted(bool) ) ); 163 this, SLOT(slotShowCompleted(bool) ) );
161 164
162 m_showDeadLineAction = new QAction( QString::null, tr("Show Deadline"), 165 m_showDeadLineAction = new QAction( QString::null, tr("Show Deadline"),
163 0, this, 0, TRUE ); 166 0, this, 0, TRUE );
164 m_showDeadLineAction->addTo( m_options ); 167 m_showDeadLineAction->addTo( m_options );
165 m_showDeadLineAction->setOn( showDeadline() ); 168 m_showDeadLineAction->setOn( showDeadline() );
166 connect(m_showDeadLineAction, SIGNAL(toggled(bool) ), 169 connect(m_showDeadLineAction, SIGNAL(toggled(bool) ),
167 this, SLOT( slotShowDeadLine( bool ) ) ); 170 this, SLOT( slotShowDeadLine( bool ) ) );
168 171
169 m_options->insertSeparator(); 172 m_options->insertSeparator();
170 173
171 m_bar->insertItem( tr("Data") ,m_edit ); 174 m_bar->insertItem( tr("Data") ,m_edit );
172 m_bar->insertItem( tr("Category"), m_catMenu ); 175 m_bar->insertItem( tr("Category"), m_catMenu );
173 m_bar->insertItem( tr("Options"), m_options ); 176 m_bar->insertItem( tr("Options"), m_options );
174 177
175 /* initialize the view menu */ 178 /* initialize the view menu */
176 a = new QAction( QString::null, tr("Show over due"), 179 a = new QAction( QString::null, tr("Show over due"),
177 0, this, 0, TRUE ); 180 0, this, 0, TRUE );
178 a->addTo( m_view ); 181 a->addTo( m_view );
179 a->setOn( showOverDue() ); 182 a->setOn( showOverDue() );
180 connect(a, SIGNAL(toggled(bool)), 183 connect(a, SIGNAL(toggled(bool)),
181 this, SLOT(slotShowDue(bool) ) ); 184 this, SLOT(slotShowDue(bool) ) );
182 m_view->insertSeparator(); 185 m_view->insertSeparator();
183 186
184 m_bar->insertItem( tr("View"), m_view ); 187 m_bar->insertItem( tr("View"), m_view );
185 188
186 /* templates */ 189 /* templates */
187 m_edit->insertItem(tr("New from template"), m_template, 190 m_edit->insertItem(tr("New from template"), m_template,
188 -1, 0 ); 191 -1, 0 );
189 192
190} 193}
191/* m_curCat from Config */ 194/* m_curCat from Config */
192void MainWindow::initConfig() { 195void MainWindow::initConfig() {
193 Config config( "todo" ); 196 Config config( "todo" );
194 config.setGroup( "View" ); 197 config.setGroup( "View" );
195 m_completed = config.readBoolEntry( "ShowComplete", TRUE ); 198 m_completed = config.readBoolEntry( "ShowComplete", TRUE );
196 m_curCat = config.readEntry( "Category", QString::null ); 199 m_curCat = config.readEntry( "Category", QString::null );
197 m_deadline = config.readBoolEntry( "ShowDeadLine", TRUE); 200 m_deadline = config.readBoolEntry( "ShowDeadLine", TRUE);
198 m_overdue = config.readBoolEntry("ShowOverDue", TRUE ); 201 m_overdue = config.readBoolEntry("ShowOverDue", TRUE );
199} 202}
200void MainWindow::initUI() { 203void MainWindow::initUI() {
201 m_stack = new QWidgetStack(this, "main stack"); 204 m_mainBox = new QVBox(this, "main box ");
202 setCentralWidget( m_stack ); 205 m_curQuick = new QuickEditImpl(this, m_mainBox );
206 m_curQuick->signal()->connect( this, SLOT(slotQuickEntered() ) );
207 m_quickEdit.append( m_curQuick );
208
209
210
211 m_stack = new QWidgetStack(m_mainBox, "main stack");
212 setCentralWidget( m_mainBox );
203 213
204 setToolBarsMovable( FALSE ); 214 setToolBarsMovable( FALSE );
205 215
206 m_tool = new QToolBar( this ); 216 m_tool = new QToolBar( this );
207 m_tool->setHorizontalStretchable( TRUE ); 217 m_tool->setHorizontalStretchable( TRUE );
208 218
209 m_bar = new QMenuBar( m_tool ); 219 m_bar = new QMenuBar( m_tool );
210 220
211 /** QPopupMenu */ 221 /** QPopupMenu */
212 m_edit = new QPopupMenu( this ); 222 m_edit = new QPopupMenu( this );
213 m_options = new QPopupMenu( this ); 223 m_options = new QPopupMenu( this );
214 m_view = new QPopupMenu( this ); 224 m_view = new QPopupMenu( this );
215 m_catMenu = new QPopupMenu( this ); 225 m_catMenu = new QPopupMenu( this );
216 m_template = new QPopupMenu( this ); 226 m_template = new QPopupMenu( this );
217 227
218 m_catMenu->setCheckable( TRUE ); 228 m_catMenu->setCheckable( TRUE );
219 m_template->setCheckable( TRUE ); 229 m_template->setCheckable( TRUE );
220 230
221 connect(m_catMenu, SIGNAL(activated(int) ), 231 connect(m_catMenu, SIGNAL(activated(int) ),
222 this, SLOT(setCategory(int) ) ); 232 this, SLOT(setCategory(int) ) );
223 connect(m_template, SIGNAL(activated(int) ), 233 connect(m_template, SIGNAL(activated(int) ),
224 this, SLOT(slotNewFromTemplate(int) ) ); 234 this, SLOT(slotNewFromTemplate(int) ) );
225} 235}
226void MainWindow::initViews() { 236void MainWindow::initViews() {
227 TableView* tableView = new TableView( this, this ); 237 TableView* tableView = new TableView( this, m_stack );
228 m_stack->addWidget( tableView, m_counter++ ); 238 m_stack->addWidget( tableView, m_counter++ );
229 m_views.append( tableView ); 239 m_views.append( tableView );
230 m_curView = tableView; 240 m_curView = tableView;
231 connectBase( tableView ); 241 connectBase( tableView );
232 /* add QString type + QString configname to 242 /* add QString type + QString configname to
233 * the View menu 243 * the View menu
234 * and subdirs for multiple views 244 * and subdirs for multiple views
235 */ 245 */
236} 246}
237void MainWindow::initEditor() { 247void MainWindow::initEditor() {
238 m_curEdit = new Editor(); 248 m_curEdit = new Editor();
239} 249}
240void MainWindow::initShow() { 250void MainWindow::initShow() {
241 m_curShow = new TextViewShow(this); 251 m_curShow = new TextViewShow(this);
242 m_stack->addWidget( m_curShow->widget() , m_counter++ ); 252 m_stack->addWidget( m_curShow->widget() , m_counter++ );
243} 253}
244MainWindow::~MainWindow() { 254MainWindow::~MainWindow() {
245 delete templateManager(); 255 delete templateManager();
246} 256}
247void MainWindow::connectBase( ViewBase* base) { 257void MainWindow::connectBase( ViewBase* base) {
248 base->connectShow( this, SLOT(slotShow(int) ) ); 258 base->connectShow( this, SLOT(slotShow(int) ) );
249 base->connectEdit( this, SLOT(slotEdit(int) ) ); 259 base->connectEdit( this, SLOT(slotEdit(int) ) );
250 base->connectUpdateSmall( this, 260 base->connectUpdateSmall( this,
251 SLOT(slotUpate1(int, const Todo::SmallTodo&) )); 261 SLOT(slotUpate1(int, const Todo::SmallTodo&) ));
252 base->connectUpdateBig( this, 262 base->connectUpdateBig( this,
253 SLOT(slotUpate2(int, const OTodo& ) ) ); 263 SLOT(slotUpate2(int, const OTodo& ) ) );
254 base->connectUpdateView( this, SLOT(slotUpdate3( QWidget* ) ) ) ; 264 base->connectUpdateView( this, SLOT(slotUpdate3( QWidget* ) ) ) ;
255 base->connectRemove(&m_todoMgr, 265 base->connectRemove(&m_todoMgr,
256 SLOT(remove(int)) ); 266 SLOT(remove(int)) );
257} 267}
258QPopupMenu* MainWindow::contextMenu( int uid ) { 268QPopupMenu* MainWindow::contextMenu( int uid ) {
259 QPopupMenu* menu = new QPopupMenu(); 269 QPopupMenu* menu = new QPopupMenu();
260 270
261 m_editAction->addTo( menu ); 271 m_editAction->addTo( menu );
262 m_deleteAction->addTo( menu ); 272 m_deleteAction->addTo( menu );
263 m_duplicateAction->addTo( menu ); 273 m_duplicateAction->addTo( menu );
264 menu->insertSeparator(); 274 menu->insertSeparator();
265 275
266 return menu; 276 return menu;
267} 277}
268QPopupMenu* MainWindow::options() { 278QPopupMenu* MainWindow::options() {
269 qWarning("Options"); 279 qWarning("Options");
270 return m_options; 280 return m_options;
271} 281}
272QPopupMenu* MainWindow::edit() { 282QPopupMenu* MainWindow::edit() {
273 return m_edit; 283 return m_edit;
274} 284}
275QPopupMenu* MainWindow::view() { 285QPopupMenu* MainWindow::view() {
276 return m_view; 286 return m_view;
277} 287}
278QToolBar* MainWindow::toolbar() { 288QToolBar* MainWindow::toolbar() {
279 return m_tool; 289 return m_tool;
280} 290}
281OTodoAccess::List MainWindow::list()const { 291OTodoAccess::List MainWindow::list()const {
282 return m_todoMgr.list(); 292 return m_todoMgr.list();
283} 293}
284OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder ) { 294OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder ) {
285 int cat = 0; 295 int cat = 0;
286 if ( m_curCat != tr("All Categories") ) 296 if ( m_curCat != tr("All Categories") )
287 cat = currentCatId(); 297 cat = currentCatId();
288 298
289 int filter = 1; 299 int filter = 1;
290 300
291 if (!m_completed ) 301 if (!m_completed )
292 filter |= 4; 302 filter |= 4;
293 if (m_overdue) 303 if (m_overdue)
294 filter |= 2; 304 filter |= 2;
295 305
296 return m_todoMgr.sorted( asc, sortOrder, filter, cat ); 306 return m_todoMgr.sorted( asc, sortOrder, filter, cat );
297} 307}
298OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder, int addFilter) { 308OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder, int addFilter) {
299 int cat = 0; 309 int cat = 0;
300 if ( m_curCat != tr("All Categories") ) 310 if ( m_curCat != tr("All Categories") )
301 cat = currentCatId(); 311 cat = currentCatId();
302 312
303 return m_todoMgr.sorted(asc, sortOrder, addFilter, cat ); 313 return m_todoMgr.sorted(asc, sortOrder, addFilter, cat );
304} 314}
305OTodo MainWindow::event( int uid ) { 315OTodo MainWindow::event( int uid ) {
306 return m_todoMgr.event( uid ); 316 return m_todoMgr.event( uid );
307} 317}
308bool MainWindow::isSyncing()const { 318bool MainWindow::isSyncing()const {
309 return m_syncing; 319 return m_syncing;
310} 320}
311TemplateManager* MainWindow::templateManager() { 321TemplateManager* MainWindow::templateManager() {
312 return m_tempManager; 322 return m_tempManager;
313} 323}
314Editor* MainWindow::currentEditor() { 324Editor* MainWindow::currentEditor() {
315 return m_curEdit; 325 return m_curEdit;
316} 326}
317TodoShow* MainWindow::currentShow() { 327TodoShow* MainWindow::currentShow() {
318 return m_curShow; 328 return m_curShow;
319} 329}
320void MainWindow::slotReload() { 330void MainWindow::slotReload() {
321 m_todoMgr.reload(); 331 m_todoMgr.reload();
322 currentView()->updateView( ); 332 currentView()->updateView( );
323 raiseCurrentView(); 333 raiseCurrentView();
324} 334}
325void MainWindow::closeEvent( QCloseEvent* e ) { 335void MainWindow::closeEvent( QCloseEvent* e ) {
326 if (m_stack->visibleWidget() == currentShow()->widget() ) { 336 if (m_stack->visibleWidget() == currentShow()->widget() ) {
327 raiseCurrentView(); 337 raiseCurrentView();
328 e->ignore(); 338 e->ignore();
329 return; 339 return;
330 } 340 }
331 /* 341 /*
332 * we should have flushed and now we're still saving 342 * we should have flushed and now we're still saving
333 * so there is no need to flush 343 * so there is no need to flush
334 */ 344 */
335 if (m_syncing ) { 345 if (m_syncing ) {
336 e->accept(); 346 e->accept();
337 return; 347 return;
338 } 348 }
339 bool quit = false; 349 bool quit = false;
340 if ( m_todoMgr.saveAll() ){ 350 if ( m_todoMgr.saveAll() ){
341 qWarning("saved"); 351 qWarning("saved");
342 quit = true; 352 quit = true;
343 }else { 353 }else {
344 if ( QMessageBox::critical( this, tr("Out of space"), 354 if ( QMessageBox::critical( this, tr("Out of space"),
345 tr("Todo was unable\n" 355 tr("Todo was unable\n"
346 "to save your changes.\n" 356 "to save your changes.\n"
347 "Free up some space\n" 357 "Free up some space\n"
348 "and try again.\n" 358 "and try again.\n"
349 "\nQuit Anyway?"), 359 "\nQuit Anyway?"),
350 QMessageBox::Yes|QMessageBox::Escape, 360 QMessageBox::Yes|QMessageBox::Escape,
351 QMessageBox::No|QMessageBox::Default) 361 QMessageBox::No|QMessageBox::Default)
352 != QMessageBox::No ) { 362 != QMessageBox::No ) {
353 e->accept(); 363 e->accept();
354 quit = true; 364 quit = true;
355 }else 365 }else
@@ -556,128 +566,141 @@ void MainWindow::slotBeam() {
556 566
557} 567}
558void MainWindow::beamDone( Ir* ir) { 568void MainWindow::beamDone( Ir* ir) {
559 delete ir; 569 delete ir;
560 ::unlink( beamfile ); 570 ::unlink( beamfile );
561} 571}
562void MainWindow::receiveFile( const QString& filename ) { 572void MainWindow::receiveFile( const QString& filename ) {
563 OTodoAccessVCal* cal = new OTodoAccessVCal(filename ); 573 OTodoAccessVCal* cal = new OTodoAccessVCal(filename );
564 OTodoAccess acc( cal ); 574 OTodoAccess acc( cal );
565 acc.load(); 575 acc.load();
566 OTodoAccess::List list = acc.allRecords(); 576 OTodoAccess::List list = acc.allRecords();
567 577
568 QString message = tr("<P>%1 new tasks arrived.<p>Would you like to add them to your Todolist?").arg(list.count() ); 578 QString message = tr("<P>%1 new tasks arrived.<p>Would you like to add them to your Todolist?").arg(list.count() );
569 579
570 if ( QMessageBox::information(this, tr("New Tasks"), 580 if ( QMessageBox::information(this, tr("New Tasks"),
571 message, QMessageBox::Ok, 581 message, QMessageBox::Ok,
572 QMessageBox::Cancel ) == QMessageBox::Ok ) { 582 QMessageBox::Cancel ) == QMessageBox::Ok ) {
573 OTodoAccess::List::Iterator it; 583 OTodoAccess::List::Iterator it;
574 for ( it = list.begin(); it != list.end(); ++it ) 584 for ( it = list.begin(); it != list.end(); ++it )
575 m_todoMgr.add( (*it) ); 585 m_todoMgr.add( (*it) );
576 586
577 currentView()->updateView(); 587 currentView()->updateView();
578 } 588 }
579} 589}
580 590
581void MainWindow::slotFlush() { 591void MainWindow::slotFlush() {
582 m_syncing = FALSE; 592 m_syncing = FALSE;
583 m_todoMgr.save(); 593 m_todoMgr.save();
584} 594}
585void MainWindow::slotShowDetails() { 595void MainWindow::slotShowDetails() {
586 slotShow( currentView()->current() ); 596 slotShow( currentView()->current() );
587} 597}
588/* 598/*
589 * populate the Categories 599 * populate the Categories
590 * Menu 600 * Menu
591 */ 601 */
592void MainWindow::populateCategories() { 602void MainWindow::populateCategories() {
593 m_todoMgr.load(); 603 m_todoMgr.load();
594 604
595 m_catMenu->clear(); 605 m_catMenu->clear();
596 int id, rememberId; 606 int id, rememberId;
597 id = 1; 607 id = 1;
598 rememberId = 1; 608 rememberId = 1;
599 609
600 m_catMenu->insertItem( tr( "All Categories" ), id++ ); 610 m_catMenu->insertItem( tr( "All Categories" ), id++ );
601 m_catMenu->insertSeparator(); 611 m_catMenu->insertSeparator();
602 QStringList categories = m_todoMgr.categories(); 612 QStringList categories = m_todoMgr.categories();
603 categories.append( tr( "Unfiled" ) ); 613 categories.append( tr( "Unfiled" ) );
604 for ( QStringList::Iterator it = categories.begin(); 614 for ( QStringList::Iterator it = categories.begin();
605 it != categories.end(); ++it ) { 615 it != categories.end(); ++it ) {
606 m_catMenu->insertItem( *it, id ); 616 m_catMenu->insertItem( *it, id );
607 if ( *it == currentCategory() ) 617 if ( *it == currentCategory() )
608 rememberId = id; 618 rememberId = id;
609 ++id; 619 ++id;
610 } 620 }
611 setCategory( rememberId ); 621 setCategory( rememberId );
612} 622}
613bool MainWindow::showCompleted()const { 623bool MainWindow::showCompleted()const {
614 return m_completed; 624 return m_completed;
615} 625}
616bool MainWindow::showDeadline()const { 626bool MainWindow::showDeadline()const {
617 return m_deadline; 627 return m_deadline;
618} 628}
619QString MainWindow::currentCategory()const { 629QString MainWindow::currentCategory()const {
620 return m_curCat; 630 return m_curCat;
621} 631}
622int MainWindow::currentCatId() { 632int MainWindow::currentCatId() {
623 return m_todoMgr.catId( m_curCat ); 633 return m_todoMgr.catId( m_curCat );
624} 634}
625ViewBase* MainWindow::currentView() { 635ViewBase* MainWindow::currentView() {
626 return m_curView; 636 return m_curView;
627} 637}
628void MainWindow::raiseCurrentView() { 638void MainWindow::raiseCurrentView() {
629 m_stack->raiseWidget( m_curView->widget() ); 639 m_stack->raiseWidget( m_curView->widget() );
630} 640}
631void MainWindow::slotShowDue(bool ov) { 641void MainWindow::slotShowDue(bool ov) {
632 m_overdue = ov; 642 m_overdue = ov;
633 currentView()->showOverDue( ov ); 643 currentView()->showOverDue( ov );
634 raiseCurrentView(); 644 raiseCurrentView();
635} 645}
636void MainWindow::slotShow( int uid ) { 646void MainWindow::slotShow( int uid ) {
637 qWarning("slotShow"); 647 qWarning("slotShow");
638 currentShow()->slotShow( event( uid ) ); 648 currentShow()->slotShow( event( uid ) );
639 m_stack->raiseWidget( currentShow()->widget() ); 649 m_stack->raiseWidget( currentShow()->widget() );
640} 650}
641void MainWindow::slotEdit( int uid ) { 651void MainWindow::slotEdit( int uid ) {
642 if(m_syncing) { 652 if(m_syncing) {
643 QMessageBox::warning(this, tr("Todo"), 653 QMessageBox::warning(this, tr("Todo"),
644 tr("Can not edit data, currently syncing")); 654 tr("Can not edit data, currently syncing"));
645 return; 655 return;
646 } 656 }
647 657
648 OTodo todo = m_todoMgr.event( uid ); 658 OTodo todo = m_todoMgr.event( uid );
649 659
650 todo = currentEditor()->edit(this, todo ); 660 todo = currentEditor()->edit(this, todo );
651 661
652 /* if completed */ 662 /* if completed */
653 if ( currentEditor()->accepted() ) { 663 if ( currentEditor()->accepted() ) {
654 qWarning("Replacing now" ); 664 qWarning("Replacing now" );
655 m_todoMgr.update( todo.uid(), todo ); 665 m_todoMgr.update( todo.uid(), todo );
656 currentView()->replaceEvent( todo ); 666 currentView()->replaceEvent( todo );
657 /* a Category might have changed */ 667 /* a Category might have changed */
658 populateCategories(); 668 populateCategories();
659 } 669 }
660 670
661 raiseCurrentView(); 671 raiseCurrentView();
662} 672}
663/* 673/*
664void MainWindow::slotUpdate1( int uid, const SmallTodo& ev) { 674void MainWindow::slotUpdate1( int uid, const SmallTodo& ev) {
665 m_todoMgr.update( uid, ev ); 675 m_todoMgr.update( uid, ev );
666} 676}
667*/ 677*/
668void MainWindow::updateTodo( const OTodo& ev) { 678void MainWindow::updateTodo( const OTodo& ev) {
669 m_todoMgr.update( ev.uid() , ev ); 679 m_todoMgr.update( ev.uid() , ev );
670} 680}
671/* The view changed it's configuration 681/* The view changed it's configuration
672 * update the view menu 682 * update the view menu
673 */ 683 */
674void MainWindow::slotUpdate3( QWidget* ) { 684void MainWindow::slotUpdate3( QWidget* ) {
675 685
676} 686}
677void MainWindow::updateList() { 687void MainWindow::updateList() {
678 m_todoMgr.updateList(); 688 m_todoMgr.updateList();
679} 689}
680void MainWindow::setReadAhead( uint count ) { 690void MainWindow::setReadAhead( uint count ) {
681 if (m_todoMgr.todoDB() ) 691 if (m_todoMgr.todoDB() )
682 m_todoMgr.todoDB()->setReadAhead( count ); 692 m_todoMgr.todoDB()->setReadAhead( count );
683} 693}
694void MainWindow::slotQuickEntered() {
695 qWarning("entered");
696 OTodo todo = quickEditor()->todo();
697 if (todo.isEmpty() )
698 return;
699
700 m_todoMgr.add( todo );
701 currentView()->addEvent( todo );
702 raiseCurrentView();
703}
704QuickEditBase* MainWindow::quickEditor() {
705 return m_curQuick;
706}
diff --git a/core/pim/todo/mainwindow.h b/core/pim/todo/mainwindow.h
index 5a18e64..270cbd1 100644
--- a/core/pim/todo/mainwindow.h
+++ b/core/pim/todo/mainwindow.h
@@ -1,177 +1,191 @@
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 Holger Freyther <zecke@handhelds.org> 3             .=l. Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
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 TODO_MAIN_WINDOW_H 29#ifndef TODO_MAIN_WINDOW_H
30#define TODO_MAIN_WINDOW_H 30#define TODO_MAIN_WINDOW_H
31 31
32#include <qlist.h> 32#include <qlist.h>
33#include <qmainwindow.h> 33#include <qmainwindow.h>
34 34
35#include <opie/otodoaccess.h> 35#include <opie/otodoaccess.h>
36#include <opie/otodo.h> 36#include <opie/otodo.h>
37 37
38#include "smalltodo.h" 38#include "smalltodo.h"
39#include "todoview.h" 39#include "todoview.h"
40#include "quickedit.h"
40#include "todomanager.h" 41#include "todomanager.h"
41 42
42class QPopupMenu; 43class QPopupMenu;
43class QMenuBar; 44class QMenuBar;
44class QToolBar; 45class QToolBar;
45class QAction; 46class QAction;
46class QWidgetStack; 47class QWidgetStack;
47class Ir; 48class Ir;
48 49class QVBox;
49 50
50namespace Todo { 51namespace Todo {
51 typedef TodoView View; 52 typedef TodoView View;
52 class TemplateManager; 53 class TemplateManager;
53 class Editor; 54 class Editor;
54 class TodoShow; 55 class TodoShow;
55 class TemplateEditor; 56 class TemplateEditor;
57 struct QuickEditBase;
56 58
57 class MainWindow : public QMainWindow { 59 class MainWindow : public QMainWindow {
58 Q_OBJECT 60 Q_OBJECT
59 public: 61 public:
60 MainWindow( QWidget *parent = 0, 62 MainWindow( QWidget *parent = 0,
61 const char* name = 0 ); 63 const char* name = 0 );
62 ~MainWindow(); 64 ~MainWindow();
63 65
64 /** return a context menu for an OTodo */ 66 /** return a context menu for an OTodo */
65 QPopupMenu* contextMenu(int uid ); 67 QPopupMenu* contextMenu(int uid );
66 QPopupMenu* options(); 68 QPopupMenu* options();
67 QPopupMenu* edit(); 69 QPopupMenu* edit();
68 QPopupMenu* view(); 70 QPopupMenu* view();
69 QToolBar* toolbar(); 71 QToolBar* toolbar();
70 72
71 73
72 void updateList(); 74 void updateList();
73 OTodoAccess::List list()const; 75 OTodoAccess::List list()const;
74 OTodoAccess::List sorted( bool asc, int sortOrder ); 76 OTodoAccess::List sorted( bool asc, int sortOrder );
75 OTodoAccess::List sorted( bool asc, int sortOrder, int addFilter ); 77 OTodoAccess::List sorted( bool asc, int sortOrder, int addFilter );
76 78
77 OTodo event(int uid ); 79 OTodo event(int uid );
78 80
79 bool isSyncing()const; 81 bool isSyncing()const;
80 bool showCompleted()const; 82 bool showCompleted()const;
81 bool showDeadline()const; 83 bool showDeadline()const;
82 bool showOverDue()const; 84 bool showOverDue()const;
83 QString currentCategory()const; 85 QString currentCategory()const;
84 int currentCatId(); 86 int currentCatId();
85 TemplateManager* templateManager(); 87 TemplateManager* templateManager();
88 QuickEditBase* quickEditor();
86 89
87 void updateTodo( const OTodo& ); 90 void updateTodo( const OTodo& );
88 void populateTemplates(); 91 void populateTemplates();
89 Editor* currentEditor(); 92 Editor* currentEditor();
90 void setReadAhead(uint count ); 93 void setReadAhead(uint count );
91private slots: 94private slots:
95 void slotQuickEntered();
92 void populateCategories(); 96 void populateCategories();
93 void slotReload(); 97 void slotReload();
94 void slotFlush(); 98 void slotFlush();
95 99
96 protected: 100 protected:
97 void closeEvent( QCloseEvent* e ); 101 void closeEvent( QCloseEvent* e );
98 102
99 private: 103 private:
100 void receiveFile( const QString& filename ); 104 void receiveFile( const QString& filename );
101 void connectBase( ViewBase* ); 105 void connectBase( ViewBase* );
102 void initUI(); 106 void initUI();
103 void initActions(); 107 void initActions();
104 void initConfig(); 108 void initConfig();
105 void initViews(); 109 void initViews();
106 void initEditor(); 110 void initEditor();
107 void initShow(); 111 void initShow();
108 void initTemplate(); 112 void initTemplate();
109 void raiseCurrentView(); 113 void raiseCurrentView();
110 ViewBase* currentView(); 114 ViewBase* currentView();
111 ViewBase* m_curView; 115 ViewBase* m_curView;
116 QuickEditBase* m_curQuick;
112 Editor* m_curEdit; 117 Editor* m_curEdit;
113 TodoShow* currentShow(); 118 TodoShow* currentShow();
114 TodoShow* m_curShow; 119 TodoShow* m_curShow;
115 TemplateEditor* currentTemplateEditor(); 120 TemplateEditor* currentTemplateEditor();
116 TemplateEditor* m_curTempEd; 121 TemplateEditor* m_curTempEd;
117 122
118 QMenuBar* m_bar; 123 QMenuBar* m_bar;
119 QToolBar* m_tool; 124 QToolBar* m_tool;
120 QAction* m_editAction, 125 QAction* m_editAction,
121 *m_deleteAction, 126 *m_deleteAction,
122 *m_findAction, 127 *m_findAction,
123 *m_completedAction, 128 *m_completedAction,
124 *m_showDeadLineAction, 129 *m_showDeadLineAction,
125 *m_deleteAllAction, 130 *m_deleteAllAction,
126 *m_deleteCompleteAction, 131 *m_deleteCompleteAction,
127 *m_duplicateAction, 132 *m_duplicateAction,
128 *m_showOverDueAction, 133 *m_showOverDueAction,
129 *m_effectiveAction; 134 *m_effectiveAction;
130 QWidgetStack *m_stack; 135 QWidgetStack *m_stack;
131 QPopupMenu* m_catMenu, 136 QPopupMenu* m_catMenu,
132 *m_edit, 137 *m_edit,
133 *m_options, 138 *m_options,
134 *m_view, 139 *m_view,
135 *m_template; 140 *m_template;
141 /* box with two rows
142 * top will be the quick edit
143 * this will bite my ass once
144 * we want to have all parts
145 * exchangeable
146 */
147 QVBox* m_mainBox;
136 148
137 bool m_syncing:1; 149 bool m_syncing:1;
138 bool m_deadline:1; 150 bool m_deadline:1;
139 bool m_completed:1; 151 bool m_completed:1;
140 bool m_overdue:1; 152 bool m_overdue:1;
141 TodoManager m_todoMgr; 153 TodoManager m_todoMgr;
142 QString m_curCat; 154 QString m_curCat;
143 QList<ViewBase> m_views; 155 QList<ViewBase> m_views;
156 QList<QuickEditBase> m_quickEdit;
144 uint m_counter; 157 uint m_counter;
145 TemplateManager* m_tempManager; 158 TemplateManager* m_tempManager;
146 159
160
147 private slots: 161 private slots:
148 void slotShow(int); 162 void slotShow(int);
149 void slotEdit(int); 163 void slotEdit(int);
150private slots: 164private slots:
151 void slotUpdate3( QWidget* ); 165 void slotUpdate3( QWidget* );
152 void slotNewFromTemplate(int id ); 166 void slotNewFromTemplate(int id );
153 void slotNew(); 167 void slotNew();
154 void slotDuplicate(); 168 void slotDuplicate();
155 void slotDelete(); 169 void slotDelete();
156 void slotDeleteAll(); 170 void slotDeleteAll();
157 void slotDeleteCompleted(); 171 void slotDeleteCompleted();
158 172
159 void slotEdit(); 173 void slotEdit();
160 void slotFind(); 174 void slotFind();
161 175
162 void setCategory( int ); 176 void setCategory( int );
163 177
164 void slotShowDeadLine( bool ); 178 void slotShowDeadLine( bool );
165 void slotShowCompleted( bool ); 179 void slotShowCompleted( bool );
166 180
167 void setDocument( const QString& ); 181 void setDocument( const QString& );
168 182
169 183
170 void slotBeam(); 184 void slotBeam();
171 void beamDone( Ir* ); 185 void beamDone( Ir* );
172 void slotShowDetails(); 186 void slotShowDetails();
173 void slotShowDue( bool ); 187 void slotShowDue( bool );
174 }; 188 };
175}; 189};
176 190
177#endif 191#endif
diff --git a/core/pim/todo/quickedit.cpp b/core/pim/todo/quickedit.cpp
new file mode 100644
index 0000000..edcd48a
--- a/dev/null
+++ b/core/pim/todo/quickedit.cpp
@@ -0,0 +1,22 @@
1#include "mainwindow.h"
2#include "quickedit.h"
3
4using namespace Todo;
5
6// not so interesting part base Implementation
7QuickEdit::QuickEdit(MainWindow* main )
8 : m_main( main ) {
9 m_sig = new QSignal();
10}
11QuickEdit::~QuickEdit() {
12 delete m_sig;
13}
14QSignal* QuickEdit::signal() {
15 return m_sig;
16}
17MainWindow* QuickEdit::mainWindow() {
18 return m_main;
19}
20void QuickEdit::commit() {
21 m_sig->activate();
22}
diff --git a/core/pim/todo/quickedit.h b/core/pim/todo/quickedit.h
new file mode 100644
index 0000000..5fe74fe
--- a/dev/null
+++ b/core/pim/todo/quickedit.h
@@ -0,0 +1,45 @@
1#ifndef OPIE_QUICK_EDIT_H
2#define OPIE_QUICK_EDIT_H
3
4#include <qsignal.h>
5#include <qwidget.h>
6
7#include <opie/otodo.h>
8
9namespace Todo{
10 class MainWindow;
11 struct QuickEditBase {
12 virtual OTodo todo()const = 0l;
13 virtual QSignal* signal() = 0l;
14 virtual QWidget* widget() = 0l;
15 };
16 /*
17 * this is my second try
18 * of signal and slots with namespaces
19 * and templates
20 * I use a different approach now
21 * I give a QSignal away
22 * and have a protected method called emit
23 */
24 /**
25 * Quick edit is meant to quickly enter
26 * OTodos in a fast way
27 */
28 class QuickEdit : public QuickEditBase{
29 public:
30 QuickEdit(MainWindow* main );
31 virtual ~QuickEdit();
32 //OTodo todo()const;
33 QSignal* signal();
34 //QWidget* widget();
35 protected:
36 MainWindow* mainWindow();
37 void commit();
38 private:
39 MainWindow* m_main;
40 QSignal* m_sig;
41 };
42};
43
44
45#endif
diff --git a/core/pim/todo/quickeditimpl.cpp b/core/pim/todo/quickeditimpl.cpp
new file mode 100644
index 0000000..2dd5b61
--- a/dev/null
+++ b/core/pim/todo/quickeditimpl.cpp
@@ -0,0 +1,89 @@
1#include <qlineedit.h>
2
3#include <opie/oclickablelabel.h>
4
5#include "mainwindow.h"
6#include "quickeditimpl.h"
7
8
9QuickEditImpl::QuickEditImpl( Todo::MainWindow* win, QWidget* arent )
10 : QHBox(arent), Todo::QuickEdit(win) {
11 m_lbl = new OClickableLabel(this );
12 m_lbl->setMinimumWidth(12);
13 m_lbl->setText("3");
14
15 m_edit = new QLineEdit(this );
16
17 m_enter = new OClickableLabel(this);
18 m_enter->setText("Enter");
19
20 m_more = new OClickableLabel(this);
21 m_more->setText("More");
22
23
24 // connect
25 connect(m_lbl, SIGNAL(clicked() ),
26 this, SLOT(slotPrio()) );
27 connect(m_enter, SIGNAL(clicked() ),
28 this, SLOT(slotEnter() ) );
29 connect(m_more, SIGNAL(clicked() ),
30 this, SLOT(slotMore() ) );
31
32 m_menu = 0l;
33 reinit();
34 setMaximumHeight( m_edit->sizeHint().height() );
35}
36QuickEditImpl::~QuickEditImpl() {
37
38}
39OTodo QuickEditImpl::todo()const {
40 return m_todo;
41}
42QWidget* QuickEditImpl::widget() {
43 return this;
44}
45QSize QuickEditImpl::sizeHint()const{
46 return m_edit->sizeHint();
47}
48void QuickEditImpl::slotEnter() {
49 OTodo todo;
50
51
52 if (!m_edit->text().isEmpty() ) {
53 todo.setUid(1 ); // new uid
54 todo.setPriority( m_lbl->text().toInt() );
55 todo.setSummary( m_edit->text() );
56 if ( mainWindow()->currentCatId() != 0 )
57 todo.setCategories( mainWindow()->currentCatId() );
58
59 m_todo = todo;
60 commit();
61 }
62 m_todo = todo;
63 reinit();
64}
65void QuickEditImpl::slotPrio() {
66 m_state++;
67 if (m_state > 2 )
68 m_state = 0;
69
70 switch(m_state ) {
71 case 0:
72 m_lbl->setText( "1" );
73 break;
74 case 2:
75 m_lbl->setText( "5" );
76 break;
77 case 1:
78 default:
79 m_lbl->setText( "3");
80 break;
81 }
82}
83void QuickEditImpl::slotMore() {
84}
85void QuickEditImpl::reinit() {
86 m_state = 1;
87 m_lbl->setText("3");
88 m_edit->clear();
89}
diff --git a/core/pim/todo/quickeditimpl.h b/core/pim/todo/quickeditimpl.h
new file mode 100644
index 0000000..d0f6c69
--- a/dev/null
+++ b/core/pim/todo/quickeditimpl.h
@@ -0,0 +1,34 @@
1#ifndef OPIE_QUICK_EDIT_IMPL_H
2#define OPIE_QUICK_EDIT_IMPL_H
3
4#include <qhbox.h>
5
6#include "quickedit.h"
7
8class QLineEdit;
9class QLabel;
10
11class QuickEditImpl : public QHBox, public Todo::QuickEdit {
12 Q_OBJECT
13public:
14 QuickEditImpl( Todo::MainWindow* win , QWidget* parent);
15 ~QuickEditImpl();
16 OTodo todo()const;
17 QWidget* widget();
18 QSize sizeHint()const;
19private slots:
20 void slotEnter();
21 void slotPrio();
22 void slotMore();
23private:
24 void reinit();
25 int m_state;
26 QLabel* m_lbl;
27 QLineEdit* m_edit;
28 QLabel* m_enter;
29 QLabel* m_more;
30 QPopupMenu* m_menu;
31 OTodo m_todo;
32};
33
34#endif
diff --git a/core/pim/todo/tableview.cpp b/core/pim/todo/tableview.cpp
index f4b898f..34b8b3c 100644
--- a/core/pim/todo/tableview.cpp
+++ b/core/pim/todo/tableview.cpp
@@ -1,299 +1,302 @@
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#include <qtimer.h> 29#include <qtimer.h>
30#include <qpoint.h> 30#include <qpoint.h>
31#include <qpopupmenu.h> 31#include <qpopupmenu.h>
32 32
33#include "mainwindow.h" 33#include "mainwindow.h"
34//#include "tableitems.h" 34//#include "tableitems.h"
35#include "tableview.h" 35#include "tableview.h"
36 36
37using namespace Todo; 37using namespace Todo;
38 38
39namespace { 39namespace {
40 static const int BoxSize = 14; 40 static const int BoxSize = 14;
41 static const int RowHeight = 20; 41 static const int RowHeight = 20;
42} 42}
43 43
44 44
45TableView::TableView( MainWindow* window, QWidget* wid ) 45TableView::TableView( MainWindow* window, QWidget* wid )
46 : QTable( wid ), TodoView( window ) { 46 : QTable( wid ), TodoView( window ) {
47 setUpdatesEnabled( false ); 47 setUpdatesEnabled( false );
48 viewport()->setUpdatesEnabled( false ); 48 viewport()->setUpdatesEnabled( false );
49 m_enablePaint = false; 49 m_enablePaint = false;
50 setNumRows(0); 50 setNumRows(0);
51 setNumCols(4); 51 setNumCols(4);
52 52
53 setSorting( TRUE ); 53 setSorting( TRUE );
54 setSelectionMode( NoSelection ); 54 setSelectionMode( NoSelection );
55 setColumnStretchable( 2, TRUE ); 55 setColumnStretchable( 2, TRUE );
56 setColumnWidth(0, 20 ); 56 setColumnWidth(0, 20 );
57 setColumnWidth(1, 35 ); 57 setColumnWidth(1, 35 );
58 58
59 setLeftMargin( 0 ); 59 setLeftMargin( 0 );
60 verticalHeader()->hide(); 60 verticalHeader()->hide();
61 61
62 horizontalHeader()->setLabel(0, tr("C.") ); 62 horizontalHeader()->setLabel(0, tr("C.") );
63 horizontalHeader()->setLabel(1, tr("Prior.") ); 63 horizontalHeader()->setLabel(1, tr("Prior.") );
64 horizontalHeader()->setLabel(2, tr("Description" ) ); 64 horizontalHeader()->setLabel(2, tr("Description" ) );
65 65
66 setColumnStretchable(3, FALSE ); 66 setColumnStretchable(3, FALSE );
67 setColumnWidth(3, 20 ); 67 setColumnWidth(3, 20 );
68 horizontalHeader()->setLabel(3, tr("Deadline") ); 68 horizontalHeader()->setLabel(3, tr("Deadline") );
69 69
70 if ( todoWindow()->showDeadline() ) 70 if ( todoWindow()->showDeadline() )
71 showColumn( 3); 71 showColumn( 3);
72 else 72 else
73 hideColumn(3 ); 73 hideColumn(3 );
74 74
75 connect((QTable*)this, SIGNAL( clicked( int, int, int, const QPoint& ) ), 75 connect((QTable*)this, SIGNAL( clicked( int, int, int, const QPoint& ) ),
76 this, SLOT( slotClicked(int, int, int, const QPoint& ) ) ); 76 this, SLOT( slotClicked(int, int, int, const QPoint& ) ) );
77 connect((QTable*)this, SIGNAL( pressed( int, int, int, const QPoint& ) ), 77 connect((QTable*)this, SIGNAL( pressed( int, int, int, const QPoint& ) ),
78 this, SLOT( slotPressed(int, int, int, const QPoint& ) ) ); 78 this, SLOT( slotPressed(int, int, int, const QPoint& ) ) );
79 connect((QTable*)this, SIGNAL(valueChanged(int, int) ), 79 connect((QTable*)this, SIGNAL(valueChanged(int, int) ),
80 this, SLOT( slotValueChanged(int, int) ) ); 80 this, SLOT( slotValueChanged(int, int) ) );
81 connect((QTable*)this, SIGNAL(currentChanged(int, int) ), 81 connect((QTable*)this, SIGNAL(currentChanged(int, int) ),
82 this, SLOT( slotCurrentChanged(int, int) ) ); 82 this, SLOT( slotCurrentChanged(int, int) ) );
83 83
84 m_menuTimer = new QTimer( this ); 84 m_menuTimer = new QTimer( this );
85 connect( m_menuTimer, SIGNAL(timeout()), 85 connect( m_menuTimer, SIGNAL(timeout()),
86 this, SLOT(slotShowMenu()) ); 86 this, SLOT(slotShowMenu()) );
87 87
88 m_enablePaint = true; 88 m_enablePaint = true;
89 setUpdatesEnabled( true ); 89 setUpdatesEnabled( true );
90 viewport()->setUpdatesEnabled( true ); 90 viewport()->setUpdatesEnabled( true );
91 viewport()->update(); 91 viewport()->update();
92 setSortOrder( 0 ); 92 setSortOrder( 0 );
93 setAscending( TRUE ); 93 setAscending( TRUE );
94 m_first = true; 94 m_first = true;
95} 95}
96/* a new day has started 96/* a new day has started
97 * update the day 97 * update the day
98 */ 98 */
99void TableView::newDay() { 99void TableView::newDay() {
100 clear(); 100 clear();
101 updateView(); 101 updateView();
102} 102}
103TableView::~TableView() { 103TableView::~TableView() {
104 104
105} 105}
106void TableView::slotShowMenu() { 106void TableView::slotShowMenu() {
107 QPopupMenu *menu = todoWindow()->contextMenu( current() ); 107 QPopupMenu *menu = todoWindow()->contextMenu( current() );
108 menu->exec(QCursor::pos() ); 108 menu->exec(QCursor::pos() );
109 delete menu; 109 delete menu;
110} 110}
111QString TableView::type() const { 111QString TableView::type() const {
112 return QString::fromLatin1( tr("Table View") ); 112 return QString::fromLatin1( tr("Table View") );
113} 113}
114int TableView::current() { 114int TableView::current() {
115 int uid = sorted().uidAt(currentRow() ); 115 int uid = sorted().uidAt(currentRow() );
116 qWarning("uid %d", uid ); 116 qWarning("uid %d", uid );
117 return uid; 117 return uid;
118} 118}
119QString TableView::currentRepresentation() { 119QString TableView::currentRepresentation() {
120 return text( currentRow(), 2); 120 return text( currentRow(), 2);
121} 121}
122/* show overdue */ 122/* show overdue */
123void TableView::showOverDue( bool ) { 123void TableView::showOverDue( bool ) {
124 clear(); 124 clear();
125 updateView(); 125 updateView();
126} 126}
127 127
128void TableView::updateView( ) { 128void TableView::updateView( ) {
129 qWarning("update view");
129 m_row = false; 130 m_row = false;
130 startTimer( 2000 ); 131 static int id;
132 id = startTimer(2000 );
131 /* FIXME we want one page to be read! 133 /* FIXME we want one page to be read!
132 * 134 *
133 * Calculate that screensize 135 * Calculate that screensize
134 */ 136 */
135 todoWindow()->setReadAhead( 4 ); 137 todoWindow()->setReadAhead( 4 );
136 sort(); 138 sort();
137 OTodoAccess::List::Iterator it, end; 139 OTodoAccess::List::Iterator it, end;
138 it = sorted().begin(); 140 it = sorted().begin();
139 end = sorted().end(); 141 end = sorted().end();
140 142
141 qWarning("setTodos"); 143 qWarning("setTodos");
142 QTime time; 144 QTime time;
143 time.start(); 145 time.start();
144 m_enablePaint = false; 146 m_enablePaint = false;
145 setUpdatesEnabled( false ); 147 setUpdatesEnabled( false );
146 viewport()->setUpdatesEnabled( false ); 148 viewport()->setUpdatesEnabled( false );
147 149
148 QTime t; 150 QTime t;
149 t.start(); 151 t.start();
150 setNumRows( it.count() ); 152 setNumRows( it.count() );
153 if ( it.count() == 0 )
154 killTimer(id);
151 int elc = time.elapsed(); 155 int elc = time.elapsed();
152 qWarning("Adding took %d", elc/1000 ); 156 qWarning("Adding took %d", elc/1000 );
153 setUpdatesEnabled( true ); 157 setUpdatesEnabled( true );
154 viewport()->setUpdatesEnabled( true ); 158 viewport()->setUpdatesEnabled( true );
155 viewport()->update(); 159 viewport()->update();
156 160
157 m_enablePaint = true; 161 m_enablePaint = true;
158 int el = time.elapsed(); 162 int el = time.elapsed();
159 qWarning("adding took %d", el/1000 ); 163 qWarning("adding took %d", el/1000 );
160} 164}
161void TableView::setTodo( int, const OTodo&) { 165void TableView::setTodo( int, const OTodo&) {
162 sort(); 166 sort();
163 167
164 /* repaint */ 168 /* repaint */
165 QTable::update(); 169 repaint();
166} 170}
167void TableView::addEvent( const OTodo&) { 171void TableView::addEvent( const OTodo&) {
168 sort();
169 172
170 /* fix problems of not showing the 'Haken' */ 173 /* fix problems of not showing the 'Haken' */
171 QTable::repaint(); 174 updateView();
172} 175}
173/* 176/*
174 * find the event 177 * find the event
175 * and then replace the complete row 178 * and then replace the complete row
176 */ 179 */
177void TableView::replaceEvent( const OTodo& ev) { 180void TableView::replaceEvent( const OTodo& ev) {
178 addEvent( ev ); 181 addEvent( ev );
179} 182}
180/* 183/*
181 * re aligning table can be slow too 184 * re aligning table can be slow too
182 * FIXME: look what performs better 185 * FIXME: look what performs better
183 * either this or the old align table 186 * either this or the old align table
184 */ 187 */
185void TableView::removeEvent( int ) { 188void TableView::removeEvent( int ) {
186 updateView(); 189 updateView();
187} 190}
188void TableView::setShowCompleted( bool b) { 191void TableView::setShowCompleted( bool b) {
189 qWarning("Show Completed %d" + b ); 192 qWarning("Show Completed %d" + b );
190 updateView(); 193 updateView();
191} 194}
192void TableView::setShowDeadline( bool b) { 195void TableView::setShowDeadline( bool b) {
193 qWarning("Show DeadLine %d" + b ); 196 qWarning("Show DeadLine %d" + b );
194 if (b) 197 if (b)
195 showColumn(3 ); 198 showColumn(3 );
196 else 199 else
197 hideColumn(3 ); 200 hideColumn(3 );
198} 201}
199void TableView::setShowCategory( const QString& str) { 202void TableView::setShowCategory( const QString& str) {
200 qWarning("setShowCategory"); 203 qWarning("setShowCategory");
201 if ( str != m_oleCat || m_first ) 204 if ( str != m_oleCat || m_first )
202 updateView(); 205 updateView();
203 206
204 m_oleCat = str; 207 m_oleCat = str;
205 m_first = false; 208 m_first = false;
206 209
207} 210}
208void TableView::clear() { 211void TableView::clear() {
209 setNumRows(0); 212 setNumRows(0);
210} 213}
211void TableView::slotClicked(int row, int col, int, 214void TableView::slotClicked(int row, int col, int,
212 const QPoint& point) { 215 const QPoint& point) {
213 if ( !cellGeometry(row, col ).contains(point ) ) 216 if ( !cellGeometry(row, col ).contains(point ) )
214 return; 217 return;
215 218
216 int ui= sorted().uidAt( row ); 219 int ui= sorted().uidAt( row );
217 220
218 221
219 switch( col ) { 222 switch( col ) {
220 case 0:{ 223 case 0:{
221 int x = point.x() -columnPos( col ); 224 int x = point.x() -columnPos( col );
222 int y = point.y() -rowPos( row ); 225 int y = point.y() -rowPos( row );
223 int w = columnWidth( col ); 226 int w = columnWidth( col );
224 int h = rowHeight( row ); 227 int h = rowHeight( row );
225 if ( x >= ( w - BoxSize ) / 2 && 228 if ( x >= ( w - BoxSize ) / 2 &&
226 x <= ( w - BoxSize ) / 2 + BoxSize && 229 x <= ( w - BoxSize ) / 2 + BoxSize &&
227 y >= ( h - BoxSize ) / 2 && 230 y >= ( h - BoxSize ) / 2 &&
228 y <= ( h - BoxSize ) / 2 + BoxSize ) { 231 y <= ( h - BoxSize ) / 2 + BoxSize ) {
229 OTodo todo = sorted()[row]; 232 OTodo todo = sorted()[row];
230 todo.setCompleted( !todo.isCompleted() ); 233 todo.setCompleted( !todo.isCompleted() );
231 TodoView::update( todo.uid(), todo ); 234 TodoView::update( todo.uid(), todo );
232 updateView(); 235 updateView();
233 } 236 }
234 } 237 }
235 break; 238 break;
236 239
237 case 1: 240 case 1:
238 break; 241 break;
239 242
240 case 2: { 243 case 2: {
241 m_menuTimer->stop(); 244 m_menuTimer->stop();
242 showTodo( ui ); 245 showTodo( ui );
243 break; 246 break;
244 } 247 }
245 case 3: { 248 case 3: {
246 m_menuTimer->stop(); 249 m_menuTimer->stop();
247 TodoView::edit( ui ); 250 TodoView::edit( ui );
248 break; 251 break;
249 } 252 }
250 } 253 }
251 254
252 255
253} 256}
254void TableView::slotPressed(int row, int col, int, 257void TableView::slotPressed(int row, int col, int,
255 const QPoint& point) { 258 const QPoint& point) {
256 259
257 /* TextColumn column */ 260 /* TextColumn column */
258 if ( col == 2 && cellGeometry( row, col ).contains( point ) ) 261 if ( col == 2 && cellGeometry( row, col ).contains( point ) )
259 m_menuTimer->start( 750, TRUE ); 262 m_menuTimer->start( 750, TRUE );
260} 263}
261void TableView::slotValueChanged( int, int ) { 264void TableView::slotValueChanged( int, int ) {
262 qWarning("Value Changed"); 265 qWarning("Value Changed");
263} 266}
264void TableView::slotCurrentChanged(int, int ) { 267void TableView::slotCurrentChanged(int, int ) {
265 m_menuTimer->stop(); 268 m_menuTimer->stop();
266} 269}
267QWidget* TableView::widget() { 270QWidget* TableView::widget() {
268 return this; 271 return this;
269} 272}
270/* 273/*
271 * We need to overwrite sortColumn 274 * We need to overwrite sortColumn
272 * because we want to sort whole row 275 * because we want to sort whole row
273 * based 276 * based
274 * We event want to set the setOrder 277 * We event want to set the setOrder
275 * to a sort() and update() 278 * to a sort() and update()
276 */ 279 */
277void TableView::sortColumn( int col, bool asc, bool ) { 280void TableView::sortColumn( int col, bool asc, bool ) {
278 qWarning("bool %d", asc ); 281 qWarning("bool %d", asc );
279 setSortOrder( col ); 282 setSortOrder( col );
280 setAscending( asc ); 283 setAscending( asc );
281 updateView(); 284 updateView();
282} 285}
283void TableView::viewportPaintEvent( QPaintEvent* e) { 286void TableView::viewportPaintEvent( QPaintEvent* e) {
284 qWarning("Paint event" ); 287 qWarning("Paint event" );
285 if (m_enablePaint ) 288 if (m_enablePaint )
286 QTable::viewportPaintEvent( e ); 289 QTable::viewportPaintEvent( e );
287} 290}
288/* 291/*
289 * This segment is copyrighted by TT 292 * This segment is copyrighted by TT
290 * it was taken from their todolist 293 * it was taken from their todolist
291 * application this code is GPL 294 * application this code is GPL
292 */ 295 */
293void TableView::paintCell(QPainter* p, int row, int col, const QRect& cr, bool ) { 296void TableView::paintCell(QPainter* p, int row, int col, const QRect& cr, bool ) {
294 const QColorGroup &cg = colorGroup(); 297 const QColorGroup &cg = colorGroup();
295 298
296 p->save(); 299 p->save();
297 300
298 OTodo task = sorted()[row]; 301 OTodo task = sorted()[row];
299 302
@@ -303,148 +306,151 @@ void TableView::paintCell(QPainter* p, int row, int col, const QRect& cr, bool
303 p->setPen(cg.mid()); 306 p->setPen(cg.mid());
304 p->drawLine( 0, cr.height() - 1, cr.width() - 1, cr.height() - 1 ); 307 p->drawLine( 0, cr.height() - 1, cr.width() - 1, cr.height() - 1 );
305 p->drawLine( cr.width() - 1, 0, cr.width() - 1, cr.height() - 1 ); 308 p->drawLine( cr.width() - 1, 0, cr.width() - 1, cr.height() - 1 );
306 p->setPen(op); 309 p->setPen(op);
307 310
308 QFont f = p->font(); 311 QFont f = p->font();
309 QFontMetrics fm(f); 312 QFontMetrics fm(f);
310 313
311 switch(col) { 314 switch(col) {
312 case 0: 315 case 0:
313 { 316 {
314 // completed field 317 // completed field
315 int marg = ( cr.width() - BoxSize ) / 2; 318 int marg = ( cr.width() - BoxSize ) / 2;
316 int x = 0; 319 int x = 0;
317 int y = ( cr.height() - BoxSize ) / 2; 320 int y = ( cr.height() - BoxSize ) / 2;
318 p->setPen( QPen( cg.text() ) ); 321 p->setPen( QPen( cg.text() ) );
319 p->drawRect( x + marg, y, BoxSize, BoxSize ); 322 p->drawRect( x + marg, y, BoxSize, BoxSize );
320 p->drawRect( x + marg+1, y+1, BoxSize-2, BoxSize-2 ); 323 p->drawRect( x + marg+1, y+1, BoxSize-2, BoxSize-2 );
321 p->setPen( darkGreen ); 324 p->setPen( darkGreen );
322 x += 1; 325 x += 1;
323 y += 1; 326 y += 1;
324 if ( task.isCompleted() ) { 327 if ( task.isCompleted() ) {
325 QPointArray a( 9*2 ); 328 QPointArray a( 9*2 );
326 int i, xx, yy; 329 int i, xx, yy;
327 xx = x+2+marg; 330 xx = x+2+marg;
328 yy = y+4; 331 yy = y+4;
329 for ( i=0; i<4; i++ ) { 332 for ( i=0; i<4; i++ ) {
330 a.setPoint( 2*i, xx, yy ); 333 a.setPoint( 2*i, xx, yy );
331 a.setPoint( 2*i+1, xx, yy+2 ); 334 a.setPoint( 2*i+1, xx, yy+2 );
332 xx++; yy++; 335 xx++; yy++;
333 } 336 }
334 yy -= 2; 337 yy -= 2;
335 for ( i=4; i<9; i++ ) { 338 for ( i=4; i<9; i++ ) {
336 a.setPoint( 2*i, xx, yy ); 339 a.setPoint( 2*i, xx, yy );
337 a.setPoint( 2*i+1, xx, yy+2 ); 340 a.setPoint( 2*i+1, xx, yy+2 );
338 xx++; yy--; 341 xx++; yy--;
339 } 342 }
340 p->drawLineSegments( a ); 343 p->drawLineSegments( a );
341 } 344 }
342 } 345 }
343 break; 346 break;
344 case 1: 347 case 1:
345 // priority field 348 // priority field
346 { 349 {
347 QString text = QString::number(task.priority()); 350 QString text = QString::number(task.priority());
348 p->drawText(2,2 + fm.ascent(), text); 351 p->drawText(2,2 + fm.ascent(), text);
349 } 352 }
350 break; 353 break;
351 case 2: 354 case 2:
352 // description field 355 // description field
353 { 356 {
354 QString text = task.summary().isEmpty() ? 357 QString text = task.summary().isEmpty() ?
355 task.description() : 358 task.description() :
356 task.summary(); 359 task.summary();
357 p->drawText(2,2 + fm.ascent(), text); 360 p->drawText(2,2 + fm.ascent(), text);
358 } 361 }
359 break; 362 break;
360 case 3: 363 case 3:
361 { 364 {
362 QString text; 365 QString text;
363 if (task.hasDueDate()) { 366 if (task.hasDueDate()) {
364 int off = QDate::currentDate().daysTo( task.dueDate() ); 367 int off = QDate::currentDate().daysTo( task.dueDate() );
365 text = QString::number(off) + tr(" day(s)"); 368 text = QString::number(off) + tr(" day(s)");
366 /* 369 /*
367 * set color if not completed 370 * set color if not completed
368 */ 371 */
369 if (!task.isCompleted() ) { 372 if (!task.isCompleted() ) {
370 QColor color = Qt::black; 373 QColor color = Qt::black;
371 if ( off < 0 ) 374 if ( off < 0 )
372 color = Qt::red; 375 color = Qt::red;
373 else if ( off == 0 ) 376 else if ( off == 0 )
374 color = Qt::yellow; 377 color = Qt::yellow;
375 else if ( off > 0 ) 378 else if ( off > 0 )
376 color = Qt::green; 379 color = Qt::green;
377 p->setPen(color ); 380 p->setPen(color );
378 } 381 }
379 } else { 382 } else {
380 text = tr("None"); 383 text = tr("None");
381 } 384 }
382 p->drawText(2,2 + fm.ascent(), text); 385 p->drawText(2,2 + fm.ascent(), text);
383 } 386 }
384 break; 387 break;
385 } 388 }
386 p->restore(); 389 p->restore();
387} 390}
388QWidget* TableView::createEditor(int row, int col, bool )const { 391QWidget* TableView::createEditor(int row, int col, bool )const {
389 switch( col ) { 392 switch( col ) {
390 case 1: { 393 case 1: {
391 /* the priority stuff */ 394 /* the priority stuff */
392 QComboBox* combo = new QComboBox( viewport() ); 395 QComboBox* combo = new QComboBox( viewport() );
393 combo->insertItem( "1" ); 396 combo->insertItem( "1" );
394 combo->insertItem( "2" ); 397 combo->insertItem( "2" );
395 combo->insertItem( "3" ); 398 combo->insertItem( "3" );
396 combo->insertItem( "4" ); 399 combo->insertItem( "4" );
397 combo->insertItem( "5" ); 400 combo->insertItem( "5" );
398 combo->setCurrentItem( sorted()[row].priority()-1 ); 401 combo->setCurrentItem( sorted()[row].priority()-1 );
399 return combo; 402 return combo;
400 } 403 }
401 case 0: 404 case 0:
402 default: 405 default:
403 return 0l; 406 return 0l;
404 } 407 }
405} 408}
406void TableView::setCellContentFromEditor(int row, int col ) { 409void TableView::setCellContentFromEditor(int row, int col ) {
407 if ( col == 1 ) { 410 if ( col == 1 ) {
408 QWidget* wid = cellWidget(row, 1 ); 411 QWidget* wid = cellWidget(row, 1 );
409 if ( wid->inherits("QComboBox") ) { 412 if ( wid->inherits("QComboBox") ) {
410 int pri = ((QComboBox*)wid)->currentItem() + 1; 413 int pri = ((QComboBox*)wid)->currentItem() + 1;
411 OTodo todo = sorted()[row]; 414 OTodo todo = sorted()[row];
412 if ( todo.priority() != pri ) { 415 if ( todo.priority() != pri ) {
413 todo.setPriority( pri ); 416 todo.setPriority( pri );
414 TodoView::update( todo.uid(), todo ); 417 TodoView::update( todo.uid(), todo );
415 updateView(); 418 updateView();
416 } 419 }
417 } 420 }
418 } 421 }
419} 422}
420void TableView::slotPriority() { 423void TableView::slotPriority() {
421 setCellContentFromEditor( currentRow(), currentColumn() ); 424 setCellContentFromEditor( currentRow(), currentColumn() );
422} 425}
423/* 426/*
424 * We'll use the TimerEvent to read ahead or to keep the cahce always 427 * We'll use the TimerEvent to read ahead or to keep the cahce always
425 * filled enough. 428 * filled enough.
426 * We will try to read ahead 4 items in both ways 429 * We will try to read ahead 4 items in both ways
427 * up and down. On odd or even we will currentRow()+-4 or +-9 430 * up and down. On odd or even we will currentRow()+-4 or +-9
428 * 431 *
429 */ 432 */
430void TableView::timerEvent( QTimerEvent* ev ) { 433void TableView::timerEvent( QTimerEvent* ev ) {
434 if (sorted().count() == 0 )
435 return;
436
431 int row = currentRow(); 437 int row = currentRow();
432 qWarning("TimerEvent %d", row); 438 qWarning("TimerEvent %d", row);
433 if ( m_row ) { 439 if ( m_row ) {
434 int ro = row-4; 440 int ro = row-4;
435 if (ro < 0 ) ro = 0; 441 if (ro < 0 ) ro = 0;
436 sorted()[ro]; 442 sorted()[ro];
437 443
438 ro = row+4; 444 ro = row+4;
439 sorted()[ro]; 445 sorted()[ro];
440 } else { 446 } else {
441 int ro = row + 8; 447 int ro = row + 8;
442 sorted()[ro]; 448 sorted()[ro];
443 449
444 ro = row-8; 450 ro = row-8;
445 if (ro < 0 ) ro = 0; 451 if (ro < 0 ) ro = 0;
446 sorted()[ro]; 452 sorted()[ro];
447 } 453 }
448 454
449 m_row = !m_row; 455 m_row = !m_row;
450} 456}
diff --git a/core/pim/todo/todo.pro b/core/pim/todo/todo.pro
index f26acee..d432e78 100644
--- a/core/pim/todo/todo.pro
+++ b/core/pim/todo/todo.pro
@@ -1,55 +1,59 @@
1 TEMPLATE= app 1 TEMPLATE= app
2 CONFIG = qt warn_on release 2 CONFIG = qt warn_on release
3 DESTDIR = $(OPIEDIR)/bin 3 DESTDIR = $(OPIEDIR)/bin
4 4
5 HEADERS= smalltodo.h \ 5 HEADERS= smalltodo.h \
6 todomanager.h \ 6 todomanager.h \
7 mainwindow.h \ 7 mainwindow.h \
8 todoview.h \ 8 todoview.h \
9 todoentryimpl.h \ 9 todoentryimpl.h \
10 tableview.h \ 10 tableview.h \
11 tableitems.h \ 11 tableitems.h \
12 todotemplatemanager.h \ 12 todotemplatemanager.h \
13 todoeditor.h \ 13 todoeditor.h \
14 todoshow.h \ 14 todoshow.h \
15 textviewshow.h \ 15 textviewshow.h \
16 templateeditor.h \ 16 templateeditor.h \
17 templatedialog.h \ 17 templatedialog.h \
18 templatedialogimpl.h 18 templatedialogimpl.h \
19 quickedit.h \
20 quickeditimpl.h
19 21
20 SOURCES= smalltodo.cpp \ 22 SOURCES= smalltodo.cpp \
21 todomanager.cpp \ 23 todomanager.cpp \
22 mainwindow.cpp \ 24 mainwindow.cpp \
23 main.cpp \ 25 main.cpp \
24 todoentryimpl.cpp \ 26 todoentryimpl.cpp \
25 tableview.cpp \ 27 tableview.cpp \
26 tableitems.cpp \ 28 tableitems.cpp \
27 todoview.cpp \ 29 todoview.cpp \
28 todotemplatemanager.cpp \ 30 todotemplatemanager.cpp \
29 todoeditor.cpp \ 31 todoeditor.cpp \
30 todoshow.cpp \ 32 todoshow.cpp \
31 textviewshow.cpp \ 33 textviewshow.cpp \
32 templateeditor.cpp \ 34 templateeditor.cpp \
33 templatedialog.cpp \ 35 templatedialog.cpp \
34 templatedialogimpl.cpp 36 templatedialogimpl.cpp \
37 quickeditimpl.cpp \
38 quickedit.cpp
35 39
36 INTERFACES= todoentry.ui 40 INTERFACES= todoentry.ui
37 TARGET = todolist 41 TARGET = todolist
38INCLUDEPATH += $(OPIEDIR)/include 42INCLUDEPATH += $(OPIEDIR)/include
39 DEPENDPATH+= $(OPIEDIR)/include 43 DEPENDPATH+= $(OPIEDIR)/include
40LIBS += -lqpe -lopie 44LIBS += -lqpe -lopie
41 45
42TRANSLATIONS = ../../../i18n/de/todolist.ts \ 46TRANSLATIONS = ../../../i18n/de/todolist.ts \
43 ../../../i18n/en/todolist.ts \ 47 ../../../i18n/en/todolist.ts \
44 ../../../i18n/es/todolist.ts \ 48 ../../../i18n/es/todolist.ts \
45 ../../../i18n/fr/todolist.ts \ 49 ../../../i18n/fr/todolist.ts \
46 ../../../i18n/hu/todolist.ts \ 50 ../../../i18n/hu/todolist.ts \
47 ../../../i18n/ja/todolist.ts \ 51 ../../../i18n/ja/todolist.ts \
48 ../../../i18n/ko/todolist.ts \ 52 ../../../i18n/ko/todolist.ts \
49 ../../../i18n/no/todolist.ts \ 53 ../../../i18n/no/todolist.ts \
50 ../../../i18n/pl/todolist.ts \ 54 ../../../i18n/pl/todolist.ts \
51 ../../../i18n/pt/todolist.ts \ 55 ../../../i18n/pt/todolist.ts \
52 ../../../i18n/pt_BR/todolist.ts \ 56 ../../../i18n/pt_BR/todolist.ts \
53 ../../../i18n/sl/todolist.ts \ 57 ../../../i18n/sl/todolist.ts \
54 ../../../i18n/zh_CN/todolist.ts \ 58 ../../../i18n/zh_CN/todolist.ts \
55 ../../../i18n/zh_TW/todolist.ts 59 ../../../i18n/zh_TW/todolist.ts