summaryrefslogtreecommitdiff
authorzecke <zecke>2002-10-25 22:12:35 (UTC)
committer zecke <zecke>2002-10-25 22:12:35 (UTC)
commitb682e9d2276c10a5c26773c6797ba1ac176ea4cf (patch) (unidiff)
tree9780ad571f14943e3ad6c3ec34a4e787f8a85217
parent595407074ac5724eb33aeb151ce27e38fbca21d5 (diff)
downloadopie-b682e9d2276c10a5c26773c6797ba1ac176ea4cf.zip
opie-b682e9d2276c10a5c26773c6797ba1ac176ea4cf.tar.gz
opie-b682e9d2276c10a5c26773c6797ba1ac176ea4cf.tar.bz2
MainWindow i18n change 'Show only over due' to avoid misunderstanding
then 'share' and 'preload' the taskeditor on first request it'll be created but on destroyed until Destruction the interface. This will happen when the apps quits. This should speed up editing and entering quite a lot
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/todo/mainwindow.cpp2
-rw-r--r--core/pim/todo/otaskeditor.cpp19
-rw-r--r--core/pim/todo/otaskeditor.h7
-rw-r--r--core/pim/todo/taskeditoroverviewimpl.cpp12
-rw-r--r--core/pim/todo/todoeditor.cpp32
-rw-r--r--core/pim/todo/todoeditor.h4
6 files changed, 59 insertions, 17 deletions
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp
index 71e6750..9b2423b 100644
--- a/core/pim/todo/mainwindow.cpp
+++ b/core/pim/todo/mainwindow.cpp
@@ -1,706 +1,706 @@
1/* 1/*
2               =. This file is part of the OPIE Project 2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 <> 3             .=l. Copyright (c) 2002 <>
4           .>+-= 4           .>+-=
5 _;:,     .>    :=|. This program is free software; you can 5 _;:,     .>    :=|. This program is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under 6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU General Public 7:`=1 )Y*s>-.--   : the terms of the GNU General Public
8.="- .-=="i,     .._ License as published by the Free Software 8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License, 9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version. 10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_. 11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This program is distributed in the hope that 12    .i_,=:_.      -<s. This program is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of 14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more 17..}^=.=       =       ; Library General Public License for more
18++=   -.     .`     .: details. 18++=   -.     .`     .: details.
19 :     =  ...= . :.=- 19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU 20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = General Public License along with 21  -_. . .   )=.  = General Public License along with
22    --        :-=` this library; see the file COPYING.LIB. 22    --        :-=` this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation, 23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330, 24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29#include <unistd.h> 29#include <unistd.h>
30 30
31#include <qmenubar.h> 31#include <qmenubar.h>
32#include <qmessagebox.h> 32#include <qmessagebox.h>
33#include <qtoolbar.h> 33#include <qtoolbar.h>
34#include <qpopupmenu.h> 34#include <qpopupmenu.h>
35#include <qwidgetstack.h> 35#include <qwidgetstack.h>
36#include <qaction.h> 36#include <qaction.h>
37#include <qtimer.h> 37#include <qtimer.h>
38#include <qvbox.h> 38#include <qvbox.h>
39#include <qlineedit.h> 39#include <qlineedit.h>
40 40
41#include <qpe/applnk.h> 41#include <qpe/applnk.h>
42#include <qpe/config.h> 42#include <qpe/config.h>
43#include <qpe/ir.h> 43#include <qpe/ir.h>
44#include <qpe/resource.h> 44#include <qpe/resource.h>
45#include <qpe/qpemessagebox.h> 45#include <qpe/qpemessagebox.h>
46 46
47#include <opie/otodoaccessvcal.h> 47#include <opie/otodoaccessvcal.h>
48 48
49#include "quickeditimpl.h" 49#include "quickeditimpl.h"
50#include "todotemplatemanager.h" 50#include "todotemplatemanager.h"
51#include "templateeditor.h" 51#include "templateeditor.h"
52#include "tableview.h" 52#include "tableview.h"
53 53
54#include "textviewshow.h" 54#include "textviewshow.h"
55#include "todoeditor.h" 55#include "todoeditor.h"
56#include "mainwindow.h" 56#include "mainwindow.h"
57 57
58 58
59using namespace Todo; 59using namespace Todo;
60 60
61MainWindow::MainWindow( QWidget* parent, 61MainWindow::MainWindow( QWidget* parent,
62 const char* name ) { 62 const char* name ) {
63 63
64 m_syncing = false; 64 m_syncing = false;
65 m_counter = 0; 65 m_counter = 0;
66 m_tempManager = new TemplateManager(); 66 m_tempManager = new TemplateManager();
67 m_tempManager->load(); 67 m_tempManager->load();
68 68
69 initUI(); 69 initUI();
70 initConfig(); 70 initConfig();
71 initViews(); 71 initViews();
72 initActions(); 72 initActions();
73 initEditor(); 73 initEditor();
74 initShow(); 74 initShow();
75 initTemplate(); 75 initTemplate();
76 76
77 populateTemplates(); 77 populateTemplates();
78 raiseCurrentView(); 78 raiseCurrentView();
79 QTimer::singleShot(0, this, SLOT(populateCategories() ) ); 79 QTimer::singleShot(0, this, SLOT(populateCategories() ) );
80} 80}
81void MainWindow::initTemplate() { 81void MainWindow::initTemplate() {
82 m_curTempEd = new TemplateEditor( this, templateManager() ); 82 m_curTempEd = new TemplateEditor( this, templateManager() );
83} 83}
84void MainWindow::initActions() { 84void MainWindow::initActions() {
85 QAction* a = new QAction( tr("New Task" ), Resource::loadPixmap( "new" ), 85 QAction* a = new QAction( tr("New Task" ), Resource::loadPixmap( "new" ),
86 QString::null, 0, this, 0 ); 86 QString::null, 0, this, 0 );
87 connect(a, SIGNAL( activated() ), 87 connect(a, SIGNAL( activated() ),
88 this, SLOT( slotNew() ) ); 88 this, SLOT( slotNew() ) );
89 a->addTo(m_tool ); 89 a->addTo(m_tool );
90 a->addTo(m_edit ); 90 a->addTo(m_edit );
91 91
92 a = new QAction( tr("Edit Task"), Resource::loadIconSet( "edit" ), 92 a = new QAction( tr("Edit Task"), Resource::loadIconSet( "edit" ),
93 QString::null, 0, this, 0 ); 93 QString::null, 0, this, 0 );
94 connect(a, SIGNAL(activated() ), 94 connect(a, SIGNAL(activated() ),
95 this, SLOT( slotEdit() ) ); 95 this, SLOT( slotEdit() ) );
96 a->addTo( m_tool ); 96 a->addTo( m_tool );
97 a->addTo( m_edit ); 97 a->addTo( m_edit );
98 m_editAction = a; 98 m_editAction = a;
99 99
100 a = new QAction( QString::null, tr("View Task"), 0, this, 0 ); 100 a = new QAction( QString::null, tr("View Task"), 0, this, 0 );
101 connect(a, SIGNAL( activated() ), 101 connect(a, SIGNAL( activated() ),
102 this, SLOT( slotShowDetails() ) ); 102 this, SLOT( slotShowDetails() ) );
103 a->addTo( m_edit ); 103 a->addTo( m_edit );
104 104
105 m_edit->insertSeparator(); 105 m_edit->insertSeparator();
106 106
107 a = new QAction( tr("Delete..."), Resource::loadIconSet( "trash" ), 107 a = new QAction( tr("Delete..."), Resource::loadIconSet( "trash" ),
108 QString::null, 0, this, 0 ); 108 QString::null, 0, this, 0 );
109 connect(a, SIGNAL(activated() ), 109 connect(a, SIGNAL(activated() ),
110 this, SLOT(slotDelete() ) ); 110 this, SLOT(slotDelete() ) );
111 a->addTo( m_tool ); 111 a->addTo( m_tool );
112 a->addTo( m_edit ); 112 a->addTo( m_edit );
113 m_deleteAction = a; 113 m_deleteAction = a;
114 114
115 a = new QAction( QString::null, tr("Delete all..."), 0, this, 0 ); 115 a = new QAction( QString::null, tr("Delete all..."), 0, this, 0 );
116 connect(a, SIGNAL( activated() ), 116 connect(a, SIGNAL( activated() ),
117 this, SLOT( slotDeleteAll() ) ); 117 this, SLOT( slotDeleteAll() ) );
118 a->addTo(m_edit ); 118 a->addTo(m_edit );
119 m_deleteAllAction = a; 119 m_deleteAllAction = a;
120 120
121 a = new QAction( QString::null, tr("Delete completed"), 121 a = new QAction( QString::null, tr("Delete completed"),
122 0, this, 0 ); 122 0, this, 0 );
123 connect(a, SIGNAL( activated() ), 123 connect(a, SIGNAL( activated() ),
124 this, SLOT( slotDeleteCompleted() ) ); 124 this, SLOT( slotDeleteCompleted() ) );
125 a->addTo(m_edit ); 125 a->addTo(m_edit );
126 a->setEnabled( TRUE ); 126 a->setEnabled( TRUE );
127 m_deleteCompleteAction = a; 127 m_deleteCompleteAction = a;
128 128
129 m_edit->insertSeparator(); 129 m_edit->insertSeparator();
130 130
131 a = new QAction( QString::null, tr("Duplicate"), 0, this, 0 ); 131 a = new QAction( QString::null, tr("Duplicate"), 0, this, 0 );
132 connect(a, SIGNAL( activated() ), 132 connect(a, SIGNAL( activated() ),
133 this, SLOT( slotDuplicate() ) ); 133 this, SLOT( slotDuplicate() ) );
134 a->addTo(m_edit ); 134 a->addTo(m_edit );
135 m_duplicateAction = a; 135 m_duplicateAction = a;
136 136
137 m_edit->insertSeparator(); 137 m_edit->insertSeparator();
138 138
139 if ( Ir::supported() ) { 139 if ( Ir::supported() ) {
140 a = new QAction( tr( "Beam" ), Resource::loadPixmap( "beam" ), 140 a = new QAction( tr( "Beam" ), Resource::loadPixmap( "beam" ),
141 QString::null, 0, this, 0 ); 141 QString::null, 0, this, 0 );
142 connect( a, SIGNAL( activated() ), 142 connect( a, SIGNAL( activated() ),
143 this, SLOT( slotBeam() ) ); 143 this, SLOT( slotBeam() ) );
144 a->addTo( m_edit ); 144 a->addTo( m_edit );
145 a->addTo( m_tool ); 145 a->addTo( m_tool );
146 } 146 }
147 147
148 a = new QAction( tr("Find"), Resource::loadIconSet( "mag" ), 148 a = new QAction( tr("Find"), Resource::loadIconSet( "mag" ),
149 QString::null, 0, this, 0 ); 149 QString::null, 0, this, 0 );
150 connect(a, SIGNAL( activated() ), 150 connect(a, SIGNAL( activated() ),
151 this, SLOT( slotFind() ) ); 151 this, SLOT( slotFind() ) );
152 a->addTo( m_options ); 152 a->addTo( m_options );
153 m_findAction = a; 153 m_findAction = a;
154 154
155 m_options->insertSeparator(); 155 m_options->insertSeparator();
156 156
157 m_completedAction = new QAction( QString::null, tr("Completed tasks"), 157 m_completedAction = new QAction( QString::null, tr("Completed tasks"),
158 0, this, 0, TRUE ); 158 0, this, 0, TRUE );
159 m_completedAction->addTo( m_options ); 159 m_completedAction->addTo( m_options );
160 m_completedAction->setOn( showCompleted() ); 160 m_completedAction->setOn( showCompleted() );
161 connect(m_completedAction, SIGNAL( toggled(bool) ), 161 connect(m_completedAction, SIGNAL( toggled(bool) ),
162 this, SLOT(slotShowCompleted(bool) ) ); 162 this, SLOT(slotShowCompleted(bool) ) );
163 163
164 m_showDeadLineAction = new QAction( QString::null, tr("Show Deadline"), 164 m_showDeadLineAction = new QAction( QString::null, tr("Show Deadline"),
165 0, this, 0, TRUE ); 165 0, this, 0, TRUE );
166 m_showDeadLineAction->addTo( m_options ); 166 m_showDeadLineAction->addTo( m_options );
167 m_showDeadLineAction->setOn( showDeadline() ); 167 m_showDeadLineAction->setOn( showDeadline() );
168 connect(m_showDeadLineAction, SIGNAL(toggled(bool) ), 168 connect(m_showDeadLineAction, SIGNAL(toggled(bool) ),
169 this, SLOT( slotShowDeadLine( bool ) ) ); 169 this, SLOT( slotShowDeadLine( bool ) ) );
170 170
171 m_options->insertSeparator(); 171 m_options->insertSeparator();
172 172
173 m_bar->insertItem( tr("Data") ,m_edit ); 173 m_bar->insertItem( tr("Data") ,m_edit );
174 m_bar->insertItem( tr("Category"), m_catMenu ); 174 m_bar->insertItem( tr("Category"), m_catMenu );
175 m_bar->insertItem( tr("Options"), m_options ); 175 m_bar->insertItem( tr("Options"), m_options );
176 176
177 /* initialize the view menu */ 177 /* initialize the view menu */
178 a = new QAction( QString::null, tr("Show over due"), 178 a = new QAction( QString::null, tr("Show only over due"),
179 0, this, 0, TRUE ); 179 0, this, 0, TRUE );
180 a->addTo( m_view ); 180 a->addTo( m_view );
181 a->setOn( showOverDue() ); 181 a->setOn( showOverDue() );
182 connect(a, SIGNAL(toggled(bool)), 182 connect(a, SIGNAL(toggled(bool)),
183 this, SLOT(slotShowDue(bool) ) ); 183 this, SLOT(slotShowDue(bool) ) );
184 m_view->insertSeparator(); 184 m_view->insertSeparator();
185 185
186 m_bar->insertItem( tr("View"), m_view ); 186 m_bar->insertItem( tr("View"), m_view );
187 187
188 /* templates */ 188 /* templates */
189 m_edit->insertItem(tr("New from template"), m_template, 189 m_edit->insertItem(tr("New from template"), m_template,
190 -1, 0 ); 190 -1, 0 );
191 191
192} 192}
193/* m_curCat from Config */ 193/* m_curCat from Config */
194void MainWindow::initConfig() { 194void MainWindow::initConfig() {
195 Config config( "todo" ); 195 Config config( "todo" );
196 config.setGroup( "View" ); 196 config.setGroup( "View" );
197 m_completed = config.readBoolEntry( "ShowComplete", TRUE ); 197 m_completed = config.readBoolEntry( "ShowComplete", TRUE );
198 m_curCat = config.readEntry( "Category", QString::null ); 198 m_curCat = config.readEntry( "Category", QString::null );
199 m_deadline = config.readBoolEntry( "ShowDeadLine", TRUE); 199 m_deadline = config.readBoolEntry( "ShowDeadLine", TRUE);
200 m_overdue = config.readBoolEntry("ShowOverDue", TRUE ); 200 m_overdue = config.readBoolEntry("ShowOverDue", TRUE );
201} 201}
202void MainWindow::initUI() { 202void MainWindow::initUI() {
203 m_mainBox = new QVBox(this, "main box "); 203 m_mainBox = new QVBox(this, "main box ");
204 m_curQuick = new QuickEditImpl(this, m_mainBox ); 204 m_curQuick = new QuickEditImpl(this, m_mainBox );
205 m_curQuick->signal()->connect( this, SLOT(slotQuickEntered() ) ); 205 m_curQuick->signal()->connect( this, SLOT(slotQuickEntered() ) );
206 m_quickEdit.append( m_curQuick ); 206 m_quickEdit.append( m_curQuick );
207 207
208 208
209 209
210 m_stack = new QWidgetStack(m_mainBox, "main stack"); 210 m_stack = new QWidgetStack(m_mainBox, "main stack");
211 setCentralWidget( m_mainBox ); 211 setCentralWidget( m_mainBox );
212 212
213 setToolBarsMovable( FALSE ); 213 setToolBarsMovable( FALSE );
214 214
215 m_tool = new QToolBar( this ); 215 m_tool = new QToolBar( this );
216 m_tool->setHorizontalStretchable( TRUE ); 216 m_tool->setHorizontalStretchable( TRUE );
217 217
218 m_bar = new QMenuBar( m_tool ); 218 m_bar = new QMenuBar( m_tool );
219 219
220 /** QPopupMenu */ 220 /** QPopupMenu */
221 m_edit = new QPopupMenu( this ); 221 m_edit = new QPopupMenu( this );
222 m_options = new QPopupMenu( this ); 222 m_options = new QPopupMenu( this );
223 m_view = new QPopupMenu( this ); 223 m_view = new QPopupMenu( this );
224 m_catMenu = new QPopupMenu( this ); 224 m_catMenu = new QPopupMenu( this );
225 m_template = new QPopupMenu( this ); 225 m_template = new QPopupMenu( this );
226 226
227 m_catMenu->setCheckable( TRUE ); 227 m_catMenu->setCheckable( TRUE );
228 m_template->setCheckable( TRUE ); 228 m_template->setCheckable( TRUE );
229 229
230 connect(m_catMenu, SIGNAL(activated(int) ), 230 connect(m_catMenu, SIGNAL(activated(int) ),
231 this, SLOT(setCategory(int) ) ); 231 this, SLOT(setCategory(int) ) );
232 connect(m_template, SIGNAL(activated(int) ), 232 connect(m_template, SIGNAL(activated(int) ),
233 this, SLOT(slotNewFromTemplate(int) ) ); 233 this, SLOT(slotNewFromTemplate(int) ) );
234} 234}
235void MainWindow::initViews() { 235void MainWindow::initViews() {
236 TableView* tableView = new TableView( this, m_stack ); 236 TableView* tableView = new TableView( this, m_stack );
237 m_stack->addWidget( tableView, m_counter++ ); 237 m_stack->addWidget( tableView, m_counter++ );
238 m_views.append( tableView ); 238 m_views.append( tableView );
239 m_curView = tableView; 239 m_curView = tableView;
240 connectBase( tableView ); 240 connectBase( tableView );
241 /* add QString type + QString configname to 241 /* add QString type + QString configname to
242 * the View menu 242 * the View menu
243 * and subdirs for multiple views 243 * and subdirs for multiple views
244 */ 244 */
245} 245}
246void MainWindow::initEditor() { 246void MainWindow::initEditor() {
247 m_curEdit = new Editor(); 247 m_curEdit = new Editor();
248} 248}
249void MainWindow::initShow() { 249void MainWindow::initShow() {
250 m_curShow = new TextViewShow(this); 250 m_curShow = new TextViewShow(this);
251 m_stack->addWidget( m_curShow->widget() , m_counter++ ); 251 m_stack->addWidget( m_curShow->widget() , m_counter++ );
252} 252}
253MainWindow::~MainWindow() { 253MainWindow::~MainWindow() {
254 delete templateManager(); 254 delete templateManager();
255} 255}
256void MainWindow::connectBase( ViewBase* base) { 256void MainWindow::connectBase( ViewBase* base) {
257 base->connectShow( this, SLOT(slotShow(int) ) ); 257 base->connectShow( this, SLOT(slotShow(int) ) );
258 base->connectEdit( this, SLOT(slotEdit(int) ) ); 258 base->connectEdit( this, SLOT(slotEdit(int) ) );
259 base->connectUpdateSmall( this, 259 base->connectUpdateSmall( this,
260 SLOT(slotUpate1(int, const Todo::SmallTodo&) )); 260 SLOT(slotUpate1(int, const Todo::SmallTodo&) ));
261 base->connectUpdateBig( this, 261 base->connectUpdateBig( this,
262 SLOT(slotUpate2(int, const OTodo& ) ) ); 262 SLOT(slotUpate2(int, const OTodo& ) ) );
263 base->connectUpdateView( this, SLOT(slotUpdate3( QWidget* ) ) ) ; 263 base->connectUpdateView( this, SLOT(slotUpdate3( QWidget* ) ) ) ;
264 base->connectRemove(&m_todoMgr, 264 base->connectRemove(&m_todoMgr,
265 SLOT(remove(int)) ); 265 SLOT(remove(int)) );
266} 266}
267QPopupMenu* MainWindow::contextMenu( int uid ) { 267QPopupMenu* MainWindow::contextMenu( int uid ) {
268 QPopupMenu* menu = new QPopupMenu(); 268 QPopupMenu* menu = new QPopupMenu();
269 269
270 m_editAction->addTo( menu ); 270 m_editAction->addTo( menu );
271 m_deleteAction->addTo( menu ); 271 m_deleteAction->addTo( menu );
272 m_duplicateAction->addTo( menu ); 272 m_duplicateAction->addTo( menu );
273 menu->insertSeparator(); 273 menu->insertSeparator();
274 274
275 return menu; 275 return menu;
276} 276}
277QPopupMenu* MainWindow::options() { 277QPopupMenu* MainWindow::options() {
278 qWarning("Options"); 278 qWarning("Options");
279 return m_options; 279 return m_options;
280} 280}
281QPopupMenu* MainWindow::edit() { 281QPopupMenu* MainWindow::edit() {
282 return m_edit; 282 return m_edit;
283} 283}
284QPopupMenu* MainWindow::view() { 284QPopupMenu* MainWindow::view() {
285 return m_view; 285 return m_view;
286} 286}
287QToolBar* MainWindow::toolbar() { 287QToolBar* MainWindow::toolbar() {
288 return m_tool; 288 return m_tool;
289} 289}
290OTodoAccess::List MainWindow::list()const { 290OTodoAccess::List MainWindow::list()const {
291 return m_todoMgr.list(); 291 return m_todoMgr.list();
292} 292}
293OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder ) { 293OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder ) {
294 int cat = 0; 294 int cat = 0;
295 if ( m_curCat != tr("All Categories") ) 295 if ( m_curCat != tr("All Categories") )
296 cat = currentCatId(); 296 cat = currentCatId();
297 297
298 int filter = 1; 298 int filter = 1;
299 299
300 if (!m_completed ) 300 if (!m_completed )
301 filter |= 4; 301 filter |= 4;
302 if (m_overdue) 302 if (m_overdue)
303 filter |= 2; 303 filter |= 2;
304 304
305 return m_todoMgr.sorted( asc, sortOrder, filter, cat ); 305 return m_todoMgr.sorted( asc, sortOrder, filter, cat );
306} 306}
307OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder, int addFilter) { 307OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder, int addFilter) {
308 int cat = 0; 308 int cat = 0;
309 if ( m_curCat != tr("All Categories") ) 309 if ( m_curCat != tr("All Categories") )
310 cat = currentCatId(); 310 cat = currentCatId();
311 311
312 return m_todoMgr.sorted(asc, sortOrder, addFilter, cat ); 312 return m_todoMgr.sorted(asc, sortOrder, addFilter, cat );
313} 313}
314OTodo MainWindow::event( int uid ) { 314OTodo MainWindow::event( int uid ) {
315 return m_todoMgr.event( uid ); 315 return m_todoMgr.event( uid );
316} 316}
317bool MainWindow::isSyncing()const { 317bool MainWindow::isSyncing()const {
318 return m_syncing; 318 return m_syncing;
319} 319}
320TemplateManager* MainWindow::templateManager() { 320TemplateManager* MainWindow::templateManager() {
321 return m_tempManager; 321 return m_tempManager;
322} 322}
323Editor* MainWindow::currentEditor() { 323Editor* MainWindow::currentEditor() {
324 return m_curEdit; 324 return m_curEdit;
325} 325}
326TodoShow* MainWindow::currentShow() { 326TodoShow* MainWindow::currentShow() {
327 return m_curShow; 327 return m_curShow;
328} 328}
329void MainWindow::slotReload() { 329void MainWindow::slotReload() {
330 m_todoMgr.reload(); 330 m_todoMgr.reload();
331 currentView()->updateView( ); 331 currentView()->updateView( );
332 raiseCurrentView(); 332 raiseCurrentView();
333} 333}
334void MainWindow::closeEvent( QCloseEvent* e ) { 334void MainWindow::closeEvent( QCloseEvent* e ) {
335 if (m_stack->visibleWidget() == currentShow()->widget() ) { 335 if (m_stack->visibleWidget() == currentShow()->widget() ) {
336 raiseCurrentView(); 336 raiseCurrentView();
337 e->ignore(); 337 e->ignore();
338 return; 338 return;
339 } 339 }
340 /* 340 /*
341 * we should have flushed and now we're still saving 341 * we should have flushed and now we're still saving
342 * so there is no need to flush 342 * so there is no need to flush
343 */ 343 */
344 if (m_syncing ) { 344 if (m_syncing ) {
345 e->accept(); 345 e->accept();
346 return; 346 return;
347 } 347 }
348 bool quit = false; 348 bool quit = false;
349 if ( m_todoMgr.saveAll() ){ 349 if ( m_todoMgr.saveAll() ){
350 qWarning("saved"); 350 qWarning("saved");
351 quit = true; 351 quit = true;
352 }else { 352 }else {
353 if ( QMessageBox::critical( this, tr("Out of space"), 353 if ( QMessageBox::critical( this, tr("Out of space"),
354 tr("Todo was unable\n" 354 tr("Todo was unable\n"
355 "to save your changes.\n" 355 "to save your changes.\n"
356 "Free up some space\n" 356 "Free up some space\n"
357 "and try again.\n" 357 "and try again.\n"
358 "\nQuit Anyway?"), 358 "\nQuit Anyway?"),
359 QMessageBox::Yes|QMessageBox::Escape, 359 QMessageBox::Yes|QMessageBox::Escape,
360 QMessageBox::No|QMessageBox::Default) 360 QMessageBox::No|QMessageBox::Default)
361 != QMessageBox::No ) { 361 != QMessageBox::No ) {
362 e->accept(); 362 e->accept();
363 quit = true; 363 quit = true;
364 }else 364 }else
365 e->ignore(); 365 e->ignore();
366 366
367 } 367 }
368 368
369 if (quit ) { 369 if (quit ) {
370 Config config( "todo" ); 370 Config config( "todo" );
371 config.setGroup( "View" ); 371 config.setGroup( "View" );
372 config.writeEntry( "ShowComplete", showCompleted() ); 372 config.writeEntry( "ShowComplete", showCompleted() );
373 config.writeEntry( "Category", currentCategory() ); 373 config.writeEntry( "Category", currentCategory() );
374 config.writeEntry( "ShowDeadLine", showDeadline()); 374 config.writeEntry( "ShowDeadLine", showDeadline());
375 config.writeEntry( "ShowOverDue", showOverDue() ); 375 config.writeEntry( "ShowOverDue", showOverDue() );
376 /* svae templates */ 376 /* svae templates */
377 templateManager()->save(); 377 templateManager()->save();
378 e->accept(); 378 e->accept();
379 } 379 }
380} 380}
381void MainWindow::populateTemplates() { 381void MainWindow::populateTemplates() {
382 m_template->clear(); 382 m_template->clear();
383 QStringList list = templateManager()->templates(); 383 QStringList list = templateManager()->templates();
384 QStringList::Iterator it; 384 QStringList::Iterator it;
385 for ( it = list.begin(); it != list.end(); ++it ) { 385 for ( it = list.begin(); it != list.end(); ++it ) {
386 m_template->insertItem( (*it) ); 386 m_template->insertItem( (*it) );
387 } 387 }
388} 388}
389/* 389/*
390 * slotNewFromTemplate 390 * slotNewFromTemplate
391 * We use the edit widget to do 391 * We use the edit widget to do
392 * the config but we setUid(-1) 392 * the config but we setUid(-1)
393 * to get a new uid 393 * to get a new uid
394 */ 394 */
395/* 395/*
396 * first we get the name of the template 396 * first we get the name of the template
397 * then we will use the TemplateManager 397 * then we will use the TemplateManager
398 */ 398 */
399void MainWindow::slotNewFromTemplate( int id ) { 399void MainWindow::slotNewFromTemplate( int id ) {
400 QString name = m_template->text( id ); 400 QString name = m_template->text( id );
401 401
402 OTodo event = templateManager()->templateEvent( name ); 402 OTodo event = templateManager()->templateEvent( name );
403 event = currentEditor()->edit(this, 403 event = currentEditor()->edit(this,
404 event ); 404 event );
405 405
406 if ( currentEditor()->accepted() ) { 406 if ( currentEditor()->accepted() ) {
407 /* assign new todo */ 407 /* assign new todo */
408 event.setUid( -1 ); 408 event.setUid( -1 );
409 currentView()->addEvent( event ); 409 currentView()->addEvent( event );
410 m_todoMgr.add( event ); 410 m_todoMgr.add( event );
411 411
412 populateCategories(); 412 populateCategories();
413 } 413 }
414} 414}
415void MainWindow::slotNew() { 415void MainWindow::slotNew() {
416 if(m_syncing) { 416 if(m_syncing) {
417 QMessageBox::warning(this, tr("Todo"), 417 QMessageBox::warning(this, tr("Todo"),
418 tr("Can not edit data, currently syncing")); 418 tr("Can not edit data, currently syncing"));
419 return; 419 return;
420 } 420 }
421 421
422 422
423 OTodo todo = currentEditor()->newTodo( currentCatId(), 423 OTodo todo = currentEditor()->newTodo( currentCatId(),
424 this ); 424 this );
425 425
426 if ( currentEditor()->accepted() ) { 426 if ( currentEditor()->accepted() ) {
427 //todo.assignUid(); 427 //todo.assignUid();
428 m_todoMgr.add( todo ); 428 m_todoMgr.add( todo );
429 currentView()->addEvent( todo ); 429 currentView()->addEvent( todo );
430 430
431 431
432 // I'm afraid we must call this every time now, otherwise 432 // I'm afraid we must call this every time now, otherwise
433 // spend expensive time comparing all these strings... 433 // spend expensive time comparing all these strings...
434 // but only call if we changed something -zecke 434 // but only call if we changed something -zecke
435 populateCategories(); 435 populateCategories();
436 } 436 }
437 raiseCurrentView( ); 437 raiseCurrentView( );
438} 438}
439void MainWindow::slotDuplicate() { 439void MainWindow::slotDuplicate() {
440 if(m_syncing) { 440 if(m_syncing) {
441 QMessageBox::warning(this, tr("Todo"), 441 QMessageBox::warning(this, tr("Todo"),
442 tr("Can not edit data, currently syncing")); 442 tr("Can not edit data, currently syncing"));
443 return; 443 return;
444 } 444 }
445 OTodo ev = m_todoMgr.event( currentView()->current() ); 445 OTodo ev = m_todoMgr.event( currentView()->current() );
446 /* let's generate a new uid */ 446 /* let's generate a new uid */
447 ev.setUid(-1); 447 ev.setUid(-1);
448 m_todoMgr.add( ev ); 448 m_todoMgr.add( ev );
449 449
450 currentView()->addEvent( ev ); 450 currentView()->addEvent( ev );
451 raiseCurrentView(); 451 raiseCurrentView();
452} 452}
453void MainWindow::slotDelete() { 453void MainWindow::slotDelete() {
454 if (!currentView()->current() ) 454 if (!currentView()->current() )
455 return; 455 return;
456 456
457 if(m_syncing) { 457 if(m_syncing) {
458 QMessageBox::warning(this, tr("Todo"), 458 QMessageBox::warning(this, tr("Todo"),
459 tr("Can not edit data, currently syncing")); 459 tr("Can not edit data, currently syncing"));
460 return; 460 return;
461 } 461 }
462 QString strName = currentView()->currentRepresentation(); 462 QString strName = currentView()->currentRepresentation();
463 if (!QPEMessageBox::confirmDelete(this, tr("Todo"), strName ) ) 463 if (!QPEMessageBox::confirmDelete(this, tr("Todo"), strName ) )
464 return; 464 return;
465 465
466 m_todoMgr.remove( currentView()->current() ); 466 m_todoMgr.remove( currentView()->current() );
467 currentView()->removeEvent( currentView()->current() ); 467 currentView()->removeEvent( currentView()->current() );
468 raiseCurrentView(); 468 raiseCurrentView();
469} 469}
470void MainWindow::slotDeleteAll() { 470void MainWindow::slotDeleteAll() {
471 if(m_syncing) { 471 if(m_syncing) {
472 QMessageBox::warning(this, tr("Todo"), 472 QMessageBox::warning(this, tr("Todo"),
473 tr("Can not edit data, currently syncing")); 473 tr("Can not edit data, currently syncing"));
474 return; 474 return;
475 } 475 }
476 476
477 //QString strName = table->text( table->currentRow(), 2 ).left( 30 ); 477 //QString strName = table->text( table->currentRow(), 2 ).left( 30 );
478 478
479 if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("all tasks?") ) ) 479 if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("all tasks?") ) )
480 return; 480 return;
481 481
482 m_todoMgr.removeAll(); 482 m_todoMgr.removeAll();
483 currentView()->clear(); 483 currentView()->clear();
484 484
485 raiseCurrentView(); 485 raiseCurrentView();
486} 486}
487void MainWindow::slotDeleteCompleted() { 487void MainWindow::slotDeleteCompleted() {
488 if(m_syncing) { 488 if(m_syncing) {
489 QMessageBox::warning(this, tr("Todo"), 489 QMessageBox::warning(this, tr("Todo"),
490 tr("Can not edit data, currently syncing")); 490 tr("Can not edit data, currently syncing"));
491 return; 491 return;
492 } 492 }
493 493
494 if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("all completed tasks?") ) ) 494 if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("all completed tasks?") ) )
495 return; 495 return;
496 496
497 // FIXME 497 // FIXME
498 //m_todoMgr.remove( currentView()->completed() ); 498 //m_todoMgr.remove( currentView()->completed() );
499 currentView()->updateView( ); 499 currentView()->updateView( );
500} 500}
501void MainWindow::slotFind() { 501void MainWindow::slotFind() {
502 502
503} 503}
504void MainWindow::slotEdit() { 504void MainWindow::slotEdit() {
505 slotEdit( currentView()->current() ); 505 slotEdit( currentView()->current() );
506} 506}
507/* 507/*
508 * set the category 508 * set the category
509 */ 509 */
510void MainWindow::setCategory( int c) { 510void MainWindow::setCategory( int c) {
511 if ( c <= 0 ) return; 511 if ( c <= 0 ) return;
512 512
513 513
514 qWarning("Iterating over cats %d", c ); 514 qWarning("Iterating over cats %d", c );
515 for ( unsigned int i = 1; i < m_catMenu->count(); i++ ) 515 for ( unsigned int i = 1; i < m_catMenu->count(); i++ )
516 m_catMenu->setItemChecked(i, c == (int)i ); 516 m_catMenu->setItemChecked(i, c == (int)i );
517 517
518 if (c == 1 ) { 518 if (c == 1 ) {
519 m_curCat = QString::null; 519 m_curCat = QString::null;
520 setCaption( tr("Todo") + " - " + tr("All Categories" ) ); 520 setCaption( tr("Todo") + " - " + tr("All Categories" ) );
521 521
522 }else if ( c == (int)m_catMenu->count() - 1 ) { 522 }else if ( c == (int)m_catMenu->count() - 1 ) {
523 m_curCat = tr("Unfiled"); 523 m_curCat = tr("Unfiled");
524 setCaption( tr("Todo") + " - " + tr("Unfiled") ); 524 setCaption( tr("Todo") + " - " + tr("Unfiled") );
525 }else { 525 }else {
526 m_curCat = m_todoMgr.categories()[c-2]; 526 m_curCat = m_todoMgr.categories()[c-2];
527 setCaption( tr("Todo") + " - " + m_curCat ); 527 setCaption( tr("Todo") + " - " + m_curCat );
528 } 528 }
529 m_catMenu->setItemChecked( c, true ); 529 m_catMenu->setItemChecked( c, true );
530 530
531 currentView()->setShowCategory( m_curCat ); 531 currentView()->setShowCategory( m_curCat );
532 raiseCurrentView(); 532 raiseCurrentView();
533} 533}
534void MainWindow::slotShowDeadLine( bool dead) { 534void MainWindow::slotShowDeadLine( bool dead) {
535 m_deadline = dead; 535 m_deadline = dead;
536 currentView()->setShowDeadline( dead ); 536 currentView()->setShowDeadline( dead );
537} 537}
538void MainWindow::slotShowCompleted( bool show) { 538void MainWindow::slotShowCompleted( bool show) {
539 m_completed = show; 539 m_completed = show;
540 currentView()->setShowCompleted( m_completed ); 540 currentView()->setShowCompleted( m_completed );
541} 541}
542bool MainWindow::showOverDue()const { 542bool MainWindow::showOverDue()const {
543 return m_overdue; 543 return m_overdue;
544} 544}
545void MainWindow::setDocument( const QString& fi) { 545void MainWindow::setDocument( const QString& fi) {
546 DocLnk doc(fi); 546 DocLnk doc(fi);
547 if (doc.isValid() ) 547 if (doc.isValid() )
548 receiveFile(doc.file() ); 548 receiveFile(doc.file() );
549 else 549 else
550 receiveFile(fi ); 550 receiveFile(fi );
551} 551}
552 552
553static const char *beamfile = "/tmp/opie-todo.vcs"; 553static const char *beamfile = "/tmp/opie-todo.vcs";
554void MainWindow::slotBeam() { 554void MainWindow::slotBeam() {
555 ::unlink( beamfile ); 555 ::unlink( beamfile );
556 OTodo todo = event( currentView()->current() ); 556 OTodo todo = event( currentView()->current() );
557 OTodoAccessVCal* cal = new OTodoAccessVCal(QString::fromLatin1(beamfile) ); 557 OTodoAccessVCal* cal = new OTodoAccessVCal(QString::fromLatin1(beamfile) );
558 OTodoAccess acc( cal ); 558 OTodoAccess acc( cal );
559 acc.load(); 559 acc.load();
560 acc.add( todo ); 560 acc.add( todo );
561 acc.save(); 561 acc.save();
562 Ir* ir = new Ir(this ); 562 Ir* ir = new Ir(this );
563 connect(ir, SIGNAL(done(Ir*) ), 563 connect(ir, SIGNAL(done(Ir*) ),
564 this, SLOT(beamDone(Ir*) ) ); 564 this, SLOT(beamDone(Ir*) ) );
565 ir->send( beamfile, todo.summary(), "text/x-vCalendar" ); 565 ir->send( beamfile, todo.summary(), "text/x-vCalendar" );
566 566
567} 567}
568void MainWindow::beamDone( Ir* ir) { 568void MainWindow::beamDone( Ir* ir) {
569 delete ir; 569 delete ir;
570 ::unlink( beamfile ); 570 ::unlink( beamfile );
571} 571}
572void MainWindow::receiveFile( const QString& filename ) { 572void MainWindow::receiveFile( const QString& filename ) {
573 OTodoAccessVCal* cal = new OTodoAccessVCal(filename ); 573 OTodoAccessVCal* cal = new OTodoAccessVCal(filename );
574 OTodoAccess acc( cal ); 574 OTodoAccess acc( cal );
575 acc.load(); 575 acc.load();
576 OTodoAccess::List list = acc.allRecords(); 576 OTodoAccess::List list = acc.allRecords();
577 577
578 QString message = tr("<P>%1 new tasks arrived.<p>Would you like to add them to your Todolist?").arg(list.count() ); 578 QString message = tr("<P>%1 new tasks arrived.<p>Would you like to add them to your Todolist?").arg(list.count() );
579 579
580 if ( QMessageBox::information(this, tr("New Tasks"), 580 if ( QMessageBox::information(this, tr("New Tasks"),
581 message, QMessageBox::Ok, 581 message, QMessageBox::Ok,
582 QMessageBox::Cancel ) == QMessageBox::Ok ) { 582 QMessageBox::Cancel ) == QMessageBox::Ok ) {
583 OTodoAccess::List::Iterator it; 583 OTodoAccess::List::Iterator it;
584 for ( it = list.begin(); it != list.end(); ++it ) 584 for ( it = list.begin(); it != list.end(); ++it )
585 m_todoMgr.add( (*it) ); 585 m_todoMgr.add( (*it) );
586 586
587 currentView()->updateView(); 587 currentView()->updateView();
588 } 588 }
589} 589}
590 590
591void MainWindow::slotFlush() { 591void MainWindow::slotFlush() {
592 m_syncing = FALSE; 592 m_syncing = FALSE;
593 m_todoMgr.save(); 593 m_todoMgr.save();
594} 594}
595void MainWindow::slotShowDetails() { 595void MainWindow::slotShowDetails() {
596 slotShow( currentView()->current() ); 596 slotShow( currentView()->current() );
597} 597}
598/* 598/*
599 * populate the Categories 599 * populate the Categories
600 * Menu 600 * Menu
601 */ 601 */
602void MainWindow::populateCategories() { 602void MainWindow::populateCategories() {
603 m_todoMgr.load(); 603 m_todoMgr.load();
604 604
605 m_catMenu->clear(); 605 m_catMenu->clear();
606 int id, rememberId; 606 int id, rememberId;
607 id = 1; 607 id = 1;
608 rememberId = 1; 608 rememberId = 1;
609 609
610 m_catMenu->insertItem( tr( "All Categories" ), id++ ); 610 m_catMenu->insertItem( tr( "All Categories" ), id++ );
611 m_catMenu->insertSeparator(); 611 m_catMenu->insertSeparator();
612 QStringList categories = m_todoMgr.categories(); 612 QStringList categories = m_todoMgr.categories();
613 categories.append( tr( "Unfiled" ) ); 613 categories.append( tr( "Unfiled" ) );
614 for ( QStringList::Iterator it = categories.begin(); 614 for ( QStringList::Iterator it = categories.begin();
615 it != categories.end(); ++it ) { 615 it != categories.end(); ++it ) {
616 m_catMenu->insertItem( *it, id ); 616 m_catMenu->insertItem( *it, id );
617 if ( *it == currentCategory() ) 617 if ( *it == currentCategory() )
618 rememberId = id; 618 rememberId = id;
619 ++id; 619 ++id;
620 } 620 }
621 setCategory( rememberId ); 621 setCategory( rememberId );
622} 622}
623bool MainWindow::showCompleted()const { 623bool MainWindow::showCompleted()const {
624 return m_completed; 624 return m_completed;
625} 625}
626bool MainWindow::showDeadline()const { 626bool MainWindow::showDeadline()const {
627 return m_deadline; 627 return m_deadline;
628} 628}
629QString MainWindow::currentCategory()const { 629QString MainWindow::currentCategory()const {
630 return m_curCat; 630 return m_curCat;
631} 631}
632int MainWindow::currentCatId() { 632int MainWindow::currentCatId() {
633 return m_todoMgr.catId( m_curCat ); 633 return m_todoMgr.catId( m_curCat );
634} 634}
635ViewBase* MainWindow::currentView() { 635ViewBase* MainWindow::currentView() {
636 return m_curView; 636 return m_curView;
637} 637}
638void MainWindow::raiseCurrentView() { 638void MainWindow::raiseCurrentView() {
639 m_stack->raiseWidget( m_curView->widget() ); 639 m_stack->raiseWidget( m_curView->widget() );
640} 640}
641void MainWindow::slotShowDue(bool ov) { 641void MainWindow::slotShowDue(bool ov) {
642 m_overdue = ov; 642 m_overdue = ov;
643 currentView()->showOverDue( ov ); 643 currentView()->showOverDue( ov );
644 raiseCurrentView(); 644 raiseCurrentView();
645} 645}
646void MainWindow::slotShow( int uid ) { 646void MainWindow::slotShow( int uid ) {
647 qWarning("slotShow"); 647 qWarning("slotShow");
648 currentShow()->slotShow( event( uid ) ); 648 currentShow()->slotShow( event( uid ) );
649 m_stack->raiseWidget( currentShow()->widget() ); 649 m_stack->raiseWidget( currentShow()->widget() );
650} 650}
651void MainWindow::slotEdit( int uid ) { 651void MainWindow::slotEdit( int uid ) {
652 if(m_syncing) { 652 if(m_syncing) {
653 QMessageBox::warning(this, tr("Todo"), 653 QMessageBox::warning(this, tr("Todo"),
654 tr("Can not edit data, currently syncing")); 654 tr("Can not edit data, currently syncing"));
655 return; 655 return;
656 } 656 }
657 657
658 OTodo todo = m_todoMgr.event( uid ); 658 OTodo todo = m_todoMgr.event( uid );
659 659
660 todo = currentEditor()->edit(this, todo ); 660 todo = currentEditor()->edit(this, todo );
661 661
662 /* if completed */ 662 /* if completed */
663 if ( currentEditor()->accepted() ) { 663 if ( currentEditor()->accepted() ) {
664 qWarning("Replacing now" ); 664 qWarning("Replacing now" );
665 m_todoMgr.update( todo.uid(), todo ); 665 m_todoMgr.update( todo.uid(), todo );
666 currentView()->replaceEvent( todo ); 666 currentView()->replaceEvent( todo );
667 /* a Category might have changed */ 667 /* a Category might have changed */
668 populateCategories(); 668 populateCategories();
669 } 669 }
670 670
671 raiseCurrentView(); 671 raiseCurrentView();
672} 672}
673/* 673/*
674void MainWindow::slotUpdate1( int uid, const SmallTodo& ev) { 674void MainWindow::slotUpdate1( int uid, const SmallTodo& ev) {
675 m_todoMgr.update( uid, ev ); 675 m_todoMgr.update( uid, ev );
676} 676}
677*/ 677*/
678void MainWindow::updateTodo( const OTodo& ev) { 678void MainWindow::updateTodo( const OTodo& ev) {
679 m_todoMgr.update( ev.uid() , ev ); 679 m_todoMgr.update( ev.uid() , ev );
680} 680}
681/* The view changed it's configuration 681/* The view changed it's configuration
682 * update the view menu 682 * update the view menu
683 */ 683 */
684void MainWindow::slotUpdate3( QWidget* ) { 684void MainWindow::slotUpdate3( QWidget* ) {
685 685
686} 686}
687void MainWindow::updateList() { 687void MainWindow::updateList() {
688 m_todoMgr.updateList(); 688 m_todoMgr.updateList();
689} 689}
690void MainWindow::setReadAhead( uint count ) { 690void MainWindow::setReadAhead( uint count ) {
691 if (m_todoMgr.todoDB() ) 691 if (m_todoMgr.todoDB() )
692 m_todoMgr.todoDB()->setReadAhead( count ); 692 m_todoMgr.todoDB()->setReadAhead( count );
693} 693}
694void MainWindow::slotQuickEntered() { 694void MainWindow::slotQuickEntered() {
695 qWarning("entered"); 695 qWarning("entered");
696 OTodo todo = quickEditor()->todo(); 696 OTodo todo = quickEditor()->todo();
697 if (todo.isEmpty() ) 697 if (todo.isEmpty() )
698 return; 698 return;
699 699
700 m_todoMgr.add( todo ); 700 m_todoMgr.add( todo );
701 currentView()->addEvent( todo ); 701 currentView()->addEvent( todo );
702 raiseCurrentView(); 702 raiseCurrentView();
703} 703}
704QuickEditBase* MainWindow::quickEditor() { 704QuickEditBase* MainWindow::quickEditor() {
705 return m_curQuick; 705 return m_curQuick;
706} 706}
diff --git a/core/pim/todo/otaskeditor.cpp b/core/pim/todo/otaskeditor.cpp
index e8e922f..1a68eb5 100644
--- a/core/pim/todo/otaskeditor.cpp
+++ b/core/pim/todo/otaskeditor.cpp
@@ -1,83 +1,90 @@
1#include <qdatetime.h> 1#include <qdatetime.h>
2#include <qlayout.h> 2#include <qlayout.h>
3#include <qlabel.h> 3#include <qlabel.h>
4#include <qmultilineedit.h> 4#include <qmultilineedit.h>
5 5
6#include <opie/orecurrancewidget.h> 6#include <opie/orecurrancewidget.h>
7 7
8#include "taskeditoroverviewimpl.h" 8#include "taskeditoroverviewimpl.h"
9#include "taskeditoradvanced.h" 9#include "taskeditoradvanced.h"
10#include "taskeditoralarms.h" 10#include "taskeditoralarms.h"
11 11
12#include "otaskeditor.h" 12#include "otaskeditor.h"
13 13
14OTaskEditor::OTaskEditor(int cur) 14OTaskEditor::OTaskEditor(int cur)
15 : QDialog(0, 0, TRUE ) { 15 : QDialog(0, 0, TRUE ) {
16 init(); 16 init();
17 OTodo to; 17 init( cur );
18 to.setCategories( cur );
19 load(to);
20 m_uid = 1; // generate a new one
21} 18}
22OTaskEditor::OTaskEditor( const OTodo& to) 19OTaskEditor::OTaskEditor( const OTodo& to)
23 : QDialog(0, 0, TRUE ) { 20 : QDialog(0, 0, TRUE ) {
24 init(); 21 init();
25 load( to ); 22 init( to );
26 m_uid = to.uid();
27} 23}
28OTaskEditor::~OTaskEditor() { 24OTaskEditor::~OTaskEditor() {
29 25
30} 26}
27void OTaskEditor::init( int cur ) {
28 OTodo to;
29 if ( cur != 0 )
30 to.setCategories( cur );
31 load(to);
32 m_uid = 1; // generate a new one
33}
34void OTaskEditor::init( const OTodo& to ) {
35 load( to );
36 m_uid = to.uid();
37}
31OTodo OTaskEditor::todo()const{ 38OTodo OTaskEditor::todo()const{
32 qWarning("saving!"); 39 qWarning("saving!");
33 OTodo to; 40 OTodo to;
34 to.setUid(m_uid ); 41 to.setUid(m_uid );
35 m_overView->save( to ); 42 m_overView->save( to );
36 to.setDescription( m_line->text() ); 43 to.setDescription( m_line->text() );
37 44
38 return to; 45 return to;
39} 46}
40void OTaskEditor::load(const OTodo& to) { 47void OTaskEditor::load(const OTodo& to) {
41 m_overView->load( to ); 48 m_overView->load( to );
42 m_line->setText( to.description() ); 49 m_line->setText( to.description() );
43} 50}
44void OTaskEditor::init() { 51void OTaskEditor::init() {
45 QVBoxLayout* lay = new QVBoxLayout(this); 52 QVBoxLayout* lay = new QVBoxLayout(this);
46 setCaption("Task Editor"); 53 setCaption("Task Editor");
47 m_tab = new OTabWidget(this); 54 m_tab = new OTabWidget(this);
48 55
49 /* 56 /*
50 * Add the Widgets 57 * Add the Widgets
51 */ 58 */
52 m_overView = new TaskEditorOverViewImpl(m_tab ); 59 m_overView = new TaskEditorOverViewImpl(m_tab );
53 m_tab->addTab( m_overView, QString::null, tr("Overview") ); 60 m_tab->addTab( m_overView, QString::null, tr("Overview") );
54 61
55 m_adv = new TaskEditorAdvanced( m_tab ); 62 m_adv = new TaskEditorAdvanced( m_tab );
56 m_line = new QMultiLineEdit(m_adv ); 63 m_line = new QMultiLineEdit(m_adv );
57 QLabel* label = new QLabel(m_adv ); 64 QLabel* label = new QLabel(m_adv );
58 label->setText( tr("Description") ); 65 label->setText( tr("Description") );
59 ((QGridLayout*) m_adv->layout() )->addWidget( label,3, 0 ); 66 ((QGridLayout*) m_adv->layout() )->addWidget( label,3, 0 );
60 ((QGridLayout*) m_adv->layout())->addWidget( m_line,4,0 ); 67 ((QGridLayout*) m_adv->layout())->addWidget( m_line,4,0 );
61 m_tab->addTab( m_adv, QString::null, tr("Advanced") ); 68 m_tab->addTab( m_adv, QString::null, tr("Advanced") );
62 69
63 m_alarm = new TaskEditorAlarms( m_tab ); 70 m_alarm = new TaskEditorAlarms( m_tab );
64 m_tab->addTab( m_alarm, QString::null, tr("Alarms") ); 71 m_tab->addTab( m_alarm, QString::null, tr("Alarms") );
65 72
66 m_remind = new TaskEditorAlarms( m_tab ); 73 m_remind = new TaskEditorAlarms( m_tab );
67 m_tab->addTab( m_remind, QString::null, tr("Reminders") ); 74 m_tab->addTab( m_remind, QString::null, tr("Reminders") );
68 75
69 QLabel* lbl = new QLabel(m_tab ); 76 QLabel* lbl = new QLabel(m_tab );
70 lbl->setText( tr("X-Ref") ); 77 lbl->setText( tr("X-Ref") );
71 m_tab->addTab( lbl, QString::null, tr("X-Ref") ); 78 m_tab->addTab( lbl, QString::null, tr("X-Ref") );
72 79
73 m_rec = new ORecurranceWidget( true, QDate::currentDate(), this ); 80 m_rec = new ORecurranceWidget( true, QDate::currentDate(), this );
74 m_tab->addTab( m_rec, QString::null, tr("Recurrance") ); 81 m_tab->addTab( m_rec, QString::null, tr("Recurrance") );
75 82
76 lay->addWidget(m_tab ); 83 lay->addWidget(m_tab );
77 84
78 /* signal and slots */ 85 /* signal and slots */
79 connect(m_overView, SIGNAL(recurranceEnabled(bool) ), 86 connect(m_overView, SIGNAL(recurranceEnabled(bool) ),
80 m_rec, SLOT(setEnabled(bool) ) ); 87 m_rec, SLOT(setEnabled(bool) ) );
81 88
82 m_tab->setCurrentTab( m_overView ); 89 m_tab->setCurrentTab( m_overView );
83} 90}
diff --git a/core/pim/todo/otaskeditor.h b/core/pim/todo/otaskeditor.h
index 5842fdc..bcbd543 100644
--- a/core/pim/todo/otaskeditor.h
+++ b/core/pim/todo/otaskeditor.h
@@ -1,37 +1,44 @@
1#ifndef OPIE_TASK_EDITOR_H 1#ifndef OPIE_TASK_EDITOR_H
2#define OPIE_TASK_EDITOR_H 2#define OPIE_TASK_EDITOR_H
3 3
4#include <qdialog.h> 4#include <qdialog.h>
5 5
6#include <opie/otodo.h> 6#include <opie/otodo.h>
7#include <opie/otabwidget.h> 7#include <opie/otabwidget.h>
8 8
9class TaskEditorOverViewImpl; 9class TaskEditorOverViewImpl;
10class TaskEditorAdvanced; 10class TaskEditorAdvanced;
11class TaskEditorAlarms; 11class TaskEditorAlarms;
12class ORecurranceWidget; 12class ORecurranceWidget;
13class QMultiLineEdit; 13class QMultiLineEdit;
14class OTaskEditor : public QDialog { 14class OTaskEditor : public QDialog {
15 Q_OBJECT 15 Q_OBJECT
16public: 16public:
17 OTaskEditor(int cur); 17 OTaskEditor(int cur);
18 OTaskEditor( const OTodo& todo ); 18 OTaskEditor( const OTodo& todo );
19 ~OTaskEditor(); 19 ~OTaskEditor();
20 20
21 /*
22 * same as the c'tor but this gives us the
23 * power to 'preload' the dialog
24 */
25 void init( int cur );
26 void init( const OTodo& todo );
27
21 OTodo todo()const; 28 OTodo todo()const;
22private: 29private:
23 void load( const OTodo& ); 30 void load( const OTodo& );
24 void init(); 31 void init();
25 32
26 OTabWidget *m_tab; 33 OTabWidget *m_tab;
27 TaskEditorOverViewImpl* m_overView; 34 TaskEditorOverViewImpl* m_overView;
28 TaskEditorAdvanced *m_adv; 35 TaskEditorAdvanced *m_adv;
29 TaskEditorAlarms *m_alarm; 36 TaskEditorAlarms *m_alarm;
30 TaskEditorAlarms* m_remind; 37 TaskEditorAlarms* m_remind;
31 ORecurranceWidget* m_rec; 38 ORecurranceWidget* m_rec;
32 QMultiLineEdit* m_line; 39 QMultiLineEdit* m_line;
33 int m_uid; 40 int m_uid;
34 41
35}; 42};
36 43
37#endif 44#endif
diff --git a/core/pim/todo/taskeditoroverviewimpl.cpp b/core/pim/todo/taskeditoroverviewimpl.cpp
index b9b2ae6..c10ad40 100644
--- a/core/pim/todo/taskeditoroverviewimpl.cpp
+++ b/core/pim/todo/taskeditoroverviewimpl.cpp
@@ -1,169 +1,181 @@
1#include <qapplication.h> 1#include <qapplication.h>
2#include <qcheckbox.h> 2#include <qcheckbox.h>
3#include <qcombobox.h> 3#include <qcombobox.h>
4#include <qpopupmenu.h> 4#include <qpopupmenu.h>
5 5
6#include <qpe/datebookmonth.h> 6#include <qpe/datebookmonth.h>
7#include <qpe/categoryselect.h> 7#include <qpe/categoryselect.h>
8#include <qpe/timestring.h> 8#include <qpe/timestring.h>
9 9
10#include "taskeditoroverviewimpl.h" 10#include "taskeditoroverviewimpl.h"
11 11
12/* 12/*
13 * we need to hack 13 * we need to hack
14 */ 14 */
15 15
16TaskEditorOverViewImpl::TaskEditorOverViewImpl( QWidget* parent, const char* name ) 16TaskEditorOverViewImpl::TaskEditorOverViewImpl( QWidget* parent, const char* name )
17 : TaskEditorOverView( parent, name ) { 17 : TaskEditorOverView( parent, name ) {
18 init(); 18 init();
19} 19}
20TaskEditorOverViewImpl::~TaskEditorOverViewImpl() { 20TaskEditorOverViewImpl::~TaskEditorOverViewImpl() {
21} 21}
22void TaskEditorOverViewImpl::load( const OTodo& todo) { 22void TaskEditorOverViewImpl::load( const OTodo& todo) {
23 /*
24 * now that we're 'preloaded' we
25 * need to disable the buttons
26 * holding the dat
27 */
28 btnDue-> setEnabled( FALSE );
29 btnComp-> setEnabled( FALSE );
30 btnStart->setEnabled( FALSE );
31
32
23 QDate date = QDate::currentDate(); 33 QDate date = QDate::currentDate();
24 QString str = TimeString::longDateString( date ); 34 QString str = TimeString::longDateString( date );
25 35
26 emit recurranceEnabled( FALSE ); 36 emit recurranceEnabled( FALSE );
27 ckbStart->setChecked( FALSE ); 37 ckbStart->setChecked( FALSE );
28 btnStart->setText( str ); 38 btnStart->setText( str );
29 39
30 ckbComp->setChecked( FALSE ); 40 ckbComp->setChecked( FALSE );
31 btnComp->setText( str ); 41 btnComp->setText( str );
32 42
33 cmbProgress->setCurrentItem( todo.progress()/20 ); 43 cmbProgress->setCurrentItem( todo.progress()/20 );
34 cmbSum->insertItem( todo.summary(), 0 ); 44 cmbSum->insertItem( todo.summary(), 0 );
35 cmbSum->setCurrentItem( 0 ); 45 cmbSum->setCurrentItem( 0 );
36 46
37 ckbDue->setChecked( todo.hasDueDate() ); 47 ckbDue->setChecked( todo.hasDueDate() );
38 btnDue->setText( TimeString::longDateString( todo.dueDate() ) ); 48 btnDue->setText( TimeString::longDateString( todo.dueDate() ) );
39 49
40 cmbPrio->setCurrentItem( todo.priority() -1 ); 50 cmbPrio->setCurrentItem( todo.priority() -1 );
41 ckbCompleted->setChecked( todo.isCompleted() ); 51 ckbCompleted->setChecked( todo.isCompleted() );
42 52
43 comboCategory->setCategories( todo.categories(), "Todo List", tr("Todo List") ); 53 comboCategory->setCategories( todo.categories(), "Todo List", tr("Todo List") );
44 54
45} 55}
46void TaskEditorOverViewImpl::save( OTodo& to) { 56void TaskEditorOverViewImpl::save( OTodo& to) {
47 qWarning("save it now"); 57 qWarning("save it now");
48 if ( ckbDue->isChecked() ) { 58 if ( ckbDue->isChecked() ) {
49 to.setDueDate( m_due ); 59 to.setDueDate( m_due );
50 to.setHasDueDate( true ); 60 to.setHasDueDate( true );
51 }else 61 }else
52 to.setHasDueDate( false ); 62 to.setHasDueDate( false );
53 if ( comboCategory->currentCategory() != -1 ) { 63 if ( comboCategory->currentCategory() != -1 ) {
54 QArray<int> arr = comboCategory->currentCategories(); 64 QArray<int> arr = comboCategory->currentCategories();
55 to.setCategories( arr ); 65 to.setCategories( arr );
56 } 66 }
57 to.setPriority( cmbPrio->currentItem() + 1 ); 67 to.setPriority( cmbPrio->currentItem() + 1 );
58 to.setCompleted( ckbCompleted->isChecked() ); 68 to.setCompleted( ckbCompleted->isChecked() );
59 to.setSummary( cmbSum->currentText() ); 69 to.setSummary( cmbSum->currentText() );
60 to.setProgress( cmbProgress->currentItem() * 20 ); 70 to.setProgress( cmbProgress->currentItem() * 20 );
61} 71}
62/* 72/*
63 * here we will init the basic view 73 * here we will init the basic view
64 * one Popup for each Date Button 74 * one Popup for each Date Button
65 * and some other signal and slots connection 75 * and some other signal and slots connection
66 */ 76 */
67void TaskEditorOverViewImpl::init() { 77void TaskEditorOverViewImpl::init() {
68 QDate curDate = QDate::currentDate(); 78 QDate curDate = QDate::currentDate();
69 m_start = m_comp = m_due = curDate; 79 m_start = m_comp = m_due = curDate;
70 QString str = TimeString::longDateString( curDate ); 80 QString str = TimeString::longDateString( curDate );
71 81
82
83
72 /* Start Date Picker */ 84 /* Start Date Picker */
73 m_startPop = new QPopupMenu(this); 85 m_startPop = new QPopupMenu(this);
74 m_startBook = new DateBookMonth(m_startPop, 0, TRUE ); 86 m_startBook = new DateBookMonth(m_startPop, 0, TRUE );
75 m_startPop->insertItem( m_startBook ); 87 m_startPop->insertItem( m_startBook );
76 connect( m_startBook, SIGNAL( dateClicked(int, int, int) ), 88 connect( m_startBook, SIGNAL( dateClicked(int, int, int) ),
77 this, SLOT(slotStartChanged(int, int, int) ) ); 89 this, SLOT(slotStartChanged(int, int, int) ) );
78 90
79 91
80 /* Due Date Picker */ 92 /* Due Date Picker */
81 m_duePop = new QPopupMenu(this); 93 m_duePop = new QPopupMenu(this);
82 m_dueBook = new DateBookMonth(m_duePop, 0, TRUE ); 94 m_dueBook = new DateBookMonth(m_duePop, 0, TRUE );
83 m_duePop->insertItem( m_dueBook ); 95 m_duePop->insertItem( m_dueBook );
84 connect( m_dueBook, SIGNAL( dateClicked(int, int, int) ), 96 connect( m_dueBook, SIGNAL( dateClicked(int, int, int) ),
85 this, SLOT(slotDueChanged(int, int, int) ) ); 97 this, SLOT(slotDueChanged(int, int, int) ) );
86 98
87 m_compPop = new QPopupMenu(this); 99 m_compPop = new QPopupMenu(this);
88 m_compBook = new DateBookMonth(m_compPop, 0, TRUE ); 100 m_compBook = new DateBookMonth(m_compPop, 0, TRUE );
89 m_compPop->insertItem(m_compBook ); 101 m_compPop->insertItem(m_compBook );
90 connect( m_compBook, SIGNAL(dateClicked(int, int, int) ), 102 connect( m_compBook, SIGNAL(dateClicked(int, int, int) ),
91 this, SLOT(slotCompletedChanged(int, int, int) ) ); 103 this, SLOT(slotCompletedChanged(int, int, int) ) );
92 104
93 105
94 /* 106 /*
95 * another part of the hack 107 * another part of the hack
96 * it's deprecated in Qt2 but 108 * it's deprecated in Qt2 but
97 * still available in my qt-copy of Qt3.1beta2 109 * still available in my qt-copy of Qt3.1beta2
98 */ 110 */
99 btnDue->setIsMenuButton( TRUE ); 111 btnDue->setIsMenuButton( TRUE );
100 btnStart->setIsMenuButton( TRUE ); 112 btnStart->setIsMenuButton( TRUE );
101 btnComp->setIsMenuButton( TRUE ); 113 btnComp->setIsMenuButton( TRUE );
102 114
103 /* now connect the hack */ 115 /* now connect the hack */
104 connect(btnDue, SIGNAL(clicked() ), 116 connect(btnDue, SIGNAL(clicked() ),
105 this, SLOT(hackySlotHack2() ) ); 117 this, SLOT(hackySlotHack2() ) );
106 connect(btnStart, SIGNAL(clicked() ), 118 connect(btnStart, SIGNAL(clicked() ),
107 this, SLOT(hackySlotHack1() ) ); 119 this, SLOT(hackySlotHack1() ) );
108 connect(btnComp, SIGNAL(clicked() ), 120 connect(btnComp, SIGNAL(clicked() ),
109 this, SLOT(hackySlotHack3() ) ); 121 this, SLOT(hackySlotHack3() ) );
110 122
111 /* recurrance */ 123 /* recurrance */
112 connect(CheckBox7, SIGNAL(clicked() ), 124 connect(CheckBox7, SIGNAL(clicked() ),
113 this, SLOT(slotRecClicked() ) ); 125 this, SLOT(slotRecClicked() ) );
114} 126}
115 127
116void TaskEditorOverViewImpl::slotStartChecked() { 128void TaskEditorOverViewImpl::slotStartChecked() {
117 qWarning("slotStartChecked"); 129 qWarning("slotStartChecked");
118 btnStart->setEnabled( ckbStart->isChecked() ); 130 btnStart->setEnabled( ckbStart->isChecked() );
119} 131}
120void TaskEditorOverViewImpl::slotStartChanged(int y, int m, int d) { 132void TaskEditorOverViewImpl::slotStartChanged(int y, int m, int d) {
121 m_start.setYMD( y, m, d ); 133 m_start.setYMD( y, m, d );
122 btnStart->setText( TimeString::longDateString( m_start ) ); 134 btnStart->setText( TimeString::longDateString( m_start ) );
123} 135}
124void TaskEditorOverViewImpl::slotDueChecked() { 136void TaskEditorOverViewImpl::slotDueChecked() {
125 btnDue->setEnabled( ckbDue->isChecked() ); 137 btnDue->setEnabled( ckbDue->isChecked() );
126 qWarning("slotDueChecked"); 138 qWarning("slotDueChecked");
127} 139}
128void TaskEditorOverViewImpl::slotDueChanged(int y, int m, int d ) { 140void TaskEditorOverViewImpl::slotDueChanged(int y, int m, int d ) {
129 m_due.setYMD(y, m, d ); 141 m_due.setYMD(y, m, d );
130 btnDue->setText( TimeString::longDateString( m_due ) ); 142 btnDue->setText( TimeString::longDateString( m_due ) );
131} 143}
132void TaskEditorOverViewImpl::slotCompletedChecked() { 144void TaskEditorOverViewImpl::slotCompletedChecked() {
133 btnComp->setEnabled( ckbComp->isChecked() ); 145 btnComp->setEnabled( ckbComp->isChecked() );
134 qWarning("slotCompletedChecked"); 146 qWarning("slotCompletedChecked");
135} 147}
136void TaskEditorOverViewImpl::slotCompletedChanged(int y, int m, int d) { 148void TaskEditorOverViewImpl::slotCompletedChanged(int y, int m, int d) {
137 m_comp.setYMD( y, m, d ); 149 m_comp.setYMD( y, m, d );
138 btnComp->setText( TimeString::longDateString( m_comp ) ); 150 btnComp->setText( TimeString::longDateString( m_comp ) );
139} 151}
140/* 152/*
141 * called by a button pressed event... 153 * called by a button pressed event...
142 * three slots to avoid ugly name() tests 154 * three slots to avoid ugly name() tests
143 * to sender() 155 * to sender()
144 */ 156 */
145void TaskEditorOverViewImpl::hackySlotHack1() { 157void TaskEditorOverViewImpl::hackySlotHack1() {
146 btnStart->setDown( FALSE ); 158 btnStart->setDown( FALSE );
147 popup( btnStart, m_startPop ); 159 popup( btnStart, m_startPop );
148} 160}
149void TaskEditorOverViewImpl::hackySlotHack2() { 161void TaskEditorOverViewImpl::hackySlotHack2() {
150 btnDue->setDown( FALSE ); 162 btnDue->setDown( FALSE );
151 popup( btnDue, m_duePop ); 163 popup( btnDue, m_duePop );
152} 164}
153void TaskEditorOverViewImpl::hackySlotHack3() { 165void TaskEditorOverViewImpl::hackySlotHack3() {
154 btnComp->setDown( FALSE ); 166 btnComp->setDown( FALSE );
155 popup( btnComp, m_compPop ); 167 popup( btnComp, m_compPop );
156} 168}
157void TaskEditorOverViewImpl::slotRecClicked() { 169void TaskEditorOverViewImpl::slotRecClicked() {
158 qWarning("enabled recurrance"); 170 qWarning("enabled recurrance");
159 emit recurranceEnabled( CheckBox7->isChecked() ); 171 emit recurranceEnabled( CheckBox7->isChecked() );
160} 172}
161/* 173/*
162 * GPL from TT QPushButton code 174 * GPL from TT QPushButton code
163 */ 175 */
164void TaskEditorOverViewImpl::popup( QPushButton* pu, QPopupMenu* pop) { 176void TaskEditorOverViewImpl::popup( QPushButton* pu, QPopupMenu* pop) {
165 if ( pu->mapToGlobal( QPoint(0, pu->rect().bottom() ) ).y() + pop->sizeHint().height() <= qApp->desktop()->height() ) 177 if ( pu->mapToGlobal( QPoint(0, pu->rect().bottom() ) ).y() + pop->sizeHint().height() <= qApp->desktop()->height() )
166 pop->exec( pu->mapToGlobal( pu->rect().bottomLeft() ) ); 178 pop->exec( pu->mapToGlobal( pu->rect().bottomLeft() ) );
167 else 179 else
168 pop->exec( pu->mapToGlobal( pu->rect().topLeft() - QPoint(0, pu->sizeHint().height() ) ) ); 180 pop->exec( pu->mapToGlobal( pu->rect().topLeft() - QPoint(0, pu->sizeHint().height() ) ) );
169} 181}
diff --git a/core/pim/todo/todoeditor.cpp b/core/pim/todo/todoeditor.cpp
index e19ab8d..9b8c5cb 100644
--- a/core/pim/todo/todoeditor.cpp
+++ b/core/pim/todo/todoeditor.cpp
@@ -1,55 +1,67 @@
1 1
2#include "otaskeditor.h" 2#include "otaskeditor.h"
3#include "todoeditor.h" 3#include "todoeditor.h"
4 4
5using namespace Todo; 5using namespace Todo;
6 6
7Editor::Editor() { 7Editor::Editor() {
8 m_accepted = false; 8 m_accepted = false;
9 m_self = 0l;
9} 10}
10Editor::~Editor() { 11Editor::~Editor() {
12 delete m_self;
13 m_self = 0;
11} 14}
12OTodo Editor::newTodo( int cur, 15OTodo Editor::newTodo( int cur,
13 QWidget* par) { 16 QWidget*) {
14 17
15 OTaskEditor e( cur); 18 OTaskEditor *e = self();
19 e->setCaption( QObject::tr("Enter Task") );
20 e->init( cur );
16 21
17 22
18#if defined(Q_WS_QWS) || defined(_WS_QWS_) 23#if defined(Q_WS_QWS) || defined(_WS_QWS_)
19 e.showMaximized(); 24 e->showMaximized();
20#endif 25#endif
21 26
22 int ret = e.exec(); 27 int ret = e->exec();
23 if ( QDialog::Accepted == ret ) { 28 if ( QDialog::Accepted == ret ) {
24 m_accepted = true; 29 m_accepted = true;
25 }else 30 }else
26 m_accepted = false; 31 m_accepted = false;
27 32
28 OTodo ev = e.todo(); 33 OTodo ev = e->todo();
29 qWarning("Todo uid"); 34 qWarning("Todo uid");
30 qWarning("Todo %s %d %d", ev.summary().latin1(), ev.progress(), ev.isCompleted() ); 35 qWarning("Todo %s %d %d", ev.summary().latin1(), ev.progress(), ev.isCompleted() );
31 ev.setUid(1); 36 ev.setUid(1);
32 37
33 return ev; 38 return ev;
34} 39}
35OTodo Editor::edit( QWidget *wid, 40OTodo Editor::edit( QWidget *wid,
36 const OTodo& todo ) { 41 const OTodo& todo ) {
37 OTaskEditor e( todo ); 42 OTaskEditor *e = self();
38 e.setCaption( QObject::tr( "Edit Task" ) ); 43 e->init( todo );
44 e->setCaption( QObject::tr( "Edit Task" ) );
39 45
40#if defined(Q_WS_QWS) || defined(_WS_QWS_) 46#if defined(Q_WS_QWS) || defined(_WS_QWS_)
41 e.showMaximized(); 47 e->showMaximized();
42#endif 48#endif
43 int ret = e.exec(); 49 int ret = e->exec();
44 50
45 OTodo ev = e.todo(); 51 OTodo ev = e->todo();
46 if ( ret == QDialog::Accepted ) 52 if ( ret == QDialog::Accepted )
47 m_accepted = true; 53 m_accepted = true;
48 else 54 else
49 m_accepted = false; 55 m_accepted = false;
50 56
51 return ev; 57 return ev;
52} 58}
53bool Editor::accepted()const { 59bool Editor::accepted()const {
54 return m_accepted; 60 return m_accepted;
55} 61}
62OTaskEditor* Editor::self() {
63 if (!m_self )
64 m_self = new OTaskEditor(0);
65
66 return m_self;
67}
diff --git a/core/pim/todo/todoeditor.h b/core/pim/todo/todoeditor.h
index bbfdcb5..fe30634 100644
--- a/core/pim/todo/todoeditor.h
+++ b/core/pim/todo/todoeditor.h
@@ -1,25 +1,29 @@
1#ifndef OPIE_TODO_EDITOR_H 1#ifndef OPIE_TODO_EDITOR_H
2#define OPIE_TODO_EDITOR_H 2#define OPIE_TODO_EDITOR_H
3 3
4#include <opie/otodo.h> 4#include <opie/otodo.h>
5 5
6 6
7class OTaskEditor;
7namespace Todo { 8namespace Todo {
8 class Editor { 9 class Editor {
9 public: 10 public:
10 Editor(); 11 Editor();
11 ~Editor(); 12 ~Editor();
12 13
13 OTodo newTodo( int currentCatId, 14 OTodo newTodo( int currentCatId,
14 QWidget* par ); 15 QWidget* par );
15 OTodo edit( QWidget* par, 16 OTodo edit( QWidget* par,
16 const OTodo& ev = OTodo() ); 17 const OTodo& ev = OTodo() );
17 18
18 19
19 bool accepted()const; 20 bool accepted()const;
21 protected:
22 OTaskEditor* self();
20 private: 23 private:
21 bool m_accepted: 1; 24 bool m_accepted: 1;
25 OTaskEditor* m_self;
22 }; 26 };
23}; 27};
24 28
25#endif 29#endif