-rw-r--r-- | core/pim/todo/mainwindow.cpp | 2 | ||||
-rw-r--r-- | core/pim/todo/mainwindow.h | 8 | ||||
-rw-r--r-- | core/pim/todo/quickeditimpl.cpp | 2 |
3 files changed, 5 insertions, 7 deletions
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp index a244e58..c2f422d 100644 --- a/core/pim/todo/mainwindow.cpp +++ b/core/pim/todo/mainwindow.cpp | |||
@@ -1,835 +1,835 @@ | |||
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/opimrecurrence.h> | 31 | #include <opie2/opimrecurrence.h> |
32 | #include <opie2/opimnotifymanager.h> | 32 | #include <opie2/opimnotifymanager.h> |
33 | #include <opie2/otodoaccessvcal.h> | 33 | #include <opie2/otodoaccessvcal.h> |
34 | #include <opie2/oapplicationfactory.h> | 34 | #include <opie2/oapplicationfactory.h> |
35 | 35 | ||
36 | #include <qpe/applnk.h> | 36 | #include <qpe/applnk.h> |
37 | #include <qpe/config.h> | 37 | #include <qpe/config.h> |
38 | #include <qpe/ir.h> | 38 | #include <qpe/ir.h> |
39 | #include <qpe/resource.h> | 39 | #include <qpe/resource.h> |
40 | #include <qpe/qpemessagebox.h> | 40 | #include <qpe/qpemessagebox.h> |
41 | #include <qpe/alarmserver.h> | 41 | #include <qpe/alarmserver.h> |
42 | #include <qpe/qpeapplication.h> | 42 | #include <qpe/qpeapplication.h> |
43 | 43 | ||
44 | #include <qmenubar.h> | 44 | #include <qmenubar.h> |
45 | #include <qmessagebox.h> | 45 | #include <qmessagebox.h> |
46 | #include <qpushbutton.h> | 46 | #include <qpushbutton.h> |
47 | #include <qaction.h> | 47 | #include <qaction.h> |
48 | #include <qtimer.h> | 48 | #include <qtimer.h> |
49 | #include <qlayout.h> | 49 | #include <qlayout.h> |
50 | #include <qwhatsthis.h> | 50 | #include <qwhatsthis.h> |
51 | 51 | ||
52 | #include "quickeditimpl.h" | 52 | #include "quickeditimpl.h" |
53 | #include "todotemplatemanager.h" | 53 | #include "todotemplatemanager.h" |
54 | #include "templateeditor.h" | 54 | #include "templateeditor.h" |
55 | #include "tableview.h" | 55 | #include "tableview.h" |
56 | 56 | ||
57 | #include "textviewshow.h" | 57 | #include "textviewshow.h" |
58 | #include "todoeditor.h" | 58 | #include "todoeditor.h" |
59 | #include "mainwindow.h" | 59 | #include "mainwindow.h" |
60 | 60 | ||
61 | OPIE_EXPORT_APP( OApplicationFactory<Todo::MainWindow> ) | 61 | OPIE_EXPORT_APP( OApplicationFactory<Todo::MainWindow> ) |
62 | 62 | ||
63 | using namespace Todo; | 63 | using namespace Todo; |
64 | 64 | ||
65 | MainWindow::MainWindow( QWidget* parent, | 65 | MainWindow::MainWindow( QWidget* parent, |
66 | const char* name, WFlags ) | 66 | const char* name, WFlags ) |
67 | : OPimMainWindow( "Todolist", parent, name, WType_TopLevel | WStyle_ContextHelp ) | 67 | : Opie::OPimMainWindow( "Todolist", parent, name, WType_TopLevel | WStyle_ContextHelp ) |
68 | { | 68 | { |
69 | if (!name) | 69 | if (!name) |
70 | setName("todo window"); | 70 | setName("todo window"); |
71 | 71 | ||
72 | m_syncing = false; | 72 | m_syncing = false; |
73 | m_showing = false; | 73 | m_showing = false; |
74 | m_counter = 0; | 74 | m_counter = 0; |
75 | m_tempManager = new TemplateManager(); | 75 | m_tempManager = new TemplateManager(); |
76 | m_tempManager->load(); | 76 | m_tempManager->load(); |
77 | 77 | ||
78 | initUI(); | 78 | initUI(); |
79 | initConfig(); | 79 | initConfig(); |
80 | initViews(); | 80 | initViews(); |
81 | initActions(); | 81 | initActions(); |
82 | initEditor(); | 82 | initEditor(); |
83 | initShow(); | 83 | initShow(); |
84 | initTemplate(); | 84 | initTemplate(); |
85 | 85 | ||
86 | populateTemplates(); | 86 | populateTemplates(); |
87 | raiseCurrentView(); | 87 | raiseCurrentView(); |
88 | QTimer::singleShot(0, this, SLOT(populateCategories() ) ); | 88 | QTimer::singleShot(0, this, SLOT(populateCategories() ) ); |
89 | } | 89 | } |
90 | void MainWindow::initTemplate() { | 90 | void MainWindow::initTemplate() { |
91 | m_curTempEd = new TemplateEditor( this, templateManager() ); | 91 | m_curTempEd = new TemplateEditor( this, templateManager() ); |
92 | } | 92 | } |
93 | void MainWindow::initActions() { | 93 | void MainWindow::initActions() { |
94 | 94 | ||
95 | // Data menu | 95 | // Data menu |
96 | m_edit->insertItem(QWidget::tr("New from template"), m_template, | 96 | m_edit->insertItem(QWidget::tr("New from template"), m_template, |
97 | -1, 0 ); | 97 | -1, 0 ); |
98 | 98 | ||
99 | QAction* a = new QAction( QWidget::tr("New Task" ), Resource::loadPixmap( "new" ), | 99 | QAction* a = new QAction( QWidget::tr("New Task" ), Resource::loadPixmap( "new" ), |
100 | QString::null, 0, this, 0 ); | 100 | QString::null, 0, this, 0 ); |
101 | connect(a, SIGNAL( activated() ), | 101 | connect(a, SIGNAL( activated() ), |
102 | this, SLOT( slotNew() ) ); | 102 | this, SLOT( slotNew() ) ); |
103 | a->setWhatsThis( QWidget::tr( "Click here to create a new task." ) ); | 103 | a->setWhatsThis( QWidget::tr( "Click here to create a new task." ) ); |
104 | a->addTo(m_tool ); | 104 | a->addTo(m_tool ); |
105 | a->addTo(m_edit ); | 105 | a->addTo(m_edit ); |
106 | 106 | ||
107 | a = new QAction( QWidget::tr("Edit Task"), Resource::loadIconSet( "edit" ), | 107 | a = new QAction( QWidget::tr("Edit Task"), Resource::loadIconSet( "edit" ), |
108 | QString::null, 0, this, 0 ); | 108 | QString::null, 0, this, 0 ); |
109 | connect(a, SIGNAL(activated() ), | 109 | connect(a, SIGNAL(activated() ), |
110 | this, SLOT( slotEdit() ) ); | 110 | this, SLOT( slotEdit() ) ); |
111 | a->setWhatsThis( QWidget::tr( "Click here to modify the current task." ) ); | 111 | a->setWhatsThis( QWidget::tr( "Click here to modify the current task." ) ); |
112 | a->addTo( m_tool ); | 112 | a->addTo( m_tool ); |
113 | a->addTo( m_edit ); | 113 | a->addTo( m_edit ); |
114 | m_editAction = a; | 114 | m_editAction = a; |
115 | 115 | ||
116 | a = new QAction( QString::null, QWidget::tr("View Task"), 0, this, 0 ); | 116 | a = new QAction( QString::null, QWidget::tr("View Task"), 0, this, 0 ); |
117 | connect(a, SIGNAL( activated() ), | 117 | connect(a, SIGNAL( activated() ), |
118 | this, SLOT( slotShowDetails() ) ); | 118 | this, SLOT( slotShowDetails() ) ); |
119 | a->addTo( m_edit ); | 119 | a->addTo( m_edit ); |
120 | 120 | ||
121 | m_edit->insertSeparator(); | 121 | m_edit->insertSeparator(); |
122 | 122 | ||
123 | a = new QAction( QWidget::tr("Delete..."), Resource::loadIconSet( "trash" ), | 123 | a = new QAction( QWidget::tr("Delete..."), Resource::loadIconSet( "trash" ), |
124 | QString::null, 0, this, 0 ); | 124 | QString::null, 0, this, 0 ); |
125 | connect(a, SIGNAL(activated() ), | 125 | connect(a, SIGNAL(activated() ), |
126 | this, SLOT(slotDelete() ) ); | 126 | this, SLOT(slotDelete() ) ); |
127 | a->setWhatsThis( QWidget::tr( "Click here to remove the current task." ) ); | 127 | a->setWhatsThis( QWidget::tr( "Click here to remove the current task." ) ); |
128 | a->addTo( m_tool ); | 128 | a->addTo( m_tool ); |
129 | a->addTo( m_edit ); | 129 | a->addTo( m_edit ); |
130 | m_deleteAction = a; | 130 | m_deleteAction = a; |
131 | 131 | ||
132 | a = new QAction( QString::null, QWidget::tr("Delete all..."), 0, this, 0 ); | 132 | a = new QAction( QString::null, QWidget::tr("Delete all..."), 0, this, 0 ); |
133 | connect(a, SIGNAL( activated() ), | 133 | connect(a, SIGNAL( activated() ), |
134 | this, SLOT( slotDeleteAll() ) ); | 134 | this, SLOT( slotDeleteAll() ) ); |
135 | a->addTo(m_edit ); | 135 | a->addTo(m_edit ); |
136 | m_deleteAllAction = a; | 136 | m_deleteAllAction = a; |
137 | 137 | ||
138 | a = new QAction( QString::null, QWidget::tr("Delete completed"), | 138 | a = new QAction( QString::null, QWidget::tr("Delete completed"), |
139 | 0, this, 0 ); | 139 | 0, this, 0 ); |
140 | connect(a, SIGNAL( activated() ), | 140 | connect(a, SIGNAL( activated() ), |
141 | this, SLOT( slotDeleteCompleted() ) ); | 141 | this, SLOT( slotDeleteCompleted() ) ); |
142 | a->addTo(m_edit ); | 142 | a->addTo(m_edit ); |
143 | a->setEnabled( TRUE ); | 143 | a->setEnabled( TRUE ); |
144 | m_deleteCompleteAction = a; | 144 | m_deleteCompleteAction = a; |
145 | 145 | ||
146 | m_edit->insertSeparator(); | 146 | m_edit->insertSeparator(); |
147 | 147 | ||
148 | a = new QAction( QString::null, QWidget::tr("Duplicate"), 0, this, 0 ); | 148 | a = new QAction( QString::null, QWidget::tr("Duplicate"), 0, this, 0 ); |
149 | connect(a, SIGNAL( activated() ), | 149 | connect(a, SIGNAL( activated() ), |
150 | this, SLOT( slotDuplicate() ) ); | 150 | this, SLOT( slotDuplicate() ) ); |
151 | a->addTo(m_edit ); | 151 | a->addTo(m_edit ); |
152 | m_duplicateAction = a; | 152 | m_duplicateAction = a; |
153 | 153 | ||
154 | m_edit->insertSeparator(); | 154 | m_edit->insertSeparator(); |
155 | 155 | ||
156 | if ( Ir::supported() ) { | 156 | if ( Ir::supported() ) { |
157 | a = new QAction( QWidget::tr( "Beam" ), Resource::loadPixmap( "beam" ), QString::null, 0, this, 0 ); | 157 | a = new QAction( QWidget::tr( "Beam" ), Resource::loadPixmap( "beam" ), QString::null, 0, this, 0 ); |
158 | connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) ); | 158 | connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) ); |
159 | a->setWhatsThis( QWidget::tr( "Click here to send the current task to another device." ) ); | 159 | a->setWhatsThis( QWidget::tr( "Click here to send the current task to another device." ) ); |
160 | a->addTo( m_edit ); | 160 | a->addTo( m_edit ); |
161 | a->addTo( m_tool ); | 161 | a->addTo( m_tool ); |
162 | } | 162 | } |
163 | 163 | ||
164 | #if 0 | 164 | #if 0 |
165 | // Options menu | 165 | // Options menu |
166 | a = new QAction( QWidget::tr("Find"), Resource::loadIconSet( "mag" ), | 166 | a = new QAction( QWidget::tr("Find"), Resource::loadIconSet( "mag" ), |
167 | QString::null, 0, this, 0 ); | 167 | QString::null, 0, this, 0 ); |
168 | connect(a, SIGNAL( activated() ), this, SLOT( slotFind() ) ); | 168 | connect(a, SIGNAL( activated() ), this, SLOT( slotFind() ) ); |
169 | a->addTo( m_options ); | 169 | a->addTo( m_options ); |
170 | m_findAction = a; | 170 | m_findAction = a; |
171 | 171 | ||
172 | 172 | ||
173 | m_options->insertSeparator(); | 173 | m_options->insertSeparator(); |
174 | #endif | 174 | #endif |
175 | 175 | ||
176 | m_completedAction = new QAction( QString::null, QWidget::tr("Show completed tasks"), | 176 | m_completedAction = new QAction( QString::null, QWidget::tr("Show completed tasks"), |
177 | 0, this, 0, TRUE ); | 177 | 0, this, 0, TRUE ); |
178 | m_completedAction->addTo( m_options ); | 178 | m_completedAction->addTo( m_options ); |
179 | m_completedAction->setOn( showCompleted() ); | 179 | m_completedAction->setOn( showCompleted() ); |
180 | connect(m_completedAction, SIGNAL( toggled(bool) ), this, SLOT(slotShowCompleted(bool) ) ); | 180 | connect(m_completedAction, SIGNAL( toggled(bool) ), this, SLOT(slotShowCompleted(bool) ) ); |
181 | 181 | ||
182 | a = new QAction( QString::null, QWidget::tr("Show only over-due tasks"), | 182 | a = new QAction( QString::null, QWidget::tr("Show only over-due tasks"), |
183 | 0, this, 0, TRUE ); | 183 | 0, this, 0, TRUE ); |
184 | a->addTo( m_options ); | 184 | a->addTo( m_options ); |
185 | a->setOn( showOverDue() ); | 185 | a->setOn( showOverDue() ); |
186 | connect(a, SIGNAL(toggled(bool)), this, SLOT(slotShowDue(bool) ) ); | 186 | connect(a, SIGNAL(toggled(bool)), this, SLOT(slotShowDue(bool) ) ); |
187 | 187 | ||
188 | m_showDeadLineAction = new QAction( QString::null, QWidget::tr("Show task deadlines"), | 188 | m_showDeadLineAction = new QAction( QString::null, QWidget::tr("Show task deadlines"), |
189 | 0, this, 0, TRUE ); | 189 | 0, this, 0, TRUE ); |
190 | m_showDeadLineAction->addTo( m_options ); | 190 | m_showDeadLineAction->addTo( m_options ); |
191 | m_showDeadLineAction->setOn( showDeadline() ); | 191 | m_showDeadLineAction->setOn( showDeadline() ); |
192 | connect(m_showDeadLineAction, SIGNAL(toggled(bool) ), this, SLOT( slotShowDeadLine(bool) ) ); | 192 | connect(m_showDeadLineAction, SIGNAL(toggled(bool) ), this, SLOT( slotShowDeadLine(bool) ) ); |
193 | 193 | ||
194 | m_showQuickTaskAction = new QAction( QString::null, QWidget::tr("Show quick task bar"), | 194 | m_showQuickTaskAction = new QAction( QString::null, QWidget::tr("Show quick task bar"), |
195 | 0, this, 0, TRUE ); | 195 | 0, this, 0, TRUE ); |
196 | m_showQuickTaskAction->addTo( m_options ); | 196 | m_showQuickTaskAction->addTo( m_options ); |
197 | m_showQuickTaskAction->setOn( showQuickTask() ); | 197 | m_showQuickTaskAction->setOn( showQuickTask() ); |
198 | connect(m_showQuickTaskAction, SIGNAL( toggled(bool) ), this, SLOT(slotShowQuickTask(bool) ) ); | 198 | connect(m_showQuickTaskAction, SIGNAL( toggled(bool) ), this, SLOT(slotShowQuickTask(bool) ) ); |
199 | 199 | ||
200 | m_options->insertSeparator(); | 200 | m_options->insertSeparator(); |
201 | 201 | ||
202 | m_bar->insertItem( QWidget::tr("Data") ,m_edit ); | 202 | m_bar->insertItem( QWidget::tr("Data") ,m_edit ); |
203 | m_bar->insertItem( QWidget::tr("Category"), m_catMenu ); | 203 | m_bar->insertItem( QWidget::tr("Category"), m_catMenu ); |
204 | m_bar->insertItem( QWidget::tr("Options"), m_options ); | 204 | m_bar->insertItem( QWidget::tr("Options"), m_options ); |
205 | 205 | ||
206 | m_curQuick = new QuickEditImpl( this, m_quicktask ); | 206 | m_curQuick = new QuickEditImpl( this, m_quicktask ); |
207 | addToolBar( (QToolBar *)m_curQuick->widget(), QWidget::tr( "QuickEdit" ), QMainWindow::Top, TRUE ); | 207 | addToolBar( (QToolBar *)m_curQuick->widget(), QWidget::tr( "QuickEdit" ), QMainWindow::Top, TRUE ); |
208 | m_curQuick->signal()->connect( this, SLOT(slotQuickEntered() ) ); | 208 | m_curQuick->signal()->connect( this, SLOT(slotQuickEntered() ) ); |
209 | 209 | ||
210 | } | 210 | } |
211 | /* m_curCat from Config */ | 211 | /* m_curCat from Config */ |
212 | void MainWindow::initConfig() { | 212 | void MainWindow::initConfig() { |
213 | Config config( "todo" ); | 213 | Config config( "todo" ); |
214 | config.setGroup( "View" ); | 214 | config.setGroup( "View" ); |
215 | m_completed = config.readBoolEntry( "ShowComplete", TRUE ); | 215 | m_completed = config.readBoolEntry( "ShowComplete", TRUE ); |
216 | m_curCat = config.readEntry( "Category", QString::null ); | 216 | m_curCat = config.readEntry( "Category", QString::null ); |
217 | m_deadline = config.readBoolEntry( "ShowDeadLine", TRUE); | 217 | m_deadline = config.readBoolEntry( "ShowDeadLine", TRUE); |
218 | m_overdue = config.readBoolEntry("ShowOverDue", FALSE ); | 218 | m_overdue = config.readBoolEntry("ShowOverDue", FALSE ); |
219 | m_quicktask = config.readBoolEntry("ShowQuickTask", TRUE); | 219 | m_quicktask = config.readBoolEntry("ShowQuickTask", TRUE); |
220 | } | 220 | } |
221 | void MainWindow::initUI() { | 221 | void MainWindow::initUI() { |
222 | 222 | ||
223 | m_stack = new OWidgetStack(this, "main stack"); | 223 | m_stack = new OWidgetStack(this, "main stack"); |
224 | 224 | ||
225 | setCentralWidget( m_stack ); | 225 | setCentralWidget( m_stack ); |
226 | 226 | ||
227 | setToolBarsMovable( FALSE ); | 227 | setToolBarsMovable( FALSE ); |
228 | 228 | ||
229 | QToolBar *menubarholder = new QToolBar( this ); | 229 | QToolBar *menubarholder = new QToolBar( this ); |
230 | menubarholder->setHorizontalStretchable( TRUE ); | 230 | menubarholder->setHorizontalStretchable( TRUE ); |
231 | m_bar = new QMenuBar( menubarholder ); | 231 | m_bar = new QMenuBar( menubarholder ); |
232 | 232 | ||
233 | m_tool = new QToolBar( this ); | 233 | m_tool = new QToolBar( this ); |
234 | 234 | ||
235 | /** QPopupMenu */ | 235 | /** QPopupMenu */ |
236 | m_edit = new QPopupMenu( this ); | 236 | m_edit = new QPopupMenu( this ); |
237 | m_options = new QPopupMenu( this ); | 237 | m_options = new QPopupMenu( this ); |
238 | m_catMenu = new QPopupMenu( this ); | 238 | m_catMenu = new QPopupMenu( this ); |
239 | m_template = new QPopupMenu( this ); | 239 | m_template = new QPopupMenu( this ); |
240 | 240 | ||
241 | m_catMenu->setCheckable( TRUE ); | 241 | m_catMenu->setCheckable( TRUE ); |
242 | m_template->setCheckable( TRUE ); | 242 | m_template->setCheckable( TRUE ); |
243 | 243 | ||
244 | connect(m_catMenu, SIGNAL(activated(int) ), | 244 | connect(m_catMenu, SIGNAL(activated(int) ), |
245 | this, SLOT(setCategory(int) ) ); | 245 | this, SLOT(setCategory(int) ) ); |
246 | connect(m_template, SIGNAL(activated(int) ), | 246 | connect(m_template, SIGNAL(activated(int) ), |
247 | this, SLOT(slotNewFromTemplate(int) ) ); | 247 | this, SLOT(slotNewFromTemplate(int) ) ); |
248 | } | 248 | } |
249 | void MainWindow::initViews() { | 249 | void MainWindow::initViews() { |
250 | 250 | ||
251 | TableView* tableView = new TableView( this, m_stack ); | 251 | TableView* tableView = new TableView( this, m_stack ); |
252 | 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." ) ); | 252 | 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." ) ); |
253 | m_stack->addWidget( tableView, m_counter++ ); | 253 | m_stack->addWidget( tableView, m_counter++ ); |
254 | m_views.append( tableView ); | 254 | m_views.append( tableView ); |
255 | m_curView = tableView; | 255 | m_curView = tableView; |
256 | connectBase( tableView ); | 256 | connectBase( tableView ); |
257 | /* add QString type + QString configname to | 257 | /* add QString type + QString configname to |
258 | * the View menu | 258 | * the View menu |
259 | * and subdirs for multiple views | 259 | * and subdirs for multiple views |
260 | */ | 260 | */ |
261 | } | 261 | } |
262 | void MainWindow::initEditor() { | 262 | void MainWindow::initEditor() { |
263 | m_curEdit = new Editor(); | 263 | m_curEdit = new Editor(); |
264 | } | 264 | } |
265 | void MainWindow::initShow() { | 265 | void MainWindow::initShow() { |
266 | m_curShow = new TextViewShow(this, this); | 266 | m_curShow = new TextViewShow(this, this); |
267 | m_stack->addWidget( m_curShow->widget() , m_counter++ ); | 267 | m_stack->addWidget( m_curShow->widget() , m_counter++ ); |
268 | } | 268 | } |
269 | MainWindow::~MainWindow() { | 269 | MainWindow::~MainWindow() { |
270 | delete templateManager(); | 270 | delete templateManager(); |
271 | } | 271 | } |
272 | void MainWindow::connectBase( ViewBase* ) { | 272 | void MainWindow::connectBase( ViewBase* ) { |
273 | // once templates and signals mix we'll use it again | 273 | // once templates and signals mix we'll use it again |
274 | } | 274 | } |
275 | QPopupMenu* MainWindow::contextMenu( int , bool recur ) { | 275 | QPopupMenu* MainWindow::contextMenu( int , bool recur ) { |
276 | QPopupMenu* menu = new QPopupMenu(); | 276 | QPopupMenu* menu = new QPopupMenu(); |
277 | 277 | ||
278 | m_editAction->addTo( menu ); | 278 | m_editAction->addTo( menu ); |
279 | m_deleteAction->addTo( menu ); | 279 | m_deleteAction->addTo( menu ); |
280 | m_duplicateAction->addTo( menu ); | 280 | m_duplicateAction->addTo( menu ); |
281 | 281 | ||
282 | menu->insertSeparator(); | 282 | menu->insertSeparator(); |
283 | 283 | ||
284 | /* | 284 | /* |
285 | * if this event recurs we allow | 285 | * if this event recurs we allow |
286 | * to detach it. | 286 | * to detach it. |
287 | * remove all | 287 | * remove all |
288 | */ | 288 | */ |
289 | if ( recur ) { | 289 | if ( recur ) { |
290 | ; // FIXME | 290 | ; // FIXME |
291 | } | 291 | } |
292 | 292 | ||
293 | return menu; | 293 | return menu; |
294 | } | 294 | } |
295 | QPopupMenu* MainWindow::options() { | 295 | QPopupMenu* MainWindow::options() { |
296 | qWarning("Options"); | 296 | qWarning("Options"); |
297 | return m_options; | 297 | return m_options; |
298 | } | 298 | } |
299 | QPopupMenu* MainWindow::edit() { | 299 | QPopupMenu* MainWindow::edit() { |
300 | return m_edit; | 300 | return m_edit; |
301 | } | 301 | } |
302 | QToolBar* MainWindow::toolbar() { | 302 | QToolBar* MainWindow::toolbar() { |
303 | return m_tool; | 303 | return m_tool; |
304 | } | 304 | } |
305 | OPimTodoAccess::List MainWindow::list()const { | 305 | OPimTodoAccess::List MainWindow::list()const { |
306 | return m_todoMgr.list(); | 306 | return m_todoMgr.list(); |
307 | } | 307 | } |
308 | OPimTodoAccess::List MainWindow::sorted( bool asc, int sortOrder ) { | 308 | OPimTodoAccess::List MainWindow::sorted( bool asc, int sortOrder ) { |
309 | int cat = 0; | 309 | int cat = 0; |
310 | if ( m_curCat != QWidget::tr("All Categories") ) | 310 | if ( m_curCat != QWidget::tr("All Categories") ) |
311 | cat = currentCatId(); | 311 | cat = currentCatId(); |
312 | if ( m_curCat == QWidget::tr("Unfiled") ) | 312 | if ( m_curCat == QWidget::tr("Unfiled") ) |
313 | cat = -1; | 313 | cat = -1; |
314 | 314 | ||
315 | qWarning(" Category %d %s", cat, m_curCat.latin1() ); | 315 | qWarning(" Category %d %s", cat, m_curCat.latin1() ); |
316 | 316 | ||
317 | int filter = 1; | 317 | int filter = 1; |
318 | 318 | ||
319 | if (!m_completed ) | 319 | if (!m_completed ) |
320 | filter |= 4; | 320 | filter |= 4; |
321 | if (m_overdue) | 321 | if (m_overdue) |
322 | filter |= 2; | 322 | filter |= 2; |
323 | 323 | ||
324 | return m_todoMgr.sorted( asc, sortOrder, filter, cat ); | 324 | return m_todoMgr.sorted( asc, sortOrder, filter, cat ); |
325 | } | 325 | } |
326 | OPimTodoAccess::List MainWindow::sorted( bool asc, int sortOrder, int addFilter) { | 326 | OPimTodoAccess::List MainWindow::sorted( bool asc, int sortOrder, int addFilter) { |
327 | int cat = 0; | 327 | int cat = 0; |
328 | if ( m_curCat != QWidget::tr("All Categories") ) | 328 | if ( m_curCat != QWidget::tr("All Categories") ) |
329 | cat = currentCatId(); | 329 | cat = currentCatId(); |
330 | 330 | ||
331 | if ( m_curCat == QWidget::tr("Unfiled") ) | 331 | if ( m_curCat == QWidget::tr("Unfiled") ) |
332 | cat = -1; | 332 | cat = -1; |
333 | 333 | ||
334 | return m_todoMgr.sorted(asc, sortOrder, addFilter, cat ); | 334 | return m_todoMgr.sorted(asc, sortOrder, addFilter, cat ); |
335 | } | 335 | } |
336 | OPimTodo MainWindow::event( int uid ) { | 336 | OPimTodo MainWindow::event( int uid ) { |
337 | return m_todoMgr.event( uid ); | 337 | return m_todoMgr.event( uid ); |
338 | } | 338 | } |
339 | bool MainWindow::isSyncing()const { | 339 | bool MainWindow::isSyncing()const { |
340 | return m_syncing; | 340 | return m_syncing; |
341 | } | 341 | } |
342 | TemplateManager* MainWindow::templateManager() { | 342 | TemplateManager* MainWindow::templateManager() { |
343 | return m_tempManager; | 343 | return m_tempManager; |
344 | } | 344 | } |
345 | Editor* MainWindow::currentEditor() { | 345 | Editor* MainWindow::currentEditor() { |
346 | return m_curEdit; | 346 | return m_curEdit; |
347 | } | 347 | } |
348 | TodoShow* MainWindow::currentShow() { | 348 | TodoShow* MainWindow::currentShow() { |
349 | return m_curShow; | 349 | return m_curShow; |
350 | } | 350 | } |
351 | void MainWindow::slotReload() { | 351 | void MainWindow::slotReload() { |
352 | m_syncing = FALSE; | 352 | m_syncing = FALSE; |
353 | m_todoMgr.reload(); | 353 | m_todoMgr.reload(); |
354 | currentView()->updateView( ); | 354 | currentView()->updateView( ); |
355 | raiseCurrentView(); | 355 | raiseCurrentView(); |
356 | } | 356 | } |
357 | void MainWindow::closeEvent( QCloseEvent* e ) { | 357 | void MainWindow::closeEvent( QCloseEvent* e ) { |
358 | if (m_stack->visibleWidget() == currentShow()->widget() ) { | 358 | if (m_stack->visibleWidget() == currentShow()->widget() ) { |
359 | m_showing = false; | 359 | m_showing = false; |
360 | raiseCurrentView(); | 360 | raiseCurrentView(); |
361 | e->ignore(); | 361 | e->ignore(); |
362 | return; | 362 | return; |
363 | } | 363 | } |
364 | /* | 364 | /* |
365 | * we should have flushed and now we're still saving | 365 | * we should have flushed and now we're still saving |
366 | * so there is no need to flush | 366 | * so there is no need to flush |
367 | */ | 367 | */ |
368 | if (m_syncing ) { | 368 | if (m_syncing ) { |
369 | e->accept(); | 369 | e->accept(); |
370 | return; | 370 | return; |
371 | } | 371 | } |
372 | bool quit = false; | 372 | bool quit = false; |
373 | if ( m_todoMgr.saveAll() ){ | 373 | if ( m_todoMgr.saveAll() ){ |
374 | qWarning("saved"); | 374 | qWarning("saved"); |
375 | quit = true; | 375 | quit = true; |
376 | }else { | 376 | }else { |
377 | if ( QMessageBox::critical( this, QWidget::tr("Out of space"), | 377 | if ( QMessageBox::critical( this, QWidget::tr("Out of space"), |
378 | QWidget::tr("Todo was unable\n" | 378 | QWidget::tr("Todo was unable\n" |
379 | "to save your changes.\n" | 379 | "to save your changes.\n" |
380 | "Free up some space\n" | 380 | "Free up some space\n" |
381 | "and try again.\n" | 381 | "and try again.\n" |
382 | "\nQuit Anyway?"), | 382 | "\nQuit Anyway?"), |
383 | QMessageBox::Yes|QMessageBox::Escape, | 383 | QMessageBox::Yes|QMessageBox::Escape, |
384 | QMessageBox::No|QMessageBox::Default) | 384 | QMessageBox::No|QMessageBox::Default) |
385 | != QMessageBox::No ) { | 385 | != QMessageBox::No ) { |
386 | e->accept(); | 386 | e->accept(); |
387 | quit = true; | 387 | quit = true; |
388 | }else | 388 | }else |
389 | e->ignore(); | 389 | e->ignore(); |
390 | 390 | ||
391 | } | 391 | } |
392 | 392 | ||
393 | if (quit ) { | 393 | if (quit ) { |
394 | Config config( "todo" ); | 394 | Config config( "todo" ); |
395 | config.setGroup( "View" ); | 395 | config.setGroup( "View" ); |
396 | config.writeEntry( "ShowComplete", showCompleted() ); | 396 | config.writeEntry( "ShowComplete", showCompleted() ); |
397 | config.writeEntry( "Category", currentCategory() ); | 397 | config.writeEntry( "Category", currentCategory() ); |
398 | config.writeEntry( "ShowDeadLine", showDeadline()); | 398 | config.writeEntry( "ShowDeadLine", showDeadline()); |
399 | config.writeEntry( "ShowOverDue", showOverDue() ); | 399 | config.writeEntry( "ShowOverDue", showOverDue() ); |
400 | config.writeEntry( "ShowQuickTask", showQuickTask() ); | 400 | config.writeEntry( "ShowQuickTask", showQuickTask() ); |
401 | /* save templates */ | 401 | /* save templates */ |
402 | templateManager()->save(); | 402 | templateManager()->save(); |
403 | e->accept(); | 403 | e->accept(); |
404 | QTimer::singleShot(0, qApp, SLOT(closeAllWindows()) ); | 404 | QTimer::singleShot(0, qApp, SLOT(closeAllWindows()) ); |
405 | } | 405 | } |
406 | } | 406 | } |
407 | void MainWindow::populateTemplates() { | 407 | void MainWindow::populateTemplates() { |
408 | m_template->clear(); | 408 | m_template->clear(); |
409 | QStringList list = templateManager()->templates(); | 409 | QStringList list = templateManager()->templates(); |
410 | QStringList::Iterator it; | 410 | QStringList::Iterator it; |
411 | for ( it = list.begin(); it != list.end(); ++it ) { | 411 | for ( it = list.begin(); it != list.end(); ++it ) { |
412 | m_template->insertItem( (*it) ); | 412 | m_template->insertItem( (*it) ); |
413 | } | 413 | } |
414 | } | 414 | } |
415 | /* | 415 | /* |
416 | * slotNewFromTemplate | 416 | * slotNewFromTemplate |
417 | * We use the edit widget to do | 417 | * We use the edit widget to do |
418 | * the config but we setUid(1) | 418 | * the config but we setUid(1) |
419 | * to get a new uid | 419 | * to get a new uid |
420 | */ | 420 | */ |
421 | /* | 421 | /* |
422 | * first we get the name of the template | 422 | * first we get the name of the template |
423 | * then we will use the TemplateManager | 423 | * then we will use the TemplateManager |
424 | */ | 424 | */ |
425 | void MainWindow::slotNewFromTemplate( int id ) { | 425 | void MainWindow::slotNewFromTemplate( int id ) { |
426 | QString name = m_template->text( id ); | 426 | QString name = m_template->text( id ); |
427 | 427 | ||
428 | OPimTodo event = templateManager()->templateEvent( name ); | 428 | OPimTodo event = templateManager()->templateEvent( name ); |
429 | event = currentEditor()->edit(this, | 429 | event = currentEditor()->edit(this, |
430 | event ); | 430 | event ); |
431 | 431 | ||
432 | if ( currentEditor()->accepted() ) { | 432 | if ( currentEditor()->accepted() ) { |
433 | /* assign new todo */ | 433 | /* assign new todo */ |
434 | event.setUid( 1 ); | 434 | event.setUid( 1 ); |
435 | handleAlarms( OPimTodo(), event ); | 435 | handleAlarms( OPimTodo(), event ); |
436 | m_todoMgr.add( event ); | 436 | m_todoMgr.add( event ); |
437 | currentView()->addEvent( event ); | 437 | currentView()->addEvent( event ); |
438 | 438 | ||
439 | populateCategories(); | 439 | populateCategories(); |
440 | } | 440 | } |
441 | raiseCurrentView(); | 441 | raiseCurrentView(); |
442 | } | 442 | } |
443 | void MainWindow::slotNew() { | 443 | void MainWindow::slotNew() { |
444 | create(); | 444 | create(); |
445 | } | 445 | } |
446 | void MainWindow::slotDuplicate() { | 446 | void MainWindow::slotDuplicate() { |
447 | if(m_syncing) { | 447 | if(m_syncing) { |
448 | QMessageBox::warning(this, QWidget::tr("Todo"), | 448 | QMessageBox::warning(this, QWidget::tr("Todo"), |
449 | QWidget::tr("Data can not be edited, currently syncing")); | 449 | QWidget::tr("Data can not be edited, currently syncing")); |
450 | return; | 450 | return; |
451 | } | 451 | } |
452 | OPimTodo ev = m_todoMgr.event( currentView()->current() ); | 452 | OPimTodo ev = m_todoMgr.event( currentView()->current() ); |
453 | /* let's generate a new uid */ | 453 | /* let's generate a new uid */ |
454 | ev.setUid(1); | 454 | ev.setUid(1); |
455 | m_todoMgr.add( ev ); | 455 | m_todoMgr.add( ev ); |
456 | 456 | ||
457 | currentView()->addEvent( ev ); | 457 | currentView()->addEvent( ev ); |
458 | raiseCurrentView(); | 458 | raiseCurrentView(); |
459 | } | 459 | } |
460 | void MainWindow::slotDelete() { | 460 | void MainWindow::slotDelete() { |
461 | if (!currentView()->current() ) | 461 | if (!currentView()->current() ) |
462 | return; | 462 | return; |
463 | 463 | ||
464 | if(m_syncing) { | 464 | if(m_syncing) { |
465 | QMessageBox::warning(this, QWidget::tr("Todo"), | 465 | QMessageBox::warning(this, QWidget::tr("Todo"), |
466 | QWidget::tr("Data can not be edited, currently syncing")); | 466 | QWidget::tr("Data can not be edited, currently syncing")); |
467 | return; | 467 | return; |
468 | } | 468 | } |
469 | QString strName = currentView()->currentRepresentation(); | 469 | QString strName = currentView()->currentRepresentation(); |
470 | if (!QPEMessageBox::confirmDelete(this, QWidget::tr("Todo"), strName ) ) | 470 | if (!QPEMessageBox::confirmDelete(this, QWidget::tr("Todo"), strName ) ) |
471 | return; | 471 | return; |
472 | 472 | ||
473 | handleAlarms( m_todoMgr.event( currentView()->current() ), OPimTodo() ); | 473 | handleAlarms( m_todoMgr.event( currentView()->current() ), OPimTodo() ); |
474 | m_todoMgr.remove( currentView()->current() ); | 474 | m_todoMgr.remove( currentView()->current() ); |
475 | currentView()->removeEvent( currentView()->current() ); | 475 | currentView()->removeEvent( currentView()->current() ); |
476 | raiseCurrentView(); | 476 | raiseCurrentView(); |
477 | } | 477 | } |
478 | void MainWindow::slotDelete(int uid ) { | 478 | void MainWindow::slotDelete(int uid ) { |
479 | if( uid == 0 ) return; | 479 | if( uid == 0 ) return; |
480 | if(m_syncing) { | 480 | if(m_syncing) { |
481 | QMessageBox::warning(this, QWidget::tr("Todo"), | 481 | QMessageBox::warning(this, QWidget::tr("Todo"), |
482 | QWidget::tr("Data can not be edited, currently syncing")); | 482 | QWidget::tr("Data can not be edited, currently syncing")); |
483 | return; | 483 | return; |
484 | } | 484 | } |
485 | OPimTodo to = m_todoMgr.event(uid); | 485 | OPimTodo to = m_todoMgr.event(uid); |
486 | if (!QPEMessageBox::confirmDelete(this, QWidget::tr("Todo"), to.toShortText() ) ) | 486 | if (!QPEMessageBox::confirmDelete(this, QWidget::tr("Todo"), to.toShortText() ) ) |
487 | return; | 487 | return; |
488 | 488 | ||
489 | handleAlarms(to, OPimTodo() ); | 489 | handleAlarms(to, OPimTodo() ); |
490 | m_todoMgr.remove( to.uid() ); | 490 | m_todoMgr.remove( to.uid() ); |
491 | currentView()->removeEvent( to.uid() ); | 491 | currentView()->removeEvent( to.uid() ); |
492 | raiseCurrentView(); | 492 | raiseCurrentView(); |
493 | } | 493 | } |
494 | void MainWindow::slotDeleteAll() { | 494 | void MainWindow::slotDeleteAll() { |
495 | if(m_syncing) { | 495 | if(m_syncing) { |
496 | QMessageBox::warning(this, QWidget::tr("Todo"), | 496 | QMessageBox::warning(this, QWidget::tr("Todo"), |
497 | QWidget::tr("Data can not be edited, currently syncing")); | 497 | QWidget::tr("Data can not be edited, currently syncing")); |
498 | return; | 498 | return; |
499 | } | 499 | } |
500 | 500 | ||
501 | 501 | ||
502 | if ( !QPEMessageBox::confirmDelete( this, QWidget::tr( "Todo" ), QWidget::tr("all tasks?") ) ) | 502 | if ( !QPEMessageBox::confirmDelete( this, QWidget::tr( "Todo" ), QWidget::tr("all tasks?") ) ) |
503 | return; | 503 | return; |
504 | 504 | ||
505 | m_todoMgr.removeAll(); | 505 | m_todoMgr.removeAll(); |
506 | currentView()->clear(); | 506 | currentView()->clear(); |
507 | 507 | ||
508 | raiseCurrentView(); | 508 | raiseCurrentView(); |
509 | } | 509 | } |
510 | void MainWindow::slotDeleteCompleted() { | 510 | void MainWindow::slotDeleteCompleted() { |
511 | if(m_syncing) { | 511 | if(m_syncing) { |
512 | QMessageBox::warning(this, QWidget::tr("Todo"), | 512 | QMessageBox::warning(this, QWidget::tr("Todo"), |
513 | QWidget::tr("Data can not be edited, currently syncing")); | 513 | QWidget::tr("Data can not be edited, currently syncing")); |
514 | return; | 514 | return; |
515 | } | 515 | } |
516 | 516 | ||
517 | if ( !QPEMessageBox::confirmDelete( this, QWidget::tr( "Todo" ), QWidget::tr("all completed tasks?") ) ) | 517 | if ( !QPEMessageBox::confirmDelete( this, QWidget::tr( "Todo" ), QWidget::tr("all completed tasks?") ) ) |
518 | return; | 518 | return; |
519 | 519 | ||
520 | 520 | ||
521 | m_todoMgr.removeCompleted(); | 521 | m_todoMgr.removeCompleted(); |
522 | currentView()->updateView( ); | 522 | currentView()->updateView( ); |
523 | } | 523 | } |
524 | void MainWindow::slotFind() { | 524 | void MainWindow::slotFind() { |
525 | 525 | ||
526 | } | 526 | } |
527 | void MainWindow::slotEdit() { | 527 | void MainWindow::slotEdit() { |
528 | slotEdit( currentView()->current() ); | 528 | slotEdit( currentView()->current() ); |
529 | } | 529 | } |
530 | /* | 530 | /* |
531 | * set the category | 531 | * set the category |
532 | */ | 532 | */ |
533 | void MainWindow::setCategory( int c) { | 533 | void MainWindow::setCategory( int c) { |
534 | if ( c <= 0 ) return; | 534 | if ( c <= 0 ) return; |
535 | 535 | ||
536 | 536 | ||
537 | qWarning("Iterating over cats %d", c ); | 537 | qWarning("Iterating over cats %d", c ); |
538 | for ( unsigned int i = 1; i < m_catMenu->count(); i++ ) | 538 | for ( unsigned int i = 1; i < m_catMenu->count(); i++ ) |
539 | m_catMenu->setItemChecked(i, c == (int)i ); | 539 | m_catMenu->setItemChecked(i, c == (int)i ); |
540 | 540 | ||
541 | if (c == 1 ) { | 541 | if (c == 1 ) { |
542 | m_curCat = QString::null; | 542 | m_curCat = QString::null; |
543 | setCaption( QWidget::tr("Todo") + " - " + QWidget::tr("All Categories" ) ); | 543 | setCaption( QWidget::tr("Todo") + " - " + QWidget::tr("All Categories" ) ); |
544 | 544 | ||
545 | }else if ( c == (int)m_catMenu->count() - 1 ) { | 545 | }else if ( c == (int)m_catMenu->count() - 1 ) { |
546 | m_curCat = QWidget::tr("Unfiled"); | 546 | m_curCat = QWidget::tr("Unfiled"); |
547 | setCaption( QWidget::tr("Todo") + " - " + QWidget::tr("Unfiled") ); | 547 | setCaption( QWidget::tr("Todo") + " - " + QWidget::tr("Unfiled") ); |
548 | }else { | 548 | }else { |
549 | m_curCat = m_todoMgr.categories()[c-2]; | 549 | m_curCat = m_todoMgr.categories()[c-2]; |
550 | setCaption( QWidget::tr("Todo") + " - " + m_curCat ); | 550 | setCaption( QWidget::tr("Todo") + " - " + m_curCat ); |
551 | } | 551 | } |
552 | m_catMenu->setItemChecked( c, true ); | 552 | m_catMenu->setItemChecked( c, true ); |
553 | 553 | ||
554 | currentView()->setShowCategory( m_curCat ); | 554 | currentView()->setShowCategory( m_curCat ); |
555 | raiseCurrentView(); | 555 | raiseCurrentView(); |
556 | } | 556 | } |
557 | void MainWindow::slotShowDeadLine( bool dead) { | 557 | void MainWindow::slotShowDeadLine( bool dead) { |
558 | m_deadline = dead; | 558 | m_deadline = dead; |
559 | currentView()->setShowDeadline( dead ); | 559 | currentView()->setShowDeadline( dead ); |
560 | } | 560 | } |
561 | void MainWindow::slotShowCompleted( bool show) { | 561 | void MainWindow::slotShowCompleted( bool show) { |
562 | m_completed = show; | 562 | m_completed = show; |
563 | currentView()->setShowCompleted( m_completed ); | 563 | currentView()->setShowCompleted( m_completed ); |
564 | } | 564 | } |
565 | void MainWindow::slotShowQuickTask( bool show ) { | 565 | void MainWindow::slotShowQuickTask( bool show ) { |
566 | m_quicktask = show; | 566 | m_quicktask = show; |
567 | if ( m_quicktask ) | 567 | if ( m_quicktask ) |
568 | m_curQuick->widget()->show(); | 568 | m_curQuick->widget()->show(); |
569 | else | 569 | else |
570 | m_curQuick->widget()->hide(); | 570 | m_curQuick->widget()->hide(); |
571 | } | 571 | } |
572 | bool MainWindow::showOverDue()const { | 572 | bool MainWindow::showOverDue()const { |
573 | return m_overdue; | 573 | return m_overdue; |
574 | } | 574 | } |
575 | void MainWindow::setDocument( const QString& fi) { | 575 | void MainWindow::setDocument( const QString& fi) { |
576 | DocLnk doc(fi); | 576 | DocLnk doc(fi); |
577 | if (doc.isValid() ) | 577 | if (doc.isValid() ) |
578 | receiveFile(doc.file() ); | 578 | receiveFile(doc.file() ); |
579 | else | 579 | else |
580 | receiveFile(fi ); | 580 | receiveFile(fi ); |
581 | } | 581 | } |
582 | 582 | ||
583 | static const char *beamfile = "/tmp/opie-todo.vcs"; | 583 | static const char *beamfile = "/tmp/opie-todo.vcs"; |
584 | void MainWindow::slotBeam() { | 584 | void MainWindow::slotBeam() { |
585 | beam( currentView()->current() ); | 585 | beam( currentView()->current() ); |
586 | } | 586 | } |
587 | void MainWindow::beamDone( Ir* ir) { | 587 | void MainWindow::beamDone( Ir* ir) { |
588 | delete ir; | 588 | delete ir; |
589 | ::unlink( beamfile ); | 589 | ::unlink( beamfile ); |
590 | } | 590 | } |
591 | void MainWindow::receiveFile( const QString& filename ) { | 591 | void MainWindow::receiveFile( const QString& filename ) { |
592 | OPimTodoAccessVCal* cal = new OPimTodoAccessVCal(filename ); | 592 | OPimTodoAccessVCal* cal = new OPimTodoAccessVCal(filename ); |
593 | 593 | ||
594 | OPimTodoAccess acc( cal ); | 594 | OPimTodoAccess acc( cal ); |
595 | acc.load(); | 595 | acc.load(); |
596 | OPimTodoAccess::List list = acc.allRecords(); | 596 | OPimTodoAccess::List list = acc.allRecords(); |
597 | 597 | ||
598 | if (list.count()){ | 598 | if (list.count()){ |
599 | 599 | ||
600 | QString message = QWidget::tr("<P>%1 new tasks arrived.<p>Would you like to add them to your Todolist?").arg(list.count() ); | 600 | QString message = QWidget::tr("<P>%1 new tasks arrived.<p>Would you like to add them to your Todolist?").arg(list.count() ); |
601 | 601 | ||
602 | if ( QMessageBox::information(this, QWidget::tr("New Tasks"), | 602 | if ( QMessageBox::information(this, QWidget::tr("New Tasks"), |
603 | message, QMessageBox::Ok, | 603 | message, QMessageBox::Ok, |
604 | QMessageBox::Cancel ) == QMessageBox::Ok ) { | 604 | QMessageBox::Cancel ) == QMessageBox::Ok ) { |
605 | OPimTodoAccess::List::Iterator it; | 605 | OPimTodoAccess::List::Iterator it; |
606 | for ( it = list.begin(); it != list.end(); ++it ) | 606 | for ( it = list.begin(); it != list.end(); ++it ) |
607 | m_todoMgr.add( (*it) ); | 607 | m_todoMgr.add( (*it) ); |
608 | 608 | ||
609 | currentView()->updateView(); | 609 | currentView()->updateView(); |
610 | } | 610 | } |
611 | } | 611 | } |
612 | } | 612 | } |
613 | 613 | ||
614 | void MainWindow::slotFlush() { | 614 | void MainWindow::slotFlush() { |
615 | m_syncing = TRUE; | 615 | m_syncing = TRUE; |
616 | m_todoMgr.save(); | 616 | m_todoMgr.save(); |
617 | } | 617 | } |
618 | void MainWindow::slotShowDetails() { | 618 | void MainWindow::slotShowDetails() { |
619 | slotShow( currentView()->current() ); | 619 | slotShow( currentView()->current() ); |
620 | } | 620 | } |
621 | /* | 621 | /* |
622 | * populate the Categories | 622 | * populate the Categories |
623 | * Menu | 623 | * Menu |
624 | */ | 624 | */ |
625 | void MainWindow::populateCategories() { | 625 | void MainWindow::populateCategories() { |
626 | m_todoMgr.load(); | 626 | m_todoMgr.load(); |
627 | 627 | ||
628 | m_catMenu->clear(); | 628 | m_catMenu->clear(); |
629 | int id, rememberId; | 629 | int id, rememberId; |
630 | id = 1; | 630 | id = 1; |
631 | rememberId = 1; | 631 | rememberId = 1; |
632 | 632 | ||
633 | m_catMenu->insertItem( QWidget::tr( "All Categories" ), id++ ); | 633 | m_catMenu->insertItem( QWidget::tr( "All Categories" ), id++ ); |
634 | m_catMenu->insertSeparator(); | 634 | m_catMenu->insertSeparator(); |
635 | QStringList categories = m_todoMgr.categories(); | 635 | QStringList categories = m_todoMgr.categories(); |
636 | categories.append( QWidget::tr( "Unfiled" ) ); | 636 | categories.append( QWidget::tr( "Unfiled" ) ); |
637 | for ( QStringList::Iterator it = categories.begin(); | 637 | for ( QStringList::Iterator it = categories.begin(); |
638 | it != categories.end(); ++it ) { | 638 | it != categories.end(); ++it ) { |
639 | m_catMenu->insertItem( *it, id ); | 639 | m_catMenu->insertItem( *it, id ); |
640 | if ( *it == currentCategory() ) | 640 | if ( *it == currentCategory() ) |
641 | rememberId = id; | 641 | rememberId = id; |
642 | ++id; | 642 | ++id; |
643 | } | 643 | } |
644 | setCategory( rememberId ); | 644 | setCategory( rememberId ); |
645 | } | 645 | } |
646 | bool MainWindow::showCompleted()const { | 646 | bool MainWindow::showCompleted()const { |
647 | return m_completed; | 647 | return m_completed; |
648 | } | 648 | } |
649 | bool MainWindow::showDeadline()const { | 649 | bool MainWindow::showDeadline()const { |
650 | return m_deadline; | 650 | return m_deadline; |
651 | } | 651 | } |
652 | bool MainWindow::showQuickTask()const { | 652 | bool MainWindow::showQuickTask()const { |
653 | return m_quicktask; | 653 | return m_quicktask; |
654 | } | 654 | } |
655 | QString MainWindow::currentCategory()const { | 655 | QString MainWindow::currentCategory()const { |
656 | return m_curCat; | 656 | return m_curCat; |
657 | } | 657 | } |
658 | int MainWindow::currentCatId() { | 658 | int MainWindow::currentCatId() { |
659 | return m_todoMgr.catId( m_curCat ); | 659 | return m_todoMgr.catId( m_curCat ); |
660 | } | 660 | } |
661 | ViewBase* MainWindow::currentView() { | 661 | ViewBase* MainWindow::currentView() { |
662 | return m_curView; | 662 | return m_curView; |
663 | } | 663 | } |
664 | void MainWindow::raiseCurrentView() { | 664 | void MainWindow::raiseCurrentView() { |
665 | // due QPE/Application/todolist show(int) | 665 | // due QPE/Application/todolist show(int) |
666 | // we might not have the populateCategories slot called once | 666 | // we might not have the populateCategories slot called once |
667 | // we would show the otodo but then imediately switch to the currentView | 667 | // we would show the otodo but then imediately switch to the currentView |
668 | // if we're initially showing we shouldn't raise the table | 668 | // if we're initially showing we shouldn't raise the table |
669 | // in returnFromView we fix up m_showing | 669 | // in returnFromView we fix up m_showing |
670 | if (m_showing ) return; | 670 | if (m_showing ) return; |
671 | 671 | ||
672 | m_stack->raiseWidget( m_curView->widget() ); | 672 | m_stack->raiseWidget( m_curView->widget() ); |
673 | } | 673 | } |
674 | void MainWindow::slotShowDue(bool ov) { | 674 | void MainWindow::slotShowDue(bool ov) { |
675 | m_overdue = ov; | 675 | m_overdue = ov; |
676 | currentView()->showOverDue( ov ); | 676 | currentView()->showOverDue( ov ); |
677 | raiseCurrentView(); | 677 | raiseCurrentView(); |
678 | } | 678 | } |
679 | void MainWindow::slotShow( int uid ) { | 679 | void MainWindow::slotShow( int uid ) { |
680 | if ( uid == 0 ) return; | 680 | if ( uid == 0 ) return; |
681 | qWarning("slotShow"); | 681 | qWarning("slotShow"); |
682 | currentShow()->slotShow( event( uid ) ); | 682 | currentShow()->slotShow( event( uid ) ); |
683 | m_stack->raiseWidget( currentShow()->widget() ); | 683 | m_stack->raiseWidget( currentShow()->widget() ); |
684 | } | 684 | } |
685 | void MainWindow::slotShowNext() { | 685 | void MainWindow::slotShowNext() { |
686 | int l = currentView()->next(); | 686 | int l = currentView()->next(); |
687 | if (l!=0) | 687 | if (l!=0) |
688 | slotShow(l); | 688 | slotShow(l); |
689 | } | 689 | } |
690 | void MainWindow::slotShowPrev() { | 690 | void MainWindow::slotShowPrev() { |
691 | int l = currentView()->prev(); | 691 | int l = currentView()->prev(); |
692 | if (l!=0) | 692 | if (l!=0) |
693 | slotShow(l); | 693 | slotShow(l); |
694 | } | 694 | } |
695 | void MainWindow::slotEdit( int uid ) { | 695 | void MainWindow::slotEdit( int uid ) { |
696 | if (uid == 0 ) return; | 696 | if (uid == 0 ) return; |
697 | if(m_syncing) { | 697 | if(m_syncing) { |
698 | QMessageBox::warning(this, QWidget::tr("Todo"), | 698 | QMessageBox::warning(this, QWidget::tr("Todo"), |
699 | QWidget::tr("Data can't be edited, currently syncing")); | 699 | QWidget::tr("Data can't be edited, currently syncing")); |
700 | return; | 700 | return; |
701 | } | 701 | } |
702 | 702 | ||
703 | OPimTodo old_todo = m_todoMgr.event( uid ); | 703 | OPimTodo old_todo = m_todoMgr.event( uid ); |
704 | 704 | ||
705 | OPimTodo todo = currentEditor()->edit(this, old_todo ); | 705 | OPimTodo todo = currentEditor()->edit(this, old_todo ); |
706 | 706 | ||
707 | /* if completed */ | 707 | /* if completed */ |
708 | if ( currentEditor()->accepted() ) { | 708 | if ( currentEditor()->accepted() ) { |
709 | handleAlarms( old_todo, todo ); | 709 | handleAlarms( old_todo, todo ); |
710 | m_todoMgr.update( todo.uid(), todo ); | 710 | m_todoMgr.update( todo.uid(), todo ); |
711 | currentView()->replaceEvent( todo ); | 711 | currentView()->replaceEvent( todo ); |
712 | /* a Category might have changed */ | 712 | /* a Category might have changed */ |
713 | populateCategories(); | 713 | populateCategories(); |
714 | } | 714 | } |
715 | 715 | ||
716 | raiseCurrentView(); | 716 | raiseCurrentView(); |
717 | } | 717 | } |
718 | /* | 718 | /* |
719 | void MainWindow::slotUpdate1( int uid, const SmallTodo& ev) { | 719 | void MainWindow::slotUpdate1( int uid, const SmallTodo& ev) { |
720 | m_todoMgr.update( uid, ev ); | 720 | m_todoMgr.update( uid, ev ); |
721 | } | 721 | } |
722 | */ | 722 | */ |
723 | void MainWindow::updateTodo( const OPimTodo& ev) { | 723 | void MainWindow::updateTodo( const OPimTodo& ev) { |
724 | m_todoMgr.update( ev.uid() , ev ); | 724 | m_todoMgr.update( ev.uid() , ev ); |
725 | } | 725 | } |
726 | /* The view changed it's configuration | 726 | /* The view changed it's configuration |
727 | * update the view menu | 727 | * update the view menu |
728 | */ | 728 | */ |
729 | void MainWindow::slotUpdate3( QWidget* ) { | 729 | void MainWindow::slotUpdate3( QWidget* ) { |
730 | 730 | ||
731 | } | 731 | } |
732 | void MainWindow::updateList() { | 732 | void MainWindow::updateList() { |
733 | m_todoMgr.updateList(); | 733 | m_todoMgr.updateList(); |
734 | } | 734 | } |
735 | void MainWindow::setReadAhead( uint count ) { | 735 | void MainWindow::setReadAhead( uint count ) { |
736 | if (m_todoMgr.todoDB() ) | 736 | if (m_todoMgr.todoDB() ) |
737 | m_todoMgr.todoDB()->setReadAhead( count ); | 737 | m_todoMgr.todoDB()->setReadAhead( count ); |
738 | } | 738 | } |
739 | void MainWindow::slotQuickEntered() { | 739 | void MainWindow::slotQuickEntered() { |
740 | qWarning("entered"); | 740 | qWarning("entered"); |
741 | OPimTodo todo = quickEditor()->todo(); | 741 | OPimTodo todo = quickEditor()->todo(); |
742 | if (todo.isEmpty() ) | 742 | if (todo.isEmpty() ) |
743 | return; | 743 | return; |
744 | 744 | ||
745 | m_todoMgr.add( todo ); | 745 | m_todoMgr.add( todo ); |
746 | currentView()->addEvent( todo ); | 746 | currentView()->addEvent( todo ); |
747 | raiseCurrentView(); | 747 | raiseCurrentView(); |
748 | } | 748 | } |
749 | QuickEditBase* MainWindow::quickEditor() { | 749 | QuickEditBase* MainWindow::quickEditor() { |
750 | return m_curQuick; | 750 | return m_curQuick; |
751 | } | 751 | } |
752 | void MainWindow::slotComplete( int uid ) { | 752 | void MainWindow::slotComplete( int uid ) { |
753 | slotComplete( event(uid) ); | 753 | slotComplete( event(uid) ); |
754 | } | 754 | } |
755 | void MainWindow::slotComplete( const OPimTodo& todo ) { | 755 | void MainWindow::slotComplete( const OPimTodo& todo ) { |
756 | OPimTodo to = todo; | 756 | OPimTodo to = todo; |
757 | to.setCompleted( !to.isCompleted() ); | 757 | to.setCompleted( !to.isCompleted() ); |
758 | to.setCompletedDate( QDate::currentDate() ); | 758 | to.setCompletedDate( QDate::currentDate() ); |
759 | 759 | ||
760 | /* | 760 | /* |
761 | * if the item does recur | 761 | * if the item does recur |
762 | * we need to spin it off | 762 | * we need to spin it off |
763 | * and update the items duedate to the next | 763 | * and update the items duedate to the next |
764 | * possible recurrance of this item... | 764 | * possible recurrance of this item... |
765 | * the spinned off one will loose the | 765 | * the spinned off one will loose the |
766 | * recurrence. | 766 | * recurrence. |
767 | * We calculate the difference between the old due date and the | 767 | * We calculate the difference between the old due date and the |
768 | * new one and add this diff to start, completed and alarm dates | 768 | * new one and add this diff to start, completed and alarm dates |
769 | * -zecke | 769 | * -zecke |
770 | */ | 770 | */ |
771 | if ( to.hasRecurrence() && to.isCompleted() ) { | 771 | if ( to.hasRecurrence() && to.isCompleted() ) { |
772 | OPimTodo to2( to ); | 772 | OPimTodo to2( to ); |
773 | 773 | ||
774 | /* the spinned off one won't recur anymore */ | 774 | /* the spinned off one won't recur anymore */ |
775 | to.setRecurrence( OPimRecurrence() ); | 775 | to.setRecurrence( OPimRecurrence() ); |
776 | 776 | ||
777 | OPimRecurrence rec = to2.recurrence(); | 777 | OPimRecurrence rec = to2.recurrence(); |
778 | rec.setStart( to.dueDate() ); | 778 | rec.setStart( to.dueDate() ); |
779 | to2.setRecurrence( rec ); | 779 | to2.setRecurrence( rec ); |
780 | /* | 780 | /* |
781 | * if there is a next occurence | 781 | * if there is a next occurence |
782 | * from the duedate of the last recurrance | 782 | * from the duedate of the last recurrance |
783 | */ | 783 | */ |
784 | QDate date; | 784 | QDate date; |
785 | if ( to2.recurrence().nextOcurrence( to2.dueDate().addDays(1), date ) ) { | 785 | if ( to2.recurrence().nextOcurrence( to2.dueDate().addDays(1), date ) ) { |
786 | int dayDiff = to.dueDate().daysTo( date ); | 786 | int dayDiff = to.dueDate().daysTo( date ); |
787 | qWarning("day diff is %d", dayDiff ); | 787 | qWarning("day diff is %d", dayDiff ); |
788 | QDate inval; | 788 | QDate inval; |
789 | /* generate a new uid for the old record */ | 789 | /* generate a new uid for the old record */ |
790 | to.setUid( 1 ); | 790 | to.setUid( 1 ); |
791 | 791 | ||
792 | /* add the old one cause it has a new UID here cause it was spin off */ | 792 | /* add the old one cause it has a new UID here cause it was spin off */ |
793 | m_todoMgr.add( to ); | 793 | m_todoMgr.add( to ); |
794 | 794 | ||
795 | /* | 795 | /* |
796 | * update the due date | 796 | * update the due date |
797 | * start date | 797 | * start date |
798 | * and complete date | 798 | * and complete date |
799 | */ | 799 | */ |
800 | to2.setDueDate( date ); | 800 | to2.setDueDate( date ); |
801 | rec.setStart( date ); | 801 | rec.setStart( date ); |
802 | to2.setRecurrence( rec ); // could be Monday, TuesDay, Thursday every week | 802 | to2.setRecurrence( rec ); // could be Monday, TuesDay, Thursday every week |
803 | 803 | ||
804 | /* move start date */ | 804 | /* move start date */ |
805 | if (to2.hasStartDate() ) | 805 | if (to2.hasStartDate() ) |
806 | to2.setStartDate( to2.startDate().addDays( dayDiff ) ); | 806 | to2.setStartDate( to2.startDate().addDays( dayDiff ) ); |
807 | 807 | ||
808 | /* now the alarms */ | 808 | /* now the alarms */ |
809 | if (to2.hasNotifiers() ) { | 809 | if (to2.hasNotifiers() ) { |
810 | OPimNotifyManager::Alarms _als = to2.notifiers().alarms(); | 810 | OPimNotifyManager::Alarms _als = to2.notifiers().alarms(); |
811 | OPimNotifyManager::Alarms als; | 811 | OPimNotifyManager::Alarms als; |
812 | 812 | ||
813 | /* for every alarm move the day */ | 813 | /* for every alarm move the day */ |
814 | for ( OPimNotifyManager::Alarms::Iterator it = _als.begin(); it != _als.end(); ++it ) { | 814 | for ( OPimNotifyManager::Alarms::Iterator it = _als.begin(); it != _als.end(); ++it ) { |
815 | OPimAlarm al = (*it); | 815 | OPimAlarm al = (*it); |
816 | al.setDateTime( al.dateTime().addDays( dayDiff ) ); | 816 | al.setDateTime( al.dateTime().addDays( dayDiff ) ); |
817 | als.append( al ); | 817 | als.append( al ); |
818 | } | 818 | } |
819 | to2.notifiers().setAlarms( als ); | 819 | to2.notifiers().setAlarms( als ); |
820 | handleAlarms( OPimTodo(), todo ); | 820 | handleAlarms( OPimTodo(), todo ); |
821 | } | 821 | } |
822 | to2.setCompletedDate( inval ); | 822 | to2.setCompletedDate( inval ); |
823 | to2.setCompleted( false ); | 823 | to2.setCompleted( false ); |
824 | 824 | ||
825 | updateTodo( to2 ); | 825 | updateTodo( to2 ); |
826 | }else | 826 | }else |
827 | updateTodo( to ); | 827 | updateTodo( to ); |
828 | }else | 828 | }else |
829 | updateTodo( to ); | 829 | updateTodo( to ); |
830 | 830 | ||
831 | currentView()->updateView(); | 831 | currentView()->updateView(); |
832 | raiseCurrentView(); | 832 | raiseCurrentView(); |
833 | } | 833 | } |
834 | void MainWindow::flush() { | 834 | void MainWindow::flush() { |
835 | slotFlush(); | 835 | slotFlush(); |
diff --git a/core/pim/todo/mainwindow.h b/core/pim/todo/mainwindow.h index 6a7296b..b35a42b 100644 --- a/core/pim/todo/mainwindow.h +++ b/core/pim/todo/mainwindow.h | |||
@@ -1,213 +1,211 @@ | |||
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 Holger Freyther <zecke@handhelds.org> | 3 | .=l. Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
4 | .>+-= | 4 | .>+-= |
5 | _;:, .> :=|. This program is free software; you can | 5 | _;:, .> :=|. This program is free software; you can |
6 | .> <`_, > . <= redistribute it and/or modify it under | 6 | .> <`_, > . <= redistribute it and/or modify it under |
7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
8 | .="- .-=="i, .._ License as published by the Free Software | 8 | .="- .-=="i, .._ License as published by the Free Software |
9 | - . .-<_> .<> Foundation; either version 2 of the License, | 9 | - . .-<_> .<> Foundation; either version 2 of the License, |
10 | ._= =} : or (at your option) any later version. | 10 | ._= =} : or (at your option) any later version. |
11 | .%`+i> _;_. | 11 | .%`+i> _;_. |
12 | .i_,=:_. -<s. This program is distributed in the hope that | 12 | .i_,=:_. -<s. This program is distributed in the hope that |
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
14 | : .. .:, . . . without even the implied warranty of | 14 | : .. .:, . . . without even the implied warranty of |
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
17 | ..}^=.= = ; Library General Public License for more | 17 | ..}^=.= = ; Library General Public License for more |
18 | ++= -. .` .: details. | 18 | ++= -. .` .: details. |
19 | : = ...= . :.=- | 19 | : = ...= . :.=- |
20 | -. .:....=;==+<; You should have received a copy of the GNU | 20 | -. .:....=;==+<; You should have received a copy of the GNU |
21 | -_. . . )=. = Library General Public License along with | 21 | -_. . . )=. = Library General Public License along with |
22 | -- :-=` this library; see the file COPYING.LIB. | 22 | -- :-=` this library; see the file COPYING.LIB. |
23 | If not, write to the Free Software Foundation, | 23 | If not, write to the Free Software Foundation, |
24 | Inc., 59 Temple Place - Suite 330, | 24 | Inc., 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | 28 | ||
29 | #ifndef TODO_MAIN_WINDOW_H | 29 | #ifndef TODO_MAIN_WINDOW_H |
30 | #define TODO_MAIN_WINDOW_H | 30 | #define TODO_MAIN_WINDOW_H |
31 | 31 | ||
32 | #include <qlist.h> | 32 | #include <qlist.h> |
33 | 33 | ||
34 | #include <opie2/otodoaccess.h> | 34 | #include <opie2/otodoaccess.h> |
35 | #include <opie2/opimtodo.h> | 35 | #include <opie2/opimtodo.h> |
36 | #include <opie2/opimmainwindow.h> | 36 | #include <opie2/opimmainwindow.h> |
37 | #include <opie2/owidgetstack.h> | 37 | #include <opie2/owidgetstack.h> |
38 | 38 | ||
39 | #include "smalltodo.h" | 39 | #include "smalltodo.h" |
40 | #include "todoview.h" | 40 | #include "todoview.h" |
41 | #include "quickedit.h" | 41 | #include "quickedit.h" |
42 | #include "todomanager.h" | 42 | #include "todomanager.h" |
43 | 43 | ||
44 | class QPopupMenu; | 44 | class QPopupMenu; |
45 | class QMenuBar; | 45 | class QMenuBar; |
46 | class QToolBar; | 46 | class QToolBar; |
47 | class QAction; | 47 | class QAction; |
48 | class Ir; | 48 | class Ir; |
49 | class QVBox; | 49 | class QVBox; |
50 | class QLineEdit; | 50 | class QLineEdit; |
51 | 51 | ||
52 | using namespace Opie; | ||
53 | |||
54 | namespace Todo { | 52 | namespace Todo { |
55 | typedef TodoView View; | 53 | typedef TodoView View; |
56 | class TemplateManager; | 54 | class TemplateManager; |
57 | class Editor; | 55 | class Editor; |
58 | class TodoShow; | 56 | class TodoShow; |
59 | class TemplateEditor; | 57 | class TemplateEditor; |
60 | struct QuickEditBase; | 58 | struct QuickEditBase; |
61 | 59 | ||
62 | class MainWindow : public OPimMainWindow { | 60 | class MainWindow : public Opie::OPimMainWindow { |
63 | Q_OBJECT | 61 | Q_OBJECT |
64 | friend class TodoView; // avoid QObject here.... | 62 | friend class TodoView; // avoid QObject here.... |
65 | friend class TodoShow; // avoid QObject | 63 | friend class TodoShow; // avoid QObject |
66 | public: | 64 | public: |
67 | /* OApplicationFactory application Name */ | 65 | /* OApplicationFactory application Name */ |
68 | static QString appName() { return QString::fromLatin1("todolist"); } | 66 | static QString appName() { return QString::fromLatin1("todolist"); } |
69 | 67 | ||
70 | MainWindow( QWidget *parent = 0, | 68 | MainWindow( QWidget *parent = 0, |
71 | const char* name = 0, WFlags fl = 0 ); | 69 | const char* name = 0, WFlags fl = 0 ); |
72 | ~MainWindow(); | 70 | ~MainWindow(); |
73 | 71 | ||
74 | /** return a context menu for an OPimTodo */ | 72 | /** return a context menu for an OPimTodo */ |
75 | QPopupMenu* contextMenu(int uid, bool doesRecur = FALSE ); | 73 | QPopupMenu* contextMenu(int uid, bool doesRecur = FALSE ); |
76 | QPopupMenu* options(); | 74 | QPopupMenu* options(); |
77 | QPopupMenu* edit(); | 75 | QPopupMenu* edit(); |
78 | QToolBar* toolbar(); | 76 | QToolBar* toolbar(); |
79 | 77 | ||
80 | 78 | ||
81 | void updateList(); | 79 | void updateList(); |
82 | OPimTodoAccess::List list()const; | 80 | OPimTodoAccess::List list()const; |
83 | OPimTodoAccess::List sorted( bool asc, int sortOrder ); | 81 | OPimTodoAccess::List sorted( bool asc, int sortOrder ); |
84 | OPimTodoAccess::List sorted( bool asc, int sortOrder, int addFilter ); | 82 | OPimTodoAccess::List sorted( bool asc, int sortOrder, int addFilter ); |
85 | 83 | ||
86 | OPimTodo event(int uid ); | 84 | OPimTodo event(int uid ); |
87 | 85 | ||
88 | bool isSyncing()const; | 86 | bool isSyncing()const; |
89 | bool showCompleted()const; | 87 | bool showCompleted()const; |
90 | bool showDeadline()const; | 88 | bool showDeadline()const; |
91 | bool showOverDue()const; | 89 | bool showOverDue()const; |
92 | bool showQuickTask()const; | 90 | bool showQuickTask()const; |
93 | QString currentCategory()const; | 91 | QString currentCategory()const; |
94 | int currentCatId(); | 92 | int currentCatId(); |
95 | TemplateManager* templateManager(); | 93 | TemplateManager* templateManager(); |
96 | QuickEditBase* quickEditor(); | 94 | QuickEditBase* quickEditor(); |
97 | 95 | ||
98 | void updateTodo( const OPimTodo& ); | 96 | void updateTodo( const OPimTodo& ); |
99 | void populateTemplates(); | 97 | void populateTemplates(); |
100 | Editor* currentEditor(); | 98 | Editor* currentEditor(); |
101 | void setReadAhead(uint count ); | 99 | void setReadAhead(uint count ); |
102 | private slots: | 100 | private slots: |
103 | void slotQuickEntered(); | 101 | void slotQuickEntered(); |
104 | void populateCategories(); | 102 | void populateCategories(); |
105 | void slotReload(); | 103 | void slotReload(); |
106 | void slotFlush(); | 104 | void slotFlush(); |
107 | 105 | ||
108 | protected: | 106 | protected: |
109 | void closeEvent( QCloseEvent* e ); | 107 | void closeEvent( QCloseEvent* e ); |
110 | 108 | ||
111 | private: | 109 | private: |
112 | /* handle setting and removing alarms */ | 110 | /* handle setting and removing alarms */ |
113 | void handleAlarms( const OPimTodo& oldTodo, const OPimTodo& newTodo ); | 111 | void handleAlarms( const OPimTodo& oldTodo, const OPimTodo& newTodo ); |
114 | void receiveFile( const QString& filename ); | 112 | void receiveFile( const QString& filename ); |
115 | void connectBase( ViewBase* ); | 113 | void connectBase( ViewBase* ); |
116 | void initUI(); | 114 | void initUI(); |
117 | void initActions(); | 115 | void initActions(); |
118 | void initConfig(); | 116 | void initConfig(); |
119 | void initViews(); | 117 | void initViews(); |
120 | void initEditor(); | 118 | void initEditor(); |
121 | void initShow(); | 119 | void initShow(); |
122 | void initTemplate(); | 120 | void initTemplate(); |
123 | void raiseCurrentView(); | 121 | void raiseCurrentView(); |
124 | ViewBase* currentView(); | 122 | ViewBase* currentView(); |
125 | ViewBase* m_curView; | 123 | ViewBase* m_curView; |
126 | bool m_showing : 1; // used to see if we show a todo in the cases we shouldn't change the table | 124 | bool m_showing : 1; // used to see if we show a todo in the cases we shouldn't change the table |
127 | QuickEditBase* m_curQuick; | 125 | QuickEditBase* m_curQuick; |
128 | Editor* m_curEdit; | 126 | Editor* m_curEdit; |
129 | TodoShow* currentShow(); | 127 | TodoShow* currentShow(); |
130 | TodoShow* m_curShow; | 128 | TodoShow* m_curShow; |
131 | TemplateEditor* currentTemplateEditor(); | 129 | TemplateEditor* currentTemplateEditor(); |
132 | TemplateEditor* m_curTempEd; | 130 | TemplateEditor* m_curTempEd; |
133 | 131 | ||
134 | QMenuBar* m_bar; | 132 | QMenuBar* m_bar; |
135 | QToolBar* m_tool; | 133 | QToolBar* m_tool; |
136 | QAction* m_editAction, | 134 | QAction* m_editAction, |
137 | *m_deleteAction, | 135 | *m_deleteAction, |
138 | *m_findAction, | 136 | *m_findAction, |
139 | *m_completedAction, | 137 | *m_completedAction, |
140 | *m_showDeadLineAction, | 138 | *m_showDeadLineAction, |
141 | *m_deleteAllAction, | 139 | *m_deleteAllAction, |
142 | *m_deleteCompleteAction, | 140 | *m_deleteCompleteAction, |
143 | *m_duplicateAction, | 141 | *m_duplicateAction, |
144 | *m_showOverDueAction, | 142 | *m_showOverDueAction, |
145 | *m_showQuickTaskAction, | 143 | *m_showQuickTaskAction, |
146 | *m_effectiveAction; | 144 | *m_effectiveAction; |
147 | OWidgetStack *m_stack; | 145 | Opie::OWidgetStack *m_stack; |
148 | QPopupMenu* m_catMenu, | 146 | QPopupMenu* m_catMenu, |
149 | *m_edit, | 147 | *m_edit, |
150 | *m_options, | 148 | *m_options, |
151 | *m_template; | 149 | *m_template; |
152 | 150 | ||
153 | bool m_syncing:1; | 151 | bool m_syncing:1; |
154 | bool m_deadline:1; | 152 | bool m_deadline:1; |
155 | bool m_completed:1; | 153 | bool m_completed:1; |
156 | bool m_overdue:1; | 154 | bool m_overdue:1; |
157 | bool m_quicktask:1; | 155 | bool m_quicktask:1; |
158 | TodoManager m_todoMgr; | 156 | TodoManager m_todoMgr; |
159 | QString m_curCat; | 157 | QString m_curCat; |
160 | QList<ViewBase> m_views; | 158 | QList<ViewBase> m_views; |
161 | uint m_counter; | 159 | uint m_counter; |
162 | TemplateManager* m_tempManager; | 160 | TemplateManager* m_tempManager; |
163 | 161 | ||
164 | 162 | ||
165 | private slots: | 163 | private slots: |
166 | void slotShow(int); | 164 | void slotShow(int); |
167 | void slotEdit(int); | 165 | void slotEdit(int); |
168 | void slotUpdate3( QWidget* ); | 166 | void slotUpdate3( QWidget* ); |
169 | void slotComplete( int uid ); | 167 | void slotComplete( int uid ); |
170 | void slotComplete( const OPimTodo& ev ); | 168 | void slotComplete( const OPimTodo& ev ); |
171 | void slotNewFromTemplate(int id ); | 169 | void slotNewFromTemplate(int id ); |
172 | void slotNew(); | 170 | void slotNew(); |
173 | void slotDuplicate(); | 171 | void slotDuplicate(); |
174 | 172 | ||
175 | void slotDelete(); | 173 | void slotDelete(); |
176 | void slotDelete(int uid ); | 174 | void slotDelete(int uid ); |
177 | void slotDeleteAll(); | 175 | void slotDeleteAll(); |
178 | void slotDeleteCompleted(); | 176 | void slotDeleteCompleted(); |
179 | 177 | ||
180 | void slotEdit(); | 178 | void slotEdit(); |
181 | void slotFind(); | 179 | void slotFind(); |
182 | 180 | ||
183 | void setCategory( int ); | 181 | void setCategory( int ); |
184 | 182 | ||
185 | void slotShowDeadLine( bool ); | 183 | void slotShowDeadLine( bool ); |
186 | void slotShowCompleted( bool ); | 184 | void slotShowCompleted( bool ); |
187 | void slotShowQuickTask( bool ); | 185 | void slotShowQuickTask( bool ); |
188 | 186 | ||
189 | void setDocument( const QString& ); | 187 | void setDocument( const QString& ); |
190 | 188 | ||
191 | 189 | ||
192 | void slotBeam(); | 190 | void slotBeam(); |
193 | void beamDone( Ir* ); | 191 | void beamDone( Ir* ); |
194 | void slotShowDetails(); | 192 | void slotShowDetails(); |
195 | void slotShowNext(); | 193 | void slotShowNext(); |
196 | void slotShowPrev(); | 194 | void slotShowPrev(); |
197 | void slotShowDue( bool ); | 195 | void slotShowDue( bool ); |
198 | void slotReturnFromView(); // for TodoShow... | 196 | void slotReturnFromView(); // for TodoShow... |
199 | /* reimplementation from opimmainwindow */ | 197 | /* reimplementation from opimmainwindow */ |
200 | protected slots: | 198 | protected slots: |
201 | void flush(); | 199 | void flush(); |
202 | void reload(); | 200 | void reload(); |
203 | int create(); | 201 | int create(); |
204 | bool remove( int uid ); | 202 | bool remove( int uid ); |
205 | void beam(int uid); | 203 | void beam(int uid); |
206 | void show( int uid ); | 204 | void show( int uid ); |
207 | void edit( int uid ); | 205 | void edit( int uid ); |
208 | void add( const OPimRecord& ); | 206 | void add( const Opie::OPimRecord& ); |
209 | void doAlarm( const QDateTime& dt, int uid ); | 207 | void doAlarm( const QDateTime& dt, int uid ); |
210 | }; | 208 | }; |
211 | } | 209 | } |
212 | 210 | ||
213 | #endif | 211 | #endif |
diff --git a/core/pim/todo/quickeditimpl.cpp b/core/pim/todo/quickeditimpl.cpp index cd0684f..94ae97e 100644 --- a/core/pim/todo/quickeditimpl.cpp +++ b/core/pim/todo/quickeditimpl.cpp | |||
@@ -1,116 +1,116 @@ | |||
1 | #include <qaction.h> | 1 | #include <qaction.h> |
2 | #include <qlineedit.h> | 2 | #include <qlineedit.h> |
3 | #include <qwhatsthis.h> | 3 | #include <qwhatsthis.h> |
4 | 4 | ||
5 | #include <qpe/resource.h> | 5 | #include <qpe/resource.h> |
6 | 6 | ||
7 | #include <opie2/oclickablelabel.h> | 7 | #include <opie2/oclickablelabel.h> |
8 | 8 | ||
9 | #include "mainwindow.h" | 9 | #include "mainwindow.h" |
10 | #include "quickeditimpl.h" | 10 | #include "quickeditimpl.h" |
11 | 11 | ||
12 | 12 | ||
13 | QuickEditImpl::QuickEditImpl( QWidget* parent, bool visible ) | 13 | QuickEditImpl::QuickEditImpl( QWidget* parent, bool visible ) |
14 | : QToolBar( (QMainWindow *)parent ), Todo::QuickEdit( (Todo::MainWindow *)parent ) { | 14 | : QToolBar( (QMainWindow *)parent ), Todo::QuickEdit( (Todo::MainWindow *)parent ) { |
15 | setHorizontalStretchable( TRUE ); | 15 | setHorizontalStretchable( TRUE ); |
16 | 16 | ||
17 | // Load priority icons | 17 | // Load priority icons |
18 | // TODO - probably should be done globally somewhere else, | 18 | // TODO - probably should be done globally somewhere else, |
19 | // see also tableview.cpp/h, taskeditoroverview.cpp/h | 19 | // see also tableview.cpp/h, taskeditoroverview.cpp/h |
20 | priority1 = Resource::loadPixmap( "todo/priority1" ); | 20 | priority1 = Resource::loadPixmap( "todo/priority1" ); |
21 | priority3 = Resource::loadPixmap( "todo/priority3" ); | 21 | priority3 = Resource::loadPixmap( "todo/priority3" ); |
22 | priority5 = Resource::loadPixmap( "todo/priority5" ); | 22 | priority5 = Resource::loadPixmap( "todo/priority5" ); |
23 | 23 | ||
24 | m_lbl = new OClickableLabel( this ); | 24 | m_lbl = new Opie::OClickableLabel( this ); |
25 | m_lbl->setMinimumWidth( 15 ); | 25 | m_lbl->setMinimumWidth( 15 ); |
26 | m_lbl->setPixmap( priority3 ); | 26 | m_lbl->setPixmap( priority3 ); |
27 | connect(m_lbl, SIGNAL(clicked() ), this, SLOT(slotPrio()) ); | 27 | connect(m_lbl, SIGNAL(clicked() ), this, SLOT(slotPrio()) ); |
28 | QWhatsThis::add( m_lbl, QWidget::tr( "Click here to set the priority of new task.\n\nThis area is called the quick task bar.\n\nIt allows you to quickly add a new task to your list. This area can be shown or hidden by selecting Options->'Show quick task bar' from the menu above." ) ); | 28 | QWhatsThis::add( m_lbl, QWidget::tr( "Click here to set the priority of new task.\n\nThis area is called the quick task bar.\n\nIt allows you to quickly add a new task to your list. This area can be shown or hidden by selecting Options->'Show quick task bar' from the menu above." ) ); |
29 | 29 | ||
30 | m_edit = new QLineEdit( this ); | 30 | m_edit = new QLineEdit( this ); |
31 | setStretchableWidget( m_edit ); | 31 | setStretchableWidget( m_edit ); |
32 | QWhatsThis::add( m_edit, QWidget::tr( "Enter description of new task here.\n\nThis area is called the quick task bar.\n\nIt allows you to quickly add a new task to your list. This area can be shown or hidden by selecting Options->'Show quick task bar' from the menu above." ) ); | 32 | QWhatsThis::add( m_edit, QWidget::tr( "Enter description of new task here.\n\nThis area is called the quick task bar.\n\nIt allows you to quickly add a new task to your list. This area can be shown or hidden by selecting Options->'Show quick task bar' from the menu above." ) ); |
33 | 33 | ||
34 | /* | 34 | /* |
35 | * it's not implemented and won't be implemented for 1.0 | 35 | * it's not implemented and won't be implemented for 1.0 |
36 | */ | 36 | */ |
37 | #if 0 | 37 | #if 0 |
38 | QAction *a = new QAction( QWidget::tr( "More" ), Resource::loadPixmap( "todo/more" ), QString::null, 0, this, 0 ); | 38 | QAction *a = new QAction( QWidget::tr( "More" ), Resource::loadPixmap( "todo/more" ), QString::null, 0, this, 0 ); |
39 | connect( a, SIGNAL( activated() ), this, SLOT( slotMore() ) ); | 39 | connect( a, SIGNAL( activated() ), this, SLOT( slotMore() ) ); |
40 | a->addTo( this ); | 40 | a->addTo( this ); |
41 | a->setWhatsThis( QWidget::tr( "Click here to enter additional information for new task.\n\nThis area is called the quick task bar.\n\nIt allows you to quickly add a new task to your list. This area can be shown or hidden by selecting Options->'Show quick task bar' from the menu above." ) ); | 41 | a->setWhatsThis( QWidget::tr( "Click here to enter additional information for new task.\n\nThis area is called the quick task bar.\n\nIt allows you to quickly add a new task to your list. This area can be shown or hidden by selecting Options->'Show quick task bar' from the menu above." ) ); |
42 | #endif | 42 | #endif |
43 | 43 | ||
44 | QAction *a = new QAction( QWidget::tr( "Enter" ), Resource::loadPixmap( "enter" ), QString::null, 0, this, 0 ); | 44 | QAction *a = new QAction( QWidget::tr( "Enter" ), Resource::loadPixmap( "enter" ), QString::null, 0, this, 0 ); |
45 | connect( a, SIGNAL( activated() ), this, SLOT( slotEnter() ) ); | 45 | connect( a, SIGNAL( activated() ), this, SLOT( slotEnter() ) ); |
46 | a->addTo( this ); | 46 | a->addTo( this ); |
47 | a->setWhatsThis( QWidget::tr( "Click here to add new task.\n\nThis area is called the quick task bar.\n\nIt allows you to quickly add a new task to your list. This area can be shown or hidden by selecting Options->'Show quick task bar' from the menu above." ) ); | 47 | a->setWhatsThis( QWidget::tr( "Click here to add new task.\n\nThis area is called the quick task bar.\n\nIt allows you to quickly add a new task to your list. This area can be shown or hidden by selecting Options->'Show quick task bar' from the menu above." ) ); |
48 | 48 | ||
49 | a = new QAction( QWidget::tr( "Cancel" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 49 | a = new QAction( QWidget::tr( "Cancel" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); |
50 | connect( a, SIGNAL( activated() ), this, SLOT( slotCancel() ) ); | 50 | connect( a, SIGNAL( activated() ), this, SLOT( slotCancel() ) ); |
51 | a->addTo( this ); | 51 | a->addTo( this ); |
52 | a->setWhatsThis( QWidget::tr( "Click here to reset new task information.\n\nThis area is called the quick task bar.\n\nIt allows you to quickly add a new task to your list. This area can be shown or hidden by selecting Options->'Show quick task bar' from the menu above." ) ); | 52 | a->setWhatsThis( QWidget::tr( "Click here to reset new task information.\n\nThis area is called the quick task bar.\n\nIt allows you to quickly add a new task to your list. This area can be shown or hidden by selecting Options->'Show quick task bar' from the menu above." ) ); |
53 | 53 | ||
54 | m_visible = visible; | 54 | m_visible = visible; |
55 | if ( !m_visible ) { | 55 | if ( !m_visible ) { |
56 | hide(); | 56 | hide(); |
57 | } | 57 | } |
58 | 58 | ||
59 | m_menu = 0l; | 59 | m_menu = 0l; |
60 | reinit(); | 60 | reinit(); |
61 | } | 61 | } |
62 | QuickEditImpl::~QuickEditImpl() { | 62 | QuickEditImpl::~QuickEditImpl() { |
63 | 63 | ||
64 | } | 64 | } |
65 | OPimTodo QuickEditImpl::todo()const { | 65 | OPimTodo QuickEditImpl::todo()const { |
66 | return m_todo; | 66 | return m_todo; |
67 | } | 67 | } |
68 | QWidget* QuickEditImpl::widget() { | 68 | QWidget* QuickEditImpl::widget() { |
69 | return this; | 69 | return this; |
70 | } | 70 | } |
71 | void QuickEditImpl::slotEnter() { | 71 | void QuickEditImpl::slotEnter() { |
72 | OPimTodo todo; | 72 | OPimTodo todo; |
73 | 73 | ||
74 | 74 | ||
75 | if (!m_edit->text().isEmpty() ) { | 75 | if (!m_edit->text().isEmpty() ) { |
76 | todo.setUid(1 ); // new uid | 76 | todo.setUid(1 ); // new uid |
77 | todo.setPriority( m_state ); | 77 | todo.setPriority( m_state ); |
78 | todo.setSummary( m_edit->text() ); | 78 | todo.setSummary( m_edit->text() ); |
79 | if ( ((Todo::MainWindow *)parent())->currentCatId() != 0 ) | 79 | if ( ((Todo::MainWindow *)parent())->currentCatId() != 0 ) |
80 | todo.setCategories( ((Todo::MainWindow *)parent())->currentCatId() ); | 80 | todo.setCategories( ((Todo::MainWindow *)parent())->currentCatId() ); |
81 | 81 | ||
82 | m_todo = todo; | 82 | m_todo = todo; |
83 | commit(); | 83 | commit(); |
84 | } | 84 | } |
85 | m_todo = todo; | 85 | m_todo = todo; |
86 | reinit(); | 86 | reinit(); |
87 | } | 87 | } |
88 | void QuickEditImpl::slotPrio() { | 88 | void QuickEditImpl::slotPrio() { |
89 | m_state -= 2; | 89 | m_state -= 2; |
90 | if ( m_state < 1 ) | 90 | if ( m_state < 1 ) |
91 | m_state = 5; | 91 | m_state = 5; |
92 | 92 | ||
93 | switch( m_state ) { | 93 | switch( m_state ) { |
94 | case 1: | 94 | case 1: |
95 | m_lbl->setPixmap( priority1 ); | 95 | m_lbl->setPixmap( priority1 ); |
96 | break; | 96 | break; |
97 | case 5: | 97 | case 5: |
98 | m_lbl->setPixmap( priority5 ); | 98 | m_lbl->setPixmap( priority5 ); |
99 | break; | 99 | break; |
100 | case 3: | 100 | case 3: |
101 | default: | 101 | default: |
102 | m_lbl->setPixmap( priority3 ); | 102 | m_lbl->setPixmap( priority3 ); |
103 | break; | 103 | break; |
104 | } | 104 | } |
105 | } | 105 | } |
106 | void QuickEditImpl::slotMore() { | 106 | void QuickEditImpl::slotMore() { |
107 | // TODO - implement | 107 | // TODO - implement |
108 | } | 108 | } |
109 | void QuickEditImpl::slotCancel() { | 109 | void QuickEditImpl::slotCancel() { |
110 | reinit(); | 110 | reinit(); |
111 | } | 111 | } |
112 | void QuickEditImpl::reinit() { | 112 | void QuickEditImpl::reinit() { |
113 | m_state = 3; | 113 | m_state = 3; |
114 | m_lbl->setPixmap( priority3 ); | 114 | m_lbl->setPixmap( priority3 ); |
115 | m_edit->clear(); | 115 | m_edit->clear(); |
116 | } | 116 | } |