author | eilers <eilers> | 2004-04-28 09:23:28 (UTC) |
---|---|---|
committer | eilers <eilers> | 2004-04-28 09:23:28 (UTC) |
commit | 8af6d533817ddc490c9d19344c7f0fa83239831e (patch) (unidiff) | |
tree | e25fcc93a4949f32e389aad8212051c093108b1a | |
parent | 134b7accd6bdc8fbc160a42f7c52c585e73f4add (diff) | |
download | opie-8af6d533817ddc490c9d19344c7f0fa83239831e.zip opie-8af6d533817ddc490c9d19344c7f0fa83239831e.tar.gz opie-8af6d533817ddc490c9d19344c7f0fa83239831e.tar.bz2 |
Removed static cast which is not working with the new modifications of
the opie-pim api
-rw-r--r-- | core/pim/todo/mainwindow.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp index 924fde1..2002e87 100644 --- a/core/pim/todo/mainwindow.cpp +++ b/core/pim/todo/mainwindow.cpp | |||
@@ -1,1041 +1,1042 @@ | |||
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 <qmenubar.h> | 45 | #include <qmenubar.h> |
46 | #include <qmessagebox.h> | 46 | #include <qmessagebox.h> |
47 | #include <qpushbutton.h> | 47 | #include <qpushbutton.h> |
48 | #include <qaction.h> | 48 | #include <qaction.h> |
49 | #include <qtimer.h> | 49 | #include <qtimer.h> |
50 | #include <qlayout.h> | 50 | #include <qlayout.h> |
51 | #include <qwhatsthis.h> | 51 | #include <qwhatsthis.h> |
52 | 52 | ||
53 | #include "quickeditimpl.h" | 53 | #include "quickeditimpl.h" |
54 | #include "todotemplatemanager.h" | 54 | #include "todotemplatemanager.h" |
55 | #include "templateeditor.h" | 55 | #include "templateeditor.h" |
56 | #include "tableview.h" | 56 | #include "tableview.h" |
57 | 57 | ||
58 | #include "textviewshow.h" | 58 | #include "textviewshow.h" |
59 | #include "todoeditor.h" | 59 | #include "todoeditor.h" |
60 | #include "mainwindow.h" | 60 | #include "mainwindow.h" |
61 | 61 | ||
62 | using Opie::Core::OApplicationFactory; | 62 | using Opie::Core::OApplicationFactory; |
63 | OPIE_EXPORT_APP( OApplicationFactory<Todo::MainWindow> ) | 63 | OPIE_EXPORT_APP( OApplicationFactory<Todo::MainWindow> ) |
64 | 64 | ||
65 | using namespace Opie; | 65 | using namespace Opie; |
66 | using namespace Todo; | 66 | using namespace Todo; |
67 | 67 | ||
68 | MainWindow::MainWindow( QWidget* parent, | 68 | MainWindow::MainWindow( QWidget* parent, |
69 | const char* name, WFlags ) | 69 | const char* name, WFlags ) |
70 | : Opie::OPimMainWindow( "Todolist", parent, name, WType_TopLevel | WStyle_ContextHelp ) | 70 | : Opie::OPimMainWindow( "Todolist", parent, name, WType_TopLevel | WStyle_ContextHelp ) |
71 | { | 71 | { |
72 | if (!name) | 72 | if (!name) |
73 | setName("todo window"); | 73 | setName("todo window"); |
74 | 74 | ||
75 | m_syncing = false; | 75 | m_syncing = false; |
76 | m_showing = false; | 76 | m_showing = false; |
77 | m_counter = 0; | 77 | m_counter = 0; |
78 | m_tempManager = new TemplateManager(); | 78 | m_tempManager = new TemplateManager(); |
79 | m_tempManager->load(); | 79 | m_tempManager->load(); |
80 | 80 | ||
81 | initUI(); | 81 | initUI(); |
82 | initConfig(); | 82 | initConfig(); |
83 | initViews(); | 83 | initViews(); |
84 | initActions(); | 84 | initActions(); |
85 | initEditor(); | 85 | initEditor(); |
86 | initShow(); | 86 | initShow(); |
87 | initTemplate(); | 87 | initTemplate(); |
88 | 88 | ||
89 | populateTemplates(); | 89 | populateTemplates(); |
90 | raiseCurrentView(); | 90 | raiseCurrentView(); |
91 | QTimer::singleShot(0, this, SLOT(populateCategories() ) ); | 91 | QTimer::singleShot(0, this, SLOT(populateCategories() ) ); |
92 | } | 92 | } |
93 | void MainWindow::initTemplate() { | 93 | void MainWindow::initTemplate() { |
94 | m_curTempEd = new TemplateEditor( this, templateManager() ); | 94 | m_curTempEd = new TemplateEditor( this, templateManager() ); |
95 | } | 95 | } |
96 | void MainWindow::initActions() { | 96 | void MainWindow::initActions() { |
97 | 97 | ||
98 | // Data menu | 98 | // Data menu |
99 | m_edit->insertItem(QWidget::tr("New from template"), m_template, | 99 | m_edit->insertItem(QWidget::tr("New from template"), m_template, |
100 | -1, 0 ); | 100 | -1, 0 ); |
101 | 101 | ||
102 | QAction* a = new QAction( QWidget::tr("New Task" ), Resource::loadPixmap( "new" ), | 102 | QAction* a = new QAction( QWidget::tr("New Task" ), Resource::loadPixmap( "new" ), |
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( slotNew() ) ); | 105 | this, SLOT( slotNew() ) ); |
106 | a->setWhatsThis( QWidget::tr( "Click here to create a new task." ) ); | 106 | a->setWhatsThis( QWidget::tr( "Click here to create a new task." ) ); |
107 | a->addTo(m_tool ); | 107 | a->addTo(m_tool ); |
108 | a->addTo(m_edit ); | 108 | a->addTo(m_edit ); |
109 | 109 | ||
110 | a = new QAction( QWidget::tr("Edit Task"), Resource::loadIconSet( "edit" ), | 110 | a = new QAction( QWidget::tr("Edit Task"), Resource::loadIconSet( "edit" ), |
111 | QString::null, 0, this, 0 ); | 111 | QString::null, 0, this, 0 ); |
112 | connect(a, SIGNAL(activated() ), | 112 | connect(a, SIGNAL(activated() ), |
113 | this, SLOT( slotEdit() ) ); | 113 | this, SLOT( slotEdit() ) ); |
114 | a->setWhatsThis( QWidget::tr( "Click here to modify the current task." ) ); | 114 | a->setWhatsThis( QWidget::tr( "Click here to modify the current task." ) ); |
115 | a->addTo( m_tool ); | 115 | a->addTo( m_tool ); |
116 | a->addTo( m_edit ); | 116 | a->addTo( m_edit ); |
117 | m_editAction = a; | 117 | m_editAction = a; |
118 | 118 | ||
119 | a = new QAction( QString::null, QWidget::tr("View Task"), 0, this, 0 ); | 119 | a = new QAction( QString::null, QWidget::tr("View Task"), 0, this, 0 ); |
120 | connect(a, SIGNAL( activated() ), | 120 | connect(a, SIGNAL( activated() ), |
121 | this, SLOT( slotShowDetails() ) ); | 121 | this, SLOT( slotShowDetails() ) ); |
122 | a->addTo( m_edit ); | 122 | a->addTo( m_edit ); |
123 | 123 | ||
124 | m_edit->insertSeparator(); | 124 | m_edit->insertSeparator(); |
125 | 125 | ||
126 | a = new QAction( QWidget::tr("Delete..."), Resource::loadIconSet( "trash" ), | 126 | a = new QAction( QWidget::tr("Delete..."), Resource::loadIconSet( "trash" ), |
127 | QString::null, 0, this, 0 ); | 127 | QString::null, 0, this, 0 ); |
128 | connect(a, SIGNAL(activated() ), | 128 | connect(a, SIGNAL(activated() ), |
129 | this, SLOT(slotDelete() ) ); | 129 | this, SLOT(slotDelete() ) ); |
130 | a->setWhatsThis( QWidget::tr( "Click here to remove the current task." ) ); | 130 | a->setWhatsThis( QWidget::tr( "Click here to remove the current task." ) ); |
131 | a->addTo( m_tool ); | 131 | a->addTo( m_tool ); |
132 | a->addTo( m_edit ); | 132 | a->addTo( m_edit ); |
133 | m_deleteAction = a; | 133 | m_deleteAction = a; |
134 | 134 | ||
135 | a = new QAction( QString::null, QWidget::tr("Delete all..."), 0, this, 0 ); | 135 | a = new QAction( QString::null, QWidget::tr("Delete all..."), 0, this, 0 ); |
136 | connect(a, SIGNAL( activated() ), | 136 | connect(a, SIGNAL( activated() ), |
137 | this, SLOT( slotDeleteAll() ) ); | 137 | this, SLOT( slotDeleteAll() ) ); |
138 | a->addTo(m_edit ); | 138 | a->addTo(m_edit ); |
139 | m_deleteAllAction = a; | 139 | m_deleteAllAction = a; |
140 | 140 | ||
141 | a = new QAction( QString::null, QWidget::tr("Delete completed"), | 141 | a = new QAction( QString::null, QWidget::tr("Delete completed"), |
142 | 0, this, 0 ); | 142 | 0, this, 0 ); |
143 | connect(a, SIGNAL( activated() ), | 143 | connect(a, SIGNAL( activated() ), |
144 | this, SLOT( slotDeleteCompleted() ) ); | 144 | this, SLOT( slotDeleteCompleted() ) ); |
145 | a->addTo(m_edit ); | 145 | a->addTo(m_edit ); |
146 | a->setEnabled( TRUE ); | 146 | a->setEnabled( TRUE ); |
147 | m_deleteCompleteAction = a; | 147 | m_deleteCompleteAction = a; |
148 | 148 | ||
149 | m_edit->insertSeparator(); | 149 | m_edit->insertSeparator(); |
150 | 150 | ||
151 | a = new QAction( QString::null, QWidget::tr("Duplicate"), 0, this, 0 ); | 151 | a = new QAction( QString::null, QWidget::tr("Duplicate"), 0, this, 0 ); |
152 | connect(a, SIGNAL( activated() ), | 152 | connect(a, SIGNAL( activated() ), |
153 | this, SLOT( slotDuplicate() ) ); | 153 | this, SLOT( slotDuplicate() ) ); |
154 | a->addTo(m_edit ); | 154 | a->addTo(m_edit ); |
155 | m_duplicateAction = a; | 155 | m_duplicateAction = a; |
156 | 156 | ||
157 | m_edit->insertSeparator(); | 157 | m_edit->insertSeparator(); |
158 | 158 | ||
159 | if ( Ir::supported() ) { | 159 | if ( Ir::supported() ) { |
160 | a = new QAction( QWidget::tr( "Beam" ), Resource::loadPixmap( "beam" ), QString::null, 0, this, 0 ); | 160 | a = new QAction( QWidget::tr( "Beam" ), Resource::loadPixmap( "beam" ), QString::null, 0, this, 0 ); |
161 | connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) ); | 161 | connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) ); |
162 | a->setWhatsThis( QWidget::tr( "Click here to send the current task to another device." ) ); | 162 | a->setWhatsThis( QWidget::tr( "Click here to send the current task to another device." ) ); |
163 | a->addTo( m_edit ); | 163 | a->addTo( m_edit ); |
164 | a->addTo( m_tool ); | 164 | a->addTo( m_tool ); |
165 | } | 165 | } |
166 | 166 | ||
167 | #if 0 | 167 | #if 0 |
168 | // Options menu | 168 | // Options menu |
169 | a = new QAction( QWidget::tr("Find"), Resource::loadIconSet( "mag" ), | 169 | a = new QAction( QWidget::tr("Find"), Resource::loadIconSet( "mag" ), |
170 | QString::null, 0, this, 0 ); | 170 | QString::null, 0, this, 0 ); |
171 | connect(a, SIGNAL( activated() ), this, SLOT( slotFind() ) ); | 171 | connect(a, SIGNAL( activated() ), this, SLOT( slotFind() ) ); |
172 | a->addTo( m_options ); | 172 | a->addTo( m_options ); |
173 | m_findAction = a; | 173 | m_findAction = a; |
174 | 174 | ||
175 | 175 | ||
176 | m_options->insertSeparator(); | 176 | m_options->insertSeparator(); |
177 | #endif | 177 | #endif |
178 | 178 | ||
179 | m_completedAction = new QAction( QString::null, QWidget::tr("Show completed tasks"), | 179 | m_completedAction = new QAction( QString::null, QWidget::tr("Show completed tasks"), |
180 | 0, this, 0, TRUE ); | 180 | 0, this, 0, TRUE ); |
181 | m_completedAction->addTo( m_options ); | 181 | m_completedAction->addTo( m_options ); |
182 | m_completedAction->setOn( showCompleted() ); | 182 | m_completedAction->setOn( showCompleted() ); |
183 | connect(m_completedAction, SIGNAL( toggled(bool) ), this, SLOT(slotShowCompleted(bool) ) ); | 183 | connect(m_completedAction, SIGNAL( toggled(bool) ), this, SLOT(slotShowCompleted(bool) ) ); |
184 | 184 | ||
185 | a = new QAction( QString::null, QWidget::tr("Show only over-due tasks"), | 185 | a = new QAction( QString::null, QWidget::tr("Show only over-due tasks"), |
186 | 0, this, 0, TRUE ); | 186 | 0, this, 0, TRUE ); |
187 | a->addTo( m_options ); | 187 | a->addTo( m_options ); |
188 | a->setOn( showOverDue() ); | 188 | a->setOn( showOverDue() ); |
189 | connect(a, SIGNAL(toggled(bool)), this, SLOT(slotShowDue(bool) ) ); | 189 | connect(a, SIGNAL(toggled(bool)), this, SLOT(slotShowDue(bool) ) ); |
190 | 190 | ||
191 | m_showDeadLineAction = new QAction( QString::null, QWidget::tr("Show task deadlines"), | 191 | m_showDeadLineAction = new QAction( QString::null, QWidget::tr("Show task deadlines"), |
192 | 0, this, 0, TRUE ); | 192 | 0, this, 0, TRUE ); |
193 | m_showDeadLineAction->addTo( m_options ); | 193 | m_showDeadLineAction->addTo( m_options ); |
194 | m_showDeadLineAction->setOn( showDeadline() ); | 194 | m_showDeadLineAction->setOn( showDeadline() ); |
195 | connect(m_showDeadLineAction, SIGNAL(toggled(bool) ), this, SLOT( slotShowDeadLine(bool) ) ); | 195 | connect(m_showDeadLineAction, SIGNAL(toggled(bool) ), this, SLOT( slotShowDeadLine(bool) ) ); |
196 | 196 | ||
197 | m_showQuickTaskAction = new QAction( QString::null, QWidget::tr("Show quick task bar"), | 197 | m_showQuickTaskAction = new QAction( QString::null, QWidget::tr("Show quick task bar"), |
198 | 0, this, 0, TRUE ); | 198 | 0, this, 0, TRUE ); |
199 | m_showQuickTaskAction->addTo( m_options ); | 199 | m_showQuickTaskAction->addTo( m_options ); |
200 | m_showQuickTaskAction->setOn( showQuickTask() ); | 200 | m_showQuickTaskAction->setOn( showQuickTask() ); |
201 | connect(m_showQuickTaskAction, SIGNAL( toggled(bool) ), this, SLOT(slotShowQuickTask(bool) ) ); | 201 | connect(m_showQuickTaskAction, SIGNAL( toggled(bool) ), this, SLOT(slotShowQuickTask(bool) ) ); |
202 | 202 | ||
203 | m_options->insertSeparator(); | 203 | m_options->insertSeparator(); |
204 | 204 | ||
205 | m_bar->insertItem( QWidget::tr("Data") ,m_edit ); | 205 | m_bar->insertItem( QWidget::tr("Data") ,m_edit ); |
206 | m_bar->insertItem( QWidget::tr("Category"), m_catMenu ); | 206 | m_bar->insertItem( QWidget::tr("Category"), m_catMenu ); |
207 | m_bar->insertItem( QWidget::tr("Options"), m_options ); | 207 | m_bar->insertItem( QWidget::tr("Options"), m_options ); |
208 | 208 | ||
209 | m_curQuick = new QuickEditImpl( this, m_quicktask ); | 209 | m_curQuick = new QuickEditImpl( this, m_quicktask ); |
210 | addToolBar( (QToolBar *)m_curQuick->widget(), QWidget::tr( "QuickEdit" ), QMainWindow::Top, TRUE ); | 210 | addToolBar( (QToolBar *)m_curQuick->widget(), QWidget::tr( "QuickEdit" ), QMainWindow::Top, TRUE ); |
211 | m_curQuick->signal()->connect( this, SLOT(slotQuickEntered() ) ); | 211 | m_curQuick->signal()->connect( this, SLOT(slotQuickEntered() ) ); |
212 | 212 | ||
213 | } | 213 | } |
214 | /* m_curCat from Config */ | 214 | /* m_curCat from Config */ |
215 | void MainWindow::initConfig() { | 215 | void MainWindow::initConfig() { |
216 | Config config( "todo" ); | 216 | Config config( "todo" ); |
217 | config.setGroup( "View" ); | 217 | config.setGroup( "View" ); |
218 | m_completed = config.readBoolEntry( "ShowComplete", TRUE ); | 218 | m_completed = config.readBoolEntry( "ShowComplete", TRUE ); |
219 | m_curCat = config.readEntry( "Category", QString::null ); | 219 | m_curCat = config.readEntry( "Category", QString::null ); |
220 | m_deadline = config.readBoolEntry( "ShowDeadLine", TRUE); | 220 | m_deadline = config.readBoolEntry( "ShowDeadLine", TRUE); |
221 | m_overdue = config.readBoolEntry("ShowOverDue", FALSE ); | 221 | m_overdue = config.readBoolEntry("ShowOverDue", FALSE ); |
222 | m_quicktask = config.readBoolEntry("ShowQuickTask", TRUE); | 222 | m_quicktask = config.readBoolEntry("ShowQuickTask", TRUE); |
223 | } | 223 | } |
224 | void MainWindow::initUI() { | 224 | void MainWindow::initUI() { |
225 | 225 | ||
226 | m_stack = new Opie::Ui::OWidgetStack(this, "main stack"); | 226 | m_stack = new Opie::Ui::OWidgetStack(this, "main stack"); |
227 | 227 | ||
228 | setCentralWidget( m_stack ); | 228 | setCentralWidget( m_stack ); |
229 | 229 | ||
230 | setToolBarsMovable( FALSE ); | 230 | setToolBarsMovable( FALSE ); |
231 | 231 | ||
232 | QToolBar *menubarholder = new QToolBar( this ); | 232 | QToolBar *menubarholder = new QToolBar( this ); |
233 | menubarholder->setHorizontalStretchable( TRUE ); | 233 | menubarholder->setHorizontalStretchable( TRUE ); |
234 | m_bar = new QMenuBar( menubarholder ); | 234 | m_bar = new QMenuBar( menubarholder ); |
235 | 235 | ||
236 | m_tool = new QToolBar( this ); | 236 | m_tool = new QToolBar( this ); |
237 | 237 | ||
238 | /** QPopupMenu */ | 238 | /** QPopupMenu */ |
239 | m_edit = new QPopupMenu( this ); | 239 | m_edit = new QPopupMenu( this ); |
240 | m_options = new QPopupMenu( this ); | 240 | m_options = new QPopupMenu( this ); |
241 | m_catMenu = new QPopupMenu( this ); | 241 | m_catMenu = new QPopupMenu( this ); |
242 | m_template = new QPopupMenu( this ); | 242 | m_template = new QPopupMenu( this ); |
243 | 243 | ||
244 | m_catMenu->setCheckable( TRUE ); | 244 | m_catMenu->setCheckable( TRUE ); |
245 | m_template->setCheckable( TRUE ); | 245 | m_template->setCheckable( TRUE ); |
246 | 246 | ||
247 | connect(m_catMenu, SIGNAL(activated(int) ), | 247 | connect(m_catMenu, SIGNAL(activated(int) ), |
248 | this, SLOT(setCategory(int) ) ); | 248 | this, SLOT(setCategory(int) ) ); |
249 | connect(m_template, SIGNAL(activated(int) ), | 249 | connect(m_template, SIGNAL(activated(int) ), |
250 | this, SLOT(slotNewFromTemplate(int) ) ); | 250 | this, SLOT(slotNewFromTemplate(int) ) ); |
251 | } | 251 | } |
252 | void MainWindow::initViews() { | 252 | void MainWindow::initViews() { |
253 | 253 | ||
254 | TableView* tableView = new TableView( this, m_stack ); | 254 | TableView* tableView = new TableView( this, m_stack ); |
255 | QWhatsThis::add( tableView, QWidget::tr( "This is a listing of all current tasks.\n\nThe list displays the following information:\n1. Completed - A green checkmark indicates task is completed. Click here to complete a task.\n2. Priority - a graphical representation of task priority. Double-click here to modify.\n3. Description - description of task. Click here to select the task.\n4. Deadline - shows when task is due. This column can be shown or hidden by selecting Options->'Show task deadlines' from the menu above." ) ); | 255 | 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." ) ); |
256 | m_stack->addWidget( tableView, m_counter++ ); | 256 | m_stack->addWidget( tableView, m_counter++ ); |
257 | m_views.append( tableView ); | 257 | m_views.append( tableView ); |
258 | m_curView = tableView; | 258 | m_curView = tableView; |
259 | connectBase( tableView ); | 259 | connectBase( tableView ); |
260 | /* add QString type + QString configname to | 260 | /* add QString type + QString configname to |
261 | * the View menu | 261 | * the View menu |
262 | * and subdirs for multiple views | 262 | * and subdirs for multiple views |
263 | */ | 263 | */ |
264 | } | 264 | } |
265 | void MainWindow::initEditor() { | 265 | void MainWindow::initEditor() { |
266 | m_curEdit = new Editor(); | 266 | m_curEdit = new Editor(); |
267 | } | 267 | } |
268 | void MainWindow::initShow() { | 268 | void MainWindow::initShow() { |
269 | m_curShow = new TextViewShow(this, this); | 269 | m_curShow = new TextViewShow(this, this); |
270 | m_stack->addWidget( m_curShow->widget() , m_counter++ ); | 270 | m_stack->addWidget( m_curShow->widget() , m_counter++ ); |
271 | } | 271 | } |
272 | MainWindow::~MainWindow() { | 272 | MainWindow::~MainWindow() { |
273 | delete templateManager(); | 273 | delete templateManager(); |
274 | } | 274 | } |
275 | void MainWindow::connectBase( ViewBase* ) { | 275 | void MainWindow::connectBase( ViewBase* ) { |
276 | // once templates and signals mix we'll use it again | 276 | // once templates and signals mix we'll use it again |
277 | } | 277 | } |
278 | QPopupMenu* MainWindow::contextMenu( int , bool recur ) { | 278 | QPopupMenu* MainWindow::contextMenu( int , bool recur ) { |
279 | QPopupMenu* menu = new QPopupMenu(); | 279 | QPopupMenu* menu = new QPopupMenu(); |
280 | 280 | ||
281 | m_editAction->addTo( menu ); | 281 | m_editAction->addTo( menu ); |
282 | m_deleteAction->addTo( menu ); | 282 | m_deleteAction->addTo( menu ); |
283 | m_duplicateAction->addTo( menu ); | 283 | m_duplicateAction->addTo( menu ); |
284 | 284 | ||
285 | menu->insertSeparator(); | 285 | menu->insertSeparator(); |
286 | 286 | ||
287 | /* | 287 | /* |
288 | * if this event recurs we allow | 288 | * if this event recurs we allow |
289 | * to detach it. | 289 | * to detach it. |
290 | * remove all | 290 | * remove all |
291 | */ | 291 | */ |
292 | if ( recur ) { | 292 | if ( recur ) { |
293 | ; // FIXME | 293 | ; // FIXME |
294 | } | 294 | } |
295 | 295 | ||
296 | return menu; | 296 | return menu; |
297 | } | 297 | } |
298 | QPopupMenu* MainWindow::options() { | 298 | QPopupMenu* MainWindow::options() { |
299 | owarn << "Options" << oendl; | 299 | owarn << "Options" << oendl; |
300 | return m_options; | 300 | return m_options; |
301 | } | 301 | } |
302 | QPopupMenu* MainWindow::edit() { | 302 | QPopupMenu* MainWindow::edit() { |
303 | return m_edit; | 303 | return m_edit; |
304 | } | 304 | } |
305 | QToolBar* MainWindow::toolbar() { | 305 | QToolBar* MainWindow::toolbar() { |
306 | return m_tool; | 306 | return m_tool; |
307 | } | 307 | } |
308 | OPimTodoAccess::List MainWindow::list()const { | 308 | OPimTodoAccess::List MainWindow::list()const { |
309 | return m_todoMgr.list(); | 309 | return m_todoMgr.list(); |
310 | } | 310 | } |
311 | OPimTodoAccess::List MainWindow::sorted( bool asc, int sortOrder ) { | 311 | OPimTodoAccess::List MainWindow::sorted( bool asc, int sortOrder ) { |
312 | int cat = 0; | 312 | int cat = 0; |
313 | if ( m_curCat != QWidget::tr("All Categories") ) | 313 | if ( m_curCat != QWidget::tr("All Categories") ) |
314 | cat = currentCatId(); | 314 | cat = currentCatId(); |
315 | if ( m_curCat == QWidget::tr("Unfiled") ) | 315 | if ( m_curCat == QWidget::tr("Unfiled") ) |
316 | cat = -1; | 316 | cat = -1; |
317 | 317 | ||
318 | owarn << " Category " << cat << " " << m_curCat << oendl; | 318 | owarn << " Category " << cat << " " << m_curCat << oendl; |
319 | 319 | ||
320 | int filter = 1; | 320 | int filter = 1; |
321 | 321 | ||
322 | if (!m_completed ) | 322 | if (!m_completed ) |
323 | filter |= 4; | 323 | filter |= 4; |
324 | if (m_overdue) | 324 | if (m_overdue) |
325 | filter |= 2; | 325 | filter |= 2; |
326 | 326 | ||
327 | return m_todoMgr.sorted( asc, sortOrder, filter, cat ); | 327 | return m_todoMgr.sorted( asc, sortOrder, filter, cat ); |
328 | } | 328 | } |
329 | OPimTodoAccess::List MainWindow::sorted( bool asc, int sortOrder, int addFilter) { | 329 | OPimTodoAccess::List MainWindow::sorted( bool asc, int sortOrder, int addFilter) { |
330 | int cat = 0; | 330 | int cat = 0; |
331 | if ( m_curCat != QWidget::tr("All Categories") ) | 331 | if ( m_curCat != QWidget::tr("All Categories") ) |
332 | cat = currentCatId(); | 332 | cat = currentCatId(); |
333 | 333 | ||
334 | if ( m_curCat == QWidget::tr("Unfiled") ) | 334 | if ( m_curCat == QWidget::tr("Unfiled") ) |
335 | cat = -1; | 335 | cat = -1; |
336 | 336 | ||
337 | return m_todoMgr.sorted(asc, sortOrder, addFilter, cat ); | 337 | return m_todoMgr.sorted(asc, sortOrder, addFilter, cat ); |
338 | } | 338 | } |
339 | OPimTodo MainWindow::event( int uid ) { | 339 | OPimTodo MainWindow::event( int uid ) { |
340 | return m_todoMgr.event( uid ); | 340 | return m_todoMgr.event( uid ); |
341 | } | 341 | } |
342 | bool MainWindow::isSyncing()const { | 342 | bool MainWindow::isSyncing()const { |
343 | return m_syncing; | 343 | return m_syncing; |
344 | } | 344 | } |
345 | TemplateManager* MainWindow::templateManager() { | 345 | TemplateManager* MainWindow::templateManager() { |
346 | return m_tempManager; | 346 | return m_tempManager; |
347 | } | 347 | } |
348 | Editor* MainWindow::currentEditor() { | 348 | Editor* MainWindow::currentEditor() { |
349 | return m_curEdit; | 349 | return m_curEdit; |
350 | } | 350 | } |
351 | TodoShow* MainWindow::currentShow() { | 351 | TodoShow* MainWindow::currentShow() { |
352 | return m_curShow; | 352 | return m_curShow; |
353 | } | 353 | } |
354 | void MainWindow::slotReload() { | 354 | void MainWindow::slotReload() { |
355 | m_syncing = FALSE; | 355 | m_syncing = FALSE; |
356 | m_todoMgr.reload(); | 356 | m_todoMgr.reload(); |
357 | currentView()->updateView( ); | 357 | currentView()->updateView( ); |
358 | raiseCurrentView(); | 358 | raiseCurrentView(); |
359 | } | 359 | } |
360 | void MainWindow::closeEvent( QCloseEvent* e ) { | 360 | void MainWindow::closeEvent( QCloseEvent* e ) { |
361 | if (m_stack->visibleWidget() == currentShow()->widget() ) { | 361 | if (m_stack->visibleWidget() == currentShow()->widget() ) { |
362 | m_showing = false; | 362 | m_showing = false; |
363 | raiseCurrentView(); | 363 | raiseCurrentView(); |
364 | e->ignore(); | 364 | e->ignore(); |
365 | return; | 365 | return; |
366 | } | 366 | } |
367 | /* | 367 | /* |
368 | * we should have flushed and now we're still saving | 368 | * we should have flushed and now we're still saving |
369 | * so there is no need to flush | 369 | * so there is no need to flush |
370 | */ | 370 | */ |
371 | if (m_syncing ) { | 371 | if (m_syncing ) { |
372 | e->accept(); | 372 | e->accept(); |
373 | return; | 373 | return; |
374 | } | 374 | } |
375 | bool quit = false; | 375 | bool quit = false; |
376 | if ( m_todoMgr.saveAll() ){ | 376 | if ( m_todoMgr.saveAll() ){ |
377 | owarn << "saved" << oendl; | 377 | owarn << "saved" << oendl; |
378 | quit = true; | 378 | quit = true; |
379 | }else { | 379 | }else { |
380 | if ( QMessageBox::critical( this, QWidget::tr("Out of space"), | 380 | if ( QMessageBox::critical( this, QWidget::tr("Out of space"), |
381 | QWidget::tr("Todo was unable\n" | 381 | QWidget::tr("Todo was unable\n" |
382 | "to save your changes.\n" | 382 | "to save your changes.\n" |
383 | "Free up some space\n" | 383 | "Free up some space\n" |
384 | "and try again.\n" | 384 | "and try again.\n" |
385 | "\nQuit Anyway?"), | 385 | "\nQuit Anyway?"), |
386 | QMessageBox::Yes|QMessageBox::Escape, | 386 | QMessageBox::Yes|QMessageBox::Escape, |
387 | QMessageBox::No|QMessageBox::Default) | 387 | QMessageBox::No|QMessageBox::Default) |
388 | != QMessageBox::No ) { | 388 | != QMessageBox::No ) { |
389 | e->accept(); | 389 | e->accept(); |
390 | quit = true; | 390 | quit = true; |
391 | }else | 391 | }else |
392 | e->ignore(); | 392 | e->ignore(); |
393 | 393 | ||
394 | } | 394 | } |
395 | 395 | ||
396 | if (quit ) { | 396 | if (quit ) { |
397 | Config config( "todo" ); | 397 | Config config( "todo" ); |
398 | config.setGroup( "View" ); | 398 | config.setGroup( "View" ); |
399 | config.writeEntry( "ShowComplete", showCompleted() ); | 399 | config.writeEntry( "ShowComplete", showCompleted() ); |
400 | config.writeEntry( "Category", currentCategory() ); | 400 | config.writeEntry( "Category", currentCategory() ); |
401 | config.writeEntry( "ShowDeadLine", showDeadline()); | 401 | config.writeEntry( "ShowDeadLine", showDeadline()); |
402 | config.writeEntry( "ShowOverDue", showOverDue() ); | 402 | config.writeEntry( "ShowOverDue", showOverDue() ); |
403 | config.writeEntry( "ShowQuickTask", showQuickTask() ); | 403 | config.writeEntry( "ShowQuickTask", showQuickTask() ); |
404 | /* save templates */ | 404 | /* save templates */ |
405 | templateManager()->save(); | 405 | templateManager()->save(); |
406 | e->accept(); | 406 | e->accept(); |
407 | QTimer::singleShot(0, qApp, SLOT(closeAllWindows()) ); | 407 | QTimer::singleShot(0, qApp, SLOT(closeAllWindows()) ); |
408 | } | 408 | } |
409 | } | 409 | } |
410 | void MainWindow::populateTemplates() { | 410 | void MainWindow::populateTemplates() { |
411 | m_template->clear(); | 411 | m_template->clear(); |
412 | QStringList list = templateManager()->templates(); | 412 | QStringList list = templateManager()->templates(); |
413 | QStringList::Iterator it; | 413 | QStringList::Iterator it; |
414 | for ( it = list.begin(); it != list.end(); ++it ) { | 414 | for ( it = list.begin(); it != list.end(); ++it ) { |
415 | m_template->insertItem( (*it) ); | 415 | m_template->insertItem( (*it) ); |
416 | } | 416 | } |
417 | } | 417 | } |
418 | /* | 418 | /* |
419 | * slotNewFromTemplate | 419 | * slotNewFromTemplate |
420 | * We use the edit widget to do | 420 | * We use the edit widget to do |
421 | * the config but we setUid(1) | 421 | * the config but we setUid(1) |
422 | * to get a new uid | 422 | * to get a new uid |
423 | */ | 423 | */ |
424 | /* | 424 | /* |
425 | * first we get the name of the template | 425 | * first we get the name of the template |
426 | * then we will use the TemplateManager | 426 | * then we will use the TemplateManager |
427 | */ | 427 | */ |
428 | void MainWindow::slotNewFromTemplate( int id ) { | 428 | void MainWindow::slotNewFromTemplate( int id ) { |
429 | QString name = m_template->text( id ); | 429 | QString name = m_template->text( id ); |
430 | 430 | ||
431 | OPimTodo event = templateManager()->templateEvent( name ); | 431 | OPimTodo event = templateManager()->templateEvent( name ); |
432 | event = currentEditor()->edit(this, | 432 | event = currentEditor()->edit(this, |
433 | event ); | 433 | event ); |
434 | 434 | ||
435 | if ( currentEditor()->accepted() ) { | 435 | if ( currentEditor()->accepted() ) { |
436 | /* assign new todo */ | 436 | /* assign new todo */ |
437 | event.setUid( 1 ); | 437 | event.setUid( 1 ); |
438 | handleAlarms( OPimTodo(), event ); | 438 | handleAlarms( OPimTodo(), event ); |
439 | m_todoMgr.add( event ); | 439 | m_todoMgr.add( event ); |
440 | currentView()->addEvent( event ); | 440 | currentView()->addEvent( event ); |
441 | 441 | ||
442 | populateCategories(); | 442 | populateCategories(); |
443 | } | 443 | } |
444 | raiseCurrentView(); | 444 | raiseCurrentView(); |
445 | } | 445 | } |
446 | void MainWindow::slotNew() { | 446 | void MainWindow::slotNew() { |
447 | create(); | 447 | create(); |
448 | } | 448 | } |
449 | void MainWindow::slotDuplicate() { | 449 | void MainWindow::slotDuplicate() { |
450 | if(m_syncing) { | 450 | if(m_syncing) { |
451 | QMessageBox::warning(this, QWidget::tr("Todo"), | 451 | QMessageBox::warning(this, QWidget::tr("Todo"), |
452 | QWidget::tr("Data can not be edited, currently syncing")); | 452 | QWidget::tr("Data can not be edited, currently syncing")); |
453 | return; | 453 | return; |
454 | } | 454 | } |
455 | OPimTodo ev = m_todoMgr.event( currentView()->current() ); | 455 | OPimTodo ev = m_todoMgr.event( currentView()->current() ); |
456 | /* let's generate a new uid */ | 456 | /* let's generate a new uid */ |
457 | ev.setUid(1); | 457 | ev.setUid(1); |
458 | m_todoMgr.add( ev ); | 458 | m_todoMgr.add( ev ); |
459 | 459 | ||
460 | currentView()->addEvent( ev ); | 460 | currentView()->addEvent( ev ); |
461 | raiseCurrentView(); | 461 | raiseCurrentView(); |
462 | } | 462 | } |
463 | void MainWindow::slotDelete() { | 463 | void MainWindow::slotDelete() { |
464 | if (!currentView()->current() ) | 464 | if (!currentView()->current() ) |
465 | return; | 465 | return; |
466 | 466 | ||
467 | if(m_syncing) { | 467 | if(m_syncing) { |
468 | QMessageBox::warning(this, QWidget::tr("Todo"), | 468 | QMessageBox::warning(this, QWidget::tr("Todo"), |
469 | QWidget::tr("Data can not be edited, currently syncing")); | 469 | QWidget::tr("Data can not be edited, currently syncing")); |
470 | return; | 470 | return; |
471 | } | 471 | } |
472 | QString strName = currentView()->currentRepresentation(); | 472 | QString strName = currentView()->currentRepresentation(); |
473 | if (!QPEMessageBox::confirmDelete(this, QWidget::tr("Todo"), strName ) ) | 473 | if (!QPEMessageBox::confirmDelete(this, QWidget::tr("Todo"), strName ) ) |
474 | return; | 474 | return; |
475 | 475 | ||
476 | handleAlarms( m_todoMgr.event( currentView()->current() ), OPimTodo() ); | 476 | handleAlarms( m_todoMgr.event( currentView()->current() ), OPimTodo() ); |
477 | m_todoMgr.remove( currentView()->current() ); | 477 | m_todoMgr.remove( currentView()->current() ); |
478 | currentView()->removeEvent( currentView()->current() ); | 478 | currentView()->removeEvent( currentView()->current() ); |
479 | raiseCurrentView(); | 479 | raiseCurrentView(); |
480 | } | 480 | } |
481 | void MainWindow::slotDelete(int uid ) { | 481 | void MainWindow::slotDelete(int uid ) { |
482 | if( uid == 0 ) return; | 482 | if( uid == 0 ) return; |
483 | if(m_syncing) { | 483 | if(m_syncing) { |
484 | QMessageBox::warning(this, QWidget::tr("Todo"), | 484 | QMessageBox::warning(this, QWidget::tr("Todo"), |
485 | QWidget::tr("Data can not be edited, currently syncing")); | 485 | QWidget::tr("Data can not be edited, currently syncing")); |
486 | return; | 486 | return; |
487 | } | 487 | } |
488 | OPimTodo to = m_todoMgr.event(uid); | 488 | OPimTodo to = m_todoMgr.event(uid); |
489 | if (!QPEMessageBox::confirmDelete(this, QWidget::tr("Todo"), to.toShortText() ) ) | 489 | if (!QPEMessageBox::confirmDelete(this, QWidget::tr("Todo"), to.toShortText() ) ) |
490 | return; | 490 | return; |
491 | 491 | ||
492 | handleAlarms(to, OPimTodo() ); | 492 | handleAlarms(to, OPimTodo() ); |
493 | m_todoMgr.remove( to.uid() ); | 493 | m_todoMgr.remove( to.uid() ); |
494 | currentView()->removeEvent( to.uid() ); | 494 | currentView()->removeEvent( to.uid() ); |
495 | raiseCurrentView(); | 495 | raiseCurrentView(); |
496 | } | 496 | } |
497 | void MainWindow::slotDeleteAll() { | 497 | void MainWindow::slotDeleteAll() { |
498 | if(m_syncing) { | 498 | if(m_syncing) { |
499 | QMessageBox::warning(this, QWidget::tr("Todo"), | 499 | QMessageBox::warning(this, QWidget::tr("Todo"), |
500 | QWidget::tr("Data can not be edited, currently syncing")); | 500 | QWidget::tr("Data can not be edited, currently syncing")); |
501 | return; | 501 | return; |
502 | } | 502 | } |
503 | 503 | ||
504 | 504 | ||
505 | if ( !QPEMessageBox::confirmDelete( this, QWidget::tr( "Todo" ), QWidget::tr("all tasks?") ) ) | 505 | if ( !QPEMessageBox::confirmDelete( this, QWidget::tr( "Todo" ), QWidget::tr("all tasks?") ) ) |
506 | return; | 506 | return; |
507 | 507 | ||
508 | m_todoMgr.removeAll(); | 508 | m_todoMgr.removeAll(); |
509 | currentView()->clear(); | 509 | currentView()->clear(); |
510 | 510 | ||
511 | raiseCurrentView(); | 511 | raiseCurrentView(); |
512 | } | 512 | } |
513 | void MainWindow::slotDeleteCompleted() { | 513 | void MainWindow::slotDeleteCompleted() { |
514 | if(m_syncing) { | 514 | if(m_syncing) { |
515 | QMessageBox::warning(this, QWidget::tr("Todo"), | 515 | QMessageBox::warning(this, QWidget::tr("Todo"), |
516 | QWidget::tr("Data can not be edited, currently syncing")); | 516 | QWidget::tr("Data can not be edited, currently syncing")); |
517 | return; | 517 | return; |
518 | } | 518 | } |
519 | 519 | ||
520 | if ( !QPEMessageBox::confirmDelete( this, QWidget::tr( "Todo" ), QWidget::tr("all completed tasks?") ) ) | 520 | if ( !QPEMessageBox::confirmDelete( this, QWidget::tr( "Todo" ), QWidget::tr("all completed tasks?") ) ) |
521 | return; | 521 | return; |
522 | 522 | ||
523 | 523 | ||
524 | m_todoMgr.removeCompleted(); | 524 | m_todoMgr.removeCompleted(); |
525 | currentView()->updateView( ); | 525 | currentView()->updateView( ); |
526 | } | 526 | } |
527 | void MainWindow::slotFind() { | 527 | void MainWindow::slotFind() { |
528 | 528 | ||
529 | } | 529 | } |
530 | void MainWindow::slotEdit() { | 530 | void MainWindow::slotEdit() { |
531 | slotEdit( currentView()->current() ); | 531 | slotEdit( currentView()->current() ); |
532 | } | 532 | } |
533 | /* | 533 | /* |
534 | * set the category | 534 | * set the category |
535 | */ | 535 | */ |
536 | void MainWindow::setCategory( int c) { | 536 | void MainWindow::setCategory( int c) { |
537 | if ( c <= 0 ) return; | 537 | if ( c <= 0 ) return; |
538 | 538 | ||
539 | 539 | ||
540 | owarn << "Iterating over cats " << c << oendl; | 540 | owarn << "Iterating over cats " << c << oendl; |
541 | for ( unsigned int i = 1; i < m_catMenu->count(); i++ ) | 541 | for ( unsigned int i = 1; i < m_catMenu->count(); i++ ) |
542 | m_catMenu->setItemChecked(i, c == (int)i ); | 542 | m_catMenu->setItemChecked(i, c == (int)i ); |
543 | 543 | ||
544 | if (c == 1 ) { | 544 | if (c == 1 ) { |
545 | m_curCat = QString::null; | 545 | m_curCat = QString::null; |
546 | setCaption( QWidget::tr("Todo") + " - " + QWidget::tr("All Categories" ) ); | 546 | setCaption( QWidget::tr("Todo") + " - " + QWidget::tr("All Categories" ) ); |
547 | 547 | ||
548 | }else if ( c == (int)m_catMenu->count() - 1 ) { | 548 | }else if ( c == (int)m_catMenu->count() - 1 ) { |
549 | m_curCat = QWidget::tr("Unfiled"); | 549 | m_curCat = QWidget::tr("Unfiled"); |
550 | setCaption( QWidget::tr("Todo") + " - " + QWidget::tr("Unfiled") ); | 550 | setCaption( QWidget::tr("Todo") + " - " + QWidget::tr("Unfiled") ); |
551 | }else { | 551 | }else { |
552 | m_curCat = m_todoMgr.categories()[c-2]; | 552 | m_curCat = m_todoMgr.categories()[c-2]; |
553 | setCaption( QWidget::tr("Todo") + " - " + m_curCat ); | 553 | setCaption( QWidget::tr("Todo") + " - " + m_curCat ); |
554 | } | 554 | } |
555 | m_catMenu->setItemChecked( c, true ); | 555 | m_catMenu->setItemChecked( c, true ); |
556 | 556 | ||
557 | currentView()->setShowCategory( m_curCat ); | 557 | currentView()->setShowCategory( m_curCat ); |
558 | raiseCurrentView(); | 558 | raiseCurrentView(); |
559 | } | 559 | } |
560 | void MainWindow::slotShowDeadLine( bool dead) { | 560 | void MainWindow::slotShowDeadLine( bool dead) { |
561 | m_deadline = dead; | 561 | m_deadline = dead; |
562 | currentView()->setShowDeadline( dead ); | 562 | currentView()->setShowDeadline( dead ); |
563 | } | 563 | } |
564 | void MainWindow::slotShowCompleted( bool show) { | 564 | void MainWindow::slotShowCompleted( bool show) { |
565 | m_completed = show; | 565 | m_completed = show; |
566 | currentView()->setShowCompleted( m_completed ); | 566 | currentView()->setShowCompleted( m_completed ); |
567 | } | 567 | } |
568 | void MainWindow::slotShowQuickTask( bool show ) { | 568 | void MainWindow::slotShowQuickTask( bool show ) { |
569 | m_quicktask = show; | 569 | m_quicktask = show; |
570 | if ( m_quicktask ) | 570 | if ( m_quicktask ) |
571 | m_curQuick->widget()->show(); | 571 | m_curQuick->widget()->show(); |
572 | else | 572 | else |
573 | m_curQuick->widget()->hide(); | 573 | m_curQuick->widget()->hide(); |
574 | } | 574 | } |
575 | bool MainWindow::showOverDue()const { | 575 | bool MainWindow::showOverDue()const { |
576 | return m_overdue; | 576 | return m_overdue; |
577 | } | 577 | } |
578 | void MainWindow::setDocument( const QString& fi) { | 578 | void MainWindow::setDocument( const QString& fi) { |
579 | DocLnk doc(fi); | 579 | DocLnk doc(fi); |
580 | if (doc.isValid() ) | 580 | if (doc.isValid() ) |
581 | receiveFile(doc.file() ); | 581 | receiveFile(doc.file() ); |
582 | else | 582 | else |
583 | receiveFile(fi ); | 583 | receiveFile(fi ); |
584 | } | 584 | } |
585 | 585 | ||
586 | static const char *beamfile = "/tmp/opie-todo.vcs"; | 586 | static const char *beamfile = "/tmp/opie-todo.vcs"; |
587 | void MainWindow::slotBeam() { | 587 | void MainWindow::slotBeam() { |
588 | beam( currentView()->current() ); | 588 | beam( currentView()->current() ); |
589 | } | 589 | } |
590 | void MainWindow::beamDone( Ir* ir) { | 590 | void MainWindow::beamDone( Ir* ir) { |
591 | delete ir; | 591 | delete ir; |
592 | ::unlink( beamfile ); | 592 | ::unlink( beamfile ); |
593 | } | 593 | } |
594 | void MainWindow::receiveFile( const QString& filename ) { | 594 | void MainWindow::receiveFile( const QString& filename ) { |
595 | OPimTodoAccessVCal* cal = new OPimTodoAccessVCal(filename ); | 595 | OPimTodoAccessVCal* cal = new OPimTodoAccessVCal(filename ); |
596 | 596 | ||
597 | OPimTodoAccess acc( cal ); | 597 | OPimTodoAccess acc( cal ); |
598 | acc.load(); | 598 | acc.load(); |
599 | OPimTodoAccess::List list = acc.allRecords(); | 599 | OPimTodoAccess::List list = acc.allRecords(); |
600 | 600 | ||
601 | if (list.count()){ | 601 | if (list.count()){ |
602 | 602 | ||
603 | QString message = QWidget::tr("<P>%1 new tasks arrived.<p>Would you like to add them to your Todolist?").arg(list.count() ); | 603 | QString message = QWidget::tr("<P>%1 new tasks arrived.<p>Would you like to add them to your Todolist?").arg(list.count() ); |
604 | 604 | ||
605 | if ( QMessageBox::information(this, QWidget::tr("New Tasks"), | 605 | if ( QMessageBox::information(this, QWidget::tr("New Tasks"), |
606 | message, QMessageBox::Ok, | 606 | message, QMessageBox::Ok, |
607 | QMessageBox::Cancel ) == QMessageBox::Ok ) { | 607 | QMessageBox::Cancel ) == QMessageBox::Ok ) { |
608 | OPimTodoAccess::List::Iterator it; | 608 | OPimTodoAccess::List::Iterator it; |
609 | for ( it = list.begin(); it != list.end(); ++it ) | 609 | for ( it = list.begin(); it != list.end(); ++it ) |
610 | m_todoMgr.add( (*it) ); | 610 | m_todoMgr.add( (*it) ); |
611 | 611 | ||
612 | currentView()->updateView(); | 612 | currentView()->updateView(); |
613 | } | 613 | } |
614 | } | 614 | } |
615 | } | 615 | } |
616 | 616 | ||
617 | void MainWindow::slotFlush() { | 617 | void MainWindow::slotFlush() { |
618 | m_syncing = TRUE; | 618 | m_syncing = TRUE; |
619 | m_todoMgr.save(); | 619 | m_todoMgr.save(); |
620 | } | 620 | } |
621 | void MainWindow::slotShowDetails() { | 621 | void MainWindow::slotShowDetails() { |
622 | slotShow( currentView()->current() ); | 622 | slotShow( currentView()->current() ); |
623 | } | 623 | } |
624 | /* | 624 | /* |
625 | * populate the Categories | 625 | * populate the Categories |
626 | * Menu | 626 | * Menu |
627 | */ | 627 | */ |
628 | void MainWindow::populateCategories() { | 628 | void MainWindow::populateCategories() { |
629 | m_todoMgr.load(); | 629 | m_todoMgr.load(); |
630 | 630 | ||
631 | m_catMenu->clear(); | 631 | m_catMenu->clear(); |
632 | int id, rememberId; | 632 | int id, rememberId; |
633 | id = 1; | 633 | id = 1; |
634 | rememberId = 1; | 634 | rememberId = 1; |
635 | 635 | ||
636 | m_catMenu->insertItem( QWidget::tr( "All Categories" ), id++ ); | 636 | m_catMenu->insertItem( QWidget::tr( "All Categories" ), id++ ); |
637 | m_catMenu->insertSeparator(); | 637 | m_catMenu->insertSeparator(); |
638 | QStringList categories = m_todoMgr.categories(); | 638 | QStringList categories = m_todoMgr.categories(); |
639 | categories.append( QWidget::tr( "Unfiled" ) ); | 639 | categories.append( QWidget::tr( "Unfiled" ) ); |
640 | for ( QStringList::Iterator it = categories.begin(); | 640 | for ( QStringList::Iterator it = categories.begin(); |
641 | it != categories.end(); ++it ) { | 641 | it != categories.end(); ++it ) { |
642 | m_catMenu->insertItem( *it, id ); | 642 | m_catMenu->insertItem( *it, id ); |
643 | if ( *it == currentCategory() ) | 643 | if ( *it == currentCategory() ) |
644 | rememberId = id; | 644 | rememberId = id; |
645 | ++id; | 645 | ++id; |
646 | } | 646 | } |
647 | setCategory( rememberId ); | 647 | setCategory( rememberId ); |
648 | } | 648 | } |
649 | bool MainWindow::showCompleted()const { | 649 | bool MainWindow::showCompleted()const { |
650 | return m_completed; | 650 | return m_completed; |
651 | } | 651 | } |
652 | bool MainWindow::showDeadline()const { | 652 | bool MainWindow::showDeadline()const { |
653 | return m_deadline; | 653 | return m_deadline; |
654 | } | 654 | } |
655 | bool MainWindow::showQuickTask()const { | 655 | bool MainWindow::showQuickTask()const { |
656 | return m_quicktask; | 656 | return m_quicktask; |
657 | } | 657 | } |
658 | QString MainWindow::currentCategory()const { | 658 | QString MainWindow::currentCategory()const { |
659 | return m_curCat; | 659 | return m_curCat; |
660 | } | 660 | } |
661 | int MainWindow::currentCatId() { | 661 | int MainWindow::currentCatId() { |
662 | return m_todoMgr.catId( m_curCat ); | 662 | return m_todoMgr.catId( m_curCat ); |
663 | } | 663 | } |
664 | ViewBase* MainWindow::currentView() { | 664 | ViewBase* MainWindow::currentView() { |
665 | return m_curView; | 665 | return m_curView; |
666 | } | 666 | } |
667 | void MainWindow::raiseCurrentView() { | 667 | void MainWindow::raiseCurrentView() { |
668 | // due QPE/Application/todolist show(int) | 668 | // due QPE/Application/todolist show(int) |
669 | // we might not have the populateCategories slot called once | 669 | // we might not have the populateCategories slot called once |
670 | // we would show the otodo but then imediately switch to the currentView | 670 | // we would show the otodo but then imediately switch to the currentView |
671 | // if we're initially showing we shouldn't raise the table | 671 | // if we're initially showing we shouldn't raise the table |
672 | // in returnFromView we fix up m_showing | 672 | // in returnFromView we fix up m_showing |
673 | if (m_showing ) return; | 673 | if (m_showing ) return; |
674 | 674 | ||
675 | m_stack->raiseWidget( m_curView->widget() ); | 675 | m_stack->raiseWidget( m_curView->widget() ); |
676 | } | 676 | } |
677 | void MainWindow::slotShowDue(bool ov) { | 677 | void MainWindow::slotShowDue(bool ov) { |
678 | m_overdue = ov; | 678 | m_overdue = ov; |
679 | currentView()->showOverDue( ov ); | 679 | currentView()->showOverDue( ov ); |
680 | raiseCurrentView(); | 680 | raiseCurrentView(); |
681 | } | 681 | } |
682 | void MainWindow::slotShow( int uid ) { | 682 | void MainWindow::slotShow( int uid ) { |
683 | if ( uid == 0 ) return; | 683 | if ( uid == 0 ) return; |
684 | 684 | ||
685 | 685 | ||
686 | owarn << "slotShow" << oendl; | 686 | owarn << "slotShow" << oendl; |
687 | currentShow()->slotShow( event( uid ) ); | 687 | currentShow()->slotShow( event( uid ) ); |
688 | m_stack->raiseWidget( currentShow()->widget() ); | 688 | m_stack->raiseWidget( currentShow()->widget() ); |
689 | } | 689 | } |
690 | void MainWindow::slotShowNext() { | 690 | void MainWindow::slotShowNext() { |
691 | int l = currentView()->next(); | 691 | int l = currentView()->next(); |
692 | if (l!=0) | 692 | if (l!=0) |
693 | slotShow(l); | 693 | slotShow(l); |
694 | } | 694 | } |
695 | void MainWindow::slotShowPrev() { | 695 | void MainWindow::slotShowPrev() { |
696 | int l = currentView()->prev(); | 696 | int l = currentView()->prev(); |
697 | if (l!=0) | 697 | if (l!=0) |
698 | slotShow(l); | 698 | slotShow(l); |
699 | } | 699 | } |
700 | void MainWindow::slotEdit( int uid ) { | 700 | void MainWindow::slotEdit( int uid ) { |
701 | if (uid == 0 ) return; | 701 | if (uid == 0 ) return; |
702 | if(m_syncing) { | 702 | if(m_syncing) { |
703 | QMessageBox::warning(this, QWidget::tr("Todo"), | 703 | QMessageBox::warning(this, QWidget::tr("Todo"), |
704 | QWidget::tr("Data can't be edited, currently syncing")); | 704 | QWidget::tr("Data can't be edited, currently syncing")); |
705 | return; | 705 | return; |
706 | } | 706 | } |
707 | 707 | ||
708 | OPimTodo old_todo = m_todoMgr.event( uid ); | 708 | OPimTodo old_todo = m_todoMgr.event( uid ); |
709 | 709 | ||
710 | OPimTodo todo = currentEditor()->edit(this, old_todo ); | 710 | OPimTodo todo = currentEditor()->edit(this, old_todo ); |
711 | 711 | ||
712 | /* if completed */ | 712 | /* if completed */ |
713 | if ( currentEditor()->accepted() ) { | 713 | if ( currentEditor()->accepted() ) { |
714 | handleAlarms( old_todo, todo ); | 714 | handleAlarms( old_todo, todo ); |
715 | m_todoMgr.update( todo.uid(), todo ); | 715 | m_todoMgr.update( todo.uid(), todo ); |
716 | currentView()->replaceEvent( todo ); | 716 | currentView()->replaceEvent( todo ); |
717 | /* a Category might have changed */ | 717 | /* a Category might have changed */ |
718 | populateCategories(); | 718 | populateCategories(); |
719 | } | 719 | } |
720 | 720 | ||
721 | raiseCurrentView(); | 721 | raiseCurrentView(); |
722 | } | 722 | } |
723 | /* | 723 | /* |
724 | void MainWindow::slotUpdate1( int uid, const SmallTodo& ev) { | 724 | void MainWindow::slotUpdate1( int uid, const SmallTodo& ev) { |
725 | m_todoMgr.update( uid, ev ); | 725 | m_todoMgr.update( uid, ev ); |
726 | } | 726 | } |
727 | */ | 727 | */ |
728 | void MainWindow::updateTodo( const OPimTodo& ev) { | 728 | void MainWindow::updateTodo( const OPimTodo& ev) { |
729 | m_todoMgr.update( ev.uid() , ev ); | 729 | m_todoMgr.update( ev.uid() , ev ); |
730 | } | 730 | } |
731 | /* The view changed it's configuration | 731 | /* The view changed it's configuration |
732 | * update the view menu | 732 | * update the view menu |
733 | */ | 733 | */ |
734 | void MainWindow::slotUpdate3( QWidget* ) { | 734 | void MainWindow::slotUpdate3( QWidget* ) { |
735 | 735 | ||
736 | } | 736 | } |
737 | void MainWindow::updateList() { | 737 | void MainWindow::updateList() { |
738 | m_todoMgr.updateList(); | 738 | m_todoMgr.updateList(); |
739 | } | 739 | } |
740 | void MainWindow::setReadAhead( uint count ) { | 740 | void MainWindow::setReadAhead( uint count ) { |
741 | if (m_todoMgr.todoDB() ) | 741 | if (m_todoMgr.todoDB() ) |
742 | m_todoMgr.todoDB()->setReadAhead( count ); | 742 | m_todoMgr.todoDB()->setReadAhead( count ); |
743 | } | 743 | } |
744 | void MainWindow::slotQuickEntered() { | 744 | void MainWindow::slotQuickEntered() { |
745 | owarn << "entered" << oendl; | 745 | owarn << "entered" << oendl; |
746 | OPimTodo todo = quickEditor()->todo(); | 746 | OPimTodo todo = quickEditor()->todo(); |
747 | if (todo.isEmpty() ) | 747 | if (todo.isEmpty() ) |
748 | return; | 748 | return; |
749 | 749 | ||
750 | m_todoMgr.add( todo ); | 750 | m_todoMgr.add( todo ); |
751 | currentView()->addEvent( todo ); | 751 | currentView()->addEvent( todo ); |
752 | raiseCurrentView(); | 752 | raiseCurrentView(); |
753 | } | 753 | } |
754 | QuickEditBase* MainWindow::quickEditor() { | 754 | QuickEditBase* MainWindow::quickEditor() { |
755 | return m_curQuick; | 755 | return m_curQuick; |
756 | } | 756 | } |
757 | void MainWindow::slotComplete( int uid ) { | 757 | void MainWindow::slotComplete( int uid ) { |
758 | slotComplete( event(uid) ); | 758 | slotComplete( event(uid) ); |
759 | } | 759 | } |
760 | void MainWindow::slotComplete( const OPimTodo& todo ) { | 760 | void MainWindow::slotComplete( const OPimTodo& todo ) { |
761 | OPimTodo to = todo; | 761 | OPimTodo to = todo; |
762 | to.setCompleted( !to.isCompleted() ); | 762 | to.setCompleted( !to.isCompleted() ); |
763 | to.setCompletedDate( QDate::currentDate() ); | 763 | to.setCompletedDate( QDate::currentDate() ); |
764 | 764 | ||
765 | /* | 765 | /* |
766 | * if the item does recur | 766 | * if the item does recur |
767 | * we need to spin it off | 767 | * we need to spin it off |
768 | * and update the items duedate to the next | 768 | * and update the items duedate to the next |
769 | * possible recurrance of this item... | 769 | * possible recurrance of this item... |
770 | * the spinned off one will loose the | 770 | * the spinned off one will loose the |
771 | * recurrence. | 771 | * recurrence. |
772 | * We calculate the difference between the old due date and the | 772 | * We calculate the difference between the old due date and the |
773 | * new one and add this diff to start, completed and alarm dates | 773 | * new one and add this diff to start, completed and alarm dates |
774 | * -zecke | 774 | * -zecke |
775 | */ | 775 | */ |
776 | if ( to.hasRecurrence() && to.isCompleted() ) { | 776 | if ( to.hasRecurrence() && to.isCompleted() ) { |
777 | OPimTodo to2( to ); | 777 | OPimTodo to2( to ); |
778 | 778 | ||
779 | /* the spinned off one won't recur anymore */ | 779 | /* the spinned off one won't recur anymore */ |
780 | to.setRecurrence( OPimRecurrence() ); | 780 | to.setRecurrence( OPimRecurrence() ); |
781 | 781 | ||
782 | OPimRecurrence rec = to2.recurrence(); | 782 | OPimRecurrence rec = to2.recurrence(); |
783 | rec.setStart( to.dueDate() ); | 783 | rec.setStart( to.dueDate() ); |
784 | to2.setRecurrence( rec ); | 784 | to2.setRecurrence( rec ); |
785 | /* | 785 | /* |
786 | * if there is a next occurence | 786 | * if there is a next occurence |
787 | * from the duedate of the last recurrance | 787 | * from the duedate of the last recurrance |
788 | */ | 788 | */ |
789 | QDate date; | 789 | QDate date; |
790 | if ( to2.recurrence().nextOcurrence( to2.dueDate().addDays(1), date ) ) { | 790 | if ( to2.recurrence().nextOcurrence( to2.dueDate().addDays(1), date ) ) { |
791 | int dayDiff = to.dueDate().daysTo( date ); | 791 | int dayDiff = to.dueDate().daysTo( date ); |
792 | owarn << "day diff is " << dayDiff << oendl; | 792 | owarn << "day diff is " << dayDiff << oendl; |
793 | QDate inval; | 793 | QDate inval; |
794 | /* generate a new uid for the old record */ | 794 | /* generate a new uid for the old record */ |
795 | to.setUid( 1 ); | 795 | to.setUid( 1 ); |
796 | 796 | ||
797 | /* add the old one cause it has a new UID here cause it was spin off */ | 797 | /* add the old one cause it has a new UID here cause it was spin off */ |
798 | m_todoMgr.add( to ); | 798 | m_todoMgr.add( to ); |
799 | 799 | ||
800 | /* | 800 | /* |
801 | * update the due date | 801 | * update the due date |
802 | * start date | 802 | * start date |
803 | * and complete date | 803 | * and complete date |
804 | */ | 804 | */ |
805 | to2.setDueDate( date ); | 805 | to2.setDueDate( date ); |
806 | rec.setStart( date ); | 806 | rec.setStart( date ); |
807 | to2.setRecurrence( rec ); // could be Monday, TuesDay, Thursday every week | 807 | to2.setRecurrence( rec ); // could be Monday, TuesDay, Thursday every week |
808 | 808 | ||
809 | /* move start date */ | 809 | /* move start date */ |
810 | if (to2.hasStartDate() ) | 810 | if (to2.hasStartDate() ) |
811 | to2.setStartDate( to2.startDate().addDays( dayDiff ) ); | 811 | to2.setStartDate( to2.startDate().addDays( dayDiff ) ); |
812 | 812 | ||
813 | /* now the alarms */ | 813 | /* now the alarms */ |
814 | if (to2.hasNotifiers() ) { | 814 | if (to2.hasNotifiers() ) { |
815 | OPimNotifyManager::Alarms _als = to2.notifiers().alarms(); | 815 | OPimNotifyManager::Alarms _als = to2.notifiers().alarms(); |
816 | OPimNotifyManager::Alarms als; | 816 | OPimNotifyManager::Alarms als; |
817 | 817 | ||
818 | /* for every alarm move the day */ | 818 | /* for every alarm move the day */ |
819 | for ( OPimNotifyManager::Alarms::Iterator it = _als.begin(); it != _als.end(); ++it ) { | 819 | for ( OPimNotifyManager::Alarms::Iterator it = _als.begin(); it != _als.end(); ++it ) { |
820 | OPimAlarm al = (*it); | 820 | OPimAlarm al = (*it); |
821 | al.setDateTime( al.dateTime().addDays( dayDiff ) ); | 821 | al.setDateTime( al.dateTime().addDays( dayDiff ) ); |
822 | als.append( al ); | 822 | als.append( al ); |
823 | } | 823 | } |
824 | to2.notifiers().setAlarms( als ); | 824 | to2.notifiers().setAlarms( als ); |
825 | handleAlarms( OPimTodo(), todo ); | 825 | handleAlarms( OPimTodo(), todo ); |
826 | } | 826 | } |
827 | to2.setCompletedDate( inval ); | 827 | to2.setCompletedDate( inval ); |
828 | to2.setCompleted( false ); | 828 | to2.setCompleted( false ); |
829 | 829 | ||
830 | updateTodo( to2 ); | 830 | updateTodo( to2 ); |
831 | }else | 831 | }else |
832 | updateTodo( to ); | 832 | updateTodo( to ); |
833 | }else | 833 | }else |
834 | updateTodo( to ); | 834 | updateTodo( to ); |
835 | 835 | ||
836 | currentView()->updateView(); | 836 | currentView()->updateView(); |
837 | raiseCurrentView(); | 837 | raiseCurrentView(); |
838 | } | 838 | } |
839 | void MainWindow::flush() { | 839 | void MainWindow::flush() { |
840 | slotFlush(); | 840 | slotFlush(); |
841 | } | 841 | } |
842 | void MainWindow::reload() { | 842 | void MainWindow::reload() { |
843 | slotReload(); | 843 | slotReload(); |
844 | } | 844 | } |
845 | int MainWindow::create() { | 845 | int MainWindow::create() { |
846 | int uid = 0; | 846 | int uid = 0; |
847 | if(m_syncing) { | 847 | if(m_syncing) { |
848 | QMessageBox::warning(this, QWidget::tr("Todo"), | 848 | QMessageBox::warning(this, QWidget::tr("Todo"), |
849 | QWidget::tr("Data can not be edited, currently syncing")); | 849 | QWidget::tr("Data can not be edited, currently syncing")); |
850 | return uid; | 850 | return uid; |
851 | } | 851 | } |
852 | m_todoMgr.load(); | 852 | m_todoMgr.load(); |
853 | 853 | ||
854 | 854 | ||
855 | OPimTodo todo = currentEditor()->newTodo( currentCatId(), | 855 | OPimTodo todo = currentEditor()->newTodo( currentCatId(), |
856 | this ); | 856 | this ); |
857 | 857 | ||
858 | if ( currentEditor()->accepted() ) { | 858 | if ( currentEditor()->accepted() ) { |
859 | //todo.assignUid(); | 859 | //todo.assignUid(); |
860 | uid = todo.uid(); | 860 | uid = todo.uid(); |
861 | handleAlarms( OPimTodo(), todo ); | 861 | handleAlarms( OPimTodo(), todo ); |
862 | m_todoMgr.add( todo ); | 862 | m_todoMgr.add( todo ); |
863 | currentView()->addEvent( todo ); | 863 | currentView()->addEvent( todo ); |
864 | 864 | ||
865 | 865 | ||
866 | // I'm afraid we must call this every time now, otherwise | 866 | // I'm afraid we must call this every time now, otherwise |
867 | // spend expensive time comparing all these strings... | 867 | // spend expensive time comparing all these strings... |
868 | // but only call if we changed something -zecke | 868 | // but only call if we changed something -zecke |
869 | populateCategories(); | 869 | populateCategories(); |
870 | } | 870 | } |
871 | raiseCurrentView( ); | 871 | raiseCurrentView( ); |
872 | 872 | ||
873 | return uid; | 873 | return uid; |
874 | } | 874 | } |
875 | /* delete it silently... */ | 875 | /* delete it silently... */ |
876 | bool MainWindow::remove( int uid ) { | 876 | bool MainWindow::remove( int uid ) { |
877 | if (m_syncing) return false; | 877 | if (m_syncing) return false; |
878 | 878 | ||
879 | /* argh need to get the whole OEvent... to disable alarms -zecke */ | 879 | /* argh need to get the whole OEvent... to disable alarms -zecke */ |
880 | handleAlarms( OPimTodo(), m_todoMgr.event( uid ) ); | 880 | handleAlarms( OPimTodo(), m_todoMgr.event( uid ) ); |
881 | 881 | ||
882 | return m_todoMgr.remove( uid ); | 882 | return m_todoMgr.remove( uid ); |
883 | } | 883 | } |
884 | void MainWindow::beam( int uid) { | 884 | void MainWindow::beam( int uid) { |
885 | if( uid == 0 ) return; | 885 | if( uid == 0 ) return; |
886 | 886 | ||
887 | ::unlink( beamfile ); | 887 | ::unlink( beamfile ); |
888 | m_todoMgr.load(); | 888 | m_todoMgr.load(); |
889 | 889 | ||
890 | OPimTodo todo = event( uid ); | 890 | OPimTodo todo = event( uid ); |
891 | OPimTodoAccessVCal* cal = new OPimTodoAccessVCal(QString::fromLatin1(beamfile) ); | 891 | OPimTodoAccessVCal* cal = new OPimTodoAccessVCal(QString::fromLatin1(beamfile) ); |
892 | OPimTodoAccess acc( cal ); | 892 | OPimTodoAccess acc( cal ); |
893 | acc.load(); | 893 | acc.load(); |
894 | acc.add( todo ); | 894 | acc.add( todo ); |
895 | acc.save(); | 895 | acc.save(); |
896 | Ir* ir = new Ir(this ); | 896 | Ir* ir = new Ir(this ); |
897 | connect(ir, SIGNAL(done(Ir*) ), | 897 | connect(ir, SIGNAL(done(Ir*) ), |
898 | this, SLOT(beamDone(Ir*) ) ); | 898 | this, SLOT(beamDone(Ir*) ) ); |
899 | ir->send(beamfile, todo.summary(), "text/x-vCalendar" ); | 899 | ir->send(beamfile, todo.summary(), "text/x-vCalendar" ); |
900 | } | 900 | } |
901 | void MainWindow::show( int uid ) { | 901 | void MainWindow::show( int uid ) { |
902 | m_todoMgr.load(); // might not be loaded yet | 902 | m_todoMgr.load(); // might not be loaded yet |
903 | m_showing = true; | 903 | m_showing = true; |
904 | slotShow( uid ); | 904 | slotShow( uid ); |
905 | raise(); | 905 | raise(); |
906 | QPEApplication::setKeepRunning(); | 906 | QPEApplication::setKeepRunning(); |
907 | } | 907 | } |
908 | void MainWindow::edit( int uid ) { | 908 | void MainWindow::edit( int uid ) { |
909 | m_todoMgr.load(); | 909 | m_todoMgr.load(); |
910 | slotEdit( uid ); | 910 | slotEdit( uid ); |
911 | } | 911 | } |
912 | void MainWindow::add( const OPimRecord& rec) { | 912 | void MainWindow::add( const OPimRecord& rec) { |
913 | if ( rec.rtti() != OPimTodo::rtti() ) return; | 913 | OPimTodo test; |
914 | if ( rec.rtti() != test.rtti() ) return; | ||
914 | m_todoMgr.load(); // might not be loaded | 915 | m_todoMgr.load(); // might not be loaded |
915 | 916 | ||
916 | const OPimTodo& todo = static_cast<const OPimTodo&>(rec); | 917 | const OPimTodo& todo = static_cast<const OPimTodo&>(rec); |
917 | 918 | ||
918 | m_todoMgr.add(todo ); | 919 | m_todoMgr.add(todo ); |
919 | currentView()->addEvent( todo ); | 920 | currentView()->addEvent( todo ); |
920 | 921 | ||
921 | 922 | ||
922 | // I'm afraid we must call this every time now, otherwise | 923 | // I'm afraid we must call this every time now, otherwise |
923 | // spend expensive time comparing all these strings... | 924 | // spend expensive time comparing all these strings... |
924 | // but only call if we changed something -zecke | 925 | // but only call if we changed something -zecke |
925 | populateCategories(); | 926 | populateCategories(); |
926 | } | 927 | } |
927 | void MainWindow::slotReturnFromView() { | 928 | void MainWindow::slotReturnFromView() { |
928 | m_showing = false; | 929 | m_showing = false; |
929 | raiseCurrentView(); | 930 | raiseCurrentView(); |
930 | } | 931 | } |
931 | 932 | ||
932 | namespace { | 933 | namespace { |
933 | OPimNotifyManager::Alarms findNonMatching( const OPimNotifyManager::Alarms& oldAls, | 934 | OPimNotifyManager::Alarms findNonMatching( const OPimNotifyManager::Alarms& oldAls, |
934 | const OPimNotifyManager::Alarms& newAls ) { | 935 | const OPimNotifyManager::Alarms& newAls ) { |
935 | OPimNotifyManager::Alarms nonMatching; | 936 | OPimNotifyManager::Alarms nonMatching; |
936 | OPimNotifyManager::Alarms::ConstIterator oldIt = oldAls.begin(); | 937 | OPimNotifyManager::Alarms::ConstIterator oldIt = oldAls.begin(); |
937 | OPimNotifyManager::Alarms::ConstIterator newIt; | 938 | OPimNotifyManager::Alarms::ConstIterator newIt; |
938 | for ( ; oldIt != oldAls.end(); ++oldIt ) { | 939 | for ( ; oldIt != oldAls.end(); ++oldIt ) { |
939 | bool found = false; | 940 | bool found = false; |
940 | QDateTime oldDt = (*oldIt).dateTime(); | 941 | QDateTime oldDt = (*oldIt).dateTime(); |
941 | for (newIt= newAls.begin(); newIt != newAls.end(); ++newIt ) { | 942 | for (newIt= newAls.begin(); newIt != newAls.end(); ++newIt ) { |
942 | if ( oldDt == (*newIt).dateTime() ) { | 943 | if ( oldDt == (*newIt).dateTime() ) { |
943 | found = true; | 944 | found = true; |
944 | break; | 945 | break; |
945 | } | 946 | } |
946 | } | 947 | } |
947 | if (!found) | 948 | if (!found) |
948 | nonMatching.append( (*oldIt) ); | 949 | nonMatching.append( (*oldIt) ); |
949 | } | 950 | } |
950 | return nonMatching; | 951 | return nonMatching; |
951 | } | 952 | } |
952 | void addAlarms( const OPimNotifyManager::Alarms& als, int uid ) { | 953 | void addAlarms( const OPimNotifyManager::Alarms& als, int uid ) { |
953 | OPimNotifyManager::Alarms::ConstIterator it; | 954 | OPimNotifyManager::Alarms::ConstIterator it; |
954 | for ( it = als.begin(); it != als.end(); ++it ) { | 955 | for ( it = als.begin(); it != als.end(); ++it ) { |
955 | owarn << "Adding alarm for " << (*it).dateTime().toString() << oendl; | 956 | owarn << "Adding alarm for " << (*it).dateTime().toString() << oendl; |
956 | AlarmServer::addAlarm( (*it).dateTime(), "QPE/Application/todolist", "alarm(QDateTime,int)", uid ); | 957 | AlarmServer::addAlarm( (*it).dateTime(), "QPE/Application/todolist", "alarm(QDateTime,int)", uid ); |
957 | } | 958 | } |
958 | 959 | ||
959 | } | 960 | } |
960 | void removeAlarms( const OPimNotifyManager::Alarms& als, int uid ) { | 961 | void removeAlarms( const OPimNotifyManager::Alarms& als, int uid ) { |
961 | OPimNotifyManager::Alarms::ConstIterator it; | 962 | OPimNotifyManager::Alarms::ConstIterator it; |
962 | for ( it = als.begin(); it != als.end(); ++it ) { | 963 | for ( it = als.begin(); it != als.end(); ++it ) { |
963 | owarn << "Removinf alarm for " << (*it).dateTime().toString() << oendl; | 964 | owarn << "Removinf alarm for " << (*it).dateTime().toString() << oendl; |
964 | AlarmServer::deleteAlarm( (*it).dateTime(), "QPE/Application/todolist", "alarm(QDateTime,int)", uid ); | 965 | AlarmServer::deleteAlarm( (*it).dateTime(), "QPE/Application/todolist", "alarm(QDateTime,int)", uid ); |
965 | } | 966 | } |
966 | } | 967 | } |
967 | } | 968 | } |
968 | 969 | ||
969 | void MainWindow::handleAlarms( const OPimTodo& oldTodo, const OPimTodo& newTodo) { | 970 | void MainWindow::handleAlarms( const OPimTodo& oldTodo, const OPimTodo& newTodo) { |
970 | /* | 971 | /* |
971 | * if oldTodo is not empty and has notifiers we need to find the deleted ones | 972 | * if oldTodo is not empty and has notifiers we need to find the deleted ones |
972 | */ | 973 | */ |
973 | if(!oldTodo.isEmpty() && oldTodo.hasNotifiers() ) { | 974 | if(!oldTodo.isEmpty() && oldTodo.hasNotifiers() ) { |
974 | OPimNotifyManager::Alarms removed; | 975 | OPimNotifyManager::Alarms removed; |
975 | OPimNotifyManager::Alarms oldAls = oldTodo.notifiers().alarms(); | 976 | OPimNotifyManager::Alarms oldAls = oldTodo.notifiers().alarms(); |
976 | if (!newTodo.hasNotifiers() ) | 977 | if (!newTodo.hasNotifiers() ) |
977 | removed = oldAls; | 978 | removed = oldAls; |
978 | else | 979 | else |
979 | removed = findNonMatching( oldAls, newTodo.notifiers().alarms() ); | 980 | removed = findNonMatching( oldAls, newTodo.notifiers().alarms() ); |
980 | 981 | ||
981 | removeAlarms( removed, oldTodo.uid() ); | 982 | removeAlarms( removed, oldTodo.uid() ); |
982 | } | 983 | } |
983 | if ( newTodo.hasNotifiers() ) { | 984 | if ( newTodo.hasNotifiers() ) { |
984 | OPimNotifyManager::Alarms added; | 985 | OPimNotifyManager::Alarms added; |
985 | if ( oldTodo.isEmpty() || !oldTodo.hasNotifiers() ) | 986 | if ( oldTodo.isEmpty() || !oldTodo.hasNotifiers() ) |
986 | added = newTodo.notifiers().alarms(); | 987 | added = newTodo.notifiers().alarms(); |
987 | else | 988 | else |
988 | added = findNonMatching( newTodo.notifiers().alarms(), oldTodo.notifiers().alarms() ); | 989 | added = findNonMatching( newTodo.notifiers().alarms(), oldTodo.notifiers().alarms() ); |
989 | 990 | ||
990 | addAlarms( added, newTodo.uid() ); | 991 | addAlarms( added, newTodo.uid() ); |
991 | } | 992 | } |
992 | } | 993 | } |
993 | /* we might have not loaded the db */ | 994 | /* we might have not loaded the db */ |
994 | void MainWindow::doAlarm( const QDateTime& dt, int uid ) { | 995 | void MainWindow::doAlarm( const QDateTime& dt, int uid ) { |
995 | m_todoMgr.load(); | 996 | m_todoMgr.load(); |
996 | 997 | ||
997 | OPimTodo todo = m_todoMgr.event( uid ); | 998 | OPimTodo todo = m_todoMgr.event( uid ); |
998 | if (!todo.hasNotifiers() ) return; | 999 | if (!todo.hasNotifiers() ) return; |
999 | 1000 | ||
1000 | /* | 1001 | /* |
1001 | * let's find the right alarm and find out if silent | 1002 | * let's find the right alarm and find out if silent |
1002 | * then show a richtext widget | 1003 | * then show a richtext widget |
1003 | */ | 1004 | */ |
1004 | bool loud = false; | 1005 | bool loud = false; |
1005 | OPimNotifyManager::Alarms als = todo.notifiers().alarms(); | 1006 | OPimNotifyManager::Alarms als = todo.notifiers().alarms(); |
1006 | OPimNotifyManager::Alarms::Iterator it; | 1007 | OPimNotifyManager::Alarms::Iterator it; |
1007 | for ( it = als.begin(); it != als.end(); ++it ) { | 1008 | for ( it = als.begin(); it != als.end(); ++it ) { |
1008 | if ( (*it).dateTime() == dt ) { | 1009 | if ( (*it).dateTime() == dt ) { |
1009 | loud = ( (*it).sound() == OPimAlarm::Loud ); | 1010 | loud = ( (*it).sound() == OPimAlarm::Loud ); |
1010 | break; | 1011 | break; |
1011 | } | 1012 | } |
1012 | } | 1013 | } |
1013 | if (loud) | 1014 | if (loud) |
1014 | startAlarm(); | 1015 | startAlarm(); |
1015 | 1016 | ||
1016 | QDialog dlg(this, 0, TRUE ); | 1017 | QDialog dlg(this, 0, TRUE ); |
1017 | QVBoxLayout* lay = new QVBoxLayout( &dlg ); | 1018 | QVBoxLayout* lay = new QVBoxLayout( &dlg ); |
1018 | QTextView* view = new QTextView( &dlg ); | 1019 | QTextView* view = new QTextView( &dlg ); |
1019 | lay->addWidget( view ); | 1020 | lay->addWidget( view ); |
1020 | QPushButton* btnOk = new QPushButton( tr("Ok"), &dlg ); | 1021 | QPushButton* btnOk = new QPushButton( tr("Ok"), &dlg ); |
1021 | connect( btnOk, SIGNAL(clicked() ), &dlg, SLOT(accept() ) ); | 1022 | connect( btnOk, SIGNAL(clicked() ), &dlg, SLOT(accept() ) ); |
1022 | lay->addWidget( btnOk ); | 1023 | lay->addWidget( btnOk ); |
1023 | 1024 | ||
1024 | QString text = tr("<h1>Alarm at %1</h1><br>").arg( TimeString::dateString( dt ) ); | 1025 | QString text = tr("<h1>Alarm at %1</h1><br>").arg( TimeString::dateString( dt ) ); |
1025 | text += todo.toRichText(); | 1026 | text += todo.toRichText(); |
1026 | view->setText( text ); | 1027 | view->setText( text ); |
1027 | 1028 | ||
1028 | bool needToStay = QPEApplication::execDialog( &dlg ); | 1029 | bool needToStay = QPEApplication::execDialog( &dlg ); |
1029 | 1030 | ||
1030 | if (loud) | 1031 | if (loud) |
1031 | killAlarm(); | 1032 | killAlarm(); |
1032 | 1033 | ||
1033 | if (needToStay) { | 1034 | if (needToStay) { |
1034 | // showMaximized(); | 1035 | // showMaximized(); |
1035 | // raise(); | 1036 | // raise(); |
1036 | QPEApplication::setKeepRunning(); | 1037 | QPEApplication::setKeepRunning(); |
1037 | // setActiveWindow(); | 1038 | // setActiveWindow(); |
1038 | } | 1039 | } |
1039 | 1040 | ||
1040 | } | 1041 | } |
1041 | 1042 | ||