summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/todo/main.cpp3
-rw-r--r--core/pim/todo/mainwindow.cpp136
-rw-r--r--core/pim/todo/mainwindow.h4
-rw-r--r--core/pim/todo/opie-todo.control6
-rw-r--r--core/pim/todo/otaskeditor.cpp14
-rw-r--r--core/pim/todo/otaskeditor.h3
-rw-r--r--core/pim/todo/quickedit.cpp1
-rw-r--r--core/pim/todo/quickeditimpl.cpp7
-rw-r--r--core/pim/todo/smalltodo.cpp1
-rw-r--r--core/pim/todo/tableview.cpp86
-rw-r--r--core/pim/todo/tableview.h18
-rw-r--r--core/pim/todo/taskeditoralarms.cpp5
-rw-r--r--core/pim/todo/taskeditoroverview.cpp6
-rw-r--r--core/pim/todo/taskeditorstatus.cpp5
-rw-r--r--core/pim/todo/templatedialogimpl.cpp1
-rw-r--r--core/pim/todo/textviewshow.cpp18
-rw-r--r--core/pim/todo/todomanager.cpp1
-rw-r--r--core/pim/todo/todoshow.cpp8
-rw-r--r--core/pim/todo/todoshow.h2
-rw-r--r--core/pim/todo/todoview.cpp3
-rw-r--r--core/pim/todo/todoview.h12
21 files changed, 273 insertions, 67 deletions
diff --git a/core/pim/todo/main.cpp b/core/pim/todo/main.cpp
index 58ed45c..7763169 100644
--- a/core/pim/todo/main.cpp
+++ b/core/pim/todo/main.cpp
@@ -1,49 +1,48 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "mainwindow.h" 21#include "mainwindow.h"
22 22
23 23
24#include <qdatetime.h>
25 24
26#include <qpe/qpeapplication.h> 25#include <qpe/qpeapplication.h>
27 26
28void myMessages( QtMsgType, const char* ) { 27void myMessages( QtMsgType, const char* ) {
29 28
30} 29}
31 30
32int main( int argc, char **argv ) 31int main( int argc, char **argv )
33{ 32{
34 qInstallMsgHandler( myMessages ); 33 qInstallMsgHandler( myMessages );
35 QPEApplication a( argc, argv ); 34 QPEApplication a( argc, argv );
36 35
37 QTime time; 36 QTime time;
38 time.start(); 37 time.start();
39 Todo::MainWindow mw; 38 Todo::MainWindow mw;
40 int t = time.elapsed(); 39 int t = time.elapsed();
41 qWarning("QTime %d", t/1000 ); 40 qWarning("QTime %d", t/1000 );
42 mw.setCaption("Opie Todolist"); 41 mw.setCaption( QObject::tr("Opie Todolist"));
43 QObject::connect( &a, SIGNAL( flush() ), &mw, SLOT( slotFlush() ) ); 42 QObject::connect( &a, SIGNAL( flush() ), &mw, SLOT( slotFlush() ) );
44 QObject::connect( &a, SIGNAL( reload() ), &mw, SLOT( slotReload() ) ); 43 QObject::connect( &a, SIGNAL( reload() ), &mw, SLOT( slotReload() ) );
45 44
46 a.showMainWidget(&mw); 45 a.showMainWidget(&mw);
47 46
48 return a.exec(); 47 return a.exec();
49} 48}
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp
index 5119ae0..6725951 100644
--- a/core/pim/todo/mainwindow.cpp
+++ b/core/pim/todo/mainwindow.cpp
@@ -1,952 +1,1036 @@
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 <qpushbutton.h> 35#include <qpushbutton.h>
36#include <qwidgetstack.h> 36#include <qwidgetstack.h>
37#include <qaction.h> 37#include <qaction.h>
38#include <qtimer.h> 38#include <qtimer.h>
39#include <qvbox.h> 39#include <qvbox.h>
40#include <qlayout.h> 40#include <qlayout.h>
41#include <qlineedit.h> 41#include <qlineedit.h>
42#include <qwhatsthis.h> 42#include <qwhatsthis.h>
43 43
44#include <qpe/applnk.h> 44#include <qpe/applnk.h>
45#include <qpe/config.h> 45#include <qpe/config.h>
46#include <qpe/ir.h> 46#include <qpe/ir.h>
47#include <qpe/resource.h> 47#include <qpe/resource.h>
48#include <qpe/qpemessagebox.h> 48#include <qpe/qpemessagebox.h>
49#include <qpe/alarmserver.h> 49#include <qpe/alarmserver.h>
50#include <qpe/timestring.h> 50#include <qpe/timestring.h>
51#include <qpe/qpeapplication.h> 51#include <qpe/qpeapplication.h>
52 52
53#include <opie/orecur.h> 53#include <opie/orecur.h>
54#include <opie/opimnotifymanager.h> 54#include <opie/opimnotifymanager.h>
55#include <opie/otodoaccessvcal.h> 55#include <opie/otodoaccessvcal.h>
56 56
57#include "quickeditimpl.h" 57#include "quickeditimpl.h"
58#include "todotemplatemanager.h" 58#include "todotemplatemanager.h"
59#include "templateeditor.h" 59#include "templateeditor.h"
60#include "tableview.h" 60#include "tableview.h"
61 61
62#include "textviewshow.h" 62#include "textviewshow.h"
63#include "todoeditor.h" 63#include "todoeditor.h"
64#include "mainwindow.h" 64#include "mainwindow.h"
65 65
66 66
67using namespace Todo; 67using namespace Todo;
68 68
69MainWindow::MainWindow( QWidget* parent, 69MainWindow::MainWindow( QWidget* parent,
70 const char* name ) 70 const char* name )
71 : OPimMainWindow( "Todolist", parent, name, WType_TopLevel | WStyle_ContextHelp ) 71 : OPimMainWindow( "Todolist", parent, name, WType_TopLevel | WStyle_ContextHelp )
72{ 72{
73 m_syncing = false; 73 m_syncing = false;
74 m_showing = false;
74 m_counter = 0; 75 m_counter = 0;
75 m_tempManager = new TemplateManager(); 76 m_tempManager = new TemplateManager();
76 m_tempManager->load(); 77 m_tempManager->load();
77 78
78 initUI(); 79 initUI();
79 initConfig(); 80 initConfig();
80 initViews(); 81 initViews();
81 initActions(); 82 initActions();
82 initEditor(); 83 initEditor();
83 initShow(); 84 initShow();
84 initTemplate(); 85 initTemplate();
85 86
86 populateTemplates(); 87 populateTemplates();
87 raiseCurrentView(); 88 raiseCurrentView();
88 QTimer::singleShot(0, this, SLOT(populateCategories() ) ); 89 QTimer::singleShot(0, this, SLOT(populateCategories() ) );
89} 90}
90void MainWindow::initTemplate() { 91void MainWindow::initTemplate() {
91 m_curTempEd = new TemplateEditor( this, templateManager() ); 92 m_curTempEd = new TemplateEditor( this, templateManager() );
92} 93}
93void MainWindow::initActions() { 94void MainWindow::initActions() {
94 95
95 // Data menu 96 // Data menu
96 m_edit->insertItem(QWidget::tr("New from template"), m_template, 97 m_edit->insertItem(QWidget::tr("New from template"), m_template,
97 -1, 0 ); 98 -1, 0 );
98 99
99 QAction* a = new QAction( QWidget::tr("New Task" ), Resource::loadPixmap( "new" ), 100 QAction* a = new QAction( QWidget::tr("New Task" ), Resource::loadPixmap( "new" ),
100 QString::null, 0, this, 0 ); 101 QString::null, 0, this, 0 );
101 connect(a, SIGNAL( activated() ), 102 connect(a, SIGNAL( activated() ),
102 this, SLOT( slotNew() ) ); 103 this, SLOT( slotNew() ) );
103 a->setWhatsThis( QWidget::tr( "Click here to create a new task." ) ); 104 a->setWhatsThis( QWidget::tr( "Click here to create a new task." ) );
104 a->addTo(m_tool ); 105 a->addTo(m_tool );
105 a->addTo(m_edit ); 106 a->addTo(m_edit );
106 107
107 a = new QAction( QWidget::tr("Edit Task"), Resource::loadIconSet( "edit" ), 108 a = new QAction( QWidget::tr("Edit Task"), Resource::loadIconSet( "edit" ),
108 QString::null, 0, this, 0 ); 109 QString::null, 0, this, 0 );
109 connect(a, SIGNAL(activated() ), 110 connect(a, SIGNAL(activated() ),
110 this, SLOT( slotEdit() ) ); 111 this, SLOT( slotEdit() ) );
111 a->setWhatsThis( QWidget::tr( "Click here to modify the current task." ) ); 112 a->setWhatsThis( QWidget::tr( "Click here to modify the current task." ) );
112 a->addTo( m_tool ); 113 a->addTo( m_tool );
113 a->addTo( m_edit ); 114 a->addTo( m_edit );
114 m_editAction = a; 115 m_editAction = a;
115 116
116 a = new QAction( QString::null, QWidget::tr("View Task"), 0, this, 0 ); 117 a = new QAction( QString::null, QWidget::tr("View Task"), 0, this, 0 );
117 connect(a, SIGNAL( activated() ), 118 connect(a, SIGNAL( activated() ),
118 this, SLOT( slotShowDetails() ) ); 119 this, SLOT( slotShowDetails() ) );
119 a->addTo( m_edit ); 120 a->addTo( m_edit );
120 121
121 m_edit->insertSeparator(); 122 m_edit->insertSeparator();
122 123
123 a = new QAction( QWidget::tr("Delete..."), Resource::loadIconSet( "trash" ), 124 a = new QAction( QWidget::tr("Delete..."), Resource::loadIconSet( "trash" ),
124 QString::null, 0, this, 0 ); 125 QString::null, 0, this, 0 );
125 connect(a, SIGNAL(activated() ), 126 connect(a, SIGNAL(activated() ),
126 this, SLOT(slotDelete() ) ); 127 this, SLOT(slotDelete() ) );
127 a->setWhatsThis( QWidget::tr( "Click here to remove the current task." ) ); 128 a->setWhatsThis( QWidget::tr( "Click here to remove the current task." ) );
128 a->addTo( m_tool ); 129 a->addTo( m_tool );
129 a->addTo( m_edit ); 130 a->addTo( m_edit );
130 m_deleteAction = a; 131 m_deleteAction = a;
131 132
132 a = new QAction( QString::null, QWidget::tr("Delete all..."), 0, this, 0 ); 133 a = new QAction( QString::null, QWidget::tr("Delete all..."), 0, this, 0 );
133 connect(a, SIGNAL( activated() ), 134 connect(a, SIGNAL( activated() ),
134 this, SLOT( slotDeleteAll() ) ); 135 this, SLOT( slotDeleteAll() ) );
135 a->addTo(m_edit ); 136 a->addTo(m_edit );
136 m_deleteAllAction = a; 137 m_deleteAllAction = a;
137 138
138 a = new QAction( QString::null, QWidget::tr("Delete completed"), 139 a = new QAction( QString::null, QWidget::tr("Delete completed"),
139 0, this, 0 ); 140 0, this, 0 );
140 connect(a, SIGNAL( activated() ), 141 connect(a, SIGNAL( activated() ),
141 this, SLOT( slotDeleteCompleted() ) ); 142 this, SLOT( slotDeleteCompleted() ) );
142 a->addTo(m_edit ); 143 a->addTo(m_edit );
143 a->setEnabled( TRUE ); 144 a->setEnabled( TRUE );
144 m_deleteCompleteAction = a; 145 m_deleteCompleteAction = a;
145 146
146 m_edit->insertSeparator(); 147 m_edit->insertSeparator();
147 148
148 a = new QAction( QString::null, QWidget::tr("Duplicate"), 0, this, 0 ); 149 a = new QAction( QString::null, QWidget::tr("Duplicate"), 0, this, 0 );
149 connect(a, SIGNAL( activated() ), 150 connect(a, SIGNAL( activated() ),
150 this, SLOT( slotDuplicate() ) ); 151 this, SLOT( slotDuplicate() ) );
151 a->addTo(m_edit ); 152 a->addTo(m_edit );
152 m_duplicateAction = a; 153 m_duplicateAction = a;
153 154
154 m_edit->insertSeparator(); 155 m_edit->insertSeparator();
155 156
156 if ( Ir::supported() ) { 157 if ( Ir::supported() ) {
157 a = new QAction( QWidget::tr( "Beam" ), Resource::loadPixmap( "beam" ), QString::null, 0, this, 0 ); 158 a = new QAction( QWidget::tr( "Beam" ), Resource::loadPixmap( "beam" ), QString::null, 0, this, 0 );
158 connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) ); 159 connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) );
159 a->setWhatsThis( QWidget::tr( "Click here to send the current task to another device." ) ); 160 a->setWhatsThis( QWidget::tr( "Click here to send the current task to another device." ) );
160 a->addTo( m_edit ); 161 a->addTo( m_edit );
161 a->addTo( m_tool ); 162 a->addTo( m_tool );
162 } 163 }
163 164
165#if 0
164 // Options menu 166 // Options menu
165 a = new QAction( QWidget::tr("Find"), Resource::loadIconSet( "mag" ), 167 a = new QAction( QWidget::tr("Find"), Resource::loadIconSet( "mag" ),
166 QString::null, 0, this, 0 ); 168 QString::null, 0, this, 0 );
167 connect(a, SIGNAL( activated() ), this, SLOT( slotFind() ) ); 169 connect(a, SIGNAL( activated() ), this, SLOT( slotFind() ) );
168 a->addTo( m_options ); 170 a->addTo( m_options );
169 m_findAction = a; 171 m_findAction = a;
170 172
173
171 m_options->insertSeparator(); 174 m_options->insertSeparator();
175#endif
172 176
173 m_completedAction = new QAction( QString::null, QWidget::tr("Show completed tasks"), 177 m_completedAction = new QAction( QString::null, QWidget::tr("Show completed tasks"),
174 0, this, 0, TRUE ); 178 0, this, 0, TRUE );
175 m_completedAction->addTo( m_options ); 179 m_completedAction->addTo( m_options );
176 m_completedAction->setOn( showCompleted() ); 180 m_completedAction->setOn( showCompleted() );
177 connect(m_completedAction, SIGNAL( toggled(bool) ), this, SLOT(slotShowCompleted(bool) ) ); 181 connect(m_completedAction, SIGNAL( toggled(bool) ), this, SLOT(slotShowCompleted(bool) ) );
178 182
179 a = new QAction( QString::null, QWidget::tr("Show only over-due tasks"), 183 a = new QAction( QString::null, QWidget::tr("Show only over-due tasks"),
180 0, this, 0, TRUE ); 184 0, this, 0, TRUE );
181 a->addTo( m_options ); 185 a->addTo( m_options );
182 a->setOn( showOverDue() ); 186 a->setOn( showOverDue() );
183 connect(a, SIGNAL(toggled(bool)), this, SLOT(slotShowDue(bool) ) ); 187 connect(a, SIGNAL(toggled(bool)), this, SLOT(slotShowDue(bool) ) );
184 188
185 m_showDeadLineAction = new QAction( QString::null, QWidget::tr("Show task deadlines"), 189 m_showDeadLineAction = new QAction( QString::null, QWidget::tr("Show task deadlines"),
186 0, this, 0, TRUE ); 190 0, this, 0, TRUE );
187 m_showDeadLineAction->addTo( m_options ); 191 m_showDeadLineAction->addTo( m_options );
188 m_showDeadLineAction->setOn( showDeadline() ); 192 m_showDeadLineAction->setOn( showDeadline() );
189 connect(m_showDeadLineAction, SIGNAL(toggled(bool) ), this, SLOT( slotShowDeadLine( bool ) ) ); 193 connect(m_showDeadLineAction, SIGNAL(toggled(bool) ), this, SLOT( slotShowDeadLine( bool ) ) );
190 194
191 m_showQuickTaskAction = new QAction( QString::null, QWidget::tr("Show quick task bar"), 195 m_showQuickTaskAction = new QAction( QString::null, QWidget::tr("Show quick task bar"),
192 0, this, 0, TRUE ); 196 0, this, 0, TRUE );
193 m_showQuickTaskAction->addTo( m_options ); 197 m_showQuickTaskAction->addTo( m_options );
194 m_showQuickTaskAction->setOn( showQuickTask() ); 198 m_showQuickTaskAction->setOn( showQuickTask() );
195 connect(m_showQuickTaskAction, SIGNAL( toggled(bool) ), this, SLOT(slotShowQuickTask(bool) ) ); 199 connect(m_showQuickTaskAction, SIGNAL( toggled(bool) ), this, SLOT(slotShowQuickTask(bool) ) );
196 200
197 m_options->insertSeparator(); 201 m_options->insertSeparator();
198 202
199 m_bar->insertItem( QWidget::tr("Data") ,m_edit ); 203 m_bar->insertItem( QWidget::tr("Data") ,m_edit );
200 m_bar->insertItem( QWidget::tr("Category"), m_catMenu ); 204 m_bar->insertItem( QWidget::tr("Category"), m_catMenu );
201 m_bar->insertItem( QWidget::tr("Options"), m_options ); 205 m_bar->insertItem( QWidget::tr("Options"), m_options );
202 206
203 m_curQuick = new QuickEditImpl( this, m_quicktask ); 207 m_curQuick = new QuickEditImpl( this, m_quicktask );
204 addToolBar( (QPEToolBar *)m_curQuick->widget(), QWidget::tr( "QuickEdit" ), QMainWindow::Top, TRUE ); 208 addToolBar( (QPEToolBar *)m_curQuick->widget(), QWidget::tr( "QuickEdit" ), QMainWindow::Top, TRUE );
205 m_curQuick->signal()->connect( this, SLOT(slotQuickEntered() ) ); 209 m_curQuick->signal()->connect( this, SLOT(slotQuickEntered() ) );
206 210
207} 211}
208/* m_curCat from Config */ 212/* m_curCat from Config */
209void MainWindow::initConfig() { 213void MainWindow::initConfig() {
210 Config config( "todo" ); 214 Config config( "todo" );
211 config.setGroup( "View" ); 215 config.setGroup( "View" );
212 m_completed = config.readBoolEntry( "ShowComplete", TRUE ); 216 m_completed = config.readBoolEntry( "ShowComplete", TRUE );
213 m_curCat = config.readEntry( "Category", QString::null ); 217 m_curCat = config.readEntry( "Category", QString::null );
214 m_deadline = config.readBoolEntry( "ShowDeadLine", TRUE); 218 m_deadline = config.readBoolEntry( "ShowDeadLine", TRUE);
215 m_overdue = config.readBoolEntry("ShowOverDue", FALSE ); 219 m_overdue = config.readBoolEntry("ShowOverDue", FALSE );
216 m_quicktask = config.readBoolEntry("ShowQuickTask", TRUE); 220 m_quicktask = config.readBoolEntry("ShowQuickTask", TRUE);
217} 221}
218void MainWindow::initUI() { 222void MainWindow::initUI() {
219 223
220 m_stack = new QWidgetStack(this, "main stack"); 224 m_stack = new QWidgetStack(this, "main stack");
221 225
222 setCentralWidget( m_stack ); 226 setCentralWidget( m_stack );
223 227
224 setToolBarsMovable( FALSE ); 228 setToolBarsMovable( FALSE );
225 229
226 QToolBar *menubarholder = new QToolBar( this ); 230 QToolBar *menubarholder = new QToolBar( this );
227 menubarholder->setHorizontalStretchable( TRUE ); 231 menubarholder->setHorizontalStretchable( TRUE );
228 m_bar = new QMenuBar( menubarholder ); 232 m_bar = new QMenuBar( menubarholder );
229 233
230 m_tool = new QToolBar( this ); 234 m_tool = new QToolBar( this );
231 235
232 /** QPopupMenu */ 236 /** QPopupMenu */
233 m_edit = new QPopupMenu( this ); 237 m_edit = new QPopupMenu( this );
234 m_options = new QPopupMenu( this ); 238 m_options = new QPopupMenu( this );
235 m_catMenu = new QPopupMenu( this ); 239 m_catMenu = new QPopupMenu( this );
236 m_template = new QPopupMenu( this ); 240 m_template = new QPopupMenu( this );
237 241
238 m_catMenu->setCheckable( TRUE ); 242 m_catMenu->setCheckable( TRUE );
239 m_template->setCheckable( TRUE ); 243 m_template->setCheckable( TRUE );
240 244
241 connect(m_catMenu, SIGNAL(activated(int) ), 245 connect(m_catMenu, SIGNAL(activated(int) ),
242 this, SLOT(setCategory(int) ) ); 246 this, SLOT(setCategory(int) ) );
243 connect(m_template, SIGNAL(activated(int) ), 247 connect(m_template, SIGNAL(activated(int) ),
244 this, SLOT(slotNewFromTemplate(int) ) ); 248 this, SLOT(slotNewFromTemplate(int) ) );
245} 249}
246void MainWindow::initViews() { 250void MainWindow::initViews() {
247 251
248 TableView* tableView = new TableView( this, m_stack ); 252 TableView* tableView = new TableView( this, m_stack );
249 QWhatsThis::add( tableView, QWidget::tr( "This is a listing of all current tasks.\n\nThe list displays the following information:\n1. Completed - A green checkmark indicates task is completed. Click here to complete a task.\n2. Priority - a graphical representation of task priority. Double-click here to modify.\n3. Description - description of task. Click here to select the task.\n4. Deadline - shows when task is due. This column can be shown or hidden by selecting Options->'Show task deadlines' from the menu above." ) ); 253 QWhatsThis::add( tableView, QWidget::tr( "This is a listing of all current tasks.\n\nThe list displays the following information:\n1. Completed - A green checkmark indicates task is completed. Click here to complete a task.\n2. Priority - a graphical representation of task priority. Double-click here to modify.\n3. Description - description of task. Click here to select the task.\n4. Deadline - shows when task is due. This column can be shown or hidden by selecting Options->'Show task deadlines' from the menu above." ) );
250 m_stack->addWidget( tableView, m_counter++ ); 254 m_stack->addWidget( tableView, m_counter++ );
251 m_views.append( tableView ); 255 m_views.append( tableView );
252 m_curView = tableView; 256 m_curView = tableView;
253 connectBase( tableView ); 257 connectBase( tableView );
254 /* add QString type + QString configname to 258 /* add QString type + QString configname to
255 * the View menu 259 * the View menu
256 * and subdirs for multiple views 260 * and subdirs for multiple views
257 */ 261 */
258} 262}
259void MainWindow::initEditor() { 263void MainWindow::initEditor() {
260 m_curEdit = new Editor(); 264 m_curEdit = new Editor();
261} 265}
262void MainWindow::initShow() { 266void MainWindow::initShow() {
263 m_curShow = new TextViewShow(this, this); 267 m_curShow = new TextViewShow(this, this);
264 m_stack->addWidget( m_curShow->widget() , m_counter++ ); 268 m_stack->addWidget( m_curShow->widget() , m_counter++ );
265} 269}
266MainWindow::~MainWindow() { 270MainWindow::~MainWindow() {
267 delete templateManager(); 271 delete templateManager();
268} 272}
269void MainWindow::connectBase( ViewBase* ) { 273void MainWindow::connectBase( ViewBase* ) {
270 // once templates and signals mix we'll use it again 274 // once templates and signals mix we'll use it again
271} 275}
272QPopupMenu* MainWindow::contextMenu( int , bool recur ) { 276QPopupMenu* MainWindow::contextMenu( int , bool recur ) {
273 QPopupMenu* menu = new QPopupMenu(); 277 QPopupMenu* menu = new QPopupMenu();
274 278
275 m_editAction->addTo( menu ); 279 m_editAction->addTo( menu );
276 m_deleteAction->addTo( menu ); 280 m_deleteAction->addTo( menu );
277 m_duplicateAction->addTo( menu ); 281 m_duplicateAction->addTo( menu );
278 282
279 menu->insertSeparator(); 283 menu->insertSeparator();
280 284
281 /* 285 /*
282 * if this event recurs we allow 286 * if this event recurs we allow
283 * to detach it. 287 * to detach it.
284 * remove all 288 * remove all
285 */ 289 */
286 if ( recur ) { 290 if ( recur ) {
287 ; // FIXME 291 ; // FIXME
288 } 292 }
289 293
290 return menu; 294 return menu;
291} 295}
292QPopupMenu* MainWindow::options() { 296QPopupMenu* MainWindow::options() {
293 qWarning("Options"); 297 qWarning("Options");
294 return m_options; 298 return m_options;
295} 299}
296QPopupMenu* MainWindow::edit() { 300QPopupMenu* MainWindow::edit() {
297 return m_edit; 301 return m_edit;
298} 302}
299QToolBar* MainWindow::toolbar() { 303QToolBar* MainWindow::toolbar() {
300 return m_tool; 304 return m_tool;
301} 305}
302OTodoAccess::List MainWindow::list()const { 306OTodoAccess::List MainWindow::list()const {
303 return m_todoMgr.list(); 307 return m_todoMgr.list();
304} 308}
305OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder ) { 309OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder ) {
306 int cat = 0; 310 int cat = 0;
307 if ( m_curCat != QWidget::tr("All Categories") ) 311 if ( m_curCat != QWidget::tr("All Categories") )
308 cat = currentCatId(); 312 cat = currentCatId();
309 if ( m_curCat == QWidget::tr("Unfiled") ) 313 if ( m_curCat == QWidget::tr("Unfiled") )
310 cat = -1; 314 cat = -1;
311 315
312 qWarning(" Category %d %s", cat, m_curCat.latin1() ); 316 qWarning(" Category %d %s", cat, m_curCat.latin1() );
313 317
314 int filter = 1; 318 int filter = 1;
315 319
316 if (!m_completed ) 320 if (!m_completed )
317 filter |= 4; 321 filter |= 4;
318 if (m_overdue) 322 if (m_overdue)
319 filter |= 2; 323 filter |= 2;
320 324
321 return m_todoMgr.sorted( asc, sortOrder, filter, cat ); 325 return m_todoMgr.sorted( asc, sortOrder, filter, cat );
322} 326}
323OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder, int addFilter) { 327OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder, int addFilter) {
324 int cat = 0; 328 int cat = 0;
325 if ( m_curCat != QWidget::tr("All Categories") ) 329 if ( m_curCat != QWidget::tr("All Categories") )
326 cat = currentCatId(); 330 cat = currentCatId();
327 331
328 if ( m_curCat == QWidget::tr("Unfiled") ) 332 if ( m_curCat == QWidget::tr("Unfiled") )
329 cat = -1; 333 cat = -1;
330 334
331 return m_todoMgr.sorted(asc, sortOrder, addFilter, cat ); 335 return m_todoMgr.sorted(asc, sortOrder, addFilter, cat );
332} 336}
333OTodo MainWindow::event( int uid ) { 337OTodo MainWindow::event( int uid ) {
334 return m_todoMgr.event( uid ); 338 return m_todoMgr.event( uid );
335} 339}
336bool MainWindow::isSyncing()const { 340bool MainWindow::isSyncing()const {
337 return m_syncing; 341 return m_syncing;
338} 342}
339TemplateManager* MainWindow::templateManager() { 343TemplateManager* MainWindow::templateManager() {
340 return m_tempManager; 344 return m_tempManager;
341} 345}
342Editor* MainWindow::currentEditor() { 346Editor* MainWindow::currentEditor() {
343 return m_curEdit; 347 return m_curEdit;
344} 348}
345TodoShow* MainWindow::currentShow() { 349TodoShow* MainWindow::currentShow() {
346 return m_curShow; 350 return m_curShow;
347} 351}
348void MainWindow::slotReload() { 352void MainWindow::slotReload() {
349 m_todoMgr.reload(); 353 m_todoMgr.reload();
350 currentView()->updateView( ); 354 currentView()->updateView( );
351 raiseCurrentView(); 355 raiseCurrentView();
352} 356}
353void MainWindow::closeEvent( QCloseEvent* e ) { 357void MainWindow::closeEvent( QCloseEvent* e ) {
354 if (m_stack->visibleWidget() == currentShow()->widget() ) { 358 if (m_stack->visibleWidget() == currentShow()->widget() ) {
359 m_showing = false;
355 raiseCurrentView(); 360 raiseCurrentView();
356 e->ignore(); 361 e->ignore();
357 return; 362 return;
358 } 363 }
359 /* 364 /*
360 * we should have flushed and now we're still saving 365 * we should have flushed and now we're still saving
361 * so there is no need to flush 366 * so there is no need to flush
362 */ 367 */
363 if (m_syncing ) { 368 if (m_syncing ) {
364 e->accept(); 369 e->accept();
365 return; 370 return;
366 } 371 }
367 bool quit = false; 372 bool quit = false;
368 if ( m_todoMgr.saveAll() ){ 373 if ( m_todoMgr.saveAll() ){
369 qWarning("saved"); 374 qWarning("saved");
370 quit = true; 375 quit = true;
371 }else { 376 }else {
372 if ( QMessageBox::critical( this, QWidget::tr("Out of space"), 377 if ( QMessageBox::critical( this, QWidget::tr("Out of space"),
373 QWidget::tr("Todo was unable\n" 378 QWidget::tr("Todo was unable\n"
374 "to save your changes.\n" 379 "to save your changes.\n"
375 "Free up some space\n" 380 "Free up some space\n"
376 "and try again.\n" 381 "and try again.\n"
377 "\nQuit Anyway?"), 382 "\nQuit Anyway?"),
378 QMessageBox::Yes|QMessageBox::Escape, 383 QMessageBox::Yes|QMessageBox::Escape,
379 QMessageBox::No|QMessageBox::Default) 384 QMessageBox::No|QMessageBox::Default)
380 != QMessageBox::No ) { 385 != QMessageBox::No ) {
381 e->accept(); 386 e->accept();
382 quit = true; 387 quit = true;
383 }else 388 }else
384 e->ignore(); 389 e->ignore();
385 390
386 } 391 }
387 392
388 if (quit ) { 393 if (quit ) {
389 Config config( "todo" ); 394 Config config( "todo" );
390 config.setGroup( "View" ); 395 config.setGroup( "View" );
391 config.writeEntry( "ShowComplete", showCompleted() ); 396 config.writeEntry( "ShowComplete", showCompleted() );
392 config.writeEntry( "Category", currentCategory() ); 397 config.writeEntry( "Category", currentCategory() );
393 config.writeEntry( "ShowDeadLine", showDeadline()); 398 config.writeEntry( "ShowDeadLine", showDeadline());
394 config.writeEntry( "ShowOverDue", showOverDue() ); 399 config.writeEntry( "ShowOverDue", showOverDue() );
395 config.writeEntry( "ShowQuickTask", showQuickTask() ); 400 config.writeEntry( "ShowQuickTask", showQuickTask() );
396 /* save templates */ 401 /* save templates */
397 templateManager()->save(); 402 templateManager()->save();
398 e->accept(); 403 e->accept();
399 } 404 }
400} 405}
401void MainWindow::populateTemplates() { 406void MainWindow::populateTemplates() {
402 m_template->clear(); 407 m_template->clear();
403 QStringList list = templateManager()->templates(); 408 QStringList list = templateManager()->templates();
404 QStringList::Iterator it; 409 QStringList::Iterator it;
405 for ( it = list.begin(); it != list.end(); ++it ) { 410 for ( it = list.begin(); it != list.end(); ++it ) {
406 m_template->insertItem( (*it) ); 411 m_template->insertItem( (*it) );
407 } 412 }
408} 413}
409/* 414/*
410 * slotNewFromTemplate 415 * slotNewFromTemplate
411 * We use the edit widget to do 416 * We use the edit widget to do
412 * the config but we setUid(-1) 417 * the config but we setUid(1)
413 * to get a new uid 418 * to get a new uid
414 */ 419 */
415/* 420/*
416 * first we get the name of the template 421 * first we get the name of the template
417 * then we will use the TemplateManager 422 * then we will use the TemplateManager
418 */ 423 */
419void MainWindow::slotNewFromTemplate( int id ) { 424void MainWindow::slotNewFromTemplate( int id ) {
420 QString name = m_template->text( id ); 425 QString name = m_template->text( id );
421 426
422 OTodo event = templateManager()->templateEvent( name ); 427 OTodo event = templateManager()->templateEvent( name );
423 event = currentEditor()->edit(this, 428 event = currentEditor()->edit(this,
424 event ); 429 event );
425 430
426 if ( currentEditor()->accepted() ) { 431 if ( currentEditor()->accepted() ) {
427 /* assign new todo */ 432 /* assign new todo */
428 event.setUid( -1 ); 433 event.setUid( 1 );
429 currentView()->addEvent( event ); 434 handleAlarms( OTodo(), event );
430 m_todoMgr.add( event ); 435 m_todoMgr.add( event );
436 currentView()->addEvent( event );
431 437
432 populateCategories(); 438 populateCategories();
433 } 439 }
440 raiseCurrentView();
434} 441}
435void MainWindow::slotNew() { 442void MainWindow::slotNew() {
436 create(); 443 create();
437} 444}
438void MainWindow::slotDuplicate() { 445void MainWindow::slotDuplicate() {
439 if(m_syncing) { 446 if(m_syncing) {
440 QMessageBox::warning(this, QWidget::tr("Todo"), 447 QMessageBox::warning(this, QWidget::tr("Todo"),
441 QWidget::tr("Can not edit data, currently syncing")); 448 QWidget::tr("Data can not be edited, currently syncing"));
442 return; 449 return;
443 } 450 }
444 OTodo ev = m_todoMgr.event( currentView()->current() ); 451 OTodo ev = m_todoMgr.event( currentView()->current() );
445 /* let's generate a new uid */ 452 /* let's generate a new uid */
446 ev.setUid(-1); 453 ev.setUid(1);
447 m_todoMgr.add( ev ); 454 m_todoMgr.add( ev );
448 455
449 currentView()->addEvent( ev ); 456 currentView()->addEvent( ev );
450 raiseCurrentView(); 457 raiseCurrentView();
451} 458}
452void MainWindow::slotDelete() { 459void MainWindow::slotDelete() {
453 if (!currentView()->current() ) 460 if (!currentView()->current() )
454 return; 461 return;
455 462
456 if(m_syncing) { 463 if(m_syncing) {
457 QMessageBox::warning(this, QWidget::tr("Todo"), 464 QMessageBox::warning(this, QWidget::tr("Todo"),
458 QWidget::tr("Can not edit data, currently syncing")); 465 QWidget::tr("Data can not be edited, currently syncing"));
459 return; 466 return;
460 } 467 }
461 QString strName = currentView()->currentRepresentation(); 468 QString strName = currentView()->currentRepresentation();
462 if (!QPEMessageBox::confirmDelete(this, QWidget::tr("Todo"), strName ) ) 469 if (!QPEMessageBox::confirmDelete(this, QWidget::tr("Todo"), strName ) )
463 return; 470 return;
464 471
465 handleAlarms( OTodo(), m_todoMgr.event( currentView()->current() ) ); 472 handleAlarms( m_todoMgr.event( currentView()->current() ), OTodo() );
466 m_todoMgr.remove( currentView()->current() ); 473 m_todoMgr.remove( currentView()->current() );
467 currentView()->removeEvent( currentView()->current() ); 474 currentView()->removeEvent( currentView()->current() );
468 raiseCurrentView(); 475 raiseCurrentView();
469} 476}
477void MainWindow::slotDelete(int uid ) {
478 if( uid == 0 ) return;
479 if(m_syncing) {
480 QMessageBox::warning(this, QWidget::tr("Todo"),
481 QWidget::tr("Data can not be edited, currently syncing"));
482 return;
483 }
484 OTodo to = m_todoMgr.event(uid);
485 if (!QPEMessageBox::confirmDelete(this, QWidget::tr("Todo"), to.toShortText() ) )
486 return;
487
488 handleAlarms(to, OTodo() );
489 m_todoMgr.remove( to.uid() );
490 currentView()->removeEvent( to.uid() );
491 raiseCurrentView();
492}
470void MainWindow::slotDeleteAll() { 493void MainWindow::slotDeleteAll() {
471 if(m_syncing) { 494 if(m_syncing) {
472 QMessageBox::warning(this, QWidget::tr("Todo"), 495 QMessageBox::warning(this, QWidget::tr("Todo"),
473 QWidget::tr("Can not edit data, currently syncing")); 496 QWidget::tr("Data can not be edited, currently syncing"));
474 return; 497 return;
475 } 498 }
476 499
477 500
478 if ( !QPEMessageBox::confirmDelete( this, QWidget::tr( "Todo" ), QWidget::tr("all tasks?") ) ) 501 if ( !QPEMessageBox::confirmDelete( this, QWidget::tr( "Todo" ), QWidget::tr("all tasks?") ) )
479 return; 502 return;
480 503
481 m_todoMgr.removeAll(); 504 m_todoMgr.removeAll();
482 currentView()->clear(); 505 currentView()->clear();
483 506
484 raiseCurrentView(); 507 raiseCurrentView();
485} 508}
486void MainWindow::slotDeleteCompleted() { 509void MainWindow::slotDeleteCompleted() {
487 if(m_syncing) { 510 if(m_syncing) {
488 QMessageBox::warning(this, QWidget::tr("Todo"), 511 QMessageBox::warning(this, QWidget::tr("Todo"),
489 QWidget::tr("Can not edit data, currently syncing")); 512 QWidget::tr("Data can not be edited, currently syncing"));
490 return; 513 return;
491 } 514 }
492 515
493 if ( !QPEMessageBox::confirmDelete( this, QWidget::tr( "Todo" ), QWidget::tr("all completed tasks?") ) ) 516 if ( !QPEMessageBox::confirmDelete( this, QWidget::tr( "Todo" ), QWidget::tr("all completed tasks?") ) )
494 return; 517 return;
495 518
496 519
497 m_todoMgr.removeCompleted(); 520 m_todoMgr.removeCompleted();
498 currentView()->updateView( ); 521 currentView()->updateView( );
499} 522}
500void MainWindow::slotFind() { 523void MainWindow::slotFind() {
501 524
502} 525}
503void MainWindow::slotEdit() { 526void MainWindow::slotEdit() {
504 slotEdit( currentView()->current() ); 527 slotEdit( currentView()->current() );
505} 528}
506/* 529/*
507 * set the category 530 * set the category
508 */ 531 */
509void MainWindow::setCategory( int c) { 532void MainWindow::setCategory( int c) {
510 if ( c <= 0 ) return; 533 if ( c <= 0 ) return;
511 534
512 535
513 qWarning("Iterating over cats %d", c ); 536 qWarning("Iterating over cats %d", c );
514 for ( unsigned int i = 1; i < m_catMenu->count(); i++ ) 537 for ( unsigned int i = 1; i < m_catMenu->count(); i++ )
515 m_catMenu->setItemChecked(i, c == (int)i ); 538 m_catMenu->setItemChecked(i, c == (int)i );
516 539
517 if (c == 1 ) { 540 if (c == 1 ) {
518 m_curCat = QString::null; 541 m_curCat = QString::null;
519 setCaption( QWidget::tr("Todo") + " - " + QWidget::tr("All Categories" ) ); 542 setCaption( QWidget::tr("Todo") + " - " + QWidget::tr("All Categories" ) );
520 543
521 }else if ( c == (int)m_catMenu->count() - 1 ) { 544 }else if ( c == (int)m_catMenu->count() - 1 ) {
522 m_curCat = QWidget::tr("Unfiled"); 545 m_curCat = QWidget::tr("Unfiled");
523 setCaption( QWidget::tr("Todo") + " - " + QWidget::tr("Unfiled") ); 546 setCaption( QWidget::tr("Todo") + " - " + QWidget::tr("Unfiled") );
524 }else { 547 }else {
525 m_curCat = m_todoMgr.categories()[c-2]; 548 m_curCat = m_todoMgr.categories()[c-2];
526 setCaption( QWidget::tr("Todo") + " - " + m_curCat ); 549 setCaption( QWidget::tr("Todo") + " - " + m_curCat );
527 } 550 }
528 m_catMenu->setItemChecked( c, true ); 551 m_catMenu->setItemChecked( c, true );
529 552
530 currentView()->setShowCategory( m_curCat ); 553 currentView()->setShowCategory( m_curCat );
531 raiseCurrentView(); 554 raiseCurrentView();
532} 555}
533void MainWindow::slotShowDeadLine( bool dead) { 556void MainWindow::slotShowDeadLine( bool dead) {
534 m_deadline = dead; 557 m_deadline = dead;
535 currentView()->setShowDeadline( dead ); 558 currentView()->setShowDeadline( dead );
536} 559}
537void MainWindow::slotShowCompleted( bool show) { 560void MainWindow::slotShowCompleted( bool show) {
538 m_completed = show; 561 m_completed = show;
539 currentView()->setShowCompleted( m_completed ); 562 currentView()->setShowCompleted( m_completed );
540} 563}
541void MainWindow::slotShowQuickTask( bool show ) { 564void MainWindow::slotShowQuickTask( bool show ) {
542 m_quicktask = show; 565 m_quicktask = show;
543 if ( m_quicktask ) 566 if ( m_quicktask )
544 m_curQuick->widget()->show(); 567 m_curQuick->widget()->show();
545 else 568 else
546 m_curQuick->widget()->hide(); 569 m_curQuick->widget()->hide();
547} 570}
548bool MainWindow::showOverDue()const { 571bool MainWindow::showOverDue()const {
549 return m_overdue; 572 return m_overdue;
550} 573}
551void MainWindow::setDocument( const QString& fi) { 574void MainWindow::setDocument( const QString& fi) {
552 DocLnk doc(fi); 575 DocLnk doc(fi);
553 if (doc.isValid() ) 576 if (doc.isValid() )
554 receiveFile(doc.file() ); 577 receiveFile(doc.file() );
555 else 578 else
556 receiveFile(fi ); 579 receiveFile(fi );
557} 580}
558 581
559static const char *beamfile = "/tmp/opie-todo.vcs"; 582static const char *beamfile = "/tmp/opie-todo.vcs";
560void MainWindow::slotBeam() { 583void MainWindow::slotBeam() {
561 beam( currentView()->current() ); 584 beam( currentView()->current() );
562} 585}
563void MainWindow::beamDone( Ir* ir) { 586void MainWindow::beamDone( Ir* ir) {
564 delete ir; 587 delete ir;
565 ::unlink( beamfile ); 588 ::unlink( beamfile );
566} 589}
567void MainWindow::receiveFile( const QString& filename ) { 590void MainWindow::receiveFile( const QString& filename ) {
568 OTodoAccessVCal* cal = new OTodoAccessVCal(filename ); 591 OTodoAccessVCal* cal = new OTodoAccessVCal(filename );
592
569 OTodoAccess acc( cal ); 593 OTodoAccess acc( cal );
570 acc.load(); 594 acc.load();
571 OTodoAccess::List list = acc.allRecords(); 595 OTodoAccess::List list = acc.allRecords();
572 596
573 QString message = QWidget::tr("<P>%1 new tasks arrived.<p>Would you like to add them to your Todolist?").arg(list.count() ); 597 if (list.count()){
574 598
575 if ( QMessageBox::information(this, QWidget::tr("New Tasks"), 599 QString message = QWidget::tr("<P>%1 new tasks arrived.<p>Would you like to add them to your Todolist?").arg(list.count() );
576 message, QMessageBox::Ok,
577 QMessageBox::Cancel ) == QMessageBox::Ok ) {
578 OTodoAccess::List::Iterator it;
579 for ( it = list.begin(); it != list.end(); ++it )
580 m_todoMgr.add( (*it) );
581 600
582 currentView()->updateView(); 601 if ( QMessageBox::information(this, QWidget::tr("New Tasks"),
602 message, QMessageBox::Ok,
603 QMessageBox::Cancel ) == QMessageBox::Ok ) {
604 OTodoAccess::List::Iterator it;
605 for ( it = list.begin(); it != list.end(); ++it )
606 m_todoMgr.add( (*it) );
607
608 currentView()->updateView();
609 }
583 } 610 }
584} 611}
585 612
586void MainWindow::slotFlush() { 613void MainWindow::slotFlush() {
587 m_syncing = FALSE; 614 m_syncing = FALSE;
588 m_todoMgr.save(); 615 m_todoMgr.save();
589} 616}
590void MainWindow::slotShowDetails() { 617void MainWindow::slotShowDetails() {
591 slotShow( currentView()->current() ); 618 slotShow( currentView()->current() );
592} 619}
593/* 620/*
594 * populate the Categories 621 * populate the Categories
595 * Menu 622 * Menu
596 */ 623 */
597void MainWindow::populateCategories() { 624void MainWindow::populateCategories() {
598 m_todoMgr.load(); 625 m_todoMgr.load();
599 626
600 m_catMenu->clear(); 627 m_catMenu->clear();
601 int id, rememberId; 628 int id, rememberId;
602 id = 1; 629 id = 1;
603 rememberId = 1; 630 rememberId = 1;
604 631
605 m_catMenu->insertItem( QWidget::tr( "All Categories" ), id++ ); 632 m_catMenu->insertItem( QWidget::tr( "All Categories" ), id++ );
606 m_catMenu->insertSeparator(); 633 m_catMenu->insertSeparator();
607 QStringList categories = m_todoMgr.categories(); 634 QStringList categories = m_todoMgr.categories();
608 categories.append( QWidget::tr( "Unfiled" ) ); 635 categories.append( QWidget::tr( "Unfiled" ) );
609 for ( QStringList::Iterator it = categories.begin(); 636 for ( QStringList::Iterator it = categories.begin();
610 it != categories.end(); ++it ) { 637 it != categories.end(); ++it ) {
611 m_catMenu->insertItem( *it, id ); 638 m_catMenu->insertItem( *it, id );
612 if ( *it == currentCategory() ) 639 if ( *it == currentCategory() )
613 rememberId = id; 640 rememberId = id;
614 ++id; 641 ++id;
615 } 642 }
616 setCategory( rememberId ); 643 setCategory( rememberId );
617} 644}
618bool MainWindow::showCompleted()const { 645bool MainWindow::showCompleted()const {
619 return m_completed; 646 return m_completed;
620} 647}
621bool MainWindow::showDeadline()const { 648bool MainWindow::showDeadline()const {
622 return m_deadline; 649 return m_deadline;
623} 650}
624bool MainWindow::showQuickTask()const { 651bool MainWindow::showQuickTask()const {
625 return m_quicktask; 652 return m_quicktask;
626} 653}
627QString MainWindow::currentCategory()const { 654QString MainWindow::currentCategory()const {
628 return m_curCat; 655 return m_curCat;
629} 656}
630int MainWindow::currentCatId() { 657int MainWindow::currentCatId() {
631 return m_todoMgr.catId( m_curCat ); 658 return m_todoMgr.catId( m_curCat );
632} 659}
633ViewBase* MainWindow::currentView() { 660ViewBase* MainWindow::currentView() {
634 return m_curView; 661 return m_curView;
635} 662}
636void MainWindow::raiseCurrentView() { 663void MainWindow::raiseCurrentView() {
664 // due QPE/Application/todolist show(int)
665 // we might not have the populateCategories slot called once
666 // we would show the otodo but then imediately switch to the currentView
667 // if we're initially showing we shouldn't raise the table
668 // in returnFromView we fix up m_showing
669 if (m_showing ) return;
670
637 m_stack->raiseWidget( m_curView->widget() ); 671 m_stack->raiseWidget( m_curView->widget() );
638} 672}
639void MainWindow::slotShowDue(bool ov) { 673void MainWindow::slotShowDue(bool ov) {
640 m_overdue = ov; 674 m_overdue = ov;
641 currentView()->showOverDue( ov ); 675 currentView()->showOverDue( ov );
642 raiseCurrentView(); 676 raiseCurrentView();
643} 677}
644void MainWindow::slotShow( int uid ) { 678void MainWindow::slotShow( int uid ) {
679 if ( uid == 0 ) return;
645 qWarning("slotShow"); 680 qWarning("slotShow");
646 currentShow()->slotShow( event( uid ) ); 681 currentShow()->slotShow( event( uid ) );
647 m_stack->raiseWidget( currentShow()->widget() ); 682 m_stack->raiseWidget( currentShow()->widget() );
648} 683}
684void MainWindow::slotShowNext() {
685 int l = currentView()->next();
686 if (l!=0)
687 slotShow(l);
688}
689void MainWindow::slotShowPrev() {
690 int l = currentView()->prev();
691 if (l!=0)
692 slotShow(l);
693}
649void MainWindow::slotEdit( int uid ) { 694void MainWindow::slotEdit( int uid ) {
650 if (uid == 1 ) return; 695 if (uid == 0 ) return;
651 if(m_syncing) { 696 if(m_syncing) {
652 QMessageBox::warning(this, QWidget::tr("Todo"), 697 QMessageBox::warning(this, QWidget::tr("Todo"),
653 QWidget::tr("Can not edit data, currently syncing")); 698 QWidget::tr("Data can't be edited, currently syncing"));
654 return; 699 return;
655 } 700 }
656 701
657 OTodo old_todo = m_todoMgr.event( uid ); 702 OTodo old_todo = m_todoMgr.event( uid );
658 703
659 OTodo todo = currentEditor()->edit(this, old_todo ); 704 OTodo todo = currentEditor()->edit(this, old_todo );
660 705
661 /* if completed */ 706 /* if completed */
662 if ( currentEditor()->accepted() ) { 707 if ( currentEditor()->accepted() ) {
663 qWarning("Replacing now" );
664 handleAlarms( old_todo, todo ); 708 handleAlarms( old_todo, todo );
665 m_todoMgr.update( todo.uid(), todo ); 709 m_todoMgr.update( todo.uid(), todo );
666 currentView()->replaceEvent( todo ); 710 currentView()->replaceEvent( todo );
667 /* a Category might have changed */ 711 /* a Category might have changed */
668 populateCategories(); 712 populateCategories();
669 } 713 }
670 714
671 raiseCurrentView(); 715 raiseCurrentView();
672} 716}
673/* 717/*
674void MainWindow::slotUpdate1( int uid, const SmallTodo& ev) { 718void MainWindow::slotUpdate1( int uid, const SmallTodo& ev) {
675 m_todoMgr.update( uid, ev ); 719 m_todoMgr.update( uid, ev );
676} 720}
677*/ 721*/
678void MainWindow::updateTodo( const OTodo& ev) { 722void MainWindow::updateTodo( const OTodo& ev) {
679 m_todoMgr.update( ev.uid() , ev ); 723 m_todoMgr.update( ev.uid() , ev );
680} 724}
681/* The view changed it's configuration 725/* The view changed it's configuration
682 * update the view menu 726 * update the view menu
683 */ 727 */
684void MainWindow::slotUpdate3( QWidget* ) { 728void MainWindow::slotUpdate3( QWidget* ) {
685 729
686} 730}
687void MainWindow::updateList() { 731void MainWindow::updateList() {
688 m_todoMgr.updateList(); 732 m_todoMgr.updateList();
689} 733}
690void MainWindow::setReadAhead( uint count ) { 734void MainWindow::setReadAhead( uint count ) {
691 if (m_todoMgr.todoDB() ) 735 if (m_todoMgr.todoDB() )
692 m_todoMgr.todoDB()->setReadAhead( count ); 736 m_todoMgr.todoDB()->setReadAhead( count );
693} 737}
694void MainWindow::slotQuickEntered() { 738void MainWindow::slotQuickEntered() {
695 qWarning("entered"); 739 qWarning("entered");
696 OTodo todo = quickEditor()->todo(); 740 OTodo todo = quickEditor()->todo();
697 if (todo.isEmpty() ) 741 if (todo.isEmpty() )
698 return; 742 return;
699 743
700 m_todoMgr.add( todo ); 744 m_todoMgr.add( todo );
701 currentView()->addEvent( todo ); 745 currentView()->addEvent( todo );
702 raiseCurrentView(); 746 raiseCurrentView();
703} 747}
704QuickEditBase* MainWindow::quickEditor() { 748QuickEditBase* MainWindow::quickEditor() {
705 return m_curQuick; 749 return m_curQuick;
706} 750}
707void MainWindow::slotComplete( int uid ) { 751void MainWindow::slotComplete( int uid ) {
708 slotComplete( event(uid) ); 752 slotComplete( event(uid) );
709} 753}
710void MainWindow::slotComplete( const OTodo& todo ) { 754void MainWindow::slotComplete( const OTodo& todo ) {
711 OTodo to = todo; 755 OTodo to = todo;
712 to.setCompleted( !to.isCompleted() ); 756 to.setCompleted( !to.isCompleted() );
713 to.setCompletedDate( QDate::currentDate() ); 757 to.setCompletedDate( QDate::currentDate() );
714 758
715 /* 759 /*
716 * if the item does recur 760 * if the item does recur
717 * we need to spin it off 761 * we need to spin it off
718 * and update the items duedate to the next 762 * and update the items duedate to the next
719 * possible recurrance of this item... 763 * possible recurrance of this item...
720 * the spinned off one will loose the 764 * the spinned off one will loose the
765 * recurrence.
766 * We calculate the difference between the old due date and the
767 * new one and add this diff to start, completed and alarm dates
768 * -zecke
721 */ 769 */
722 if ( to.hasRecurrence() && to.isCompleted() ) { 770 if ( to.hasRecurrence() && to.isCompleted() ) {
723 OTodo to2( to ); 771 OTodo to2( to );
724 772
725 /* the spinned off one won't recur anymore */ 773 /* the spinned off one won't recur anymore */
726 to.setRecurrence( ORecur() ); 774 to.setRecurrence( ORecur() );
727 775
728 ORecur rec = to2.recurrence(); 776 ORecur rec = to2.recurrence();
729 rec.setStart( to.dueDate() ); 777 rec.setStart( to.dueDate() );
730 to2.setRecurrence( rec ); 778 to2.setRecurrence( rec );
731 /* 779 /*
732 * if there is a next occurence 780 * if there is a next occurence
733 * from the duedate of the last recurrance 781 * from the duedate of the last recurrance
734 */ 782 */
735 QDate date; 783 QDate date;
736 if ( to2.recurrence().nextOcurrence( to2.dueDate().addDays(1), date ) ) { 784 if ( to2.recurrence().nextOcurrence( to2.dueDate().addDays(1), date ) ) {
785 int dayDiff = to.dueDate().daysTo( date );
786 qWarning("day diff is %d", dayDiff );
737 QDate inval; 787 QDate inval;
738 /* generate a new uid for the old record */ 788 /* generate a new uid for the old record */
739 to.setUid( 1 ); 789 to.setUid( 1 );
740 790
741 /* add the old one cause it has a new UID here cause it was spin off */ 791 /* add the old one cause it has a new UID here cause it was spin off */
742 m_todoMgr.add( to ); 792 m_todoMgr.add( to );
743 793
744 /* 794 /*
745 * update the due date 795 * update the due date
746 * start date 796 * start date
747 * and complete date 797 * and complete date
748 */ 798 */
749 to2.setDueDate( date ); 799 to2.setDueDate( date );
750 to2.setStartDate( inval ); 800 rec.setStart( date );
801 to2.setRecurrence( rec ); // could be Monday, TuesDay, Thursday every week
802
803 /* move start date */
804 if (to2.hasStartDate() )
805 to2.setStartDate( to2.startDate().addDays( dayDiff ) );
806
807 /* now the alarms */
808 if (to2.hasNotifiers() ) {
809 OPimNotifyManager::Alarms _als = to2.notifiers().alarms();
810 OPimNotifyManager::Alarms als;
811
812 /* for every alarm move the day */
813 for ( OPimNotifyManager::Alarms::Iterator it = _als.begin(); it != _als.end(); ++it ) {
814 OPimAlarm al = (*it);
815 al.setDateTime( al.dateTime().addDays( dayDiff ) );
816 als.append( al );
817 }
818 to2.notifiers().setAlarms( als );
819 handleAlarms( OTodo(), todo );
820 }
751 to2.setCompletedDate( inval ); 821 to2.setCompletedDate( inval );
752 to2.setCompleted( false ); 822 to2.setCompleted( false );
823
753 updateTodo( to2 ); 824 updateTodo( to2 );
754 }else 825 }else
755 updateTodo( to ); 826 updateTodo( to );
756 }else 827 }else
757 updateTodo( to ); 828 updateTodo( to );
758 829
759 currentView()->updateView(); 830 currentView()->updateView();
760 raiseCurrentView(); 831 raiseCurrentView();
761} 832}
762void MainWindow::flush() { 833void MainWindow::flush() {
763 slotFlush(); 834 slotFlush();
764} 835}
765void MainWindow::reload() { 836void MainWindow::reload() {
766 slotReload(); 837 slotReload();
767} 838}
768int MainWindow::create() { 839int MainWindow::create() {
769 int uid = 0; 840 int uid = 0;
770 if(m_syncing) { 841 if(m_syncing) {
771 QMessageBox::warning(this, QWidget::tr("Todo"), 842 QMessageBox::warning(this, QWidget::tr("Todo"),
772 QWidget::tr("Can not edit data, currently syncing")); 843 QWidget::tr("Data can not be edited, currently syncing"));
773 return uid; 844 return uid;
774 } 845 }
846 m_todoMgr.load();
775 847
776 848
777 OTodo todo = currentEditor()->newTodo( currentCatId(), 849 OTodo todo = currentEditor()->newTodo( currentCatId(),
778 this ); 850 this );
779 851
780 if ( currentEditor()->accepted() ) { 852 if ( currentEditor()->accepted() ) {
781 //todo.assignUid(); 853 //todo.assignUid();
782 uid = todo.uid(); 854 uid = todo.uid();
783 handleAlarms( OTodo(), todo ); 855 handleAlarms( OTodo(), todo );
784 m_todoMgr.add( todo ); 856 m_todoMgr.add( todo );
785 currentView()->addEvent( todo ); 857 currentView()->addEvent( todo );
786 858
787 859
788 // I'm afraid we must call this every time now, otherwise 860 // I'm afraid we must call this every time now, otherwise
789 // spend expensive time comparing all these strings... 861 // spend expensive time comparing all these strings...
790 // but only call if we changed something -zecke 862 // but only call if we changed something -zecke
791 populateCategories(); 863 populateCategories();
792 } 864 }
793 raiseCurrentView( ); 865 raiseCurrentView( );
794 866
795 return uid; 867 return uid;
796} 868}
797/* delete it silently... */ 869/* delete it silently... */
798bool MainWindow::remove( int uid ) { 870bool MainWindow::remove( int uid ) {
799 if (m_syncing) return false; 871 if (m_syncing) return false;
800 872
801 /* argh need to get the whole OEvent... to disable alarms -zecke */ 873 /* argh need to get the whole OEvent... to disable alarms -zecke */
802 handleAlarms( OTodo(), m_todoMgr.event( uid ) ); 874 handleAlarms( OTodo(), m_todoMgr.event( uid ) );
803 875
804 return m_todoMgr.remove( uid ); 876 return m_todoMgr.remove( uid );
805} 877}
806void MainWindow::beam( int uid) { 878void MainWindow::beam( int uid) {
879 if( uid == 0 ) return;
880
807 ::unlink( beamfile ); 881 ::unlink( beamfile );
882 m_todoMgr.load();
883
808 OTodo todo = event( uid ); 884 OTodo todo = event( uid );
809 OTodoAccessVCal* cal = new OTodoAccessVCal(QString::fromLatin1(beamfile) ); 885 OTodoAccessVCal* cal = new OTodoAccessVCal(QString::fromLatin1(beamfile) );
810 OTodoAccess acc( cal ); 886 OTodoAccess acc( cal );
811 acc.load(); 887 acc.load();
812 acc.add( todo ); 888 acc.add( todo );
813 acc.save(); 889 acc.save();
814 Ir* ir = new Ir(this ); 890 Ir* ir = new Ir(this );
815 connect(ir, SIGNAL(done(Ir*) ), 891 connect(ir, SIGNAL(done(Ir*) ),
816 this, SLOT(beamDone(Ir*) ) ); 892 this, SLOT(beamDone(Ir*) ) );
817 ir->send(beamfile, todo.summary(), "text/x-vCalendar" ); 893 ir->send(beamfile, todo.summary(), "text/x-vCalendar" );
818} 894}
819void MainWindow::show( int uid ) { 895void MainWindow::show( int uid ) {
896 m_todoMgr.load(); // might not be loaded yet
897 m_showing = true;
820 slotShow( uid ); 898 slotShow( uid );
899 raise();
900 QPEApplication::setKeepRunning();
821} 901}
822void MainWindow::edit( int uid ) { 902void MainWindow::edit( int uid ) {
903 m_todoMgr.load();
823 slotEdit( uid ); 904 slotEdit( uid );
824} 905}
825void MainWindow::add( const OPimRecord& rec) { 906void MainWindow::add( const OPimRecord& rec) {
826 if ( rec.rtti() != OTodo::rtti() ) return; 907 if ( rec.rtti() != OTodo::rtti() ) return;
908 m_todoMgr.load(); // might not be loaded
827 909
828 const OTodo& todo = static_cast<const OTodo&>(rec); 910 const OTodo& todo = static_cast<const OTodo&>(rec);
829 911
830 m_todoMgr.add(todo ); 912 m_todoMgr.add(todo );
831 currentView()->addEvent( todo ); 913 currentView()->addEvent( todo );
832 914
833 915
834 // I'm afraid we must call this every time now, otherwise 916 // I'm afraid we must call this every time now, otherwise
835 // spend expensive time comparing all these strings... 917 // spend expensive time comparing all these strings...
836 // but only call if we changed something -zecke 918 // but only call if we changed something -zecke
837 populateCategories(); 919 populateCategories();
838} 920}
839void MainWindow::slotReturnFromView() { 921void MainWindow::slotReturnFromView() {
922 m_showing = false;
840 raiseCurrentView(); 923 raiseCurrentView();
841} 924}
842 925
843namespace { 926namespace {
844 OPimNotifyManager::Alarms findNonMatching( const OPimNotifyManager::Alarms& oldAls, 927 OPimNotifyManager::Alarms findNonMatching( const OPimNotifyManager::Alarms& oldAls,
845 const OPimNotifyManager::Alarms& newAls ) { 928 const OPimNotifyManager::Alarms& newAls ) {
846 OPimNotifyManager::Alarms nonMatching; 929 OPimNotifyManager::Alarms nonMatching;
847 OPimNotifyManager::Alarms::ConstIterator oldIt = oldAls.begin(); 930 OPimNotifyManager::Alarms::ConstIterator oldIt = oldAls.begin();
848 OPimNotifyManager::Alarms::ConstIterator newIt; 931 OPimNotifyManager::Alarms::ConstIterator newIt;
849 for ( ; oldIt != oldAls.end(); ++oldIt ) { 932 for ( ; oldIt != oldAls.end(); ++oldIt ) {
850 bool found = false; 933 bool found = false;
851 QDateTime oldDt = (*oldIt).dateTime(); 934 QDateTime oldDt = (*oldIt).dateTime();
852 for (newIt= newAls.begin(); newIt != newAls.end(); ++newIt ) { 935 for (newIt= newAls.begin(); newIt != newAls.end(); ++newIt ) {
853 if ( oldDt == (*newIt).dateTime() ) { 936 if ( oldDt == (*newIt).dateTime() ) {
854 found = true; 937 found = true;
855 break; 938 break;
856 } 939 }
857 } 940 }
858 if (!found) 941 if (!found)
859 nonMatching.append( (*oldIt) ); 942 nonMatching.append( (*oldIt) );
860 } 943 }
861 return nonMatching; 944 return nonMatching;
862 } 945 }
863 void addAlarms( const OPimNotifyManager::Alarms& als, int uid ) { 946 void addAlarms( const OPimNotifyManager::Alarms& als, int uid ) {
864 OPimNotifyManager::Alarms::ConstIterator it; 947 OPimNotifyManager::Alarms::ConstIterator it;
865 for ( it = als.begin(); it != als.end(); ++it ) { 948 for ( it = als.begin(); it != als.end(); ++it ) {
866 qWarning("Adding alarm for %s", (*it).dateTime().toString().latin1() ); 949 qWarning("Adding alarm for %s", (*it).dateTime().toString().latin1() );
867 AlarmServer::addAlarm( (*it).dateTime(), "QPE/Application/todolist", "alarm(QDateTime,int)", uid ); 950 AlarmServer::addAlarm( (*it).dateTime(), "QPE/Application/todolist", "alarm(QDateTime,int)", uid );
868 } 951 }
869 952
870 } 953 }
871 void removeAlarms( const OPimNotifyManager::Alarms& als, int uid ) { 954 void removeAlarms( const OPimNotifyManager::Alarms& als, int uid ) {
872 OPimNotifyManager::Alarms::ConstIterator it; 955 OPimNotifyManager::Alarms::ConstIterator it;
873 for ( it = als.begin(); it != als.end(); ++it ) { 956 for ( it = als.begin(); it != als.end(); ++it ) {
874 qWarning("Removinf alarm for %s", (*it).dateTime().toString().latin1() ); 957 qWarning("Removinf alarm for %s", (*it).dateTime().toString().latin1() );
875 AlarmServer::deleteAlarm( (*it).dateTime(), "QPE/Application/todolist", "alarm(QDateTime,int)", uid ); 958 AlarmServer::deleteAlarm( (*it).dateTime(), "QPE/Application/todolist", "alarm(QDateTime,int)", uid );
876 } 959 }
877 } 960 }
878} 961}
879 962
880void MainWindow::handleAlarms( const OTodo& oldTodo, const OTodo& newTodo) { 963void MainWindow::handleAlarms( const OTodo& oldTodo, const OTodo& newTodo) {
881 /* 964 /*
882 * if oldTodo is not empty and has notifiers we need to find the deleted ones 965 * if oldTodo is not empty and has notifiers we need to find the deleted ones
883 */ 966 */
884 if(!oldTodo.isEmpty() && oldTodo.hasNotifiers() ) { 967 if(!oldTodo.isEmpty() && oldTodo.hasNotifiers() ) {
885 OPimNotifyManager::Alarms removed; 968 OPimNotifyManager::Alarms removed;
886 OPimNotifyManager::Alarms oldAls = oldTodo.notifiers().alarms(); 969 OPimNotifyManager::Alarms oldAls = oldTodo.notifiers().alarms();
887 if (!newTodo.hasNotifiers() ) 970 if (!newTodo.hasNotifiers() )
888 removed = oldAls; 971 removed = oldAls;
889 else 972 else
890 removed = findNonMatching( oldAls, newTodo.notifiers().alarms() ); 973 removed = findNonMatching( oldAls, newTodo.notifiers().alarms() );
891 974
892 removeAlarms( removed, oldTodo.uid() ); 975 removeAlarms( removed, oldTodo.uid() );
893 } 976 }
894 if ( newTodo.hasNotifiers() ) { 977 if ( newTodo.hasNotifiers() ) {
895 OPimNotifyManager::Alarms added; 978 OPimNotifyManager::Alarms added;
896 if ( oldTodo.isEmpty() || !oldTodo.hasNotifiers() ) 979 if ( oldTodo.isEmpty() || !oldTodo.hasNotifiers() )
897 added = newTodo.notifiers().alarms(); 980 added = newTodo.notifiers().alarms();
898 else 981 else
899 added = findNonMatching( newTodo.notifiers().alarms(), oldTodo.notifiers().alarms() ); 982 added = findNonMatching( newTodo.notifiers().alarms(), oldTodo.notifiers().alarms() );
900 983
901 addAlarms( added, newTodo.uid() ); 984 addAlarms( added, newTodo.uid() );
902 } 985 }
903} 986}
904/* we might have not loaded the db */ 987/* we might have not loaded the db */
905void MainWindow::doAlarm( const QDateTime& dt, int uid ) { 988void MainWindow::doAlarm( const QDateTime& dt, int uid ) {
906 m_todoMgr.load(); 989 m_todoMgr.load();
907 990
908 OTodo todo = m_todoMgr.event( uid ); 991 OTodo todo = m_todoMgr.event( uid );
909 if (!todo.hasNotifiers() ) return; 992 if (!todo.hasNotifiers() ) return;
910 993
911 /* 994 /*
912 * let's find the right alarm and find out if silent 995 * let's find the right alarm and find out if silent
913 * then show a richtext widget 996 * then show a richtext widget
914 */ 997 */
915 bool loud = false; 998 bool loud = false;
916 OPimNotifyManager::Alarms als = todo.notifiers().alarms(); 999 OPimNotifyManager::Alarms als = todo.notifiers().alarms();
917 OPimNotifyManager::Alarms::Iterator it; 1000 OPimNotifyManager::Alarms::Iterator it;
918 for ( it = als.begin(); it != als.end(); ++it ) { 1001 for ( it = als.begin(); it != als.end(); ++it ) {
919 if ( (*it).dateTime() == dt ) { 1002 if ( (*it).dateTime() == dt ) {
920 loud = ( (*it).sound() == OPimAlarm::Loud ); 1003 loud = ( (*it).sound() == OPimAlarm::Loud );
921 break; 1004 break;
922 } 1005 }
923 } 1006 }
924 if (loud) 1007 if (loud)
925 startAlarm(); 1008 startAlarm();
926 1009
927 QDialog dlg(this, 0, TRUE ); 1010 QDialog dlg(this, 0, TRUE );
928 QVBoxLayout* lay = new QVBoxLayout( &dlg ); 1011 QVBoxLayout* lay = new QVBoxLayout( &dlg );
929 QTextView* view = new QTextView( &dlg ); 1012 QTextView* view = new QTextView( &dlg );
930 lay->addWidget( view ); 1013 lay->addWidget( view );
931 QPushButton* btnOk = new QPushButton( tr("Ok"), &dlg ); 1014 QPushButton* btnOk = new QPushButton( tr("Ok"), &dlg );
932 connect( btnOk, SIGNAL(clicked() ), &dlg, SLOT(accept() ) ); 1015 connect( btnOk, SIGNAL(clicked() ), &dlg, SLOT(accept() ) );
933 lay->addWidget( btnOk ); 1016 lay->addWidget( btnOk );
934 1017
935 QString text = tr("<h1>Alarm at %0</h1><br>").arg( TimeString::dateString( dt ) ); 1018 QString text = tr("<h1>Alarm at %1</h1><br>").arg( TimeString::dateString( dt ) );
936 text += todo.toRichText(); 1019 text += todo.toRichText();
937 view->setText( text ); 1020 view->setText( text );
938 1021
939 dlg.showMaximized(); 1022 dlg.showMaximized();
940 bool needToStay = dlg.exec(); 1023 bool needToStay = dlg.exec();
941 1024
942 if (loud) 1025 if (loud)
943 killAlarm(); 1026 killAlarm();
944 1027
945 if (needToStay) { 1028 if (needToStay) {
946 showMaximized(); 1029// showMaximized();
947 raise(); 1030// raise();
948 QPEApplication::setKeepRunning(); 1031 QPEApplication::setKeepRunning();
949 setActiveWindow(); 1032// setActiveWindow();
950 } 1033 }
951 1034
952} 1035}
1036
diff --git a/core/pim/todo/mainwindow.h b/core/pim/todo/mainwindow.h
index 02e2449..b04a958 100644
--- a/core/pim/todo/mainwindow.h
+++ b/core/pim/todo/mainwindow.h
@@ -1,204 +1,208 @@
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 33
34#include <opie/otodoaccess.h> 34#include <opie/otodoaccess.h>
35#include <opie/otodo.h> 35#include <opie/otodo.h>
36#include <opie/opimmainwindow.h> 36#include <opie/opimmainwindow.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 "quickedit.h"
41#include "todomanager.h" 41#include "todomanager.h"
42 42
43class QPopupMenu; 43class QPopupMenu;
44class QMenuBar; 44class QMenuBar;
45class QToolBar; 45class QToolBar;
46class QAction; 46class 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 friend class TodoShow; // avoid QObject 63 friend class TodoShow; // avoid QObject
64 public: 64 public:
65 MainWindow( QWidget *parent = 0, 65 MainWindow( QWidget *parent = 0,
66 const char* name = 0 ); 66 const char* name = 0 );
67 ~MainWindow(); 67 ~MainWindow();
68 68
69 /** return a context menu for an OTodo */ 69 /** return a context menu for an OTodo */
70 QPopupMenu* contextMenu(int uid, bool doesRecur = FALSE ); 70 QPopupMenu* contextMenu(int uid, bool doesRecur = FALSE );
71 QPopupMenu* options(); 71 QPopupMenu* options();
72 QPopupMenu* edit(); 72 QPopupMenu* edit();
73 QToolBar* toolbar(); 73 QToolBar* toolbar();
74 74
75 75
76 void updateList(); 76 void updateList();
77 OTodoAccess::List list()const; 77 OTodoAccess::List list()const;
78 OTodoAccess::List sorted( bool asc, int sortOrder ); 78 OTodoAccess::List sorted( bool asc, int sortOrder );
79 OTodoAccess::List sorted( bool asc, int sortOrder, int addFilter ); 79 OTodoAccess::List sorted( bool asc, int sortOrder, int addFilter );
80 80
81 OTodo event(int uid ); 81 OTodo event(int uid );
82 82
83 bool isSyncing()const; 83 bool isSyncing()const;
84 bool showCompleted()const; 84 bool showCompleted()const;
85 bool showDeadline()const; 85 bool showDeadline()const;
86 bool showOverDue()const; 86 bool showOverDue()const;
87 bool showQuickTask()const; 87 bool showQuickTask()const;
88 QString currentCategory()const; 88 QString currentCategory()const;
89 int currentCatId(); 89 int currentCatId();
90 TemplateManager* templateManager(); 90 TemplateManager* templateManager();
91 QuickEditBase* quickEditor(); 91 QuickEditBase* quickEditor();
92 92
93 void updateTodo( const OTodo& ); 93 void updateTodo( const OTodo& );
94 void populateTemplates(); 94 void populateTemplates();
95 Editor* currentEditor(); 95 Editor* currentEditor();
96 void setReadAhead(uint count ); 96 void setReadAhead(uint count );
97private slots: 97private slots:
98 void slotQuickEntered(); 98 void slotQuickEntered();
99 void populateCategories(); 99 void populateCategories();
100 void slotReload(); 100 void slotReload();
101 void slotFlush(); 101 void slotFlush();
102 102
103 protected: 103 protected:
104 void closeEvent( QCloseEvent* e ); 104 void closeEvent( QCloseEvent* e );
105 105
106 private: 106 private:
107 /* handle setting and removing alarms */ 107 /* handle setting and removing alarms */
108 void handleAlarms( const OTodo& oldTodo, const OTodo& newTodo ); 108 void handleAlarms( const OTodo& oldTodo, const OTodo& newTodo );
109 void receiveFile( const QString& filename ); 109 void receiveFile( const QString& filename );
110 void connectBase( ViewBase* ); 110 void connectBase( ViewBase* );
111 void initUI(); 111 void initUI();
112 void initActions(); 112 void initActions();
113 void initConfig(); 113 void initConfig();
114 void initViews(); 114 void initViews();
115 void initEditor(); 115 void initEditor();
116 void initShow(); 116 void initShow();
117 void initTemplate(); 117 void initTemplate();
118 void raiseCurrentView(); 118 void raiseCurrentView();
119 ViewBase* currentView(); 119 ViewBase* currentView();
120 ViewBase* m_curView; 120 ViewBase* m_curView;
121 bool m_showing : 1; // used to see if we show a todo in the cases we shouldn't change the table
121 QuickEditBase* m_curQuick; 122 QuickEditBase* m_curQuick;
122 Editor* m_curEdit; 123 Editor* m_curEdit;
123 TodoShow* currentShow(); 124 TodoShow* currentShow();
124 TodoShow* m_curShow; 125 TodoShow* m_curShow;
125 TemplateEditor* currentTemplateEditor(); 126 TemplateEditor* currentTemplateEditor();
126 TemplateEditor* m_curTempEd; 127 TemplateEditor* m_curTempEd;
127 128
128 QMenuBar* m_bar; 129 QMenuBar* m_bar;
129 QToolBar* m_tool; 130 QToolBar* m_tool;
130 QAction* m_editAction, 131 QAction* m_editAction,
131 *m_deleteAction, 132 *m_deleteAction,
132 *m_findAction, 133 *m_findAction,
133 *m_completedAction, 134 *m_completedAction,
134 *m_showDeadLineAction, 135 *m_showDeadLineAction,
135 *m_deleteAllAction, 136 *m_deleteAllAction,
136 *m_deleteCompleteAction, 137 *m_deleteCompleteAction,
137 *m_duplicateAction, 138 *m_duplicateAction,
138 *m_showOverDueAction, 139 *m_showOverDueAction,
139 *m_showQuickTaskAction, 140 *m_showQuickTaskAction,
140 *m_effectiveAction; 141 *m_effectiveAction;
141 QWidgetStack *m_stack; 142 QWidgetStack *m_stack;
142 QPopupMenu* m_catMenu, 143 QPopupMenu* m_catMenu,
143 *m_edit, 144 *m_edit,
144 *m_options, 145 *m_options,
145 *m_template; 146 *m_template;
146 147
147 bool m_syncing:1; 148 bool m_syncing:1;
148 bool m_deadline:1; 149 bool m_deadline:1;
149 bool m_completed:1; 150 bool m_completed:1;
150 bool m_overdue:1; 151 bool m_overdue:1;
151 bool m_quicktask:1; 152 bool m_quicktask:1;
152 TodoManager m_todoMgr; 153 TodoManager m_todoMgr;
153 QString m_curCat; 154 QString m_curCat;
154 QList<ViewBase> m_views; 155 QList<ViewBase> m_views;
155 uint m_counter; 156 uint m_counter;
156 TemplateManager* m_tempManager; 157 TemplateManager* m_tempManager;
157 158
158 159
159 private slots: 160 private slots:
160 void slotShow(int); 161 void slotShow(int);
161 void slotEdit(int); 162 void slotEdit(int);
162 void slotUpdate3( QWidget* ); 163 void slotUpdate3( QWidget* );
163 void slotComplete( int uid ); 164 void slotComplete( int uid );
164 void slotComplete( const OTodo& ev ); 165 void slotComplete( const OTodo& ev );
165 void slotNewFromTemplate(int id ); 166 void slotNewFromTemplate(int id );
166 void slotNew(); 167 void slotNew();
167 void slotDuplicate(); 168 void slotDuplicate();
168 169
169 void slotDelete(); 170 void slotDelete();
171 void slotDelete(int uid );
170 void slotDeleteAll(); 172 void slotDeleteAll();
171 void slotDeleteCompleted(); 173 void slotDeleteCompleted();
172 174
173 void slotEdit(); 175 void slotEdit();
174 void slotFind(); 176 void slotFind();
175 177
176 void setCategory( int ); 178 void setCategory( int );
177 179
178 void slotShowDeadLine( bool ); 180 void slotShowDeadLine( bool );
179 void slotShowCompleted( bool ); 181 void slotShowCompleted( bool );
180 void slotShowQuickTask( bool ); 182 void slotShowQuickTask( bool );
181 183
182 void setDocument( const QString& ); 184 void setDocument( const QString& );
183 185
184 186
185 void slotBeam(); 187 void slotBeam();
186 void beamDone( Ir* ); 188 void beamDone( Ir* );
187 void slotShowDetails(); 189 void slotShowDetails();
190 void slotShowNext();
191 void slotShowPrev();
188 void slotShowDue( bool ); 192 void slotShowDue( bool );
189 void slotReturnFromView(); // for TodoShow... 193 void slotReturnFromView(); // for TodoShow...
190 /* reimplementation from opimmainwindow */ 194 /* reimplementation from opimmainwindow */
191 protected slots: 195 protected slots:
192 void flush(); 196 void flush();
193 void reload(); 197 void reload();
194 int create(); 198 int create();
195 bool remove( int uid ); 199 bool remove( int uid );
196 void beam(int uid); 200 void beam(int uid);
197 void show( int uid ); 201 void show( int uid );
198 void edit( int uid ); 202 void edit( int uid );
199 void add( const OPimRecord& ); 203 void add( const OPimRecord& );
200 void doAlarm( const QDateTime& dt, int uid ); 204 void doAlarm( const QDateTime& dt, int uid );
201 }; 205 };
202} 206}
203 207
204#endif 208#endif
diff --git a/core/pim/todo/opie-todo.control b/core/pim/todo/opie-todo.control
index b579306..17a65a8 100644
--- a/core/pim/todo/opie-todo.control
+++ b/core/pim/todo/opie-todo.control
@@ -1,10 +1,10 @@
1Package: opie-todo 1Package: opie-todo
2Files: bin/todolist apps/1Pim/todo.desktop pics/todo 2Files: bin/todolist apps/1Pim/todo.desktop
3Priority: optional 3Priority: optional
4Section: opie/applications 4Section: opie/applications
5Maintainer: Holger 'zecke' Freyther <zecke@handhelds.org> 5Maintainer: Holger 'zecke' Freyther <zecke@handhelds.org>
6Architecture: arm 6Architecture: arm
7Version: $QPE_VERSION-$SUB_VERSION 7Depends: task-opie-minimal, libopie1, opie-pics
8Depends: task-opie-minimal, libopie1
9Description: TODO-list manager 8Description: TODO-list manager
10 A Todo-list manager for the Opie environment. 9 A Todo-list manager for the Opie environment.
10Version: $QPE_VERSION$EXTRAVERSION
diff --git a/core/pim/todo/otaskeditor.cpp b/core/pim/todo/otaskeditor.cpp
index 84f854f..1ed20b4 100644
--- a/core/pim/todo/otaskeditor.cpp
+++ b/core/pim/todo/otaskeditor.cpp
@@ -1,96 +1,92 @@
1#include <qdatetime.h>
2#include <qlabel.h>
3#include <qlayout.h> 1#include <qlayout.h>
4#include <qmultilineedit.h>
5 2
6#include <opie/orecurrancewidget.h> 3#include <opie/orecurrancewidget.h>
7 4
8#include "taskeditoroverview.h" 5#include "taskeditoroverview.h"
9#include "taskeditorstatus.h" 6#include "taskeditorstatus.h"
10#include "taskeditoralarms.h" 7#include "taskeditoralarms.h"
11 8
12#include "otaskeditor.h" 9#include "otaskeditor.h"
13 10
14OTaskEditor::OTaskEditor(int cur) 11OTaskEditor::OTaskEditor(int cur)
15 : QDialog( 0, 0, TRUE, WStyle_ContextHelp ) { 12 : QDialog( 0, 0, TRUE, WStyle_ContextHelp ) {
16 init(); 13 init();
17 init( cur ); 14 init( cur );
18} 15}
19OTaskEditor::OTaskEditor( const OTodo& to) 16OTaskEditor::OTaskEditor( const OTodo& to)
20 : QDialog( 0, 0, TRUE, WStyle_ContextHelp ) { 17 : QDialog( 0, 0, TRUE, WStyle_ContextHelp ) {
21 init(); 18 init();
22 init( to ); 19 init( to );
23} 20}
24OTaskEditor::~OTaskEditor() { 21OTaskEditor::~OTaskEditor() {
25 22
26} 23}
27void OTaskEditor::init( int cur ) { 24void OTaskEditor::init( int cur ) {
28 OTodo to; 25 OTodo to;
26 to.setUid( 1 ); // generate a new uid
29 if ( cur != 0 ) 27 if ( cur != 0 )
30 to.setCategories( cur ); 28 to.setCategories( cur );
31 load(to); 29 load(to);
32 m_uid = 1; // generate a new one
33} 30}
34void OTaskEditor::init( const OTodo& to ) { 31void OTaskEditor::init( const OTodo& to ) {
35 load( to ); 32 load( to );
36 m_uid = to.uid();
37} 33}
38OTodo OTaskEditor::todo()const{ 34OTodo OTaskEditor::todo()const{
39 qWarning("saving!"); 35 qWarning("saving!");
40 OTodo to; 36 OTodo to ( m_todo );
41 to.setUid(m_uid );
42 m_overView->save( to ); 37 m_overView->save( to );
43 m_stat->save( to ); 38 m_stat->save( to );
44 to.setRecurrence( m_rec->recurrence() ); 39 to.setRecurrence( m_rec->recurrence() );
45 m_alarm->save( to ); 40 m_alarm->save( to );
46 41
47 return to; 42 return to;
48} 43}
49void OTaskEditor::load(const OTodo& to) { 44void OTaskEditor::load(const OTodo& to) {
50 m_overView->load( to ); 45 m_overView->load( to );
51 m_stat->load( to ); 46 m_stat->load( to );
52 m_rec->setRecurrence( to.recurrence(), to.hasDueDate() ? to.dueDate() : QDate::currentDate() ); 47 m_rec->setRecurrence( to.recurrence(), to.hasDueDate() ? to.dueDate() : QDate::currentDate() );
53 m_alarm->setEnabled( !to.hasRecurrence() );
54 m_alarm->load( to ); 48 m_alarm->load( to );
49
50 m_todo = to;
55} 51}
56void OTaskEditor::init() { 52void OTaskEditor::init() {
57 setCaption("Task Editor"); 53 setCaption(tr("Task Editor") );
58 54
59 QVBoxLayout* layo = new QVBoxLayout( this ); 55 QVBoxLayout* layo = new QVBoxLayout( this );
60 m_tab = new OTabWidget( this ); 56 m_tab = new OTabWidget( this );
61 layo->addWidget( m_tab ); 57 layo->addWidget( m_tab );
62 58
63 /* 59 /*
64 * Add the Widgets 60 * Add the Widgets
65 */ 61 */
66 m_overView = new TaskEditorOverView( m_tab ); 62 m_overView = new TaskEditorOverView( m_tab );
67 m_tab->addTab( m_overView, "todo/info", tr("Information") ); 63 m_tab->addTab( m_overView, "todo/info", tr("Information") );
68 64
69 m_stat = new TaskEditorStatus( m_tab ); 65 m_stat = new TaskEditorStatus( m_tab );
70 m_tab->addTab( m_stat, "todo/TodoList", tr("Status") ); 66 m_tab->addTab( m_stat, "todo/TodoList", tr("Status") );
71 67
72 m_alarm = new TaskEditorAlarms( m_tab ); 68 m_alarm = new TaskEditorAlarms( m_tab );
73 m_tab->addTab( m_alarm, "todo/alarm", tr("Alarms") ); 69 m_tab->addTab( m_alarm, "todo/alarm", tr("Alarms") );
74 70
75// m_remind = new TaskEditorAlarms( m_tab ); 71// m_remind = new TaskEditorAlarms( m_tab );
76// m_tab->addTab( m_remind, "todo/reminder", tr("Reminders") ); 72// m_tab->addTab( m_remind, "todo/reminder", tr("Reminders") );
77 73
78// QLabel* lbl = new QLabel( m_tab ); 74// QLabel* lbl = new QLabel( m_tab );
79// lbl->setText( tr("X-Ref") ); 75// lbl->setText( tr("X-Ref") );
80// m_tab->addTab( lbl, "todo/xref", tr("X-Ref") ); 76// m_tab->addTab( lbl, "todo/xref", tr("X-Ref") );
81 77
82 m_rec = new ORecurranceWidget( true, QDate::currentDate(), this ); 78 m_rec = new ORecurranceWidget( true, QDate::currentDate(), this );
83 m_tab->addTab( m_rec, "repeat", tr("Recurrence") ); 79 m_tab->addTab( m_rec, "repeat", tr("Recurrence") );
84 80
85 81
86 /* signal and slots */ 82 /* signal and slots */
87 connect(m_overView, SIGNAL(recurranceEnabled(bool) ), 83 connect(m_overView, SIGNAL(recurranceEnabled(bool) ),
88 m_rec, SLOT(setEnabled(bool) ) ); 84 m_rec, SLOT(setEnabled(bool) ) );
89 85
90 /* connect due date changed to the recurrence tab */ 86 /* connect due date changed to the recurrence tab */
91 connect(m_stat, SIGNAL(dueDateChanged(const QDate&) ), 87 connect(m_stat, SIGNAL(dueDateChanged(const QDate&) ),
92 m_rec, SLOT(setStartDate(const QDate& ) ) ); 88 m_rec, SLOT(setStartDate(const QDate& ) ) );
93 89
94 90
95 m_tab->setCurrentTab( m_overView ); 91 m_tab->setCurrentTab( m_overView );
96} 92}
diff --git a/core/pim/todo/otaskeditor.h b/core/pim/todo/otaskeditor.h
index 795f333..2daae52 100644
--- a/core/pim/todo/otaskeditor.h
+++ b/core/pim/todo/otaskeditor.h
@@ -1,44 +1,43 @@
1#ifndef OPIE_TASK_EDITOR_H 1#ifndef OPIE_TASK_EDITOR_H
2#define OPIE_TASK_EDITOR_H 2#define OPIE_TASK_EDITOR_H
3 3
4#include <qdialog.h> 4#include <qdialog.h>
5 5
6#include <opie/otodo.h> 6#include <opie/otodo.h>
7#include <opie/otabwidget.h> 7#include <opie/otabwidget.h>
8 8
9class TaskEditorOverView; 9class TaskEditorOverView;
10class TaskEditorStatus; 10class TaskEditorStatus;
11class TaskEditorAlarms; 11class TaskEditorAlarms;
12class ORecurranceWidget; 12class ORecurranceWidget;
13class QMultiLineEdit; 13class QMultiLineEdit;
14 14
15class OTaskEditor : public QDialog { 15class OTaskEditor : public QDialog {
16 Q_OBJECT 16 Q_OBJECT
17public: 17public:
18 OTaskEditor(int cur); 18 OTaskEditor(int cur);
19 OTaskEditor( const OTodo& todo ); 19 OTaskEditor( const OTodo& todo );
20 ~OTaskEditor(); 20 ~OTaskEditor();
21 21
22 /* 22 /*
23 * same as the c'tor but this gives us the 23 * same as the c'tor but this gives us the
24 * power to 'preload' the dialog 24 * power to 'preload' the dialog
25 */ 25 */
26 void init( int cur ); 26 void init( int cur );
27 void init( const OTodo& todo ); 27 void init( const OTodo& todo );
28 28
29 OTodo todo()const; 29 OTodo todo()const;
30private: 30private:
31 void load( const OTodo& ); 31 void load( const OTodo& );
32 void init(); 32 void init();
33 33
34 OTabWidget *m_tab; 34 OTabWidget *m_tab;
35 TaskEditorOverView *m_overView; 35 TaskEditorOverView *m_overView;
36 TaskEditorStatus *m_stat; 36 TaskEditorStatus *m_stat;
37 TaskEditorAlarms *m_alarm; 37 TaskEditorAlarms *m_alarm;
38 TaskEditorAlarms *m_remind; 38 TaskEditorAlarms *m_remind;
39 ORecurranceWidget *m_rec; 39 ORecurranceWidget *m_rec;
40 int m_uid; 40 OTodo m_todo;
41
42}; 41};
43 42
44#endif 43#endif
diff --git a/core/pim/todo/quickedit.cpp b/core/pim/todo/quickedit.cpp
index edcd48a..16fc53a 100644
--- a/core/pim/todo/quickedit.cpp
+++ b/core/pim/todo/quickedit.cpp
@@ -1,22 +1,21 @@
1#include "mainwindow.h"
2#include "quickedit.h" 1#include "quickedit.h"
3 2
4using namespace Todo; 3using namespace Todo;
5 4
6// not so interesting part base Implementation 5// not so interesting part base Implementation
7QuickEdit::QuickEdit(MainWindow* main ) 6QuickEdit::QuickEdit(MainWindow* main )
8 : m_main( main ) { 7 : m_main( main ) {
9 m_sig = new QSignal(); 8 m_sig = new QSignal();
10} 9}
11QuickEdit::~QuickEdit() { 10QuickEdit::~QuickEdit() {
12 delete m_sig; 11 delete m_sig;
13} 12}
14QSignal* QuickEdit::signal() { 13QSignal* QuickEdit::signal() {
15 return m_sig; 14 return m_sig;
16} 15}
17MainWindow* QuickEdit::mainWindow() { 16MainWindow* QuickEdit::mainWindow() {
18 return m_main; 17 return m_main;
19} 18}
20void QuickEdit::commit() { 19void QuickEdit::commit() {
21 m_sig->activate(); 20 m_sig->activate();
22} 21}
diff --git a/core/pim/todo/quickeditimpl.cpp b/core/pim/todo/quickeditimpl.cpp
index f4c7c47..70e0582 100644
--- a/core/pim/todo/quickeditimpl.cpp
+++ b/core/pim/todo/quickeditimpl.cpp
@@ -1,111 +1,116 @@
1#include <qaction.h> 1#include <qaction.h>
2#include <qlineedit.h> 2#include <qlineedit.h>
3#include <qwhatsthis.h> 3#include <qwhatsthis.h>
4 4
5#include <qpe/resource.h> 5#include <qpe/resource.h>
6 6
7#include <opie/oclickablelabel.h> 7#include <opie/oclickablelabel.h>
8 8
9#include "mainwindow.h" 9#include "mainwindow.h"
10#include "quickeditimpl.h" 10#include "quickeditimpl.h"
11 11
12 12
13QuickEditImpl::QuickEditImpl( QWidget* parent, bool visible ) 13QuickEditImpl::QuickEditImpl( QWidget* parent, bool visible )
14 : QPEToolBar( (QMainWindow *)parent ), Todo::QuickEdit( (Todo::MainWindow *)parent ) { 14 : QPEToolBar( (QMainWindow *)parent ), Todo::QuickEdit( (Todo::MainWindow *)parent ) {
15 setHorizontalStretchable( TRUE ); 15 setHorizontalStretchable( TRUE );
16 16
17 // Load priority icons 17 // Load priority icons
18 // TODO - probably should be done globally somewhere else, 18 // TODO - probably should be done globally somewhere else,
19 // see also tableview.cpp/h, taskeditoroverview.cpp/h 19 // see also tableview.cpp/h, taskeditoroverview.cpp/h
20 priority1 = Resource::loadPixmap( "todo/priority1" ); 20 priority1 = Resource::loadPixmap( "todo/priority1" );
21 priority3 = Resource::loadPixmap( "todo/priority3" ); 21 priority3 = Resource::loadPixmap( "todo/priority3" );
22 priority5 = Resource::loadPixmap( "todo/priority5" ); 22 priority5 = Resource::loadPixmap( "todo/priority5" );
23 23
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 QWhatsThis::add( m_lbl, QWidget::tr( "Click here to set the priority of new task.\n\nThis area is called the quick task bar.\n\nIt allows you to quickly add a new task to your list. This area can be shown or hidden by selecting Options->'Show quick task bar' from the menu above." ) ); 28 QWhatsThis::add( m_lbl, QWidget::tr( "Click here to set the priority of new task.\n\nThis area is called the quick task bar.\n\nIt allows you to quickly add a new task to your list. This area can be shown or hidden by selecting Options->'Show quick task bar' from the menu above." ) );
29 29
30 m_edit = new QLineEdit( this ); 30 m_edit = new QLineEdit( this );
31 setStretchableWidget( m_edit ); 31 setStretchableWidget( m_edit );
32 QWhatsThis::add( m_edit, QWidget::tr( "Enter description of new task here.\n\nThis area is called the quick task bar.\n\nIt allows you to quickly add a new task to your list. This area can be shown or hidden by selecting Options->'Show quick task bar' from the menu above." ) ); 32 QWhatsThis::add( m_edit, QWidget::tr( "Enter description of new task here.\n\nThis area is called the quick task bar.\n\nIt allows you to quickly add a new task to your list. This area can be shown or hidden by selecting Options->'Show quick task bar' from the menu above." ) );
33 33
34 /*
35 * it's not implemented and won't be implemented for 1.0
36 */
37#if 0
34 QAction *a = new QAction( QWidget::tr( "More" ), Resource::loadPixmap( "todo/more" ), QString::null, 0, this, 0 ); 38 QAction *a = new QAction( QWidget::tr( "More" ), Resource::loadPixmap( "todo/more" ), QString::null, 0, this, 0 );
35 connect( a, SIGNAL( activated() ), this, SLOT( slotMore() ) ); 39 connect( a, SIGNAL( activated() ), this, SLOT( slotMore() ) );
36 a->addTo( this ); 40 a->addTo( this );
37 a->setWhatsThis( QWidget::tr( "Click here to enter additional information for new task.\n\nThis area is called the quick task bar.\n\nIt allows you to quickly add a new task to your list. This area can be shown or hidden by selecting Options->'Show quick task bar' from the menu above." ) ); 41 a->setWhatsThis( QWidget::tr( "Click here to enter additional information for new task.\n\nThis area is called the quick task bar.\n\nIt allows you to quickly add a new task to your list. This area can be shown or hidden by selecting Options->'Show quick task bar' from the menu above." ) );
42#endif
38 43
39 a = new QAction( QWidget::tr( "Enter" ), Resource::loadPixmap( "enter" ), QString::null, 0, this, 0 ); 44 QAction *a = new QAction( QWidget::tr( "Enter" ), Resource::loadPixmap( "enter" ), QString::null, 0, this, 0 );
40 connect( a, SIGNAL( activated() ), this, SLOT( slotEnter() ) ); 45 connect( a, SIGNAL( activated() ), this, SLOT( slotEnter() ) );
41 a->addTo( this ); 46 a->addTo( this );
42 a->setWhatsThis( QWidget::tr( "Click here to add new task.\n\nThis area is called the quick task bar.\n\nIt allows you to quickly add a new task to your list. This area can be shown or hidden by selecting Options->'Show quick task bar' from the menu above." ) ); 47 a->setWhatsThis( QWidget::tr( "Click here to add new task.\n\nThis area is called the quick task bar.\n\nIt allows you to quickly add a new task to your list. This area can be shown or hidden by selecting Options->'Show quick task bar' from the menu above." ) );
43 48
44 a = new QAction( QWidget::tr( "Cancel" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); 49 a = new QAction( QWidget::tr( "Cancel" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 );
45 connect( a, SIGNAL( activated() ), this, SLOT( slotCancel() ) ); 50 connect( a, SIGNAL( activated() ), this, SLOT( slotCancel() ) );
46 a->addTo( this ); 51 a->addTo( this );
47 a->setWhatsThis( QWidget::tr( "Click here to reset new task information.\n\nThis area is called the quick task bar.\n\nIt allows you to quickly add a new task to your list. This area can be shown or hidden by selecting Options->'Show quick task bar' from the menu above." ) ); 52 a->setWhatsThis( QWidget::tr( "Click here to reset new task information.\n\nThis area is called the quick task bar.\n\nIt allows you to quickly add a new task to your list. This area can be shown or hidden by selecting Options->'Show quick task bar' from the menu above." ) );
48 53
49 m_visible = visible; 54 m_visible = visible;
50 if ( !m_visible ) { 55 if ( !m_visible ) {
51 hide(); 56 hide();
52 } 57 }
53 58
54 m_menu = 0l; 59 m_menu = 0l;
55 reinit(); 60 reinit();
56} 61}
57QuickEditImpl::~QuickEditImpl() { 62QuickEditImpl::~QuickEditImpl() {
58 63
59} 64}
60OTodo QuickEditImpl::todo()const { 65OTodo QuickEditImpl::todo()const {
61 return m_todo; 66 return m_todo;
62} 67}
63QWidget* QuickEditImpl::widget() { 68QWidget* QuickEditImpl::widget() {
64 return this; 69 return this;
65} 70}
66void QuickEditImpl::slotEnter() { 71void QuickEditImpl::slotEnter() {
67 OTodo todo; 72 OTodo todo;
68 73
69 74
70 if (!m_edit->text().isEmpty() ) { 75 if (!m_edit->text().isEmpty() ) {
71 todo.setUid(1 ); // new uid 76 todo.setUid(1 ); // new uid
72 todo.setPriority( m_state ); 77 todo.setPriority( m_state );
73 todo.setSummary( m_edit->text() ); 78 todo.setSummary( m_edit->text() );
74 if ( ((Todo::MainWindow *)parent())->currentCatId() != 0 ) 79 if ( ((Todo::MainWindow *)parent())->currentCatId() != 0 )
75 todo.setCategories( ((Todo::MainWindow *)parent())->currentCatId() ); 80 todo.setCategories( ((Todo::MainWindow *)parent())->currentCatId() );
76 81
77 m_todo = todo; 82 m_todo = todo;
78 commit(); 83 commit();
79 } 84 }
80 m_todo = todo; 85 m_todo = todo;
81 reinit(); 86 reinit();
82} 87}
83void QuickEditImpl::slotPrio() { 88void QuickEditImpl::slotPrio() {
84 m_state -= 2; 89 m_state -= 2;
85 if ( m_state < 1 ) 90 if ( m_state < 1 )
86 m_state = 5; 91 m_state = 5;
87 92
88 switch( m_state ) { 93 switch( m_state ) {
89 case 1: 94 case 1:
90 m_lbl->setPixmap( priority1 ); 95 m_lbl->setPixmap( priority1 );
91 break; 96 break;
92 case 5: 97 case 5:
93 m_lbl->setPixmap( priority5 ); 98 m_lbl->setPixmap( priority5 );
94 break; 99 break;
95 case 3: 100 case 3:
96 default: 101 default:
97 m_lbl->setPixmap( priority3 ); 102 m_lbl->setPixmap( priority3 );
98 break; 103 break;
99 } 104 }
100} 105}
101void QuickEditImpl::slotMore() { 106void QuickEditImpl::slotMore() {
102 // TODO - implement 107 // TODO - implement
103} 108}
104void QuickEditImpl::slotCancel() { 109void QuickEditImpl::slotCancel() {
105 reinit(); 110 reinit();
106} 111}
107void QuickEditImpl::reinit() { 112void QuickEditImpl::reinit() {
108 m_state = 3; 113 m_state = 3;
109 m_lbl->setPixmap( priority3 ); 114 m_lbl->setPixmap( priority3 );
110 m_edit->clear(); 115 m_edit->clear();
111} 116}
diff --git a/core/pim/todo/smalltodo.cpp b/core/pim/todo/smalltodo.cpp
index 412fe9e..504256d 100644
--- a/core/pim/todo/smalltodo.cpp
+++ b/core/pim/todo/smalltodo.cpp
@@ -1,114 +1,113 @@
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@handhelds.org> 3             .=l. Copyright (c) 2002 <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#include <qshared.h>
29 28
30#include "smalltodo.h" 29#include "smalltodo.h"
31 30
32using namespace Todo; 31using namespace Todo;
33 32
34struct SmallTodo::SmallTodoPrivate : public QShared{ 33struct SmallTodo::SmallTodoPrivate : public QShared{
35 34
36 SmallTodoPrivate() : QShared(), uid(-1) {}; 35 SmallTodoPrivate() : QShared(), uid(-1) {};
37 QString name; 36 QString name;
38 QStringList categories; // as real Names 37 QStringList categories; // as real Names
39 int uid; 38 int uid;
40 bool complete:1; 39 bool complete:1;
41 QDate date; 40 QDate date;
42 41
43 42
44 void deleteSelf() { delete this; }; 43 void deleteSelf() { delete this; };
45}; 44};
46 45
47SmallTodo::SmallTodo(int uid, 46SmallTodo::SmallTodo(int uid,
48 bool comp, 47 bool comp,
49 const QDate& date, 48 const QDate& date,
50 const QString& name, 49 const QString& name,
51 const QStringList& cats) { 50 const QStringList& cats) {
52 d = new SmallTodoPrivate(); 51 d = new SmallTodoPrivate();
53 d->name = name; 52 d->name = name;
54 d->uid = uid; 53 d->uid = uid;
55 d->categories = cats; 54 d->categories = cats;
56 d->complete = comp; 55 d->complete = comp;
57 d->date = date; 56 d->date = date;
58} 57}
59SmallTodo::SmallTodo( const SmallTodo& s ) : d(s.d) { 58SmallTodo::SmallTodo( const SmallTodo& s ) : d(s.d) {
60 d->ref(); 59 d->ref();
61} 60}
62SmallTodo::~SmallTodo() { 61SmallTodo::~SmallTodo() {
63 /* deref and if last one delete */ 62 /* deref and if last one delete */
64 if ( d->deref() ) { 63 if ( d->deref() ) {
65 d->deleteSelf(); 64 d->deleteSelf();
66 } 65 }
67} 66}
68bool SmallTodo::operator==( const SmallTodo& todo ) { 67bool SmallTodo::operator==( const SmallTodo& todo ) {
69 if ( d->complete != todo.d->complete ) return false; 68 if ( d->complete != todo.d->complete ) return false;
70 if ( d->name != todo.d->name ) return false; 69 if ( d->name != todo.d->name ) return false;
71 if ( d->uid != todo.d->uid ) return false; 70 if ( d->uid != todo.d->uid ) return false;
72 if ( d->categories != todo.d->categories ) return false; 71 if ( d->categories != todo.d->categories ) return false;
73 if ( d->date != todo.d->date ) return false; 72 if ( d->date != todo.d->date ) return false;
74 73
75 return true; 74 return true;
76} 75}
77bool SmallTodo::operator==( const SmallTodo& todo ) const{ 76bool SmallTodo::operator==( const SmallTodo& todo ) const{
78 if ( d->complete != todo.d->complete ) return false; 77 if ( d->complete != todo.d->complete ) return false;
79 if ( d->uid != todo.d->uid ) return false; 78 if ( d->uid != todo.d->uid ) return false;
80 if ( d->name != todo.d->name ) return false; 79 if ( d->name != todo.d->name ) return false;
81 if ( d->categories != todo.d->categories ) return false; 80 if ( d->categories != todo.d->categories ) return false;
82 if ( d->date != todo.d->date ) return false; 81 if ( d->date != todo.d->date ) return false;
83 82
84 return true; 83 return true;
85} 84}
86SmallTodo &SmallTodo::operator=( const SmallTodo& todo ) { 85SmallTodo &SmallTodo::operator=( const SmallTodo& todo ) {
87 todo.d->ref(); 86 todo.d->ref();
88 deref(); 87 deref();
89 88
90 d = todo.d; 89 d = todo.d;
91 90
92 return *this; 91 return *this;
93} 92}
94void SmallTodo::deref() { 93void SmallTodo::deref() {
95 if ( d->deref() ) { 94 if ( d->deref() ) {
96 delete d; 95 delete d;
97 d = 0; 96 d = 0;
98 } 97 }
99} 98}
100QString SmallTodo::name() const { 99QString SmallTodo::name() const {
101 return d->name; 100 return d->name;
102} 101}
103QStringList SmallTodo::categories()const { 102QStringList SmallTodo::categories()const {
104 return d->categories; 103 return d->categories;
105} 104}
106int SmallTodo::uid()const { 105int SmallTodo::uid()const {
107 return d->uid; 106 return d->uid;
108} 107}
109bool SmallTodo::isCompleted()const { 108bool SmallTodo::isCompleted()const {
110 return d->complete; 109 return d->complete;
111} 110}
112QDate SmallTodo::date()const { 111QDate SmallTodo::date()const {
113 return d->date; 112 return d->date;
114} 113}
diff --git a/core/pim/todo/tableview.cpp b/core/pim/todo/tableview.cpp
index d9cda09..2e252d5 100644
--- a/core/pim/todo/tableview.cpp
+++ b/core/pim/todo/tableview.cpp
@@ -1,554 +1,628 @@
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#include <cctype>
30 31
31#include <qcombobox.h> 32#include <qcombobox.h>
32#include <qlineedit.h> 33#include <qlineedit.h>
33#include <qtimer.h> 34#include <qtimer.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#include <qpe/resource.h>
39 39
40#include <opie/orecur.h> 40#include <opie/orecur.h>
41 41
42#include "mainwindow.h" 42#include "mainwindow.h"
43//#include "tableitems.h" 43//#include "tableitems.h"
44#include "tableview.h" 44#include "tableview.h"
45 45
46using namespace Todo; 46using namespace Todo;
47 47
48namespace { 48namespace {
49 static const int BoxSize = 14; 49 static const int BoxSize = 14;
50 static const int RowHeight = 20; 50 static const int RowHeight = 20;
51} 51}
52 52
53TableView::EditorWidget::EditorWidget() : m_wid(0l), m_row(-1), m_col(-1) {
54}
55void TableView::EditorWidget::setCellWidget(QWidget* wid, int row, int col ) {
56 m_wid = wid;
57 m_row = row;
58 m_col = col;
59}
60void TableView::EditorWidget::releaseCellWidget() {
61 m_wid = 0;
62 m_row = m_col = -1;
63}
64QWidget* TableView::EditorWidget::cellWidget()const {
65 return m_wid;
66}
67int TableView::EditorWidget::cellRow()const {
68 return m_row;
69}
70int TableView::EditorWidget::cellCol()const {
71 return m_col;
72}
73
53 74
54void TableView::initConfig() { 75void TableView::initConfig() {
55 Config config( "todo" ); 76 Config config( "todo" );
56 config.setGroup( "Options" ); 77 config.setGroup( "Options" );
57 m_completeStrokeWidth = config.readNumEntry( "CompleteStrokeWidth", 8 ); 78 m_completeStrokeWidth = config.readNumEntry( "CompleteStrokeWidth", 8 );
58 for (int i = 0; i < numCols(); i++ ) { 79 for (int i = 0; i < numCols(); i++ ) {
59 int width = config.readNumEntry("Width"+QString::number(i), -1 ); 80 int width = config.readNumEntry("Width"+QString::number(i), -1 );
60 setColumnWidth(i, width == -1 ? columnWidth(i) : width ); 81 setColumnWidth(i, width == -1 ? columnWidth(i) : width );
61 } 82 }
62} 83}
63 84
64TableView::TableView( MainWindow* window, QWidget* wid ) 85TableView::TableView( MainWindow* window, QWidget* wid )
65 : QTable( wid ), TodoView( window ) { 86 : QTable( wid ), TodoView( window ) {
66 87
67 // Load icons 88 // Load icons
68 // TODO - probably should be done globally somewhere else, 89 // TODO - probably should be done globally somewhere else,
69 // see also quickeditimpl.cpp/h, taskeditoroverview.cpp/h 90 // see also quickeditimpl.cpp/h, taskeditoroverview.cpp/h
70 m_pic_completed = Resource::loadPixmap( "todo/completed" ); 91 m_pic_completed = Resource::loadPixmap( "todo/completed" );
71 QString namestr; 92 QString namestr;
72 for ( unsigned int i = 1; i < 6; i++ ) { 93 for ( unsigned int i = 1; i < 6; i++ ) {
73 namestr = "todo/priority"; 94 namestr = "todo/priority";
74 namestr.append( QString::number( i ) ); 95 namestr.append( QString::number( i ) );
75 m_pic_priority[ i - 1 ] = Resource::loadPixmap( namestr ); 96 m_pic_priority[ i - 1 ] = Resource::loadPixmap( namestr );
76 } 97 }
77 98
78 setUpdatesEnabled( false ); 99 setUpdatesEnabled( false );
79 viewport()->setUpdatesEnabled( false ); 100 viewport()->setUpdatesEnabled( false );
80 m_enablePaint = false; 101 m_enablePaint = false;
81 setNumRows(0); 102 setNumRows(0);
82 setNumCols(4); 103 setNumCols(4);
83 104
84 horizontalHeader()->setLabel( 0, QWidget::tr("C.") ); 105 horizontalHeader()->setLabel( 0, QWidget::tr("C.") );
85 horizontalHeader()->setLabel( 1, QWidget::tr("Priority") ); 106 horizontalHeader()->setLabel( 1, QWidget::tr("Priority") );
86 horizontalHeader()->setLabel( 2, QWidget::tr("Description" ) ); 107 horizontalHeader()->setLabel( 2, QWidget::tr("Description" ) );
87 horizontalHeader()->setLabel( 3, QWidget::tr("Deadline") ); 108 horizontalHeader()->setLabel( 3, QWidget::tr("Deadline") );
88 109
89 setShowDeadline( todoWindow()->showDeadline() ); 110 setShowDeadline( todoWindow()->showDeadline() );
90 111
91 setSorting( TRUE ); 112 setSorting( TRUE );
92 setSelectionMode( NoSelection ); 113 setSelectionMode( NoSelection );
93 114
94 setLeftMargin( 0 ); 115 setLeftMargin( 0 );
95 verticalHeader()->hide(); 116 verticalHeader()->hide();
96 117
97 connect((QTable*)this, SIGNAL( clicked( int, int, int, const QPoint& ) ), 118 connect((QTable*)this, SIGNAL( clicked( int, int, int, const QPoint& ) ),
98 this, SLOT( slotClicked(int, int, int, const QPoint& ) ) ); 119 this, SLOT( slotClicked(int, int, int, const QPoint& ) ) );
99 connect((QTable*)this, SIGNAL( pressed( int, int, int, const QPoint& ) ), 120 connect((QTable*)this, SIGNAL( pressed( int, int, int, const QPoint& ) ),
100 this, SLOT( slotPressed(int, int, int, const QPoint& ) ) ); 121 this, SLOT( slotPressed(int, int, int, const QPoint& ) ) );
101 connect((QTable*)this, SIGNAL(valueChanged(int, int) ), 122 connect((QTable*)this, SIGNAL(valueChanged(int, int) ),
102 this, SLOT( slotValueChanged(int, int) ) ); 123 this, SLOT( slotValueChanged(int, int) ) );
103 connect((QTable*)this, SIGNAL(currentChanged(int, int) ), 124 connect((QTable*)this, SIGNAL(currentChanged(int, int) ),
104 this, SLOT( slotCurrentChanged(int, int) ) ); 125 this, SLOT( slotCurrentChanged(int, int) ) );
105 126
106 m_menuTimer = new QTimer( this ); 127 m_menuTimer = new QTimer( this );
107 connect( m_menuTimer, SIGNAL(timeout()), 128 connect( m_menuTimer, SIGNAL(timeout()),
108 this, SLOT(slotShowMenu()) ); 129 this, SLOT(slotShowMenu()) );
109 130
110 /* now let's init the config */ 131 /* now let's init the config */
111 initConfig(); 132 initConfig();
112 133
113 134
114 m_enablePaint = true; 135 m_enablePaint = true;
115 setUpdatesEnabled( true ); 136 setUpdatesEnabled( true );
116 viewport()->setUpdatesEnabled( true ); 137 viewport()->setUpdatesEnabled( true );
117 viewport()->update(); 138 viewport()->update();
118 setSortOrder( 0 ); 139 setSortOrder( 0 );
119 setAscending( TRUE ); 140 setAscending( TRUE );
120 m_first = true; 141 m_first = true;
121 142
122 143
123} 144}
124/* a new day has started 145/* a new day has started
125 * update the day 146 * update the day
126 */ 147 */
127void TableView::newDay() { 148void TableView::newDay() {
128 clear(); 149 clear();
129 updateView(); 150 updateView();
130} 151}
131TableView::~TableView() { 152TableView::~TableView() {
132 Config config( "todo" ); 153 Config config( "todo" );
133 config.setGroup( "Options" ); 154 config.setGroup( "Options" );
134 for (int i = 0; i < numCols(); i++ ) 155 for (int i = 0; i < numCols(); i++ )
135 config.writeEntry("Width"+QString::number(i), columnWidth(i) ); 156 config.writeEntry("Width"+QString::number(i), columnWidth(i) );
136} 157}
137void TableView::slotShowMenu() { 158void TableView::slotShowMenu() {
138 QPopupMenu *menu = todoWindow()->contextMenu( current(), sorted()[currentRow()].recurrence().doesRecur() ); 159 QPopupMenu *menu = todoWindow()->contextMenu( current(), sorted()[currentRow()].recurrence().doesRecur() );
139 menu->exec(QCursor::pos() ); 160 menu->exec(QCursor::pos() );
140 delete menu; 161 delete menu;
141} 162}
142QString TableView::type() const { 163QString TableView::type() const {
143 return QString::fromLatin1( tr("Table View") ); 164 return QString::fromLatin1( tr("Table View") );
144} 165}
145int TableView::current() { 166int TableView::current() {
146 if (numRows() == 0 ) return 1; 167 if (numRows() == 0 ) return 0;
147 int uid = sorted().uidAt(currentRow() ); 168 int uid = sorted().uidAt(currentRow() );
148 169
149 return uid; 170 return uid;
150} 171}
172int TableView::next() {
173 if ( numRows() == 0 ) return 0;
174 if ( currentRow() + 1 >= numRows() ) return 0;
175 setCurrentCell( currentRow() +1, currentColumn() );
176 return sorted().uidAt( currentRow() );
177}
178int TableView::prev() {
179 if ( numRows() == 0 ) return 0;
180 if ( currentRow() - 1 < 0 ) return 0;
181 setCurrentCell( currentRow() -1, currentColumn() );
182 return sorted().uidAt( currentRow() );
183
184}
151QString TableView::currentRepresentation() { 185QString TableView::currentRepresentation() {
152 OTodo to = sorted()[currentRow()]; 186 OTodo to = sorted()[currentRow()];
153 return to.summary().isEmpty() ? to.description().left(20) : to.summary() ; 187 return to.summary().isEmpty() ? to.description().left(20) : to.summary() ;
154} 188}
155/* show overdue */ 189/* show overdue */
156void TableView::showOverDue( bool ) { 190void TableView::showOverDue( bool ) {
157 clear(); 191 clear();
158 updateView(); 192 updateView();
159} 193}
160 194
161void TableView::updateView( ) { 195void TableView::updateView( ) {
162 qWarning("update view"); 196 qWarning("update view");
163 m_row = false; 197 m_row = false;
164 static int id; 198 static int id;
165 id = startTimer(4000 ); 199 id = startTimer(4000 );
166 /* FIXME we want one page to be read! 200 /* FIXME we want one page to be read!
167 * 201 *
168 * Calculate that screensize 202 * Calculate that screensize
169 */ 203 */
170 todoWindow()->setReadAhead( 4 ); 204 todoWindow()->setReadAhead( 4 );
171 sort(); 205 sort();
172 OTodoAccess::List::Iterator it, end; 206 OTodoAccess::List::Iterator it, end;
173 it = sorted().begin(); 207 it = sorted().begin();
174 end = sorted().end(); 208 end = sorted().end();
175 209
176 qWarning("setTodos"); 210 qWarning("setTodos");
177 QTime time; 211 QTime time;
178 time.start(); 212 time.start();
179 m_enablePaint = false; 213 m_enablePaint = false;
180 setUpdatesEnabled( false ); 214 setUpdatesEnabled( false );
181 viewport()->setUpdatesEnabled( false ); 215 viewport()->setUpdatesEnabled( false );
182 216
183 setNumRows( it.count() ); 217 setNumRows( it.count() );
184 if ( it.count() == 0 ) 218 if ( it.count() == 0 )
185 killTimer(id); 219 killTimer(id);
186 220
187// int elc = time.elapsed(); 221// int elc = time.elapsed();
188 setUpdatesEnabled( true ); 222 setUpdatesEnabled( true );
189 viewport()->setUpdatesEnabled( true ); 223 viewport()->setUpdatesEnabled( true );
190 viewport()->update(); 224 viewport()->update();
191 225
192 m_enablePaint = true; 226 m_enablePaint = true;
193// int el = time.elapsed(); 227// int el = time.elapsed();
194} 228}
195void TableView::setTodo( int, const OTodo&) { 229void TableView::setTodo( int, const OTodo&) {
196 sort(); 230 sort();
197 231
198 /* repaint */ 232 /* repaint */
199 repaint(); 233 repaint();
200} 234}
201void TableView::addEvent( const OTodo&) { 235void TableView::addEvent( const OTodo&) {
202 236
203 /* fix problems of not showing the 'Haken' */ 237 /* fix problems of not showing the 'Haken' */
204 updateView(); 238 updateView();
205} 239}
206/* 240/*
207 * find the event 241 * find the event
208 * and then replace the complete row 242 * and then replace the complete row
209 */ 243 */
210void TableView::replaceEvent( const OTodo& ev) { 244void TableView::replaceEvent( const OTodo& ev) {
211 addEvent( ev ); 245 addEvent( ev );
212} 246}
213/* 247/*
214 * re aligning table can be slow too 248 * re aligning table can be slow too
215 * FIXME: look what performs better 249 * FIXME: look what performs better
216 * either this or the old align table 250 * either this or the old align table
217 */ 251 */
218void TableView::removeEvent( int ) { 252void TableView::removeEvent( int ) {
219 updateView(); 253 updateView();
220} 254}
221void TableView::setShowCompleted( bool b) { 255void TableView::setShowCompleted( bool b) {
222 qWarning("Show Completed %d" + b ); 256 qWarning("Show Completed %d" , b );
223 updateView(); 257 updateView();
224} 258}
225void TableView::setShowDeadline( bool b ) { 259void TableView::setShowDeadline( bool b ) {
226 qWarning( "Show DeadLine %d" + b ); 260 qWarning( "Show DeadLine %d" , b );
227 if ( b ) 261 if ( b )
228 showColumn( 3 ); 262 showColumn( 3 );
229 else 263 else
230 hideColumn( 3 ); 264 hideColumn( 3 );
231 265
232 // Try to intelligently size columns 266 // Try to intelligently size columns
233 // TODO - would use width() below, but doesn't have valid value at time of c'tor 267 // TODO - would use width() below, but doesn't have valid value at time of c'tor
234 int col2width = 238; 268 int col2width = 238;
235 int width = m_pic_completed.width(); 269 int width = m_pic_completed.width();
236 setColumnWidth( 0, width ); 270 setColumnWidth( 0, width );
237 col2width -= width; 271 col2width -= width;
238 width = fontMetrics().boundingRect( horizontalHeader()->label( 1 ) ).width() + 8; 272 width = fontMetrics().boundingRect( horizontalHeader()->label( 1 ) ).width() + 8;
239 setColumnWidth( 1, width ); 273 setColumnWidth( 1, width );
240 col2width -= width; 274 col2width -= width;
241 if ( b ) { 275 if ( b ) {
242 width = fontMetrics().boundingRect( horizontalHeader()->label( 3 ) ).width() + 8; 276 width = fontMetrics().boundingRect( horizontalHeader()->label( 3 ) ).width() + 8;
243 setColumnWidth( 3, width ); 277 setColumnWidth( 3, width );
244 col2width -= width; 278 col2width -= width;
245 } 279 }
246 setColumnWidth( 2, col2width ); 280 setColumnWidth( 2, col2width );
247} 281}
248void TableView::setShowCategory( const QString& str) { 282void TableView::setShowCategory( const QString& str) {
249 qWarning("setShowCategory"); 283 qWarning("setShowCategory");
250 if ( str != m_oleCat || m_first ) 284 if ( str != m_oleCat || m_first )
251 updateView(); 285 updateView();
252 286
253 m_oleCat = str; 287 m_oleCat = str;
254 m_first = false; 288 m_first = false;
255 289
256} 290}
257void TableView::clear() { 291void TableView::clear() {
258 setNumRows(0); 292 setNumRows(0);
259} 293}
260void TableView::slotClicked(int row, int col, int, 294void TableView::slotClicked(int row, int col, int,
261 const QPoint& point) { 295 const QPoint& point) {
296 if ( m_editorWidget.cellWidget() ) {
297 //setCellContentFromEditor(m_editorWidget.cellRow(), m_editorWidget.cellCol() );
298 endEdit(m_editorWidget.cellRow(), m_editorWidget.cellCol(),
299 true, true );
300 m_editorWidget.releaseCellWidget();
301 }
302
262 if ( !cellGeometry(row, col ).contains(point ) ) 303 if ( !cellGeometry(row, col ).contains(point ) )
263 return; 304 return;
264 305
265 int ui= sorted().uidAt( row ); 306 int ui= sorted().uidAt( row );
266 307
267 308
268 switch( col ) { 309 switch( col ) {
269 case 0:{ 310 case 0:{
270 int x = point.x() -columnPos( col ); 311 int x = point.x() -columnPos( col );
271 int y = point.y() -rowPos( row ); 312 int y = point.y() -rowPos( row );
272 int w = columnWidth( col ); 313 int w = columnWidth( col );
273 int h = rowHeight( row ); 314 int h = rowHeight( row );
274 if ( x >= ( w - BoxSize ) / 2 && 315 if ( x >= ( w - BoxSize ) / 2 &&
275 x <= ( w - BoxSize ) / 2 + BoxSize && 316 x <= ( w - BoxSize ) / 2 + BoxSize &&
276 y >= ( h - BoxSize ) / 2 && 317 y >= ( h - BoxSize ) / 2 &&
277 y <= ( h - BoxSize ) / 2 + BoxSize ) { 318 y <= ( h - BoxSize ) / 2 + BoxSize ) {
278 TodoView::complete(sorted()[row] ); 319 TodoView::complete(sorted()[row] );
279 } 320 }
280 } 321 }
281 break; 322 break;
282 323
283 case 1: 324 // Priority emit a double click...
325 case 1:{
326 QWidget* wid = beginEdit( row, col, FALSE );
327 m_editorWidget.setCellWidget( wid, row, col );
328 }
284 break; 329 break;
285 330
286 case 2: { 331 case 2: {
287 m_menuTimer->stop(); 332 m_menuTimer->stop();
288 showTodo( ui ); 333 showTodo( ui );
289 break; 334 break;
290 } 335 }
291 case 3: { 336 case 3: {
292 m_menuTimer->stop(); 337 m_menuTimer->stop();
293 TodoView::edit( ui ); 338 TodoView::edit( ui );
294 break; 339 break;
295 } 340 }
296 } 341 }
297 342
298 343
299} 344}
300void TableView::slotPressed(int row, int col, int, 345void TableView::slotPressed(int row, int col, int,
301 const QPoint& point) { 346 const QPoint& point) {
302 347
303 qWarning("pressed row %d col %d x:%d+y:%d", row,col,point.x(),point.y() ); 348 qWarning("pressed row %d col %d x:%d+y:%d", row,col,point.x(),point.y() );
304 m_prevP = point; 349 m_prevP = point;
305 /* TextColumn column */ 350 /* TextColumn column */
306 if ( col == 2 && cellGeometry( row, col ).contains( point ) ) 351 if ( col == 2 && cellGeometry( row, col ).contains( point ) )
307 m_menuTimer->start( 750, TRUE ); 352 m_menuTimer->start( 750, TRUE );
308} 353}
309void TableView::slotValueChanged( int, int ) { 354void TableView::slotValueChanged( int, int ) {
310 qWarning("Value Changed"); 355 qWarning("Value Changed");
311} 356}
312void TableView::slotCurrentChanged(int, int ) { 357void TableView::slotCurrentChanged(int, int ) {
313 m_menuTimer->stop(); 358 m_menuTimer->stop();
314} 359}
315QWidget* TableView::widget() { 360QWidget* TableView::widget() {
316 return this; 361 return this;
317} 362}
318/* 363/*
319 * We need to overwrite sortColumn 364 * We need to overwrite sortColumn
320 * because we want to sort whole row 365 * because we want to sort whole row
321 * based 366 * based
322 * We event want to set the setOrder 367 * We event want to set the setOrder
323 * to a sort() and update() 368 * to a sort() and update()
324 */ 369 */
325void TableView::sortColumn( int col, bool asc, bool ) { 370void TableView::sortColumn( int col, bool asc, bool ) {
326 qWarning("bool %d", asc ); 371 qWarning("bool %d", asc );
327 setSortOrder( col ); 372 setSortOrder( col );
328 setAscending( asc ); 373 setAscending( asc );
329 updateView(); 374 updateView();
330} 375}
331void TableView::viewportPaintEvent( QPaintEvent* e) { 376void TableView::viewportPaintEvent( QPaintEvent* e) {
332 if (m_enablePaint ) 377 if (m_enablePaint )
333 QTable::viewportPaintEvent( e ); 378 QTable::viewportPaintEvent( e );
334} 379}
335/* 380/*
336 * This segment is copyrighted by TT 381 * This segment is copyrighted by TT
337 * it was taken from their todolist 382 * it was taken from their todolist
338 * application this code is GPL 383 * application this code is GPL
339 */ 384 */
340void TableView::paintCell(QPainter* p, int row, int col, const QRect& cr, bool ) { 385void TableView::paintCell(QPainter* p, int row, int col, const QRect& cr, bool ) {
341 const QColorGroup &cg = colorGroup(); 386 const QColorGroup &cg = colorGroup();
342 387
343 p->save(); 388 p->save();
344 389
345 OTodo task = sorted()[row]; 390 OTodo task = sorted()[row];
346 391
347 // TODO - give user option for grid or bars? 392 // TODO - give user option for grid or bars?
348 393
349 // Paint alternating background bars 394 // Paint alternating background bars
350 if ( (row % 2 ) == 0 ) { 395 if ( (row % 2 ) == 0 ) {
351 p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Base ) ); 396 p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Base ) );
352 p->setPen( QPen( cg.text() ) ); 397 p->setPen( QPen( cg.text() ) );
353 } 398 }
354 else { 399 else {
355 p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Background ) ); 400 p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Background ) );
356 p->setPen( QPen( cg.buttonText() ) ); 401 p->setPen( QPen( cg.buttonText() ) );
357 } 402 }
358 403
359 // Paint grid 404 // Paint grid
360 //p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Base ) ); 405 //p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Base ) );
361 //QPen op = p->pen(); 406 //QPen op = p->pen();
362 //p->setPen(cg.mid()); 407 //p->setPen(cg.mid());
363 //p->drawLine( 0, cr.height() - 1, cr.width() - 1, cr.height() - 1 ); 408 //p->drawLine( 0, cr.height() - 1, cr.width() - 1, cr.height() - 1 );
364 //p->drawLine( cr.width() - 1, 0, cr.width() - 1, cr.height() - 1 ); 409 //p->drawLine( cr.width() - 1, 0, cr.width() - 1, cr.height() - 1 );
365 //p->setPen(op); 410 //p->setPen(op);
366 411
367 QFont f = p->font(); 412 QFont f = p->font();
368 QFontMetrics fm(f); 413 QFontMetrics fm(f);
369 414
370 int marg = ( cr.width() - BoxSize ) / 2; 415 int marg = ( cr.width() - BoxSize ) / 2;
371 int x = 0; 416 int x = 0;
372 int y = ( cr.height() - BoxSize ) / 2; 417 int y = ( cr.height() - BoxSize ) / 2;
373 418
374 switch(col) { 419 switch(col) {
375 case 0: // completed field 420 case 0: // completed field
376 { 421 {
377 //p->setPen( QPen( cg.text() ) ); 422 //p->setPen( QPen( cg.text() ) );
378 //p->drawRect( x + marg, y, BoxSize, BoxSize ); 423 //p->drawRect( x + marg, y, BoxSize, BoxSize );
379 //p->drawRect( x + marg+1, y+1, BoxSize-2, BoxSize-2 ); 424 //p->drawRect( x + marg+1, y+1, BoxSize-2, BoxSize-2 );
380 if ( task.isCompleted() ) { 425 if ( task.isCompleted() ) {
381 p->drawPixmap( x + marg, y, m_pic_completed ); 426 p->drawPixmap( x + marg, y, m_pic_completed );
382 } 427 }
383 } 428 }
384 break; 429 break;
385 case 1: // priority field 430 case 1: // priority field
386 { 431 {
387 p->drawPixmap( x + marg, y, m_pic_priority[ task.priority() - 1 ] ); 432 p->drawPixmap( x + marg, y, m_pic_priority[ task.priority() - 1 ] );
388 } 433 }
389 break; 434 break;
390 case 2: // description field 435 case 2: // description field
391 { 436 {
392 QString text = task.summary().isEmpty() ? 437 QString text = task.summary().isEmpty() ?
393 task.description().left(20) : 438 task.description().left(20) :
394 task.summary(); 439 task.summary();
395 p->drawText(2,2 + fm.ascent(), text); 440 p->drawText(2,2 + fm.ascent(), text);
396 } 441 }
397 break; 442 break;
398 case 3: 443 case 3:
399 { 444 {
400 QString text; 445 QString text;
401 if (task.hasDueDate()) { 446 if (task.hasDueDate()) {
402 int off = QDate::currentDate().daysTo( task.dueDate() ); 447 int off = QDate::currentDate().daysTo( task.dueDate() );
403 text = tr( "%1 day(s)").arg(QString::number(off)); 448 text = tr( "%1 day(s)").arg(QString::number(off));
404 /* 449 /*
405 * set color if not completed 450 * set color if not completed
406 */ 451 */
407 if (!task.isCompleted() ) { 452 if (!task.isCompleted() ) {
408 QColor color = Qt::black; 453 QColor color = Qt::black;
409 if ( off < 0 ) 454 if ( off < 0 )
410 color = Qt::red; 455 color = Qt::red;
411 else if ( off == 0 ) 456 else if ( off == 0 )
412 color = Qt::yellow; 457 color = Qt::yellow;
413 else if ( off > 0 ) 458 else if ( off > 0 )
414 color = Qt::green; 459 color = Qt::green;
415 p->setPen(color ); 460 p->setPen(color );
416 } 461 }
417 } else { 462 } else {
418 text = tr("None"); 463 text = tr("None");
419 } 464 }
420 p->drawText(2,2 + fm.ascent(), text); 465 p->drawText(2,2 + fm.ascent(), text);
421 } 466 }
422 break; 467 break;
423 } 468 }
424 p->restore(); 469 p->restore();
425} 470}
426QWidget* TableView::createEditor(int row, int col, bool )const { 471QWidget* TableView::createEditor(int row, int col, bool )const {
427 switch( col ) { 472 switch( col ) {
428 case 1: { 473 case 1: {
429 /* the priority stuff */ 474 /* the priority stuff */
430 QComboBox* combo = new QComboBox( viewport() ); 475 QComboBox* combo = new QComboBox( viewport() );
431 for ( int i = 0; i < 5; i++ ) { 476 for ( int i = 0; i < 5; i++ ) {
432 combo->insertItem( m_pic_priority[ i ] ); 477 combo->insertItem( m_pic_priority[ i ] );
433 } 478 }
434 combo->setCurrentItem( sorted()[row].priority()-1 ); 479 combo->setCurrentItem( sorted()[row].priority()-1 );
435 return combo; 480 return combo;
436 } 481 }
437 /* summary */ 482 /* summary */
438 case 2:{ 483 case 2:{
439 QLineEdit* edit = new QLineEdit( viewport() ); 484 QLineEdit* edit = new QLineEdit( viewport() );
440 edit->setText( sorted()[row].summary() ); 485 edit->setText( sorted()[row].summary() );
441 return edit; 486 return edit;
442 } 487 }
443 case 0: 488 case 0:
444 default: 489 default:
445 return 0l; 490 return 0l;
446 } 491 }
447} 492}
448void TableView::setCellContentFromEditor(int row, int col ) { 493void TableView::setCellContentFromEditor(int row, int col ) {
494 qWarning("set cell content from editor");
449 if ( col == 1 ) { 495 if ( col == 1 ) {
450 QWidget* wid = cellWidget(row, 1 ); 496 QWidget* wid = cellWidget(row, 1 );
451 if ( wid->inherits("QComboBox") ) { 497 if ( wid->inherits("QComboBox") ) {
452 int pri = ((QComboBox*)wid)->currentItem() + 1; 498 int pri = ((QComboBox*)wid)->currentItem() + 1;
453 OTodo todo = sorted()[row]; 499 OTodo todo = sorted()[row];
454 if ( todo.priority() != pri ) { 500 if ( todo.priority() != pri ) {
455 todo.setPriority( pri ); 501 todo.setPriority( pri );
456 TodoView::update( todo.uid(), todo ); 502 TodoView::update( todo.uid(), todo );
457 updateView(); 503 updateView();
458 } 504 }
459 } 505 }
460 }else if ( col == 2) { 506 }else if ( col == 2) {
461 QWidget* wid = cellWidget(row, 2); 507 QWidget* wid = cellWidget(row, 2);
462 if ( wid->inherits("QLineEdit") ) { 508 if ( wid->inherits("QLineEdit") ) {
463 QString text = ((QLineEdit*)wid)->text(); 509 QString text = ((QLineEdit*)wid)->text();
464 OTodo todo = sorted()[row]; 510 OTodo todo = sorted()[row];
465 if ( todo.summary() != text ) { 511 if ( todo.summary() != text ) {
466 todo.setSummary( text ); 512 todo.setSummary( text );
467 TodoView::update( todo.uid(), todo ); 513 TodoView::update( todo.uid(), todo );
468 updateView(); 514 updateView();
469 } 515 }
470 } 516 }
471 } 517 }
472} 518}
473void TableView::slotPriority() { 519void TableView::slotPriority() {
474 setCellContentFromEditor( currentRow(), currentColumn() ); 520 setCellContentFromEditor( currentRow(), currentColumn() );
475} 521}
476/* 522/*
477 * We'll use the TimerEvent to read ahead or to keep the cahce always 523 * We'll use the TimerEvent to read ahead or to keep the cahce always
478 * filled enough. 524 * filled enough.
479 * We will try to read ahead 4 items in both ways 525 * We will try to read ahead 4 items in both ways
480 * up and down. On odd or even we will currentRow()+-4 or +-9 526 * up and down. On odd or even we will currentRow()+-4 or +-9
481 * 527 *
482 */ 528 */
483void TableView::timerEvent( QTimerEvent* ) { 529void TableView::timerEvent( QTimerEvent* ) {
484// qWarning("sorted %d", sorted().count() ); 530// qWarning("sorted %d", sorted().count() );
485 if (sorted().count() == 0 ) 531 if (sorted().count() == 0 )
486 return; 532 return;
487 533
488 int row = currentRow(); 534 int row = currentRow();
489 if ( m_row ) { 535 if ( m_row ) {
490 int ro = row-4; 536 int ro = row-4;
491 if (ro < 0 ) ro = 0; 537 if (ro < 0 ) ro = 0;
492 sorted()[ro]; 538 sorted()[ro];
493 539
494 ro = row+4; 540 ro = row+4;
495 sorted()[ro]; 541 sorted()[ro];
496 } else { 542 } else {
497 int ro = row + 8; 543 int ro = row + 8;
498 sorted()[ro]; 544 sorted()[ro];
499 545
500 ro = row-8; 546 ro = row-8;
501 if (ro < 0 ) ro = 0; 547 if (ro < 0 ) ro = 0;
502 sorted()[ro]; 548 sorted()[ro];
503 } 549 }
504 550
505 m_row = !m_row; 551 m_row = !m_row;
506} 552}
507 553
508// We want a strike through completed ;) 554// We want a strike through completed ;)
509// durchstreichen to complete 555// durchstreichen to complete
510/* 556/*
511 * MouseTracking is off this mean we only receive 557 * MouseTracking is off this mean we only receive
512 * these events if the mouse button is pressed 558 * these events if the mouse button is pressed
513 * We've the previous point saved 559 * We've the previous point saved
514 * We check if the previous and current Point are 560 * We check if the previous and current Point are
515 * in the same row. 561 * in the same row.
516 * Then we check if they're some pixel horizontal away 562 * Then we check if they're some pixel horizontal away
517 * if the distance between the two points is greater than 563 * if the distance between the two points is greater than
518 * 8 we mark the underlying todo as completed and do a repaint 564 * 8 we mark the underlying todo as completed and do a repaint
519 * 565 *
520 * BUG: When clicking on the Due column and it's scrollable 566 * BUG: When clicking on the Due column and it's scrollable
521 * the todo is marked as completed... 567 * the todo is marked as completed...
522 * REASON: QTable is doing auto scrolling which leads to a move 568 * REASON: QTable is doing auto scrolling which leads to a move
523 * in the x coordinate and this way it's able to pass the 569 * in the x coordinate and this way it's able to pass the
524 * m_completeStrokeWidth criteria 570 * m_completeStrokeWidth criteria
525 * WORKAROUND: strike through needs to strike through the same 571 * WORKAROUND: strike through needs to strike through the same
526 * row and two columns! 572 * row and two columns!
527 */ 573 */
528void TableView::contentsMouseReleaseEvent( QMouseEvent* e) { 574void TableView::contentsMouseReleaseEvent( QMouseEvent* e) {
529 int row = rowAt(m_prevP.y()); 575 int row = rowAt(m_prevP.y());
530 int colOld = columnAt(m_prevP.x() ); 576 int colOld = columnAt(m_prevP.x() );
531 int colNew = columnAt(e->x() ); 577 int colNew = columnAt(e->x() );
532 qWarning("colNew: %d colOld: %d", colNew, colOld ); 578 qWarning("colNew: %d colOld: %d", colNew, colOld );
533 if ( row == rowAt( e->y() ) && row != -1 && 579 if ( row == rowAt( e->y() ) && row != -1 &&
534 colOld != colNew ) { 580 colOld != colNew ) {
535 TodoView::complete( sorted()[row] ); 581 TodoView::complete( sorted()[row] );
536 return; 582 return;
537 } 583 }
538 QTable::contentsMouseReleaseEvent( e ); 584 QTable::contentsMouseReleaseEvent( e );
539} 585}
540void TableView::contentsMouseMoveEvent( QMouseEvent* e ) { 586void TableView::contentsMouseMoveEvent( QMouseEvent* e ) {
541 m_menuTimer->stop(); 587 m_menuTimer->stop();
542 QTable::contentsMouseMoveEvent( e ); 588 QTable::contentsMouseMoveEvent( e );
543} 589}
544void TableView::keyPressEvent( QKeyEvent* event) { 590void TableView::keyPressEvent( QKeyEvent* event) {
591 if ( m_editorWidget.cellWidget() ) {
592// setCellContentFromEditor(m_editorWidget.cellRow(), m_editorWidget.cellCol() );
593 endEdit(m_editorWidget.cellRow(), m_editorWidget.cellCol(),
594 true, true );
595 m_editorWidget.releaseCellWidget();
596 setFocus();
597 }
598 int row = currentRow();
599 int col = currentColumn();
600
601 char key = ::toupper( event->ascii() );
602 /* let QTable also handle the d later */
603 if ( key == 'D' )
604 removeQuery( sorted().uidAt( row ) );
605
606
545 switch( event->key() ) { 607 switch( event->key() ) {
546 case Qt::Key_F33: 608 case Qt::Key_F33:
547 case Qt::Key_Enter: 609 case Qt::Key_Enter:
548 case Qt::Key_Return: 610 case Qt::Key_Return:
549 showTodo( sorted().uidAt( currentRow() ) ); 611 case Qt::Key_Space:
612 if ( col == 0 ) {
613 TodoView::complete(sorted()[row]);
614 }else if ( col == 1 ) {
615 QWidget* wid = beginEdit(row, col, FALSE );
616 m_editorWidget.setCellWidget( wid, row, col );
617 }else if ( col == 2 ) {
618 showTodo( sorted().uidAt( currentRow() ) );
619 }else if ( col == 3 ) {
620 TodoView::edit( sorted().uidAt(row) );
621 }
622
550 break; 623 break;
551 default: 624 default:
552 QTable::keyPressEvent( event ); 625 QTable::keyPressEvent( event );
553 } 626 }
554} 627}
628
diff --git a/core/pim/todo/tableview.h b/core/pim/todo/tableview.h
index 689c496..528ddc9 100644
--- a/core/pim/todo/tableview.h
+++ b/core/pim/todo/tableview.h
@@ -1,112 +1,130 @@
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#include <qpixmap.h>
35 35
36#include "todoview.h" 36#include "todoview.h"
37 37
38class QTimer; 38class QTimer;
39 39
40namespace Todo { 40namespace Todo {
41 class CheckItem; 41 class CheckItem;
42 class DueTextItem; 42 class DueTextItem;
43 class TableView : public QTable, public TodoView { 43 class TableView : public QTable, public TodoView {
44 Q_OBJECT 44 Q_OBJECT
45 public: 45 public:
46 TableView( MainWindow*, QWidget* parent ); 46 TableView( MainWindow*, QWidget* parent );
47 ~TableView(); 47 ~TableView();
48 48
49 49
50 QString type()const; 50 QString type()const;
51 int current(); 51 int current();
52 QString currentRepresentation(); 52 QString currentRepresentation();
53 int next();
54 int prev();
53 55
54 void clear(); 56 void clear();
55 void showOverDue( bool ); 57 void showOverDue( bool );
56 void updateView(); 58 void updateView();
57 void setTodo( int uid, const OTodo& ); 59 void setTodo( int uid, const OTodo& );
58 void addEvent( const OTodo& event ); 60 void addEvent( const OTodo& event );
59 void replaceEvent( const OTodo& ); 61 void replaceEvent( const OTodo& );
60 void removeEvent( int uid ); 62 void removeEvent( int uid );
61 void setShowCompleted( bool ); 63 void setShowCompleted( bool );
62 void setShowDeadline( bool ); 64 void setShowDeadline( bool );
63 65
64 void setShowCategory(const QString& =QString::null ); 66 void setShowCategory(const QString& =QString::null );
65 void newDay(); 67 void newDay();
66 QWidget* widget(); 68 QWidget* widget();
67 void sortColumn(int, bool, bool ); 69 void sortColumn(int, bool, bool );
68 70
69 /* 71 /*
70 * we do our drawing ourselves 72 * we do our drawing ourselves
71 * because we don't want to have 73 * because we don't want to have
72 * 40.000 QTableItems for 10.000 74 * 40.000 QTableItems for 10.000
73 * OTodos where we only show 10 at a time! 75 * OTodos where we only show 10 at a time!
74 */ 76 */
75 void paintCell(QPainter* p, int row, int col, const QRect&, bool ); 77 void paintCell(QPainter* p, int row, int col, const QRect&, bool );
76 private: 78 private:
77 /* reimplented for internal reasons */ 79 /* reimplented for internal reasons */
78 void viewportPaintEvent( QPaintEvent* ); 80 void viewportPaintEvent( QPaintEvent* );
79 QTimer *m_menuTimer; 81 QTimer *m_menuTimer;
80 bool m_enablePaint:1; 82 bool m_enablePaint:1;
81 QString m_oleCat; 83 QString m_oleCat;
82 bool m_first : 1; 84 bool m_first : 1;
83 85
84 QPixmap m_pic_completed; 86 QPixmap m_pic_completed;
85 QPixmap m_pic_priority[ 5 ]; 87 QPixmap m_pic_priority[ 5 ];
86 88
87 protected: 89 protected:
88 void keyPressEvent( QKeyEvent* ); 90 void keyPressEvent( QKeyEvent* );
89 void contentsMouseReleaseEvent( QMouseEvent* ); 91 void contentsMouseReleaseEvent( QMouseEvent* );
90 void contentsMouseMoveEvent( QMouseEvent* ); 92 void contentsMouseMoveEvent( QMouseEvent* );
91 void timerEvent( QTimerEvent* e ); 93 void timerEvent( QTimerEvent* e );
92 QWidget* createEditor(int row, int col, bool initFromCell )const; 94 QWidget* createEditor(int row, int col, bool initFromCell )const;
93 void setCellContentFromEditor( int row, int col ); 95 void setCellContentFromEditor( int row, int col );
96 /**
97 * for inline editing on single click and to work around some
98 * bug in qt2.3.5
99 */
100 struct EditorWidget {
101 EditorWidget();
102 void setCellWidget(QWidget*, int row, int col );
103 void releaseCellWidget();
104 QWidget* cellWidget()const;
105 int cellRow()const;
106 int cellCol()const;
107 private:
108 QWidget* m_wid;
109 int m_row, m_col;
110 };
111 EditorWidget m_editorWidget;
94 112
95private slots: 113private slots:
96 void slotShowMenu(); 114 void slotShowMenu();
97 void slotClicked(int, int, int, 115 void slotClicked(int, int, int,
98 const QPoint& ); 116 const QPoint& );
99 void slotPressed(int, int, int, 117 void slotPressed(int, int, int,
100 const QPoint& ); 118 const QPoint& );
101 void slotValueChanged(int, int); 119 void slotValueChanged(int, int);
102 void slotCurrentChanged(int, int ); 120 void slotCurrentChanged(int, int );
103 void slotPriority(); 121 void slotPriority();
104 private: 122 private:
105 void initConfig(); 123 void initConfig();
106 int m_completeStrokeWidth; 124 int m_completeStrokeWidth;
107 bool m_row : 1; 125 bool m_row : 1;
108 QPoint m_prevP; 126 QPoint m_prevP;
109 }; 127 };
110}; 128};
111 129
112#endif 130#endif
diff --git a/core/pim/todo/taskeditoralarms.cpp b/core/pim/todo/taskeditoralarms.cpp
index bff3338..bcc40fe 100644
--- a/core/pim/todo/taskeditoralarms.cpp
+++ b/core/pim/todo/taskeditoralarms.cpp
@@ -1,236 +1,231 @@
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 "taskeditoralarms.h" 29#include "taskeditoralarms.h"
30 30
31#include <opie/otodo.h> 31#include <opie/otodo.h>
32#include <opie/opimnotifymanager.h> 32#include <opie/opimnotifymanager.h>
33#include <opie/otimepicker.h> 33#include <opie/otimepicker.h>
34 34
35#include <qpe/datebookmonth.h> 35#include <qpe/datebookmonth.h>
36#include <qpe/resource.h> 36#include <qpe/resource.h>
37#include <qpe/timestring.h>
38 37
39#include <qdatetime.h>
40#include <qlistview.h> 38#include <qlistview.h>
41#include <qpushbutton.h>
42#include <qpopupmenu.h>
43#include <qlayout.h> 39#include <qlayout.h>
44#include <qwhatsthis.h>
45 40
46 41
47class AlarmItem : public QListViewItem { 42class AlarmItem : public QListViewItem {
48public: 43public:
49 AlarmItem( QListView*, const OPimAlarm& ); 44 AlarmItem( QListView*, const OPimAlarm& );
50 ~AlarmItem(); 45 ~AlarmItem();
51 46
52 OPimAlarm alarm()const; 47 OPimAlarm alarm()const;
53 void setAlarm( const OPimAlarm& ); 48 void setAlarm( const OPimAlarm& );
54private: 49private:
55 QDateTime m_dt; 50 QDateTime m_dt;
56 int m_type; 51 int m_type;
57}; 52};
58AlarmItem::AlarmItem( QListView* view, const OPimAlarm& dt) 53AlarmItem::AlarmItem( QListView* view, const OPimAlarm& dt)
59 : QListViewItem(view) { 54 : QListViewItem(view) {
60 setAlarm( dt ); 55 setAlarm( dt );
61} 56}
62void AlarmItem::setAlarm( const OPimAlarm& dt ) { 57void AlarmItem::setAlarm( const OPimAlarm& dt ) {
63 m_dt = dt.dateTime(); 58 m_dt = dt.dateTime();
64 m_type = dt.sound(); 59 m_type = dt.sound();
65 setText( 0, TimeString::dateString( m_dt.date() ) ); 60 setText( 0, TimeString::dateString( m_dt.date() ) );
66 setText( 1, TimeString::timeString( m_dt.time() ) ); 61 setText( 1, TimeString::timeString( m_dt.time() ) );
67 setText( 2, m_type == 0 ? QObject::tr("silent") : QObject::tr("loud") ); 62 setText( 2, m_type == 0 ? QObject::tr("silent") : QObject::tr("loud") );
68} 63}
69AlarmItem::~AlarmItem() { 64AlarmItem::~AlarmItem() {
70} 65}
71OPimAlarm AlarmItem::alarm()const{ 66OPimAlarm AlarmItem::alarm()const{
72 OPimAlarm al( m_type, m_dt ); 67 OPimAlarm al( m_type, m_dt );
73 68
74 return al; 69 return al;
75} 70}
76 71
77TaskEditorAlarms::TaskEditorAlarms( QWidget* parent, int, const char* name, WFlags fl ) 72TaskEditorAlarms::TaskEditorAlarms( QWidget* parent, int, const char* name, WFlags fl )
78 : QWidget( parent, name, fl ) 73 : QWidget( parent, name, fl )
79{ 74{
80 m_date = m_type = m_time = 0; 75 m_date = m_type = m_time = 0;
81 QGridLayout *layout = new QGridLayout( this, 2, 2, 4, 4 ); 76 QGridLayout *layout = new QGridLayout( this, 2, 2, 4, 4 );
82 77
83 lstAlarms = new QListView( this ); 78 lstAlarms = new QListView( this );
84 lstAlarms->addColumn( tr("Date") ); 79 lstAlarms->addColumn( tr("Date") );
85 lstAlarms->addColumn( tr("Time") ); 80 lstAlarms->addColumn( tr("Time") );
86 lstAlarms->addColumn( tr("Type") ); 81 lstAlarms->addColumn( tr("Type") );
87 82
88 connect( lstAlarms, SIGNAL(clicked ( QListViewItem *, const QPoint &, int ) ), 83 connect( lstAlarms, SIGNAL(clicked ( QListViewItem *, const QPoint &, int ) ),
89 this, SLOT(inlineEdit(QListViewItem*, const QPoint&, int ) ) ); 84 this, SLOT(inlineEdit(QListViewItem*, const QPoint&, int ) ) );
90 85
91 layout->addMultiCellWidget( lstAlarms, 0, 0, 0, 2 ); 86 layout->addMultiCellWidget( lstAlarms, 0, 0, 0, 2 );
92 87
93 QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), this ); 88 QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), this );
94 //QWhatsThis::add( btn, tr( "Click here to add a new transaction." ) ); 89 //QWhatsThis::add( btn, tr( "Click here to add a new transaction." ) );
95 connect( btn, SIGNAL( clicked() ), this, SLOT( slotNew() ) ); 90 connect( btn, SIGNAL( clicked() ), this, SLOT( slotNew() ) );
96 layout->addWidget( btn, 1, 0 ); 91 layout->addWidget( btn, 1, 0 );
97/* use when we've reminders too */ 92/* use when we've reminders too */
98#if 0 93#if 0
99 btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Edit" ), this ); 94 btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Edit" ), this );
100 //QWhatsThis::add( btn, tr( "Select a transaction and then click here to edit it." ) ); 95 //QWhatsThis::add( btn, tr( "Select a transaction and then click here to edit it." ) );
101 connect( btn, SIGNAL( clicked() ), this, SLOT( slotEdit() ) ); 96 connect( btn, SIGNAL( clicked() ), this, SLOT( slotEdit() ) );
102 layout->addWidget( btn, 1, 1 ); 97 layout->addWidget( btn, 1, 1 );
103#endif 98#endif
104 99
105 btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), this ); 100 btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), this );
106 //QWhatsThis::add( btn, tr( "Select a checkbook and then click here to delete it." ) ); 101 //QWhatsThis::add( btn, tr( "Select a checkbook and then click here to delete it." ) );
107 connect( btn, SIGNAL( clicked() ), this, SLOT( slotDelete() ) ); 102 connect( btn, SIGNAL( clicked() ), this, SLOT( slotDelete() ) );
108 layout->addWidget( btn, 1, 2 ); 103 layout->addWidget( btn, 1, 2 );
109} 104}
110 105
111TaskEditorAlarms::~TaskEditorAlarms(){ 106TaskEditorAlarms::~TaskEditorAlarms(){
112} 107}
113 108
114void TaskEditorAlarms::slotNew(){ 109void TaskEditorAlarms::slotNew(){
115 (void)new AlarmItem(lstAlarms, OPimAlarm(0, QDateTime::currentDateTime() ) ); 110 (void)new AlarmItem(lstAlarms, OPimAlarm(0, QDateTime::currentDateTime() ) );
116} 111}
117 112
118void TaskEditorAlarms::slotEdit(){ 113void TaskEditorAlarms::slotEdit(){
119} 114}
120 115
121void TaskEditorAlarms::slotDelete(){ 116void TaskEditorAlarms::slotDelete(){
122 QListViewItem* item = lstAlarms->currentItem(); 117 QListViewItem* item = lstAlarms->currentItem();
123 if (!item) return; 118 if (!item) return;
124 119
125 lstAlarms->takeItem( item ); delete item; 120 lstAlarms->takeItem( item ); delete item;
126 121
127 122
128} 123}
129 124
130void TaskEditorAlarms::load( const OTodo& todo) { 125void TaskEditorAlarms::load( const OTodo& todo) {
131 lstAlarms->clear(); 126 lstAlarms->clear();
132 if (!todo.hasNotifiers() ) return; 127 if (!todo.hasNotifiers() ) return;
133 128
134 OPimNotifyManager::Alarms als = todo.notifiers().alarms(); 129 OPimNotifyManager::Alarms als = todo.notifiers().alarms();
135 130
136 if (als.isEmpty() ) return; 131 if (als.isEmpty() ) return;
137 132
138 OPimNotifyManager::Alarms::Iterator it = als.begin(); 133 OPimNotifyManager::Alarms::Iterator it = als.begin();
139 for ( ; it != als.end(); ++it ) 134 for ( ; it != als.end(); ++it )
140 (void)new AlarmItem( lstAlarms, (*it) ); 135 (void)new AlarmItem( lstAlarms, (*it) );
141 136
142 137
143} 138}
144void TaskEditorAlarms::save( OTodo& todo ) { 139void TaskEditorAlarms::save( OTodo& todo ) {
145 if (lstAlarms->childCount() <= 0 ) return; 140 if (lstAlarms->childCount() <= 0 ) return;
146 141
147 OPimNotifyManager::Alarms alarms; 142 OPimNotifyManager::Alarms alarms;
148 143
149 for ( QListViewItem* item = lstAlarms->firstChild(); item; item = item->nextSibling() ) { 144 for ( QListViewItem* item = lstAlarms->firstChild(); item; item = item->nextSibling() ) {
150 AlarmItem *alItem = static_cast<AlarmItem*>(item); 145 AlarmItem *alItem = static_cast<AlarmItem*>(item);
151 alarms.append( alItem->alarm() ); 146 alarms.append( alItem->alarm() );
152 } 147 }
153 148
154 OPimNotifyManager& manager = todo.notifiers(); 149 OPimNotifyManager& manager = todo.notifiers();
155 manager.setAlarms( alarms ); 150 manager.setAlarms( alarms );
156} 151}
157void TaskEditorAlarms::inlineEdit( QListViewItem* alarm, const QPoint& p, int col ) { 152void TaskEditorAlarms::inlineEdit( QListViewItem* alarm, const QPoint& p, int col ) {
158 if (!alarm) return; 153 if (!alarm) return;
159 154
160 AlarmItem* item = static_cast<AlarmItem*>(alarm); 155 AlarmItem* item = static_cast<AlarmItem*>(alarm);
161 switch( col ) { 156 switch( col ) {
162 // date 157 // date
163 case 0: 158 case 0:
164 return inlineSetDate( item, p ); 159 return inlineSetDate( item, p );
165 // time 160 // time
166 case 1: 161 case 1:
167 return inlineSetTime( item ); 162 return inlineSetTime( item );
168 // type 163 // type
169 case 2: 164 case 2:
170 return inlineSetType( item, p ); 165 return inlineSetType( item, p );
171 } 166 }
172} 167}
173void TaskEditorAlarms::inlineSetDate( AlarmItem* item, const QPoint& p ) { 168void TaskEditorAlarms::inlineSetDate( AlarmItem* item, const QPoint& p ) {
174 QPopupMenu* pop = popup( 0 ); 169 QPopupMenu* pop = popup( 0 );
175 m_dbMonth->setDate( item->alarm().dateTime().date() ); 170 m_dbMonth->setDate( item->alarm().dateTime().date() );
176 pop->exec(p); 171 pop->exec(p);
177 172
178 OPimAlarm al = item->alarm(); 173 OPimAlarm al = item->alarm();
179 QDateTime dt = al.dateTime(); 174 QDateTime dt = al.dateTime();
180 dt.setDate( m_dbMonth->selectedDate() ); 175 dt.setDate( m_dbMonth->selectedDate() );
181 al.setDateTime( dt ); 176 al.setDateTime( dt );
182 item->setAlarm( al ); 177 item->setAlarm( al );
183} 178}
184void TaskEditorAlarms::inlineSetType( AlarmItem* item, const QPoint& p ) { 179void TaskEditorAlarms::inlineSetType( AlarmItem* item, const QPoint& p ) {
185 int type; 180 int type;
186 QPopupMenu* pop = popup( 2 ); 181 QPopupMenu* pop = popup( 2 );
187 switch( pop->exec(p) ) { 182 switch( pop->exec(p) ) {
188 case 10: 183 case 10:
189 type = 1; 184 type = 1;
190 break; 185 break;
191 case 20: 186 case 20:
192 default: 187 default:
193 type = 0; 188 type = 0;
194 } 189 }
195 OPimAlarm al = item->alarm(); 190 OPimAlarm al = item->alarm();
196 al.setSound( type ); 191 al.setSound( type );
197 item->setAlarm( al ); 192 item->setAlarm( al );
198} 193}
199void TaskEditorAlarms::inlineSetTime( AlarmItem* item ) { 194void TaskEditorAlarms::inlineSetTime( AlarmItem* item ) {
200 OPimAlarm al = item->alarm(); 195 OPimAlarm al = item->alarm();
201 QDateTime dt = al.dateTime(); 196 QDateTime dt = al.dateTime();
202 197
203 OTimePickerDialog dialog; 198 OTimePickerDialog dialog;
204 dialog.setTime( dt.time() ); 199 dialog.setTime( dt.time() );
205 if ( dialog.exec() == QDialog::Accepted ) { 200 if ( dialog.exec() == QDialog::Accepted ) {
206 dt.setTime( dialog.time() ); 201 dt.setTime( dialog.time() );
207 al.setDateTime( dt ); 202 al.setDateTime( dt );
208 item->setAlarm( al ); 203 item->setAlarm( al );
209 } 204 }
210} 205}
211QPopupMenu* TaskEditorAlarms::popup( int column ) { 206QPopupMenu* TaskEditorAlarms::popup( int column ) {
212 QPopupMenu* pop = 0; 207 QPopupMenu* pop = 0;
213 switch( column ) { 208 switch( column ) {
214 case 0:{ 209 case 0:{
215 if (!m_date) { 210 if (!m_date) {
216 m_date = new QPopupMenu(this); 211 m_date = new QPopupMenu(this);
217 m_dbMonth = new DateBookMonth(m_date, 0, TRUE); 212 m_dbMonth = new DateBookMonth(m_date, 0, TRUE);
218 m_date->insertItem(m_dbMonth); 213 m_date->insertItem(m_dbMonth);
219 } 214 }
220 pop = m_date; 215 pop = m_date;
221 } 216 }
222 break; 217 break;
223 case 1: 218 case 1:
224 break; 219 break;
225 case 2:{ 220 case 2:{
226 if (!m_type) { 221 if (!m_type) {
227 m_type = new QPopupMenu(this); 222 m_type = new QPopupMenu(this);
228 m_type->insertItem( QObject::tr("loud"), 10 ); 223 m_type->insertItem( QObject::tr("loud"), 10 );
229 m_type->insertItem( QObject::tr("silent"), 20 ); 224 m_type->insertItem( QObject::tr("silent"), 20 );
230 } 225 }
231 pop = m_type; 226 pop = m_type;
232 } 227 }
233 break; 228 break;
234 default: 229 default:
235 break; 230 break;
236 } 231 }
diff --git a/core/pim/todo/taskeditoroverview.cpp b/core/pim/todo/taskeditoroverview.cpp
index 9a8abea..415dcf2 100644
--- a/core/pim/todo/taskeditoroverview.cpp
+++ b/core/pim/todo/taskeditoroverview.cpp
@@ -1,177 +1,175 @@
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 "taskeditoroverview.h" 29#include "taskeditoroverview.h"
30 30
31#include <opie/orecur.h> 31#include <opie/orecur.h>
32 32
33#include <qpe/categoryselect.h> 33#include <qpe/categoryselect.h>
34#include <qpe/datebookmonth.h> 34#include <qpe/datebookmonth.h>
35#include <qpe/resource.h> 35#include <qpe/resource.h>
36#include <qpe/timestring.h>
37 36
38#include <qcheckbox.h> 37#include <qcheckbox.h>
39#include <qcombobox.h>
40#include <qlabel.h> 38#include <qlabel.h>
41#include <qlayout.h> 39#include <qlayout.h>
42#include <qmultilineedit.h> 40#include <qmultilineedit.h>
43#include <qwhatsthis.h> 41#include <qwhatsthis.h>
44 42
45TaskEditorOverView::TaskEditorOverView( QWidget* parent, const char* name, WFlags fl ) 43TaskEditorOverView::TaskEditorOverView( QWidget* parent, const char* name, WFlags fl )
46 : QWidget( parent, name, fl ) 44 : QWidget( parent, name, fl )
47{ 45{
48 // Load icons 46 // Load icons
49 // TODO - probably should be done globally somewhere else, 47 // TODO - probably should be done globally somewhere else,
50 // see also quickeditimpl.cpp/h, tableview.cpp/h 48 // see also quickeditimpl.cpp/h, tableview.cpp/h
51 QString namestr; 49 QString namestr;
52 for ( unsigned int i = 1; i < 6; i++ ) { 50 for ( unsigned int i = 1; i < 6; i++ ) {
53 namestr = "todo/priority"; 51 namestr = "todo/priority";
54 namestr.append( QString::number( i ) ); 52 namestr.append( QString::number( i ) );
55 m_pic_priority[ i - 1 ] = Resource::loadPixmap( namestr ); 53 m_pic_priority[ i - 1 ] = Resource::loadPixmap( namestr );
56 } 54 }
57 55
58 QVBoxLayout *vb = new QVBoxLayout( this ); 56 QVBoxLayout *vb = new QVBoxLayout( this );
59 57
60 QScrollView *sv = new QScrollView( this ); 58 QScrollView *sv = new QScrollView( this );
61 vb->addWidget( sv ); 59 vb->addWidget( sv );
62 sv->setResizePolicy( QScrollView::AutoOneFit ); 60 sv->setResizePolicy( QScrollView::AutoOneFit );
63 sv->setFrameStyle( QFrame::NoFrame ); 61 sv->setFrameStyle( QFrame::NoFrame );
64 62
65 QWidget *container = new QWidget( sv->viewport() ); 63 QWidget *container = new QWidget( sv->viewport() );
66 sv->addChild( container ); 64 sv->addChild( container );
67 65
68 QGridLayout *layout = new QGridLayout( container, 7, 2, 4, 4 ); 66 QGridLayout *layout = new QGridLayout( container, 7, 2, 4, 4 );
69 67
70 // Description 68 // Description
71 QLabel *label = new QLabel( tr( "Description:" ), container ); 69 QLabel *label = new QLabel( tr( "Summary:" ), container );
72 layout->addWidget( label, 0, 0 ); 70 layout->addWidget( label, 0, 0 );
73 QWhatsThis::add( label, tr( "Enter brief description of the task here." ) ); 71 QWhatsThis::add( label, tr( "Enter brief description of the task here." ) );
74 cmbDesc = new QComboBox( TRUE, container ); 72 cmbDesc = new QComboBox( TRUE, container );
75 cmbDesc->insertItem( tr( "Complete " ) ); 73 cmbDesc->insertItem( tr( "Complete " ) );
76 cmbDesc->insertItem( tr( "Work on " ) ); 74 cmbDesc->insertItem( tr( "Work on " ) );
77 cmbDesc->insertItem( tr( "Buy " ) ); 75 cmbDesc->insertItem( tr( "Buy " ) );
78 cmbDesc->insertItem( tr( "Organize " ) ); 76 cmbDesc->insertItem( tr( "Organize " ) );
79 cmbDesc->insertItem( tr( "Get " ) ); 77 cmbDesc->insertItem( tr( "Get " ) );
80 cmbDesc->insertItem( tr( "Update " ) ); 78 cmbDesc->insertItem( tr( "Update " ) );
81 cmbDesc->insertItem( tr( "Create " ) ); 79 cmbDesc->insertItem( tr( "Create " ) );
82 cmbDesc->insertItem( tr( "Plan " ) ); 80 cmbDesc->insertItem( tr( "Plan " ) );
83 cmbDesc->insertItem( tr( "Call " ) ); 81 cmbDesc->insertItem( tr( "Call " ) );
84 cmbDesc->insertItem( tr( "Mail " ) ); 82 cmbDesc->insertItem( tr( "Mail " ) );
85 cmbDesc->clearEdit(); 83 cmbDesc->clearEdit();
86 layout->addMultiCellWidget( cmbDesc, 1, 1, 0, 1 ); 84 layout->addMultiCellWidget( cmbDesc, 1, 1, 0, 1 );
87 QWhatsThis::add( cmbDesc, tr( "Enter brief description of the task here." ) ); 85 QWhatsThis::add( cmbDesc, tr( "Enter brief description of the task here." ) );
88 86
89 // Priority 87 // Priority
90 label = new QLabel( QWidget::tr( "Priority:" ), container ); 88 label = new QLabel( QWidget::tr( "Priority:" ), container );
91 layout->addWidget( label, 2, 0 ); 89 layout->addWidget( label, 2, 0 );
92 QWhatsThis::add( label, tr( "Select priority of task here." ) ); 90 QWhatsThis::add( label, tr( "Select priority of task here." ) );
93 cmbPriority = new QComboBox( FALSE, container ); 91 cmbPriority = new QComboBox( FALSE, container );
94 cmbPriority->setMinimumHeight( 26 ); 92 cmbPriority->setMinimumHeight( 26 );
95 cmbPriority->insertItem( m_pic_priority[ 0 ], tr( "Very High" ) ); 93 cmbPriority->insertItem( m_pic_priority[ 0 ], tr( "Very High" ) );
96 cmbPriority->insertItem( m_pic_priority[ 1 ], tr( "High" ) ); 94 cmbPriority->insertItem( m_pic_priority[ 1 ], tr( "High" ) );
97 cmbPriority->insertItem( m_pic_priority[ 2 ], tr( "Normal" ) ); 95 cmbPriority->insertItem( m_pic_priority[ 2 ], tr( "Normal" ) );
98 cmbPriority->insertItem( m_pic_priority[ 3 ], tr( "Low" ) ); 96 cmbPriority->insertItem( m_pic_priority[ 3 ], tr( "Low" ) );
99 cmbPriority->insertItem( m_pic_priority[ 4 ], tr( "Very Low" ) ); 97 cmbPriority->insertItem( m_pic_priority[ 4 ], tr( "Very Low" ) );
100 cmbPriority->setCurrentItem( 2 ); 98 cmbPriority->setCurrentItem( 2 );
101 layout->addWidget( cmbPriority, 2, 1 ); 99 layout->addWidget( cmbPriority, 2, 1 );
102 QWhatsThis::add( cmbPriority, tr( "Select priority of task here." ) ); 100 QWhatsThis::add( cmbPriority, tr( "Select priority of task here." ) );
103 101
104 // Category 102 // Category
105 label = new QLabel( tr( "Category:" ), container ); 103 label = new QLabel( tr( "Category:" ), container );
106 layout->addWidget( label, 3, 0 ); 104 layout->addWidget( label, 3, 0 );
107 QWhatsThis::add( label, tr( "Select category to organize this task with." ) ); 105 QWhatsThis::add( label, tr( "Select category to organize this task with." ) );
108 cmbCategory = new CategorySelect( container ); 106 cmbCategory = new CategorySelect( container );
109 layout->addWidget( cmbCategory, 3, 1 ); 107 layout->addWidget( cmbCategory, 3, 1 );
110 QWhatsThis::add( cmbCategory, tr( "Select category to organize this task with." ) ); 108 QWhatsThis::add( cmbCategory, tr( "Select category to organize this task with." ) );
111 109
112 // Recurrence 110 // Recurrence
113 ckbRecurrence = new QCheckBox( tr( "Recurring task" ), container ); 111 ckbRecurrence = new QCheckBox( tr( "Recurring task" ), container );
114 layout->addMultiCellWidget( ckbRecurrence, 4, 4, 0, 1 ); 112 layout->addMultiCellWidget( ckbRecurrence, 4, 4, 0, 1 );
115 QWhatsThis::add( ckbRecurrence, tr( "Click here if task happens on a regular basis. If selected, frequency can be set on the Recurrence tab." ) ); 113 QWhatsThis::add( ckbRecurrence, tr( "Click here if task happens on a regular basis. If selected, frequency can be set on the Recurrence tab." ) );
116 connect( ckbRecurrence, SIGNAL(clicked() ), this, SLOT( slotRecClicked() ) ); 114 connect( ckbRecurrence, SIGNAL(clicked() ), this, SLOT( slotRecClicked() ) );
117 115
118 // Notes 116 // Notes
119 label = new QLabel( tr( "Notes:" ), container ); 117 label = new QLabel( tr( "Description:" ), container );
120 layout->addWidget( label, 5, 0 ); 118 layout->addWidget( label, 5, 0 );
121 QWhatsThis::add( label, tr( "Enter any additional information about this task here." ) ); 119 QWhatsThis::add( label, tr( "Enter any additional information about this task here." ) );
122 mleNotes = new QMultiLineEdit( container ); 120 mleNotes = new QMultiLineEdit( container );
123 mleNotes->setWordWrap( QMultiLineEdit::WidgetWidth ); 121 mleNotes->setWordWrap( QMultiLineEdit::WidgetWidth );
124 layout->addMultiCellWidget( mleNotes, 6, 6, 0, 1 ); 122 layout->addMultiCellWidget( mleNotes, 6, 6, 0, 1 );
125 QWhatsThis::add( mleNotes, tr( "Enter any additional information about this task here." ) ); 123 QWhatsThis::add( mleNotes, tr( "Enter any additional information about this task here." ) );
126} 124}
127 125
128TaskEditorOverView::~TaskEditorOverView() 126TaskEditorOverView::~TaskEditorOverView()
129{ 127{
130} 128}
131 129
132void TaskEditorOverView::load( const OTodo& todo ) 130void TaskEditorOverView::load( const OTodo& todo )
133{ 131{
134 // Description 132 // Description
135 cmbDesc->insertItem( todo.summary(), 0 ); 133 cmbDesc->insertItem( todo.summary(), 0 );
136 cmbDesc->setCurrentItem( 0 ); 134 cmbDesc->setCurrentItem( 0 );
137 135
138 // Priority 136 // Priority
139 cmbPriority->setCurrentItem( todo.priority() - 1 ); 137 cmbPriority->setCurrentItem( todo.priority() - 1 );
140 138
141 // Category 139 // Category
142 cmbCategory->setCategories( todo.categories(), "Todo List", tr( "Todo List" ) ); 140 cmbCategory->setCategories( todo.categories(), "Todo List", tr( "Todo List" ) );
143 141
144 // Recurrence 142 // Recurrence
145 ckbRecurrence->setChecked( todo.hasRecurrence() ); 143 ckbRecurrence->setChecked( todo.hasRecurrence() );
146 emit recurranceEnabled( todo.hasRecurrence() ); 144 emit recurranceEnabled( todo.hasRecurrence() );
147 145
148 // Notes 146 // Notes
149 mleNotes->setText( todo.description() ); 147 mleNotes->setText( todo.description() );
150 148
151} 149}
152 150
153void TaskEditorOverView::save( OTodo &todo ) 151void TaskEditorOverView::save( OTodo &todo )
154{ 152{
155 // Description 153 // Description
156 todo.setSummary( cmbDesc->currentText() ); 154 todo.setSummary( cmbDesc->currentText() );
157 155
158 // Priority 156 // Priority
159 todo.setPriority( cmbPriority->currentItem() + 1 ); 157 todo.setPriority( cmbPriority->currentItem() + 1 );
160 158
161 // Category 159 // Category
162 if ( cmbCategory->currentCategory() != -1 ) 160 if ( cmbCategory->currentCategory() != -1 )
163 { 161 {
164 QArray<int> arr = cmbCategory->currentCategories(); 162 QArray<int> arr = cmbCategory->currentCategories();
165 todo.setCategories( arr ); 163 todo.setCategories( arr );
166 } 164 }
167 165
168 // Recurrence - don't need to save here... 166 // Recurrence - don't need to save here...
169 167
170 // Notes 168 // Notes
171 todo.setDescription( mleNotes->text() ); 169 todo.setDescription( mleNotes->text() );
172} 170}
173 171
174void TaskEditorOverView::slotRecClicked() 172void TaskEditorOverView::slotRecClicked()
175{ 173{
176 emit recurranceEnabled( ckbRecurrence->isChecked() ); 174 emit recurranceEnabled( ckbRecurrence->isChecked() );
177} 175}
diff --git a/core/pim/todo/taskeditorstatus.cpp b/core/pim/todo/taskeditorstatus.cpp
index 0ab4223..98e3cea 100644
--- a/core/pim/todo/taskeditorstatus.cpp
+++ b/core/pim/todo/taskeditorstatus.cpp
@@ -1,306 +1,303 @@
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 "taskeditorstatus.h" 29#include "taskeditorstatus.h"
30 30
31#include <opie/otodo.h> 31#include <opie/otodo.h>
32#include <opie/opimmaintainer.h> 32#include <opie/opimmaintainer.h>
33#include <opie/opimstate.h> 33#include <opie/opimstate.h>
34 34
35#include <qpe/datebookmonth.h> 35#include <qpe/datebookmonth.h>
36#include <qpe/resource.h>
37#include <qpe/timestring.h>
38 36
39#include <qcheckbox.h> 37#include <qcheckbox.h>
40#include <qcombobox.h> 38#include <qcombobox.h>
41#include <qlabel.h> 39#include <qlabel.h>
42#include <qlayout.h> 40#include <qlayout.h>
43#include <qscrollview.h>
44#include <qtoolbutton.h>
45#include <qwhatsthis.h> 41#include <qwhatsthis.h>
46 42
47// FIXME add the hack slots instead of setPopup!!!! 43// FIXME add the hack slots instead of setPopup!!!!
48// drw you shouldn't have removed them 44// drw you shouldn't have removed them
49 45
50TaskEditorStatus::TaskEditorStatus( QWidget* parent, const char* name, WFlags fl ) 46TaskEditorStatus::TaskEditorStatus( QWidget* parent, const char* name, WFlags fl )
51 : QWidget( parent, name, fl ) 47 : QWidget( parent, name, fl )
52{ 48{
53 QDate curDate = QDate::currentDate(); 49 QDate curDate = QDate::currentDate();
54 m_start = m_comp = m_due = curDate; 50 m_start = m_comp = m_due = curDate;
55 QString curDateStr = TimeString::longDateString( curDate ); 51 QString curDateStr = TimeString::longDateString( curDate );
56 52
57 QVBoxLayout *vb = new QVBoxLayout( this ); 53 QVBoxLayout *vb = new QVBoxLayout( this );
58 54
59 QScrollView *sv = new QScrollView( this ); 55 QScrollView *sv = new QScrollView( this );
60 vb->addWidget( sv ); 56 vb->addWidget( sv );
61 sv->setResizePolicy( QScrollView::AutoOneFit ); 57 sv->setResizePolicy( QScrollView::AutoOneFit );
62 sv->setFrameStyle( QFrame::NoFrame ); 58 sv->setFrameStyle( QFrame::NoFrame );
63 59
64 QWidget *container = new QWidget( sv->viewport() ); 60 QWidget *container = new QWidget( sv->viewport() );
65 sv->addChild( container ); 61 sv->addChild( container );
66 62
67 QGridLayout *layout = new QGridLayout( container, 7, 3, 4, 4 ); 63 QGridLayout *layout = new QGridLayout( container, 7, 3, 4, 4 );
68 64
69 // Status 65 // Status
70 QLabel *label = new QLabel( tr( "Status:" ), container ); 66 QLabel *label = new QLabel( tr( "Status:" ), container );
71 layout->addWidget( label, 0, 0 ); 67 layout->addWidget( label, 0, 0 );
72 QWhatsThis::add( label, tr( "Click here to set the current status of this task." ) ); 68 QWhatsThis::add( label, tr( "Click here to set the current status of this task." ) );
73 cmbStatus = new QComboBox( FALSE, container ); 69 cmbStatus = new QComboBox( FALSE, container );
74 cmbStatus->insertItem( tr( "Started" ) ); 70 cmbStatus->insertItem( tr( "Started" ) );
75 cmbStatus->insertItem( tr( "Postponed" ) ); 71 cmbStatus->insertItem( tr( "Postponed" ) );
76 cmbStatus->insertItem( tr( "Finished" ) ); 72 cmbStatus->insertItem( tr( "Finished" ) );
77 cmbStatus->insertItem( tr( "Not started" ) ); 73 cmbStatus->insertItem( tr( "Not started" ) );
78 layout->addMultiCellWidget( cmbStatus, 0, 0, 1, 2 ); 74 layout->addMultiCellWidget( cmbStatus, 0, 0, 1, 2 );
79 QWhatsThis::add( cmbStatus, tr( "Click here to set the current status of this task." ) ); 75 QWhatsThis::add( cmbStatus, tr( "Click here to set the current status of this task." ) );
80 76
81 // Progress 77 // Progress
82 label = new QLabel( tr( "Progress:" ), container ); 78 label = new QLabel( tr( "Progress:" ), container );
83 layout->addWidget( label, 1, 0 ); 79 layout->addWidget( label, 1, 0 );
84 QWhatsThis::add( label, tr( "Select progress made on this task here." ) ); 80 QWhatsThis::add( label, tr( "Select progress made on this task here." ) );
85 cmbProgress = new QComboBox( FALSE, container ); 81 cmbProgress = new QComboBox( FALSE, container );
86 cmbProgress->insertItem( tr( "0 %" ) ); 82 cmbProgress->insertItem( tr( "0 %" ) );
87 cmbProgress->insertItem( tr( "20 %" ) ); 83 cmbProgress->insertItem( tr( "20 %" ) );
88 cmbProgress->insertItem( tr( "40 %" ) ); 84 cmbProgress->insertItem( tr( "40 %" ) );
89 cmbProgress->insertItem( tr( "60 %" ) ); 85 cmbProgress->insertItem( tr( "60 %" ) );
90 cmbProgress->insertItem( tr( "80 %" ) ); 86 cmbProgress->insertItem( tr( "80 %" ) );
91 cmbProgress->insertItem( tr( "100 %" ) ); 87 cmbProgress->insertItem( tr( "100 %" ) );
92 layout->addMultiCellWidget( cmbProgress, 1, 1, 1, 2 ); 88 layout->addMultiCellWidget( cmbProgress, 1, 1, 1, 2 );
93 QWhatsThis::add( cmbProgress, tr( "Select progress made on this task here." ) ); 89 QWhatsThis::add( cmbProgress, tr( "Select progress made on this task here." ) );
94 90
95 // Start date 91 // Start date
96 ckbStart = new QCheckBox( tr( "Start Date:" ), container ); 92 ckbStart = new QCheckBox( tr( "Start Date:" ), container );
97 layout->addWidget( ckbStart, 2, 0 ); 93 layout->addWidget( ckbStart, 2, 0 );
98 QWhatsThis::add( ckbStart, tr( "Click here to set the date this task was started." ) ); 94 QWhatsThis::add( ckbStart, tr( "Click here to set the date this task was started." ) );
99 connect( ckbStart, SIGNAL( clicked() ), this, SLOT( slotStartChecked() ) ); 95 connect( ckbStart, SIGNAL( clicked() ), this, SLOT( slotStartChecked() ) );
100 btnStart = new QPushButton( curDateStr, container ); 96 btnStart = new QPushButton( curDateStr, container );
101 btnStart->setEnabled( FALSE ); 97 btnStart->setEnabled( FALSE );
102 layout->addMultiCellWidget( btnStart, 2, 2, 1, 2 ); 98 layout->addMultiCellWidget( btnStart, 2, 2, 1, 2 );
103 QWhatsThis::add( btnStart, tr( "Click here to set the date this task was started." ) ); 99 QWhatsThis::add( btnStart, tr( "Click here to set the date this task was started." ) );
104 QPopupMenu *popup = new QPopupMenu( this ); 100 QPopupMenu *popup = new QPopupMenu( this );
105 m_startBook = new DateBookMonth( popup, 0, TRUE ); 101 m_startBook = new DateBookMonth( popup, 0, TRUE );
106 popup->insertItem( m_startBook ); 102 popup->insertItem( m_startBook );
107 btnStart->setPopup( popup ); 103 btnStart->setPopup( popup );
108 connect( m_startBook, SIGNAL( dateClicked( int, int, int ) ), 104 connect( m_startBook, SIGNAL( dateClicked( int, int, int ) ),
109 this, SLOT( slotStartChanged( int, int, int ) ) ); 105 this, SLOT( slotStartChanged( int, int, int ) ) );
110 106
111 // Due date 107 // Due date
112 ckbDue = new QCheckBox( tr( "Due Date:" ), container ); 108 ckbDue = new QCheckBox( tr( "Due Date:" ), container );
113 layout->addWidget( ckbDue, 3, 0 ); 109 layout->addWidget( ckbDue, 3, 0 );
114 QWhatsThis::add( ckbDue, tr( "Click here to set the date this task needs to be completed by." ) ); 110 QWhatsThis::add( ckbDue, tr( "Click here to set the date this task needs to be completed by." ) );
115 connect( ckbDue, SIGNAL( clicked() ), this, SLOT( slotDueChecked() ) ); 111 connect( ckbDue, SIGNAL( clicked() ), this, SLOT( slotDueChecked() ) );
116 btnDue = new QPushButton( curDateStr, container ); 112 btnDue = new QPushButton( curDateStr, container );
117 btnDue->setEnabled( FALSE ); 113 btnDue->setEnabled( FALSE );
118 layout->addMultiCellWidget( btnDue, 3, 3, 1, 2 ); 114 layout->addMultiCellWidget( btnDue, 3, 3, 1, 2 );
119 QWhatsThis::add( btnDue, tr( "Click here to set the date this task needs to be completed by." ) ); 115 QWhatsThis::add( btnDue, tr( "Click here to set the date this task needs to be completed by." ) );
120 popup = new QPopupMenu( this ); 116 popup = new QPopupMenu( this );
121 m_dueBook = new DateBookMonth( popup, 0, TRUE ); 117 m_dueBook = new DateBookMonth( popup, 0, TRUE );
122 popup->insertItem( m_dueBook ); 118 popup->insertItem( m_dueBook );
123 btnDue->setPopup( popup ); 119 btnDue->setPopup( popup );
124 connect( m_dueBook, SIGNAL( dateClicked( int, int, int ) ), 120 connect( m_dueBook, SIGNAL( dateClicked( int, int, int ) ),
125 this, SLOT( slotDueChanged( int, int, int ) ) ); 121 this, SLOT( slotDueChanged( int, int, int ) ) );
126 122
127 // Completed 123 // Completed
128 ckbComp = new QCheckBox( tr( "Completed:" ), container ); 124 ckbComp = new QCheckBox( tr( "Completed:" ), container );
129 layout->addWidget( ckbComp, 4, 0 ); 125 layout->addWidget( ckbComp, 4, 0 );
130 QWhatsThis::add( ckbComp, tr( "Click here to mark this task as completed." ) ); 126 QWhatsThis::add( ckbComp, tr( "Click here to mark this task as completed." ) );
131 connect( ckbComp, SIGNAL( clicked() ), this, SLOT( slotCompChecked() ) ); 127 connect( ckbComp, SIGNAL( clicked() ), this, SLOT( slotCompChecked() ) );
132 btnComp = new QPushButton( curDateStr, container ); 128 btnComp = new QPushButton( curDateStr, container );
133 btnComp->setEnabled( FALSE ); 129 btnComp->setEnabled( FALSE );
134 layout->addMultiCellWidget( btnComp, 4, 4, 1, 2 ); 130 layout->addMultiCellWidget( btnComp, 4, 4, 1, 2 );
135 QWhatsThis::add( btnComp, tr( "Click here to set the date this task was completed." ) ); 131 QWhatsThis::add( btnComp, tr( "Click here to set the date this task was completed." ) );
136 popup = new QPopupMenu( this ); 132 popup = new QPopupMenu( this );
137 m_compBook = new DateBookMonth( popup, 0, TRUE ); 133 m_compBook = new DateBookMonth( popup, 0, TRUE );
138 popup->insertItem( m_compBook ); 134 popup->insertItem( m_compBook );
139 btnComp->setPopup( popup ); 135 btnComp->setPopup( popup );
140 connect( m_compBook, SIGNAL( dateClicked( int, int, int ) ), 136 connect( m_compBook, SIGNAL( dateClicked( int, int, int ) ),
141 this, SLOT( slotCompChanged( int, int, int ) ) ); 137 this, SLOT( slotCompChanged( int, int, int ) ) );
142 138
143 QSpacerItem *spacer = new QSpacerItem( 5, 5, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding ); 139 QSpacerItem *spacer = new QSpacerItem( 5, 5, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding );
144 layout->addItem( spacer, 5, 0 ); 140 layout->addItem( spacer, 5, 0 );
145 141
146 // Maintainer mode 142 // Maintainer mode
147#if 0 143#if 0
148 label = new QLabel( tr( "Maintainer Mode:" ), container ); 144 label = new QLabel( tr( "Maintainer Mode:" ), container );
149 layout->addWidget( label, 6, 0 ); 145 layout->addWidget( label, 6, 0 );
150 QWhatsThis::add( label, tr( "Click here to set the maintainer's role." ) ); 146 QWhatsThis::add( label, tr( "Click here to set the maintainer's role." ) );
151 cmbMaintMode = new QComboBox( FALSE, container ); 147 cmbMaintMode = new QComboBox( FALSE, container );
152 cmbMaintMode->insertItem( tr( "Nothing" ) ); 148 cmbMaintMode->insertItem( tr( "Nothing" ) );
153 cmbMaintMode->insertItem( tr( "Responsible" ) ); 149 cmbMaintMode->insertItem( tr( "Responsible" ) );
154 cmbMaintMode->insertItem( tr( "Done By" ) ); 150 cmbMaintMode->insertItem( tr( "Done By" ) );
155 cmbMaintMode->insertItem( tr( "Coordinating" ) ); 151 cmbMaintMode->insertItem( tr( "Coordinating" ) );
156// layout->addMultiCellWidget( cmbMaintMode, 6, 6, 1, 2 ); 152// layout->addMultiCellWidget( cmbMaintMode, 6, 6, 1, 2 );
157 QWhatsThis::add( cmbMaintMode, tr( "Click here to set the maintainer's role." ) ); 153 QWhatsThis::add( cmbMaintMode, tr( "Click here to set the maintainer's role." ) );
158 154
159 // Maintainer 155 // Maintainer
160 label = new QLabel( tr( "Maintainer:" ), container ); 156 label = new QLabel( tr( "Maintainer:" ), container );
161 layout->addWidget( label, 7, 0 ); 157 layout->addWidget( label, 7, 0 );
162 QWhatsThis::add( label, tr( "This is the name of the current task maintainer." ) ); 158 QWhatsThis::add( label, tr( "This is the name of the current task maintainer." ) );
163 txtMaintainer = new QLabel( tr( "test" ), container ); 159 txtMaintainer = new QLabel( tr( "test" ), container );
164 txtMaintainer->setTextFormat( QLabel::RichText ); 160 txtMaintainer->setTextFormat( QLabel::RichText );
165 layout->addWidget( txtMaintainer, 7, 1 ); 161 layout->addWidget( txtMaintainer, 7, 1 );
166 QWhatsThis::add( txtMaintainer, tr( "This is the name of the current task maintainer." ) ); 162 QWhatsThis::add( txtMaintainer, tr( "This is the name of the current task maintainer." ) );
167 tbtMaintainer = new QToolButton( container ); 163 tbtMaintainer = new QToolButton( container );
168 tbtMaintainer->setPixmap( Resource::loadPixmap( "todo/more" ) ); 164 tbtMaintainer->setPixmap( Resource::loadPixmap( "todo/more" ) );
169// layout->addWidget( tbtMaintainer, 7, 2 ); 165// layout->addWidget( tbtMaintainer, 7, 2 );
170 QWhatsThis::add( tbtMaintainer, tr( "Click here to select the task maintainer." ) ); 166 QWhatsThis::add( tbtMaintainer, tr( "Click here to select the task maintainer." ) );
171#endif 167#endif
172} 168}
173 169
174TaskEditorStatus::~TaskEditorStatus() 170TaskEditorStatus::~TaskEditorStatus()
175{ 171{
176} 172}
177 173
178void TaskEditorStatus::load( const OTodo &todo ) 174void TaskEditorStatus::load( const OTodo &todo )
179{ 175{
180 QDate date = QDate::currentDate(); 176 QDate date = QDate::currentDate();
181 QString str = TimeString::longDateString( date ); 177 QString str = TimeString::longDateString( date );
182 178
183 // Status 179 // Status
184 int state = todo.hasState()? todo.state().state() : OPimState::NotStarted; 180 int state = todo.hasState()? todo.state().state() : OPimState::NotStarted;
185 if ( state == OPimState::Undefined ) 181 if ( state == OPimState::Undefined )
186 state = OPimState::NotStarted; 182 state = OPimState::NotStarted;
187 cmbStatus->setCurrentItem( state ); 183 cmbStatus->setCurrentItem( state );
188 184
189 // Progress 185 // Progress
190 cmbProgress->setCurrentItem( todo.progress() / 20 ); 186 cmbProgress->setCurrentItem( todo.progress() / 20 );
191 187
192 // Start date 188 // Start date
193 ckbStart->setChecked( todo.hasStartDate() ); 189 ckbStart->setChecked( todo.hasStartDate() );
194 btnStart->setEnabled( todo.hasStartDate() ); 190 btnStart->setEnabled( todo.hasStartDate() );
195 if ( todo.hasStartDate() ) 191 if ( todo.hasStartDate() )
196 { 192 {
197 m_start = todo.startDate(); 193 m_start = todo.startDate();
198 btnStart->setText( TimeString::longDateString( m_start ) ); 194 btnStart->setText( TimeString::longDateString( m_start ) );
199 } 195 }
200 else 196 else
201 btnStart->setText( str ); 197 btnStart->setText( str );
202 198
203 // Due date 199 // Due date
204 ckbDue->setChecked( todo.hasDueDate() ); 200 ckbDue->setChecked( todo.hasDueDate() );
205 btnDue->setText( TimeString::longDateString( todo.dueDate() ) ); 201 btnDue->setText( TimeString::longDateString( todo.dueDate() ) );
206 btnDue->setEnabled( todo.hasDueDate() ); 202 btnDue->setEnabled( todo.hasDueDate() );
207 m_due = todo.dueDate(); 203 m_due = todo.dueDate();
208 204
209 // Completed 205 // Completed
210 ckbComp->setChecked( todo.isCompleted() ); 206 ckbComp->setChecked( todo.isCompleted() );
211 btnComp->setEnabled( todo.hasCompletedDate() ); 207 btnComp->setEnabled( todo.hasCompletedDate() );
212 if ( todo.hasCompletedDate() ) 208 if ( todo.hasCompletedDate() )
213 { 209 {
214 m_comp = todo.completedDate(); 210 m_comp = todo.completedDate();
215 btnComp->setText( TimeString::longDateString( m_comp ) ); 211 btnComp->setText( TimeString::longDateString( m_comp ) );
216 } 212 }
217 else 213 else
218 btnComp->setText( str ); 214 btnComp->setText( str );
219 215
220 // Maintainer Mode 216 // Maintainer Mode
221#if 0 217#if 0
222 state = todo.hasMaintainer() ? todo.maintainer().mode() : OPimMaintainer::Nothing; 218 state = todo.hasMaintainer() ? todo.maintainer().mode() : OPimMaintainer::Nothing;
223 if ( state == OPimMaintainer::Undefined ) 219 if ( state == OPimMaintainer::Undefined )
224 state = OPimMaintainer::Nothing; 220 state = OPimMaintainer::Nothing;
225 cmbMaintMode->setCurrentItem( state ); 221 cmbMaintMode->setCurrentItem( state );
226#endif 222#endif
227 // Maintainer - not implemented yet 223 // Maintainer - not implemented yet
228} 224}
229 225
230void TaskEditorStatus::save( OTodo &todo ) 226void TaskEditorStatus::save( OTodo &todo )
231{ 227{
232 QDate inval; 228 QDate inval;
233 229
234 // Status 230 // Status
235 todo.setState( OPimState( cmbStatus->currentItem() ) ); 231 todo.setState( OPimState( cmbStatus->currentItem() ) );
236 232
237 // Progress 233 // Progress
238 todo.setProgress( cmbProgress->currentItem() * 20 ); 234 todo.setProgress( cmbProgress->currentItem() * 20 );
239 235
240 // Start date 236 // Start date
241 if ( ckbStart->isChecked() ) 237 if ( ckbStart->isChecked() )
242 { 238 {
243 todo.setStartDate( m_start ); 239 todo.setStartDate( m_start );
244 } 240 }
245 else 241 else
246 todo.setStartDate( inval ); 242 todo.setStartDate( inval );
247 243
248 // Due date 244 // Due date
249 if ( ckbDue->isChecked() ) 245 if ( ckbDue->isChecked() )
250 { 246 {
251 todo.setDueDate( m_due ); 247 todo.setDueDate( m_due );
252 todo.setHasDueDate( true ); 248 todo.setHasDueDate( true );
253 } 249 }
254 else 250 else
255 todo.setHasDueDate( false ); 251 todo.setHasDueDate( false );
256 252
257 // Completed 253 // Completed
258 todo.setCompleted( ckbComp->isChecked() ); 254 todo.setCompleted( ckbComp->isChecked() );
259 if ( ckbComp->isChecked() ) 255 if ( ckbComp->isChecked() )
260 { 256 {
261 todo.setCompletedDate( m_comp ); 257 todo.setCompletedDate( m_comp );
262 } 258 }
263 else 259 else
264 todo.setCompletedDate( inval ); 260 todo.setCompletedDate( inval );
265 261
266#if 0 262#if 0
267 // Maintainer mode - not implemented yet 263 // Maintainer mode - not implemented yet
268 264
269 // Maintainer 265 // Maintainer
270 /* TODO - resolve name to uid.....*/ 266 /* TODO - resolve name to uid.....*/
271 todo.setMaintainer( OPimMaintainer( cmbMaintMode->currentItem(), -10 ) ); 267 todo.setMaintainer( OPimMaintainer( cmbMaintMode->currentItem(), -10 ) );
272#endif 268#endif
273} 269}
274 270
275void TaskEditorStatus::slotStartChecked() 271void TaskEditorStatus::slotStartChecked()
276{ 272{
277 btnStart->setEnabled( ckbStart->isChecked() ); 273 btnStart->setEnabled( ckbStart->isChecked() );
278} 274}
279 275
280void TaskEditorStatus::slotCompChecked() 276void TaskEditorStatus::slotCompChecked()
281{ 277{
282 btnComp->setEnabled( ckbComp->isChecked() ); 278 btnComp->setEnabled( ckbComp->isChecked() );
283} 279}
284 280
285void TaskEditorStatus::slotDueChecked() 281void TaskEditorStatus::slotDueChecked()
286{ 282{
287 btnDue->setEnabled( ckbDue->isChecked() ); 283 btnDue->setEnabled( ckbDue->isChecked() );
288} 284}
289 285
290void TaskEditorStatus::slotStartChanged(int y, int m, int d) 286void TaskEditorStatus::slotStartChanged(int y, int m, int d)
291{ 287{
292 m_start.setYMD( y, m, d ); 288 m_start.setYMD( y, m, d );
293 btnStart->setText( TimeString::longDateString( m_start ) ); 289 btnStart->setText( TimeString::longDateString( m_start ) );
294} 290}
295 291
296void TaskEditorStatus::slotCompChanged(int y, int m, int d) 292void TaskEditorStatus::slotCompChanged(int y, int m, int d)
297{ 293{
298 m_comp.setYMD( y, m, d ); 294 m_comp.setYMD( y, m, d );
299 btnComp->setText( TimeString::longDateString( m_comp ) ); 295 btnComp->setText( TimeString::longDateString( m_comp ) );
300} 296}
301 297
302void TaskEditorStatus::slotDueChanged(int y, int m, int d) 298void TaskEditorStatus::slotDueChanged(int y, int m, int d)
303{ 299{
304 m_due.setYMD( y, m, d ); 300 m_due.setYMD( y, m, d );
305 btnDue->setText( TimeString::longDateString( m_due ) ); 301 btnDue->setText( TimeString::longDateString( m_due ) );
302 emit dueDateChanged( m_due );
306} 303}
diff --git a/core/pim/todo/templatedialogimpl.cpp b/core/pim/todo/templatedialogimpl.cpp
index fed92f0..c2306ac 100644
--- a/core/pim/todo/templatedialogimpl.cpp
+++ b/core/pim/todo/templatedialogimpl.cpp
@@ -1,119 +1,118 @@
1#include <qlistview.h>
2#include <qlineedit.h> 1#include <qlineedit.h>
3 2
4#include "mainwindow.h" 3#include "mainwindow.h"
5#include "todoeditor.h" 4#include "todoeditor.h"
6#include "todotemplatemanager.h" 5#include "todotemplatemanager.h"
7#include "templatedialogimpl.h" 6#include "templatedialogimpl.h"
8 7
9 8
10using namespace Todo; 9using namespace Todo;
11 10
12/* TRANSLATOR Todo::TemplateDialogImpl */ 11/* TRANSLATOR Todo::TemplateDialogImpl */
13 12
14namespace { 13namespace {
15 class TemplateListItem : public QListViewItem { 14 class TemplateListItem : public QListViewItem {
16 public: 15 public:
17 TemplateListItem( QListView*, 16 TemplateListItem( QListView*,
18 const QString& name, 17 const QString& name,
19 const OTodo& ); 18 const OTodo& );
20 ~TemplateListItem(); 19 ~TemplateListItem();
21 20
22 OTodo event()const; 21 OTodo event()const;
23 QString text()const; 22 QString text()const;
24 void setText(const QString& str ); 23 void setText(const QString& str );
25 void setEvent( const OTodo& ); 24 void setEvent( const OTodo& );
26 private: 25 private:
27 QString m_name; 26 QString m_name;
28 OTodo m_ev; 27 OTodo m_ev;
29 }; 28 };
30 29
31 /* implementation */ 30 /* implementation */
32 TemplateListItem::TemplateListItem( QListView* view, 31 TemplateListItem::TemplateListItem( QListView* view,
33 const QString& text, 32 const QString& text,
34 const OTodo& ev ) 33 const OTodo& ev )
35 : QListViewItem( view ), m_name( text ), m_ev( ev ) 34 : QListViewItem( view ), m_name( text ), m_ev( ev )
36 { 35 {
37 QListViewItem::setText(0, m_name ); 36 QListViewItem::setText(0, m_name );
38 } 37 }
39 TemplateListItem::~TemplateListItem() {} 38 TemplateListItem::~TemplateListItem() {}
40 OTodo TemplateListItem::event() const { 39 OTodo TemplateListItem::event() const {
41 return m_ev; 40 return m_ev;
42 } 41 }
43 QString TemplateListItem::text()const { 42 QString TemplateListItem::text()const {
44 return m_name; 43 return m_name;
45 } 44 }
46 void TemplateListItem::setText( const QString& str ) { 45 void TemplateListItem::setText( const QString& str ) {
47 QListViewItem::setText(0, str ); 46 QListViewItem::setText(0, str );
48 m_name = str; 47 m_name = str;
49 } 48 }
50 void TemplateListItem::setEvent( const OTodo& ev) { 49 void TemplateListItem::setEvent( const OTodo& ev) {
51 m_ev = ev; 50 m_ev = ev;
52 } 51 }
53} 52}
54 53
55TemplateDialogImpl::TemplateDialogImpl( MainWindow* win, 54TemplateDialogImpl::TemplateDialogImpl( MainWindow* win,
56 TemplateManager* man ) 55 TemplateManager* man )
57 : TemplateDialog( win ), m_win( win), m_man( man ) 56 : TemplateDialog( win ), m_win( win), m_man( man )
58{ 57{
59 /* fill the listview */ 58 /* fill the listview */
60 /* not the fastest way.... */ 59 /* not the fastest way.... */
61 QStringList list = man->templates(); 60 QStringList list = man->templates();
62 for (QStringList::Iterator it = list.begin(); 61 for (QStringList::Iterator it = list.begin();
63 it != list.end(); ++it ) { 62 it != list.end(); ++it ) {
64 new TemplateListItem( listView(), (*it), man->templateEvent( (*it) ) ); 63 new TemplateListItem( listView(), (*it), man->templateEvent( (*it) ) );
65 } 64 }
66 listView()->addColumn( QWidget::tr("Name") ); 65 listView()->addColumn( QWidget::tr("Name") );
67 66
68 connect( listView(), SIGNAL(clicked(QListViewItem*) ), 67 connect( listView(), SIGNAL(clicked(QListViewItem*) ),
69 this, SLOT(slotClicked(QListViewItem*) ) ); 68 this, SLOT(slotClicked(QListViewItem*) ) );
70} 69}
71TemplateDialogImpl::~TemplateDialogImpl() { 70TemplateDialogImpl::~TemplateDialogImpl() {
72 71
73} 72}
74void TemplateDialogImpl::slotAdd() { 73void TemplateDialogImpl::slotAdd() {
75 QString str = QWidget::tr("New Template %1").arg( listView()->childCount() ); 74 QString str = QWidget::tr("New Template %1").arg( listView()->childCount() );
76 OTodo ev; 75 OTodo ev;
77 m_man->addEvent(str, ev); 76 m_man->addEvent(str, ev);
78 new TemplateListItem( listView(), str, ev ); 77 new TemplateListItem( listView(), str, ev );
79} 78}
80void TemplateDialogImpl::slotRemove() { 79void TemplateDialogImpl::slotRemove() {
81 TemplateListItem* item = (TemplateListItem*) listView()->currentItem(); 80 TemplateListItem* item = (TemplateListItem*) listView()->currentItem();
82 listView()->takeItem( item ); 81 listView()->takeItem( item );
83 82
84 m_man->removeEvent( item->text() ); 83 m_man->removeEvent( item->text() );
85 84
86 delete item; 85 delete item;
87} 86}
88void TemplateDialogImpl::slotEdit() { 87void TemplateDialogImpl::slotEdit() {
89 TemplateListItem* item = (TemplateListItem*)listView()->currentItem(); 88 TemplateListItem* item = (TemplateListItem*)listView()->currentItem();
90 OTodo ev = m_win->currentEditor()->edit( m_win, item->event() ); 89 OTodo ev = m_win->currentEditor()->edit( m_win, item->event() );
91 if ( m_win->currentEditor()->accepted() ) { 90 if ( m_win->currentEditor()->accepted() ) {
92 item->setEvent( ev ); 91 item->setEvent( ev );
93 m_man->removeEvent( item->text() ); 92 m_man->removeEvent( item->text() );
94 m_man->addEvent( item->text(), ev ); 93 m_man->addEvent( item->text(), ev );
95 } 94 }
96} 95}
97/* 96/*
98 * we need to update 97 * we need to update
99 * the text 98 * the text
100 */ 99 */
101 100
102void TemplateDialogImpl::slotReturn() { 101void TemplateDialogImpl::slotReturn() {
103 TemplateListItem* tbl = (TemplateListItem*)listView()->currentItem(); 102 TemplateListItem* tbl = (TemplateListItem*)listView()->currentItem();
104 103
105 if (tbl->text() != edit()->text() ) { 104 if (tbl->text() != edit()->text() ) {
106 m_man->removeEvent( tbl->text() ); 105 m_man->removeEvent( tbl->text() );
107 tbl->setText( edit()->text() ); 106 tbl->setText( edit()->text() );
108 m_man->addEvent( tbl->text(), tbl->event() ); 107 m_man->addEvent( tbl->text(), tbl->event() );
109 } 108 }
110} 109}
111/* update the lineedit when changing */ 110/* update the lineedit when changing */
112void TemplateDialogImpl::slotClicked( QListViewItem* item) { 111void TemplateDialogImpl::slotClicked( QListViewItem* item) {
113 if (!item) 112 if (!item)
114 return; 113 return;
115 114
116 TemplateListItem* tbl = static_cast<TemplateListItem*>(item); 115 TemplateListItem* tbl = static_cast<TemplateListItem*>(item);
117 edit()->setText( tbl->text() ); 116 edit()->setText( tbl->text() );
118} 117}
119 118
diff --git a/core/pim/todo/textviewshow.cpp b/core/pim/todo/textviewshow.cpp
index fe8a9c8..35ea74b 100644
--- a/core/pim/todo/textviewshow.cpp
+++ b/core/pim/todo/textviewshow.cpp
@@ -1,32 +1,48 @@
1#include "mainwindow.h"
2#include "textviewshow.h" 1#include "textviewshow.h"
3 2
4using namespace Todo; 3using namespace Todo;
5 4
6TextViewShow::TextViewShow( QWidget* parent, MainWindow* win) 5TextViewShow::TextViewShow( QWidget* parent, MainWindow* win)
7 : QTextView( parent ), TodoShow(win) { 6 : QTextView( parent ), TodoShow(win) {
8 7
9} 8}
10TextViewShow::~TextViewShow() { 9TextViewShow::~TextViewShow() {
11} 10}
12QString TextViewShow::type()const { 11QString TextViewShow::type()const {
13 return QString::fromLatin1("TextViewShow"); 12 return QString::fromLatin1("TextViewShow");
14} 13}
15void TextViewShow::slotShow( const OTodo& ev ) { 14void TextViewShow::slotShow( const OTodo& ev ) {
16 setText( ev.toRichText() ); 15 setText( ev.toRichText() );
17} 16}
18QWidget* TextViewShow::widget() { 17QWidget* TextViewShow::widget() {
19 return this; 18 return this;
20} 19}
21void TextViewShow::keyPressEvent( QKeyEvent* event ) { 20void TextViewShow::keyPressEvent( QKeyEvent* event ) {
22 switch( event->key() ) { 21 switch( event->key() ) {
22 case Qt::Key_Up:
23 if ( ( visibleHeight() < contentsHeight() ) &&
24 ( verticalScrollBar()->value() > verticalScrollBar()->minValue() ) )
25 scrollBy( 0, -(visibleHeight()-20) );
26 else
27 showPrev();
28 break;
29 case Qt::Key_Down:
30 if ( ( visibleHeight() < contentsHeight() ) &&
31 ( verticalScrollBar()->value() < verticalScrollBar()->maxValue() ) )
32 scrollBy( 0, visibleHeight()-20 );
33 else
34 showNext();
35 break;
36 case Qt::Key_Left:
37 case Qt::Key_Right:
23 case Qt::Key_F33: 38 case Qt::Key_F33:
24 case Qt::Key_Enter: 39 case Qt::Key_Enter:
25 case Qt::Key_Return: 40 case Qt::Key_Return:
41 case Qt::Key_Space:
26 escapeView(); 42 escapeView();
27 break; 43 break;
28 default: 44 default:
29 QTextView::keyPressEvent( event ); 45 QTextView::keyPressEvent( event );
30 break; 46 break;
31 } 47 }
32} 48}
diff --git a/core/pim/todo/todomanager.cpp b/core/pim/todo/todomanager.cpp
index df2e711..501cca7 100644
--- a/core/pim/todo/todomanager.cpp
+++ b/core/pim/todo/todomanager.cpp
@@ -1,128 +1,127 @@
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#include <qdatetime.h>
29#include <qpe/categoryselect.h> 28#include <qpe/categoryselect.h>
30 29
31#include "todomanager.h" 30#include "todomanager.h"
32 31
33using namespace Todo; 32using namespace Todo;
34 33
35TodoManager::TodoManager( QObject *obj ) 34TodoManager::TodoManager( QObject *obj )
36 : QObject( obj ) { 35 : QObject( obj ) {
37 m_db = 0l; 36 m_db = 0l;
38 QTime time; 37 QTime time;
39 time.start(); 38 time.start();
40 int el = time.elapsed(); 39 int el = time.elapsed();
41 qWarning("QTimer for loading %d", el/1000 ); 40 qWarning("QTimer for loading %d", el/1000 );
42} 41}
43TodoManager::~TodoManager() { 42TodoManager::~TodoManager() {
44 delete m_db; 43 delete m_db;
45} 44}
46OTodo TodoManager::event(int uid ) { 45OTodo TodoManager::event(int uid ) {
47 return m_db->find( uid ); 46 return m_db->find( uid );
48} 47}
49void TodoManager::updateList() { 48void TodoManager::updateList() {
50 qWarning("update list"); 49 qWarning("update list");
51 m_list = m_db->allRecords(); 50 m_list = m_db->allRecords();
52} 51}
53OTodoAccess::List TodoManager::list() const{ 52OTodoAccess::List TodoManager::list() const{
54 return m_list; 53 return m_list;
55} 54}
56OTodoAccess::List TodoManager::sorted( bool asc, int so, int f, int cat ) { 55OTodoAccess::List TodoManager::sorted( bool asc, int so, int f, int cat ) {
57 return m_db->sorted( asc, so, f, cat ); 56 return m_db->sorted( asc, so, f, cat );
58} 57}
59OTodoAccess::List::Iterator TodoManager::overDue() { 58OTodoAccess::List::Iterator TodoManager::overDue() {
60 int filter = 2 | 1; 59 int filter = 2 | 1;
61 m_list = m_db->sorted(m_asc, m_sortOrder, filter, m_ca ); 60 m_list = m_db->sorted(m_asc, m_sortOrder, filter, m_ca );
62 m_it = m_list.begin(); 61 m_it = m_list.begin();
63 return m_it; 62 return m_it;
64} 63}
65OTodoAccess::List::Iterator TodoManager::fromTo( const QDate& start, 64OTodoAccess::List::Iterator TodoManager::fromTo( const QDate& start,
66 const QDate& end ) { 65 const QDate& end ) {
67 m_list = m_db->effectiveToDos( start, end ); 66 m_list = m_db->effectiveToDos( start, end );
68 m_it = m_list.begin(); 67 m_it = m_list.begin();
69 return m_it; 68 return m_it;
70} 69}
71OTodoAccess::List::Iterator TodoManager::query( const OTodo& ev, int query ) { 70OTodoAccess::List::Iterator TodoManager::query( const OTodo& ev, int query ) {
72 m_list = m_db->queryByExample( ev, query ); 71 m_list = m_db->queryByExample( ev, query );
73 m_it = m_list.begin(); 72 m_it = m_list.begin();
74 return m_it; 73 return m_it;
75} 74}
76OTodoAccess* TodoManager::todoDB() { 75OTodoAccess* TodoManager::todoDB() {
77 return m_db; 76 return m_db;
78} 77}
79void TodoManager::add( const OTodo& ev ) { 78void TodoManager::add( const OTodo& ev ) {
80 m_db->add( ev ); 79 m_db->add( ev );
81} 80}
82void TodoManager::update( int, const SmallTodo& ) { 81void TodoManager::update( int, const SmallTodo& ) {
83 82
84} 83}
85void TodoManager::update( int, const OTodo& ev) { 84void TodoManager::update( int, const OTodo& ev) {
86 m_db->replace( ev ); 85 m_db->replace( ev );
87} 86}
88bool TodoManager::remove( int uid ) { 87bool TodoManager::remove( int uid ) {
89 return m_db->remove( uid ); 88 return m_db->remove( uid );
90} 89}
91void TodoManager::removeAll() { 90void TodoManager::removeAll() {
92 m_db->clear(); 91 m_db->clear();
93} 92}
94void TodoManager::removeCompleted() { 93void TodoManager::removeCompleted() {
95 m_db->removeAllCompleted(); 94 m_db->removeAllCompleted();
96} 95}
97void TodoManager::save() { 96void TodoManager::save() {
98 m_db->save(); 97 m_db->save();
99} 98}
100bool TodoManager::saveAll() { 99bool TodoManager::saveAll() {
101 return m_db->save(); 100 return m_db->save();
102} 101}
103void TodoManager::reload() { 102void TodoManager::reload() {
104 m_db->reload(); 103 m_db->reload();
105} 104}
106QStringList TodoManager::categories() { 105QStringList TodoManager::categories() {
107 m_cat.load(categoryFileName() ); 106 m_cat.load(categoryFileName() );
108 return m_cat.labels( "Todo List"); 107 return m_cat.labels( "Todo List");
109} 108}
110/* 109/*
111 * we rely on load beeing called from populateCategories 110 * we rely on load beeing called from populateCategories
112 */ 111 */
113int TodoManager::catId( const QString& cats ) { 112int TodoManager::catId( const QString& cats ) {
114 return m_cat.id( "Todo List", cats ); 113 return m_cat.id( "Todo List", cats );
115} 114}
116void TodoManager::remove( const QArray<int>& ids) { 115void TodoManager::remove( const QArray<int>& ids) {
117 for (uint i=0; i < ids.size(); i++ ) 116 for (uint i=0; i < ids.size(); i++ )
118 remove( ids[i] ); 117 remove( ids[i] );
119} 118}
120bool TodoManager::isLoaded()const { 119bool TodoManager::isLoaded()const {
121 return (m_db == 0 ); 120 return (m_db == 0 );
122} 121}
123void TodoManager::load() { 122void TodoManager::load() {
124 if (!m_db) { 123 if (!m_db) {
125 m_db = new OTodoAccess(); 124 m_db = new OTodoAccess();
126 m_db->load(); 125 m_db->load();
127 } 126 }
128} 127}
diff --git a/core/pim/todo/todoshow.cpp b/core/pim/todo/todoshow.cpp
index 4dbc9aa..5962028 100644
--- a/core/pim/todo/todoshow.cpp
+++ b/core/pim/todo/todoshow.cpp
@@ -1,16 +1,24 @@
1 1
2#include "mainwindow.h" 2#include "mainwindow.h"
3#include "todoshow.h" 3#include "todoshow.h"
4 4
5using namespace Todo; 5using namespace Todo;
6 6
7TodoShow::TodoShow(MainWindow* win) { 7TodoShow::TodoShow(MainWindow* win) {
8 m_win = win; 8 m_win = win;
9} 9}
10TodoShow::~TodoShow() { 10TodoShow::~TodoShow() {
11} 11}
12void TodoShow::escapeView() { 12void TodoShow::escapeView() {
13 if (m_win ) 13 if (m_win )
14 m_win->slotReturnFromView(); 14 m_win->slotReturnFromView();
15} 15}
16 16
17void TodoShow::showNext() {
18 if (m_win)
19 m_win->slotShowNext();
20}
21void TodoShow::showPrev() {
22 if (m_win)
23 m_win->slotShowPrev();
24}
diff --git a/core/pim/todo/todoshow.h b/core/pim/todo/todoshow.h
index 7267b13..2babe93 100644
--- a/core/pim/todo/todoshow.h
+++ b/core/pim/todo/todoshow.h
@@ -1,58 +1,60 @@
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#ifndef TODO_TODO_SHOW_H 28#ifndef TODO_TODO_SHOW_H
29#define TODO_TODO_SHOW_H 29#define TODO_TODO_SHOW_H
30 30
31#include <qstring.h> 31#include <qstring.h>
32#include <qwidget.h> 32#include <qwidget.h>
33 33
34#include <opie/otodo.h> 34#include <opie/otodo.h>
35 35
36namespace Todo { 36namespace Todo {
37 class MainWindow; 37 class MainWindow;
38 /** 38 /**
39 * TodoShow is the baseclass of 39 * TodoShow is the baseclass of
40 * of all TodoShows. 40 * of all TodoShows.
41 * The first implementation is a QTextView 41 * The first implementation is a QTextView
42 * implementation showing the Todo as richtext 42 * implementation showing the Todo as richtext
43 */ 43 */
44 class TodoShow { 44 class TodoShow {
45 public: 45 public:
46 TodoShow( MainWindow* win); 46 TodoShow( MainWindow* win);
47 virtual ~TodoShow(); 47 virtual ~TodoShow();
48 virtual QString type()const = 0; 48 virtual QString type()const = 0;
49 virtual void slotShow( const OTodo& ev ) = 0; 49 virtual void slotShow( const OTodo& ev ) = 0;
50 virtual QWidget* widget() = 0; 50 virtual QWidget* widget() = 0;
51 protected: 51 protected:
52 void escapeView(); 52 void escapeView();
53 void showNext();
54 void showPrev();
53 private: 55 private:
54 MainWindow *m_win; 56 MainWindow *m_win;
55 }; 57 };
56}; 58};
57 59
58#endif 60#endif
diff --git a/core/pim/todo/todoview.cpp b/core/pim/todo/todoview.cpp
index 3e808e7..31047cf 100644
--- a/core/pim/todo/todoview.cpp
+++ b/core/pim/todo/todoview.cpp
@@ -1,66 +1,69 @@
1#include "mainwindow.h" 1#include "mainwindow.h"
2 2
3#include "todoview.h" 3#include "todoview.h"
4 4
5using namespace Todo; 5using namespace Todo;
6 6
7 7
8 8
9 9
10TodoView::TodoView( MainWindow* win ) 10TodoView::TodoView( MainWindow* win )
11 : m_main( win ) 11 : m_main( win )
12{ 12{
13 m_asc = false; 13 m_asc = false;
14 m_sortOrder = -1; 14 m_sortOrder = -1;
15} 15}
16TodoView::~TodoView() { 16TodoView::~TodoView() {
17}; 17};
18MainWindow* TodoView::todoWindow() { 18MainWindow* TodoView::todoWindow() {
19 return m_main; 19 return m_main;
20} 20}
21 21
22OTodo TodoView::event(int uid ) { 22OTodo TodoView::event(int uid ) {
23 return m_main->event( uid ); 23 return m_main->event( uid );
24} 24}
25OTodoAccess::List TodoView::list(){ 25OTodoAccess::List TodoView::list(){
26 todoWindow()->updateList(); 26 todoWindow()->updateList();
27 return todoWindow()->list(); 27 return todoWindow()->list();
28} 28}
29OTodoAccess::List TodoView::sorted()const{ 29OTodoAccess::List TodoView::sorted()const{
30 return m_sort; 30 return m_sort;
31} 31}
32void TodoView::sort() { 32void TodoView::sort() {
33 m_sort = todoWindow()->sorted(m_asc,m_sortOrder ); 33 m_sort = todoWindow()->sorted(m_asc,m_sortOrder );
34 qWarning("m_sort.count() = %d", m_sort.count() ); 34 qWarning("m_sort.count() = %d", m_sort.count() );
35} 35}
36void TodoView::sort(int sort) { 36void TodoView::sort(int sort) {
37 m_sort = todoWindow()->sorted(m_asc, m_sortOrder, sort ); 37 m_sort = todoWindow()->sorted(m_asc, m_sortOrder, sort );
38} 38}
39void TodoView::setSortOrder( int order ) { 39void TodoView::setSortOrder( int order ) {
40 m_sortOrder = order; 40 m_sortOrder = order;
41} 41}
42void TodoView::setAscending( bool b ) { 42void TodoView::setAscending( bool b ) {
43 qWarning("setAscending %d", b ); 43 qWarning("setAscending %d", b );
44 m_asc = b; 44 m_asc = b;
45} 45}
46void TodoView::update(int, const SmallTodo& ) { 46void TodoView::update(int, const SmallTodo& ) {
47 //m_main->slotUpate1( uid, to ); 47 //m_main->slotUpate1( uid, to );
48} 48}
49void TodoView::update(int , const OTodo& ev ) { 49void TodoView::update(int , const OTodo& ev ) {
50 m_main->updateTodo( ev ); 50 m_main->updateTodo( ev );
51} 51}
52void TodoView::showTodo( int uid ) { 52void TodoView::showTodo( int uid ) {
53 m_main->slotShow( uid ); 53 m_main->slotShow( uid );
54} 54}
55void TodoView::edit( int uid ) { 55void TodoView::edit( int uid ) {
56 m_main->slotEdit( uid ); 56 m_main->slotEdit( uid );
57} 57}
58void TodoView::remove( int uid ) { 58void TodoView::remove( int uid ) {
59 m_main->m_todoMgr.remove( uid ); 59 m_main->m_todoMgr.remove( uid );
60} 60}
61void TodoView::complete( int uid ) { 61void TodoView::complete( int uid ) {
62 m_main->slotComplete( uid ); 62 m_main->slotComplete( uid );
63} 63}
64void TodoView::complete( const OTodo& ev ) { 64void TodoView::complete( const OTodo& ev ) {
65 m_main->slotComplete( ev ); 65 m_main->slotComplete( ev );
66} 66}
67void TodoView::removeQuery( int uid ) {
68 m_main->slotDelete( uid );
69}
diff --git a/core/pim/todo/todoview.h b/core/pim/todo/todoview.h
index e73e808..e5ed66f 100644
--- a/core/pim/todo/todoview.h
+++ b/core/pim/todo/todoview.h
@@ -1,124 +1,136 @@
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 TODO_VIEW_H 29#ifndef TODO_VIEW_H
30#define TODO_VIEW_H 30#define TODO_VIEW_H
31 31
32#include <qarray.h> 32#include <qarray.h>
33#include <qstring.h> 33#include <qstring.h>
34#include <qvaluelist.h> 34#include <qvaluelist.h>
35#include <qwidget.h> 35#include <qwidget.h>
36 36
37#include <opie/otodoaccess.h> 37#include <opie/otodoaccess.h>
38 38
39#include "smalltodo.h" 39#include "smalltodo.h"
40 40
41 41
42namespace Todo { 42namespace Todo {
43 class MainWindow; 43 class MainWindow;
44 44
45 /** 45 /**
46 * due to inheretince problems we need this base class 46 * due to inheretince problems we need this base class
47 */ 47 */
48 struct ViewBase { 48 struct ViewBase {
49 public: 49 public:
50 virtual QWidget* widget() = 0; 50 virtual QWidget* widget() = 0;
51 virtual QString type()const = 0; 51 virtual QString type()const = 0;
52 virtual int current() = 0; 52 virtual int current() = 0;
53 virtual QString currentRepresentation() = 0; 53 virtual QString currentRepresentation() = 0;
54 virtual void showOverDue( bool ) = 0; 54 virtual void showOverDue( bool ) = 0;
55 55
56 /**
57 * the next record in the view or 0 if none is there
58 */
59 virtual int next() = 0;
60
61 /**
62 * the previous record or 0 if none is there..
63 */
64 virtual int prev() = 0;
65
56 /* 66 /*
57 * update the view 67 * update the view
58 */ 68 */
59 virtual void updateView() = 0; 69 virtual void updateView() = 0;
60 70
61 virtual void addEvent( const OTodo& ) = 0; 71 virtual void addEvent( const OTodo& ) = 0;
62 virtual void replaceEvent( const OTodo& ) = 0; 72 virtual void replaceEvent( const OTodo& ) = 0;
63 virtual void removeEvent( int uid ) = 0; 73 virtual void removeEvent( int uid ) = 0;
64 virtual void setShowCompleted( bool ) = 0; 74 virtual void setShowCompleted( bool ) = 0;
65 virtual void setShowDeadline( bool ) = 0; 75 virtual void setShowDeadline( bool ) = 0;
66 virtual void setShowCategory( const QString& = QString::null ) = 0; 76 virtual void setShowCategory( const QString& = QString::null ) = 0;
67 virtual void clear() = 0; 77 virtual void clear() = 0;
68 virtual void newDay() = 0; 78 virtual void newDay() = 0;
69 }; 79 };
70 80
71 /** 81 /**
72 * A base class for all TodoView which are showing 82 * A base class for all TodoView which are showing
73 * a list of todos. 83 * a list of todos.
74 * Either in a QTable, QListView or any other QWidget 84 * Either in a QTable, QListView or any other QWidget
75 * derived class 85 * derived class
76 * Through the MainWindow( dispatcher ) one can access 86 * Through the MainWindow( dispatcher ) one can access
77 * the relevant informations 87 * the relevant informations
78 * 88 *
79 * It's not possible to have signal and slots from within 89 * It's not possible to have signal and slots from within
80 * templates this way you've to register for a signal 90 * templates this way you've to register for a signal
81 */ 91 */
82 class TodoView : public ViewBase{ 92 class TodoView : public ViewBase{
83 93
84 public: 94 public:
85 /** 95 /**
86 * c'tor 96 * c'tor
87 */ 97 */
88 TodoView( MainWindow* win ); 98 TodoView( MainWindow* win );
89 99
90 /** 100 /**
91 *d'tor 101 *d'tor
92 */ 102 */
93 virtual ~TodoView(); 103 virtual ~TodoView();
94 104
95 protected: 105 protected:
96 MainWindow* todoWindow(); 106 MainWindow* todoWindow();
97 OTodo event(int uid ); 107 OTodo event(int uid );
98 OTodoAccess::List list(); 108 OTodoAccess::List list();
99 OTodoAccess::List sorted()const; 109 OTodoAccess::List sorted()const;
100 void sort(); 110 void sort();
101 void sort(int sort ); 111 void sort(int sort );
102 void setSortOrder( int order ); 112 void setSortOrder( int order );
103 void setAscending( bool ); 113 void setAscending( bool );
104 114
105 /* 115 /*
106 * These things needs to be implemented 116 * These things needs to be implemented
107 * in a implementation 117 * in a implementation
108 */ 118 */
109 void showTodo( int uid ); 119 void showTodo( int uid );
110 void edit( int uid ); 120 void edit( int uid );
111 void update(int uid, const SmallTodo& to ); 121 void update(int uid, const SmallTodo& to );
112 void update(int uid, const OTodo& ev); 122 void update(int uid, const OTodo& ev);
113 void remove( int uid ); 123 void remove( int uid );
124 /* will ask the user if the item should be deleted */
125 void removeQuery(int uid );
114 void complete( int uid ); 126 void complete( int uid );
115 void complete( const OTodo& ev ); 127 void complete( const OTodo& ev );
116 private: 128 private:
117 MainWindow *m_main; 129 MainWindow *m_main;
118 OTodoAccess::List m_sort; 130 OTodoAccess::List m_sort;
119 bool m_asc : 1; 131 bool m_asc : 1;
120 int m_sortOrder; 132 int m_sortOrder;
121 }; 133 };
122}; 134};
123 135
124#endif 136#endif