summaryrefslogtreecommitdiff
authorzecke <zecke>2003-05-07 17:44:59 (UTC)
committer zecke <zecke>2003-05-07 17:44:59 (UTC)
commitac895871f93dce9734189daf9cb95dbbda605096 (patch) (unidiff)
tree18f34fcdeededd689ea9b7a3f8fd9d76d2e22282
parent1cee00987d34729393fb9383d90babd39517cc68 (diff)
downloadopie-ac895871f93dce9734189daf9cb95dbbda605096.zip
opie-ac895871f93dce9734189daf9cb95dbbda605096.tar.gz
opie-ac895871f93dce9734189daf9cb95dbbda605096.tar.bz2
one more
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/todo/mainwindow.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp
index 77cbe17..c5cedc6 100644
--- a/core/pim/todo/mainwindow.cpp
+++ b/core/pim/todo/mainwindow.cpp
@@ -1,823 +1,823 @@
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 <qlayout.h> 39#include <qlayout.h>
40#include <qlineedit.h> 40#include <qlineedit.h>
41#include <qwhatsthis.h> 41#include <qwhatsthis.h>
42 42
43#include <qpe/applnk.h> 43#include <qpe/applnk.h>
44#include <qpe/config.h> 44#include <qpe/config.h>
45#include <qpe/ir.h> 45#include <qpe/ir.h>
46#include <qpe/resource.h> 46#include <qpe/resource.h>
47#include <qpe/qpemessagebox.h> 47#include <qpe/qpemessagebox.h>
48 48
49#include <opie/orecur.h> 49#include <opie/orecur.h>
50#include <opie/otodoaccessvcal.h> 50#include <opie/otodoaccessvcal.h>
51 51
52#include "quickeditimpl.h" 52#include "quickeditimpl.h"
53#include "todotemplatemanager.h" 53#include "todotemplatemanager.h"
54#include "templateeditor.h" 54#include "templateeditor.h"
55#include "tableview.h" 55#include "tableview.h"
56 56
57#include "textviewshow.h" 57#include "textviewshow.h"
58#include "todoeditor.h" 58#include "todoeditor.h"
59#include "mainwindow.h" 59#include "mainwindow.h"
60 60
61 61
62using namespace Todo; 62using namespace Todo;
63 63
64MainWindow::MainWindow( QWidget* parent, 64MainWindow::MainWindow( QWidget* parent,
65 const char* name ) 65 const char* name )
66 : OPimMainWindow( "Todolist", parent, name, WType_TopLevel | WStyle_ContextHelp ) 66 : OPimMainWindow( "Todolist", parent, name, WType_TopLevel | WStyle_ContextHelp )
67{ 67{
68 m_syncing = false; 68 m_syncing = false;
69 m_counter = 0; 69 m_counter = 0;
70 m_tempManager = new TemplateManager(); 70 m_tempManager = new TemplateManager();
71 m_tempManager->load(); 71 m_tempManager->load();
72 72
73 initUI(); 73 initUI();
74 initConfig(); 74 initConfig();
75 initViews(); 75 initViews();
76 initActions(); 76 initActions();
77 initEditor(); 77 initEditor();
78 initShow(); 78 initShow();
79 initTemplate(); 79 initTemplate();
80 80
81 populateTemplates(); 81 populateTemplates();
82 raiseCurrentView(); 82 raiseCurrentView();
83 QTimer::singleShot(0, this, SLOT(populateCategories() ) ); 83 QTimer::singleShot(0, this, SLOT(populateCategories() ) );
84} 84}
85void MainWindow::initTemplate() { 85void MainWindow::initTemplate() {
86 m_curTempEd = new TemplateEditor( this, templateManager() ); 86 m_curTempEd = new TemplateEditor( this, templateManager() );
87} 87}
88void MainWindow::initActions() { 88void MainWindow::initActions() {
89 89
90 // Data menu 90 // Data menu
91 m_edit->insertItem(QWidget::tr("New from template"), m_template, 91 m_edit->insertItem(QWidget::tr("New from template"), m_template,
92 -1, 0 ); 92 -1, 0 );
93 93
94 QAction* a = new QAction( QWidget::tr("New Task" ), Resource::loadPixmap( "new" ), 94 QAction* a = new QAction( QWidget::tr("New Task" ), Resource::loadPixmap( "new" ),
95 QString::null, 0, this, 0 ); 95 QString::null, 0, this, 0 );
96 connect(a, SIGNAL( activated() ), 96 connect(a, SIGNAL( activated() ),
97 this, SLOT( slotNew() ) ); 97 this, SLOT( slotNew() ) );
98 a->setWhatsThis( QWidget::tr( "Click here to create a new task." ) ); 98 a->setWhatsThis( QWidget::tr( "Click here to create a new task." ) );
99 a->addTo(m_tool ); 99 a->addTo(m_tool );
100 a->addTo(m_edit ); 100 a->addTo(m_edit );
101 101
102 a = new QAction( QWidget::tr("Edit Task"), Resource::loadIconSet( "edit" ), 102 a = new QAction( QWidget::tr("Edit Task"), Resource::loadIconSet( "edit" ),
103 QString::null, 0, this, 0 ); 103 QString::null, 0, this, 0 );
104 connect(a, SIGNAL(activated() ), 104 connect(a, SIGNAL(activated() ),
105 this, SLOT( slotEdit() ) ); 105 this, SLOT( slotEdit() ) );
106 a->setWhatsThis( QWidget::tr( "Click here to modify the current task." ) ); 106 a->setWhatsThis( QWidget::tr( "Click here to modify the current task." ) );
107 a->addTo( m_tool ); 107 a->addTo( m_tool );
108 a->addTo( m_edit ); 108 a->addTo( m_edit );
109 m_editAction = a; 109 m_editAction = a;
110 110
111 a = new QAction( QString::null, QWidget::tr("View Task"), 0, this, 0 ); 111 a = new QAction( QString::null, QWidget::tr("View Task"), 0, this, 0 );
112 connect(a, SIGNAL( activated() ), 112 connect(a, SIGNAL( activated() ),
113 this, SLOT( slotShowDetails() ) ); 113 this, SLOT( slotShowDetails() ) );
114 a->addTo( m_edit ); 114 a->addTo( m_edit );
115 115
116 m_edit->insertSeparator(); 116 m_edit->insertSeparator();
117 117
118 a = new QAction( QWidget::tr("Delete..."), Resource::loadIconSet( "trash" ), 118 a = new QAction( QWidget::tr("Delete..."), Resource::loadIconSet( "trash" ),
119 QString::null, 0, this, 0 ); 119 QString::null, 0, this, 0 );
120 connect(a, SIGNAL(activated() ), 120 connect(a, SIGNAL(activated() ),
121 this, SLOT(slotDelete() ) ); 121 this, SLOT(slotDelete() ) );
122 a->setWhatsThis( QWidget::tr( "Click here to remove the current task." ) ); 122 a->setWhatsThis( QWidget::tr( "Click here to remove the current task." ) );
123 a->addTo( m_tool ); 123 a->addTo( m_tool );
124 a->addTo( m_edit ); 124 a->addTo( m_edit );
125 m_deleteAction = a; 125 m_deleteAction = a;
126 126
127 a = new QAction( QString::null, QWidget::tr("Delete all..."), 0, this, 0 ); 127 a = new QAction( QString::null, QWidget::tr("Delete all..."), 0, this, 0 );
128 connect(a, SIGNAL( activated() ), 128 connect(a, SIGNAL( activated() ),
129 this, SLOT( slotDeleteAll() ) ); 129 this, SLOT( slotDeleteAll() ) );
130 a->addTo(m_edit ); 130 a->addTo(m_edit );
131 m_deleteAllAction = a; 131 m_deleteAllAction = a;
132 132
133 a = new QAction( QString::null, QWidget::tr("Delete completed"), 133 a = new QAction( QString::null, QWidget::tr("Delete completed"),
134 0, this, 0 ); 134 0, this, 0 );
135 connect(a, SIGNAL( activated() ), 135 connect(a, SIGNAL( activated() ),
136 this, SLOT( slotDeleteCompleted() ) ); 136 this, SLOT( slotDeleteCompleted() ) );
137 a->addTo(m_edit ); 137 a->addTo(m_edit );
138 a->setEnabled( TRUE ); 138 a->setEnabled( TRUE );
139 m_deleteCompleteAction = a; 139 m_deleteCompleteAction = a;
140 140
141 m_edit->insertSeparator(); 141 m_edit->insertSeparator();
142 142
143 a = new QAction( QString::null, QWidget::tr("Duplicate"), 0, this, 0 ); 143 a = new QAction( QString::null, QWidget::tr("Duplicate"), 0, this, 0 );
144 connect(a, SIGNAL( activated() ), 144 connect(a, SIGNAL( activated() ),
145 this, SLOT( slotDuplicate() ) ); 145 this, SLOT( slotDuplicate() ) );
146 a->addTo(m_edit ); 146 a->addTo(m_edit );
147 m_duplicateAction = a; 147 m_duplicateAction = a;
148 148
149 m_edit->insertSeparator(); 149 m_edit->insertSeparator();
150 150
151 if ( Ir::supported() ) { 151 if ( Ir::supported() ) {
152 a = new QAction( QWidget::tr( "Beam" ), Resource::loadPixmap( "beam" ), QString::null, 0, this, 0 ); 152 a = new QAction( QWidget::tr( "Beam" ), Resource::loadPixmap( "beam" ), QString::null, 0, this, 0 );
153 connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) ); 153 connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) );
154 a->setWhatsThis( QWidget::tr( "Click here to send the current task to another device." ) ); 154 a->setWhatsThis( QWidget::tr( "Click here to send the current task to another device." ) );
155 a->addTo( m_edit ); 155 a->addTo( m_edit );
156 a->addTo( m_tool ); 156 a->addTo( m_tool );
157 } 157 }
158 158
159 // Options menu 159 // Options menu
160 a = new QAction( QWidget::tr("Find"), Resource::loadIconSet( "mag" ), 160 a = new QAction( QWidget::tr("Find"), Resource::loadIconSet( "mag" ),
161 QString::null, 0, this, 0 ); 161 QString::null, 0, this, 0 );
162 connect(a, SIGNAL( activated() ), this, SLOT( slotFind() ) ); 162 connect(a, SIGNAL( activated() ), this, SLOT( slotFind() ) );
163 a->addTo( m_options ); 163 a->addTo( m_options );
164 m_findAction = a; 164 m_findAction = a;
165 165
166 m_options->insertSeparator(); 166 m_options->insertSeparator();
167 167
168 m_completedAction = new QAction( QString::null, QWidget::tr("Show completed tasks"), 168 m_completedAction = new QAction( QString::null, QWidget::tr("Show completed tasks"),
169 0, this, 0, TRUE ); 169 0, this, 0, TRUE );
170 m_completedAction->addTo( m_options ); 170 m_completedAction->addTo( m_options );
171 m_completedAction->setOn( showCompleted() ); 171 m_completedAction->setOn( showCompleted() );
172 connect(m_completedAction, SIGNAL( toggled(bool) ), this, SLOT(slotShowCompleted(bool) ) ); 172 connect(m_completedAction, SIGNAL( toggled(bool) ), this, SLOT(slotShowCompleted(bool) ) );
173 173
174 a = new QAction( QString::null, QWidget::tr("Show only over-due tasks"), 174 a = new QAction( QString::null, QWidget::tr("Show only over-due tasks"),
175 0, this, 0, TRUE ); 175 0, this, 0, TRUE );
176 a->addTo( m_options ); 176 a->addTo( m_options );
177 a->setOn( showOverDue() ); 177 a->setOn( showOverDue() );
178 connect(a, SIGNAL(toggled(bool)), this, SLOT(slotShowDue(bool) ) ); 178 connect(a, SIGNAL(toggled(bool)), this, SLOT(slotShowDue(bool) ) );
179 179
180 m_showDeadLineAction = new QAction( QString::null, QWidget::tr("Show task deadlines"), 180 m_showDeadLineAction = new QAction( QString::null, QWidget::tr("Show task deadlines"),
181 0, this, 0, TRUE ); 181 0, this, 0, TRUE );
182 m_showDeadLineAction->addTo( m_options ); 182 m_showDeadLineAction->addTo( m_options );
183 m_showDeadLineAction->setOn( showDeadline() ); 183 m_showDeadLineAction->setOn( showDeadline() );
184 connect(m_showDeadLineAction, SIGNAL(toggled(bool) ), this, SLOT( slotShowDeadLine( bool ) ) ); 184 connect(m_showDeadLineAction, SIGNAL(toggled(bool) ), this, SLOT( slotShowDeadLine( bool ) ) );
185 185
186 m_showQuickTaskAction = new QAction( QString::null, QWidget::tr("Show quick task bar"), 186 m_showQuickTaskAction = new QAction( QString::null, QWidget::tr("Show quick task bar"),
187 0, this, 0, TRUE ); 187 0, this, 0, TRUE );
188 m_showQuickTaskAction->addTo( m_options ); 188 m_showQuickTaskAction->addTo( m_options );
189 m_showQuickTaskAction->setOn( showQuickTask() ); 189 m_showQuickTaskAction->setOn( showQuickTask() );
190 connect(m_showQuickTaskAction, SIGNAL( toggled(bool) ), this, SLOT(slotShowQuickTask(bool) ) ); 190 connect(m_showQuickTaskAction, SIGNAL( toggled(bool) ), this, SLOT(slotShowQuickTask(bool) ) );
191 191
192 m_options->insertSeparator(); 192 m_options->insertSeparator();
193 193
194 m_bar->insertItem( QWidget::tr("Data") ,m_edit ); 194 m_bar->insertItem( QWidget::tr("Data") ,m_edit );
195 m_bar->insertItem( QWidget::tr("Category"), m_catMenu ); 195 m_bar->insertItem( QWidget::tr("Category"), m_catMenu );
196 m_bar->insertItem( QWidget::tr("Options"), m_options ); 196 m_bar->insertItem( QWidget::tr("Options"), m_options );
197 197
198 m_curQuick = new QuickEditImpl( this, m_quicktask ); 198 m_curQuick = new QuickEditImpl( this, m_quicktask );
199 addToolBar( (QPEToolBar *)m_curQuick->widget(), QWidget::tr( "QuickEdit" ), QMainWindow::Top, TRUE ); 199 addToolBar( (QPEToolBar *)m_curQuick->widget(), QWidget::tr( "QuickEdit" ), QMainWindow::Top, TRUE );
200 m_curQuick->signal()->connect( this, SLOT(slotQuickEntered() ) ); 200 m_curQuick->signal()->connect( this, SLOT(slotQuickEntered() ) );
201 201
202} 202}
203/* m_curCat from Config */ 203/* m_curCat from Config */
204void MainWindow::initConfig() { 204void MainWindow::initConfig() {
205 Config config( "todo" ); 205 Config config( "todo" );
206 config.setGroup( "View" ); 206 config.setGroup( "View" );
207 m_completed = config.readBoolEntry( "ShowComplete", TRUE ); 207 m_completed = config.readBoolEntry( "ShowComplete", TRUE );
208 m_curCat = config.readEntry( "Category", QString::null ); 208 m_curCat = config.readEntry( "Category", QString::null );
209 m_deadline = config.readBoolEntry( "ShowDeadLine", TRUE); 209 m_deadline = config.readBoolEntry( "ShowDeadLine", TRUE);
210 m_overdue = config.readBoolEntry("ShowOverDue", FALSE ); 210 m_overdue = config.readBoolEntry("ShowOverDue", FALSE );
211 m_quicktask = config.readBoolEntry("ShowQuickTask", TRUE); 211 m_quicktask = config.readBoolEntry("ShowQuickTask", TRUE);
212} 212}
213void MainWindow::initUI() { 213void MainWindow::initUI() {
214 214
215 m_stack = new QWidgetStack(this, "main stack"); 215 m_stack = new QWidgetStack(this, "main stack");
216 216
217 setCentralWidget( m_stack ); 217 setCentralWidget( m_stack );
218 218
219 setToolBarsMovable( FALSE ); 219 setToolBarsMovable( FALSE );
220 220
221 QToolBar *menubarholder = new QToolBar( this ); 221 QToolBar *menubarholder = new QToolBar( this );
222 menubarholder->setHorizontalStretchable( TRUE ); 222 menubarholder->setHorizontalStretchable( TRUE );
223 m_bar = new QMenuBar( menubarholder ); 223 m_bar = new QMenuBar( menubarholder );
224 224
225 m_tool = new QToolBar( this ); 225 m_tool = new QToolBar( this );
226 226
227 /** QPopupMenu */ 227 /** QPopupMenu */
228 m_edit = new QPopupMenu( this ); 228 m_edit = new QPopupMenu( this );
229 m_options = new QPopupMenu( this ); 229 m_options = new QPopupMenu( this );
230 m_catMenu = new QPopupMenu( this ); 230 m_catMenu = new QPopupMenu( this );
231 m_template = new QPopupMenu( this ); 231 m_template = new QPopupMenu( this );
232 232
233 m_catMenu->setCheckable( TRUE ); 233 m_catMenu->setCheckable( TRUE );
234 m_template->setCheckable( TRUE ); 234 m_template->setCheckable( TRUE );
235 235
236 connect(m_catMenu, SIGNAL(activated(int) ), 236 connect(m_catMenu, SIGNAL(activated(int) ),
237 this, SLOT(setCategory(int) ) ); 237 this, SLOT(setCategory(int) ) );
238 connect(m_template, SIGNAL(activated(int) ), 238 connect(m_template, SIGNAL(activated(int) ),
239 this, SLOT(slotNewFromTemplate(int) ) ); 239 this, SLOT(slotNewFromTemplate(int) ) );
240} 240}
241void MainWindow::initViews() { 241void MainWindow::initViews() {
242 242
243 TableView* tableView = new TableView( this, m_stack ); 243 TableView* tableView = new TableView( this, m_stack );
244 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." ) ); 244 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." ) );
245 m_stack->addWidget( tableView, m_counter++ ); 245 m_stack->addWidget( tableView, m_counter++ );
246 m_views.append( tableView ); 246 m_views.append( tableView );
247 m_curView = tableView; 247 m_curView = tableView;
248 connectBase( tableView ); 248 connectBase( tableView );
249 /* add QString type + QString configname to 249 /* add QString type + QString configname to
250 * the View menu 250 * the View menu
251 * and subdirs for multiple views 251 * and subdirs for multiple views
252 */ 252 */
253} 253}
254void MainWindow::initEditor() { 254void MainWindow::initEditor() {
255 m_curEdit = new Editor(); 255 m_curEdit = new Editor();
256} 256}
257void MainWindow::initShow() { 257void MainWindow::initShow() {
258 m_curShow = new TextViewShow(this, this); 258 m_curShow = new TextViewShow(this, this);
259 m_stack->addWidget( m_curShow->widget() , m_counter++ ); 259 m_stack->addWidget( m_curShow->widget() , m_counter++ );
260} 260}
261MainWindow::~MainWindow() { 261MainWindow::~MainWindow() {
262 delete templateManager(); 262 delete templateManager();
263} 263}
264void MainWindow::connectBase( ViewBase* ) { 264void MainWindow::connectBase( ViewBase* ) {
265 // once templates and signals mix we'll use it again 265 // once templates and signals mix we'll use it again
266} 266}
267QPopupMenu* MainWindow::contextMenu( int , bool recur ) { 267QPopupMenu* MainWindow::contextMenu( int , bool recur ) {
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 273
274 menu->insertSeparator(); 274 menu->insertSeparator();
275 275
276 /* 276 /*
277 * if this event recurs we allow 277 * if this event recurs we allow
278 * to detach it. 278 * to detach it.
279 * remove all 279 * remove all
280 */ 280 */
281 if ( recur ) { 281 if ( recur ) {
282 ; // FIXME 282 ; // FIXME
283 } 283 }
284 284
285 return menu; 285 return menu;
286} 286}
287QPopupMenu* MainWindow::options() { 287QPopupMenu* MainWindow::options() {
288 qWarning("Options"); 288 qWarning("Options");
289 return m_options; 289 return m_options;
290} 290}
291QPopupMenu* MainWindow::edit() { 291QPopupMenu* MainWindow::edit() {
292 return m_edit; 292 return m_edit;
293} 293}
294QToolBar* MainWindow::toolbar() { 294QToolBar* MainWindow::toolbar() {
295 return m_tool; 295 return m_tool;
296} 296}
297OTodoAccess::List MainWindow::list()const { 297OTodoAccess::List MainWindow::list()const {
298 return m_todoMgr.list(); 298 return m_todoMgr.list();
299} 299}
300OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder ) { 300OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder ) {
301 int cat = 0; 301 int cat = 0;
302 if ( m_curCat != QWidget::tr("All Categories") ) 302 if ( m_curCat != QWidget::tr("All Categories") )
303 cat = currentCatId(); 303 cat = currentCatId();
304 304
305 int filter = 1; 305 int filter = 1;
306 306
307 if (!m_completed ) 307 if (!m_completed )
308 filter |= 4; 308 filter |= 4;
309 if (m_overdue) 309 if (m_overdue)
310 filter |= 2; 310 filter |= 2;
311 311
312 return m_todoMgr.sorted( asc, sortOrder, filter, cat ); 312 return m_todoMgr.sorted( asc, sortOrder, filter, cat );
313} 313}
314OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder, int addFilter) { 314OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder, int addFilter) {
315 int cat = 0; 315 int cat = 0;
316 if ( m_curCat != QWidget::tr("All Categories") ) 316 if ( m_curCat != QWidget::tr("All Categories") )
317 cat = currentCatId(); 317 cat = currentCatId();
318 318
319 return m_todoMgr.sorted(asc, sortOrder, addFilter, cat ); 319 return m_todoMgr.sorted(asc, sortOrder, addFilter, cat );
320} 320}
321OTodo MainWindow::event( int uid ) { 321OTodo MainWindow::event( int uid ) {
322 return m_todoMgr.event( uid ); 322 return m_todoMgr.event( uid );
323} 323}
324bool MainWindow::isSyncing()const { 324bool MainWindow::isSyncing()const {
325 return m_syncing; 325 return m_syncing;
326} 326}
327TemplateManager* MainWindow::templateManager() { 327TemplateManager* MainWindow::templateManager() {
328 return m_tempManager; 328 return m_tempManager;
329} 329}
330Editor* MainWindow::currentEditor() { 330Editor* MainWindow::currentEditor() {
331 return m_curEdit; 331 return m_curEdit;
332} 332}
333TodoShow* MainWindow::currentShow() { 333TodoShow* MainWindow::currentShow() {
334 return m_curShow; 334 return m_curShow;
335} 335}
336void MainWindow::slotReload() { 336void MainWindow::slotReload() {
337 m_todoMgr.reload(); 337 m_todoMgr.reload();
338 currentView()->updateView( ); 338 currentView()->updateView( );
339 raiseCurrentView(); 339 raiseCurrentView();
340} 340}
341void MainWindow::closeEvent( QCloseEvent* e ) { 341void MainWindow::closeEvent( QCloseEvent* e ) {
342 if (m_stack->visibleWidget() == currentShow()->widget() ) { 342 if (m_stack->visibleWidget() == currentShow()->widget() ) {
343 raiseCurrentView(); 343 raiseCurrentView();
344 e->ignore(); 344 e->ignore();
345 return; 345 return;
346 } 346 }
347 /* 347 /*
348 * we should have flushed and now we're still saving 348 * we should have flushed and now we're still saving
349 * so there is no need to flush 349 * so there is no need to flush
350 */ 350 */
351 if (m_syncing ) { 351 if (m_syncing ) {
352 e->accept(); 352 e->accept();
353 return; 353 return;
354 } 354 }
355 bool quit = false; 355 bool quit = false;
356 if ( m_todoMgr.saveAll() ){ 356 if ( m_todoMgr.saveAll() ){
357 qWarning("saved"); 357 qWarning("saved");
358 quit = true; 358 quit = true;
359 }else { 359 }else {
360 if ( QMessageBox::critical( this, QWidget::tr("Out of space"), 360 if ( QMessageBox::critical( this, QWidget::tr("Out of space"),
361 QWidget::tr("Todo was unable\n" 361 QWidget::tr("Todo was unable\n"
362 "to save your changes.\n" 362 "to save your changes.\n"
363 "Free up some space\n" 363 "Free up some space\n"
364 "and try again.\n" 364 "and try again.\n"
365 "\nQuit Anyway?"), 365 "\nQuit Anyway?"),
366 QMessageBox::Yes|QMessageBox::Escape, 366 QMessageBox::Yes|QMessageBox::Escape,
367 QMessageBox::No|QMessageBox::Default) 367 QMessageBox::No|QMessageBox::Default)
368 != QMessageBox::No ) { 368 != QMessageBox::No ) {
369 e->accept(); 369 e->accept();
370 quit = true; 370 quit = true;
371 }else 371 }else
372 e->ignore(); 372 e->ignore();
373 373
374 } 374 }
375 375
376 if (quit ) { 376 if (quit ) {
377 Config config( "todo" ); 377 Config config( "todo" );
378 config.setGroup( "View" ); 378 config.setGroup( "View" );
379 config.writeEntry( "ShowComplete", showCompleted() ); 379 config.writeEntry( "ShowComplete", showCompleted() );
380 config.writeEntry( "Category", currentCategory() ); 380 config.writeEntry( "Category", currentCategory() );
381 config.writeEntry( "ShowDeadLine", showDeadline()); 381 config.writeEntry( "ShowDeadLine", showDeadline());
382 config.writeEntry( "ShowOverDue", showOverDue() ); 382 config.writeEntry( "ShowOverDue", showOverDue() );
383 config.writeEntry( "ShowQuickTask", showQuickTask() ); 383 config.writeEntry( "ShowQuickTask", showQuickTask() );
384 /* save templates */ 384 /* save templates */
385 templateManager()->save(); 385 templateManager()->save();
386 e->accept(); 386 e->accept();
387 } 387 }
388} 388}
389void MainWindow::populateTemplates() { 389void MainWindow::populateTemplates() {
390 m_template->clear(); 390 m_template->clear();
391 QStringList list = templateManager()->templates(); 391 QStringList list = templateManager()->templates();
392 QStringList::Iterator it; 392 QStringList::Iterator it;
393 for ( it = list.begin(); it != list.end(); ++it ) { 393 for ( it = list.begin(); it != list.end(); ++it ) {
394 m_template->insertItem( (*it) ); 394 m_template->insertItem( (*it) );
395 } 395 }
396} 396}
397/* 397/*
398 * slotNewFromTemplate 398 * slotNewFromTemplate
399 * We use the edit widget to do 399 * We use the edit widget to do
400 * the config but we setUid(-1) 400 * the config but we setUid(-1)
401 * to get a new uid 401 * to get a new uid
402 */ 402 */
403/* 403/*
404 * first we get the name of the template 404 * first we get the name of the template
405 * then we will use the TemplateManager 405 * then we will use the TemplateManager
406 */ 406 */
407void MainWindow::slotNewFromTemplate( int id ) { 407void MainWindow::slotNewFromTemplate( int id ) {
408 QString name = m_template->text( id ); 408 QString name = m_template->text( id );
409 409
410 OTodo event = templateManager()->templateEvent( name ); 410 OTodo event = templateManager()->templateEvent( name );
411 event = currentEditor()->edit(this, 411 event = currentEditor()->edit(this,
412 event ); 412 event );
413 413
414 if ( currentEditor()->accepted() ) { 414 if ( currentEditor()->accepted() ) {
415 /* assign new todo */ 415 /* assign new todo */
416 event.setUid( -1 ); 416 event.setUid( -1 );
417 currentView()->addEvent( event ); 417 currentView()->addEvent( event );
418 m_todoMgr.add( event ); 418 m_todoMgr.add( event );
419 419
420 populateCategories(); 420 populateCategories();
421 } 421 }
422} 422}
423void MainWindow::slotNew() { 423void MainWindow::slotNew() {
424 create(); 424 create();
425} 425}
426void MainWindow::slotDuplicate() { 426void MainWindow::slotDuplicate() {
427 if(m_syncing) { 427 if(m_syncing) {
428 QMessageBox::warning(this, QWidget::tr("Todo"), 428 QMessageBox::warning(this, QWidget::tr("Todo"),
429 QWidget::tr("Can not edit data, currently syncing")); 429 QWidget::tr("Can not edit data, currently syncing"));
430 return; 430 return;
431 } 431 }
432 OTodo ev = m_todoMgr.event( currentView()->current() ); 432 OTodo ev = m_todoMgr.event( currentView()->current() );
433 /* let's generate a new uid */ 433 /* let's generate a new uid */
434 ev.setUid(-1); 434 ev.setUid(-1);
435 m_todoMgr.add( ev ); 435 m_todoMgr.add( ev );
436 436
437 currentView()->addEvent( ev ); 437 currentView()->addEvent( ev );
438 raiseCurrentView(); 438 raiseCurrentView();
439} 439}
440void MainWindow::slotDelete() { 440void MainWindow::slotDelete() {
441 if (!currentView()->current() ) 441 if (!currentView()->current() )
442 return; 442 return;
443 443
444 if(m_syncing) { 444 if(m_syncing) {
445 QMessageBox::warning(this, QWidget::tr("Todo"), 445 QMessageBox::warning(this, QWidget::tr("Todo"),
446 QWidget::tr("Can not edit data, currently syncing")); 446 QWidget::tr("Can not edit data, currently syncing"));
447 return; 447 return;
448 } 448 }
449 QString strName = currentView()->currentRepresentation(); 449 QString strName = currentView()->currentRepresentation();
450 if (!QPEMessageBox::confirmDelete(this, QWidget::tr("Todo"), strName ) ) 450 if (!QPEMessageBox::confirmDelete(this, QWidget::tr("Todo"), strName ) )
451 return; 451 return;
452 452
453 m_todoMgr.remove( currentView()->current() ); 453 m_todoMgr.remove( currentView()->current() );
454 currentView()->removeEvent( currentView()->current() ); 454 currentView()->removeEvent( currentView()->current() );
455 raiseCurrentView(); 455 raiseCurrentView();
456} 456}
457void MainWindow::slotDeleteAll() { 457void MainWindow::slotDeleteAll() {
458 if(m_syncing) { 458 if(m_syncing) {
459 QMessageBox::warning(this, QWidget::tr("Todo"), 459 QMessageBox::warning(this, QWidget::tr("Todo"),
460 QWidget::tr("Can not edit data, currently syncing")); 460 QWidget::tr("Can not edit data, currently syncing"));
461 return; 461 return;
462 } 462 }
463 463
464 464
465 if ( !QPEMessageBox::confirmDelete( this, QWidget::tr( "Todo" ), QWidget::tr("all tasks?") ) ) 465 if ( !QPEMessageBox::confirmDelete( this, QWidget::tr( "Todo" ), QWidget::tr("all tasks?") ) )
466 return; 466 return;
467 467
468 m_todoMgr.removeAll(); 468 m_todoMgr.removeAll();
469 currentView()->clear(); 469 currentView()->clear();
470 470
471 raiseCurrentView(); 471 raiseCurrentView();
472} 472}
473void MainWindow::slotDeleteCompleted() { 473void MainWindow::slotDeleteCompleted() {
474 if(m_syncing) { 474 if(m_syncing) {
475 QMessageBox::warning(this, QWidget::tr("Todo"), 475 QMessageBox::warning(this, QWidget::tr("Todo"),
476 QWidget::tr("Can not edit data, currently syncing")); 476 QWidget::tr("Can not edit data, currently syncing"));
477 return; 477 return;
478 } 478 }
479 479
480 if ( !QPEMessageBox::confirmDelete( this, QWidget::tr( "Todo" ), QWidget::tr("all completed tasks?") ) ) 480 if ( !QPEMessageBox::confirmDelete( this, QWidget::tr( "Todo" ), QWidget::tr("all completed tasks?") ) )
481 return; 481 return;
482 482
483 483
484 m_todoMgr.removeCompleted(); 484 m_todoMgr.removeCompleted();
485 currentView()->updateView( ); 485 currentView()->updateView( );
486} 486}
487void MainWindow::slotFind() { 487void MainWindow::slotFind() {
488 488
489} 489}
490void MainWindow::slotEdit() { 490void MainWindow::slotEdit() {
491 slotEdit( currentView()->current() ); 491 slotEdit( currentView()->current() );
492} 492}
493/* 493/*
494 * set the category 494 * set the category
495 */ 495 */
496void MainWindow::setCategory( int c) { 496void MainWindow::setCategory( int c) {
497 if ( c <= 0 ) return; 497 if ( c <= 0 ) return;
498 498
499 499
500 qWarning("Iterating over cats %d", c ); 500 qWarning("Iterating over cats %d", c );
501 for ( unsigned int i = 1; i < m_catMenu->count(); i++ ) 501 for ( unsigned int i = 1; i < m_catMenu->count(); i++ )
502 m_catMenu->setItemChecked(i, c == (int)i ); 502 m_catMenu->setItemChecked(i, c == (int)i );
503 503
504 if (c == 1 ) { 504 if (c == 1 ) {
505 m_curCat = QString::null; 505 m_curCat = QString::null;
506 setCaption( QWidget::tr("Todo") + " - " + QWidget::tr("All Categories" ) ); 506 setCaption( QWidget::tr("Todo") + " - " + QWidget::tr("All Categories" ) );
507 507
508 }else if ( c == (int)m_catMenu->count() - 1 ) { 508 }else if ( c == (int)m_catMenu->count() - 1 ) {
509 m_curCat = QWidget::tr("Unfiled"); 509 m_curCat = QWidget::tr("Unfiled");
510 setCaption( QWidget::tr("Todo") + " - " + QWidget::tr("Unfiled") ); 510 setCaption( QWidget::tr("Todo") + " - " + QWidget::tr("Unfiled") );
511 }else { 511 }else {
512 m_curCat = m_todoMgr.categories()[c-2]; 512 m_curCat = m_todoMgr.categories()[c-2];
513 setCaption( QWidget::tr("Todo") + " - " + m_curCat ); 513 setCaption( QWidget::tr("Todo") + " - " + m_curCat );
514 } 514 }
515 m_catMenu->setItemChecked( c, true ); 515 m_catMenu->setItemChecked( c, true );
516 516
517 currentView()->setShowCategory( m_curCat ); 517 currentView()->setShowCategory( m_curCat );
518 raiseCurrentView(); 518 raiseCurrentView();
519} 519}
520void MainWindow::slotShowDeadLine( bool dead) { 520void MainWindow::slotShowDeadLine( bool dead) {
521 m_deadline = dead; 521 m_deadline = dead;
522 currentView()->setShowDeadline( dead ); 522 currentView()->setShowDeadline( dead );
523} 523}
524void MainWindow::slotShowCompleted( bool show) { 524void MainWindow::slotShowCompleted( bool show) {
525 m_completed = show; 525 m_completed = show;
526 currentView()->setShowCompleted( m_completed ); 526 currentView()->setShowCompleted( m_completed );
527} 527}
528void MainWindow::slotShowQuickTask( bool show ) { 528void MainWindow::slotShowQuickTask( bool show ) {
529 m_quicktask = show; 529 m_quicktask = show;
530 if ( m_quicktask ) 530 if ( m_quicktask )
531 m_curQuick->widget()->show(); 531 m_curQuick->widget()->show();
532 else 532 else
533 m_curQuick->widget()->hide(); 533 m_curQuick->widget()->hide();
534} 534}
535bool MainWindow::showOverDue()const { 535bool MainWindow::showOverDue()const {
536 return m_overdue; 536 return m_overdue;
537} 537}
538void MainWindow::setDocument( const QString& fi) { 538void MainWindow::setDocument( const QString& fi) {
539 DocLnk doc(fi); 539 DocLnk doc(fi);
540 if (doc.isValid() ) 540 if (doc.isValid() )
541 receiveFile(doc.file() ); 541 receiveFile(doc.file() );
542 else 542 else
543 receiveFile(fi ); 543 receiveFile(fi );
544} 544}
545 545
546static const char *beamfile = "/tmp/opie-todo.vcs"; 546static const char *beamfile = "/tmp/opie-todo.vcs";
547void MainWindow::slotBeam() { 547void MainWindow::slotBeam() {
548 beam( currentView()->current() ); 548 beam( currentView()->current() );
549} 549}
550void MainWindow::beamDone( Ir* ir) { 550void MainWindow::beamDone( Ir* ir) {
551 delete ir; 551 delete ir;
552 ::unlink( beamfile ); 552 ::unlink( beamfile );
553} 553}
554void MainWindow::receiveFile( const QString& filename ) { 554void MainWindow::receiveFile( const QString& filename ) {
555 OTodoAccessVCal* cal = new OTodoAccessVCal(filename ); 555 OTodoAccessVCal* cal = new OTodoAccessVCal(filename );
556 OTodoAccess acc( cal ); 556 OTodoAccess acc( cal );
557 acc.load(); 557 acc.load();
558 OTodoAccess::List list = acc.allRecords(); 558 OTodoAccess::List list = acc.allRecords();
559 559
560 QString message = QWidget::tr("<P>%1 new tasks arrived.<p>Would you like to add them to your Todolist?").arg(list.count() ); 560 QString message = QWidget::tr("<P>%1 new tasks arrived.<p>Would you like to add them to your Todolist?").arg(list.count() );
561 561
562 if ( QMessageBox::information(this, QWidget::tr("New Tasks"), 562 if ( QMessageBox::information(this, QWidget::tr("New Tasks"),
563 message, QMessageBox::Ok, 563 message, QMessageBox::Ok,
564 QMessageBox::Cancel ) == QMessageBox::Ok ) { 564 QMessageBox::Cancel ) == QMessageBox::Ok ) {
565 OTodoAccess::List::Iterator it; 565 OTodoAccess::List::Iterator it;
566 for ( it = list.begin(); it != list.end(); ++it ) 566 for ( it = list.begin(); it != list.end(); ++it )
567 m_todoMgr.add( (*it) ); 567 m_todoMgr.add( (*it) );
568 568
569 currentView()->updateView(); 569 currentView()->updateView();
570 } 570 }
571} 571}
572 572
573void MainWindow::slotFlush() { 573void MainWindow::slotFlush() {
574 m_syncing = FALSE; 574 m_syncing = FALSE;
575 m_todoMgr.save(); 575 m_todoMgr.save();
576} 576}
577void MainWindow::slotShowDetails() { 577void MainWindow::slotShowDetails() {
578 slotShow( currentView()->current() ); 578 slotShow( currentView()->current() );
579} 579}
580/* 580/*
581 * populate the Categories 581 * populate the Categories
582 * Menu 582 * Menu
583 */ 583 */
584void MainWindow::populateCategories() { 584void MainWindow::populateCategories() {
585 m_todoMgr.load(); 585 m_todoMgr.load();
586 586
587 m_catMenu->clear(); 587 m_catMenu->clear();
588 int id, rememberId; 588 int id, rememberId;
589 id = 1; 589 id = 1;
590 rememberId = 1; 590 rememberId = 1;
591 591
592 m_catMenu->insertItem( QWidget::tr( "All Categories" ), id++ ); 592 m_catMenu->insertItem( QWidget::tr( "All Categories" ), id++ );
593 m_catMenu->insertSeparator(); 593 m_catMenu->insertSeparator();
594 QStringList categories = m_todoMgr.categories(); 594 QStringList categories = m_todoMgr.categories();
595 categories.append( QWidget::tr( "Unfiled" ) ); 595 categories.append( QWidget::tr( "Unfiled" ) );
596 for ( QStringList::Iterator it = categories.begin(); 596 for ( QStringList::Iterator it = categories.begin();
597 it != categories.end(); ++it ) { 597 it != categories.end(); ++it ) {
598 m_catMenu->insertItem( *it, id ); 598 m_catMenu->insertItem( *it, id );
599 if ( *it == currentCategory() ) 599 if ( *it == currentCategory() )
600 rememberId = id; 600 rememberId = id;
601 ++id; 601 ++id;
602 } 602 }
603 setCategory( rememberId ); 603 setCategory( rememberId );
604} 604}
605bool MainWindow::showCompleted()const { 605bool MainWindow::showCompleted()const {
606 return m_completed; 606 return m_completed;
607} 607}
608bool MainWindow::showDeadline()const { 608bool MainWindow::showDeadline()const {
609 return m_deadline; 609 return m_deadline;
610} 610}
611bool MainWindow::showQuickTask()const { 611bool MainWindow::showQuickTask()const {
612 return m_quicktask; 612 return m_quicktask;
613} 613}
614QString MainWindow::currentCategory()const { 614QString MainWindow::currentCategory()const {
615 return m_curCat; 615 return m_curCat;
616} 616}
617int MainWindow::currentCatId() { 617int MainWindow::currentCatId() {
618 return m_todoMgr.catId( m_curCat ); 618 return m_todoMgr.catId( m_curCat );
619} 619}
620ViewBase* MainWindow::currentView() { 620ViewBase* MainWindow::currentView() {
621 return m_curView; 621 return m_curView;
622} 622}
623void MainWindow::raiseCurrentView() { 623void MainWindow::raiseCurrentView() {
624 m_stack->raiseWidget( m_curView->widget() ); 624 m_stack->raiseWidget( m_curView->widget() );
625} 625}
626void MainWindow::slotShowDue(bool ov) { 626void MainWindow::slotShowDue(bool ov) {
627 m_overdue = ov; 627 m_overdue = ov;
628 currentView()->showOverDue( ov ); 628 currentView()->showOverDue( ov );
629 raiseCurrentView(); 629 raiseCurrentView();
630} 630}
631void MainWindow::slotShow( int uid ) { 631void MainWindow::slotShow( int uid ) {
632 qWarning("slotShow"); 632 qWarning("slotShow");
633 currentShow()->slotShow( event( uid ) ); 633 currentShow()->slotShow( event( uid ) );
634 m_stack->raiseWidget( currentShow()->widget() ); 634 m_stack->raiseWidget( currentShow()->widget() );
635} 635}
636void MainWindow::slotEdit( int uid ) { 636void MainWindow::slotEdit( int uid ) {
637 if (uid == 1 ) return; 637 if (uid == 1 ) return;
638 if(m_syncing) { 638 if(m_syncing) {
639 QMessageBox::warning(this, QWidget::tr("Todo"), 639 QMessageBox::warning(this, QWidget::tr("Todo"),
640 QWidget::tr("Can not edit data, currently syncing")); 640 QWidget::tr("Can not edit data, currently syncing"));
641 return; 641 return;
642 } 642 }
643 643
644 OTodo todo = m_todoMgr.event( uid ); 644 OTodo todo = m_todoMgr.event( uid );
645 645
646 todo = currentEditor()->edit(this, todo ); 646 todo = currentEditor()->edit(this, todo );
647 647
648 /* if completed */ 648 /* if completed */
649 if ( currentEditor()->accepted() ) { 649 if ( currentEditor()->accepted() ) {
650 qWarning("Replacing now" ); 650 qWarning("Replacing now" );
651 m_todoMgr.update( todo.uid(), todo ); 651 m_todoMgr.update( todo.uid(), todo );
652 currentView()->replaceEvent( todo ); 652 currentView()->replaceEvent( todo );
653 /* a Category might have changed */ 653 /* a Category might have changed */
654 populateCategories(); 654 populateCategories();
655 } 655 }
656 656
657 raiseCurrentView(); 657 raiseCurrentView();
658} 658}
659/* 659/*
660void MainWindow::slotUpdate1( int uid, const SmallTodo& ev) { 660void MainWindow::slotUpdate1( int uid, const SmallTodo& ev) {
661 m_todoMgr.update( uid, ev ); 661 m_todoMgr.update( uid, ev );
662} 662}
663*/ 663*/
664void MainWindow::updateTodo( const OTodo& ev) { 664void MainWindow::updateTodo( const OTodo& ev) {
665 m_todoMgr.update( ev.uid() , ev ); 665 m_todoMgr.update( ev.uid() , ev );
666} 666}
667/* The view changed it's configuration 667/* The view changed it's configuration
668 * update the view menu 668 * update the view menu
669 */ 669 */
670void MainWindow::slotUpdate3( QWidget* ) { 670void MainWindow::slotUpdate3( QWidget* ) {
671 671
672} 672}
673void MainWindow::updateList() { 673void MainWindow::updateList() {
674 m_todoMgr.updateList(); 674 m_todoMgr.updateList();
675} 675}
676void MainWindow::setReadAhead( uint count ) { 676void MainWindow::setReadAhead( uint count ) {
677 if (m_todoMgr.todoDB() ) 677 if (m_todoMgr.todoDB() )
678 m_todoMgr.todoDB()->setReadAhead( count ); 678 m_todoMgr.todoDB()->setReadAhead( count );
679} 679}
680void MainWindow::slotQuickEntered() { 680void MainWindow::slotQuickEntered() {
681 qWarning("entered"); 681 qWarning("entered");
682 OTodo todo = quickEditor()->todo(); 682 OTodo todo = quickEditor()->todo();
683 if (todo.isEmpty() ) 683 if (todo.isEmpty() )
684 return; 684 return;
685 685
686 m_todoMgr.add( todo ); 686 m_todoMgr.add( todo );
687 currentView()->addEvent( todo ); 687 currentView()->addEvent( todo );
688 raiseCurrentView(); 688 raiseCurrentView();
689} 689}
690QuickEditBase* MainWindow::quickEditor() { 690QuickEditBase* MainWindow::quickEditor() {
691 return m_curQuick; 691 return m_curQuick;
692} 692}
693void MainWindow::slotComplete( int uid ) { 693void MainWindow::slotComplete( int uid ) {
694 slotComplete( event(uid) ); 694 slotComplete( event(uid) );
695} 695}
696void MainWindow::slotComplete( const OTodo& todo ) { 696void MainWindow::slotComplete( const OTodo& todo ) {
697 OTodo to = todo; 697 OTodo to = todo;
698 to.setCompleted( !to.isCompleted() ); 698 to.setCompleted( !to.isCompleted() );
699 to.setCompletedDate( QDate::currentDate() ); 699 to.setCompletedDate( QDate::currentDate() );
700 700
701 /* 701 /*
702 * if the item does recur 702 * if the item does recur
703 * we need to spin it off 703 * we need to spin it off
704 * and update the items duedate to the next 704 * and update the items duedate to the next
705 * possible recurrance of this item... 705 * possible recurrance of this item...
706 * the spinned off one will loose the 706 * the spinned off one will loose the
707 */ 707 */
708 if ( to.recurrence().doesRecur() && to.isCompleted() ) { 708 if ( to.hasRecurrence() && to.isCompleted() ) {
709 OTodo to2( to ); 709 OTodo to2( to );
710 710
711 /* the spinned off one won't recur anymore */ 711 /* the spinned off one won't recur anymore */
712 to.setRecurrence( ORecur() ); 712 to.setRecurrence( ORecur() );
713 713
714 ORecur rec = to2.recurrence(); 714 ORecur rec = to2.recurrence();
715 rec.setStart( to.dueDate() ); 715 rec.setStart( to.dueDate() );
716 to2.setRecurrence( rec ); 716 to2.setRecurrence( rec );
717 /* 717 /*
718 * if there is a next occurence 718 * if there is a next occurence
719 * from the duedate of the last recurrance 719 * from the duedate of the last recurrance
720 */ 720 */
721 QDate date; 721 QDate date;
722 if ( to2.recurrence().nextOcurrence( to2.dueDate().addDays(1), date ) ) { 722 if ( to2.recurrence().nextOcurrence( to2.dueDate().addDays(1), date ) ) {
723 QDate inval; 723 QDate inval;
724 /* generate a new uid for the old record */ 724 /* generate a new uid for the old record */
725 to.setUid( 1 ); 725 to.setUid( 1 );
726 726
727 /* add the old one cause it has a new UID here cause it was spin off */ 727 /* add the old one cause it has a new UID here cause it was spin off */
728 m_todoMgr.add( to ); 728 m_todoMgr.add( to );
729 729
730 /* 730 /*
731 * update the due date 731 * update the due date
732 * start date 732 * start date
733 * and complete date 733 * and complete date
734 */ 734 */
735 to2.setDueDate( date ); 735 to2.setDueDate( date );
736 to2.setStartDate( inval ); 736 to2.setStartDate( inval );
737 to2.setCompletedDate( inval ); 737 to2.setCompletedDate( inval );
738 to2.setCompleted( false ); 738 to2.setCompleted( false );
739 updateTodo( to2 ); 739 updateTodo( to2 );
740 }else 740 }else
741 updateTodo( to ); 741 updateTodo( to );
742 }else 742 }else
743 updateTodo( to ); 743 updateTodo( to );
744 744
745 currentView()->updateView(); 745 currentView()->updateView();
746 raiseCurrentView(); 746 raiseCurrentView();
747} 747}
748void MainWindow::flush() { 748void MainWindow::flush() {
749 slotFlush(); 749 slotFlush();
750} 750}
751void MainWindow::reload() { 751void MainWindow::reload() {
752 slotReload(); 752 slotReload();
753} 753}
754int MainWindow::create() { 754int MainWindow::create() {
755 int uid = 0; 755 int uid = 0;
756 if(m_syncing) { 756 if(m_syncing) {
757 QMessageBox::warning(this, QWidget::tr("Todo"), 757 QMessageBox::warning(this, QWidget::tr("Todo"),
758 QWidget::tr("Can not edit data, currently syncing")); 758 QWidget::tr("Can not edit data, currently syncing"));
759 return uid; 759 return uid;
760 } 760 }
761 761
762 762
763 OTodo todo = currentEditor()->newTodo( currentCatId(), 763 OTodo todo = currentEditor()->newTodo( currentCatId(),
764 this ); 764 this );
765 765
766 if ( currentEditor()->accepted() ) { 766 if ( currentEditor()->accepted() ) {
767 //todo.assignUid(); 767 //todo.assignUid();
768 uid = todo.uid(); 768 uid = todo.uid();
769 m_todoMgr.add( todo ); 769 m_todoMgr.add( todo );
770 currentView()->addEvent( todo ); 770 currentView()->addEvent( todo );
771 771
772 772
773 // I'm afraid we must call this every time now, otherwise 773 // I'm afraid we must call this every time now, otherwise
774 // spend expensive time comparing all these strings... 774 // spend expensive time comparing all these strings...
775 // but only call if we changed something -zecke 775 // but only call if we changed something -zecke
776 populateCategories(); 776 populateCategories();
777 } 777 }
778 raiseCurrentView( ); 778 raiseCurrentView( );
779 779
780 return uid; 780 return uid;
781} 781}
782/* delete it silently... */ 782/* delete it silently... */
783bool MainWindow::remove( int uid ) { 783bool MainWindow::remove( int uid ) {
784 if (m_syncing) return false; 784 if (m_syncing) return false;
785 785
786 return m_todoMgr.remove( uid ); 786 return m_todoMgr.remove( uid );
787} 787}
788void MainWindow::beam( int uid) { 788void MainWindow::beam( int uid) {
789 ::unlink( beamfile ); 789 ::unlink( beamfile );
790 OTodo todo = event( uid ); 790 OTodo todo = event( uid );
791 OTodoAccessVCal* cal = new OTodoAccessVCal(QString::fromLatin1(beamfile) ); 791 OTodoAccessVCal* cal = new OTodoAccessVCal(QString::fromLatin1(beamfile) );
792 OTodoAccess acc( cal ); 792 OTodoAccess acc( cal );
793 acc.load(); 793 acc.load();
794 acc.add( todo ); 794 acc.add( todo );
795 acc.save(); 795 acc.save();
796 Ir* ir = new Ir(this ); 796 Ir* ir = new Ir(this );
797 connect(ir, SIGNAL(done(Ir*) ), 797 connect(ir, SIGNAL(done(Ir*) ),
798 this, SLOT(beamDone(Ir*) ) ); 798 this, SLOT(beamDone(Ir*) ) );
799 ir->send(beamfile, todo.summary(), "text/x-vCalendar" ); 799 ir->send(beamfile, todo.summary(), "text/x-vCalendar" );
800} 800}
801void MainWindow::show( int uid ) { 801void MainWindow::show( int uid ) {
802 slotShow( uid ); 802 slotShow( uid );
803} 803}
804void MainWindow::edit( int uid ) { 804void MainWindow::edit( int uid ) {
805 slotEdit( uid ); 805 slotEdit( uid );
806} 806}
807void MainWindow::add( const OPimRecord& rec) { 807void MainWindow::add( const OPimRecord& rec) {
808 if ( rec.rtti() != OTodo::rtti() ) return; 808 if ( rec.rtti() != OTodo::rtti() ) return;
809 809
810 const OTodo& todo = static_cast<const OTodo&>(rec); 810 const OTodo& todo = static_cast<const OTodo&>(rec);
811 811
812 m_todoMgr.add(todo ); 812 m_todoMgr.add(todo );
813 currentView()->addEvent( todo ); 813 currentView()->addEvent( todo );
814 814
815 815
816 // I'm afraid we must call this every time now, otherwise 816 // I'm afraid we must call this every time now, otherwise
817 // spend expensive time comparing all these strings... 817 // spend expensive time comparing all these strings...
818 // but only call if we changed something -zecke 818 // but only call if we changed something -zecke
819 populateCategories(); 819 populateCategories();
820} 820}
821void MainWindow::slotReturnFromView() { 821void MainWindow::slotReturnFromView() {
822 raiseCurrentView(); 822 raiseCurrentView();
823} 823}