summaryrefslogtreecommitdiff
authordrw <drw>2004-04-02 22:15:36 (UTC)
committer drw <drw>2004-04-02 22:15:36 (UTC)
commitedd008d91ca57453601d0c2098936287d98975e6 (patch) (unidiff)
treeffdc1d494333537e33a3ad0390f83968cb884966
parent6f335843b89f60fe009b43a4134e9b3753fff974 (diff)
downloadopie-edd008d91ca57453601d0c2098936287d98975e6.zip
opie-edd008d91ca57453601d0c2098936287d98975e6.tar.gz
opie-edd008d91ca57453601d0c2098936287d98975e6.tar.bz2
Use ODebug (another 35 down...) - all of core/pim is converted.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/todo/main.cpp4
-rw-r--r--core/pim/todo/mainwindow.cpp19
-rw-r--r--core/pim/todo/opie-todo.control2
-rw-r--r--core/pim/todo/otaskeditor.cpp4
-rw-r--r--core/pim/todo/tableview.cpp34
-rw-r--r--core/pim/todo/templatedialog.cpp10
-rw-r--r--core/pim/todo/todoeditor.cpp5
-rw-r--r--core/pim/todo/todomanager.cpp7
-rw-r--r--core/pim/todo/todotemplatemanager.cpp7
-rw-r--r--core/pim/todo/todoview.cpp6
10 files changed, 56 insertions, 42 deletions
diff --git a/core/pim/todo/main.cpp b/core/pim/todo/main.cpp
index 7763169..d070ff8 100644
--- a/core/pim/todo/main.cpp
+++ b/core/pim/todo/main.cpp
@@ -1,48 +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#include <opie2/odebug.h>
24 24
25#include <qpe/qpeapplication.h> 25#include <qpe/qpeapplication.h>
26 26
27void myMessages( QtMsgType, const char* ) { 27void myMessages( QtMsgType, const char* ) {
28 28
29} 29}
30 30
31int main( int argc, char **argv ) 31int main( int argc, char **argv )
32{ 32{
33 qInstallMsgHandler( myMessages ); 33 qInstallMsgHandler( myMessages );
34 QPEApplication a( argc, argv ); 34 QPEApplication a( argc, argv );
35 35
36 QTime time; 36 QTime time;
37 time.start(); 37 time.start();
38 Todo::MainWindow mw; 38 Todo::MainWindow mw;
39 int t = time.elapsed(); 39 int t = time.elapsed();
40 qWarning("QTime %d", t/1000 ); 40 Opie::Core::owarn << "QTime " << t/1000 << oendl;
41 mw.setCaption( QObject::tr("Opie Todolist")); 41 mw.setCaption( QObject::tr("Opie Todolist"));
42 QObject::connect( &a, SIGNAL( flush() ), &mw, SLOT( slotFlush() ) ); 42 QObject::connect( &a, SIGNAL( flush() ), &mw, SLOT( slotFlush() ) );
43 QObject::connect( &a, SIGNAL( reload() ), &mw, SLOT( slotReload() ) ); 43 QObject::connect( &a, SIGNAL( reload() ), &mw, SLOT( slotReload() ) );
44 44
45 a.showMainWidget(&mw); 45 a.showMainWidget(&mw);
46 46
47 return a.exec(); 47 return a.exec();
48} 48}
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp
index f0642c4..d552928 100644
--- a/core/pim/todo/mainwindow.cpp
+++ b/core/pim/todo/mainwindow.cpp
@@ -1,1038 +1,1039 @@
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 <opie2/odebug.h>
31#include <opie2/opimrecurrence.h> 32#include <opie2/opimrecurrence.h>
32#include <opie2/opimnotifymanager.h> 33#include <opie2/opimnotifymanager.h>
33#include <opie2/otodoaccessvcal.h> 34#include <opie2/otodoaccessvcal.h>
34#include <opie2/oapplicationfactory.h> 35#include <opie2/oapplicationfactory.h>
35 36
36#include <qpe/applnk.h> 37#include <qpe/applnk.h>
37#include <qpe/config.h> 38#include <qpe/config.h>
38#include <qpe/ir.h> 39#include <qpe/ir.h>
39#include <qpe/resource.h> 40#include <qpe/resource.h>
40#include <qpe/qpemessagebox.h> 41#include <qpe/qpemessagebox.h>
41#include <qpe/alarmserver.h> 42#include <qpe/alarmserver.h>
42#include <qpe/qpeapplication.h> 43#include <qpe/qpeapplication.h>
43 44
44#include <qmenubar.h> 45#include <qmenubar.h>
45#include <qmessagebox.h> 46#include <qmessagebox.h>
46#include <qpushbutton.h> 47#include <qpushbutton.h>
47#include <qaction.h> 48#include <qaction.h>
48#include <qtimer.h> 49#include <qtimer.h>
49#include <qlayout.h> 50#include <qlayout.h>
50#include <qwhatsthis.h> 51#include <qwhatsthis.h>
51 52
52#include "quickeditimpl.h" 53#include "quickeditimpl.h"
53#include "todotemplatemanager.h" 54#include "todotemplatemanager.h"
54#include "templateeditor.h" 55#include "templateeditor.h"
55#include "tableview.h" 56#include "tableview.h"
56 57
57#include "textviewshow.h" 58#include "textviewshow.h"
58#include "todoeditor.h" 59#include "todoeditor.h"
59#include "mainwindow.h" 60#include "mainwindow.h"
60 61
61using namespace Opie::Core; 62using namespace Opie::Core;
62OPIE_EXPORT_APP( OApplicationFactory<Todo::MainWindow> ) 63OPIE_EXPORT_APP( OApplicationFactory<Todo::MainWindow> )
63 64
64 using namespace Opie; 65 using namespace Opie;
65using namespace Todo; 66using namespace Todo;
66 67
67MainWindow::MainWindow( QWidget* parent, 68MainWindow::MainWindow( QWidget* parent,
68 const char* name, WFlags ) 69 const char* name, WFlags )
69 : Opie::OPimMainWindow( "Todolist", parent, name, WType_TopLevel | WStyle_ContextHelp ) 70 : Opie::OPimMainWindow( "Todolist", parent, name, WType_TopLevel | WStyle_ContextHelp )
70{ 71{
71 if (!name) 72 if (!name)
72 setName("todo window"); 73 setName("todo window");
73 74
74 m_syncing = false; 75 m_syncing = false;
75 m_showing = false; 76 m_showing = false;
76 m_counter = 0; 77 m_counter = 0;
77 m_tempManager = new TemplateManager(); 78 m_tempManager = new TemplateManager();
78 m_tempManager->load(); 79 m_tempManager->load();
79 80
80 initUI(); 81 initUI();
81 initConfig(); 82 initConfig();
82 initViews(); 83 initViews();
83 initActions(); 84 initActions();
84 initEditor(); 85 initEditor();
85 initShow(); 86 initShow();
86 initTemplate(); 87 initTemplate();
87 88
88 populateTemplates(); 89 populateTemplates();
89 raiseCurrentView(); 90 raiseCurrentView();
90 QTimer::singleShot(0, this, SLOT(populateCategories() ) ); 91 QTimer::singleShot(0, this, SLOT(populateCategories() ) );
91} 92}
92void MainWindow::initTemplate() { 93void MainWindow::initTemplate() {
93 m_curTempEd = new TemplateEditor( this, templateManager() ); 94 m_curTempEd = new TemplateEditor( this, templateManager() );
94} 95}
95void MainWindow::initActions() { 96void MainWindow::initActions() {
96 97
97 // Data menu 98 // Data menu
98 m_edit->insertItem(QWidget::tr("New from template"), m_template, 99 m_edit->insertItem(QWidget::tr("New from template"), m_template,
99 -1, 0 ); 100 -1, 0 );
100 101
101 QAction* a = new QAction( QWidget::tr("New Task" ), Resource::loadPixmap( "new" ), 102 QAction* a = new QAction( QWidget::tr("New Task" ), Resource::loadPixmap( "new" ),
102 QString::null, 0, this, 0 ); 103 QString::null, 0, this, 0 );
103 connect(a, SIGNAL( activated() ), 104 connect(a, SIGNAL( activated() ),
104 this, SLOT( slotNew() ) ); 105 this, SLOT( slotNew() ) );
105 a->setWhatsThis( QWidget::tr( "Click here to create a new task." ) ); 106 a->setWhatsThis( QWidget::tr( "Click here to create a new task." ) );
106 a->addTo(m_tool ); 107 a->addTo(m_tool );
107 a->addTo(m_edit ); 108 a->addTo(m_edit );
108 109
109 a = new QAction( QWidget::tr("Edit Task"), Resource::loadIconSet( "edit" ), 110 a = new QAction( QWidget::tr("Edit Task"), Resource::loadIconSet( "edit" ),
110 QString::null, 0, this, 0 ); 111 QString::null, 0, this, 0 );
111 connect(a, SIGNAL(activated() ), 112 connect(a, SIGNAL(activated() ),
112 this, SLOT( slotEdit() ) ); 113 this, SLOT( slotEdit() ) );
113 a->setWhatsThis( QWidget::tr( "Click here to modify the current task." ) ); 114 a->setWhatsThis( QWidget::tr( "Click here to modify the current task." ) );
114 a->addTo( m_tool ); 115 a->addTo( m_tool );
115 a->addTo( m_edit ); 116 a->addTo( m_edit );
116 m_editAction = a; 117 m_editAction = a;
117 118
118 a = new QAction( QString::null, QWidget::tr("View Task"), 0, this, 0 ); 119 a = new QAction( QString::null, QWidget::tr("View Task"), 0, this, 0 );
119 connect(a, SIGNAL( activated() ), 120 connect(a, SIGNAL( activated() ),
120 this, SLOT( slotShowDetails() ) ); 121 this, SLOT( slotShowDetails() ) );
121 a->addTo( m_edit ); 122 a->addTo( m_edit );
122 123
123 m_edit->insertSeparator(); 124 m_edit->insertSeparator();
124 125
125 a = new QAction( QWidget::tr("Delete..."), Resource::loadIconSet( "trash" ), 126 a = new QAction( QWidget::tr("Delete..."), Resource::loadIconSet( "trash" ),
126 QString::null, 0, this, 0 ); 127 QString::null, 0, this, 0 );
127 connect(a, SIGNAL(activated() ), 128 connect(a, SIGNAL(activated() ),
128 this, SLOT(slotDelete() ) ); 129 this, SLOT(slotDelete() ) );
129 a->setWhatsThis( QWidget::tr( "Click here to remove the current task." ) ); 130 a->setWhatsThis( QWidget::tr( "Click here to remove the current task." ) );
130 a->addTo( m_tool ); 131 a->addTo( m_tool );
131 a->addTo( m_edit ); 132 a->addTo( m_edit );
132 m_deleteAction = a; 133 m_deleteAction = a;
133 134
134 a = new QAction( QString::null, QWidget::tr("Delete all..."), 0, this, 0 ); 135 a = new QAction( QString::null, QWidget::tr("Delete all..."), 0, this, 0 );
135 connect(a, SIGNAL( activated() ), 136 connect(a, SIGNAL( activated() ),
136 this, SLOT( slotDeleteAll() ) ); 137 this, SLOT( slotDeleteAll() ) );
137 a->addTo(m_edit ); 138 a->addTo(m_edit );
138 m_deleteAllAction = a; 139 m_deleteAllAction = a;
139 140
140 a = new QAction( QString::null, QWidget::tr("Delete completed"), 141 a = new QAction( QString::null, QWidget::tr("Delete completed"),
141 0, this, 0 ); 142 0, this, 0 );
142 connect(a, SIGNAL( activated() ), 143 connect(a, SIGNAL( activated() ),
143 this, SLOT( slotDeleteCompleted() ) ); 144 this, SLOT( slotDeleteCompleted() ) );
144 a->addTo(m_edit ); 145 a->addTo(m_edit );
145 a->setEnabled( TRUE ); 146 a->setEnabled( TRUE );
146 m_deleteCompleteAction = a; 147 m_deleteCompleteAction = a;
147 148
148 m_edit->insertSeparator(); 149 m_edit->insertSeparator();
149 150
150 a = new QAction( QString::null, QWidget::tr("Duplicate"), 0, this, 0 ); 151 a = new QAction( QString::null, QWidget::tr("Duplicate"), 0, this, 0 );
151 connect(a, SIGNAL( activated() ), 152 connect(a, SIGNAL( activated() ),
152 this, SLOT( slotDuplicate() ) ); 153 this, SLOT( slotDuplicate() ) );
153 a->addTo(m_edit ); 154 a->addTo(m_edit );
154 m_duplicateAction = a; 155 m_duplicateAction = a;
155 156
156 m_edit->insertSeparator(); 157 m_edit->insertSeparator();
157 158
158 if ( Ir::supported() ) { 159 if ( Ir::supported() ) {
159 a = new QAction( QWidget::tr( "Beam" ), Resource::loadPixmap( "beam" ), QString::null, 0, this, 0 ); 160 a = new QAction( QWidget::tr( "Beam" ), Resource::loadPixmap( "beam" ), QString::null, 0, this, 0 );
160 connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) ); 161 connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) );
161 a->setWhatsThis( QWidget::tr( "Click here to send the current task to another device." ) ); 162 a->setWhatsThis( QWidget::tr( "Click here to send the current task to another device." ) );
162 a->addTo( m_edit ); 163 a->addTo( m_edit );
163 a->addTo( m_tool ); 164 a->addTo( m_tool );
164 } 165 }
165 166
166#if 0 167#if 0
167 // Options menu 168 // Options menu
168 a = new QAction( QWidget::tr("Find"), Resource::loadIconSet( "mag" ), 169 a = new QAction( QWidget::tr("Find"), Resource::loadIconSet( "mag" ),
169 QString::null, 0, this, 0 ); 170 QString::null, 0, this, 0 );
170 connect(a, SIGNAL( activated() ), this, SLOT( slotFind() ) ); 171 connect(a, SIGNAL( activated() ), this, SLOT( slotFind() ) );
171 a->addTo( m_options ); 172 a->addTo( m_options );
172 m_findAction = a; 173 m_findAction = a;
173 174
174 175
175 m_options->insertSeparator(); 176 m_options->insertSeparator();
176#endif 177#endif
177 178
178 m_completedAction = new QAction( QString::null, QWidget::tr("Show completed tasks"), 179 m_completedAction = new QAction( QString::null, QWidget::tr("Show completed tasks"),
179 0, this, 0, TRUE ); 180 0, this, 0, TRUE );
180 m_completedAction->addTo( m_options ); 181 m_completedAction->addTo( m_options );
181 m_completedAction->setOn( showCompleted() ); 182 m_completedAction->setOn( showCompleted() );
182 connect(m_completedAction, SIGNAL( toggled(bool) ), this, SLOT(slotShowCompleted(bool) ) ); 183 connect(m_completedAction, SIGNAL( toggled(bool) ), this, SLOT(slotShowCompleted(bool) ) );
183 184
184 a = new QAction( QString::null, QWidget::tr("Show only over-due tasks"), 185 a = new QAction( QString::null, QWidget::tr("Show only over-due tasks"),
185 0, this, 0, TRUE ); 186 0, this, 0, TRUE );
186 a->addTo( m_options ); 187 a->addTo( m_options );
187 a->setOn( showOverDue() ); 188 a->setOn( showOverDue() );
188 connect(a, SIGNAL(toggled(bool)), this, SLOT(slotShowDue(bool) ) ); 189 connect(a, SIGNAL(toggled(bool)), this, SLOT(slotShowDue(bool) ) );
189 190
190 m_showDeadLineAction = new QAction( QString::null, QWidget::tr("Show task deadlines"), 191 m_showDeadLineAction = new QAction( QString::null, QWidget::tr("Show task deadlines"),
191 0, this, 0, TRUE ); 192 0, this, 0, TRUE );
192 m_showDeadLineAction->addTo( m_options ); 193 m_showDeadLineAction->addTo( m_options );
193 m_showDeadLineAction->setOn( showDeadline() ); 194 m_showDeadLineAction->setOn( showDeadline() );
194 connect(m_showDeadLineAction, SIGNAL(toggled(bool) ), this, SLOT( slotShowDeadLine(bool) ) ); 195 connect(m_showDeadLineAction, SIGNAL(toggled(bool) ), this, SLOT( slotShowDeadLine(bool) ) );
195 196
196 m_showQuickTaskAction = new QAction( QString::null, QWidget::tr("Show quick task bar"), 197 m_showQuickTaskAction = new QAction( QString::null, QWidget::tr("Show quick task bar"),
197 0, this, 0, TRUE ); 198 0, this, 0, TRUE );
198 m_showQuickTaskAction->addTo( m_options ); 199 m_showQuickTaskAction->addTo( m_options );
199 m_showQuickTaskAction->setOn( showQuickTask() ); 200 m_showQuickTaskAction->setOn( showQuickTask() );
200 connect(m_showQuickTaskAction, SIGNAL( toggled(bool) ), this, SLOT(slotShowQuickTask(bool) ) ); 201 connect(m_showQuickTaskAction, SIGNAL( toggled(bool) ), this, SLOT(slotShowQuickTask(bool) ) );
201 202
202 m_options->insertSeparator(); 203 m_options->insertSeparator();
203 204
204 m_bar->insertItem( QWidget::tr("Data") ,m_edit ); 205 m_bar->insertItem( QWidget::tr("Data") ,m_edit );
205 m_bar->insertItem( QWidget::tr("Category"), m_catMenu ); 206 m_bar->insertItem( QWidget::tr("Category"), m_catMenu );
206 m_bar->insertItem( QWidget::tr("Options"), m_options ); 207 m_bar->insertItem( QWidget::tr("Options"), m_options );
207 208
208 m_curQuick = new QuickEditImpl( this, m_quicktask ); 209 m_curQuick = new QuickEditImpl( this, m_quicktask );
209 addToolBar( (QToolBar *)m_curQuick->widget(), QWidget::tr( "QuickEdit" ), QMainWindow::Top, TRUE ); 210 addToolBar( (QToolBar *)m_curQuick->widget(), QWidget::tr( "QuickEdit" ), QMainWindow::Top, TRUE );
210 m_curQuick->signal()->connect( this, SLOT(slotQuickEntered() ) ); 211 m_curQuick->signal()->connect( this, SLOT(slotQuickEntered() ) );
211 212
212} 213}
213/* m_curCat from Config */ 214/* m_curCat from Config */
214void MainWindow::initConfig() { 215void MainWindow::initConfig() {
215 Config config( "todo" ); 216 Config config( "todo" );
216 config.setGroup( "View" ); 217 config.setGroup( "View" );
217 m_completed = config.readBoolEntry( "ShowComplete", TRUE ); 218 m_completed = config.readBoolEntry( "ShowComplete", TRUE );
218 m_curCat = config.readEntry( "Category", QString::null ); 219 m_curCat = config.readEntry( "Category", QString::null );
219 m_deadline = config.readBoolEntry( "ShowDeadLine", TRUE); 220 m_deadline = config.readBoolEntry( "ShowDeadLine", TRUE);
220 m_overdue = config.readBoolEntry("ShowOverDue", FALSE ); 221 m_overdue = config.readBoolEntry("ShowOverDue", FALSE );
221 m_quicktask = config.readBoolEntry("ShowQuickTask", TRUE); 222 m_quicktask = config.readBoolEntry("ShowQuickTask", TRUE);
222} 223}
223void MainWindow::initUI() { 224void MainWindow::initUI() {
224 225
225 m_stack = new Opie::Ui::OWidgetStack(this, "main stack"); 226 m_stack = new Opie::Ui::OWidgetStack(this, "main stack");
226 227
227 setCentralWidget( m_stack ); 228 setCentralWidget( m_stack );
228 229
229 setToolBarsMovable( FALSE ); 230 setToolBarsMovable( FALSE );
230 231
231 QToolBar *menubarholder = new QToolBar( this ); 232 QToolBar *menubarholder = new QToolBar( this );
232 menubarholder->setHorizontalStretchable( TRUE ); 233 menubarholder->setHorizontalStretchable( TRUE );
233 m_bar = new QMenuBar( menubarholder ); 234 m_bar = new QMenuBar( menubarholder );
234 235
235 m_tool = new QToolBar( this ); 236 m_tool = new QToolBar( this );
236 237
237 /** QPopupMenu */ 238 /** QPopupMenu */
238 m_edit = new QPopupMenu( this ); 239 m_edit = new QPopupMenu( this );
239 m_options = new QPopupMenu( this ); 240 m_options = new QPopupMenu( this );
240 m_catMenu = new QPopupMenu( this ); 241 m_catMenu = new QPopupMenu( this );
241 m_template = new QPopupMenu( this ); 242 m_template = new QPopupMenu( this );
242 243
243 m_catMenu->setCheckable( TRUE ); 244 m_catMenu->setCheckable( TRUE );
244 m_template->setCheckable( TRUE ); 245 m_template->setCheckable( TRUE );
245 246
246 connect(m_catMenu, SIGNAL(activated(int) ), 247 connect(m_catMenu, SIGNAL(activated(int) ),
247 this, SLOT(setCategory(int) ) ); 248 this, SLOT(setCategory(int) ) );
248 connect(m_template, SIGNAL(activated(int) ), 249 connect(m_template, SIGNAL(activated(int) ),
249 this, SLOT(slotNewFromTemplate(int) ) ); 250 this, SLOT(slotNewFromTemplate(int) ) );
250} 251}
251void MainWindow::initViews() { 252void MainWindow::initViews() {
252 253
253 TableView* tableView = new TableView( this, m_stack ); 254 TableView* tableView = new TableView( this, m_stack );
254 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." ) ); 255 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." ) );
255 m_stack->addWidget( tableView, m_counter++ ); 256 m_stack->addWidget( tableView, m_counter++ );
256 m_views.append( tableView ); 257 m_views.append( tableView );
257 m_curView = tableView; 258 m_curView = tableView;
258 connectBase( tableView ); 259 connectBase( tableView );
259 /* add QString type + QString configname to 260 /* add QString type + QString configname to
260 * the View menu 261 * the View menu
261 * and subdirs for multiple views 262 * and subdirs for multiple views
262 */ 263 */
263} 264}
264void MainWindow::initEditor() { 265void MainWindow::initEditor() {
265 m_curEdit = new Editor(); 266 m_curEdit = new Editor();
266} 267}
267void MainWindow::initShow() { 268void MainWindow::initShow() {
268 m_curShow = new TextViewShow(this, this); 269 m_curShow = new TextViewShow(this, this);
269 m_stack->addWidget( m_curShow->widget() , m_counter++ ); 270 m_stack->addWidget( m_curShow->widget() , m_counter++ );
270} 271}
271MainWindow::~MainWindow() { 272MainWindow::~MainWindow() {
272 delete templateManager(); 273 delete templateManager();
273} 274}
274void MainWindow::connectBase( ViewBase* ) { 275void MainWindow::connectBase( ViewBase* ) {
275 // once templates and signals mix we'll use it again 276 // once templates and signals mix we'll use it again
276} 277}
277QPopupMenu* MainWindow::contextMenu( int , bool recur ) { 278QPopupMenu* MainWindow::contextMenu( int , bool recur ) {
278 QPopupMenu* menu = new QPopupMenu(); 279 QPopupMenu* menu = new QPopupMenu();
279 280
280 m_editAction->addTo( menu ); 281 m_editAction->addTo( menu );
281 m_deleteAction->addTo( menu ); 282 m_deleteAction->addTo( menu );
282 m_duplicateAction->addTo( menu ); 283 m_duplicateAction->addTo( menu );
283 284
284 menu->insertSeparator(); 285 menu->insertSeparator();
285 286
286 /* 287 /*
287 * if this event recurs we allow 288 * if this event recurs we allow
288 * to detach it. 289 * to detach it.
289 * remove all 290 * remove all
290 */ 291 */
291 if ( recur ) { 292 if ( recur ) {
292 ; // FIXME 293 ; // FIXME
293 } 294 }
294 295
295 return menu; 296 return menu;
296} 297}
297QPopupMenu* MainWindow::options() { 298QPopupMenu* MainWindow::options() {
298 qWarning("Options"); 299 Opie::Core::owarn << "Options" << oendl;
299 return m_options; 300 return m_options;
300} 301}
301QPopupMenu* MainWindow::edit() { 302QPopupMenu* MainWindow::edit() {
302 return m_edit; 303 return m_edit;
303} 304}
304QToolBar* MainWindow::toolbar() { 305QToolBar* MainWindow::toolbar() {
305 return m_tool; 306 return m_tool;
306} 307}
307OPimTodoAccess::List MainWindow::list()const { 308OPimTodoAccess::List MainWindow::list()const {
308 return m_todoMgr.list(); 309 return m_todoMgr.list();
309} 310}
310OPimTodoAccess::List MainWindow::sorted( bool asc, int sortOrder ) { 311OPimTodoAccess::List MainWindow::sorted( bool asc, int sortOrder ) {
311 int cat = 0; 312 int cat = 0;
312 if ( m_curCat != QWidget::tr("All Categories") ) 313 if ( m_curCat != QWidget::tr("All Categories") )
313 cat = currentCatId(); 314 cat = currentCatId();
314 if ( m_curCat == QWidget::tr("Unfiled") ) 315 if ( m_curCat == QWidget::tr("Unfiled") )
315 cat = -1; 316 cat = -1;
316 317
317 qWarning(" Category %d %s", cat, m_curCat.latin1() ); 318 Opie::Core::owarn << " Category " << cat << " " << m_curCat << oendl;
318 319
319 int filter = 1; 320 int filter = 1;
320 321
321 if (!m_completed ) 322 if (!m_completed )
322 filter |= 4; 323 filter |= 4;
323 if (m_overdue) 324 if (m_overdue)
324 filter |= 2; 325 filter |= 2;
325 326
326 return m_todoMgr.sorted( asc, sortOrder, filter, cat ); 327 return m_todoMgr.sorted( asc, sortOrder, filter, cat );
327} 328}
328OPimTodoAccess::List MainWindow::sorted( bool asc, int sortOrder, int addFilter) { 329OPimTodoAccess::List MainWindow::sorted( bool asc, int sortOrder, int addFilter) {
329 int cat = 0; 330 int cat = 0;
330 if ( m_curCat != QWidget::tr("All Categories") ) 331 if ( m_curCat != QWidget::tr("All Categories") )
331 cat = currentCatId(); 332 cat = currentCatId();
332 333
333 if ( m_curCat == QWidget::tr("Unfiled") ) 334 if ( m_curCat == QWidget::tr("Unfiled") )
334 cat = -1; 335 cat = -1;
335 336
336 return m_todoMgr.sorted(asc, sortOrder, addFilter, cat ); 337 return m_todoMgr.sorted(asc, sortOrder, addFilter, cat );
337} 338}
338OPimTodo MainWindow::event( int uid ) { 339OPimTodo MainWindow::event( int uid ) {
339 return m_todoMgr.event( uid ); 340 return m_todoMgr.event( uid );
340} 341}
341bool MainWindow::isSyncing()const { 342bool MainWindow::isSyncing()const {
342 return m_syncing; 343 return m_syncing;
343} 344}
344TemplateManager* MainWindow::templateManager() { 345TemplateManager* MainWindow::templateManager() {
345 return m_tempManager; 346 return m_tempManager;
346} 347}
347Editor* MainWindow::currentEditor() { 348Editor* MainWindow::currentEditor() {
348 return m_curEdit; 349 return m_curEdit;
349} 350}
350TodoShow* MainWindow::currentShow() { 351TodoShow* MainWindow::currentShow() {
351 return m_curShow; 352 return m_curShow;
352} 353}
353void MainWindow::slotReload() { 354void MainWindow::slotReload() {
354 m_syncing = FALSE; 355 m_syncing = FALSE;
355 m_todoMgr.reload(); 356 m_todoMgr.reload();
356 currentView()->updateView( ); 357 currentView()->updateView( );
357 raiseCurrentView(); 358 raiseCurrentView();
358} 359}
359void MainWindow::closeEvent( QCloseEvent* e ) { 360void MainWindow::closeEvent( QCloseEvent* e ) {
360 if (m_stack->visibleWidget() == currentShow()->widget() ) { 361 if (m_stack->visibleWidget() == currentShow()->widget() ) {
361 m_showing = false; 362 m_showing = false;
362 raiseCurrentView(); 363 raiseCurrentView();
363 e->ignore(); 364 e->ignore();
364 return; 365 return;
365 } 366 }
366 /* 367 /*
367 * we should have flushed and now we're still saving 368 * we should have flushed and now we're still saving
368 * so there is no need to flush 369 * so there is no need to flush
369 */ 370 */
370 if (m_syncing ) { 371 if (m_syncing ) {
371 e->accept(); 372 e->accept();
372 return; 373 return;
373 } 374 }
374 bool quit = false; 375 bool quit = false;
375 if ( m_todoMgr.saveAll() ){ 376 if ( m_todoMgr.saveAll() ){
376 qWarning("saved"); 377 Opie::Core::owarn << "saved" << oendl;
377 quit = true; 378 quit = true;
378 }else { 379 }else {
379 if ( QMessageBox::critical( this, QWidget::tr("Out of space"), 380 if ( QMessageBox::critical( this, QWidget::tr("Out of space"),
380 QWidget::tr("Todo was unable\n" 381 QWidget::tr("Todo was unable\n"
381 "to save your changes.\n" 382 "to save your changes.\n"
382 "Free up some space\n" 383 "Free up some space\n"
383 "and try again.\n" 384 "and try again.\n"
384 "\nQuit Anyway?"), 385 "\nQuit Anyway?"),
385 QMessageBox::Yes|QMessageBox::Escape, 386 QMessageBox::Yes|QMessageBox::Escape,
386 QMessageBox::No|QMessageBox::Default) 387 QMessageBox::No|QMessageBox::Default)
387 != QMessageBox::No ) { 388 != QMessageBox::No ) {
388 e->accept(); 389 e->accept();
389 quit = true; 390 quit = true;
390 }else 391 }else
391 e->ignore(); 392 e->ignore();
392 393
393 } 394 }
394 395
395 if (quit ) { 396 if (quit ) {
396 Config config( "todo" ); 397 Config config( "todo" );
397 config.setGroup( "View" ); 398 config.setGroup( "View" );
398 config.writeEntry( "ShowComplete", showCompleted() ); 399 config.writeEntry( "ShowComplete", showCompleted() );
399 config.writeEntry( "Category", currentCategory() ); 400 config.writeEntry( "Category", currentCategory() );
400 config.writeEntry( "ShowDeadLine", showDeadline()); 401 config.writeEntry( "ShowDeadLine", showDeadline());
401 config.writeEntry( "ShowOverDue", showOverDue() ); 402 config.writeEntry( "ShowOverDue", showOverDue() );
402 config.writeEntry( "ShowQuickTask", showQuickTask() ); 403 config.writeEntry( "ShowQuickTask", showQuickTask() );
403 /* save templates */ 404 /* save templates */
404 templateManager()->save(); 405 templateManager()->save();
405 e->accept(); 406 e->accept();
406 QTimer::singleShot(0, qApp, SLOT(closeAllWindows()) ); 407 QTimer::singleShot(0, qApp, SLOT(closeAllWindows()) );
407 } 408 }
408} 409}
409void MainWindow::populateTemplates() { 410void MainWindow::populateTemplates() {
410 m_template->clear(); 411 m_template->clear();
411 QStringList list = templateManager()->templates(); 412 QStringList list = templateManager()->templates();
412 QStringList::Iterator it; 413 QStringList::Iterator it;
413 for ( it = list.begin(); it != list.end(); ++it ) { 414 for ( it = list.begin(); it != list.end(); ++it ) {
414 m_template->insertItem( (*it) ); 415 m_template->insertItem( (*it) );
415 } 416 }
416} 417}
417/* 418/*
418 * slotNewFromTemplate 419 * slotNewFromTemplate
419 * We use the edit widget to do 420 * We use the edit widget to do
420 * the config but we setUid(1) 421 * the config but we setUid(1)
421 * to get a new uid 422 * to get a new uid
422 */ 423 */
423/* 424/*
424 * first we get the name of the template 425 * first we get the name of the template
425 * then we will use the TemplateManager 426 * then we will use the TemplateManager
426 */ 427 */
427void MainWindow::slotNewFromTemplate( int id ) { 428void MainWindow::slotNewFromTemplate( int id ) {
428 QString name = m_template->text( id ); 429 QString name = m_template->text( id );
429 430
430 OPimTodo event = templateManager()->templateEvent( name ); 431 OPimTodo event = templateManager()->templateEvent( name );
431 event = currentEditor()->edit(this, 432 event = currentEditor()->edit(this,
432 event ); 433 event );
433 434
434 if ( currentEditor()->accepted() ) { 435 if ( currentEditor()->accepted() ) {
435 /* assign new todo */ 436 /* assign new todo */
436 event.setUid( 1 ); 437 event.setUid( 1 );
437 handleAlarms( OPimTodo(), event ); 438 handleAlarms( OPimTodo(), event );
438 m_todoMgr.add( event ); 439 m_todoMgr.add( event );
439 currentView()->addEvent( event ); 440 currentView()->addEvent( event );
440 441
441 populateCategories(); 442 populateCategories();
442 } 443 }
443 raiseCurrentView(); 444 raiseCurrentView();
444} 445}
445void MainWindow::slotNew() { 446void MainWindow::slotNew() {
446 create(); 447 create();
447} 448}
448void MainWindow::slotDuplicate() { 449void MainWindow::slotDuplicate() {
449 if(m_syncing) { 450 if(m_syncing) {
450 QMessageBox::warning(this, QWidget::tr("Todo"), 451 QMessageBox::warning(this, QWidget::tr("Todo"),
451 QWidget::tr("Data can not be edited, currently syncing")); 452 QWidget::tr("Data can not be edited, currently syncing"));
452 return; 453 return;
453 } 454 }
454 OPimTodo ev = m_todoMgr.event( currentView()->current() ); 455 OPimTodo ev = m_todoMgr.event( currentView()->current() );
455 /* let's generate a new uid */ 456 /* let's generate a new uid */
456 ev.setUid(1); 457 ev.setUid(1);
457 m_todoMgr.add( ev ); 458 m_todoMgr.add( ev );
458 459
459 currentView()->addEvent( ev ); 460 currentView()->addEvent( ev );
460 raiseCurrentView(); 461 raiseCurrentView();
461} 462}
462void MainWindow::slotDelete() { 463void MainWindow::slotDelete() {
463 if (!currentView()->current() ) 464 if (!currentView()->current() )
464 return; 465 return;
465 466
466 if(m_syncing) { 467 if(m_syncing) {
467 QMessageBox::warning(this, QWidget::tr("Todo"), 468 QMessageBox::warning(this, QWidget::tr("Todo"),
468 QWidget::tr("Data can not be edited, currently syncing")); 469 QWidget::tr("Data can not be edited, currently syncing"));
469 return; 470 return;
470 } 471 }
471 QString strName = currentView()->currentRepresentation(); 472 QString strName = currentView()->currentRepresentation();
472 if (!QPEMessageBox::confirmDelete(this, QWidget::tr("Todo"), strName ) ) 473 if (!QPEMessageBox::confirmDelete(this, QWidget::tr("Todo"), strName ) )
473 return; 474 return;
474 475
475 handleAlarms( m_todoMgr.event( currentView()->current() ), OPimTodo() ); 476 handleAlarms( m_todoMgr.event( currentView()->current() ), OPimTodo() );
476 m_todoMgr.remove( currentView()->current() ); 477 m_todoMgr.remove( currentView()->current() );
477 currentView()->removeEvent( currentView()->current() ); 478 currentView()->removeEvent( currentView()->current() );
478 raiseCurrentView(); 479 raiseCurrentView();
479} 480}
480void MainWindow::slotDelete(int uid ) { 481void MainWindow::slotDelete(int uid ) {
481 if( uid == 0 ) return; 482 if( uid == 0 ) return;
482 if(m_syncing) { 483 if(m_syncing) {
483 QMessageBox::warning(this, QWidget::tr("Todo"), 484 QMessageBox::warning(this, QWidget::tr("Todo"),
484 QWidget::tr("Data can not be edited, currently syncing")); 485 QWidget::tr("Data can not be edited, currently syncing"));
485 return; 486 return;
486 } 487 }
487 OPimTodo to = m_todoMgr.event(uid); 488 OPimTodo to = m_todoMgr.event(uid);
488 if (!QPEMessageBox::confirmDelete(this, QWidget::tr("Todo"), to.toShortText() ) ) 489 if (!QPEMessageBox::confirmDelete(this, QWidget::tr("Todo"), to.toShortText() ) )
489 return; 490 return;
490 491
491 handleAlarms(to, OPimTodo() ); 492 handleAlarms(to, OPimTodo() );
492 m_todoMgr.remove( to.uid() ); 493 m_todoMgr.remove( to.uid() );
493 currentView()->removeEvent( to.uid() ); 494 currentView()->removeEvent( to.uid() );
494 raiseCurrentView(); 495 raiseCurrentView();
495} 496}
496void MainWindow::slotDeleteAll() { 497void MainWindow::slotDeleteAll() {
497 if(m_syncing) { 498 if(m_syncing) {
498 QMessageBox::warning(this, QWidget::tr("Todo"), 499 QMessageBox::warning(this, QWidget::tr("Todo"),
499 QWidget::tr("Data can not be edited, currently syncing")); 500 QWidget::tr("Data can not be edited, currently syncing"));
500 return; 501 return;
501 } 502 }
502 503
503 504
504 if ( !QPEMessageBox::confirmDelete( this, QWidget::tr( "Todo" ), QWidget::tr("all tasks?") ) ) 505 if ( !QPEMessageBox::confirmDelete( this, QWidget::tr( "Todo" ), QWidget::tr("all tasks?") ) )
505 return; 506 return;
506 507
507 m_todoMgr.removeAll(); 508 m_todoMgr.removeAll();
508 currentView()->clear(); 509 currentView()->clear();
509 510
510 raiseCurrentView(); 511 raiseCurrentView();
511} 512}
512void MainWindow::slotDeleteCompleted() { 513void MainWindow::slotDeleteCompleted() {
513 if(m_syncing) { 514 if(m_syncing) {
514 QMessageBox::warning(this, QWidget::tr("Todo"), 515 QMessageBox::warning(this, QWidget::tr("Todo"),
515 QWidget::tr("Data can not be edited, currently syncing")); 516 QWidget::tr("Data can not be edited, currently syncing"));
516 return; 517 return;
517 } 518 }
518 519
519 if ( !QPEMessageBox::confirmDelete( this, QWidget::tr( "Todo" ), QWidget::tr("all completed tasks?") ) ) 520 if ( !QPEMessageBox::confirmDelete( this, QWidget::tr( "Todo" ), QWidget::tr("all completed tasks?") ) )
520 return; 521 return;
521 522
522 523
523 m_todoMgr.removeCompleted(); 524 m_todoMgr.removeCompleted();
524 currentView()->updateView( ); 525 currentView()->updateView( );
525} 526}
526void MainWindow::slotFind() { 527void MainWindow::slotFind() {
527 528
528} 529}
529void MainWindow::slotEdit() { 530void MainWindow::slotEdit() {
530 slotEdit( currentView()->current() ); 531 slotEdit( currentView()->current() );
531} 532}
532/* 533/*
533 * set the category 534 * set the category
534 */ 535 */
535void MainWindow::setCategory( int c) { 536void MainWindow::setCategory( int c) {
536 if ( c <= 0 ) return; 537 if ( c <= 0 ) return;
537 538
538 539
539 qWarning("Iterating over cats %d", c ); 540 Opie::Core::owarn << "Iterating over cats " << c << oendl;
540 for ( unsigned int i = 1; i < m_catMenu->count(); i++ ) 541 for ( unsigned int i = 1; i < m_catMenu->count(); i++ )
541 m_catMenu->setItemChecked(i, c == (int)i ); 542 m_catMenu->setItemChecked(i, c == (int)i );
542 543
543 if (c == 1 ) { 544 if (c == 1 ) {
544 m_curCat = QString::null; 545 m_curCat = QString::null;
545 setCaption( QWidget::tr("Todo") + " - " + QWidget::tr("All Categories" ) ); 546 setCaption( QWidget::tr("Todo") + " - " + QWidget::tr("All Categories" ) );
546 547
547 }else if ( c == (int)m_catMenu->count() - 1 ) { 548 }else if ( c == (int)m_catMenu->count() - 1 ) {
548 m_curCat = QWidget::tr("Unfiled"); 549 m_curCat = QWidget::tr("Unfiled");
549 setCaption( QWidget::tr("Todo") + " - " + QWidget::tr("Unfiled") ); 550 setCaption( QWidget::tr("Todo") + " - " + QWidget::tr("Unfiled") );
550 }else { 551 }else {
551 m_curCat = m_todoMgr.categories()[c-2]; 552 m_curCat = m_todoMgr.categories()[c-2];
552 setCaption( QWidget::tr("Todo") + " - " + m_curCat ); 553 setCaption( QWidget::tr("Todo") + " - " + m_curCat );
553 } 554 }
554 m_catMenu->setItemChecked( c, true ); 555 m_catMenu->setItemChecked( c, true );
555 556
556 currentView()->setShowCategory( m_curCat ); 557 currentView()->setShowCategory( m_curCat );
557 raiseCurrentView(); 558 raiseCurrentView();
558} 559}
559void MainWindow::slotShowDeadLine( bool dead) { 560void MainWindow::slotShowDeadLine( bool dead) {
560 m_deadline = dead; 561 m_deadline = dead;
561 currentView()->setShowDeadline( dead ); 562 currentView()->setShowDeadline( dead );
562} 563}
563void MainWindow::slotShowCompleted( bool show) { 564void MainWindow::slotShowCompleted( bool show) {
564 m_completed = show; 565 m_completed = show;
565 currentView()->setShowCompleted( m_completed ); 566 currentView()->setShowCompleted( m_completed );
566} 567}
567void MainWindow::slotShowQuickTask( bool show ) { 568void MainWindow::slotShowQuickTask( bool show ) {
568 m_quicktask = show; 569 m_quicktask = show;
569 if ( m_quicktask ) 570 if ( m_quicktask )
570 m_curQuick->widget()->show(); 571 m_curQuick->widget()->show();
571 else 572 else
572 m_curQuick->widget()->hide(); 573 m_curQuick->widget()->hide();
573} 574}
574bool MainWindow::showOverDue()const { 575bool MainWindow::showOverDue()const {
575 return m_overdue; 576 return m_overdue;
576} 577}
577void MainWindow::setDocument( const QString& fi) { 578void MainWindow::setDocument( const QString& fi) {
578 DocLnk doc(fi); 579 DocLnk doc(fi);
579 if (doc.isValid() ) 580 if (doc.isValid() )
580 receiveFile(doc.file() ); 581 receiveFile(doc.file() );
581 else 582 else
582 receiveFile(fi ); 583 receiveFile(fi );
583} 584}
584 585
585static const char *beamfile = "/tmp/opie-todo.vcs"; 586static const char *beamfile = "/tmp/opie-todo.vcs";
586void MainWindow::slotBeam() { 587void MainWindow::slotBeam() {
587 beam( currentView()->current() ); 588 beam( currentView()->current() );
588} 589}
589void MainWindow::beamDone( Ir* ir) { 590void MainWindow::beamDone( Ir* ir) {
590 delete ir; 591 delete ir;
591 ::unlink( beamfile ); 592 ::unlink( beamfile );
592} 593}
593void MainWindow::receiveFile( const QString& filename ) { 594void MainWindow::receiveFile( const QString& filename ) {
594 OPimTodoAccessVCal* cal = new OPimTodoAccessVCal(filename ); 595 OPimTodoAccessVCal* cal = new OPimTodoAccessVCal(filename );
595 596
596 OPimTodoAccess acc( cal ); 597 OPimTodoAccess acc( cal );
597 acc.load(); 598 acc.load();
598 OPimTodoAccess::List list = acc.allRecords(); 599 OPimTodoAccess::List list = acc.allRecords();
599 600
600 if (list.count()){ 601 if (list.count()){
601 602
602 QString message = QWidget::tr("<P>%1 new tasks arrived.<p>Would you like to add them to your Todolist?").arg(list.count() ); 603 QString message = QWidget::tr("<P>%1 new tasks arrived.<p>Would you like to add them to your Todolist?").arg(list.count() );
603 604
604 if ( QMessageBox::information(this, QWidget::tr("New Tasks"), 605 if ( QMessageBox::information(this, QWidget::tr("New Tasks"),
605 message, QMessageBox::Ok, 606 message, QMessageBox::Ok,
606 QMessageBox::Cancel ) == QMessageBox::Ok ) { 607 QMessageBox::Cancel ) == QMessageBox::Ok ) {
607 OPimTodoAccess::List::Iterator it; 608 OPimTodoAccess::List::Iterator it;
608 for ( it = list.begin(); it != list.end(); ++it ) 609 for ( it = list.begin(); it != list.end(); ++it )
609 m_todoMgr.add( (*it) ); 610 m_todoMgr.add( (*it) );
610 611
611 currentView()->updateView(); 612 currentView()->updateView();
612 } 613 }
613 } 614 }
614} 615}
615 616
616void MainWindow::slotFlush() { 617void MainWindow::slotFlush() {
617 m_syncing = TRUE; 618 m_syncing = TRUE;
618 m_todoMgr.save(); 619 m_todoMgr.save();
619} 620}
620void MainWindow::slotShowDetails() { 621void MainWindow::slotShowDetails() {
621 slotShow( currentView()->current() ); 622 slotShow( currentView()->current() );
622} 623}
623/* 624/*
624 * populate the Categories 625 * populate the Categories
625 * Menu 626 * Menu
626 */ 627 */
627void MainWindow::populateCategories() { 628void MainWindow::populateCategories() {
628 m_todoMgr.load(); 629 m_todoMgr.load();
629 630
630 m_catMenu->clear(); 631 m_catMenu->clear();
631 int id, rememberId; 632 int id, rememberId;
632 id = 1; 633 id = 1;
633 rememberId = 1; 634 rememberId = 1;
634 635
635 m_catMenu->insertItem( QWidget::tr( "All Categories" ), id++ ); 636 m_catMenu->insertItem( QWidget::tr( "All Categories" ), id++ );
636 m_catMenu->insertSeparator(); 637 m_catMenu->insertSeparator();
637 QStringList categories = m_todoMgr.categories(); 638 QStringList categories = m_todoMgr.categories();
638 categories.append( QWidget::tr( "Unfiled" ) ); 639 categories.append( QWidget::tr( "Unfiled" ) );
639 for ( QStringList::Iterator it = categories.begin(); 640 for ( QStringList::Iterator it = categories.begin();
640 it != categories.end(); ++it ) { 641 it != categories.end(); ++it ) {
641 m_catMenu->insertItem( *it, id ); 642 m_catMenu->insertItem( *it, id );
642 if ( *it == currentCategory() ) 643 if ( *it == currentCategory() )
643 rememberId = id; 644 rememberId = id;
644 ++id; 645 ++id;
645 } 646 }
646 setCategory( rememberId ); 647 setCategory( rememberId );
647} 648}
648bool MainWindow::showCompleted()const { 649bool MainWindow::showCompleted()const {
649 return m_completed; 650 return m_completed;
650} 651}
651bool MainWindow::showDeadline()const { 652bool MainWindow::showDeadline()const {
652 return m_deadline; 653 return m_deadline;
653} 654}
654bool MainWindow::showQuickTask()const { 655bool MainWindow::showQuickTask()const {
655 return m_quicktask; 656 return m_quicktask;
656} 657}
657QString MainWindow::currentCategory()const { 658QString MainWindow::currentCategory()const {
658 return m_curCat; 659 return m_curCat;
659} 660}
660int MainWindow::currentCatId() { 661int MainWindow::currentCatId() {
661 return m_todoMgr.catId( m_curCat ); 662 return m_todoMgr.catId( m_curCat );
662} 663}
663ViewBase* MainWindow::currentView() { 664ViewBase* MainWindow::currentView() {
664 return m_curView; 665 return m_curView;
665} 666}
666void MainWindow::raiseCurrentView() { 667void MainWindow::raiseCurrentView() {
667 // due QPE/Application/todolist show(int) 668 // due QPE/Application/todolist show(int)
668 // we might not have the populateCategories slot called once 669 // we might not have the populateCategories slot called once
669 // we would show the otodo but then imediately switch to the currentView 670 // we would show the otodo but then imediately switch to the currentView
670 // if we're initially showing we shouldn't raise the table 671 // if we're initially showing we shouldn't raise the table
671 // in returnFromView we fix up m_showing 672 // in returnFromView we fix up m_showing
672 if (m_showing ) return; 673 if (m_showing ) return;
673 674
674 m_stack->raiseWidget( m_curView->widget() ); 675 m_stack->raiseWidget( m_curView->widget() );
675} 676}
676void MainWindow::slotShowDue(bool ov) { 677void MainWindow::slotShowDue(bool ov) {
677 m_overdue = ov; 678 m_overdue = ov;
678 currentView()->showOverDue( ov ); 679 currentView()->showOverDue( ov );
679 raiseCurrentView(); 680 raiseCurrentView();
680} 681}
681void MainWindow::slotShow( int uid ) { 682void MainWindow::slotShow( int uid ) {
682 if ( uid == 0 ) return; 683 if ( uid == 0 ) return;
683 qWarning("slotShow"); 684 Opie::Core::owarn << "slotShow" << oendl;
684 currentShow()->slotShow( event( uid ) ); 685 currentShow()->slotShow( event( uid ) );
685 m_stack->raiseWidget( currentShow()->widget() ); 686 m_stack->raiseWidget( currentShow()->widget() );
686} 687}
687void MainWindow::slotShowNext() { 688void MainWindow::slotShowNext() {
688 int l = currentView()->next(); 689 int l = currentView()->next();
689 if (l!=0) 690 if (l!=0)
690 slotShow(l); 691 slotShow(l);
691} 692}
692void MainWindow::slotShowPrev() { 693void MainWindow::slotShowPrev() {
693 int l = currentView()->prev(); 694 int l = currentView()->prev();
694 if (l!=0) 695 if (l!=0)
695 slotShow(l); 696 slotShow(l);
696} 697}
697void MainWindow::slotEdit( int uid ) { 698void MainWindow::slotEdit( int uid ) {
698 if (uid == 0 ) return; 699 if (uid == 0 ) return;
699 if(m_syncing) { 700 if(m_syncing) {
700 QMessageBox::warning(this, QWidget::tr("Todo"), 701 QMessageBox::warning(this, QWidget::tr("Todo"),
701 QWidget::tr("Data can't be edited, currently syncing")); 702 QWidget::tr("Data can't be edited, currently syncing"));
702 return; 703 return;
703 } 704 }
704 705
705 OPimTodo old_todo = m_todoMgr.event( uid ); 706 OPimTodo old_todo = m_todoMgr.event( uid );
706 707
707 OPimTodo todo = currentEditor()->edit(this, old_todo ); 708 OPimTodo todo = currentEditor()->edit(this, old_todo );
708 709
709 /* if completed */ 710 /* if completed */
710 if ( currentEditor()->accepted() ) { 711 if ( currentEditor()->accepted() ) {
711 handleAlarms( old_todo, todo ); 712 handleAlarms( old_todo, todo );
712 m_todoMgr.update( todo.uid(), todo ); 713 m_todoMgr.update( todo.uid(), todo );
713 currentView()->replaceEvent( todo ); 714 currentView()->replaceEvent( todo );
714 /* a Category might have changed */ 715 /* a Category might have changed */
715 populateCategories(); 716 populateCategories();
716 } 717 }
717 718
718 raiseCurrentView(); 719 raiseCurrentView();
719} 720}
720/* 721/*
721void MainWindow::slotUpdate1( int uid, const SmallTodo& ev) { 722void MainWindow::slotUpdate1( int uid, const SmallTodo& ev) {
722 m_todoMgr.update( uid, ev ); 723 m_todoMgr.update( uid, ev );
723} 724}
724*/ 725*/
725void MainWindow::updateTodo( const OPimTodo& ev) { 726void MainWindow::updateTodo( const OPimTodo& ev) {
726 m_todoMgr.update( ev.uid() , ev ); 727 m_todoMgr.update( ev.uid() , ev );
727} 728}
728/* The view changed it's configuration 729/* The view changed it's configuration
729 * update the view menu 730 * update the view menu
730 */ 731 */
731void MainWindow::slotUpdate3( QWidget* ) { 732void MainWindow::slotUpdate3( QWidget* ) {
732 733
733} 734}
734void MainWindow::updateList() { 735void MainWindow::updateList() {
735 m_todoMgr.updateList(); 736 m_todoMgr.updateList();
736} 737}
737void MainWindow::setReadAhead( uint count ) { 738void MainWindow::setReadAhead( uint count ) {
738 if (m_todoMgr.todoDB() ) 739 if (m_todoMgr.todoDB() )
739 m_todoMgr.todoDB()->setReadAhead( count ); 740 m_todoMgr.todoDB()->setReadAhead( count );
740} 741}
741void MainWindow::slotQuickEntered() { 742void MainWindow::slotQuickEntered() {
742 qWarning("entered"); 743 Opie::Core::owarn << "entered" << oendl;
743 OPimTodo todo = quickEditor()->todo(); 744 OPimTodo todo = quickEditor()->todo();
744 if (todo.isEmpty() ) 745 if (todo.isEmpty() )
745 return; 746 return;
746 747
747 m_todoMgr.add( todo ); 748 m_todoMgr.add( todo );
748 currentView()->addEvent( todo ); 749 currentView()->addEvent( todo );
749 raiseCurrentView(); 750 raiseCurrentView();
750} 751}
751QuickEditBase* MainWindow::quickEditor() { 752QuickEditBase* MainWindow::quickEditor() {
752 return m_curQuick; 753 return m_curQuick;
753} 754}
754void MainWindow::slotComplete( int uid ) { 755void MainWindow::slotComplete( int uid ) {
755 slotComplete( event(uid) ); 756 slotComplete( event(uid) );
756} 757}
757void MainWindow::slotComplete( const OPimTodo& todo ) { 758void MainWindow::slotComplete( const OPimTodo& todo ) {
758 OPimTodo to = todo; 759 OPimTodo to = todo;
759 to.setCompleted( !to.isCompleted() ); 760 to.setCompleted( !to.isCompleted() );
760 to.setCompletedDate( QDate::currentDate() ); 761 to.setCompletedDate( QDate::currentDate() );
761 762
762 /* 763 /*
763 * if the item does recur 764 * if the item does recur
764 * we need to spin it off 765 * we need to spin it off
765 * and update the items duedate to the next 766 * and update the items duedate to the next
766 * possible recurrance of this item... 767 * possible recurrance of this item...
767 * the spinned off one will loose the 768 * the spinned off one will loose the
768 * recurrence. 769 * recurrence.
769 * We calculate the difference between the old due date and the 770 * We calculate the difference between the old due date and the
770 * new one and add this diff to start, completed and alarm dates 771 * new one and add this diff to start, completed and alarm dates
771 * -zecke 772 * -zecke
772 */ 773 */
773 if ( to.hasRecurrence() && to.isCompleted() ) { 774 if ( to.hasRecurrence() && to.isCompleted() ) {
774 OPimTodo to2( to ); 775 OPimTodo to2( to );
775 776
776 /* the spinned off one won't recur anymore */ 777 /* the spinned off one won't recur anymore */
777 to.setRecurrence( OPimRecurrence() ); 778 to.setRecurrence( OPimRecurrence() );
778 779
779 OPimRecurrence rec = to2.recurrence(); 780 OPimRecurrence rec = to2.recurrence();
780 rec.setStart( to.dueDate() ); 781 rec.setStart( to.dueDate() );
781 to2.setRecurrence( rec ); 782 to2.setRecurrence( rec );
782 /* 783 /*
783 * if there is a next occurence 784 * if there is a next occurence
784 * from the duedate of the last recurrance 785 * from the duedate of the last recurrance
785 */ 786 */
786 QDate date; 787 QDate date;
787 if ( to2.recurrence().nextOcurrence( to2.dueDate().addDays(1), date ) ) { 788 if ( to2.recurrence().nextOcurrence( to2.dueDate().addDays(1), date ) ) {
788 int dayDiff = to.dueDate().daysTo( date ); 789 int dayDiff = to.dueDate().daysTo( date );
789 qWarning("day diff is %d", dayDiff ); 790 Opie::Core::owarn << "day diff is " << dayDiff << oendl;
790 QDate inval; 791 QDate inval;
791 /* generate a new uid for the old record */ 792 /* generate a new uid for the old record */
792 to.setUid( 1 ); 793 to.setUid( 1 );
793 794
794 /* add the old one cause it has a new UID here cause it was spin off */ 795 /* add the old one cause it has a new UID here cause it was spin off */
795 m_todoMgr.add( to ); 796 m_todoMgr.add( to );
796 797
797 /* 798 /*
798 * update the due date 799 * update the due date
799 * start date 800 * start date
800 * and complete date 801 * and complete date
801 */ 802 */
802 to2.setDueDate( date ); 803 to2.setDueDate( date );
803 rec.setStart( date ); 804 rec.setStart( date );
804 to2.setRecurrence( rec ); // could be Monday, TuesDay, Thursday every week 805 to2.setRecurrence( rec ); // could be Monday, TuesDay, Thursday every week
805 806
806 /* move start date */ 807 /* move start date */
807 if (to2.hasStartDate() ) 808 if (to2.hasStartDate() )
808 to2.setStartDate( to2.startDate().addDays( dayDiff ) ); 809 to2.setStartDate( to2.startDate().addDays( dayDiff ) );
809 810
810 /* now the alarms */ 811 /* now the alarms */
811 if (to2.hasNotifiers() ) { 812 if (to2.hasNotifiers() ) {
812 OPimNotifyManager::Alarms _als = to2.notifiers().alarms(); 813 OPimNotifyManager::Alarms _als = to2.notifiers().alarms();
813 OPimNotifyManager::Alarms als; 814 OPimNotifyManager::Alarms als;
814 815
815 /* for every alarm move the day */ 816 /* for every alarm move the day */
816 for ( OPimNotifyManager::Alarms::Iterator it = _als.begin(); it != _als.end(); ++it ) { 817 for ( OPimNotifyManager::Alarms::Iterator it = _als.begin(); it != _als.end(); ++it ) {
817 OPimAlarm al = (*it); 818 OPimAlarm al = (*it);
818 al.setDateTime( al.dateTime().addDays( dayDiff ) ); 819 al.setDateTime( al.dateTime().addDays( dayDiff ) );
819 als.append( al ); 820 als.append( al );
820 } 821 }
821 to2.notifiers().setAlarms( als ); 822 to2.notifiers().setAlarms( als );
822 handleAlarms( OPimTodo(), todo ); 823 handleAlarms( OPimTodo(), todo );
823 } 824 }
824 to2.setCompletedDate( inval ); 825 to2.setCompletedDate( inval );
825 to2.setCompleted( false ); 826 to2.setCompleted( false );
826 827
827 updateTodo( to2 ); 828 updateTodo( to2 );
828 }else 829 }else
829 updateTodo( to ); 830 updateTodo( to );
830 }else 831 }else
831 updateTodo( to ); 832 updateTodo( to );
832 833
833 currentView()->updateView(); 834 currentView()->updateView();
834 raiseCurrentView(); 835 raiseCurrentView();
835} 836}
836void MainWindow::flush() { 837void MainWindow::flush() {
837 slotFlush(); 838 slotFlush();
838} 839}
839void MainWindow::reload() { 840void MainWindow::reload() {
840 slotReload(); 841 slotReload();
841} 842}
842int MainWindow::create() { 843int MainWindow::create() {
843 int uid = 0; 844 int uid = 0;
844 if(m_syncing) { 845 if(m_syncing) {
845 QMessageBox::warning(this, QWidget::tr("Todo"), 846 QMessageBox::warning(this, QWidget::tr("Todo"),
846 QWidget::tr("Data can not be edited, currently syncing")); 847 QWidget::tr("Data can not be edited, currently syncing"));
847 return uid; 848 return uid;
848 } 849 }
849 m_todoMgr.load(); 850 m_todoMgr.load();
850 851
851 852
852 OPimTodo todo = currentEditor()->newTodo( currentCatId(), 853 OPimTodo todo = currentEditor()->newTodo( currentCatId(),
853 this ); 854 this );
854 855
855 if ( currentEditor()->accepted() ) { 856 if ( currentEditor()->accepted() ) {
856 //todo.assignUid(); 857 //todo.assignUid();
857 uid = todo.uid(); 858 uid = todo.uid();
858 handleAlarms( OPimTodo(), todo ); 859 handleAlarms( OPimTodo(), todo );
859 m_todoMgr.add( todo ); 860 m_todoMgr.add( todo );
860 currentView()->addEvent( todo ); 861 currentView()->addEvent( todo );
861 862
862 863
863 // I'm afraid we must call this every time now, otherwise 864 // I'm afraid we must call this every time now, otherwise
864 // spend expensive time comparing all these strings... 865 // spend expensive time comparing all these strings...
865 // but only call if we changed something -zecke 866 // but only call if we changed something -zecke
866 populateCategories(); 867 populateCategories();
867 } 868 }
868 raiseCurrentView( ); 869 raiseCurrentView( );
869 870
870 return uid; 871 return uid;
871} 872}
872/* delete it silently... */ 873/* delete it silently... */
873bool MainWindow::remove( int uid ) { 874bool MainWindow::remove( int uid ) {
874 if (m_syncing) return false; 875 if (m_syncing) return false;
875 876
876 /* argh need to get the whole OEvent... to disable alarms -zecke */ 877 /* argh need to get the whole OEvent... to disable alarms -zecke */
877 handleAlarms( OPimTodo(), m_todoMgr.event( uid ) ); 878 handleAlarms( OPimTodo(), m_todoMgr.event( uid ) );
878 879
879 return m_todoMgr.remove( uid ); 880 return m_todoMgr.remove( uid );
880} 881}
881void MainWindow::beam( int uid) { 882void MainWindow::beam( int uid) {
882 if( uid == 0 ) return; 883 if( uid == 0 ) return;
883 884
884 ::unlink( beamfile ); 885 ::unlink( beamfile );
885 m_todoMgr.load(); 886 m_todoMgr.load();
886 887
887 OPimTodo todo = event( uid ); 888 OPimTodo todo = event( uid );
888 OPimTodoAccessVCal* cal = new OPimTodoAccessVCal(QString::fromLatin1(beamfile) ); 889 OPimTodoAccessVCal* cal = new OPimTodoAccessVCal(QString::fromLatin1(beamfile) );
889 OPimTodoAccess acc( cal ); 890 OPimTodoAccess acc( cal );
890 acc.load(); 891 acc.load();
891 acc.add( todo ); 892 acc.add( todo );
892 acc.save(); 893 acc.save();
893 Ir* ir = new Ir(this ); 894 Ir* ir = new Ir(this );
894 connect(ir, SIGNAL(done(Ir*) ), 895 connect(ir, SIGNAL(done(Ir*) ),
895 this, SLOT(beamDone(Ir*) ) ); 896 this, SLOT(beamDone(Ir*) ) );
896 ir->send(beamfile, todo.summary(), "text/x-vCalendar" ); 897 ir->send(beamfile, todo.summary(), "text/x-vCalendar" );
897} 898}
898void MainWindow::show( int uid ) { 899void MainWindow::show( int uid ) {
899 m_todoMgr.load(); // might not be loaded yet 900 m_todoMgr.load(); // might not be loaded yet
900 m_showing = true; 901 m_showing = true;
901 slotShow( uid ); 902 slotShow( uid );
902 raise(); 903 raise();
903 QPEApplication::setKeepRunning(); 904 QPEApplication::setKeepRunning();
904} 905}
905void MainWindow::edit( int uid ) { 906void MainWindow::edit( int uid ) {
906 m_todoMgr.load(); 907 m_todoMgr.load();
907 slotEdit( uid ); 908 slotEdit( uid );
908} 909}
909void MainWindow::add( const OPimRecord& rec) { 910void MainWindow::add( const OPimRecord& rec) {
910 if ( rec.rtti() != OPimTodo::rtti() ) return; 911 if ( rec.rtti() != OPimTodo::rtti() ) return;
911 m_todoMgr.load(); // might not be loaded 912 m_todoMgr.load(); // might not be loaded
912 913
913 const OPimTodo& todo = static_cast<const OPimTodo&>(rec); 914 const OPimTodo& todo = static_cast<const OPimTodo&>(rec);
914 915
915 m_todoMgr.add(todo ); 916 m_todoMgr.add(todo );
916 currentView()->addEvent( todo ); 917 currentView()->addEvent( todo );
917 918
918 919
919 // I'm afraid we must call this every time now, otherwise 920 // I'm afraid we must call this every time now, otherwise
920 // spend expensive time comparing all these strings... 921 // spend expensive time comparing all these strings...
921 // but only call if we changed something -zecke 922 // but only call if we changed something -zecke
922 populateCategories(); 923 populateCategories();
923} 924}
924void MainWindow::slotReturnFromView() { 925void MainWindow::slotReturnFromView() {
925 m_showing = false; 926 m_showing = false;
926 raiseCurrentView(); 927 raiseCurrentView();
927} 928}
928 929
929namespace { 930namespace {
930 OPimNotifyManager::Alarms findNonMatching( const OPimNotifyManager::Alarms& oldAls, 931 OPimNotifyManager::Alarms findNonMatching( const OPimNotifyManager::Alarms& oldAls,
931 const OPimNotifyManager::Alarms& newAls ) { 932 const OPimNotifyManager::Alarms& newAls ) {
932 OPimNotifyManager::Alarms nonMatching; 933 OPimNotifyManager::Alarms nonMatching;
933 OPimNotifyManager::Alarms::ConstIterator oldIt = oldAls.begin(); 934 OPimNotifyManager::Alarms::ConstIterator oldIt = oldAls.begin();
934 OPimNotifyManager::Alarms::ConstIterator newIt; 935 OPimNotifyManager::Alarms::ConstIterator newIt;
935 for ( ; oldIt != oldAls.end(); ++oldIt ) { 936 for ( ; oldIt != oldAls.end(); ++oldIt ) {
936 bool found = false; 937 bool found = false;
937 QDateTime oldDt = (*oldIt).dateTime(); 938 QDateTime oldDt = (*oldIt).dateTime();
938 for (newIt= newAls.begin(); newIt != newAls.end(); ++newIt ) { 939 for (newIt= newAls.begin(); newIt != newAls.end(); ++newIt ) {
939 if ( oldDt == (*newIt).dateTime() ) { 940 if ( oldDt == (*newIt).dateTime() ) {
940 found = true; 941 found = true;
941 break; 942 break;
942 } 943 }
943 } 944 }
944 if (!found) 945 if (!found)
945 nonMatching.append( (*oldIt) ); 946 nonMatching.append( (*oldIt) );
946 } 947 }
947 return nonMatching; 948 return nonMatching;
948 } 949 }
949 void addAlarms( const OPimNotifyManager::Alarms& als, int uid ) { 950 void addAlarms( const OPimNotifyManager::Alarms& als, int uid ) {
950 OPimNotifyManager::Alarms::ConstIterator it; 951 OPimNotifyManager::Alarms::ConstIterator it;
951 for ( it = als.begin(); it != als.end(); ++it ) { 952 for ( it = als.begin(); it != als.end(); ++it ) {
952 qWarning("Adding alarm for %s", (*it).dateTime().toString().latin1() ); 953 Opie::Core::owarn << "Adding alarm for " << (*it).dateTime().toString() << oendl;
953 AlarmServer::addAlarm( (*it).dateTime(), "QPE/Application/todolist", "alarm(QDateTime,int)", uid ); 954 AlarmServer::addAlarm( (*it).dateTime(), "QPE/Application/todolist", "alarm(QDateTime,int)", uid );
954 } 955 }
955 956
956 } 957 }
957 void removeAlarms( const OPimNotifyManager::Alarms& als, int uid ) { 958 void removeAlarms( const OPimNotifyManager::Alarms& als, int uid ) {
958 OPimNotifyManager::Alarms::ConstIterator it; 959 OPimNotifyManager::Alarms::ConstIterator it;
959 for ( it = als.begin(); it != als.end(); ++it ) { 960 for ( it = als.begin(); it != als.end(); ++it ) {
960 qWarning("Removinf alarm for %s", (*it).dateTime().toString().latin1() ); 961 Opie::Core::owarn << "Removinf alarm for " << (*it).dateTime().toString() << oendl;
961 AlarmServer::deleteAlarm( (*it).dateTime(), "QPE/Application/todolist", "alarm(QDateTime,int)", uid ); 962 AlarmServer::deleteAlarm( (*it).dateTime(), "QPE/Application/todolist", "alarm(QDateTime,int)", uid );
962 } 963 }
963 } 964 }
964} 965}
965 966
966void MainWindow::handleAlarms( const OPimTodo& oldTodo, const OPimTodo& newTodo) { 967void MainWindow::handleAlarms( const OPimTodo& oldTodo, const OPimTodo& newTodo) {
967 /* 968 /*
968 * if oldTodo is not empty and has notifiers we need to find the deleted ones 969 * if oldTodo is not empty and has notifiers we need to find the deleted ones
969 */ 970 */
970 if(!oldTodo.isEmpty() && oldTodo.hasNotifiers() ) { 971 if(!oldTodo.isEmpty() && oldTodo.hasNotifiers() ) {
971 OPimNotifyManager::Alarms removed; 972 OPimNotifyManager::Alarms removed;
972 OPimNotifyManager::Alarms oldAls = oldTodo.notifiers().alarms(); 973 OPimNotifyManager::Alarms oldAls = oldTodo.notifiers().alarms();
973 if (!newTodo.hasNotifiers() ) 974 if (!newTodo.hasNotifiers() )
974 removed = oldAls; 975 removed = oldAls;
975 else 976 else
976 removed = findNonMatching( oldAls, newTodo.notifiers().alarms() ); 977 removed = findNonMatching( oldAls, newTodo.notifiers().alarms() );
977 978
978 removeAlarms( removed, oldTodo.uid() ); 979 removeAlarms( removed, oldTodo.uid() );
979 } 980 }
980 if ( newTodo.hasNotifiers() ) { 981 if ( newTodo.hasNotifiers() ) {
981 OPimNotifyManager::Alarms added; 982 OPimNotifyManager::Alarms added;
982 if ( oldTodo.isEmpty() || !oldTodo.hasNotifiers() ) 983 if ( oldTodo.isEmpty() || !oldTodo.hasNotifiers() )
983 added = newTodo.notifiers().alarms(); 984 added = newTodo.notifiers().alarms();
984 else 985 else
985 added = findNonMatching( newTodo.notifiers().alarms(), oldTodo.notifiers().alarms() ); 986 added = findNonMatching( newTodo.notifiers().alarms(), oldTodo.notifiers().alarms() );
986 987
987 addAlarms( added, newTodo.uid() ); 988 addAlarms( added, newTodo.uid() );
988 } 989 }
989} 990}
990/* we might have not loaded the db */ 991/* we might have not loaded the db */
991void MainWindow::doAlarm( const QDateTime& dt, int uid ) { 992void MainWindow::doAlarm( const QDateTime& dt, int uid ) {
992 m_todoMgr.load(); 993 m_todoMgr.load();
993 994
994 OPimTodo todo = m_todoMgr.event( uid ); 995 OPimTodo todo = m_todoMgr.event( uid );
995 if (!todo.hasNotifiers() ) return; 996 if (!todo.hasNotifiers() ) return;
996 997
997 /* 998 /*
998 * let's find the right alarm and find out if silent 999 * let's find the right alarm and find out if silent
999 * then show a richtext widget 1000 * then show a richtext widget
1000 */ 1001 */
1001 bool loud = false; 1002 bool loud = false;
1002 OPimNotifyManager::Alarms als = todo.notifiers().alarms(); 1003 OPimNotifyManager::Alarms als = todo.notifiers().alarms();
1003 OPimNotifyManager::Alarms::Iterator it; 1004 OPimNotifyManager::Alarms::Iterator it;
1004 for ( it = als.begin(); it != als.end(); ++it ) { 1005 for ( it = als.begin(); it != als.end(); ++it ) {
1005 if ( (*it).dateTime() == dt ) { 1006 if ( (*it).dateTime() == dt ) {
1006 loud = ( (*it).sound() == OPimAlarm::Loud ); 1007 loud = ( (*it).sound() == OPimAlarm::Loud );
1007 break; 1008 break;
1008 } 1009 }
1009 } 1010 }
1010 if (loud) 1011 if (loud)
1011 startAlarm(); 1012 startAlarm();
1012 1013
1013 QDialog dlg(this, 0, TRUE ); 1014 QDialog dlg(this, 0, TRUE );
1014 QVBoxLayout* lay = new QVBoxLayout( &dlg ); 1015 QVBoxLayout* lay = new QVBoxLayout( &dlg );
1015 QTextView* view = new QTextView( &dlg ); 1016 QTextView* view = new QTextView( &dlg );
1016 lay->addWidget( view ); 1017 lay->addWidget( view );
1017 QPushButton* btnOk = new QPushButton( tr("Ok"), &dlg ); 1018 QPushButton* btnOk = new QPushButton( tr("Ok"), &dlg );
1018 connect( btnOk, SIGNAL(clicked() ), &dlg, SLOT(accept() ) ); 1019 connect( btnOk, SIGNAL(clicked() ), &dlg, SLOT(accept() ) );
1019 lay->addWidget( btnOk ); 1020 lay->addWidget( btnOk );
1020 1021
1021 QString text = tr("<h1>Alarm at %1</h1><br>").arg( TimeString::dateString( dt ) ); 1022 QString text = tr("<h1>Alarm at %1</h1><br>").arg( TimeString::dateString( dt ) );
1022 text += todo.toRichText(); 1023 text += todo.toRichText();
1023 view->setText( text ); 1024 view->setText( text );
1024 1025
1025 bool needToStay = QPEApplication::execDialog( &dlg ); 1026 bool needToStay = QPEApplication::execDialog( &dlg );
1026 1027
1027 if (loud) 1028 if (loud)
1028 killAlarm(); 1029 killAlarm();
1029 1030
1030 if (needToStay) { 1031 if (needToStay) {
1031// showMaximized(); 1032// showMaximized();
1032// raise(); 1033// raise();
1033 QPEApplication::setKeepRunning(); 1034 QPEApplication::setKeepRunning();
1034// setActiveWindow(); 1035// setActiveWindow();
1035 } 1036 }
1036 1037
1037} 1038}
1038 1039
diff --git a/core/pim/todo/opie-todo.control b/core/pim/todo/opie-todo.control
index 47c2b67..3a65c04 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: plugins/application/libtodolist.so* bin/todolist apps/1Pim/todo.desktop 2Files: plugins/application/libtodolist.so* bin/todolist apps/1Pim/todo.desktop
3Priority: optional 3Priority: optional
4Section: opie/pim 4Section: opie/pim
5Maintainer: Holger 'zecke' Freyther <zecke@handhelds.org> 5Maintainer: Holger 'zecke' Freyther <zecke@handhelds.org>
6Architecture: arm 6Architecture: arm
7Depends: task-opie-minimal, libopiecore2, libopieui2, libopiepim2, opie-pics, libopiedb2 7Depends: task-opie-minimal, libopiecore2, libopieui2, libopiepim2, opie-pics
8Description: Todo list manager 8Description: Todo list manager
9 A Todo list manager for the Opie environment. 9 A Todo list manager for the Opie environment.
10Version: $QPE_VERSION$EXTRAVERSION 10Version: $QPE_VERSION$EXTRAVERSION
diff --git a/core/pim/todo/otaskeditor.cpp b/core/pim/todo/otaskeditor.cpp
index a8349c1..55a3dd5 100644
--- a/core/pim/todo/otaskeditor.cpp
+++ b/core/pim/todo/otaskeditor.cpp
@@ -1,93 +1,95 @@
1#include <qlayout.h> 1#include <qlayout.h>
2 2
3#include <opie2/odebug.h>
4
3#include "taskeditoroverview.h" 5#include "taskeditoroverview.h"
4#include "taskeditorstatus.h" 6#include "taskeditorstatus.h"
5#include "taskeditoralarms.h" 7#include "taskeditoralarms.h"
6 8
7#include "otaskeditor.h" 9#include "otaskeditor.h"
8 10
9using namespace Opie::Ui; 11using namespace Opie::Ui;
10using namespace Opie; 12using namespace Opie;
11 13
12OTaskEditor::OTaskEditor(int cur) 14OTaskEditor::OTaskEditor(int cur)
13 : QDialog( 0, 0, TRUE, WStyle_ContextHelp ) { 15 : QDialog( 0, 0, TRUE, WStyle_ContextHelp ) {
14 init(); 16 init();
15 init( cur ); 17 init( cur );
16} 18}
17OTaskEditor::OTaskEditor( const OPimTodo& to) 19OTaskEditor::OTaskEditor( const OPimTodo& to)
18 : QDialog( 0, 0, TRUE, WStyle_ContextHelp ) { 20 : QDialog( 0, 0, TRUE, WStyle_ContextHelp ) {
19 init(); 21 init();
20 init( to ); 22 init( to );
21} 23}
22OTaskEditor::~OTaskEditor() { 24OTaskEditor::~OTaskEditor() {
23 25
24} 26}
25void OTaskEditor::init( int cur ) { 27void OTaskEditor::init( int cur ) {
26 OPimTodo to; 28 OPimTodo to;
27 to.setUid( 1 ); // generate a new uid 29 to.setUid( 1 ); // generate a new uid
28 if ( cur != 0 ) 30 if ( cur != 0 )
29 to.setCategories( cur ); 31 to.setCategories( cur );
30 load(to); 32 load(to);
31} 33}
32void OTaskEditor::init( const OPimTodo& to ) { 34void OTaskEditor::init( const OPimTodo& to ) {
33 load( to ); 35 load( to );
34} 36}
35OPimTodo OTaskEditor::todo()const{ 37OPimTodo OTaskEditor::todo()const{
36 qWarning("saving!"); 38 Opie::Core::owarn << "saving!" << oendl;
37 OPimTodo to ( m_todo ); 39 OPimTodo to ( m_todo );
38 m_overView->save( to ); 40 m_overView->save( to );
39 m_stat->save( to ); 41 m_stat->save( to );
40 to.setRecurrence( m_rec->recurrence() ); 42 to.setRecurrence( m_rec->recurrence() );
41 m_alarm->save( to ); 43 m_alarm->save( to );
42 44
43 return to; 45 return to;
44} 46}
45void OTaskEditor::load(const OPimTodo& to) { 47void OTaskEditor::load(const OPimTodo& to) {
46 m_overView->load( to ); 48 m_overView->load( to );
47 m_stat->load( to ); 49 m_stat->load( to );
48 m_rec->setRecurrence( to.recurrence(), to.hasDueDate() ? to.dueDate() : QDate::currentDate() ); 50 m_rec->setRecurrence( to.recurrence(), to.hasDueDate() ? to.dueDate() : QDate::currentDate() );
49 m_alarm->load( to ); 51 m_alarm->load( to );
50 52
51 m_todo = to; 53 m_todo = to;
52} 54}
53void OTaskEditor::init() { 55void OTaskEditor::init() {
54 setCaption(tr("Task Editor") ); 56 setCaption(tr("Task Editor") );
55 57
56 QVBoxLayout* layo = new QVBoxLayout( this ); 58 QVBoxLayout* layo = new QVBoxLayout( this );
57 m_tab = new OTabWidget( this ); 59 m_tab = new OTabWidget( this );
58 layo->addWidget( m_tab ); 60 layo->addWidget( m_tab );
59 61
60 /* 62 /*
61 * Add the Widgets 63 * Add the Widgets
62 */ 64 */
63 m_overView = new TaskEditorOverView( m_tab ); 65 m_overView = new TaskEditorOverView( m_tab );
64 m_tab->addTab( m_overView, "todo/info", tr("Information") ); 66 m_tab->addTab( m_overView, "todo/info", tr("Information") );
65 67
66 m_stat = new TaskEditorStatus( m_tab ); 68 m_stat = new TaskEditorStatus( m_tab );
67 m_tab->addTab( m_stat, "todo/TodoList", tr("Status") ); 69 m_tab->addTab( m_stat, "todo/TodoList", tr("Status") );
68 70
69 m_alarm = new TaskEditorAlarms( m_tab ); 71 m_alarm = new TaskEditorAlarms( m_tab );
70 m_tab->addTab( m_alarm, "todo/alarm", tr("Alarms") ); 72 m_tab->addTab( m_alarm, "todo/alarm", tr("Alarms") );
71 73
72// m_remind = new TaskEditorAlarms( m_tab ); 74// m_remind = new TaskEditorAlarms( m_tab );
73// m_tab->addTab( m_remind, "todo/reminder", tr("Reminders") ); 75// m_tab->addTab( m_remind, "todo/reminder", tr("Reminders") );
74 76
75// QLabel* lbl = new QLabel( m_tab ); 77// QLabel* lbl = new QLabel( m_tab );
76// lbl->setText( tr("X-Ref") ); 78// lbl->setText( tr("X-Ref") );
77// m_tab->addTab( lbl, "todo/xref", tr("X-Ref") ); 79// m_tab->addTab( lbl, "todo/xref", tr("X-Ref") );
78 80
79 m_rec = new OPimRecurrenceWidget( true, QDate::currentDate(), this ); 81 m_rec = new OPimRecurrenceWidget( true, QDate::currentDate(), this );
80 m_tab->addTab( m_rec, "repeat", tr("Recurrence") ); 82 m_tab->addTab( m_rec, "repeat", tr("Recurrence") );
81 83
82 84
83 /* signal and slots */ 85 /* signal and slots */
84 connect(m_overView, SIGNAL(recurranceEnabled(bool) ), 86 connect(m_overView, SIGNAL(recurranceEnabled(bool) ),
85 m_rec, SLOT(setEnabled(bool) ) ); 87 m_rec, SLOT(setEnabled(bool) ) );
86 88
87 /* connect due date changed to the recurrence tab */ 89 /* connect due date changed to the recurrence tab */
88 connect(m_stat, SIGNAL(dueDateChanged(const QDate&) ), 90 connect(m_stat, SIGNAL(dueDateChanged(const QDate&) ),
89 m_rec, SLOT(setStartDate(const QDate&) ) ); 91 m_rec, SLOT(setStartDate(const QDate&) ) );
90 92
91 93
92 m_tab->setCurrentTab( m_overView ); 94 m_tab->setCurrentTab( m_overView );
93} 95}
diff --git a/core/pim/todo/tableview.cpp b/core/pim/todo/tableview.cpp
index 0d298f4..0b1c579 100644
--- a/core/pim/todo/tableview.cpp
+++ b/core/pim/todo/tableview.cpp
@@ -1,638 +1,640 @@
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#include <cctype>
31 31
32#include <qcombobox.h> 32#include <opie2/odebug.h>
33#include <qlineedit.h> 33#include <opie2/opimrecurrence.h>
34#include <qtimer.h>
35#include <qpopupmenu.h>
36 34
37#include <qpe/config.h> 35#include <qpe/config.h>
38#include <qpe/resource.h> 36#include <qpe/resource.h>
39 37
40#include <opie2/opimrecurrence.h> 38#include <qcombobox.h>
39#include <qlineedit.h>
40#include <qtimer.h>
41#include <qpopupmenu.h>
41 42
42#include "mainwindow.h" 43#include "mainwindow.h"
43//#include "tableitems.h" 44//#include "tableitems.h"
44#include "tableview.h" 45#include "tableview.h"
45 46
46using namespace Todo; 47using namespace Todo;
47 48
48namespace { 49namespace {
49 static const int BoxSize = 14; 50 static const int BoxSize = 14;
50 static const int RowHeight = 20; 51 static const int RowHeight = 20;
51} 52}
52 53
53TableView::EditorWidget::EditorWidget() : m_wid(0l), m_row(-1), m_col(-1) { 54TableView::EditorWidget::EditorWidget() : m_wid(0l), m_row(-1), m_col(-1) {
54} 55}
55void TableView::EditorWidget::setCellWidget(QWidget* wid, int row, int col ) { 56void TableView::EditorWidget::setCellWidget(QWidget* wid, int row, int col ) {
56 m_wid = wid; 57 m_wid = wid;
57 m_row = row; 58 m_row = row;
58 m_col = col; 59 m_col = col;
59} 60}
60void TableView::EditorWidget::releaseCellWidget() { 61void TableView::EditorWidget::releaseCellWidget() {
61 m_wid = 0; 62 m_wid = 0;
62 m_row = m_col = -1; 63 m_row = m_col = -1;
63} 64}
64QWidget* TableView::EditorWidget::cellWidget()const { 65QWidget* TableView::EditorWidget::cellWidget()const {
65 return m_wid; 66 return m_wid;
66} 67}
67int TableView::EditorWidget::cellRow()const { 68int TableView::EditorWidget::cellRow()const {
68 return m_row; 69 return m_row;
69} 70}
70int TableView::EditorWidget::cellCol()const { 71int TableView::EditorWidget::cellCol()const {
71 return m_col; 72 return m_col;
72} 73}
73 74
74 75
75void TableView::initConfig() { 76void TableView::initConfig() {
76 Config config( "todo" ); 77 Config config( "todo" );
77 config.setGroup( "Options" ); 78 config.setGroup( "Options" );
78 m_completeStrokeWidth = config.readNumEntry( "CompleteStrokeWidth", 8 ); 79 m_completeStrokeWidth = config.readNumEntry( "CompleteStrokeWidth", 8 );
79 for (int i = 0; i < numCols(); i++ ) { 80 for (int i = 0; i < numCols(); i++ ) {
80 int width = config.readNumEntry("Width"+QString::number(i), -1 ); 81 int width = config.readNumEntry("Width"+QString::number(i), -1 );
81 setColumnWidth(i, width == -1 ? columnWidth(i) : width ); 82 setColumnWidth(i, width == -1 ? columnWidth(i) : width );
82 } 83 }
83} 84}
84 85
85TableView::TableView( MainWindow* window, QWidget* wid ) 86TableView::TableView( MainWindow* window, QWidget* wid )
86 : QTable( wid ), TodoView( window ) { 87 : QTable( wid ), TodoView( window ) {
87 88
88 setName("TableView"); 89 setName("TableView");
89 // Load icons 90 // Load icons
90 // TODO - probably should be done globally somewhere else, 91 // TODO - probably should be done globally somewhere else,
91 // see also quickeditimpl.cpp/h, taskeditoroverview.cpp/h 92 // see also quickeditimpl.cpp/h, taskeditoroverview.cpp/h
92 m_pic_completed = Resource::loadPixmap( "todo/completed" ); 93 m_pic_completed = Resource::loadPixmap( "todo/completed" );
93 QString namestr; 94 QString namestr;
94 for ( unsigned int i = 1; i < 6; i++ ) { 95 for ( unsigned int i = 1; i < 6; i++ ) {
95 namestr = "todo/priority"; 96 namestr = "todo/priority";
96 namestr.append( QString::number( i ) ); 97 namestr.append( QString::number( i ) );
97 m_pic_priority[ i - 1 ] = Resource::loadPixmap( namestr ); 98 m_pic_priority[ i - 1 ] = Resource::loadPixmap( namestr );
98 } 99 }
99 100
100 setUpdatesEnabled( false ); 101 setUpdatesEnabled( false );
101 viewport()->setUpdatesEnabled( false ); 102 viewport()->setUpdatesEnabled( false );
102 m_enablePaint = false; 103 m_enablePaint = false;
103 setNumRows(0); 104 setNumRows(0);
104 setNumCols(4); 105 setNumCols(4);
105 106
106 horizontalHeader()->setLabel( 0, QWidget::tr("C.") ); 107 horizontalHeader()->setLabel( 0, QWidget::tr("C.") );
107 horizontalHeader()->setLabel( 1, QWidget::tr("Priority") ); 108 horizontalHeader()->setLabel( 1, QWidget::tr("Priority") );
108 horizontalHeader()->setLabel( 2, QWidget::tr("Summary" ) ); 109 horizontalHeader()->setLabel( 2, QWidget::tr("Summary" ) );
109 horizontalHeader()->setLabel( 3, QWidget::tr("Deadline") ); 110 horizontalHeader()->setLabel( 3, QWidget::tr("Deadline") );
110 111
111 setShowDeadline( todoWindow()->showDeadline() ); 112 setShowDeadline( todoWindow()->showDeadline() );
112 113
113 setSorting( TRUE ); 114 setSorting( TRUE );
114 setSelectionMode( NoSelection ); 115 setSelectionMode( NoSelection );
115 116
116 setLeftMargin( 0 ); 117 setLeftMargin( 0 );
117 verticalHeader()->hide(); 118 verticalHeader()->hide();
118 119
119 connect((QTable*)this, SIGNAL( clicked(int,int,int,const QPoint&) ), 120 connect((QTable*)this, SIGNAL( clicked(int,int,int,const QPoint&) ),
120 this, SLOT( slotClicked(int,int,int,const QPoint&) ) ); 121 this, SLOT( slotClicked(int,int,int,const QPoint&) ) );
121 connect((QTable*)this, SIGNAL( pressed(int,int,int,const QPoint&) ), 122 connect((QTable*)this, SIGNAL( pressed(int,int,int,const QPoint&) ),
122 this, SLOT( slotPressed(int,int,int,const QPoint&) ) ); 123 this, SLOT( slotPressed(int,int,int,const QPoint&) ) );
123 connect((QTable*)this, SIGNAL(valueChanged(int,int) ), 124 connect((QTable*)this, SIGNAL(valueChanged(int,int) ),
124 this, SLOT( slotValueChanged(int,int) ) ); 125 this, SLOT( slotValueChanged(int,int) ) );
125 connect((QTable*)this, SIGNAL(currentChanged(int,int) ), 126 connect((QTable*)this, SIGNAL(currentChanged(int,int) ),
126 this, SLOT( slotCurrentChanged(int,int) ) ); 127 this, SLOT( slotCurrentChanged(int,int) ) );
127 128
128 m_menuTimer = new QTimer( this ); 129 m_menuTimer = new QTimer( this );
129 connect( m_menuTimer, SIGNAL(timeout()), 130 connect( m_menuTimer, SIGNAL(timeout()),
130 this, SLOT(slotShowMenu()) ); 131 this, SLOT(slotShowMenu()) );
131 132
132 /* now let's init the config */ 133 /* now let's init the config */
133 initConfig(); 134 initConfig();
134 135
135 136
136 m_enablePaint = true; 137 m_enablePaint = true;
137 setUpdatesEnabled( true ); 138 setUpdatesEnabled( true );
138 viewport()->setUpdatesEnabled( true ); 139 viewport()->setUpdatesEnabled( true );
139 viewport()->update(); 140 viewport()->update();
140 setSortOrder( 0 ); 141 setSortOrder( 0 );
141 setAscending( TRUE ); 142 setAscending( TRUE );
142 m_first = true; 143 m_first = true;
143 144
144 145
145} 146}
146/* a new day has started 147/* a new day has started
147 * update the day 148 * update the day
148 */ 149 */
149void TableView::newDay() { 150void TableView::newDay() {
150 clear(); 151 clear();
151 updateView(); 152 updateView();
152} 153}
153TableView::~TableView() { 154TableView::~TableView() {
154 Config config( "todo" ); 155 Config config( "todo" );
155 config.setGroup( "Options" ); 156 config.setGroup( "Options" );
156 for (int i = 0; i < numCols(); i++ ) 157 for (int i = 0; i < numCols(); i++ )
157 config.writeEntry("Width"+QString::number(i), columnWidth(i) ); 158 config.writeEntry("Width"+QString::number(i), columnWidth(i) );
158} 159}
159void TableView::slotShowMenu() { 160void TableView::slotShowMenu() {
160 QPopupMenu *menu = todoWindow()->contextMenu( current(), sorted()[currentRow()].recurrence().doesRecur() ); 161 QPopupMenu *menu = todoWindow()->contextMenu( current(), sorted()[currentRow()].recurrence().doesRecur() );
161 menu->exec(QCursor::pos() ); 162 menu->exec(QCursor::pos() );
162 delete menu; 163 delete menu;
163} 164}
164QString TableView::type() const { 165QString TableView::type() const {
165 return QString::fromLatin1( tr("Table View") ); 166 return QString::fromLatin1( tr("Table View") );
166} 167}
167int TableView::current() { 168int TableView::current() {
168 if (numRows() == 0 ) return 0; 169 if (numRows() == 0 ) return 0;
169 int uid = sorted().uidAt(currentRow() ); 170 int uid = sorted().uidAt(currentRow() );
170 171
171 return uid; 172 return uid;
172} 173}
173int TableView::next() { 174int TableView::next() {
174 if ( numRows() == 0 ) return 0; 175 if ( numRows() == 0 ) return 0;
175 if ( currentRow() + 1 >= numRows() ) return 0; 176 if ( currentRow() + 1 >= numRows() ) return 0;
176 setCurrentCell( currentRow() +1, currentColumn() ); 177 setCurrentCell( currentRow() +1, currentColumn() );
177 return sorted().uidAt( currentRow() ); 178 return sorted().uidAt( currentRow() );
178} 179}
179int TableView::prev() { 180int TableView::prev() {
180 if ( numRows() == 0 ) return 0; 181 if ( numRows() == 0 ) return 0;
181 if ( currentRow() - 1 < 0 ) return 0; 182 if ( currentRow() - 1 < 0 ) return 0;
182 setCurrentCell( currentRow() -1, currentColumn() ); 183 setCurrentCell( currentRow() -1, currentColumn() );
183 return sorted().uidAt( currentRow() ); 184 return sorted().uidAt( currentRow() );
184 185
185} 186}
186QString TableView::currentRepresentation() { 187QString TableView::currentRepresentation() {
187 OPimTodo to = sorted()[currentRow()]; 188 OPimTodo to = sorted()[currentRow()];
188 return to.summary().isEmpty() ? to.description().left(20) : to.summary() ; 189 return to.summary().isEmpty() ? to.description().left(20) : to.summary() ;
189} 190}
190/* show overdue */ 191/* show overdue */
191void TableView::showOverDue( bool ) { 192void TableView::showOverDue( bool ) {
192 clear(); 193 clear();
193 updateView(); 194 updateView();
194} 195}
195 196
196void TableView::updateView( ) { 197void TableView::updateView( ) {
197 qWarning("update view"); 198 Opie::Core::owarn << "update view" << oendl;
198 m_row = false; 199 m_row = false;
199 static int id; 200 static int id;
200 id = startTimer(4000 ); 201 id = startTimer(4000 );
201 /* FIXME we want one page to be read! 202 /* FIXME we want one page to be read!
202 * 203 *
203 * Calculate that screensize 204 * Calculate that screensize
204 */ 205 */
205 todoWindow()->setReadAhead( 4 ); 206 todoWindow()->setReadAhead( 4 );
206 sort(); 207 sort();
207 OPimTodoAccess::List::Iterator it, end; 208 OPimTodoAccess::List::Iterator it, end;
208 it = sorted().begin(); 209 it = sorted().begin();
209 end = sorted().end(); 210 end = sorted().end();
210 211
211 qWarning("setTodos"); 212 Opie::Core::owarn << "setTodos" << oendl;
212 QTime time; 213 QTime time;
213 time.start(); 214 time.start();
214 m_enablePaint = false; 215 m_enablePaint = false;
215 setUpdatesEnabled( false ); 216 setUpdatesEnabled( false );
216 viewport()->setUpdatesEnabled( false ); 217 viewport()->setUpdatesEnabled( false );
217 218
218 setNumRows( it.count() ); 219 setNumRows( it.count() );
219 if ( it.count() == 0 ) 220 if ( it.count() == 0 )
220 killTimer(id); 221 killTimer(id);
221 222
222// int elc = time.elapsed(); 223// int elc = time.elapsed();
223 setUpdatesEnabled( true ); 224 setUpdatesEnabled( true );
224 viewport()->setUpdatesEnabled( true ); 225 viewport()->setUpdatesEnabled( true );
225 viewport()->update(); 226 viewport()->update();
226 227
227 m_enablePaint = true; 228 m_enablePaint = true;
228// int el = time.elapsed(); 229// int el = time.elapsed();
229} 230}
230void TableView::setTodo( int, const OPimTodo&) { 231void TableView::setTodo( int, const OPimTodo&) {
231 sort(); 232 sort();
232 233
233 /* repaint */ 234 /* repaint */
234 repaint(); 235 repaint();
235} 236}
236void TableView::addEvent( const OPimTodo&) { 237void TableView::addEvent( const OPimTodo&) {
237 238
238 /* fix problems of not showing the 'Haken' */ 239 /* fix problems of not showing the 'Haken' */
239 updateView(); 240 updateView();
240} 241}
241/* 242/*
242 * find the event 243 * find the event
243 * and then replace the complete row 244 * and then replace the complete row
244 */ 245 */
245void TableView::replaceEvent( const OPimTodo& ev) { 246void TableView::replaceEvent( const OPimTodo& ev) {
246 addEvent( ev ); 247 addEvent( ev );
247} 248}
248/* 249/*
249 * re aligning table can be slow too 250 * re aligning table can be slow too
250 * FIXME: look what performs better 251 * FIXME: look what performs better
251 * either this or the old align table 252 * either this or the old align table
252 */ 253 */
253void TableView::removeEvent( int ) { 254void TableView::removeEvent( int ) {
254 updateView(); 255 updateView();
255} 256}
256void TableView::setShowCompleted( bool b) { 257void TableView::setShowCompleted( bool b) {
257 qWarning("Show Completed %d" , b ); 258 Opie::Core::owarn << "Show Completed " << b << oendl;
258 updateView(); 259 updateView();
259} 260}
260void TableView::setShowDeadline( bool b ) { 261void TableView::setShowDeadline( bool b ) {
261 qWarning( "Show DeadLine %d" , b ); 262 Opie::Core::owarn << "Show Deadline " << b << oendl;
262 if ( b ) 263 if ( b )
263 showColumn( 3 ); 264 showColumn( 3 );
264 else 265 else
265 hideColumn( 3 ); 266 hideColumn( 3 );
266 267
267 // Try to intelligently size columns 268 // Try to intelligently size columns
268 // TODO - would use width() below, but doesn't have valid value at time of c'tor 269 // TODO - would use width() below, but doesn't have valid value at time of c'tor
269 int col2width = 238; 270 int col2width = 238;
270 int width = m_pic_completed.width(); 271 int width = m_pic_completed.width();
271 setColumnWidth( 0, width ); 272 setColumnWidth( 0, width );
272 col2width -= width; 273 col2width -= width;
273 width = fontMetrics().boundingRect( horizontalHeader()->label( 1 ) ).width() + 8; 274 width = fontMetrics().boundingRect( horizontalHeader()->label( 1 ) ).width() + 8;
274 setColumnWidth( 1, width ); 275 setColumnWidth( 1, width );
275 col2width -= width; 276 col2width -= width;
276 if ( b ) { 277 if ( b ) {
277 width = fontMetrics().boundingRect( horizontalHeader()->label( 3 ) ).width() + 8; 278 width = fontMetrics().boundingRect( horizontalHeader()->label( 3 ) ).width() + 8;
278 setColumnWidth( 3, width ); 279 setColumnWidth( 3, width );
279 col2width -= width; 280 col2width -= width;
280 } 281 }
281 setColumnWidth( 2, col2width ); 282 setColumnWidth( 2, col2width );
282} 283}
283void TableView::setShowCategory( const QString& str) { 284void TableView::setShowCategory( const QString& str) {
284 qWarning("setShowCategory"); 285 Opie::Core::owarn << "setShowCategory" << oendl;
285 if ( str != m_oleCat || m_first ) 286 if ( str != m_oleCat || m_first )
286 updateView(); 287 updateView();
287 288
288 m_oleCat = str; 289 m_oleCat = str;
289 m_first = false; 290 m_first = false;
290 291
291} 292}
292void TableView::clear() { 293void TableView::clear() {
293 setNumRows(0); 294 setNumRows(0);
294} 295}
295void TableView::slotClicked(int row, int col, int, 296void TableView::slotClicked(int row, int col, int,
296 const QPoint& point) { 297 const QPoint& point) {
297 if ( m_editorWidget.cellWidget() ) { 298 if ( m_editorWidget.cellWidget() ) {
298 //setCellContentFromEditor(m_editorWidget.cellRow(), m_editorWidget.cellCol() ); 299 //setCellContentFromEditor(m_editorWidget.cellRow(), m_editorWidget.cellCol() );
299 endEdit(m_editorWidget.cellRow(), m_editorWidget.cellCol(), 300 endEdit(m_editorWidget.cellRow(), m_editorWidget.cellCol(),
300 true, true ); 301 true, true );
301 m_editorWidget.releaseCellWidget(); 302 m_editorWidget.releaseCellWidget();
302 } 303 }
303 304
304 if ( !cellGeometry(row, col ).contains(point ) ) 305 if ( !cellGeometry(row, col ).contains(point ) )
305 return; 306 return;
306 307
307 int ui= sorted().uidAt( row ); 308 int ui= sorted().uidAt( row );
308 309
309 310
310 switch( col ) { 311 switch( col ) {
311 case 0:{ 312 case 0:{
312 int x = point.x() -columnPos( col ); 313 int x = point.x() -columnPos( col );
313 int y = point.y() -rowPos( row ); 314 int y = point.y() -rowPos( row );
314 int w = columnWidth( col ); 315 int w = columnWidth( col );
315 int h = rowHeight( row ); 316 int h = rowHeight( row );
316 if ( x >= ( w - BoxSize ) / 2 && 317 if ( x >= ( w - BoxSize ) / 2 &&
317 x <= ( w - BoxSize ) / 2 + BoxSize && 318 x <= ( w - BoxSize ) / 2 + BoxSize &&
318 y >= ( h - BoxSize ) / 2 && 319 y >= ( h - BoxSize ) / 2 &&
319 y <= ( h - BoxSize ) / 2 + BoxSize ) { 320 y <= ( h - BoxSize ) / 2 + BoxSize ) {
320 TodoView::complete(sorted()[row] ); 321 TodoView::complete(sorted()[row] );
321 } 322 }
322 } 323 }
323 break; 324 break;
324 325
325 // Priority emit a double click... 326 // Priority emit a double click...
326 case 1:{ 327 case 1:{
327 QWidget* wid = beginEdit( row, col, FALSE ); 328 QWidget* wid = beginEdit( row, col, FALSE );
328 m_editorWidget.setCellWidget( wid, row, col ); 329 m_editorWidget.setCellWidget( wid, row, col );
329 } 330 }
330 break; 331 break;
331 332
332 case 2: { 333 case 2: {
333 m_menuTimer->stop(); 334 m_menuTimer->stop();
334 showTodo( ui ); 335 showTodo( ui );
335 break; 336 break;
336 } 337 }
337 case 3: { 338 case 3: {
338 m_menuTimer->stop(); 339 m_menuTimer->stop();
339 TodoView::edit( ui ); 340 TodoView::edit( ui );
340 break; 341 break;
341 } 342 }
342 } 343 }
343 344
344 345
345} 346}
346void TableView::slotPressed(int row, int col, int, 347void TableView::slotPressed(int row, int col, int,
347 const QPoint& point) { 348 const QPoint& point) {
348 349
349 qWarning("pressed row %d col %d x:%d+y:%d", row,col,point.x(),point.y() ); 350 Opie::Core::owarn << "pressed row " << row << " col " << col << " x:" << point.x()
351 << "+y:" << point.y() << oendl;
350 m_prevP = point; 352 m_prevP = point;
351 /* TextColumn column */ 353 /* TextColumn column */
352 if ( col == 2 && cellGeometry( row, col ).contains( point ) ) 354 if ( col == 2 && cellGeometry( row, col ).contains( point ) )
353 m_menuTimer->start( 750, TRUE ); 355 m_menuTimer->start( 750, TRUE );
354} 356}
355void TableView::slotValueChanged( int, int ) { 357void TableView::slotValueChanged( int, int ) {
356 qWarning("Value Changed"); 358 Opie::Core::owarn << "Value Changed" << oendl;
357} 359}
358void TableView::slotCurrentChanged(int, int ) { 360void TableView::slotCurrentChanged(int, int ) {
359 m_menuTimer->stop(); 361 m_menuTimer->stop();
360} 362}
361QWidget* TableView::widget() { 363QWidget* TableView::widget() {
362 return this; 364 return this;
363} 365}
364/* 366/*
365 * We need to overwrite sortColumn 367 * We need to overwrite sortColumn
366 * because we want to sort whole row 368 * because we want to sort whole row
367 * based 369 * based
368 * We event want to set the setOrder 370 * We event want to set the setOrder
369 * to a sort() and update() 371 * to a sort() and update()
370 */ 372 */
371void TableView::sortColumn( int col, bool asc, bool ) { 373void TableView::sortColumn( int col, bool asc, bool ) {
372 qWarning("bool %d", asc ); 374 Opie::Core::owarn << "bool " << asc << oendl;
373 setSortOrder( col ); 375 setSortOrder( col );
374 setAscending( asc ); 376 setAscending( asc );
375 updateView(); 377 updateView();
376} 378}
377void TableView::viewportPaintEvent( QPaintEvent* e) { 379void TableView::viewportPaintEvent( QPaintEvent* e) {
378 if (m_enablePaint ) 380 if (m_enablePaint )
379 QTable::viewportPaintEvent( e ); 381 QTable::viewportPaintEvent( e );
380} 382}
381/* 383/*
382 * This segment is copyrighted by TT 384 * This segment is copyrighted by TT
383 * it was taken from their todolist 385 * it was taken from their todolist
384 * application this code is GPL 386 * application this code is GPL
385 */ 387 */
386void TableView::paintCell(QPainter* p, int row, int col, const QRect& cr, bool ) { 388void TableView::paintCell(QPainter* p, int row, int col, const QRect& cr, bool ) {
387 const QColorGroup &cg = colorGroup(); 389 const QColorGroup &cg = colorGroup();
388 390
389 p->save(); 391 p->save();
390 392
391 OPimTodo task = sorted()[row]; 393 OPimTodo task = sorted()[row];
392 394
393 // TODO - give user option for grid or bars? 395 // TODO - give user option for grid or bars?
394 396
395 // Paint alternating background bars 397 // Paint alternating background bars
396 if ( (row % 2 ) == 0 ) { 398 if ( (row % 2 ) == 0 ) {
397 p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Base ) ); 399 p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Base ) );
398 p->setPen( QPen( cg.text() ) ); 400 p->setPen( QPen( cg.text() ) );
399 } 401 }
400 else { 402 else {
401 p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Background ) ); 403 p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Background ) );
402 p->setPen( QPen( cg.buttonText() ) ); 404 p->setPen( QPen( cg.buttonText() ) );
403 } 405 }
404 406
405 // Paint grid 407 // Paint grid
406 //p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Base ) ); 408 //p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Base ) );
407 //QPen op = p->pen(); 409 //QPen op = p->pen();
408 //p->setPen(cg.mid()); 410 //p->setPen(cg.mid());
409 //p->drawLine( 0, cr.height() - 1, cr.width() - 1, cr.height() - 1 ); 411 //p->drawLine( 0, cr.height() - 1, cr.width() - 1, cr.height() - 1 );
410 //p->drawLine( cr.width() - 1, 0, cr.width() - 1, cr.height() - 1 ); 412 //p->drawLine( cr.width() - 1, 0, cr.width() - 1, cr.height() - 1 );
411 //p->setPen(op); 413 //p->setPen(op);
412 414
413 QFont f = p->font(); 415 QFont f = p->font();
414 QFontMetrics fm(f); 416 QFontMetrics fm(f);
415 417
416 int marg = ( cr.width() - BoxSize ) / 2; 418 int marg = ( cr.width() - BoxSize ) / 2;
417 int x = 0; 419 int x = 0;
418 int y = ( cr.height() - BoxSize ) / 2; 420 int y = ( cr.height() - BoxSize ) / 2;
419 421
420 switch(col) { 422 switch(col) {
421 case 0: // completed field 423 case 0: // completed field
422 { 424 {
423 //p->setPen( QPen( cg.text() ) ); 425 //p->setPen( QPen( cg.text() ) );
424 //p->drawRect( x + marg, y, BoxSize, BoxSize ); 426 //p->drawRect( x + marg, y, BoxSize, BoxSize );
425 //p->drawRect( x + marg+1, y+1, BoxSize-2, BoxSize-2 ); 427 //p->drawRect( x + marg+1, y+1, BoxSize-2, BoxSize-2 );
426 if ( task.isCompleted() ) { 428 if ( task.isCompleted() ) {
427 p->drawPixmap( x + marg, y, m_pic_completed ); 429 p->drawPixmap( x + marg, y, m_pic_completed );
428 } 430 }
429 } 431 }
430 break; 432 break;
431 case 1: // priority field 433 case 1: // priority field
432 { 434 {
433 p->drawPixmap( x + marg, y, m_pic_priority[ task.priority() - 1 ] ); 435 p->drawPixmap( x + marg, y, m_pic_priority[ task.priority() - 1 ] );
434 } 436 }
435 break; 437 break;
436 case 2: // description field 438 case 2: // description field
437 { 439 {
438 QString text = task.summary().isEmpty() ? 440 QString text = task.summary().isEmpty() ?
439 task.description().left(20) : 441 task.description().left(20) :
440 task.summary(); 442 task.summary();
441 p->drawText(2,2 + fm.ascent(), text); 443 p->drawText(2,2 + fm.ascent(), text);
442 } 444 }
443 break; 445 break;
444 case 3: 446 case 3:
445 { 447 {
446 QString text; 448 QString text;
447 if (task.hasDueDate()) { 449 if (task.hasDueDate()) {
448 int off = QDate::currentDate().daysTo( task.dueDate() ); 450 int off = QDate::currentDate().daysTo( task.dueDate() );
449 text = tr( "%1 day(s)").arg(QString::number(off)); 451 text = tr( "%1 day(s)").arg(QString::number(off));
450 /* 452 /*
451 * set color if not completed 453 * set color if not completed
452 */ 454 */
453 if (!task.isCompleted() ) { 455 if (!task.isCompleted() ) {
454 QColor color = Qt::black; 456 QColor color = Qt::black;
455 if ( off < 0 ) 457 if ( off < 0 )
456 color = Qt::red; 458 color = Qt::red;
457 else if ( off == 0 ) 459 else if ( off == 0 )
458 color = Qt::yellow; 460 color = Qt::yellow;
459 else if ( off > 0 ) 461 else if ( off > 0 )
460 color = Qt::green; 462 color = Qt::green;
461 p->setPen(color ); 463 p->setPen(color );
462 } 464 }
463 } else { 465 } else {
464 text = tr("None"); 466 text = tr("None");
465 } 467 }
466 p->drawText(2,2 + fm.ascent(), text); 468 p->drawText(2,2 + fm.ascent(), text);
467 } 469 }
468 break; 470 break;
469 } 471 }
470 p->restore(); 472 p->restore();
471} 473}
472QWidget* TableView::createEditor(int row, int col, bool )const { 474QWidget* TableView::createEditor(int row, int col, bool )const {
473 switch( col ) { 475 switch( col ) {
474 case 1: { 476 case 1: {
475 /* the priority stuff */ 477 /* the priority stuff */
476 QComboBox* combo = new QComboBox( viewport() ); 478 QComboBox* combo = new QComboBox( viewport() );
477 for ( int i = 0; i < 5; i++ ) { 479 for ( int i = 0; i < 5; i++ ) {
478 combo->insertItem( m_pic_priority[ i ] ); 480 combo->insertItem( m_pic_priority[ i ] );
479 } 481 }
480 combo->setCurrentItem( sorted()[row].priority()-1 ); 482 combo->setCurrentItem( sorted()[row].priority()-1 );
481 return combo; 483 return combo;
482 } 484 }
483 /* summary */ 485 /* summary */
484 case 2:{ 486 case 2:{
485 QLineEdit* edit = new QLineEdit( viewport() ); 487 QLineEdit* edit = new QLineEdit( viewport() );
486 edit->setText( sorted()[row].summary() ); 488 edit->setText( sorted()[row].summary() );
487 return edit; 489 return edit;
488 } 490 }
489 case 0: 491 case 0:
490 default: 492 default:
491 return 0l; 493 return 0l;
492 } 494 }
493} 495}
494void TableView::setCellContentFromEditor(int row, int col ) { 496void TableView::setCellContentFromEditor(int row, int col ) {
495 qWarning("set cell content from editor"); 497 Opie::Core::owarn << "set cell content from editor" << oendl;
496 if ( col == 1 ) { 498 if ( col == 1 ) {
497 QWidget* wid = cellWidget(row, 1 ); 499 QWidget* wid = cellWidget(row, 1 );
498 if ( wid->inherits("QComboBox") ) { 500 if ( wid->inherits("QComboBox") ) {
499 int pri = ((QComboBox*)wid)->currentItem() + 1; 501 int pri = ((QComboBox*)wid)->currentItem() + 1;
500 OPimTodo todo = sorted()[row]; 502 OPimTodo todo = sorted()[row];
501 if ( todo.priority() != pri ) { 503 if ( todo.priority() != pri ) {
502 todo.setPriority( pri ); 504 todo.setPriority( pri );
503 TodoView::update( todo.uid(), todo ); 505 TodoView::update( todo.uid(), todo );
504 updateView(); 506 updateView();
505 } 507 }
506 } 508 }
507 }else if ( col == 2) { 509 }else if ( col == 2) {
508 QWidget* wid = cellWidget(row, 2); 510 QWidget* wid = cellWidget(row, 2);
509 if ( wid->inherits("QLineEdit") ) { 511 if ( wid->inherits("QLineEdit") ) {
510 QString text = ((QLineEdit*)wid)->text(); 512 QString text = ((QLineEdit*)wid)->text();
511 OPimTodo todo = sorted()[row]; 513 OPimTodo todo = sorted()[row];
512 if ( todo.summary() != text ) { 514 if ( todo.summary() != text ) {
513 todo.setSummary( text ); 515 todo.setSummary( text );
514 TodoView::update( todo.uid(), todo ); 516 TodoView::update( todo.uid(), todo );
515 updateView(); 517 updateView();
516 } 518 }
517 } 519 }
518 } 520 }
519} 521}
520void TableView::slotPriority() { 522void TableView::slotPriority() {
521 setCellContentFromEditor( currentRow(), currentColumn() ); 523 setCellContentFromEditor( currentRow(), currentColumn() );
522} 524}
523/* 525/*
524 * We'll use the TimerEvent to read ahead or to keep the cahce always 526 * We'll use the TimerEvent to read ahead or to keep the cahce always
525 * filled enough. 527 * filled enough.
526 * We will try to read ahead 4 items in both ways 528 * We will try to read ahead 4 items in both ways
527 * up and down. On odd or even we will currentRow()+-4 or +-9 529 * up and down. On odd or even we will currentRow()+-4 or +-9
528 * 530 *
529 */ 531 */
530void TableView::timerEvent( QTimerEvent* ) { 532void TableView::timerEvent( QTimerEvent* ) {
531// qWarning("sorted %d", sorted().count() ); 533// Opie::Core::owarn << "sorted " << sorted().count() << oendl;
532 if (sorted().count() == 0 ) 534 if (sorted().count() == 0 )
533 return; 535 return;
534 536
535 int row = currentRow(); 537 int row = currentRow();
536 if ( m_row ) { 538 if ( m_row ) {
537 int ro = row-4; 539 int ro = row-4;
538 if (ro < 0 ) ro = 0; 540 if (ro < 0 ) ro = 0;
539 sorted()[ro]; 541 sorted()[ro];
540 542
541 ro = row+4; 543 ro = row+4;
542 sorted()[ro]; 544 sorted()[ro];
543 } else { 545 } else {
544 int ro = row + 8; 546 int ro = row + 8;
545 sorted()[ro]; 547 sorted()[ro];
546 548
547 ro = row-8; 549 ro = row-8;
548 if (ro < 0 ) ro = 0; 550 if (ro < 0 ) ro = 0;
549 sorted()[ro]; 551 sorted()[ro];
550 } 552 }
551 553
552 m_row = !m_row; 554 m_row = !m_row;
553} 555}
554 556
555// We want a strike through completed ;) 557// We want a strike through completed ;)
556// durchstreichen to complete 558// durchstreichen to complete
557/* 559/*
558 * MouseTracking is off this mean we only receive 560 * MouseTracking is off this mean we only receive
559 * these events if the mouse button is pressed 561 * these events if the mouse button is pressed
560 * We've the previous point saved 562 * We've the previous point saved
561 * We check if the previous and current Point are 563 * We check if the previous and current Point are
562 * in the same row. 564 * in the same row.
563 * Then we check if they're some pixel horizontal away 565 * Then we check if they're some pixel horizontal away
564 * if the distance between the two points is greater than 566 * if the distance between the two points is greater than
565 * 8 we mark the underlying todo as completed and do a repaint 567 * 8 we mark the underlying todo as completed and do a repaint
566 * 568 *
567 * BUG: When clicking on the Due column and it's scrollable 569 * BUG: When clicking on the Due column and it's scrollable
568 * the todo is marked as completed... 570 * the todo is marked as completed...
569 * REASON: QTable is doing auto scrolling which leads to a move 571 * REASON: QTable is doing auto scrolling which leads to a move
570 * in the x coordinate and this way it's able to pass the 572 * in the x coordinate and this way it's able to pass the
571 * m_completeStrokeWidth criteria 573 * m_completeStrokeWidth criteria
572 * WORKAROUND: strike through needs to strike through the same 574 * WORKAROUND: strike through needs to strike through the same
573 * row and two columns! 575 * row and two columns!
574 */ 576 */
575void TableView::contentsMouseReleaseEvent( QMouseEvent* e) { 577void TableView::contentsMouseReleaseEvent( QMouseEvent* e) {
576 int row = rowAt(m_prevP.y()); 578 int row = rowAt(m_prevP.y());
577 int colOld = columnAt(m_prevP.x() ); 579 int colOld = columnAt(m_prevP.x() );
578 int colNew = columnAt(e->x() ); 580 int colNew = columnAt(e->x() );
579 qWarning("colNew: %d colOld: %d", colNew, colOld ); 581 Opie::Core::owarn << "colNew: " << colNew << " colOld: " << colOld << oendl;
580 if ( row == rowAt( e->y() ) && row != -1 && 582 if ( row == rowAt( e->y() ) && row != -1 &&
581 colOld != colNew ) { 583 colOld != colNew ) {
582 TodoView::complete( sorted()[row] ); 584 TodoView::complete( sorted()[row] );
583 return; 585 return;
584 } 586 }
585 QTable::contentsMouseReleaseEvent( e ); 587 QTable::contentsMouseReleaseEvent( e );
586} 588}
587void TableView::contentsMouseMoveEvent( QMouseEvent* e ) { 589void TableView::contentsMouseMoveEvent( QMouseEvent* e ) {
588 m_menuTimer->stop(); 590 m_menuTimer->stop();
589 QTable::contentsMouseMoveEvent( e ); 591 QTable::contentsMouseMoveEvent( e );
590} 592}
591void TableView::keyPressEvent( QKeyEvent* event) { 593void TableView::keyPressEvent( QKeyEvent* event) {
592 if ( m_editorWidget.cellWidget() ) { 594 if ( m_editorWidget.cellWidget() ) {
593// setCellContentFromEditor(m_editorWidget.cellRow(), m_editorWidget.cellCol() ); 595// setCellContentFromEditor(m_editorWidget.cellRow(), m_editorWidget.cellCol() );
594 endEdit(m_editorWidget.cellRow(), m_editorWidget.cellCol(), 596 endEdit(m_editorWidget.cellRow(), m_editorWidget.cellCol(),
595 true, true ); 597 true, true );
596 m_editorWidget.releaseCellWidget(); 598 m_editorWidget.releaseCellWidget();
597 setFocus(); 599 setFocus();
598 } 600 }
599 601
600 if ( sorted().count() < 1 ) { 602 if ( sorted().count() < 1 ) {
601 QTable::keyPressEvent( event ); 603 QTable::keyPressEvent( event );
602 return; 604 return;
603 } 605 }
604 606
605 int row = currentRow(); 607 int row = currentRow();
606 int col = currentColumn(); 608 int col = currentColumn();
607 609
608 char key = ::toupper( event->ascii() ); 610 char key = ::toupper( event->ascii() );
609 /* let QTable also handle the d letter */ 611 /* let QTable also handle the d letter */
610 if ( key == 'D' ) { 612 if ( key == 'D' ) {
611 event->accept(); 613 event->accept();
612 removeQuery( sorted().uidAt( row ) ); 614 removeQuery( sorted().uidAt( row ) );
613 return; 615 return;
614 } 616 }
615 617
616 618
617 switch( event->key() ) { 619 switch( event->key() ) {
618 case Qt::Key_F33: 620 case Qt::Key_F33:
619 case Qt::Key_Enter: 621 case Qt::Key_Enter:
620 case Qt::Key_Return: 622 case Qt::Key_Return:
621 case Qt::Key_Space: 623 case Qt::Key_Space:
622 if ( col == 0 ) { 624 if ( col == 0 ) {
623 TodoView::complete(sorted()[row]); 625 TodoView::complete(sorted()[row]);
624 }else if ( col == 1 ) { 626 }else if ( col == 1 ) {
625 QWidget* wid = beginEdit(row, col, FALSE ); 627 QWidget* wid = beginEdit(row, col, FALSE );
626 m_editorWidget.setCellWidget( wid, row, col ); 628 m_editorWidget.setCellWidget( wid, row, col );
627 }else if ( col == 2 ) { 629 }else if ( col == 2 ) {
628 showTodo( sorted().uidAt( currentRow() ) ); 630 showTodo( sorted().uidAt( currentRow() ) );
629 }else if ( col == 3 ) { 631 }else if ( col == 3 ) {
630 TodoView::edit( sorted().uidAt(row) ); 632 TodoView::edit( sorted().uidAt(row) );
631 } 633 }
632 event->accept(); 634 event->accept();
633 break; 635 break;
634 default: 636 default:
635 QTable::keyPressEvent( event ); 637 QTable::keyPressEvent( event );
636 } 638 }
637} 639}
638 640
diff --git a/core/pim/todo/templatedialog.cpp b/core/pim/todo/templatedialog.cpp
index 8dfbd0b..32327a6 100644
--- a/core/pim/todo/templatedialog.cpp
+++ b/core/pim/todo/templatedialog.cpp
@@ -1,62 +1,64 @@
1#include <opie2/odebug.h>
2
1#include <qpushbutton.h> 3#include <qpushbutton.h>
2#include <qhbox.h> 4#include <qhbox.h>
3#include <qlayout.h> 5#include <qlayout.h>
4#include <qlistview.h> 6#include <qlistview.h>
5#include <qlineedit.h> 7#include <qlineedit.h>
6 8
7#include "templatedialog.h" 9#include "templatedialog.h"
8 10
9 11
10using namespace Todo; 12using namespace Todo;
11 13
12/* TRANSLATOR Todo::TemplateDialog */ 14/* TRANSLATOR Todo::TemplateDialog */
13 15
14TemplateDialog::TemplateDialog( QWidget* widget ) 16TemplateDialog::TemplateDialog( QWidget* widget )
15 : QDialog( widget, "TemplateDialog", TRUE ) 17 : QDialog( widget, "TemplateDialog", TRUE )
16{ 18{
17 setCaption( QWidget::tr("Template Editor") ); 19 setCaption( QWidget::tr("Template Editor") );
18 m_main = new QVBoxLayout(this ); 20 m_main = new QVBoxLayout(this );
19 21
20 m_list = new QListView( this ); 22 m_list = new QListView( this );
21 m_main->addWidget( m_list, 100 ); 23 m_main->addWidget( m_list, 100 );
22 24
23 m_lne = new QLineEdit( this ); 25 m_lne = new QLineEdit( this );
24 m_main->addWidget( m_lne ); 26 m_main->addWidget( m_lne );
25 27
26 m_btnBar = new QHBox( this ); 28 m_btnBar = new QHBox( this );
27 m_add = new QPushButton( QWidget::tr("Add"), m_btnBar ); 29 m_add = new QPushButton( QWidget::tr("Add"), m_btnBar );
28 m_edit = new QPushButton( QWidget::tr("Edit"), m_btnBar ); 30 m_edit = new QPushButton( QWidget::tr("Edit"), m_btnBar );
29 m_rem = new QPushButton( QWidget::tr("Remove"), m_btnBar ); 31 m_rem = new QPushButton( QWidget::tr("Remove"), m_btnBar );
30 m_main->addWidget( m_btnBar ); 32 m_main->addWidget( m_btnBar );
31 33
32 connect(m_add, SIGNAL(clicked() ), 34 connect(m_add, SIGNAL(clicked() ),
33 this, SLOT(slotAdd() ) ); 35 this, SLOT(slotAdd() ) );
34 connect(m_edit, SIGNAL(clicked() ), 36 connect(m_edit, SIGNAL(clicked() ),
35 this, SLOT(slotEdit() ) ); 37 this, SLOT(slotEdit() ) );
36 connect(m_rem, SIGNAL(clicked() ), 38 connect(m_rem, SIGNAL(clicked() ),
37 this, SLOT(slotRemove() ) ); 39 this, SLOT(slotRemove() ) );
38 connect(m_lne, SIGNAL(returnPressed() ), 40 connect(m_lne, SIGNAL(returnPressed() ),
39 this, SLOT(slotReturn() ) ); 41 this, SLOT(slotReturn() ) );
40 42
41} 43}
42TemplateDialog::~TemplateDialog() { 44TemplateDialog::~TemplateDialog() {
43 // Qt does delete our widgets 45 // Qt does delete our widgets
44} 46}
45QListView* TemplateDialog::listView() { 47QListView* TemplateDialog::listView() {
46 return m_list; 48 return m_list;
47} 49}
48QLineEdit* TemplateDialog::edit() { 50QLineEdit* TemplateDialog::edit() {
49 return m_lne; 51 return m_lne;
50} 52}
51void TemplateDialog::slotAdd() { 53void TemplateDialog::slotAdd() {
52 qWarning("Not Implemented here"); 54 Opie::Core::owarn << "Not Implemented here" << oendl;
53} 55}
54void TemplateDialog::slotRemove() { 56void TemplateDialog::slotRemove() {
55 qWarning("Not Implemented here"); 57 Opie::Core::owarn << "Not Implemented here" << oendl;
56} 58}
57void TemplateDialog::slotEdit() { 59void TemplateDialog::slotEdit() {
58 qWarning("Not Implemented here"); 60 Opie::Core::owarn << "Not Implemented here" << oendl;
59} 61}
60void TemplateDialog::slotReturn() { 62void TemplateDialog::slotReturn() {
61 qWarning("Not Implemented here"); 63 Opie::Core::owarn << "Not Implemented here" << oendl;
62} 64}
diff --git a/core/pim/todo/todoeditor.cpp b/core/pim/todo/todoeditor.cpp
index 4b5ecb1..7857d52 100644
--- a/core/pim/todo/todoeditor.cpp
+++ b/core/pim/todo/todoeditor.cpp
@@ -1,63 +1,64 @@
1#include <opie2/odebug.h>
1 2
2#include <qpe/qpeapplication.h> 3#include <qpe/qpeapplication.h>
3 4
4#include "otaskeditor.h" 5#include "otaskeditor.h"
5#include "todoeditor.h" 6#include "todoeditor.h"
6 7
7using namespace Opie; 8using namespace Opie;
8using namespace Todo; 9using namespace Todo;
9 10
10Editor::Editor() { 11Editor::Editor() {
11 m_accepted = false; 12 m_accepted = false;
12 m_self = 0l; 13 m_self = 0l;
13} 14}
14Editor::~Editor() { 15Editor::~Editor() {
15 delete m_self; 16 delete m_self;
16 m_self = 0; 17 m_self = 0;
17} 18}
18OPimTodo Editor::newTodo( int cur, 19OPimTodo Editor::newTodo( int cur,
19 QWidget*) { 20 QWidget*) {
20 21
21 OTaskEditor *e = self(); 22 OTaskEditor *e = self();
22 e->setCaption( QObject::tr("Enter Task") ); 23 e->setCaption( QObject::tr("Enter Task") );
23 e->init( cur ); 24 e->init( cur );
24 25
25 int ret = QPEApplication::execDialog( e ); 26 int ret = QPEApplication::execDialog( e );
26 27
27 if ( QDialog::Accepted == ret ) { 28 if ( QDialog::Accepted == ret ) {
28 m_accepted = true; 29 m_accepted = true;
29 }else 30 }else
30 m_accepted = false; 31 m_accepted = false;
31 32
32 OPimTodo ev = e->todo(); 33 OPimTodo ev = e->todo();
33 qWarning("Todo uid"); 34 Opie::Core::owarn << "Todo uid" << oendl;
34 qWarning("Todo %s %d %d", ev.summary().latin1(), ev.progress(), ev.isCompleted() ); 35 Opie::Core::owarn << "Todo " << ev.summary() << " " << ev.progress() << " " << ev.isCompleted() << oendl;
35 ev.setUid(1); 36 ev.setUid(1);
36 37
37 return ev; 38 return ev;
38} 39}
39OPimTodo Editor::edit( QWidget *, 40OPimTodo Editor::edit( QWidget *,
40 const OPimTodo& todo ) { 41 const OPimTodo& todo ) {
41 OTaskEditor *e = self(); 42 OTaskEditor *e = self();
42 e->init( todo ); 43 e->init( todo );
43 e->setCaption( QObject::tr( "Edit Task" ) ); 44 e->setCaption( QObject::tr( "Edit Task" ) );
44 45
45 int ret = QPEApplication::execDialog( e ); 46 int ret = QPEApplication::execDialog( e );
46 47
47 OPimTodo ev = e->todo(); 48 OPimTodo ev = e->todo();
48 if ( ret == QDialog::Accepted ) 49 if ( ret == QDialog::Accepted )
49 m_accepted = true; 50 m_accepted = true;
50 else 51 else
51 m_accepted = false; 52 m_accepted = false;
52 53
53 return ev; 54 return ev;
54} 55}
55bool Editor::accepted()const { 56bool Editor::accepted()const {
56 return m_accepted; 57 return m_accepted;
57} 58}
58OTaskEditor* Editor::self() { 59OTaskEditor* Editor::self() {
59 if (!m_self ) 60 if (!m_self )
60 m_self = new OTaskEditor(0); 61 m_self = new OTaskEditor(0);
61 62
62 return m_self; 63 return m_self;
63} 64}
diff --git a/core/pim/todo/todomanager.cpp b/core/pim/todo/todomanager.cpp
index 21e1d0c..7826747 100644
--- a/core/pim/todo/todomanager.cpp
+++ b/core/pim/todo/todomanager.cpp
@@ -1,127 +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
29#include <opie2/odebug.h>
30
28#include <qpe/categoryselect.h> 31#include <qpe/categoryselect.h>
29 32
30#include "todomanager.h" 33#include "todomanager.h"
31 34
32using namespace Todo; 35using namespace Todo;
33 36
34TodoManager::TodoManager( QObject *obj ) 37TodoManager::TodoManager( QObject *obj )
35 : QObject( obj ) { 38 : QObject( obj ) {
36 m_db = 0l; 39 m_db = 0l;
37 QTime time; 40 QTime time;
38 time.start(); 41 time.start();
39 int el = time.elapsed(); 42 int el = time.elapsed();
40 qWarning("QTimer for loading %d", el/1000 ); 43 Opie::Core::owarn << "QTimer for loading " << el/1000 << oendl;
41} 44}
42TodoManager::~TodoManager() { 45TodoManager::~TodoManager() {
43 delete m_db; 46 delete m_db;
44} 47}
45OPimTodo TodoManager::event(int uid ) { 48OPimTodo TodoManager::event(int uid ) {
46 return m_db->find( uid ); 49 return m_db->find( uid );
47} 50}
48void TodoManager::updateList() { 51void TodoManager::updateList() {
49 qWarning("update list"); 52 Opie::Core::owarn << "update lists" << oendl;
50 m_list = m_db->allRecords(); 53 m_list = m_db->allRecords();
51} 54}
52OPimTodoAccess::List TodoManager::list() const{ 55OPimTodoAccess::List TodoManager::list() const{
53 return m_list; 56 return m_list;
54} 57}
55OPimTodoAccess::List TodoManager::sorted( bool asc, int so, int f, int cat ) { 58OPimTodoAccess::List TodoManager::sorted( bool asc, int so, int f, int cat ) {
56 return m_db->sorted( asc, so, f, cat ); 59 return m_db->sorted( asc, so, f, cat );
57} 60}
58OPimTodoAccess::List::Iterator TodoManager::overDue() { 61OPimTodoAccess::List::Iterator TodoManager::overDue() {
59 int filter = 2 | 1; 62 int filter = 2 | 1;
60 m_list = m_db->sorted(m_asc, m_sortOrder, filter, m_ca ); 63 m_list = m_db->sorted(m_asc, m_sortOrder, filter, m_ca );
61 m_it = m_list.begin(); 64 m_it = m_list.begin();
62 return m_it; 65 return m_it;
63} 66}
64OPimTodoAccess::List::Iterator TodoManager::fromTo( const QDate& start, 67OPimTodoAccess::List::Iterator TodoManager::fromTo( const QDate& start,
65 const QDate& end ) { 68 const QDate& end ) {
66 m_list = m_db->effectiveToDos( start, end ); 69 m_list = m_db->effectiveToDos( start, end );
67 m_it = m_list.begin(); 70 m_it = m_list.begin();
68 return m_it; 71 return m_it;
69} 72}
70OPimTodoAccess::List::Iterator TodoManager::query( const OPimTodo& ev, int query ) { 73OPimTodoAccess::List::Iterator TodoManager::query( const OPimTodo& ev, int query ) {
71 m_list = m_db->queryByExample( ev, query ); 74 m_list = m_db->queryByExample( ev, query );
72 m_it = m_list.begin(); 75 m_it = m_list.begin();
73 return m_it; 76 return m_it;
74} 77}
75OPimTodoAccess* TodoManager::todoDB() { 78OPimTodoAccess* TodoManager::todoDB() {
76 return m_db; 79 return m_db;
77} 80}
78void TodoManager::add( const OPimTodo& ev ) { 81void TodoManager::add( const OPimTodo& ev ) {
79 m_db->add( ev ); 82 m_db->add( ev );
80} 83}
81void TodoManager::update( int, const SmallTodo& ) { 84void TodoManager::update( int, const SmallTodo& ) {
82 85
83} 86}
84void TodoManager::update( int, const OPimTodo& ev) { 87void TodoManager::update( int, const OPimTodo& ev) {
85 m_db->replace( ev ); 88 m_db->replace( ev );
86} 89}
87bool TodoManager::remove( int uid ) { 90bool TodoManager::remove( int uid ) {
88 return m_db->remove( uid ); 91 return m_db->remove( uid );
89} 92}
90void TodoManager::removeAll() { 93void TodoManager::removeAll() {
91 m_db->clear(); 94 m_db->clear();
92} 95}
93void TodoManager::removeCompleted() { 96void TodoManager::removeCompleted() {
94 m_db->removeAllCompleted(); 97 m_db->removeAllCompleted();
95} 98}
96void TodoManager::save() { 99void TodoManager::save() {
97 m_db->save(); 100 m_db->save();
98} 101}
99bool TodoManager::saveAll() { 102bool TodoManager::saveAll() {
100 return m_db->save(); 103 return m_db->save();
101} 104}
102void TodoManager::reload() { 105void TodoManager::reload() {
103 m_db->reload(); 106 m_db->reload();
104} 107}
105QStringList TodoManager::categories() { 108QStringList TodoManager::categories() {
106 m_cat.load(categoryFileName() ); 109 m_cat.load(categoryFileName() );
107 return m_cat.labels( "Todo List"); 110 return m_cat.labels( "Todo List");
108} 111}
109/* 112/*
110 * we rely on load beeing called from populateCategories 113 * we rely on load beeing called from populateCategories
111 */ 114 */
112int TodoManager::catId( const QString& cats ) { 115int TodoManager::catId( const QString& cats ) {
113 return m_cat.id( "Todo List", cats ); 116 return m_cat.id( "Todo List", cats );
114} 117}
115void TodoManager::remove( const QArray<int>& ids) { 118void TodoManager::remove( const QArray<int>& ids) {
116 for (uint i=0; i < ids.size(); i++ ) 119 for (uint i=0; i < ids.size(); i++ )
117 remove( ids[i] ); 120 remove( ids[i] );
118} 121}
119bool TodoManager::isLoaded()const { 122bool TodoManager::isLoaded()const {
120 return (m_db == 0 ); 123 return (m_db == 0 );
121} 124}
122void TodoManager::load() { 125void TodoManager::load() {
123 if (!m_db) { 126 if (!m_db) {
124 m_db = new OPimTodoAccess(); 127 m_db = new OPimTodoAccess();
125 m_db->load(); 128 m_db->load();
126 } 129 }
127} 130}
diff --git a/core/pim/todo/todotemplatemanager.cpp b/core/pim/todo/todotemplatemanager.cpp
index eeac51b..0b20d5a 100644
--- a/core/pim/todo/todotemplatemanager.cpp
+++ b/core/pim/todo/todotemplatemanager.cpp
@@ -1,81 +1,82 @@
1#include <opie2/odebug.h>
1#include <opie2/otodoaccess.h> 2#include <opie2/otodoaccess.h>
2#include <opie2/otodoaccessxml.h> 3#include <opie2/otodoaccessxml.h>
3 4
4#include <qpe/config.h> 5#include <qpe/config.h>
5#include <qpe/global.h> 6#include <qpe/global.h>
6 7
7#include "todotemplatemanager.h" 8#include "todotemplatemanager.h"
8 9
9 10
10using namespace Todo; 11using namespace Todo;
11 12
12TemplateManager::TemplateManager() { 13TemplateManager::TemplateManager() {
13 m_path = Global::applicationFileName("todolist", "templates.xml"); 14 m_path = Global::applicationFileName("todolist", "templates.xml");
14} 15}
15TemplateManager::~TemplateManager() { 16TemplateManager::~TemplateManager() {
16 save(); 17 save();
17} 18}
18void TemplateManager::load() { 19void TemplateManager::load() {
19 Config conf("todolist_templates"); 20 Config conf("todolist_templates");
20 OPimTodoAccessXML *xml = new OPimTodoAccessXML( QString::fromLatin1("template"), 21 OPimTodoAccessXML *xml = new OPimTodoAccessXML( QString::fromLatin1("template"),
21 m_path ); 22 m_path );
22 OPimTodoAccess todoDB(xml ); 23 OPimTodoAccess todoDB(xml );
23 todoDB.load(); 24 todoDB.load();
24 25
25 OPimTodoAccess::List::Iterator it; 26 OPimTodoAccess::List::Iterator it;
26 OPimTodoAccess::List list = todoDB.allRecords(); 27 OPimTodoAccess::List list = todoDB.allRecords();
27 for ( it = list.begin(); it != list.end(); ++it ) { 28 for ( it = list.begin(); it != list.end(); ++it ) {
28 OPimTodo ev = (*it); 29 OPimTodo ev = (*it);
29 conf.setGroup( QString::number( ev.uid() ) ); 30 conf.setGroup( QString::number( ev.uid() ) );
30 QString str = conf.readEntry("Name", QString::null ); 31 QString str = conf.readEntry("Name", QString::null );
31 if (str.isEmpty() ) 32 if (str.isEmpty() )
32 continue; 33 continue;
33 34
34 m_templates.insert( str, ev ); 35 m_templates.insert( str, ev );
35 } 36 }
36} 37}
37void TemplateManager::save() { 38void TemplateManager::save() {
38 qWarning("Saving!!!!"); 39 Opie::Core::owarn << "Saving!!!!" << oendl;
39 Config conf("todolist_templates"); 40 Config conf("todolist_templates");
40 41
41 OPimTodoAccessXML *res = new OPimTodoAccessXML( "template", 42 OPimTodoAccessXML *res = new OPimTodoAccessXML( "template",
42 m_path ); 43 m_path );
43 OPimTodoAccess db(res); 44 OPimTodoAccess db(res);
44 db.load(); 45 db.load();
45 db.clear(); 46 db.clear();
46 47
47 48
48 QMap<QString, OPimTodo>::Iterator it; 49 QMap<QString, OPimTodo>::Iterator it;
49 for ( it = m_templates.begin(); it != m_templates.end(); ++it ) { 50 for ( it = m_templates.begin(); it != m_templates.end(); ++it ) {
50 OPimTodo ev = it.data(); 51 OPimTodo ev = it.data();
51 conf.setGroup( QString::number( ev.uid() ) ); 52 conf.setGroup( QString::number( ev.uid() ) );
52 qWarning("Name" + it.key() ); 53 Opie::Core::owarn << "Name " << it.key() << oendl;
53 conf.writeEntry("Name", it.key() ); 54 conf.writeEntry("Name", it.key() );
54 db.add( ev ); 55 db.add( ev );
55 } 56 }
56 db.save(); 57 db.save();
57} 58}
58void TemplateManager::addEvent( const QString& str, 59void TemplateManager::addEvent( const QString& str,
59 const OPimTodo& ev) { 60 const OPimTodo& ev) {
60 qWarning("AddEvent"+ str ); 61 Opie::Core::owarn << "AddEvent " << str << oendl;
61 OPimTodo todo = ev; 62 OPimTodo todo = ev;
62 if( ev.uid() == 0 ) 63 if( ev.uid() == 0 )
63 todo.setUid(1); // generate a new uid 64 todo.setUid(1); // generate a new uid
64 65
65 m_templates.replace( str, todo ); 66 m_templates.replace( str, todo );
66} 67}
67void TemplateManager::removeEvent( const QString& str ) { 68void TemplateManager::removeEvent( const QString& str ) {
68 m_templates.remove( str ); 69 m_templates.remove( str );
69} 70}
70QStringList TemplateManager::templates() const { 71QStringList TemplateManager::templates() const {
71 QStringList list; 72 QStringList list;
72 QMap<QString, OPimTodo>::ConstIterator it; 73 QMap<QString, OPimTodo>::ConstIterator it;
73 for (it = m_templates.begin(); it != m_templates.end(); ++it ) { 74 for (it = m_templates.begin(); it != m_templates.end(); ++it ) {
74 list << it.key(); 75 list << it.key();
75 } 76 }
76 77
77 return list; 78 return list;
78} 79}
79OPimTodo TemplateManager::templateEvent( const QString& templateName ) { 80OPimTodo TemplateManager::templateEvent( const QString& templateName ) {
80 return m_templates[templateName]; 81 return m_templates[templateName];
81} 82}
diff --git a/core/pim/todo/todoview.cpp b/core/pim/todo/todoview.cpp
index d99cf77..03e1060 100644
--- a/core/pim/todo/todoview.cpp
+++ b/core/pim/todo/todoview.cpp
@@ -1,69 +1,71 @@
1#include "mainwindow.h" 1#include "mainwindow.h"
2 2
3#include <opie2/odebug.h>
4
3#include "todoview.h" 5#include "todoview.h"
4 6
5using namespace Todo; 7using namespace Todo;
6 8
7 9
8 10
9 11
10TodoView::TodoView( MainWindow* win ) 12TodoView::TodoView( MainWindow* win )
11 : m_main( win ) 13 : m_main( win )
12{ 14{
13 m_asc = false; 15 m_asc = false;
14 m_sortOrder = -1; 16 m_sortOrder = -1;
15} 17}
16TodoView::~TodoView() { 18TodoView::~TodoView() {
17}; 19};
18MainWindow* TodoView::todoWindow() { 20MainWindow* TodoView::todoWindow() {
19 return m_main; 21 return m_main;
20} 22}
21 23
22OPimTodo TodoView::event(int uid ) { 24OPimTodo TodoView::event(int uid ) {
23 return m_main->event( uid ); 25 return m_main->event( uid );
24} 26}
25OPimTodoAccess::List TodoView::list(){ 27OPimTodoAccess::List TodoView::list(){
26 todoWindow()->updateList(); 28 todoWindow()->updateList();
27 return todoWindow()->list(); 29 return todoWindow()->list();
28} 30}
29OPimTodoAccess::List TodoView::sorted()const{ 31OPimTodoAccess::List TodoView::sorted()const{
30 return m_sort; 32 return m_sort;
31} 33}
32void TodoView::sort() { 34void TodoView::sort() {
33 m_sort = todoWindow()->sorted(m_asc,m_sortOrder ); 35 m_sort = todoWindow()->sorted(m_asc,m_sortOrder );
34 qWarning("m_sort.count() = %d", m_sort.count() ); 36 Opie::Core::owarn << "m_sort.count() = " << m_sort.count() << oendl;
35} 37}
36void TodoView::sort(int sort) { 38void TodoView::sort(int sort) {
37 m_sort = todoWindow()->sorted(m_asc, m_sortOrder, sort ); 39 m_sort = todoWindow()->sorted(m_asc, m_sortOrder, sort );
38} 40}
39void TodoView::setSortOrder( int order ) { 41void TodoView::setSortOrder( int order ) {
40 m_sortOrder = order; 42 m_sortOrder = order;
41} 43}
42void TodoView::setAscending( bool b ) { 44void TodoView::setAscending( bool b ) {
43 qWarning("setAscending %d", b ); 45 Opie::Core::owarn << "setAscending " << b << oendl;
44 m_asc = b; 46 m_asc = b;
45} 47}
46void TodoView::update(int, const SmallTodo& ) { 48void TodoView::update(int, const SmallTodo& ) {
47 //m_main->slotUpate1( uid, to ); 49 //m_main->slotUpate1( uid, to );
48} 50}
49void TodoView::update(int , const OPimTodo& ev ) { 51void TodoView::update(int , const OPimTodo& ev ) {
50 m_main->updateTodo( ev ); 52 m_main->updateTodo( ev );
51} 53}
52void TodoView::showTodo( int uid ) { 54void TodoView::showTodo( int uid ) {
53 m_main->slotShow( uid ); 55 m_main->slotShow( uid );
54} 56}
55void TodoView::edit( int uid ) { 57void TodoView::edit( int uid ) {
56 m_main->slotEdit( uid ); 58 m_main->slotEdit( uid );
57} 59}
58void TodoView::remove( int uid ) { 60void TodoView::remove( int uid ) {
59 m_main->m_todoMgr.remove( uid ); 61 m_main->m_todoMgr.remove( uid );
60} 62}
61void TodoView::complete( int uid ) { 63void TodoView::complete( int uid ) {
62 m_main->slotComplete( uid ); 64 m_main->slotComplete( uid );
63} 65}
64void TodoView::complete( const OPimTodo& ev ) { 66void TodoView::complete( const OPimTodo& ev ) {
65 m_main->slotComplete( ev ); 67 m_main->slotComplete( ev );
66} 68}
67void TodoView::removeQuery( int uid ) { 69void TodoView::removeQuery( int uid ) {
68 m_main->slotDelete( uid ); 70 m_main->slotDelete( uid );
69} 71}