-rw-r--r-- | core/pim/todo/mainwindow.cpp | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp index 75da27c..9013522 100644 --- a/core/pim/todo/mainwindow.cpp +++ b/core/pim/todo/mainwindow.cpp | |||
@@ -1,664 +1,665 @@ | |||
1 | /* | 1 | /* |
2 | =. This file is part of the OPIE Project | 2 | =. This file is part of the OPIE Project |
3 | .=l. Copyright (c) 2002 <> | 3 | .=l. Copyright (c) 2002 <> |
4 | .>+-= | 4 | .>+-= |
5 | _;:, .> :=|. This program is free software; you can | 5 | _;:, .> :=|. This program is free software; you can |
6 | .> <`_, > . <= redistribute it and/or modify it under | 6 | .> <`_, > . <= redistribute it and/or modify it under |
7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
8 | .="- .-=="i, .._ License as published by the Free Software | 8 | .="- .-=="i, .._ License as published by the Free Software |
9 | - . .-<_> .<> Foundation; either version 2 of the License, | 9 | - . .-<_> .<> Foundation; either version 2 of the License, |
10 | ._= =} : or (at your option) any later version. | 10 | ._= =} : or (at your option) any later version. |
11 | .%`+i> _;_. | 11 | .%`+i> _;_. |
12 | .i_,=:_. -<s. This program is distributed in the hope that | 12 | .i_,=:_. -<s. This program is distributed in the hope that |
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
14 | : .. .:, . . . without even the implied warranty of | 14 | : .. .:, . . . without even the implied warranty of |
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
17 | ..}^=.= = ; Library General Public License for more | 17 | ..}^=.= = ; Library General Public License for more |
18 | ++= -. .` .: details. | 18 | ++= -. .` .: details. |
19 | : = ...= . :.=- | 19 | : = ...= . :.=- |
20 | -. .:....=;==+<; You should have received a copy of the GNU | 20 | -. .:....=;==+<; You should have received a copy of the GNU |
21 | -_. . . )=. = General Public License along with | 21 | -_. . . )=. = General Public License along with |
22 | -- :-=` this library; see the file COPYING.LIB. | 22 | -- :-=` this library; see the file COPYING.LIB. |
23 | If not, write to the Free Software Foundation, | 23 | If not, write to the Free Software Foundation, |
24 | Inc., 59 Temple Place - Suite 330, | 24 | Inc., 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include <unistd.h> | 29 | #include <unistd.h> |
30 | 30 | ||
31 | #include <opie2/odebug.h> | 31 | #include <opie2/odebug.h> |
32 | #include <opie2/opimrecurrence.h> | 32 | #include <opie2/opimrecurrence.h> |
33 | #include <opie2/opimnotifymanager.h> | 33 | #include <opie2/opimnotifymanager.h> |
34 | #include <opie2/otodoaccessvcal.h> | 34 | #include <opie2/otodoaccessvcal.h> |
35 | #include <opie2/oapplicationfactory.h> | 35 | #include <opie2/oapplicationfactory.h> |
36 | 36 | ||
37 | #include <qpe/applnk.h> | 37 | #include <qpe/applnk.h> |
38 | #include <qpe/config.h> | 38 | #include <qpe/config.h> |
39 | #include <qpe/ir.h> | 39 | #include <qpe/ir.h> |
40 | #include <qpe/resource.h> | 40 | #include <qpe/resource.h> |
41 | #include <qpe/qpemessagebox.h> | 41 | #include <qpe/qpemessagebox.h> |
42 | #include <qpe/alarmserver.h> | 42 | #include <qpe/alarmserver.h> |
43 | #include <qpe/qpeapplication.h> | 43 | #include <qpe/qpeapplication.h> |
44 | 44 | ||
45 | #include <qaction.h> | 45 | #include <qaction.h> |
46 | #include <qlayout.h> | 46 | #include <qlayout.h> |
47 | #include <qmenubar.h> | 47 | #include <qmenubar.h> |
48 | #include <qmessagebox.h> | 48 | #include <qmessagebox.h> |
49 | #include <qpushbutton.h> | 49 | #include <qpushbutton.h> |
50 | #include <qstringlist.h> | 50 | #include <qstringlist.h> |
51 | #include <qtimer.h> | 51 | #include <qtimer.h> |
52 | #include <qwhatsthis.h> | 52 | #include <qwhatsthis.h> |
53 | 53 | ||
54 | #include "quickeditimpl.h" | 54 | #include "quickeditimpl.h" |
55 | #include "todotemplatemanager.h" | 55 | #include "todotemplatemanager.h" |
56 | #include "templatedialogimpl.h" | 56 | #include "templatedialogimpl.h" |
57 | #include "tableview.h" | 57 | #include "tableview.h" |
58 | 58 | ||
59 | #include "textviewshow.h" | 59 | #include "textviewshow.h" |
60 | #include "todoeditor.h" | 60 | #include "todoeditor.h" |
61 | #include "newtaskdlg.h" | 61 | #include "newtaskdlg.h" |
62 | #include "mainwindow.h" | 62 | #include "mainwindow.h" |
63 | 63 | ||
64 | using Opie::Core::OApplicationFactory; | 64 | using Opie::Core::OApplicationFactory; |
65 | OPIE_EXPORT_APP( OApplicationFactory<Todo::MainWindow> ) | 65 | OPIE_EXPORT_APP( OApplicationFactory<Todo::MainWindow> ) |
66 | 66 | ||
67 | using namespace Opie; | 67 | using namespace Opie; |
68 | using namespace Todo; | 68 | using namespace Todo; |
69 | 69 | ||
70 | MainWindow::MainWindow( QWidget* parent, | 70 | MainWindow::MainWindow( QWidget* parent, |
71 | const char* name, WFlags ) | 71 | const char* name, WFlags ) |
72 | : Opie::OPimMainWindow( "Todolist", tr( "Todo List" ), "Todo List", tr( "Task" ), "todo", | 72 | : Opie::OPimMainWindow( "Todolist", "Todo List", tr( "Task" ), "todo", |
73 | parent, name, WType_TopLevel | WStyle_ContextHelp ) | 73 | parent, name, WType_TopLevel | WStyle_ContextHelp ) |
74 | { | 74 | { |
75 | setCaption( tr( "Todo List" ) ); | ||
75 | if (!name) | 76 | if (!name) |
76 | setName("todo window"); | 77 | setName("todo window"); |
77 | 78 | ||
78 | m_syncing = false; | 79 | m_syncing = false; |
79 | m_showing = false; | 80 | m_showing = false; |
80 | m_counter = 0; | 81 | m_counter = 0; |
81 | m_tempManager = new TemplateManager(); | 82 | m_tempManager = new TemplateManager(); |
82 | m_tempManager->load(); | 83 | m_tempManager->load(); |
83 | 84 | ||
84 | initConfig(); | 85 | initConfig(); |
85 | initUI(); | 86 | initUI(); |
86 | initViews(); | 87 | initViews(); |
87 | initActions(); | 88 | initActions(); |
88 | initEditor(); | 89 | initEditor(); |
89 | initShow(); | 90 | initShow(); |
90 | 91 | ||
91 | raiseCurrentView(); | 92 | raiseCurrentView(); |
92 | QTimer::singleShot( 0, this, SLOT(initStuff()) ); | 93 | QTimer::singleShot( 0, this, SLOT(initStuff()) ); |
93 | } | 94 | } |
94 | void MainWindow::initStuff() { | 95 | void MainWindow::initStuff() { |
95 | m_todoMgr.load(); | 96 | m_todoMgr.load(); |
96 | setViewCategory( m_curCat ); | 97 | setViewCategory( m_curCat ); |
97 | setCategory( m_curCat ); | 98 | setCategory( m_curCat ); |
98 | } | 99 | } |
99 | void MainWindow::initActions() { | 100 | void MainWindow::initActions() { |
100 | // Insert Task menu items | 101 | // Insert Task menu items |
101 | QActionGroup *items = new QActionGroup( this, QString::null, false ); | 102 | QActionGroup *items = new QActionGroup( this, QString::null, false ); |
102 | 103 | ||
103 | m_deleteCompleteAction = new QAction( QString::null, QWidget::tr( "Delete completed" ), | 104 | m_deleteCompleteAction = new QAction( QString::null, QWidget::tr( "Delete completed" ), |
104 | 0, items, 0 ); | 105 | 0, items, 0 ); |
105 | connect( m_deleteCompleteAction, SIGNAL(activated()), this, SLOT(slotDeleteCompleted()) ); | 106 | connect( m_deleteCompleteAction, SIGNAL(activated()), this, SLOT(slotDeleteCompleted()) ); |
106 | 107 | ||
107 | insertItemMenuItems( items ); | 108 | insertItemMenuItems( items ); |
108 | 109 | ||
109 | // Insert View menu items | 110 | // Insert View menu items |
110 | items = new QActionGroup( this, QString::null, false ); | 111 | items = new QActionGroup( this, QString::null, false ); |
111 | 112 | ||
112 | m_completedAction = new QAction( QString::null, QWidget::tr("Show completed tasks"), | 113 | m_completedAction = new QAction( QString::null, QWidget::tr("Show completed tasks"), |
113 | 0, items, 0, true ); | 114 | 0, items, 0, true ); |
114 | m_completedAction->setOn( showCompleted() ); | 115 | m_completedAction->setOn( showCompleted() ); |
115 | connect( m_completedAction, SIGNAL(toggled(bool)), this, SLOT(slotShowCompleted(bool)) ); | 116 | connect( m_completedAction, SIGNAL(toggled(bool)), this, SLOT(slotShowCompleted(bool)) ); |
116 | 117 | ||
117 | QAction *a = new QAction( QString::null, QWidget::tr("Show only over-due tasks"), | 118 | QAction *a = new QAction( QString::null, QWidget::tr("Show only over-due tasks"), |
118 | 0, items, 0, true ); | 119 | 0, items, 0, true ); |
119 | a->setOn( showOverDue() ); | 120 | a->setOn( showOverDue() ); |
120 | connect( a, SIGNAL(toggled(bool)), this, SLOT(slotShowDue(bool)) ); | 121 | connect( a, SIGNAL(toggled(bool)), this, SLOT(slotShowDue(bool)) ); |
121 | 122 | ||
122 | m_showDeadLineAction = new QAction( QString::null, QWidget::tr("Show task deadlines"), | 123 | m_showDeadLineAction = new QAction( QString::null, QWidget::tr("Show task deadlines"), |
123 | 0, items, 0, true ); | 124 | 0, items, 0, true ); |
124 | m_showDeadLineAction->setOn( showDeadline() ); | 125 | m_showDeadLineAction->setOn( showDeadline() ); |
125 | connect( m_showDeadLineAction, SIGNAL(toggled(bool)), this, SLOT(slotShowDeadLine(bool)) ); | 126 | connect( m_showDeadLineAction, SIGNAL(toggled(bool)), this, SLOT(slotShowDeadLine(bool)) ); |
126 | 127 | ||
127 | m_showQuickTaskAction = new QAction( QString::null, QWidget::tr("Show quick task bar"), | 128 | m_showQuickTaskAction = new QAction( QString::null, QWidget::tr("Show quick task bar"), |
128 | 0, items, 0, true ); | 129 | 0, items, 0, true ); |
129 | m_showQuickTaskAction->setOn( showQuickTask() ); | 130 | m_showQuickTaskAction->setOn( showQuickTask() ); |
130 | connect( m_showQuickTaskAction, SIGNAL(toggled(bool)), this, SLOT(slotShowQuickTask(bool)) ); | 131 | connect( m_showQuickTaskAction, SIGNAL(toggled(bool)), this, SLOT(slotShowQuickTask(bool)) ); |
131 | 132 | ||
132 | insertViewMenuItems( items ); | 133 | insertViewMenuItems( items ); |
133 | } | 134 | } |
134 | /* m_curCat from Config */ | 135 | /* m_curCat from Config */ |
135 | void MainWindow::initConfig() { | 136 | void MainWindow::initConfig() { |
136 | Config config( "todo" ); | 137 | Config config( "todo" ); |
137 | config.setGroup( "View" ); | 138 | config.setGroup( "View" ); |
138 | m_completed = config.readBoolEntry( "ShowComplete", true ); | 139 | m_completed = config.readBoolEntry( "ShowComplete", true ); |
139 | m_curCat = config.readEntry( "Category", QString::null ); | 140 | m_curCat = config.readEntry( "Category", QString::null ); |
140 | m_deadline = config.readBoolEntry( "ShowDeadLine", true); | 141 | m_deadline = config.readBoolEntry( "ShowDeadLine", true); |
141 | m_overdue = config.readBoolEntry("ShowOverDue", false ); | 142 | m_overdue = config.readBoolEntry("ShowOverDue", false ); |
142 | m_quicktask = config.readBoolEntry("ShowQuickTask", true); | 143 | m_quicktask = config.readBoolEntry("ShowQuickTask", true); |
143 | } | 144 | } |
144 | void MainWindow::initUI() { | 145 | void MainWindow::initUI() { |
145 | // Create main widget stack | 146 | // Create main widget stack |
146 | m_stack = new Opie::Ui::OWidgetStack(this, "main stack"); | 147 | m_stack = new Opie::Ui::OWidgetStack(this, "main stack"); |
147 | setCentralWidget( m_stack ); | 148 | setCentralWidget( m_stack ); |
148 | connect( this, SIGNAL(categorySelected(const QString&)), | 149 | connect( this, SIGNAL(categorySelected(const QString&)), |
149 | this, SLOT(setCategory(const QString&)) ); | 150 | this, SLOT(setCategory(const QString&)) ); |
150 | 151 | ||
151 | // Create quick task toolbar | 152 | // Create quick task toolbar |
152 | m_curQuick = new QuickEditImpl( this, m_quicktask ); | 153 | m_curQuick = new QuickEditImpl( this, m_quicktask ); |
153 | addToolBar( (QToolBar *)m_curQuick->widget(), QWidget::tr( "QuickEdit" ), | 154 | addToolBar( (QToolBar *)m_curQuick->widget(), QWidget::tr( "QuickEdit" ), |
154 | QMainWindow::Top, true ); | 155 | QMainWindow::Top, true ); |
155 | m_curQuick->signal()->connect( this, SLOT(slotQuickEntered()) ); | 156 | m_curQuick->signal()->connect( this, SLOT(slotQuickEntered()) ); |
156 | } | 157 | } |
157 | void MainWindow::initViews() { | 158 | void MainWindow::initViews() { |
158 | 159 | ||
159 | TableView* tableView = new TableView( this, m_stack ); | 160 | TableView* tableView = new TableView( this, m_stack ); |
160 | 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." ) ); | 161 | 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." ) ); |
161 | m_stack->addWidget( tableView, m_counter++ ); | 162 | m_stack->addWidget( tableView, m_counter++ ); |
162 | m_views.append( tableView ); | 163 | m_views.append( tableView ); |
163 | m_curView = tableView; | 164 | m_curView = tableView; |
164 | connectBase( tableView ); | 165 | connectBase( tableView ); |
165 | /* add QString type + QString configname to | 166 | /* add QString type + QString configname to |
166 | * the View menu | 167 | * the View menu |
167 | * and subdirs for multiple views | 168 | * and subdirs for multiple views |
168 | */ | 169 | */ |
169 | } | 170 | } |
170 | void MainWindow::initEditor() { | 171 | void MainWindow::initEditor() { |
171 | m_curEdit = new Editor(); | 172 | m_curEdit = new Editor(); |
172 | } | 173 | } |
173 | void MainWindow::initShow() { | 174 | void MainWindow::initShow() { |
174 | m_curShow = new TextViewShow(this, this); | 175 | m_curShow = new TextViewShow(this, this); |
175 | m_stack->addWidget( m_curShow->widget() , m_counter++ ); | 176 | m_stack->addWidget( m_curShow->widget() , m_counter++ ); |
176 | } | 177 | } |
177 | MainWindow::~MainWindow() { | 178 | MainWindow::~MainWindow() { |
178 | delete templateManager(); | 179 | delete templateManager(); |
179 | } | 180 | } |
180 | void MainWindow::connectBase( ViewBase* ) { | 181 | void MainWindow::connectBase( ViewBase* ) { |
181 | // once templates and signals mix we'll use it again | 182 | // once templates and signals mix we'll use it again |
182 | } | 183 | } |
183 | QPopupMenu* MainWindow::contextMenu( int , bool /*recur*/ ) { | 184 | QPopupMenu* MainWindow::contextMenu( int , bool /*recur*/ ) { |
184 | return itemContextMenu(); | 185 | return itemContextMenu(); |
185 | } | 186 | } |
186 | OPimTodoAccess::List MainWindow::list()const { | 187 | OPimTodoAccess::List MainWindow::list()const { |
187 | return m_todoMgr.list(); | 188 | return m_todoMgr.list(); |
188 | } | 189 | } |
189 | OPimTodoAccess::List MainWindow::sorted( bool asc, int sortOrder ) { | 190 | OPimTodoAccess::List MainWindow::sorted( bool asc, int sortOrder ) { |
190 | int cat = 0; | 191 | int cat = 0; |
191 | if ( m_curCat != tr( "All" ) ) | 192 | if ( m_curCat != tr( "All" ) ) |
192 | cat = currentCatId(); | 193 | cat = currentCatId(); |
193 | if ( m_curCat == tr( "Unfiled" ) ) | 194 | if ( m_curCat == tr( "Unfiled" ) ) |
194 | cat = -1; | 195 | cat = -1; |
195 | 196 | ||
196 | int filter = OPimTodoAccess::FilterCategory; | 197 | int filter = OPimTodoAccess::FilterCategory; |
197 | 198 | ||
198 | if (!m_completed ) | 199 | if (!m_completed ) |
199 | filter |= OPimTodoAccess::DoNotShowCompleted; | 200 | filter |= OPimTodoAccess::DoNotShowCompleted; |
200 | if (m_overdue) | 201 | if (m_overdue) |
201 | filter |= OPimTodoAccess::OnlyOverDue; | 202 | filter |= OPimTodoAccess::OnlyOverDue; |
202 | 203 | ||
203 | return m_todoMgr.sorted( asc, sortOrder, filter, cat ); | 204 | return m_todoMgr.sorted( asc, sortOrder, filter, cat ); |
204 | } | 205 | } |
205 | OPimTodoAccess::List MainWindow::sorted( bool asc, int sortOrder, int addFilter) { | 206 | OPimTodoAccess::List MainWindow::sorted( bool asc, int sortOrder, int addFilter) { |
206 | int cat = 0; | 207 | int cat = 0; |
207 | if ( m_curCat != tr( "All" ) ) | 208 | if ( m_curCat != tr( "All" ) ) |
208 | cat = currentCatId(); | 209 | cat = currentCatId(); |
209 | 210 | ||
210 | if ( m_curCat == tr( "Unfiled" ) ) | 211 | if ( m_curCat == tr( "Unfiled" ) ) |
211 | cat = -1; | 212 | cat = -1; |
212 | 213 | ||
213 | return m_todoMgr.sorted(asc, sortOrder, addFilter, cat ); | 214 | return m_todoMgr.sorted(asc, sortOrder, addFilter, cat ); |
214 | } | 215 | } |
215 | OPimTodo MainWindow::event( int uid ) { | 216 | OPimTodo MainWindow::event( int uid ) { |
216 | return m_todoMgr.event( uid ); | 217 | return m_todoMgr.event( uid ); |
217 | } | 218 | } |
218 | bool MainWindow::isSyncing()const { | 219 | bool MainWindow::isSyncing()const { |
219 | return m_syncing; | 220 | return m_syncing; |
220 | } | 221 | } |
221 | TemplateManager* MainWindow::templateManager() { | 222 | TemplateManager* MainWindow::templateManager() { |
222 | return m_tempManager; | 223 | return m_tempManager; |
223 | } | 224 | } |
224 | Editor* MainWindow::currentEditor() { | 225 | Editor* MainWindow::currentEditor() { |
225 | return m_curEdit; | 226 | return m_curEdit; |
226 | } | 227 | } |
227 | TodoShow* MainWindow::currentShow() { | 228 | TodoShow* MainWindow::currentShow() { |
228 | return m_curShow; | 229 | return m_curShow; |
229 | } | 230 | } |
230 | void MainWindow::slotReload() { | 231 | void MainWindow::slotReload() { |
231 | m_syncing = false; | 232 | m_syncing = false; |
232 | m_todoMgr.reload(); | 233 | m_todoMgr.reload(); |
233 | currentView()->updateView( ); | 234 | currentView()->updateView( ); |
234 | raiseCurrentView(); | 235 | raiseCurrentView(); |
235 | } | 236 | } |
236 | void MainWindow::closeEvent( QCloseEvent* e ) { | 237 | void MainWindow::closeEvent( QCloseEvent* e ) { |
237 | if (m_stack->visibleWidget() == currentShow()->widget() ) { | 238 | if (m_stack->visibleWidget() == currentShow()->widget() ) { |
238 | m_showing = false; | 239 | m_showing = false; |
239 | raiseCurrentView(); | 240 | raiseCurrentView(); |
240 | e->ignore(); | 241 | e->ignore(); |
241 | return; | 242 | return; |
242 | } | 243 | } |
243 | /* | 244 | /* |
244 | * we should have flushed and now we're still saving | 245 | * we should have flushed and now we're still saving |
245 | * so there is no need to flush | 246 | * so there is no need to flush |
246 | */ | 247 | */ |
247 | if (m_syncing ) { | 248 | if (m_syncing ) { |
248 | e->accept(); | 249 | e->accept(); |
249 | return; | 250 | return; |
250 | } | 251 | } |
251 | bool quit = false; | 252 | bool quit = false; |
252 | if ( m_todoMgr.saveAll() ){ | 253 | if ( m_todoMgr.saveAll() ){ |
253 | quit = true; | 254 | quit = true; |
254 | }else { | 255 | }else { |
255 | if ( QMessageBox::critical( this, QWidget::tr("Out of space"), | 256 | if ( QMessageBox::critical( this, QWidget::tr("Out of space"), |
256 | QWidget::tr("Todo was unable\n" | 257 | QWidget::tr("Todo was unable\n" |
257 | "to save your changes.\n" | 258 | "to save your changes.\n" |
258 | "Free up some space\n" | 259 | "Free up some space\n" |
259 | "and try again.\n" | 260 | "and try again.\n" |
260 | "\nQuit Anyway?"), | 261 | "\nQuit Anyway?"), |
261 | QMessageBox::Yes|QMessageBox::Escape, | 262 | QMessageBox::Yes|QMessageBox::Escape, |
262 | QMessageBox::No|QMessageBox::Default) | 263 | QMessageBox::No|QMessageBox::Default) |
263 | != QMessageBox::No ) { | 264 | != QMessageBox::No ) { |
264 | e->accept(); | 265 | e->accept(); |
265 | quit = true; | 266 | quit = true; |
266 | }else | 267 | }else |
267 | e->ignore(); | 268 | e->ignore(); |
268 | 269 | ||
269 | } | 270 | } |
270 | 271 | ||
271 | if (quit ) { | 272 | if (quit ) { |
272 | Config config( "todo" ); | 273 | Config config( "todo" ); |
273 | config.setGroup( "View" ); | 274 | config.setGroup( "View" ); |
274 | config.writeEntry( "ShowComplete", showCompleted() ); | 275 | config.writeEntry( "ShowComplete", showCompleted() ); |
275 | config.writeEntry( "Category", currentCategory() ); | 276 | config.writeEntry( "Category", currentCategory() ); |
276 | config.writeEntry( "ShowDeadLine", showDeadline()); | 277 | config.writeEntry( "ShowDeadLine", showDeadline()); |
277 | config.writeEntry( "ShowOverDue", showOverDue() ); | 278 | config.writeEntry( "ShowOverDue", showOverDue() ); |
278 | config.writeEntry( "ShowQuickTask", showQuickTask() ); | 279 | config.writeEntry( "ShowQuickTask", showQuickTask() ); |
279 | /* save templates */ | 280 | /* save templates */ |
280 | templateManager()->save(); | 281 | templateManager()->save(); |
281 | e->accept(); | 282 | e->accept(); |
282 | QTimer::singleShot(0, qApp, SLOT(closeAllWindows()) ); | 283 | QTimer::singleShot(0, qApp, SLOT(closeAllWindows()) ); |
283 | } | 284 | } |
284 | } | 285 | } |
285 | void MainWindow::slotItemNew() { | 286 | void MainWindow::slotItemNew() { |
286 | NewTaskDlg dlg( templateManager()->templates(), this ); | 287 | NewTaskDlg dlg( templateManager()->templates(), this ); |
287 | if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) { | 288 | if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) { |
288 | QString tempName = dlg.tempSelected(); | 289 | QString tempName = dlg.tempSelected(); |
289 | if ( tempName.isNull() ) | 290 | if ( tempName.isNull() ) |
290 | // Create new, blank task | 291 | // Create new, blank task |
291 | create(); | 292 | create(); |
292 | else { | 293 | else { |
293 | // Create new task from the template selected | 294 | // Create new task from the template selected |
294 | OPimTodo event = templateManager()->templateEvent( tempName ); | 295 | OPimTodo event = templateManager()->templateEvent( tempName ); |
295 | event = currentEditor()->edit( this, event ); | 296 | event = currentEditor()->edit( this, event ); |
296 | if ( currentEditor()->accepted() ) { | 297 | if ( currentEditor()->accepted() ) { |
297 | event.setUid( 1 ); | 298 | event.setUid( 1 ); |
298 | handleAlarms( OPimTodo(), event ); | 299 | handleAlarms( OPimTodo(), event ); |
299 | m_todoMgr.add( event ); | 300 | m_todoMgr.add( event ); |
300 | currentView()->addEvent( event ); | 301 | currentView()->addEvent( event ); |
301 | 302 | ||
302 | reloadCategories(); | 303 | reloadCategories(); |
303 | } | 304 | } |
304 | raiseCurrentView(); | 305 | raiseCurrentView(); |
305 | } | 306 | } |
306 | } | 307 | } |
307 | } | 308 | } |
308 | void MainWindow::slotItemEdit() { | 309 | void MainWindow::slotItemEdit() { |
309 | slotEdit( currentView()->current() ); | 310 | slotEdit( currentView()->current() ); |
310 | } | 311 | } |
311 | void MainWindow::slotItemDuplicate() { | 312 | void MainWindow::slotItemDuplicate() { |
312 | if(m_syncing) { | 313 | if(m_syncing) { |
313 | QMessageBox::warning(this, QWidget::tr("Todo"), | 314 | QMessageBox::warning(this, QWidget::tr("Todo"), |
314 | QWidget::tr("Data can not be edited, currently syncing")); | 315 | QWidget::tr("Data can not be edited, currently syncing")); |
315 | return; | 316 | return; |
316 | } | 317 | } |
317 | OPimTodo ev = m_todoMgr.event( currentView()->current() ); | 318 | OPimTodo ev = m_todoMgr.event( currentView()->current() ); |
318 | /* let's generate a new uid */ | 319 | /* let's generate a new uid */ |
319 | ev.setUid(1); | 320 | ev.setUid(1); |
320 | m_todoMgr.add( ev ); | 321 | m_todoMgr.add( ev ); |
321 | 322 | ||
322 | currentView()->addEvent( ev ); | 323 | currentView()->addEvent( ev ); |
323 | raiseCurrentView(); | 324 | raiseCurrentView(); |
324 | } | 325 | } |
325 | void MainWindow::slotItemDelete() { | 326 | void MainWindow::slotItemDelete() { |
326 | if (!currentView()->current() ) | 327 | if (!currentView()->current() ) |
327 | return; | 328 | return; |
328 | 329 | ||
329 | if(m_syncing) { | 330 | if(m_syncing) { |
330 | QMessageBox::warning(this, QWidget::tr("Todo"), | 331 | QMessageBox::warning(this, QWidget::tr("Todo"), |
331 | QWidget::tr("Data can not be edited, currently syncing")); | 332 | QWidget::tr("Data can not be edited, currently syncing")); |
332 | return; | 333 | return; |
333 | } | 334 | } |
334 | QString strName = currentView()->currentRepresentation(); | 335 | QString strName = currentView()->currentRepresentation(); |
335 | if (!QPEMessageBox::confirmDelete(this, QWidget::tr("Todo"), strName ) ) | 336 | if (!QPEMessageBox::confirmDelete(this, QWidget::tr("Todo"), strName ) ) |
336 | return; | 337 | return; |
337 | 338 | ||
338 | handleAlarms( m_todoMgr.event( currentView()->current() ), OPimTodo() ); | 339 | handleAlarms( m_todoMgr.event( currentView()->current() ), OPimTodo() ); |
339 | m_todoMgr.remove( currentView()->current() ); | 340 | m_todoMgr.remove( currentView()->current() ); |
340 | currentView()->removeEvent( currentView()->current() ); | 341 | currentView()->removeEvent( currentView()->current() ); |
341 | raiseCurrentView(); | 342 | raiseCurrentView(); |
342 | } | 343 | } |
343 | 344 | ||
344 | static const char *beamfile = "/tmp/opie-todo.vcs"; | 345 | static const char *beamfile = "/tmp/opie-todo.vcs"; |
345 | void MainWindow::slotItemBeam() { | 346 | void MainWindow::slotItemBeam() { |
346 | beam( currentView()->current() ); | 347 | beam( currentView()->current() ); |
347 | } | 348 | } |
348 | void MainWindow::slotItemFind() { | 349 | void MainWindow::slotItemFind() { |
349 | } | 350 | } |
350 | void MainWindow::slotConfigure() { | 351 | void MainWindow::slotConfigure() { |
351 | TemplateDialogImpl dlg( this, m_tempManager ); | 352 | TemplateDialogImpl dlg( this, m_tempManager ); |
352 | if ( QPEApplication::execDialog( &dlg ) != QDialog::Accepted ) | 353 | if ( QPEApplication::execDialog( &dlg ) != QDialog::Accepted ) |
353 | m_tempManager->load(); | 354 | m_tempManager->load(); |
354 | } | 355 | } |
355 | void MainWindow::slotDelete(int uid ) { | 356 | void MainWindow::slotDelete(int uid ) { |
356 | if( uid == 0 ) return; | 357 | if( uid == 0 ) return; |
357 | if(m_syncing) { | 358 | if(m_syncing) { |
358 | QMessageBox::warning(this, QWidget::tr("Todo"), | 359 | QMessageBox::warning(this, QWidget::tr("Todo"), |
359 | QWidget::tr("Data can not be edited, currently syncing")); | 360 | QWidget::tr("Data can not be edited, currently syncing")); |
360 | return; | 361 | return; |
361 | } | 362 | } |
362 | OPimTodo to = m_todoMgr.event(uid); | 363 | OPimTodo to = m_todoMgr.event(uid); |
363 | if (!QPEMessageBox::confirmDelete(this, QWidget::tr("Todo"), to.toShortText() ) ) | 364 | if (!QPEMessageBox::confirmDelete(this, QWidget::tr("Todo"), to.toShortText() ) ) |
364 | return; | 365 | return; |
365 | 366 | ||
366 | handleAlarms(to, OPimTodo() ); | 367 | handleAlarms(to, OPimTodo() ); |
367 | m_todoMgr.remove( to.uid() ); | 368 | m_todoMgr.remove( to.uid() ); |
368 | currentView()->removeEvent( to.uid() ); | 369 | currentView()->removeEvent( to.uid() ); |
369 | raiseCurrentView(); | 370 | raiseCurrentView(); |
370 | } | 371 | } |
371 | void MainWindow::slotDeleteAll() { | 372 | void MainWindow::slotDeleteAll() { |
372 | if(m_syncing) { | 373 | if(m_syncing) { |
373 | QMessageBox::warning(this, QWidget::tr("Todo"), | 374 | QMessageBox::warning(this, QWidget::tr("Todo"), |
374 | QWidget::tr("Data can not be edited, currently syncing")); | 375 | QWidget::tr("Data can not be edited, currently syncing")); |
375 | return; | 376 | return; |
376 | } | 377 | } |
377 | 378 | ||
378 | 379 | ||
379 | if ( !QPEMessageBox::confirmDelete( this, QWidget::tr( "Todo" ), QWidget::tr("all tasks?") ) ) | 380 | if ( !QPEMessageBox::confirmDelete( this, QWidget::tr( "Todo" ), QWidget::tr("all tasks?") ) ) |
380 | return; | 381 | return; |
381 | 382 | ||
382 | m_todoMgr.removeAll(); | 383 | m_todoMgr.removeAll(); |
383 | currentView()->clear(); | 384 | currentView()->clear(); |
384 | 385 | ||
385 | raiseCurrentView(); | 386 | raiseCurrentView(); |
386 | } | 387 | } |
387 | void MainWindow::slotDeleteCompleted() { | 388 | void MainWindow::slotDeleteCompleted() { |
388 | if(m_syncing) { | 389 | if(m_syncing) { |
389 | QMessageBox::warning(this, QWidget::tr("Todo"), | 390 | QMessageBox::warning(this, QWidget::tr("Todo"), |
390 | QWidget::tr("Data can not be edited, currently syncing")); | 391 | QWidget::tr("Data can not be edited, currently syncing")); |
391 | return; | 392 | return; |
392 | } | 393 | } |
393 | 394 | ||
394 | if ( !QPEMessageBox::confirmDelete( this, QWidget::tr( "Todo" ), QWidget::tr("all completed tasks?") ) ) | 395 | if ( !QPEMessageBox::confirmDelete( this, QWidget::tr( "Todo" ), QWidget::tr("all completed tasks?") ) ) |
395 | return; | 396 | return; |
396 | 397 | ||
397 | 398 | ||
398 | m_todoMgr.removeCompleted(); | 399 | m_todoMgr.removeCompleted(); |
399 | currentView()->updateView( ); | 400 | currentView()->updateView( ); |
400 | } | 401 | } |
401 | /* | 402 | /* |
402 | * set the category | 403 | * set the category |
403 | */ | 404 | */ |
404 | void MainWindow::setCategory( const QString &category ) { | 405 | void MainWindow::setCategory( const QString &category ) { |
405 | m_curCat = category; | 406 | m_curCat = category; |
406 | if ( m_curCat == tr( "All" ) ) | 407 | if ( m_curCat == tr( "All" ) ) |
407 | m_curCat = QString::null; | 408 | m_curCat = QString::null; |
408 | 409 | ||
409 | currentView()->setShowCategory( m_curCat ); | 410 | currentView()->setShowCategory( m_curCat ); |
410 | raiseCurrentView(); | 411 | raiseCurrentView(); |
411 | } | 412 | } |
412 | void MainWindow::slotShowDeadLine( bool dead) { | 413 | void MainWindow::slotShowDeadLine( bool dead) { |
413 | m_deadline = dead; | 414 | m_deadline = dead; |
414 | currentView()->setShowDeadline( dead ); | 415 | currentView()->setShowDeadline( dead ); |
415 | } | 416 | } |
416 | void MainWindow::slotShowCompleted( bool show) { | 417 | void MainWindow::slotShowCompleted( bool show) { |
417 | m_completed = show; | 418 | m_completed = show; |
418 | currentView()->setShowCompleted( m_completed ); | 419 | currentView()->setShowCompleted( m_completed ); |
419 | } | 420 | } |
420 | void MainWindow::slotShowQuickTask( bool show ) { | 421 | void MainWindow::slotShowQuickTask( bool show ) { |
421 | m_quicktask = show; | 422 | m_quicktask = show; |
422 | if ( m_quicktask ) | 423 | if ( m_quicktask ) |
423 | m_curQuick->widget()->show(); | 424 | m_curQuick->widget()->show(); |
424 | else | 425 | else |
425 | m_curQuick->widget()->hide(); | 426 | m_curQuick->widget()->hide(); |
426 | } | 427 | } |
427 | bool MainWindow::showOverDue()const { | 428 | bool MainWindow::showOverDue()const { |
428 | return m_overdue; | 429 | return m_overdue; |
429 | } | 430 | } |
430 | void MainWindow::setDocument( const QString& fi) { | 431 | void MainWindow::setDocument( const QString& fi) { |
431 | DocLnk doc(fi); | 432 | DocLnk doc(fi); |
432 | if (doc.isValid() ) | 433 | if (doc.isValid() ) |
433 | receiveFile(doc.file() ); | 434 | receiveFile(doc.file() ); |
434 | else | 435 | else |
435 | receiveFile(fi ); | 436 | receiveFile(fi ); |
436 | } | 437 | } |
437 | void MainWindow::beamDone( Ir* ir) { | 438 | void MainWindow::beamDone( Ir* ir) { |
438 | delete ir; | 439 | delete ir; |
439 | ::unlink( beamfile ); | 440 | ::unlink( beamfile ); |
440 | } | 441 | } |
441 | void MainWindow::receiveFile( const QString& filename ) { | 442 | void MainWindow::receiveFile( const QString& filename ) { |
442 | OPimTodoAccessVCal* cal = new OPimTodoAccessVCal(filename ); | 443 | OPimTodoAccessVCal* cal = new OPimTodoAccessVCal(filename ); |
443 | 444 | ||
444 | OPimTodoAccess acc( cal ); | 445 | OPimTodoAccess acc( cal ); |
445 | acc.load(); | 446 | acc.load(); |
446 | OPimTodoAccess::List list = acc.allRecords(); | 447 | OPimTodoAccess::List list = acc.allRecords(); |
447 | 448 | ||
448 | if (list.count()){ | 449 | if (list.count()){ |
449 | 450 | ||
450 | QString message = QWidget::tr("<P>%1 new tasks arrived.<p>Would you like to add them to your Todolist?").arg(list.count() ); | 451 | QString message = QWidget::tr("<P>%1 new tasks arrived.<p>Would you like to add them to your Todolist?").arg(list.count() ); |
451 | 452 | ||
452 | if ( QMessageBox::information(this, QWidget::tr("New Tasks"), | 453 | if ( QMessageBox::information(this, QWidget::tr("New Tasks"), |
453 | message, QMessageBox::Ok, | 454 | message, QMessageBox::Ok, |
454 | QMessageBox::Cancel ) == QMessageBox::Ok ) { | 455 | QMessageBox::Cancel ) == QMessageBox::Ok ) { |
455 | OPimTodoAccess::List::Iterator it; | 456 | OPimTodoAccess::List::Iterator it; |
456 | for ( it = list.begin(); it != list.end(); ++it ) | 457 | for ( it = list.begin(); it != list.end(); ++it ) |
457 | m_todoMgr.add( (*it) ); | 458 | m_todoMgr.add( (*it) ); |
458 | 459 | ||
459 | currentView()->updateView(); | 460 | currentView()->updateView(); |
460 | } | 461 | } |
461 | } | 462 | } |
462 | } | 463 | } |
463 | 464 | ||
464 | void MainWindow::slotFlush() { | 465 | void MainWindow::slotFlush() { |
465 | m_syncing = true; | 466 | m_syncing = true; |
466 | m_todoMgr.save(); | 467 | m_todoMgr.save(); |
467 | } | 468 | } |
468 | void MainWindow::slotShowDetails() { | 469 | void MainWindow::slotShowDetails() { |
469 | slotShow( currentView()->current() ); | 470 | slotShow( currentView()->current() ); |
470 | } | 471 | } |
471 | bool MainWindow::showCompleted()const { | 472 | bool MainWindow::showCompleted()const { |
472 | return m_completed; | 473 | return m_completed; |
473 | } | 474 | } |
474 | bool MainWindow::showDeadline()const { | 475 | bool MainWindow::showDeadline()const { |
475 | return m_deadline; | 476 | return m_deadline; |
476 | } | 477 | } |
477 | bool MainWindow::showQuickTask()const { | 478 | bool MainWindow::showQuickTask()const { |
478 | return m_quicktask; | 479 | return m_quicktask; |
479 | } | 480 | } |
480 | QString MainWindow::currentCategory()const { | 481 | QString MainWindow::currentCategory()const { |
481 | return m_curCat; | 482 | return m_curCat; |
482 | } | 483 | } |
483 | int MainWindow::currentCatId() { | 484 | int MainWindow::currentCatId() { |
484 | return m_todoMgr.catId( m_curCat ); | 485 | return m_todoMgr.catId( m_curCat ); |
485 | } | 486 | } |
486 | ViewBase* MainWindow::currentView() { | 487 | ViewBase* MainWindow::currentView() { |
487 | return m_curView; | 488 | return m_curView; |
488 | } | 489 | } |
489 | void MainWindow::raiseCurrentView() { | 490 | void MainWindow::raiseCurrentView() { |
490 | // due QPE/Application/todolist show(int) | 491 | // due QPE/Application/todolist show(int) |
491 | // we might not have the populateCategories slot called once | 492 | // we might not have the populateCategories slot called once |
492 | // we would show the otodo but then imediately switch to the currentView | 493 | // we would show the otodo but then imediately switch to the currentView |
493 | // if we're initially showing we shouldn't raise the table | 494 | // if we're initially showing we shouldn't raise the table |
494 | // in returnFromView we fix up m_showing | 495 | // in returnFromView we fix up m_showing |
495 | if (m_showing ) return; | 496 | if (m_showing ) return; |
496 | 497 | ||
497 | m_stack->raiseWidget( m_curView->widget() ); | 498 | m_stack->raiseWidget( m_curView->widget() ); |
498 | } | 499 | } |
499 | void MainWindow::slotShowDue(bool ov) { | 500 | void MainWindow::slotShowDue(bool ov) { |
500 | m_overdue = ov; | 501 | m_overdue = ov; |
501 | currentView()->showOverDue( ov ); | 502 | currentView()->showOverDue( ov ); |
502 | raiseCurrentView(); | 503 | raiseCurrentView(); |
503 | } | 504 | } |
504 | void MainWindow::slotShow( int uid ) { | 505 | void MainWindow::slotShow( int uid ) { |
505 | if ( uid == 0 ) return; | 506 | if ( uid == 0 ) return; |
506 | 507 | ||
507 | 508 | ||
508 | currentShow()->slotShow( event( uid ) ); | 509 | currentShow()->slotShow( event( uid ) ); |
509 | m_stack->raiseWidget( currentShow()->widget() ); | 510 | m_stack->raiseWidget( currentShow()->widget() ); |
510 | } | 511 | } |
511 | void MainWindow::slotShowNext() { | 512 | void MainWindow::slotShowNext() { |
512 | int l = currentView()->next(); | 513 | int l = currentView()->next(); |
513 | if (l!=0) | 514 | if (l!=0) |
514 | slotShow(l); | 515 | slotShow(l); |
515 | } | 516 | } |
516 | void MainWindow::slotShowPrev() { | 517 | void MainWindow::slotShowPrev() { |
517 | int l = currentView()->prev(); | 518 | int l = currentView()->prev(); |
518 | if (l!=0) | 519 | if (l!=0) |
519 | slotShow(l); | 520 | slotShow(l); |
520 | } | 521 | } |
521 | void MainWindow::slotEdit( int uid ) { | 522 | void MainWindow::slotEdit( int uid ) { |
522 | if (uid == 0 ) return; | 523 | if (uid == 0 ) return; |
523 | if(m_syncing) { | 524 | if(m_syncing) { |
524 | QMessageBox::warning(this, QWidget::tr("Todo"), | 525 | QMessageBox::warning(this, QWidget::tr("Todo"), |
525 | QWidget::tr("Data can't be edited, currently syncing")); | 526 | QWidget::tr("Data can't be edited, currently syncing")); |
526 | return; | 527 | return; |
527 | } | 528 | } |
528 | 529 | ||
529 | OPimTodo old_todo = m_todoMgr.event( uid ); | 530 | OPimTodo old_todo = m_todoMgr.event( uid ); |
530 | 531 | ||
531 | OPimTodo todo = currentEditor()->edit(this, old_todo ); | 532 | OPimTodo todo = currentEditor()->edit(this, old_todo ); |
532 | 533 | ||
533 | /* if completed */ | 534 | /* if completed */ |
534 | if ( currentEditor()->accepted() ) { | 535 | if ( currentEditor()->accepted() ) { |
535 | handleAlarms( old_todo, todo ); | 536 | handleAlarms( old_todo, todo ); |
536 | m_todoMgr.update( todo.uid(), todo ); | 537 | m_todoMgr.update( todo.uid(), todo ); |
537 | currentView()->replaceEvent( todo ); | 538 | currentView()->replaceEvent( todo ); |
538 | /* a Category might have changed */ | 539 | /* a Category might have changed */ |
539 | reloadCategories(); | 540 | reloadCategories(); |
540 | } | 541 | } |
541 | 542 | ||
542 | raiseCurrentView(); | 543 | raiseCurrentView(); |
543 | } | 544 | } |
544 | /* | 545 | /* |
545 | void MainWindow::slotUpdate1( int uid, const SmallTodo& ev) { | 546 | void MainWindow::slotUpdate1( int uid, const SmallTodo& ev) { |
546 | m_todoMgr.update( uid, ev ); | 547 | m_todoMgr.update( uid, ev ); |
547 | } | 548 | } |
548 | */ | 549 | */ |
549 | void MainWindow::updateTodo( const OPimTodo& ev) { | 550 | void MainWindow::updateTodo( const OPimTodo& ev) { |
550 | m_todoMgr.update( ev.uid() , ev ); | 551 | m_todoMgr.update( ev.uid() , ev ); |
551 | } | 552 | } |
552 | /* The view changed it's configuration | 553 | /* The view changed it's configuration |
553 | * update the view menu | 554 | * update the view menu |
554 | */ | 555 | */ |
555 | void MainWindow::slotUpdate3( QWidget* ) { | 556 | void MainWindow::slotUpdate3( QWidget* ) { |
556 | 557 | ||
557 | } | 558 | } |
558 | void MainWindow::updateList() { | 559 | void MainWindow::updateList() { |
559 | m_todoMgr.updateList(); | 560 | m_todoMgr.updateList(); |
560 | } | 561 | } |
561 | void MainWindow::setReadAhead( uint count ) { | 562 | void MainWindow::setReadAhead( uint count ) { |
562 | if (m_todoMgr.todoDB() ) | 563 | if (m_todoMgr.todoDB() ) |
563 | m_todoMgr.todoDB()->setReadAhead( count ); | 564 | m_todoMgr.todoDB()->setReadAhead( count ); |
564 | } | 565 | } |
565 | void MainWindow::slotQuickEntered() { | 566 | void MainWindow::slotQuickEntered() { |
566 | OPimTodo todo = quickEditor()->todo(); | 567 | OPimTodo todo = quickEditor()->todo(); |
567 | if (todo.isEmpty() ) | 568 | if (todo.isEmpty() ) |
568 | return; | 569 | return; |
569 | 570 | ||
570 | m_todoMgr.add( todo ); | 571 | m_todoMgr.add( todo ); |
571 | currentView()->addEvent( todo ); | 572 | currentView()->addEvent( todo ); |
572 | raiseCurrentView(); | 573 | raiseCurrentView(); |
573 | } | 574 | } |
574 | QuickEditBase* MainWindow::quickEditor() { | 575 | QuickEditBase* MainWindow::quickEditor() { |
575 | return m_curQuick; | 576 | return m_curQuick; |
576 | } | 577 | } |
577 | void MainWindow::slotComplete( int uid ) { | 578 | void MainWindow::slotComplete( int uid ) { |
578 | slotComplete( event(uid) ); | 579 | slotComplete( event(uid) ); |
579 | } | 580 | } |
580 | void MainWindow::slotComplete( const OPimTodo& todo ) { | 581 | void MainWindow::slotComplete( const OPimTodo& todo ) { |
581 | OPimTodo to = todo; | 582 | OPimTodo to = todo; |
582 | to.setCompleted( !to.isCompleted() ); | 583 | to.setCompleted( !to.isCompleted() ); |
583 | to.setCompletedDate( QDate::currentDate() ); | 584 | to.setCompletedDate( QDate::currentDate() ); |
584 | 585 | ||
585 | /* | 586 | /* |
586 | * if the item does recur | 587 | * if the item does recur |
587 | * we need to spin it off | 588 | * we need to spin it off |
588 | * and update the items duedate to the next | 589 | * and update the items duedate to the next |
589 | * possible recurrance of this item... | 590 | * possible recurrance of this item... |
590 | * the spinned off one will loose the | 591 | * the spinned off one will loose the |
591 | * recurrence. | 592 | * recurrence. |
592 | * We calculate the difference between the old due date and the | 593 | * We calculate the difference between the old due date and the |
593 | * new one and add this diff to start, completed and alarm dates | 594 | * new one and add this diff to start, completed and alarm dates |
594 | * -zecke | 595 | * -zecke |
595 | */ | 596 | */ |
596 | if ( to.hasRecurrence() && to.isCompleted() ) { | 597 | if ( to.hasRecurrence() && to.isCompleted() ) { |
597 | OPimTodo to2( to ); | 598 | OPimTodo to2( to ); |
598 | 599 | ||
599 | /* the spinned off one won't recur anymore */ | 600 | /* the spinned off one won't recur anymore */ |
600 | to.setRecurrence( OPimRecurrence() ); | 601 | to.setRecurrence( OPimRecurrence() ); |
601 | 602 | ||
602 | OPimRecurrence rec = to2.recurrence(); | 603 | OPimRecurrence rec = to2.recurrence(); |
603 | rec.setStart( to.dueDate() ); | 604 | rec.setStart( to.dueDate() ); |
604 | to2.setRecurrence( rec ); | 605 | to2.setRecurrence( rec ); |
605 | /* | 606 | /* |
606 | * if there is a next occurence | 607 | * if there is a next occurence |
607 | * from the duedate of the last recurrance | 608 | * from the duedate of the last recurrance |
608 | */ | 609 | */ |
609 | QDate date; | 610 | QDate date; |
610 | if ( to2.recurrence().nextOcurrence( to2.dueDate().addDays(1), date ) ) { | 611 | if ( to2.recurrence().nextOcurrence( to2.dueDate().addDays(1), date ) ) { |
611 | int dayDiff = to.dueDate().daysTo( date ); | 612 | int dayDiff = to.dueDate().daysTo( date ); |
612 | QDate inval; | 613 | QDate inval; |
613 | /* generate a new uid for the old record */ | 614 | /* generate a new uid for the old record */ |
614 | to.setUid( 1 ); | 615 | to.setUid( 1 ); |
615 | 616 | ||
616 | /* add the old one cause it has a new UID here cause it was spin off */ | 617 | /* add the old one cause it has a new UID here cause it was spin off */ |
617 | m_todoMgr.add( to ); | 618 | m_todoMgr.add( to ); |
618 | 619 | ||
619 | /* | 620 | /* |
620 | * update the due date | 621 | * update the due date |
621 | * start date | 622 | * start date |
622 | * and complete date | 623 | * and complete date |
623 | */ | 624 | */ |
624 | to2.setDueDate( date ); | 625 | to2.setDueDate( date ); |
625 | rec.setStart( date ); | 626 | rec.setStart( date ); |
626 | to2.setRecurrence( rec ); // could be Monday, TuesDay, Thursday every week | 627 | to2.setRecurrence( rec ); // could be Monday, TuesDay, Thursday every week |
627 | 628 | ||
628 | /* move start date */ | 629 | /* move start date */ |
629 | if (to2.hasStartDate() ) | 630 | if (to2.hasStartDate() ) |
630 | to2.setStartDate( to2.startDate().addDays( dayDiff ) ); | 631 | to2.setStartDate( to2.startDate().addDays( dayDiff ) ); |
631 | 632 | ||
632 | /* now the alarms */ | 633 | /* now the alarms */ |
633 | if (to2.hasNotifiers() ) { | 634 | if (to2.hasNotifiers() ) { |
634 | OPimNotifyManager::Alarms _als = to2.notifiers().alarms(); | 635 | OPimNotifyManager::Alarms _als = to2.notifiers().alarms(); |
635 | OPimNotifyManager::Alarms als; | 636 | OPimNotifyManager::Alarms als; |
636 | 637 | ||
637 | /* for every alarm move the day */ | 638 | /* for every alarm move the day */ |
638 | for ( OPimNotifyManager::Alarms::Iterator it = _als.begin(); it != _als.end(); ++it ) { | 639 | for ( OPimNotifyManager::Alarms::Iterator it = _als.begin(); it != _als.end(); ++it ) { |
639 | OPimAlarm al = (*it); | 640 | OPimAlarm al = (*it); |
640 | al.setDateTime( al.dateTime().addDays( dayDiff ) ); | 641 | al.setDateTime( al.dateTime().addDays( dayDiff ) ); |
641 | als.append( al ); | 642 | als.append( al ); |
642 | } | 643 | } |
643 | to2.notifiers().setAlarms( als ); | 644 | to2.notifiers().setAlarms( als ); |
644 | handleAlarms( OPimTodo(), todo ); | 645 | handleAlarms( OPimTodo(), todo ); |
645 | } | 646 | } |
646 | to2.setCompletedDate( inval ); | 647 | to2.setCompletedDate( inval ); |
647 | to2.setCompleted( false ); | 648 | to2.setCompleted( false ); |
648 | 649 | ||
649 | updateTodo( to2 ); | 650 | updateTodo( to2 ); |
650 | }else | 651 | }else |
651 | updateTodo( to ); | 652 | updateTodo( to ); |
652 | }else | 653 | }else |
653 | updateTodo( to ); | 654 | updateTodo( to ); |
654 | 655 | ||
655 | currentView()->updateView(); | 656 | currentView()->updateView(); |
656 | raiseCurrentView(); | 657 | raiseCurrentView(); |
657 | } | 658 | } |
658 | void MainWindow::flush() { | 659 | void MainWindow::flush() { |
659 | slotFlush(); | 660 | slotFlush(); |
660 | } | 661 | } |
661 | void MainWindow::reload() { | 662 | void MainWindow::reload() { |
662 | slotReload(); | 663 | slotReload(); |
663 | } | 664 | } |
664 | int MainWindow::create() { | 665 | int MainWindow::create() { |