-rw-r--r-- | core/pim/todo/mainwindow.cpp | 425 | ||||
-rw-r--r-- | core/pim/todo/mainwindow.h | 77 | ||||
-rw-r--r-- | core/pim/todo/newtaskdlg.cpp | 78 | ||||
-rw-r--r-- | core/pim/todo/newtaskdlg.h | 56 | ||||
-rw-r--r-- | core/pim/todo/tableview.cpp | 88 | ||||
-rw-r--r-- | core/pim/todo/tableview.h | 52 | ||||
-rw-r--r-- | core/pim/todo/templateeditor.cpp | 38 | ||||
-rw-r--r-- | core/pim/todo/templateeditor.h | 31 | ||||
-rw-r--r-- | core/pim/todo/todo.pro | 8 | ||||
-rw-r--r-- | core/pim/todo/todomanager.cpp | 43 |
10 files changed, 375 insertions, 521 deletions
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp index 9424c23..75da27c 100644 --- a/core/pim/todo/mainwindow.cpp +++ b/core/pim/todo/mainwindow.cpp | |||
@@ -1,1032 +1,859 @@ | |||
1 | /* | 1 | /* |
2 | =. This file is part of the OPIE Project | 2 | =. This file is part of the OPIE Project |
3 | .=l. Copyright (c) 2002 <> | 3 | .=l. Copyright (c) 2002 <> |
4 | .>+-= | 4 | .>+-= |
5 | _;:, .> :=|. This program is free software; you can | 5 | _;:, .> :=|. This program is free software; you can |
6 | .> <`_, > . <= redistribute it and/or modify it under | 6 | .> <`_, > . <= redistribute it and/or modify it under |
7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
8 | .="- .-=="i, .._ License as published by the Free Software | 8 | .="- .-=="i, .._ License as published by the Free Software |
9 | - . .-<_> .<> Foundation; either version 2 of the License, | 9 | - . .-<_> .<> Foundation; either version 2 of the License, |
10 | ._= =} : or (at your option) any later version. | 10 | ._= =} : or (at your option) any later version. |
11 | .%`+i> _;_. | 11 | .%`+i> _;_. |
12 | .i_,=:_. -<s. This program is distributed in the hope that | 12 | .i_,=:_. -<s. This program is distributed in the hope that |
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
14 | : .. .:, . . . without even the implied warranty of | 14 | : .. .:, . . . without even the implied warranty of |
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
17 | ..}^=.= = ; Library General Public License for more | 17 | ..}^=.= = ; Library General Public License for more |
18 | ++= -. .` .: details. | 18 | ++= -. .` .: details. |
19 | : = ...= . :.=- | 19 | : = ...= . :.=- |
20 | -. .:....=;==+<; You should have received a copy of the GNU | 20 | -. .:....=;==+<; You should have received a copy of the GNU |
21 | -_. . . )=. = General Public License along with | 21 | -_. . . )=. = General Public License along with |
22 | -- :-=` this library; see the file COPYING.LIB. | 22 | -- :-=` this library; see the file COPYING.LIB. |
23 | If not, write to the Free Software Foundation, | 23 | If not, write to the Free Software Foundation, |
24 | Inc., 59 Temple Place - Suite 330, | 24 | Inc., 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include <unistd.h> | 29 | #include <unistd.h> |
30 | 30 | ||
31 | #include <opie2/odebug.h> | 31 | #include <opie2/odebug.h> |
32 | #include <opie2/opimrecurrence.h> | 32 | #include <opie2/opimrecurrence.h> |
33 | #include <opie2/opimnotifymanager.h> | 33 | #include <opie2/opimnotifymanager.h> |
34 | #include <opie2/otodoaccessvcal.h> | 34 | #include <opie2/otodoaccessvcal.h> |
35 | #include <opie2/oapplicationfactory.h> | 35 | #include <opie2/oapplicationfactory.h> |
36 | 36 | ||
37 | #include <qpe/applnk.h> | 37 | #include <qpe/applnk.h> |
38 | #include <qpe/config.h> | 38 | #include <qpe/config.h> |
39 | #include <qpe/ir.h> | 39 | #include <qpe/ir.h> |
40 | #include <qpe/resource.h> | 40 | #include <qpe/resource.h> |
41 | #include <qpe/qpemessagebox.h> | 41 | #include <qpe/qpemessagebox.h> |
42 | #include <qpe/alarmserver.h> | 42 | #include <qpe/alarmserver.h> |
43 | #include <qpe/qpeapplication.h> | 43 | #include <qpe/qpeapplication.h> |
44 | 44 | ||
45 | #include <qaction.h> | ||
46 | #include <qlayout.h> | ||
45 | #include <qmenubar.h> | 47 | #include <qmenubar.h> |
46 | #include <qmessagebox.h> | 48 | #include <qmessagebox.h> |
47 | #include <qpushbutton.h> | 49 | #include <qpushbutton.h> |
48 | #include <qaction.h> | 50 | #include <qstringlist.h> |
49 | #include <qtimer.h> | 51 | #include <qtimer.h> |
50 | #include <qlayout.h> | ||
51 | #include <qwhatsthis.h> | 52 | #include <qwhatsthis.h> |
52 | 53 | ||
53 | #include "quickeditimpl.h" | 54 | #include "quickeditimpl.h" |
54 | #include "todotemplatemanager.h" | 55 | #include "todotemplatemanager.h" |
55 | #include "templateeditor.h" | 56 | #include "templatedialogimpl.h" |
56 | #include "tableview.h" | 57 | #include "tableview.h" |
57 | 58 | ||
58 | #include "textviewshow.h" | 59 | #include "textviewshow.h" |
59 | #include "todoeditor.h" | 60 | #include "todoeditor.h" |
61 | #include "newtaskdlg.h" | ||
60 | #include "mainwindow.h" | 62 | #include "mainwindow.h" |
61 | 63 | ||
62 | using Opie::Core::OApplicationFactory; | 64 | using Opie::Core::OApplicationFactory; |
63 | OPIE_EXPORT_APP( OApplicationFactory<Todo::MainWindow> ) | 65 | OPIE_EXPORT_APP( OApplicationFactory<Todo::MainWindow> ) |
64 | 66 | ||
65 | using namespace Opie; | 67 | using namespace Opie; |
66 | using namespace Todo; | 68 | using namespace Todo; |
67 | 69 | ||
68 | MainWindow::MainWindow( QWidget* parent, | 70 | MainWindow::MainWindow( QWidget* parent, |
69 | const char* name, WFlags ) | 71 | const char* name, WFlags ) |
70 | : Opie::OPimMainWindow( "Todolist", parent, name, WType_TopLevel | WStyle_ContextHelp ) | 72 | : Opie::OPimMainWindow( "Todolist", tr( "Todo List" ), "Todo List", tr( "Task" ), "todo", |
73 | parent, name, WType_TopLevel | WStyle_ContextHelp ) | ||
71 | { | 74 | { |
72 | if (!name) | 75 | if (!name) |
73 | setName("todo window"); | 76 | setName("todo window"); |
74 | 77 | ||
75 | m_syncing = false; | 78 | m_syncing = false; |
76 | m_showing = false; | 79 | m_showing = false; |
77 | m_counter = 0; | 80 | m_counter = 0; |
78 | m_tempManager = new TemplateManager(); | 81 | m_tempManager = new TemplateManager(); |
79 | m_tempManager->load(); | 82 | m_tempManager->load(); |
80 | 83 | ||
81 | initUI(); | ||
82 | initConfig(); | 84 | initConfig(); |
85 | initUI(); | ||
83 | initViews(); | 86 | initViews(); |
84 | initActions(); | 87 | initActions(); |
85 | initEditor(); | 88 | initEditor(); |
86 | initShow(); | 89 | initShow(); |
87 | initTemplate(); | ||
88 | 90 | ||
89 | populateTemplates(); | ||
90 | raiseCurrentView(); | 91 | raiseCurrentView(); |
91 | QTimer::singleShot(0, this, SLOT(populateCategories() ) ); | 92 | QTimer::singleShot( 0, this, SLOT(initStuff()) ); |
92 | } | 93 | } |
93 | void MainWindow::initTemplate() { | 94 | void MainWindow::initStuff() { |
94 | m_curTempEd = new TemplateEditor( this, templateManager() ); | 95 | m_todoMgr.load(); |
96 | setViewCategory( m_curCat ); | ||
97 | setCategory( m_curCat ); | ||
95 | } | 98 | } |
96 | void MainWindow::initActions() { | 99 | void MainWindow::initActions() { |
97 | 100 | // Insert Task menu items | |
98 | // Data menu | 101 | QActionGroup *items = new QActionGroup( this, QString::null, false ); |
99 | m_edit->insertItem(QWidget::tr("New from template"), m_template, | 102 | |
100 | -1, 0 ); | 103 | m_deleteCompleteAction = new QAction( QString::null, QWidget::tr( "Delete completed" ), |
101 | 104 | 0, items, 0 ); | |
102 | QAction* a = new QAction( QWidget::tr("New Task" ), Resource::loadPixmap( "new" ), | 105 | connect( m_deleteCompleteAction, SIGNAL(activated()), this, SLOT(slotDeleteCompleted()) ); |
103 | QString::null, 0, this, 0 ); | 106 | |
104 | connect(a, SIGNAL( activated() ), | 107 | insertItemMenuItems( items ); |
105 | this, SLOT( slotNew() ) ); | 108 | |
106 | a->setWhatsThis( QWidget::tr( "Click here to create a new task." ) ); | 109 | // Insert View menu items |
107 | a->addTo(m_tool ); | 110 | items = new QActionGroup( this, QString::null, false ); |
108 | a->addTo(m_edit ); | 111 | |
109 | |||
110 | a = new QAction( QWidget::tr("Edit Task"), Resource::loadIconSet( "edit" ), | ||
111 | QString::null, 0, this, 0 ); | ||
112 | connect(a, SIGNAL(activated() ), | ||
113 | this, SLOT( slotEdit() ) ); | ||
114 | a->setWhatsThis( QWidget::tr( "Click here to modify the current task." ) ); | ||
115 | a->addTo( m_tool ); | ||
116 | a->addTo( m_edit ); | ||
117 | m_editAction = a; | ||
118 | |||
119 | a = new QAction( QString::null, QWidget::tr("View Task"), 0, this, 0 ); | ||
120 | connect(a, SIGNAL( activated() ), | ||
121 | this, SLOT( slotShowDetails() ) ); | ||
122 | a->addTo( m_edit ); | ||
123 | |||
124 | m_edit->insertSeparator(); | ||
125 | |||
126 | a = new QAction( QWidget::tr("Delete..."), Resource::loadIconSet( "trash" ), | ||
127 | QString::null, 0, this, 0 ); | ||
128 | connect(a, SIGNAL(activated() ), | ||
129 | this, SLOT(slotDelete() ) ); | ||
130 | a->setWhatsThis( QWidget::tr( "Click here to remove the current task." ) ); | ||
131 | a->addTo( m_tool ); | ||
132 | a->addTo( m_edit ); | ||
133 | m_deleteAction = a; | ||
134 | |||
135 | a = new QAction( QString::null, QWidget::tr("Delete all..."), 0, this, 0 ); | ||
136 | connect(a, SIGNAL( activated() ), | ||
137 | this, SLOT( slotDeleteAll() ) ); | ||
138 | a->addTo(m_edit ); | ||
139 | m_deleteAllAction = a; | ||
140 | |||
141 | a = new QAction( QString::null, QWidget::tr("Delete completed"), | ||
142 | 0, this, 0 ); | ||
143 | connect(a, SIGNAL( activated() ), | ||
144 | this, SLOT( slotDeleteCompleted() ) ); | ||
145 | a->addTo(m_edit ); | ||
146 | a->setEnabled( TRUE ); | ||
147 | m_deleteCompleteAction = a; | ||
148 | |||
149 | m_edit->insertSeparator(); | ||
150 | |||
151 | a = new QAction( QString::null, QWidget::tr("Duplicate"), 0, this, 0 ); | ||
152 | connect(a, SIGNAL( activated() ), | ||
153 | this, SLOT( slotDuplicate() ) ); | ||
154 | a->addTo(m_edit ); | ||
155 | m_duplicateAction = a; | ||
156 | |||
157 | m_edit->insertSeparator(); | ||
158 | |||
159 | if ( Ir::supported() ) { | ||
160 | a = new QAction( QWidget::tr( "Beam" ), Resource::loadPixmap( "beam" ), QString::null, 0, this, 0 ); | ||
161 | connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) ); | ||
162 | a->setWhatsThis( QWidget::tr( "Click here to send the current task to another device." ) ); | ||
163 | a->addTo( m_edit ); | ||
164 | a->addTo( m_tool ); | ||
165 | } | ||
166 | |||
167 | #if 0 | ||
168 | // Options menu | ||
169 | a = new QAction( QWidget::tr("Find"), Resource::loadIconSet( "mag" ), | ||
170 | QString::null, 0, this, 0 ); | ||
171 | connect(a, SIGNAL( activated() ), this, SLOT( slotFind() ) ); | ||
172 | a->addTo( m_options ); | ||
173 | m_findAction = a; | ||
174 | |||
175 | |||
176 | m_options->insertSeparator(); | ||
177 | #endif | ||
178 | |||
179 | m_completedAction = new QAction( QString::null, QWidget::tr("Show completed tasks"), | 112 | m_completedAction = new QAction( QString::null, QWidget::tr("Show completed tasks"), |
180 | 0, this, 0, TRUE ); | 113 | 0, items, 0, true ); |
181 | m_completedAction->addTo( m_options ); | ||
182 | m_completedAction->setOn( showCompleted() ); | 114 | m_completedAction->setOn( showCompleted() ); |
183 | connect(m_completedAction, SIGNAL( toggled(bool) ), this, SLOT(slotShowCompleted(bool) ) ); | 115 | connect( m_completedAction, SIGNAL(toggled(bool)), this, SLOT(slotShowCompleted(bool)) ); |
184 | 116 | ||
185 | a = new QAction( QString::null, QWidget::tr("Show only over-due tasks"), | 117 | QAction *a = new QAction( QString::null, QWidget::tr("Show only over-due tasks"), |
186 | 0, this, 0, TRUE ); | 118 | 0, items, 0, true ); |
187 | a->addTo( m_options ); | ||
188 | a->setOn( showOverDue() ); | 119 | a->setOn( showOverDue() ); |
189 | connect(a, SIGNAL(toggled(bool)), this, SLOT(slotShowDue(bool) ) ); | 120 | connect( a, SIGNAL(toggled(bool)), this, SLOT(slotShowDue(bool)) ); |
190 | 121 | ||
191 | m_showDeadLineAction = new QAction( QString::null, QWidget::tr("Show task deadlines"), | 122 | m_showDeadLineAction = new QAction( QString::null, QWidget::tr("Show task deadlines"), |
192 | 0, this, 0, TRUE ); | 123 | 0, items, 0, true ); |
193 | m_showDeadLineAction->addTo( m_options ); | ||
194 | m_showDeadLineAction->setOn( showDeadline() ); | 124 | m_showDeadLineAction->setOn( showDeadline() ); |
195 | connect(m_showDeadLineAction, SIGNAL(toggled(bool) ), this, SLOT( slotShowDeadLine(bool) ) ); | 125 | connect( m_showDeadLineAction, SIGNAL(toggled(bool)), this, SLOT(slotShowDeadLine(bool)) ); |
196 | 126 | ||
197 | m_showQuickTaskAction = new QAction( QString::null, QWidget::tr("Show quick task bar"), | 127 | m_showQuickTaskAction = new QAction( QString::null, QWidget::tr("Show quick task bar"), |
198 | 0, this, 0, TRUE ); | 128 | 0, items, 0, true ); |
199 | m_showQuickTaskAction->addTo( m_options ); | ||
200 | m_showQuickTaskAction->setOn( showQuickTask() ); | 129 | m_showQuickTaskAction->setOn( showQuickTask() ); |
201 | connect(m_showQuickTaskAction, SIGNAL( toggled(bool) ), this, SLOT(slotShowQuickTask(bool) ) ); | 130 | connect( m_showQuickTaskAction, SIGNAL(toggled(bool)), this, SLOT(slotShowQuickTask(bool)) ); |
202 | 131 | ||
203 | m_options->insertSeparator(); | 132 | insertViewMenuItems( items ); |
204 | |||
205 | m_bar->insertItem( QWidget::tr("Data") ,m_edit ); | ||
206 | m_bar->insertItem( QWidget::tr("Category"), m_catMenu ); | ||
207 | m_bar->insertItem( QWidget::tr("Options"), m_options ); | ||
208 | |||
209 | m_curQuick = new QuickEditImpl( this, m_quicktask ); | ||
210 | addToolBar( (QToolBar *)m_curQuick->widget(), QWidget::tr( "QuickEdit" ), QMainWindow::Top, TRUE ); | ||
211 | m_curQuick->signal()->connect( this, SLOT(slotQuickEntered() ) ); | ||
212 | |||
213 | } | 133 | } |
214 | /* m_curCat from Config */ | 134 | /* m_curCat from Config */ |
215 | void MainWindow::initConfig() { | 135 | void MainWindow::initConfig() { |
216 | Config config( "todo" ); | 136 | Config config( "todo" ); |
217 | config.setGroup( "View" ); | 137 | config.setGroup( "View" ); |
218 | m_completed = config.readBoolEntry( "ShowComplete", TRUE ); | 138 | m_completed = config.readBoolEntry( "ShowComplete", true ); |
219 | m_curCat = config.readEntry( "Category", QString::null ); | 139 | m_curCat = config.readEntry( "Category", QString::null ); |
220 | m_deadline = config.readBoolEntry( "ShowDeadLine", TRUE); | 140 | m_deadline = config.readBoolEntry( "ShowDeadLine", true); |
221 | m_overdue = config.readBoolEntry("ShowOverDue", FALSE ); | 141 | m_overdue = config.readBoolEntry("ShowOverDue", false ); |
222 | m_quicktask = config.readBoolEntry("ShowQuickTask", TRUE); | 142 | m_quicktask = config.readBoolEntry("ShowQuickTask", true); |
223 | } | 143 | } |
224 | void MainWindow::initUI() { | 144 | void MainWindow::initUI() { |
225 | 145 | // Create main widget stack | |
226 | m_stack = new Opie::Ui::OWidgetStack(this, "main stack"); | 146 | m_stack = new Opie::Ui::OWidgetStack(this, "main stack"); |
227 | |||
228 | setCentralWidget( m_stack ); | 147 | setCentralWidget( m_stack ); |
229 | 148 | connect( this, SIGNAL(categorySelected(const QString&)), | |
230 | setToolBarsMovable( FALSE ); | 149 | this, SLOT(setCategory(const QString&)) ); |
231 | 150 | ||
232 | QToolBar *menubarholder = new QToolBar( this ); | 151 | // Create quick task toolbar |
233 | menubarholder->setHorizontalStretchable( TRUE ); | 152 | m_curQuick = new QuickEditImpl( this, m_quicktask ); |
234 | m_bar = new QMenuBar( menubarholder ); | 153 | addToolBar( (QToolBar *)m_curQuick->widget(), QWidget::tr( "QuickEdit" ), |
235 | 154 | QMainWindow::Top, true ); | |
236 | m_tool = new QToolBar( this ); | 155 | m_curQuick->signal()->connect( this, SLOT(slotQuickEntered()) ); |
237 | |||
238 | /** QPopupMenu */ | ||
239 | m_edit = new QPopupMenu( this ); | ||
240 | m_options = new QPopupMenu( this ); | ||
241 | m_catMenu = new QPopupMenu( this ); | ||
242 | m_template = new QPopupMenu( this ); | ||
243 | |||
244 | m_catMenu->setCheckable( TRUE ); | ||
245 | m_template->setCheckable( TRUE ); | ||
246 | |||
247 | connect(m_catMenu, SIGNAL(activated(int) ), | ||
248 | this, SLOT(setCategory(int) ) ); | ||
249 | connect(m_template, SIGNAL(activated(int) ), | ||
250 | this, SLOT(slotNewFromTemplate(int) ) ); | ||
251 | } | 156 | } |
252 | void MainWindow::initViews() { | 157 | void MainWindow::initViews() { |
253 | 158 | ||
254 | TableView* tableView = new TableView( this, m_stack ); | 159 | 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." ) ); | 160 | QWhatsThis::add( tableView, QWidget::tr( "This is a listing of all current tasks.\n\nThe list displays the following information:\n1. Completed - A green checkmark indicates task is completed. Click here to complete a task.\n2. Priority - a graphical representation of task priority. Double-click here to modify.\n3. Description - description of task. Click here to select the task.\n4. Deadline - shows when task is due. This column can be shown or hidden by selecting Options->'Show task deadlines' from the menu above." ) ); |
256 | m_stack->addWidget( tableView, m_counter++ ); | 161 | m_stack->addWidget( tableView, m_counter++ ); |
257 | m_views.append( tableView ); | 162 | m_views.append( tableView ); |
258 | m_curView = tableView; | 163 | m_curView = tableView; |
259 | connectBase( tableView ); | 164 | connectBase( tableView ); |
260 | /* add QString type + QString configname to | 165 | /* add QString type + QString configname to |
261 | * the View menu | 166 | * the View menu |
262 | * and subdirs for multiple views | 167 | * and subdirs for multiple views |
263 | */ | 168 | */ |
264 | } | 169 | } |
265 | void MainWindow::initEditor() { | 170 | void MainWindow::initEditor() { |
266 | m_curEdit = new Editor(); | 171 | m_curEdit = new Editor(); |
267 | } | 172 | } |
268 | void MainWindow::initShow() { | 173 | void MainWindow::initShow() { |
269 | m_curShow = new TextViewShow(this, this); | 174 | m_curShow = new TextViewShow(this, this); |
270 | m_stack->addWidget( m_curShow->widget() , m_counter++ ); | 175 | m_stack->addWidget( m_curShow->widget() , m_counter++ ); |
271 | } | 176 | } |
272 | MainWindow::~MainWindow() { | 177 | MainWindow::~MainWindow() { |
273 | delete templateManager(); | 178 | delete templateManager(); |
274 | } | 179 | } |
275 | void MainWindow::connectBase( ViewBase* ) { | 180 | void MainWindow::connectBase( ViewBase* ) { |
276 | // once templates and signals mix we'll use it again | 181 | // once templates and signals mix we'll use it again |
277 | } | 182 | } |
278 | QPopupMenu* MainWindow::contextMenu( int , bool recur ) { | 183 | QPopupMenu* MainWindow::contextMenu( int , bool /*recur*/ ) { |
279 | QPopupMenu* menu = new QPopupMenu(); | 184 | return itemContextMenu(); |
280 | |||
281 | m_editAction->addTo( menu ); | ||
282 | m_deleteAction->addTo( menu ); | ||
283 | m_duplicateAction->addTo( menu ); | ||
284 | |||
285 | menu->insertSeparator(); | ||
286 | |||
287 | /* | ||
288 | * if this event recurs we allow | ||
289 | * to detach it. | ||
290 | * remove all | ||
291 | */ | ||
292 | if ( recur ) { | ||
293 | ; // FIXME | ||
294 | } | ||
295 | |||
296 | return menu; | ||
297 | } | ||
298 | QPopupMenu* MainWindow::options() { | ||
299 | return m_options; | ||
300 | } | ||
301 | QPopupMenu* MainWindow::edit() { | ||
302 | return m_edit; | ||
303 | } | ||
304 | QToolBar* MainWindow::toolbar() { | ||
305 | return m_tool; | ||
306 | } | 185 | } |
307 | OPimTodoAccess::List MainWindow::list()const { | 186 | OPimTodoAccess::List MainWindow::list()const { |
308 | return m_todoMgr.list(); | 187 | return m_todoMgr.list(); |
309 | } | 188 | } |
310 | OPimTodoAccess::List MainWindow::sorted( bool asc, int sortOrder ) { | 189 | OPimTodoAccess::List MainWindow::sorted( bool asc, int sortOrder ) { |
311 | int cat = 0; | 190 | int cat = 0; |
312 | if ( m_curCat != QWidget::tr("All Categories") ) | 191 | if ( m_curCat != tr( "All" ) ) |
313 | cat = currentCatId(); | 192 | cat = currentCatId(); |
314 | if ( m_curCat == QWidget::tr("Unfiled") ) | 193 | if ( m_curCat == tr( "Unfiled" ) ) |
315 | cat = -1; | 194 | cat = -1; |
316 | 195 | ||
317 | int filter = OPimTodoAccess::FilterCategory; | 196 | int filter = OPimTodoAccess::FilterCategory; |
318 | 197 | ||
319 | if (!m_completed ) | 198 | if (!m_completed ) |
320 | filter |= OPimTodoAccess::DoNotShowCompleted; | 199 | filter |= OPimTodoAccess::DoNotShowCompleted; |
321 | if (m_overdue) | 200 | if (m_overdue) |
322 | filter |= OPimTodoAccess::OnlyOverDue; | 201 | filter |= OPimTodoAccess::OnlyOverDue; |
323 | 202 | ||
324 | return m_todoMgr.sorted( asc, sortOrder, filter, cat ); | 203 | return m_todoMgr.sorted( asc, sortOrder, filter, cat ); |
325 | } | 204 | } |
326 | OPimTodoAccess::List MainWindow::sorted( bool asc, int sortOrder, int addFilter) { | 205 | OPimTodoAccess::List MainWindow::sorted( bool asc, int sortOrder, int addFilter) { |
327 | int cat = 0; | 206 | int cat = 0; |
328 | if ( m_curCat != QWidget::tr("All Categories") ) | 207 | if ( m_curCat != tr( "All" ) ) |
329 | cat = currentCatId(); | 208 | cat = currentCatId(); |
330 | 209 | ||
331 | if ( m_curCat == QWidget::tr("Unfiled") ) | 210 | if ( m_curCat == tr( "Unfiled" ) ) |
332 | cat = -1; | 211 | cat = -1; |
333 | 212 | ||
334 | return m_todoMgr.sorted(asc, sortOrder, addFilter, cat ); | 213 | return m_todoMgr.sorted(asc, sortOrder, addFilter, cat ); |
335 | } | 214 | } |
336 | OPimTodo MainWindow::event( int uid ) { | 215 | OPimTodo MainWindow::event( int uid ) { |
337 | return m_todoMgr.event( uid ); | 216 | return m_todoMgr.event( uid ); |
338 | } | 217 | } |
339 | bool MainWindow::isSyncing()const { | 218 | bool MainWindow::isSyncing()const { |
340 | return m_syncing; | 219 | return m_syncing; |
341 | } | 220 | } |
342 | TemplateManager* MainWindow::templateManager() { | 221 | TemplateManager* MainWindow::templateManager() { |
343 | return m_tempManager; | 222 | return m_tempManager; |
344 | } | 223 | } |
345 | Editor* MainWindow::currentEditor() { | 224 | Editor* MainWindow::currentEditor() { |
346 | return m_curEdit; | 225 | return m_curEdit; |
347 | } | 226 | } |
348 | TodoShow* MainWindow::currentShow() { | 227 | TodoShow* MainWindow::currentShow() { |
349 | return m_curShow; | 228 | return m_curShow; |
350 | } | 229 | } |
351 | void MainWindow::slotReload() { | 230 | void MainWindow::slotReload() { |
352 | m_syncing = FALSE; | 231 | m_syncing = false; |
353 | m_todoMgr.reload(); | 232 | m_todoMgr.reload(); |
354 | currentView()->updateView( ); | 233 | currentView()->updateView( ); |
355 | raiseCurrentView(); | 234 | raiseCurrentView(); |
356 | } | 235 | } |
357 | void MainWindow::closeEvent( QCloseEvent* e ) { | 236 | void MainWindow::closeEvent( QCloseEvent* e ) { |
358 | if (m_stack->visibleWidget() == currentShow()->widget() ) { | 237 | if (m_stack->visibleWidget() == currentShow()->widget() ) { |
359 | m_showing = false; | 238 | m_showing = false; |
360 | raiseCurrentView(); | 239 | raiseCurrentView(); |
361 | e->ignore(); | 240 | e->ignore(); |
362 | return; | 241 | return; |
363 | } | 242 | } |
364 | /* | 243 | /* |
365 | * we should have flushed and now we're still saving | 244 | * we should have flushed and now we're still saving |
366 | * so there is no need to flush | 245 | * so there is no need to flush |
367 | */ | 246 | */ |
368 | if (m_syncing ) { | 247 | if (m_syncing ) { |
369 | e->accept(); | 248 | e->accept(); |
370 | return; | 249 | return; |
371 | } | 250 | } |
372 | bool quit = false; | 251 | bool quit = false; |
373 | if ( m_todoMgr.saveAll() ){ | 252 | if ( m_todoMgr.saveAll() ){ |
374 | quit = true; | 253 | quit = true; |
375 | }else { | 254 | }else { |
376 | if ( QMessageBox::critical( this, QWidget::tr("Out of space"), | 255 | if ( QMessageBox::critical( this, QWidget::tr("Out of space"), |
377 | QWidget::tr("Todo was unable\n" | 256 | QWidget::tr("Todo was unable\n" |
378 | "to save your changes.\n" | 257 | "to save your changes.\n" |
379 | "Free up some space\n" | 258 | "Free up some space\n" |
380 | "and try again.\n" | 259 | "and try again.\n" |
381 | "\nQuit Anyway?"), | 260 | "\nQuit Anyway?"), |
382 | QMessageBox::Yes|QMessageBox::Escape, | 261 | QMessageBox::Yes|QMessageBox::Escape, |
383 | QMessageBox::No|QMessageBox::Default) | 262 | QMessageBox::No|QMessageBox::Default) |
384 | != QMessageBox::No ) { | 263 | != QMessageBox::No ) { |
385 | e->accept(); | 264 | e->accept(); |
386 | quit = true; | 265 | quit = true; |
387 | }else | 266 | }else |
388 | e->ignore(); | 267 | e->ignore(); |
389 | 268 | ||
390 | } | 269 | } |
391 | 270 | ||
392 | if (quit ) { | 271 | if (quit ) { |
393 | Config config( "todo" ); | 272 | Config config( "todo" ); |
394 | config.setGroup( "View" ); | 273 | config.setGroup( "View" ); |
395 | config.writeEntry( "ShowComplete", showCompleted() ); | 274 | config.writeEntry( "ShowComplete", showCompleted() ); |
396 | config.writeEntry( "Category", currentCategory() ); | 275 | config.writeEntry( "Category", currentCategory() ); |
397 | config.writeEntry( "ShowDeadLine", showDeadline()); | 276 | config.writeEntry( "ShowDeadLine", showDeadline()); |
398 | config.writeEntry( "ShowOverDue", showOverDue() ); | 277 | config.writeEntry( "ShowOverDue", showOverDue() ); |
399 | config.writeEntry( "ShowQuickTask", showQuickTask() ); | 278 | config.writeEntry( "ShowQuickTask", showQuickTask() ); |
400 | /* save templates */ | 279 | /* save templates */ |
401 | templateManager()->save(); | 280 | templateManager()->save(); |
402 | e->accept(); | 281 | e->accept(); |
403 | QTimer::singleShot(0, qApp, SLOT(closeAllWindows()) ); | 282 | QTimer::singleShot(0, qApp, SLOT(closeAllWindows()) ); |
404 | } | 283 | } |
405 | } | 284 | } |
406 | void MainWindow::populateTemplates() { | 285 | void MainWindow::slotItemNew() { |
407 | m_template->clear(); | 286 | NewTaskDlg dlg( templateManager()->templates(), this ); |
408 | QStringList list = templateManager()->templates(); | 287 | if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) { |
409 | QStringList::Iterator it; | 288 | QString tempName = dlg.tempSelected(); |
410 | for ( it = list.begin(); it != list.end(); ++it ) { | 289 | if ( tempName.isNull() ) |
411 | m_template->insertItem( (*it) ); | 290 | // Create new, blank task |
412 | } | 291 | create(); |
413 | } | 292 | else { |
414 | /* | 293 | // Create new task from the template selected |
415 | * slotNewFromTemplate | 294 | OPimTodo event = templateManager()->templateEvent( tempName ); |
416 | * We use the edit widget to do | 295 | event = currentEditor()->edit( this, event ); |
417 | * the config but we setUid(1) | 296 | if ( currentEditor()->accepted() ) { |
418 | * to get a new uid | 297 | event.setUid( 1 ); |
419 | */ | 298 | handleAlarms( OPimTodo(), event ); |
420 | /* | 299 | m_todoMgr.add( event ); |
421 | * first we get the name of the template | 300 | currentView()->addEvent( event ); |
422 | * then we will use the TemplateManager | 301 | |
423 | */ | 302 | reloadCategories(); |
424 | void MainWindow::slotNewFromTemplate( int id ) { | 303 | } |
425 | QString name = m_template->text( id ); | 304 | raiseCurrentView(); |
426 | 305 | } | |
427 | OPimTodo event = templateManager()->templateEvent( name ); | ||
428 | event = currentEditor()->edit(this, | ||
429 | event ); | ||
430 | |||
431 | if ( currentEditor()->accepted() ) { | ||
432 | /* assign new todo */ | ||
433 | event.setUid( 1 ); | ||
434 | handleAlarms( OPimTodo(), event ); | ||
435 | m_todoMgr.add( event ); | ||
436 | currentView()->addEvent( event ); | ||
437 | |||
438 | populateCategories(); | ||
439 | } | 306 | } |
440 | raiseCurrentView(); | ||
441 | } | 307 | } |
442 | void MainWindow::slotNew() { | 308 | void MainWindow::slotItemEdit() { |
443 | create(); | 309 | slotEdit( currentView()->current() ); |
444 | } | 310 | } |
445 | void MainWindow::slotDuplicate() { | 311 | void MainWindow::slotItemDuplicate() { |
446 | if(m_syncing) { | 312 | if(m_syncing) { |
447 | QMessageBox::warning(this, QWidget::tr("Todo"), | 313 | QMessageBox::warning(this, QWidget::tr("Todo"), |
448 | QWidget::tr("Data can not be edited, currently syncing")); | 314 | QWidget::tr("Data can not be edited, currently syncing")); |
449 | return; | 315 | return; |
450 | } | 316 | } |
451 | OPimTodo ev = m_todoMgr.event( currentView()->current() ); | 317 | OPimTodo ev = m_todoMgr.event( currentView()->current() ); |
452 | /* let's generate a new uid */ | 318 | /* let's generate a new uid */ |
453 | ev.setUid(1); | 319 | ev.setUid(1); |
454 | m_todoMgr.add( ev ); | 320 | m_todoMgr.add( ev ); |
455 | 321 | ||
456 | currentView()->addEvent( ev ); | 322 | currentView()->addEvent( ev ); |
457 | raiseCurrentView(); | 323 | raiseCurrentView(); |
458 | } | 324 | } |
459 | void MainWindow::slotDelete() { | 325 | void MainWindow::slotItemDelete() { |
460 | if (!currentView()->current() ) | 326 | if (!currentView()->current() ) |
461 | return; | 327 | return; |
462 | 328 | ||
463 | if(m_syncing) { | 329 | if(m_syncing) { |
464 | QMessageBox::warning(this, QWidget::tr("Todo"), | 330 | QMessageBox::warning(this, QWidget::tr("Todo"), |
465 | QWidget::tr("Data can not be edited, currently syncing")); | 331 | QWidget::tr("Data can not be edited, currently syncing")); |
466 | return; | 332 | return; |
467 | } | 333 | } |
468 | QString strName = currentView()->currentRepresentation(); | 334 | QString strName = currentView()->currentRepresentation(); |
469 | if (!QPEMessageBox::confirmDelete(this, QWidget::tr("Todo"), strName ) ) | 335 | if (!QPEMessageBox::confirmDelete(this, QWidget::tr("Todo"), strName ) ) |
470 | return; | 336 | return; |
471 | 337 | ||
472 | handleAlarms( m_todoMgr.event( currentView()->current() ), OPimTodo() ); | 338 | handleAlarms( m_todoMgr.event( currentView()->current() ), OPimTodo() ); |
473 | m_todoMgr.remove( currentView()->current() ); | 339 | m_todoMgr.remove( currentView()->current() ); |
474 | currentView()->removeEvent( currentView()->current() ); | 340 | currentView()->removeEvent( currentView()->current() ); |
475 | raiseCurrentView(); | 341 | raiseCurrentView(); |
476 | } | 342 | } |
343 | |||
344 | static const char *beamfile = "/tmp/opie-todo.vcs"; | ||
345 | void MainWindow::slotItemBeam() { | ||
346 | beam( currentView()->current() ); | ||
347 | } | ||
348 | void MainWindow::slotItemFind() { | ||
349 | } | ||
350 | void MainWindow::slotConfigure() { | ||
351 | TemplateDialogImpl dlg( this, m_tempManager ); | ||
352 | if ( QPEApplication::execDialog( &dlg ) != QDialog::Accepted ) | ||
353 | m_tempManager->load(); | ||
354 | } | ||
477 | void MainWindow::slotDelete(int uid ) { | 355 | void MainWindow::slotDelete(int uid ) { |
478 | if( uid == 0 ) return; | 356 | if( uid == 0 ) return; |
479 | if(m_syncing) { | 357 | if(m_syncing) { |
480 | QMessageBox::warning(this, QWidget::tr("Todo"), | 358 | QMessageBox::warning(this, QWidget::tr("Todo"), |
481 | QWidget::tr("Data can not be edited, currently syncing")); | 359 | QWidget::tr("Data can not be edited, currently syncing")); |
482 | return; | 360 | return; |
483 | } | 361 | } |
484 | OPimTodo to = m_todoMgr.event(uid); | 362 | OPimTodo to = m_todoMgr.event(uid); |
485 | if (!QPEMessageBox::confirmDelete(this, QWidget::tr("Todo"), to.toShortText() ) ) | 363 | if (!QPEMessageBox::confirmDelete(this, QWidget::tr("Todo"), to.toShortText() ) ) |
486 | return; | 364 | return; |
487 | 365 | ||
488 | handleAlarms(to, OPimTodo() ); | 366 | handleAlarms(to, OPimTodo() ); |
489 | m_todoMgr.remove( to.uid() ); | 367 | m_todoMgr.remove( to.uid() ); |
490 | currentView()->removeEvent( to.uid() ); | 368 | currentView()->removeEvent( to.uid() ); |
491 | raiseCurrentView(); | 369 | raiseCurrentView(); |
492 | } | 370 | } |
493 | void MainWindow::slotDeleteAll() { | 371 | void MainWindow::slotDeleteAll() { |
494 | if(m_syncing) { | 372 | if(m_syncing) { |
495 | QMessageBox::warning(this, QWidget::tr("Todo"), | 373 | QMessageBox::warning(this, QWidget::tr("Todo"), |
496 | QWidget::tr("Data can not be edited, currently syncing")); | 374 | QWidget::tr("Data can not be edited, currently syncing")); |
497 | return; | 375 | return; |
498 | } | 376 | } |
499 | 377 | ||
500 | 378 | ||
501 | if ( !QPEMessageBox::confirmDelete( this, QWidget::tr( "Todo" ), QWidget::tr("all tasks?") ) ) | 379 | if ( !QPEMessageBox::confirmDelete( this, QWidget::tr( "Todo" ), QWidget::tr("all tasks?") ) ) |
502 | return; | 380 | return; |
503 | 381 | ||
504 | m_todoMgr.removeAll(); | 382 | m_todoMgr.removeAll(); |
505 | currentView()->clear(); | 383 | currentView()->clear(); |
506 | 384 | ||
507 | raiseCurrentView(); | 385 | raiseCurrentView(); |
508 | } | 386 | } |
509 | void MainWindow::slotDeleteCompleted() { | 387 | void MainWindow::slotDeleteCompleted() { |
510 | if(m_syncing) { | 388 | if(m_syncing) { |
511 | QMessageBox::warning(this, QWidget::tr("Todo"), | 389 | QMessageBox::warning(this, QWidget::tr("Todo"), |
512 | QWidget::tr("Data can not be edited, currently syncing")); | 390 | QWidget::tr("Data can not be edited, currently syncing")); |
513 | return; | 391 | return; |
514 | } | 392 | } |
515 | 393 | ||
516 | if ( !QPEMessageBox::confirmDelete( this, QWidget::tr( "Todo" ), QWidget::tr("all completed tasks?") ) ) | 394 | if ( !QPEMessageBox::confirmDelete( this, QWidget::tr( "Todo" ), QWidget::tr("all completed tasks?") ) ) |
517 | return; | 395 | return; |
518 | 396 | ||
519 | 397 | ||
520 | m_todoMgr.removeCompleted(); | 398 | m_todoMgr.removeCompleted(); |
521 | currentView()->updateView( ); | 399 | currentView()->updateView( ); |
522 | } | 400 | } |
523 | void MainWindow::slotFind() { | ||
524 | |||
525 | } | ||
526 | void MainWindow::slotEdit() { | ||
527 | slotEdit( currentView()->current() ); | ||
528 | } | ||
529 | /* | 401 | /* |
530 | * set the category | 402 | * set the category |
531 | */ | 403 | */ |
532 | void MainWindow::setCategory( int c) { | 404 | void MainWindow::setCategory( const QString &category ) { |
533 | if ( c <= 0 ) return; | 405 | m_curCat = category; |
534 | 406 | if ( m_curCat == tr( "All" ) ) | |
535 | |||
536 | for ( unsigned int i = 1; i < m_catMenu->count(); i++ ) | ||
537 | m_catMenu->setItemChecked(i, c == (int)i ); | ||
538 | |||
539 | if (c == 1 ) { | ||
540 | m_curCat = QString::null; | 407 | m_curCat = QString::null; |
541 | setCaption( QWidget::tr("Todo") + " - " + QWidget::tr("All Categories" ) ); | 408 | |
542 | |||
543 | }else if ( c == (int)m_catMenu->count() - 1 ) { | ||
544 | m_curCat = QWidget::tr("Unfiled"); | ||
545 | setCaption( QWidget::tr("Todo") + " - " + QWidget::tr("Unfiled") ); | ||
546 | }else { | ||
547 | m_curCat = m_todoMgr.categories()[c-2]; | ||
548 | setCaption( QWidget::tr("Todo") + " - " + m_curCat ); | ||
549 | } | ||
550 | m_catMenu->setItemChecked( c, true ); | ||
551 | |||
552 | currentView()->setShowCategory( m_curCat ); | 409 | currentView()->setShowCategory( m_curCat ); |
553 | raiseCurrentView(); | 410 | raiseCurrentView(); |
554 | } | 411 | } |
555 | void MainWindow::slotShowDeadLine( bool dead) { | 412 | void MainWindow::slotShowDeadLine( bool dead) { |
556 | m_deadline = dead; | 413 | m_deadline = dead; |
557 | currentView()->setShowDeadline( dead ); | 414 | currentView()->setShowDeadline( dead ); |
558 | } | 415 | } |
559 | void MainWindow::slotShowCompleted( bool show) { | 416 | void MainWindow::slotShowCompleted( bool show) { |
560 | m_completed = show; | 417 | m_completed = show; |
561 | currentView()->setShowCompleted( m_completed ); | 418 | currentView()->setShowCompleted( m_completed ); |
562 | } | 419 | } |
563 | void MainWindow::slotShowQuickTask( bool show ) { | 420 | void MainWindow::slotShowQuickTask( bool show ) { |
564 | m_quicktask = show; | 421 | m_quicktask = show; |
565 | if ( m_quicktask ) | 422 | if ( m_quicktask ) |
566 | m_curQuick->widget()->show(); | 423 | m_curQuick->widget()->show(); |
567 | else | 424 | else |
568 | m_curQuick->widget()->hide(); | 425 | m_curQuick->widget()->hide(); |
569 | } | 426 | } |
570 | bool MainWindow::showOverDue()const { | 427 | bool MainWindow::showOverDue()const { |
571 | return m_overdue; | 428 | return m_overdue; |
572 | } | 429 | } |
573 | void MainWindow::setDocument( const QString& fi) { | 430 | void MainWindow::setDocument( const QString& fi) { |
574 | DocLnk doc(fi); | 431 | DocLnk doc(fi); |
575 | if (doc.isValid() ) | 432 | if (doc.isValid() ) |
576 | receiveFile(doc.file() ); | 433 | receiveFile(doc.file() ); |
577 | else | 434 | else |
578 | receiveFile(fi ); | 435 | receiveFile(fi ); |
579 | } | 436 | } |
580 | |||
581 | static const char *beamfile = "/tmp/opie-todo.vcs"; | ||
582 | void MainWindow::slotBeam() { | ||
583 | beam( currentView()->current() ); | ||
584 | } | ||
585 | void MainWindow::beamDone( Ir* ir) { | 437 | void MainWindow::beamDone( Ir* ir) { |
586 | delete ir; | 438 | delete ir; |
587 | ::unlink( beamfile ); | 439 | ::unlink( beamfile ); |
588 | } | 440 | } |
589 | void MainWindow::receiveFile( const QString& filename ) { | 441 | void MainWindow::receiveFile( const QString& filename ) { |
590 | OPimTodoAccessVCal* cal = new OPimTodoAccessVCal(filename ); | 442 | OPimTodoAccessVCal* cal = new OPimTodoAccessVCal(filename ); |
591 | 443 | ||
592 | OPimTodoAccess acc( cal ); | 444 | OPimTodoAccess acc( cal ); |
593 | acc.load(); | 445 | acc.load(); |
594 | OPimTodoAccess::List list = acc.allRecords(); | 446 | OPimTodoAccess::List list = acc.allRecords(); |
595 | 447 | ||
596 | if (list.count()){ | 448 | if (list.count()){ |
597 | 449 | ||
598 | QString message = QWidget::tr("<P>%1 new tasks arrived.<p>Would you like to add them to your Todolist?").arg(list.count() ); | 450 | QString message = QWidget::tr("<P>%1 new tasks arrived.<p>Would you like to add them to your Todolist?").arg(list.count() ); |
599 | 451 | ||
600 | if ( QMessageBox::information(this, QWidget::tr("New Tasks"), | 452 | if ( QMessageBox::information(this, QWidget::tr("New Tasks"), |
601 | message, QMessageBox::Ok, | 453 | message, QMessageBox::Ok, |
602 | QMessageBox::Cancel ) == QMessageBox::Ok ) { | 454 | QMessageBox::Cancel ) == QMessageBox::Ok ) { |
603 | OPimTodoAccess::List::Iterator it; | 455 | OPimTodoAccess::List::Iterator it; |
604 | for ( it = list.begin(); it != list.end(); ++it ) | 456 | for ( it = list.begin(); it != list.end(); ++it ) |
605 | m_todoMgr.add( (*it) ); | 457 | m_todoMgr.add( (*it) ); |
606 | 458 | ||
607 | currentView()->updateView(); | 459 | currentView()->updateView(); |
608 | } | 460 | } |
609 | } | 461 | } |
610 | } | 462 | } |
611 | 463 | ||
612 | void MainWindow::slotFlush() { | 464 | void MainWindow::slotFlush() { |
613 | m_syncing = TRUE; | 465 | m_syncing = true; |
614 | m_todoMgr.save(); | 466 | m_todoMgr.save(); |
615 | } | 467 | } |
616 | void MainWindow::slotShowDetails() { | 468 | void MainWindow::slotShowDetails() { |
617 | slotShow( currentView()->current() ); | 469 | slotShow( currentView()->current() ); |
618 | } | 470 | } |
619 | /* | ||
620 | * populate the Categories | ||
621 | * Menu | ||
622 | */ | ||
623 | void MainWindow::populateCategories() { | ||
624 | m_todoMgr.load(); | ||
625 | |||
626 | m_catMenu->clear(); | ||
627 | int id, rememberId; | ||
628 | id = 1; | ||
629 | rememberId = 1; | ||
630 | |||
631 | m_catMenu->insertItem( QWidget::tr( "All Categories" ), id++ ); | ||
632 | m_catMenu->insertSeparator(); | ||
633 | QStringList categories = m_todoMgr.categories(); | ||
634 | categories.append( QWidget::tr( "Unfiled" ) ); | ||
635 | for ( QStringList::Iterator it = categories.begin(); | ||
636 | it != categories.end(); ++it ) { | ||
637 | m_catMenu->insertItem( *it, id ); | ||
638 | if ( *it == currentCategory() ) | ||
639 | rememberId = id; | ||
640 | ++id; | ||
641 | } | ||
642 | setCategory( rememberId ); | ||
643 | } | ||
644 | bool MainWindow::showCompleted()const { | 471 | bool MainWindow::showCompleted()const { |
645 | return m_completed; | 472 | return m_completed; |
646 | } | 473 | } |
647 | bool MainWindow::showDeadline()const { | 474 | bool MainWindow::showDeadline()const { |
648 | return m_deadline; | 475 | return m_deadline; |
649 | } | 476 | } |
650 | bool MainWindow::showQuickTask()const { | 477 | bool MainWindow::showQuickTask()const { |
651 | return m_quicktask; | 478 | return m_quicktask; |
652 | } | 479 | } |
653 | QString MainWindow::currentCategory()const { | 480 | QString MainWindow::currentCategory()const { |
654 | return m_curCat; | 481 | return m_curCat; |
655 | } | 482 | } |
656 | int MainWindow::currentCatId() { | 483 | int MainWindow::currentCatId() { |
657 | return m_todoMgr.catId( m_curCat ); | 484 | return m_todoMgr.catId( m_curCat ); |
658 | } | 485 | } |
659 | ViewBase* MainWindow::currentView() { | 486 | ViewBase* MainWindow::currentView() { |
660 | return m_curView; | 487 | return m_curView; |
661 | } | 488 | } |
662 | void MainWindow::raiseCurrentView() { | 489 | void MainWindow::raiseCurrentView() { |
663 | // due QPE/Application/todolist show(int) | 490 | // due QPE/Application/todolist show(int) |
664 | // we might not have the populateCategories slot called once | 491 | // we might not have the populateCategories slot called once |
665 | // we would show the otodo but then imediately switch to the currentView | 492 | // we would show the otodo but then imediately switch to the currentView |
666 | // if we're initially showing we shouldn't raise the table | 493 | // if we're initially showing we shouldn't raise the table |
667 | // in returnFromView we fix up m_showing | 494 | // in returnFromView we fix up m_showing |
668 | if (m_showing ) return; | 495 | if (m_showing ) return; |
669 | 496 | ||
670 | m_stack->raiseWidget( m_curView->widget() ); | 497 | m_stack->raiseWidget( m_curView->widget() ); |
671 | } | 498 | } |
672 | void MainWindow::slotShowDue(bool ov) { | 499 | void MainWindow::slotShowDue(bool ov) { |
673 | m_overdue = ov; | 500 | m_overdue = ov; |
674 | currentView()->showOverDue( ov ); | 501 | currentView()->showOverDue( ov ); |
675 | raiseCurrentView(); | 502 | raiseCurrentView(); |
676 | } | 503 | } |
677 | void MainWindow::slotShow( int uid ) { | 504 | void MainWindow::slotShow( int uid ) { |
678 | if ( uid == 0 ) return; | 505 | if ( uid == 0 ) return; |
679 | 506 | ||
680 | 507 | ||
681 | currentShow()->slotShow( event( uid ) ); | 508 | currentShow()->slotShow( event( uid ) ); |
682 | m_stack->raiseWidget( currentShow()->widget() ); | 509 | m_stack->raiseWidget( currentShow()->widget() ); |
683 | } | 510 | } |
684 | void MainWindow::slotShowNext() { | 511 | void MainWindow::slotShowNext() { |
685 | int l = currentView()->next(); | 512 | int l = currentView()->next(); |
686 | if (l!=0) | 513 | if (l!=0) |
687 | slotShow(l); | 514 | slotShow(l); |
688 | } | 515 | } |
689 | void MainWindow::slotShowPrev() { | 516 | void MainWindow::slotShowPrev() { |
690 | int l = currentView()->prev(); | 517 | int l = currentView()->prev(); |
691 | if (l!=0) | 518 | if (l!=0) |
692 | slotShow(l); | 519 | slotShow(l); |
693 | } | 520 | } |
694 | void MainWindow::slotEdit( int uid ) { | 521 | void MainWindow::slotEdit( int uid ) { |
695 | if (uid == 0 ) return; | 522 | if (uid == 0 ) return; |
696 | if(m_syncing) { | 523 | if(m_syncing) { |
697 | QMessageBox::warning(this, QWidget::tr("Todo"), | 524 | QMessageBox::warning(this, QWidget::tr("Todo"), |
698 | QWidget::tr("Data can't be edited, currently syncing")); | 525 | QWidget::tr("Data can't be edited, currently syncing")); |
699 | return; | 526 | return; |
700 | } | 527 | } |
701 | 528 | ||
702 | OPimTodo old_todo = m_todoMgr.event( uid ); | 529 | OPimTodo old_todo = m_todoMgr.event( uid ); |
703 | 530 | ||
704 | OPimTodo todo = currentEditor()->edit(this, old_todo ); | 531 | OPimTodo todo = currentEditor()->edit(this, old_todo ); |
705 | 532 | ||
706 | /* if completed */ | 533 | /* if completed */ |
707 | if ( currentEditor()->accepted() ) { | 534 | if ( currentEditor()->accepted() ) { |
708 | handleAlarms( old_todo, todo ); | 535 | handleAlarms( old_todo, todo ); |
709 | m_todoMgr.update( todo.uid(), todo ); | 536 | m_todoMgr.update( todo.uid(), todo ); |
710 | currentView()->replaceEvent( todo ); | 537 | currentView()->replaceEvent( todo ); |
711 | /* a Category might have changed */ | 538 | /* a Category might have changed */ |
712 | populateCategories(); | 539 | reloadCategories(); |
713 | } | 540 | } |
714 | 541 | ||
715 | raiseCurrentView(); | 542 | raiseCurrentView(); |
716 | } | 543 | } |
717 | /* | 544 | /* |
718 | void MainWindow::slotUpdate1( int uid, const SmallTodo& ev) { | 545 | void MainWindow::slotUpdate1( int uid, const SmallTodo& ev) { |
719 | m_todoMgr.update( uid, ev ); | 546 | m_todoMgr.update( uid, ev ); |
720 | } | 547 | } |
721 | */ | 548 | */ |
722 | void MainWindow::updateTodo( const OPimTodo& ev) { | 549 | void MainWindow::updateTodo( const OPimTodo& ev) { |
723 | m_todoMgr.update( ev.uid() , ev ); | 550 | m_todoMgr.update( ev.uid() , ev ); |
724 | } | 551 | } |
725 | /* The view changed it's configuration | 552 | /* The view changed it's configuration |
726 | * update the view menu | 553 | * update the view menu |
727 | */ | 554 | */ |
728 | void MainWindow::slotUpdate3( QWidget* ) { | 555 | void MainWindow::slotUpdate3( QWidget* ) { |
729 | 556 | ||
730 | } | 557 | } |
731 | void MainWindow::updateList() { | 558 | void MainWindow::updateList() { |
732 | m_todoMgr.updateList(); | 559 | m_todoMgr.updateList(); |
733 | } | 560 | } |
734 | void MainWindow::setReadAhead( uint count ) { | 561 | void MainWindow::setReadAhead( uint count ) { |
735 | if (m_todoMgr.todoDB() ) | 562 | if (m_todoMgr.todoDB() ) |
736 | m_todoMgr.todoDB()->setReadAhead( count ); | 563 | m_todoMgr.todoDB()->setReadAhead( count ); |
737 | } | 564 | } |
738 | void MainWindow::slotQuickEntered() { | 565 | void MainWindow::slotQuickEntered() { |
739 | OPimTodo todo = quickEditor()->todo(); | 566 | OPimTodo todo = quickEditor()->todo(); |
740 | if (todo.isEmpty() ) | 567 | if (todo.isEmpty() ) |
741 | return; | 568 | return; |
742 | 569 | ||
743 | m_todoMgr.add( todo ); | 570 | m_todoMgr.add( todo ); |
744 | currentView()->addEvent( todo ); | 571 | currentView()->addEvent( todo ); |
745 | raiseCurrentView(); | 572 | raiseCurrentView(); |
746 | } | 573 | } |
747 | QuickEditBase* MainWindow::quickEditor() { | 574 | QuickEditBase* MainWindow::quickEditor() { |
748 | return m_curQuick; | 575 | return m_curQuick; |
749 | } | 576 | } |
750 | void MainWindow::slotComplete( int uid ) { | 577 | void MainWindow::slotComplete( int uid ) { |
751 | slotComplete( event(uid) ); | 578 | slotComplete( event(uid) ); |
752 | } | 579 | } |
753 | void MainWindow::slotComplete( const OPimTodo& todo ) { | 580 | void MainWindow::slotComplete( const OPimTodo& todo ) { |
754 | OPimTodo to = todo; | 581 | OPimTodo to = todo; |
755 | to.setCompleted( !to.isCompleted() ); | 582 | to.setCompleted( !to.isCompleted() ); |
756 | to.setCompletedDate( QDate::currentDate() ); | 583 | to.setCompletedDate( QDate::currentDate() ); |
757 | 584 | ||
758 | /* | 585 | /* |
759 | * if the item does recur | 586 | * if the item does recur |
760 | * we need to spin it off | 587 | * we need to spin it off |
761 | * and update the items duedate to the next | 588 | * and update the items duedate to the next |
762 | * possible recurrance of this item... | 589 | * possible recurrance of this item... |
763 | * the spinned off one will loose the | 590 | * the spinned off one will loose the |
764 | * recurrence. | 591 | * recurrence. |
765 | * We calculate the difference between the old due date and the | 592 | * We calculate the difference between the old due date and the |
766 | * new one and add this diff to start, completed and alarm dates | 593 | * new one and add this diff to start, completed and alarm dates |
767 | * -zecke | 594 | * -zecke |
768 | */ | 595 | */ |
769 | if ( to.hasRecurrence() && to.isCompleted() ) { | 596 | if ( to.hasRecurrence() && to.isCompleted() ) { |
770 | OPimTodo to2( to ); | 597 | OPimTodo to2( to ); |
771 | 598 | ||
772 | /* the spinned off one won't recur anymore */ | 599 | /* the spinned off one won't recur anymore */ |
773 | to.setRecurrence( OPimRecurrence() ); | 600 | to.setRecurrence( OPimRecurrence() ); |
774 | 601 | ||
775 | OPimRecurrence rec = to2.recurrence(); | 602 | OPimRecurrence rec = to2.recurrence(); |
776 | rec.setStart( to.dueDate() ); | 603 | rec.setStart( to.dueDate() ); |
777 | to2.setRecurrence( rec ); | 604 | to2.setRecurrence( rec ); |
778 | /* | 605 | /* |
779 | * if there is a next occurence | 606 | * if there is a next occurence |
780 | * from the duedate of the last recurrance | 607 | * from the duedate of the last recurrance |
781 | */ | 608 | */ |
782 | QDate date; | 609 | QDate date; |
783 | if ( to2.recurrence().nextOcurrence( to2.dueDate().addDays(1), date ) ) { | 610 | if ( to2.recurrence().nextOcurrence( to2.dueDate().addDays(1), date ) ) { |
784 | int dayDiff = to.dueDate().daysTo( date ); | 611 | int dayDiff = to.dueDate().daysTo( date ); |
785 | QDate inval; | 612 | QDate inval; |
786 | /* generate a new uid for the old record */ | 613 | /* generate a new uid for the old record */ |
787 | to.setUid( 1 ); | 614 | to.setUid( 1 ); |
788 | 615 | ||
789 | /* add the old one cause it has a new UID here cause it was spin off */ | 616 | /* add the old one cause it has a new UID here cause it was spin off */ |
790 | m_todoMgr.add( to ); | 617 | m_todoMgr.add( to ); |
791 | 618 | ||
792 | /* | 619 | /* |
793 | * update the due date | 620 | * update the due date |
794 | * start date | 621 | * start date |
795 | * and complete date | 622 | * and complete date |
796 | */ | 623 | */ |
797 | to2.setDueDate( date ); | 624 | to2.setDueDate( date ); |
798 | rec.setStart( date ); | 625 | rec.setStart( date ); |
799 | to2.setRecurrence( rec ); // could be Monday, TuesDay, Thursday every week | 626 | to2.setRecurrence( rec ); // could be Monday, TuesDay, Thursday every week |
800 | 627 | ||
801 | /* move start date */ | 628 | /* move start date */ |
802 | if (to2.hasStartDate() ) | 629 | if (to2.hasStartDate() ) |
803 | to2.setStartDate( to2.startDate().addDays( dayDiff ) ); | 630 | to2.setStartDate( to2.startDate().addDays( dayDiff ) ); |
804 | 631 | ||
805 | /* now the alarms */ | 632 | /* now the alarms */ |
806 | if (to2.hasNotifiers() ) { | 633 | if (to2.hasNotifiers() ) { |
807 | OPimNotifyManager::Alarms _als = to2.notifiers().alarms(); | 634 | OPimNotifyManager::Alarms _als = to2.notifiers().alarms(); |
808 | OPimNotifyManager::Alarms als; | 635 | OPimNotifyManager::Alarms als; |
809 | 636 | ||
810 | /* for every alarm move the day */ | 637 | /* for every alarm move the day */ |
811 | for ( OPimNotifyManager::Alarms::Iterator it = _als.begin(); it != _als.end(); ++it ) { | 638 | for ( OPimNotifyManager::Alarms::Iterator it = _als.begin(); it != _als.end(); ++it ) { |
812 | OPimAlarm al = (*it); | 639 | OPimAlarm al = (*it); |
813 | al.setDateTime( al.dateTime().addDays( dayDiff ) ); | 640 | al.setDateTime( al.dateTime().addDays( dayDiff ) ); |
814 | als.append( al ); | 641 | als.append( al ); |
815 | } | 642 | } |
816 | to2.notifiers().setAlarms( als ); | 643 | to2.notifiers().setAlarms( als ); |
817 | handleAlarms( OPimTodo(), todo ); | 644 | handleAlarms( OPimTodo(), todo ); |
818 | } | 645 | } |
819 | to2.setCompletedDate( inval ); | 646 | to2.setCompletedDate( inval ); |
820 | to2.setCompleted( false ); | 647 | to2.setCompleted( false ); |
821 | 648 | ||
822 | updateTodo( to2 ); | 649 | updateTodo( to2 ); |
823 | }else | 650 | }else |
824 | updateTodo( to ); | 651 | updateTodo( to ); |
825 | }else | 652 | }else |
826 | updateTodo( to ); | 653 | updateTodo( to ); |
827 | 654 | ||
828 | currentView()->updateView(); | 655 | currentView()->updateView(); |
829 | raiseCurrentView(); | 656 | raiseCurrentView(); |
830 | } | 657 | } |
831 | void MainWindow::flush() { | 658 | void MainWindow::flush() { |
832 | slotFlush(); | 659 | slotFlush(); |
833 | } | 660 | } |
834 | void MainWindow::reload() { | 661 | void MainWindow::reload() { |
835 | slotReload(); | 662 | slotReload(); |
836 | } | 663 | } |
837 | int MainWindow::create() { | 664 | int MainWindow::create() { |
838 | int uid = 0; | 665 | int uid = 0; |
839 | if(m_syncing) { | 666 | if(m_syncing) { |
840 | QMessageBox::warning(this, QWidget::tr("Todo"), | 667 | QMessageBox::warning(this, QWidget::tr("Todo"), |
841 | QWidget::tr("Data can not be edited, currently syncing")); | 668 | QWidget::tr("Data can not be edited, currently syncing")); |
842 | return uid; | 669 | return uid; |
843 | } | 670 | } |
844 | m_todoMgr.load(); | 671 | m_todoMgr.load(); |
845 | 672 | ||
846 | 673 | ||
847 | OPimTodo todo = currentEditor()->newTodo( currentCatId(), | 674 | OPimTodo todo = currentEditor()->newTodo( currentCatId(), |
848 | this ); | 675 | this ); |
849 | 676 | ||
850 | if ( currentEditor()->accepted() ) { | 677 | if ( currentEditor()->accepted() ) { |
851 | //todo.assignUid(); | 678 | //todo.assignUid(); |
852 | uid = todo.uid(); | 679 | uid = todo.uid(); |
853 | handleAlarms( OPimTodo(), todo ); | 680 | handleAlarms( OPimTodo(), todo ); |
854 | m_todoMgr.add( todo ); | 681 | m_todoMgr.add( todo ); |
855 | currentView()->addEvent( todo ); | 682 | currentView()->addEvent( todo ); |
856 | 683 | ||
857 | 684 | ||
858 | // I'm afraid we must call this every time now, otherwise | 685 | // I'm afraid we must call this every time now, otherwise |
859 | // spend expensive time comparing all these strings... | 686 | // spend expensive time comparing all these strings... |
860 | // but only call if we changed something -zecke | 687 | // but only call if we changed something -zecke |
861 | populateCategories(); | 688 | reloadCategories(); |
862 | } | 689 | } |
863 | raiseCurrentView( ); | 690 | raiseCurrentView( ); |
864 | 691 | ||
865 | return uid; | 692 | return uid; |
866 | } | 693 | } |
867 | /* delete it silently... */ | 694 | /* delete it silently... */ |
868 | bool MainWindow::remove( int uid ) { | 695 | bool MainWindow::remove( int uid ) { |
869 | if (m_syncing) return false; | 696 | if (m_syncing) return false; |
870 | 697 | ||
871 | /* argh need to get the whole OEvent... to disable alarms -zecke */ | 698 | /* argh need to get the whole OEvent... to disable alarms -zecke */ |
872 | handleAlarms( OPimTodo(), m_todoMgr.event( uid ) ); | 699 | handleAlarms( OPimTodo(), m_todoMgr.event( uid ) ); |
873 | 700 | ||
874 | return m_todoMgr.remove( uid ); | 701 | return m_todoMgr.remove( uid ); |
875 | } | 702 | } |
876 | void MainWindow::beam( int uid) { | 703 | void MainWindow::beam( int uid) { |
877 | if( uid == 0 ) return; | 704 | if( uid == 0 ) return; |
878 | 705 | ||
879 | ::unlink( beamfile ); | 706 | ::unlink( beamfile ); |
880 | m_todoMgr.load(); | 707 | m_todoMgr.load(); |
881 | 708 | ||
882 | OPimTodo todo = event( uid ); | 709 | OPimTodo todo = event( uid ); |
883 | OPimTodoAccessVCal* cal = new OPimTodoAccessVCal(QString::fromLatin1(beamfile) ); | 710 | OPimTodoAccessVCal* cal = new OPimTodoAccessVCal(QString::fromLatin1(beamfile) ); |
884 | OPimTodoAccess acc( cal ); | 711 | OPimTodoAccess acc( cal ); |
885 | acc.load(); | 712 | acc.load(); |
886 | acc.add( todo ); | 713 | acc.add( todo ); |
887 | acc.save(); | 714 | acc.save(); |
888 | Ir* ir = new Ir(this ); | 715 | Ir* ir = new Ir(this ); |
889 | connect(ir, SIGNAL(done(Ir*) ), | 716 | connect(ir, SIGNAL(done(Ir*) ), |
890 | this, SLOT(beamDone(Ir*) ) ); | 717 | this, SLOT(beamDone(Ir*) ) ); |
891 | ir->send(beamfile, todo.summary(), "text/x-vCalendar" ); | 718 | ir->send(beamfile, todo.summary(), "text/x-vCalendar" ); |
892 | } | 719 | } |
893 | void MainWindow::show( int uid ) { | 720 | void MainWindow::show( int uid ) { |
894 | m_todoMgr.load(); // might not be loaded yet | 721 | m_todoMgr.load(); // might not be loaded yet |
895 | m_showing = true; | 722 | m_showing = true; |
896 | slotShow( uid ); | 723 | slotShow( uid ); |
897 | raise(); | 724 | raise(); |
898 | QPEApplication::setKeepRunning(); | 725 | QPEApplication::setKeepRunning(); |
899 | } | 726 | } |
900 | void MainWindow::edit( int uid ) { | 727 | void MainWindow::edit( int uid ) { |
901 | m_todoMgr.load(); | 728 | m_todoMgr.load(); |
902 | slotEdit( uid ); | 729 | slotEdit( uid ); |
903 | } | 730 | } |
904 | void MainWindow::add( const OPimRecord& rec) { | 731 | void MainWindow::add( const OPimRecord& rec) { |
905 | OPimTodo test; | 732 | OPimTodo test; |
906 | if ( rec.rtti() != test.rtti() ) return; | 733 | if ( rec.rtti() != test.rtti() ) return; |
907 | m_todoMgr.load(); // might not be loaded | 734 | m_todoMgr.load(); // might not be loaded |
908 | 735 | ||
909 | const OPimTodo& todo = static_cast<const OPimTodo&>(rec); | 736 | const OPimTodo& todo = static_cast<const OPimTodo&>(rec); |
910 | 737 | ||
911 | m_todoMgr.add(todo ); | 738 | m_todoMgr.add(todo ); |
912 | currentView()->addEvent( todo ); | 739 | currentView()->addEvent( todo ); |
913 | 740 | ||
914 | 741 | ||
915 | // I'm afraid we must call this every time now, otherwise | 742 | // I'm afraid we must call this every time now, otherwise |
916 | // spend expensive time comparing all these strings... | 743 | // spend expensive time comparing all these strings... |
917 | // but only call if we changed something -zecke | 744 | // but only call if we changed something -zecke |
918 | populateCategories(); | 745 | reloadCategories(); |
919 | } | 746 | } |
920 | void MainWindow::slotReturnFromView() { | 747 | void MainWindow::slotReturnFromView() { |
921 | m_showing = false; | 748 | m_showing = false; |
922 | raiseCurrentView(); | 749 | raiseCurrentView(); |
923 | } | 750 | } |
924 | 751 | ||
925 | namespace { | 752 | namespace { |
926 | OPimNotifyManager::Alarms findNonMatching( const OPimNotifyManager::Alarms& oldAls, | 753 | OPimNotifyManager::Alarms findNonMatching( const OPimNotifyManager::Alarms& oldAls, |
927 | const OPimNotifyManager::Alarms& newAls ) { | 754 | const OPimNotifyManager::Alarms& newAls ) { |
928 | OPimNotifyManager::Alarms nonMatching; | 755 | OPimNotifyManager::Alarms nonMatching; |
929 | OPimNotifyManager::Alarms::ConstIterator oldIt = oldAls.begin(); | 756 | OPimNotifyManager::Alarms::ConstIterator oldIt = oldAls.begin(); |
930 | OPimNotifyManager::Alarms::ConstIterator newIt; | 757 | OPimNotifyManager::Alarms::ConstIterator newIt; |
931 | for ( ; oldIt != oldAls.end(); ++oldIt ) { | 758 | for ( ; oldIt != oldAls.end(); ++oldIt ) { |
932 | bool found = false; | 759 | bool found = false; |
933 | QDateTime oldDt = (*oldIt).dateTime(); | 760 | QDateTime oldDt = (*oldIt).dateTime(); |
934 | for (newIt= newAls.begin(); newIt != newAls.end(); ++newIt ) { | 761 | for (newIt= newAls.begin(); newIt != newAls.end(); ++newIt ) { |
935 | if ( oldDt == (*newIt).dateTime() ) { | 762 | if ( oldDt == (*newIt).dateTime() ) { |
936 | found = true; | 763 | found = true; |
937 | break; | 764 | break; |
938 | } | 765 | } |
939 | } | 766 | } |
940 | if (!found) | 767 | if (!found) |
941 | nonMatching.append( (*oldIt) ); | 768 | nonMatching.append( (*oldIt) ); |
942 | } | 769 | } |
943 | return nonMatching; | 770 | return nonMatching; |
944 | } | 771 | } |
945 | void addAlarms( const OPimNotifyManager::Alarms& als, int uid ) { | 772 | void addAlarms( const OPimNotifyManager::Alarms& als, int uid ) { |
946 | OPimNotifyManager::Alarms::ConstIterator it; | 773 | OPimNotifyManager::Alarms::ConstIterator it; |
947 | for ( it = als.begin(); it != als.end(); ++it ) { | 774 | for ( it = als.begin(); it != als.end(); ++it ) { |
948 | AlarmServer::addAlarm( (*it).dateTime(), "QPE/Application/todolist", "alarm(QDateTime,int)", uid ); | 775 | AlarmServer::addAlarm( (*it).dateTime(), "QPE/Application/todolist", "alarm(QDateTime,int)", uid ); |
949 | } | 776 | } |
950 | 777 | ||
951 | } | 778 | } |
952 | void removeAlarms( const OPimNotifyManager::Alarms& als, int uid ) { | 779 | void removeAlarms( const OPimNotifyManager::Alarms& als, int uid ) { |
953 | OPimNotifyManager::Alarms::ConstIterator it; | 780 | OPimNotifyManager::Alarms::ConstIterator it; |
954 | for ( it = als.begin(); it != als.end(); ++it ) { | 781 | for ( it = als.begin(); it != als.end(); ++it ) { |
955 | AlarmServer::deleteAlarm( (*it).dateTime(), "QPE/Application/todolist", "alarm(QDateTime,int)", uid ); | 782 | AlarmServer::deleteAlarm( (*it).dateTime(), "QPE/Application/todolist", "alarm(QDateTime,int)", uid ); |
956 | } | 783 | } |
957 | } | 784 | } |
958 | } | 785 | } |
959 | 786 | ||
960 | void MainWindow::handleAlarms( const OPimTodo& oldTodo, const OPimTodo& newTodo) { | 787 | void MainWindow::handleAlarms( const OPimTodo& oldTodo, const OPimTodo& newTodo) { |
961 | /* | 788 | /* |
962 | * if oldTodo is not empty and has notifiers we need to find the deleted ones | 789 | * if oldTodo is not empty and has notifiers we need to find the deleted ones |
963 | */ | 790 | */ |
964 | if(!oldTodo.isEmpty() && oldTodo.hasNotifiers() ) { | 791 | if(!oldTodo.isEmpty() && oldTodo.hasNotifiers() ) { |
965 | OPimNotifyManager::Alarms removed; | 792 | OPimNotifyManager::Alarms removed; |
966 | OPimNotifyManager::Alarms oldAls = oldTodo.notifiers().alarms(); | 793 | OPimNotifyManager::Alarms oldAls = oldTodo.notifiers().alarms(); |
967 | if (!newTodo.hasNotifiers() ) | 794 | if (!newTodo.hasNotifiers() ) |
968 | removed = oldAls; | 795 | removed = oldAls; |
969 | else | 796 | else |
970 | removed = findNonMatching( oldAls, newTodo.notifiers().alarms() ); | 797 | removed = findNonMatching( oldAls, newTodo.notifiers().alarms() ); |
971 | 798 | ||
972 | removeAlarms( removed, oldTodo.uid() ); | 799 | removeAlarms( removed, oldTodo.uid() ); |
973 | } | 800 | } |
974 | if ( newTodo.hasNotifiers() ) { | 801 | if ( newTodo.hasNotifiers() ) { |
975 | OPimNotifyManager::Alarms added; | 802 | OPimNotifyManager::Alarms added; |
976 | if ( oldTodo.isEmpty() || !oldTodo.hasNotifiers() ) | 803 | if ( oldTodo.isEmpty() || !oldTodo.hasNotifiers() ) |
977 | added = newTodo.notifiers().alarms(); | 804 | added = newTodo.notifiers().alarms(); |
978 | else | 805 | else |
979 | added = findNonMatching( newTodo.notifiers().alarms(), oldTodo.notifiers().alarms() ); | 806 | added = findNonMatching( newTodo.notifiers().alarms(), oldTodo.notifiers().alarms() ); |
980 | 807 | ||
981 | addAlarms( added, newTodo.uid() ); | 808 | addAlarms( added, newTodo.uid() ); |
982 | } | 809 | } |
983 | } | 810 | } |
984 | /* we might have not loaded the db */ | 811 | /* we might have not loaded the db */ |
985 | void MainWindow::doAlarm( const QDateTime& dt, int uid ) { | 812 | void MainWindow::doAlarm( const QDateTime& dt, int uid ) { |
986 | m_todoMgr.load(); | 813 | m_todoMgr.load(); |
987 | 814 | ||
988 | OPimTodo todo = m_todoMgr.event( uid ); | 815 | OPimTodo todo = m_todoMgr.event( uid ); |
989 | if (!todo.hasNotifiers() ) return; | 816 | if (!todo.hasNotifiers() ) return; |
990 | 817 | ||
991 | /* | 818 | /* |
992 | * let's find the right alarm and find out if silent | 819 | * let's find the right alarm and find out if silent |
993 | * then show a richtext widget | 820 | * then show a richtext widget |
994 | */ | 821 | */ |
995 | bool loud = false; | 822 | bool loud = false; |
996 | OPimNotifyManager::Alarms als = todo.notifiers().alarms(); | 823 | OPimNotifyManager::Alarms als = todo.notifiers().alarms(); |
997 | OPimNotifyManager::Alarms::Iterator it; | 824 | OPimNotifyManager::Alarms::Iterator it; |
998 | for ( it = als.begin(); it != als.end(); ++it ) { | 825 | for ( it = als.begin(); it != als.end(); ++it ) { |
999 | if ( (*it).dateTime() == dt ) { | 826 | if ( (*it).dateTime() == dt ) { |
1000 | loud = ( (*it).sound() == OPimAlarm::Loud ); | 827 | loud = ( (*it).sound() == OPimAlarm::Loud ); |
1001 | break; | 828 | break; |
1002 | } | 829 | } |
1003 | } | 830 | } |
1004 | if (loud) | 831 | if (loud) |
1005 | startAlarm(); | 832 | startAlarm(); |
1006 | 833 | ||
1007 | QDialog dlg(this, 0, TRUE ); | 834 | QDialog dlg(this, 0, true ); |
1008 | QVBoxLayout* lay = new QVBoxLayout( &dlg ); | 835 | QVBoxLayout* lay = new QVBoxLayout( &dlg ); |
1009 | QTextView* view = new QTextView( &dlg ); | 836 | QTextView* view = new QTextView( &dlg ); |
1010 | lay->addWidget( view ); | 837 | lay->addWidget( view ); |
1011 | QPushButton* btnOk = new QPushButton( tr("Ok"), &dlg ); | 838 | QPushButton* btnOk = new QPushButton( tr("Ok"), &dlg ); |
1012 | connect( btnOk, SIGNAL(clicked() ), &dlg, SLOT(accept() ) ); | 839 | connect( btnOk, SIGNAL(clicked() ), &dlg, SLOT(accept() ) ); |
1013 | lay->addWidget( btnOk ); | 840 | lay->addWidget( btnOk ); |
1014 | 841 | ||
1015 | QString text = tr("<h1>Alarm at %1</h1><br>").arg( TimeString::dateString( dt ) ); | 842 | QString text = tr("<h1>Alarm at %1</h1><br>").arg( TimeString::dateString( dt ) ); |
1016 | text += todo.toRichText(); | 843 | text += todo.toRichText(); |
1017 | view->setText( text ); | 844 | view->setText( text ); |
1018 | 845 | ||
1019 | bool needToStay = QPEApplication::execDialog( &dlg ); | 846 | bool needToStay = QPEApplication::execDialog( &dlg ); |
1020 | 847 | ||
1021 | if (loud) | 848 | if (loud) |
1022 | killAlarm(); | 849 | killAlarm(); |
1023 | 850 | ||
1024 | if (needToStay) { | 851 | if (needToStay) { |
1025 | // showMaximized(); | 852 | // showMaximized(); |
1026 | // raise(); | 853 | // raise(); |
1027 | QPEApplication::setKeepRunning(); | 854 | QPEApplication::setKeepRunning(); |
1028 | // setActiveWindow(); | 855 | // setActiveWindow(); |
1029 | } | 856 | } |
1030 | 857 | ||
1031 | } | 858 | } |
1032 | 859 | ||
diff --git a/core/pim/todo/mainwindow.h b/core/pim/todo/mainwindow.h index f0d6a42..c0fe805 100644 --- a/core/pim/todo/mainwindow.h +++ b/core/pim/todo/mainwindow.h | |||
@@ -1,211 +1,198 @@ | |||
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 | namespace Todo { | 52 | namespace Todo { |
53 | typedef TodoView View; | 53 | typedef TodoView View; |
54 | class TemplateManager; | 54 | class TemplateManager; |
55 | class Editor; | 55 | class Editor; |
56 | class TodoShow; | 56 | class TodoShow; |
57 | class TemplateEditor; | ||
58 | struct QuickEditBase; | 57 | struct QuickEditBase; |
59 | 58 | ||
60 | class MainWindow : public Opie::OPimMainWindow { | 59 | class MainWindow : public Opie::OPimMainWindow { |
61 | Q_OBJECT | 60 | Q_OBJECT |
62 | friend class TodoView; // avoid QObject here.... | 61 | friend class TodoView; // avoid QObject here.... |
63 | friend class TodoShow; // avoid QObject | 62 | friend class TodoShow; // avoid QObject |
64 | public: | 63 | public: |
65 | /* Opie::Core::OApplicationFactory application Name */ | 64 | /* Opie::Core::OApplicationFactory application Name */ |
66 | static QString appName() { return QString::fromLatin1("todolist"); } | 65 | static QString appName() { return QString::fromLatin1("todolist"); } |
67 | 66 | ||
68 | MainWindow( QWidget *parent = 0, | 67 | MainWindow( QWidget *parent = 0, |
69 | const char* name = 0, WFlags fl = 0 ); | 68 | const char* name = 0, WFlags fl = 0 ); |
70 | ~MainWindow(); | 69 | ~MainWindow(); |
71 | 70 | ||
72 | /** return a context menu for an OPimTodo */ | 71 | /** return a context menu for an OPimTodo */ |
73 | QPopupMenu* contextMenu(int uid, bool doesRecur = FALSE ); | 72 | QPopupMenu* contextMenu(int uid, bool doesRecur = FALSE ); |
74 | QPopupMenu* options(); | ||
75 | QPopupMenu* edit(); | ||
76 | QToolBar* toolbar(); | ||
77 | |||
78 | 73 | ||
79 | void updateList(); | 74 | void updateList(); |
80 | OPimTodoAccess::List list()const; | 75 | OPimTodoAccess::List list()const; |
81 | OPimTodoAccess::List sorted( bool asc, int sortOrder ); | 76 | OPimTodoAccess::List sorted( bool asc, int sortOrder ); |
82 | OPimTodoAccess::List sorted( bool asc, int sortOrder, int addFilter ); | 77 | OPimTodoAccess::List sorted( bool asc, int sortOrder, int addFilter ); |
83 | 78 | ||
84 | OPimTodo event(int uid ); | 79 | OPimTodo event(int uid ); |
85 | 80 | ||
86 | bool isSyncing()const; | 81 | bool isSyncing()const; |
87 | bool showCompleted()const; | 82 | bool showCompleted()const; |
88 | bool showDeadline()const; | 83 | bool showDeadline()const; |
89 | bool showOverDue()const; | 84 | bool showOverDue()const; |
90 | bool showQuickTask()const; | 85 | bool showQuickTask()const; |
91 | QString currentCategory()const; | 86 | QString currentCategory()const; |
92 | int currentCatId(); | 87 | int currentCatId(); |
93 | TemplateManager* templateManager(); | 88 | TemplateManager* templateManager(); |
94 | QuickEditBase* quickEditor(); | 89 | QuickEditBase* quickEditor(); |
95 | 90 | ||
96 | void updateTodo( const OPimTodo& ); | 91 | void updateTodo( const OPimTodo& ); |
97 | void populateTemplates(); | ||
98 | Editor* currentEditor(); | 92 | Editor* currentEditor(); |
99 | void setReadAhead(uint count ); | 93 | void setReadAhead(uint count ); |
100 | private slots: | 94 | private slots: |
101 | void slotQuickEntered(); | 95 | void slotQuickEntered(); |
102 | void populateCategories(); | ||
103 | void slotReload(); | 96 | void slotReload(); |
104 | void slotFlush(); | 97 | void slotFlush(); |
105 | 98 | ||
106 | protected: | 99 | protected: |
107 | void closeEvent( QCloseEvent* e ); | 100 | void closeEvent( QCloseEvent* e ); |
108 | 101 | ||
109 | private: | 102 | private: |
110 | /* handle setting and removing alarms */ | 103 | /* handle setting and removing alarms */ |
111 | void handleAlarms( const OPimTodo& oldTodo, const OPimTodo& newTodo ); | 104 | void handleAlarms( const OPimTodo& oldTodo, const OPimTodo& newTodo ); |
112 | void receiveFile( const QString& filename ); | 105 | void receiveFile( const QString& filename ); |
113 | void connectBase( ViewBase* ); | 106 | void connectBase( ViewBase* ); |
114 | void initUI(); | 107 | void initUI(); |
115 | void initActions(); | 108 | void initActions(); |
116 | void initConfig(); | 109 | void initConfig(); |
117 | void initViews(); | 110 | void initViews(); |
118 | void initEditor(); | 111 | void initEditor(); |
119 | void initShow(); | 112 | void initShow(); |
120 | void initTemplate(); | ||
121 | void raiseCurrentView(); | 113 | void raiseCurrentView(); |
122 | ViewBase* currentView(); | 114 | ViewBase* currentView(); |
123 | ViewBase* m_curView; | 115 | ViewBase* m_curView; |
124 | bool m_showing : 1; // used to see if we show a todo in the cases we shouldn't change the table | 116 | bool m_showing : 1; // used to see if we show a todo in the cases we shouldn't change the table |
125 | QuickEditBase* m_curQuick; | 117 | QuickEditBase* m_curQuick; |
126 | Editor* m_curEdit; | 118 | Editor* m_curEdit; |
127 | TodoShow* currentShow(); | 119 | TodoShow* currentShow(); |
128 | TodoShow* m_curShow; | 120 | TodoShow* m_curShow; |
129 | TemplateEditor* currentTemplateEditor(); | ||
130 | TemplateEditor* m_curTempEd; | ||
131 | 121 | ||
132 | QMenuBar* m_bar; | ||
133 | QToolBar* m_tool; | ||
134 | QAction* m_editAction, | 122 | QAction* m_editAction, |
135 | *m_deleteAction, | 123 | *m_deleteAction, |
136 | *m_findAction, | 124 | *m_findAction, |
137 | *m_completedAction, | 125 | *m_completedAction, |
138 | *m_showDeadLineAction, | 126 | *m_showDeadLineAction, |
139 | *m_deleteAllAction, | 127 | *m_deleteAllAction, |
140 | *m_deleteCompleteAction, | 128 | *m_deleteCompleteAction, |
141 | *m_duplicateAction, | 129 | *m_duplicateAction, |
142 | *m_showOverDueAction, | 130 | *m_showOverDueAction, |
143 | *m_showQuickTaskAction, | 131 | *m_showQuickTaskAction, |
144 | *m_effectiveAction; | 132 | *m_effectiveAction; |
145 | Opie::Ui::OWidgetStack *m_stack; | 133 | Opie::Ui::OWidgetStack *m_stack; |
146 | QPopupMenu* m_catMenu, | ||
147 | *m_edit, | ||
148 | *m_options, | ||
149 | *m_template; | ||
150 | 134 | ||
151 | bool m_syncing:1; | 135 | bool m_syncing:1; |
152 | bool m_deadline:1; | 136 | bool m_deadline:1; |
153 | bool m_completed:1; | 137 | bool m_completed:1; |
154 | bool m_overdue:1; | 138 | bool m_overdue:1; |
155 | bool m_quicktask:1; | 139 | bool m_quicktask:1; |
156 | TodoManager m_todoMgr; | 140 | TodoManager m_todoMgr; |
157 | QString m_curCat; | 141 | QString m_curCat; |
158 | QList<ViewBase> m_views; | 142 | QList<ViewBase> m_views; |
159 | uint m_counter; | 143 | uint m_counter; |
160 | TemplateManager* m_tempManager; | 144 | TemplateManager* m_tempManager; |
161 | 145 | ||
162 | 146 | ||
163 | private slots: | 147 | private slots: |
148 | void initStuff(); | ||
149 | |||
150 | void slotItemNew(); | ||
151 | void slotItemEdit(); | ||
152 | void slotItemDuplicate(); | ||
153 | void slotItemDelete(); | ||
154 | void slotItemBeam(); | ||
155 | void slotItemFind(); | ||
156 | void slotConfigure(); | ||
157 | |||
164 | void slotShow(int); | 158 | void slotShow(int); |
165 | void slotEdit(int); | 159 | void slotEdit(int); |
166 | void slotUpdate3( QWidget* ); | 160 | void slotUpdate3( QWidget* ); |
167 | void slotComplete( int uid ); | 161 | void slotComplete( int uid ); |
168 | void slotComplete( const OPimTodo& ev ); | 162 | void slotComplete( const OPimTodo& ev ); |
169 | void slotNewFromTemplate(int id ); | ||
170 | void slotNew(); | ||
171 | void slotDuplicate(); | ||
172 | 163 | ||
173 | void slotDelete(); | ||
174 | void slotDelete(int uid ); | 164 | void slotDelete(int uid ); |
175 | void slotDeleteAll(); | 165 | void slotDeleteAll(); |
176 | void slotDeleteCompleted(); | 166 | void slotDeleteCompleted(); |
177 | 167 | ||
178 | void slotEdit(); | ||
179 | void slotFind(); | ||
180 | 168 | ||
181 | void setCategory( int ); | 169 | void setCategory( const QString &category ); |
182 | 170 | ||
183 | void slotShowDeadLine( bool ); | 171 | void slotShowDeadLine( bool ); |
184 | void slotShowCompleted( bool ); | 172 | void slotShowCompleted( bool ); |
185 | void slotShowQuickTask( bool ); | 173 | void slotShowQuickTask( bool ); |
186 | 174 | ||
187 | void setDocument( const QString& ); | 175 | void setDocument( const QString& ); |
188 | 176 | ||
189 | 177 | ||
190 | void slotBeam(); | ||
191 | void beamDone( Ir* ); | 178 | void beamDone( Ir* ); |
192 | void slotShowDetails(); | 179 | void slotShowDetails(); |
193 | void slotShowNext(); | 180 | void slotShowNext(); |
194 | void slotShowPrev(); | 181 | void slotShowPrev(); |
195 | void slotShowDue( bool ); | 182 | void slotShowDue( bool ); |
196 | void slotReturnFromView(); // for TodoShow... | 183 | void slotReturnFromView(); // for TodoShow... |
197 | /* reimplementation from opimmainwindow */ | 184 | /* reimplementation from opimmainwindow */ |
198 | protected slots: | 185 | protected slots: |
199 | void flush(); | 186 | void flush(); |
200 | void reload(); | 187 | void reload(); |
201 | int create(); | 188 | int create(); |
202 | bool remove( int uid ); | 189 | bool remove( int uid ); |
203 | void beam(int uid); | 190 | void beam(int uid); |
204 | void show( int uid ); | 191 | void show( int uid ); |
205 | void edit( int uid ); | 192 | void edit( int uid ); |
206 | void add( const Opie::OPimRecord& ); | 193 | void add( const Opie::OPimRecord& ); |
207 | void doAlarm( const QDateTime& dt, int uid ); | 194 | void doAlarm( const QDateTime& dt, int uid ); |
208 | }; | 195 | }; |
209 | } | 196 | } |
210 | 197 | ||
211 | #endif | 198 | #endif |
diff --git a/core/pim/todo/newtaskdlg.cpp b/core/pim/todo/newtaskdlg.cpp new file mode 100644 index 0000000..0b5a29d --- a/dev/null +++ b/core/pim/todo/newtaskdlg.cpp | |||
@@ -0,0 +1,78 @@ | |||
1 | /* | ||
2 | =. This file is part of the OPIE Project | ||
3 | .=l. Copyright (c) 2005 Dan Williams <drw@handhelds.org> | ||
4 | .>+-= | ||
5 | _;:, .> :=|. This program is free software; you can | ||
6 | .> <`_, > . <= redistribute it and/or modify it under | ||
7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | ||
8 | .="- .-=="i, .._ License as published by the Free Software | ||
9 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
10 | ._= =} : or (at your option) any later version. | ||
11 | .%`+i> _;_. | ||
12 | .i_,=:_. -<s. This program is distributed in the hope that | ||
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
14 | : .. .:, . . . without even the implied warranty of | ||
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
17 | ..}^=.= = ; Library General Public License for more | ||
18 | ++= -. .` .: details. | ||
19 | : = ...= . :.=- | ||
20 | -. .:....=;==+<; You should have received a copy of the GNU | ||
21 | -_. . . )=. = General Public License along with | ||
22 | -- :-=` this library; see the file COPYING.LIB. | ||
23 | If not, write to the Free Software Foundation, | ||
24 | Inc., 59 Temple Place - Suite 330, | ||
25 | Boston, MA 02111-1307, USA. | ||
26 | |||
27 | */ | ||
28 | |||
29 | #include "newtaskdlg.h" | ||
30 | |||
31 | #include <qbuttongroup.h> | ||
32 | #include <qcombobox.h> | ||
33 | #include <qlayout.h> | ||
34 | #include <qradiobutton.h> | ||
35 | |||
36 | NewTaskDlg::NewTaskDlg( const QStringList &templates, QWidget *parent ) | ||
37 | : QDialog( parent, QString::null, true, WStyle_ContextHelp ) | ||
38 | { | ||
39 | setCaption( tr( "New Task" ) ); | ||
40 | |||
41 | QButtonGroup *bg = new QButtonGroup( this ); | ||
42 | bg->hide(); | ||
43 | |||
44 | QVBoxLayout *layout = new QVBoxLayout( this, 10, 3 ); | ||
45 | |||
46 | QRadioButton *btn = new QRadioButton( tr( "Blank task" ), this ); | ||
47 | btn->setChecked( true ); | ||
48 | bg->insert( btn ); | ||
49 | layout->addWidget( btn ); | ||
50 | |||
51 | layout->addStretch(); | ||
52 | |||
53 | m_useTemplate = new QRadioButton( tr( "Using template:" ), this ); | ||
54 | connect( m_useTemplate, SIGNAL(toggled(bool)), this, SLOT(slotUseTemplate(bool)) ); | ||
55 | bg->insert( m_useTemplate ); | ||
56 | layout->addWidget( m_useTemplate ); | ||
57 | |||
58 | m_templateList = new QComboBox( this ); | ||
59 | m_templateList->insertStringList( templates ); | ||
60 | m_templateList->setEnabled( false ); | ||
61 | layout->addWidget( m_templateList ); | ||
62 | |||
63 | layout->addStretch(); | ||
64 | } | ||
65 | |||
66 | QString NewTaskDlg::tempSelected() { | ||
67 | QString tempStr; | ||
68 | if ( m_useTemplate->isChecked() ) | ||
69 | tempStr = m_templateList->currentText(); | ||
70 | |||
71 | return tempStr; | ||
72 | } | ||
73 | |||
74 | void NewTaskDlg::slotUseTemplate( bool on ) { | ||
75 | m_templateList->setEnabled( on ); | ||
76 | if ( on ) | ||
77 | m_templateList->setFocus(); | ||
78 | } | ||
diff --git a/core/pim/todo/newtaskdlg.h b/core/pim/todo/newtaskdlg.h new file mode 100644 index 0000000..31398b3 --- a/dev/null +++ b/core/pim/todo/newtaskdlg.h | |||
@@ -0,0 +1,56 @@ | |||
1 | /* | ||
2 | =. This file is part of the OPIE Project | ||
3 | .=l. Copyright (c) 2002 <> | ||
4 | .>+-= | ||
5 | _;:, .> :=|. This program is free software; you can | ||
6 | .> <`_, > . <= redistribute it and/or modify it under | ||
7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | ||
8 | .="- .-=="i, .._ License as published by the Free Software | ||
9 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
10 | ._= =} : or (at your option) any later version. | ||
11 | .%`+i> _;_. | ||
12 | .i_,=:_. -<s. This program is distributed in the hope that | ||
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
14 | : .. .:, . . . without even the implied warranty of | ||
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
17 | ..}^=.= = ; Library General Public License for more | ||
18 | ++= -. .` .: details. | ||
19 | : = ...= . :.=- | ||
20 | -. .:....=;==+<; You should have received a copy of the GNU | ||
21 | -_. . . )=. = General Public License along with | ||
22 | -- :-=` this library; see the file COPYING.LIB. | ||
23 | If not, write to the Free Software Foundation, | ||
24 | Inc., 59 Temple Place - Suite 330, | ||
25 | Boston, MA 02111-1307, USA. | ||
26 | |||
27 | */ | ||
28 | |||
29 | #ifndef NEWTASKDLG_H | ||
30 | #define NEWTASKDLG_H | ||
31 | |||
32 | #include <qdialog.h> | ||
33 | |||
34 | #include <qstringlist.h> | ||
35 | |||
36 | class QComboBox; | ||
37 | class QRadioButton; | ||
38 | |||
39 | class NewTaskDlg : public QDialog | ||
40 | { | ||
41 | Q_OBJECT | ||
42 | |||
43 | public: | ||
44 | NewTaskDlg( const QStringList &templates, QWidget *parent = 0l ); | ||
45 | |||
46 | QString tempSelected(); | ||
47 | |||
48 | private: | ||
49 | QRadioButton *m_useTemplate; | ||
50 | QComboBox *m_templateList; | ||
51 | |||
52 | private slots: | ||
53 | void slotUseTemplate( bool on ); | ||
54 | }; | ||
55 | |||
56 | #endif | ||
diff --git a/core/pim/todo/tableview.cpp b/core/pim/todo/tableview.cpp index 221faca..c64ad46 100644 --- a/core/pim/todo/tableview.cpp +++ b/core/pim/todo/tableview.cpp | |||
@@ -1,644 +1,624 @@ | |||
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 <zecke> | 3 | .=l. Copyright (c) 2002 <zecke> |
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 | #include <stdlib.h> | 28 | #include <stdlib.h> |
29 | #include <cmath> | 29 | #include <cmath> |
30 | #include <cctype> | 30 | #include <cctype> |
31 | 31 | ||
32 | #include <opie2/odebug.h> | 32 | #include <opie2/odebug.h> |
33 | #include <opie2/opimrecurrence.h> | 33 | #include <opie2/opimrecurrence.h> |
34 | 34 | ||
35 | #include <qpe/config.h> | 35 | #include <qpe/config.h> |
36 | #include <qpe/qpeapplication.h> | ||
36 | #include <qpe/resource.h> | 37 | #include <qpe/resource.h> |
37 | 38 | ||
38 | #include <qcombobox.h> | 39 | #include <qcombobox.h> |
39 | #include <qlineedit.h> | 40 | #include <qlineedit.h> |
40 | #include <qtimer.h> | ||
41 | #include <qpopupmenu.h> | 41 | #include <qpopupmenu.h> |
42 | 42 | ||
43 | #include "mainwindow.h" | 43 | #include "mainwindow.h" |
44 | //#include "tableitems.h" | 44 | //#include "tableitems.h" |
45 | #include "tableview.h" | 45 | #include "tableview.h" |
46 | 46 | ||
47 | using namespace Todo; | 47 | using namespace Todo; |
48 | 48 | ||
49 | namespace { | 49 | namespace { |
50 | static const int BoxSize = 14; | 50 | static const int BoxSize = 14; |
51 | static const int RowHeight = 20; | 51 | static const int RowHeight = 20; |
52 | } | 52 | } |
53 | 53 | ||
54 | TableView::EditorWidget::EditorWidget() : m_wid(0l), m_row(-1), m_col(-1) { | 54 | TableView::EditorWidget::EditorWidget() : m_wid(0l), m_row(-1), m_col(-1) { |
55 | } | 55 | } |
56 | void TableView::EditorWidget::setCellWidget(QWidget* wid, int row, int col ) { | 56 | void TableView::EditorWidget::setCellWidget(QWidget* wid, int row, int col ) { |
57 | m_wid = wid; | 57 | m_wid = wid; |
58 | m_row = row; | 58 | m_row = row; |
59 | m_col = col; | 59 | m_col = col; |
60 | } | 60 | } |
61 | void TableView::EditorWidget::releaseCellWidget() { | 61 | void TableView::EditorWidget::releaseCellWidget() { |
62 | m_wid = 0; | 62 | m_wid = 0; |
63 | m_row = m_col = -1; | 63 | m_row = m_col = -1; |
64 | } | 64 | } |
65 | QWidget* TableView::EditorWidget::cellWidget()const { | 65 | QWidget* TableView::EditorWidget::cellWidget()const { |
66 | return m_wid; | 66 | return m_wid; |
67 | } | 67 | } |
68 | int TableView::EditorWidget::cellRow()const { | 68 | int TableView::EditorWidget::cellRow()const { |
69 | return m_row; | 69 | return m_row; |
70 | } | 70 | } |
71 | int TableView::EditorWidget::cellCol()const { | 71 | int TableView::EditorWidget::cellCol()const { |
72 | return m_col; | 72 | return m_col; |
73 | } | 73 | } |
74 | 74 | ||
75 | 75 | ||
76 | void TableView::initConfig() { | 76 | void TableView::initConfig() { |
77 | Config config( "todo" ); | 77 | Config config( "todo" ); |
78 | config.setGroup( "Options" ); | 78 | config.setGroup( "Options" ); |
79 | m_completeStrokeWidth = config.readNumEntry( "CompleteStrokeWidth", 8 ); | 79 | m_completeStrokeWidth = config.readNumEntry( "CompleteStrokeWidth", 8 ); |
80 | for (int i = 0; i < numCols(); i++ ) { | 80 | for (int i = 0; i < numCols(); i++ ) { |
81 | int width = config.readNumEntry("Width"+QString::number(i), -1 ); | 81 | int width = config.readNumEntry("Width"+QString::number(i), -1 ); |
82 | setColumnWidth(i, width == -1 ? columnWidth(i) : width ); | 82 | setColumnWidth(i, width == -1 ? columnWidth(i) : width ); |
83 | } | 83 | } |
84 | } | 84 | } |
85 | 85 | ||
86 | TableView::TableView( MainWindow* window, QWidget* wid ) | 86 | TableView::TableView( MainWindow* window, QWidget* wid ) |
87 | : QTable( wid ), TodoView( window ) { | 87 | : QTable( wid ), TodoView( window ) { |
88 | 88 | ||
89 | setName("TableView"); | 89 | setName("TableView"); |
90 | // Load icons | 90 | // Load icons |
91 | // TODO - probably should be done globally somewhere else, | 91 | // TODO - probably should be done globally somewhere else, |
92 | // see also quickeditimpl.cpp/h, taskeditoroverview.cpp/h | 92 | // see also quickeditimpl.cpp/h, taskeditoroverview.cpp/h |
93 | m_pic_completed = Resource::loadPixmap( "todo/completed" ); | 93 | m_pic_completed = Resource::loadPixmap( "todo/completed" ); |
94 | QString namestr; | 94 | QString namestr; |
95 | for ( unsigned int i = 1; i < 6; i++ ) { | 95 | for ( unsigned int i = 1; i < 6; i++ ) { |
96 | namestr = "todo/priority"; | 96 | namestr = "todo/priority"; |
97 | namestr.append( QString::number( i ) ); | 97 | namestr.append( QString::number( i ) ); |
98 | m_pic_priority[ i - 1 ] = Resource::loadPixmap( namestr ); | 98 | m_pic_priority[ i - 1 ] = Resource::loadPixmap( namestr ); |
99 | } | 99 | } |
100 | 100 | ||
101 | setUpdatesEnabled( false ); | 101 | setUpdatesEnabled( false ); |
102 | viewport()->setUpdatesEnabled( false ); | 102 | viewport()->setUpdatesEnabled( false ); |
103 | m_enablePaint = false; | 103 | m_enablePaint = false; |
104 | setNumRows(0); | 104 | setNumRows(0); |
105 | setNumCols(4); | 105 | setNumCols(4); |
106 | 106 | ||
107 | horizontalHeader()->setLabel( 0, QWidget::tr("C.") ); | 107 | horizontalHeader()->setLabel( 0, QWidget::tr("C.") ); |
108 | horizontalHeader()->setLabel( 1, QWidget::tr("Priority") ); | 108 | horizontalHeader()->setLabel( 1, QWidget::tr("Priority") ); |
109 | horizontalHeader()->setLabel( 2, QWidget::tr("Summary" ) ); | 109 | horizontalHeader()->setLabel( 2, QWidget::tr("Summary" ) ); |
110 | horizontalHeader()->setLabel( 3, QWidget::tr("Deadline") ); | 110 | horizontalHeader()->setLabel( 3, QWidget::tr("Deadline") ); |
111 | 111 | ||
112 | setShowDeadline( todoWindow()->showDeadline() ); | 112 | setShowDeadline( todoWindow()->showDeadline() ); |
113 | 113 | ||
114 | setSorting( TRUE ); | 114 | setSorting( TRUE ); |
115 | setSelectionMode( NoSelection ); | 115 | setSelectionMode( NoSelection ); |
116 | 116 | ||
117 | setLeftMargin( 0 ); | 117 | setLeftMargin( 0 ); |
118 | verticalHeader()->hide(); | 118 | verticalHeader()->hide(); |
119 | 119 | ||
120 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | ||
120 | connect((QTable*)this, SIGNAL( clicked(int,int,int,const QPoint&) ), | 121 | connect((QTable*)this, SIGNAL( clicked(int,int,int,const QPoint&) ), |
121 | this, SLOT( slotClicked(int,int,int,const QPoint&) ) ); | 122 | this, SLOT( slotClicked(int,int,int,const QPoint&) ) ); |
122 | connect((QTable*)this, SIGNAL( pressed(int,int,int,const QPoint&) ), | ||
123 | this, SLOT( slotPressed(int,int,int,const QPoint&) ) ); | ||
124 | connect((QTable*)this, SIGNAL(valueChanged(int,int) ), | 123 | connect((QTable*)this, SIGNAL(valueChanged(int,int) ), |
125 | this, SLOT( slotValueChanged(int,int) ) ); | 124 | this, SLOT( slotValueChanged(int,int) ) ); |
126 | connect((QTable*)this, SIGNAL(currentChanged(int,int) ), | 125 | connect((QTable*)this, SIGNAL(currentChanged(int,int) ), |
127 | this, SLOT( slotCurrentChanged(int,int) ) ); | 126 | this, SLOT( slotCurrentChanged(int,int) ) ); |
128 | 127 | ||
129 | m_menuTimer = new QTimer( this ); | ||
130 | connect( m_menuTimer, SIGNAL(timeout()), | ||
131 | this, SLOT(slotShowMenu()) ); | ||
132 | |||
133 | /* now let's init the config */ | 128 | /* now let's init the config */ |
134 | initConfig(); | 129 | initConfig(); |
135 | 130 | ||
136 | 131 | ||
137 | m_enablePaint = true; | 132 | m_enablePaint = true; |
138 | setUpdatesEnabled( true ); | 133 | setUpdatesEnabled( true ); |
139 | viewport()->setUpdatesEnabled( true ); | 134 | viewport()->setUpdatesEnabled( true ); |
140 | viewport()->update(); | 135 | viewport()->update(); |
141 | setSortOrder( Opie::OPimTodoAccess::Completed ); | 136 | setSortOrder( Opie::OPimTodoAccess::Completed ); |
142 | setAscending( TRUE ); | 137 | setAscending( TRUE ); |
143 | m_first = true; | 138 | m_first = true; |
144 | 139 | ||
145 | 140 | ||
146 | } | 141 | } |
147 | /* a new day has started | 142 | /* a new day has started |
148 | * update the day | 143 | * update the day |
149 | */ | 144 | */ |
150 | void TableView::newDay() { | 145 | void TableView::newDay() { |
151 | clear(); | 146 | clear(); |
152 | updateView(); | 147 | updateView(); |
153 | } | 148 | } |
154 | TableView::~TableView() { | 149 | TableView::~TableView() { |
155 | Config config( "todo" ); | 150 | Config config( "todo" ); |
156 | config.setGroup( "Options" ); | 151 | config.setGroup( "Options" ); |
157 | for (int i = 0; i < numCols(); i++ ) | 152 | for (int i = 0; i < numCols(); i++ ) |
158 | config.writeEntry("Width"+QString::number(i), columnWidth(i) ); | 153 | config.writeEntry("Width"+QString::number(i), columnWidth(i) ); |
159 | } | 154 | } |
160 | void TableView::slotShowMenu() { | ||
161 | QPopupMenu *menu = todoWindow()->contextMenu( current(), sorted()[currentRow()].recurrence().doesRecur() ); | ||
162 | menu->exec(QCursor::pos() ); | ||
163 | delete menu; | ||
164 | } | ||
165 | QString TableView::type() const { | 155 | QString TableView::type() const { |
166 | return QString::fromLatin1( tr("Table View") ); | 156 | return QString::fromLatin1( tr("Table View") ); |
167 | } | 157 | } |
168 | int TableView::current() { | 158 | int TableView::current() { |
169 | if (numRows() == 0 ) return 0; | 159 | if (numRows() == 0 ) return 0; |
170 | int uid = sorted().uidAt(currentRow() ); | 160 | int uid = sorted().uidAt(currentRow() ); |
171 | 161 | ||
172 | return uid; | 162 | return uid; |
173 | } | 163 | } |
174 | int TableView::next() { | 164 | int TableView::next() { |
175 | if ( numRows() == 0 ) return 0; | 165 | if ( numRows() == 0 ) return 0; |
176 | if ( currentRow() + 1 >= numRows() ) return 0; | 166 | if ( currentRow() + 1 >= numRows() ) return 0; |
177 | setCurrentCell( currentRow() +1, currentColumn() ); | 167 | setCurrentCell( currentRow() +1, currentColumn() ); |
178 | return sorted().uidAt( currentRow() ); | 168 | return sorted().uidAt( currentRow() ); |
179 | } | 169 | } |
180 | int TableView::prev() { | 170 | int TableView::prev() { |
181 | if ( numRows() == 0 ) return 0; | 171 | if ( numRows() == 0 ) return 0; |
182 | if ( currentRow() - 1 < 0 ) return 0; | 172 | if ( currentRow() - 1 < 0 ) return 0; |
183 | setCurrentCell( currentRow() -1, currentColumn() ); | 173 | setCurrentCell( currentRow() -1, currentColumn() ); |
184 | return sorted().uidAt( currentRow() ); | 174 | return sorted().uidAt( currentRow() ); |
185 | 175 | ||
186 | } | 176 | } |
187 | QString TableView::currentRepresentation() { | 177 | QString TableView::currentRepresentation() { |
188 | OPimTodo to = sorted()[currentRow()]; | 178 | OPimTodo to = sorted()[currentRow()]; |
189 | return to.summary().isEmpty() ? to.description().left(20) : to.summary() ; | 179 | return to.summary().isEmpty() ? to.description().left(20) : to.summary() ; |
190 | } | 180 | } |
191 | /* show overdue */ | 181 | /* show overdue */ |
192 | void TableView::showOverDue( bool ) { | 182 | void TableView::showOverDue( bool ) { |
193 | clear(); | 183 | clear(); |
194 | updateView(); | 184 | updateView(); |
195 | } | 185 | } |
196 | 186 | ||
197 | void TableView::updateView( ) { | 187 | void TableView::updateView( ) { |
198 | m_row = false; | 188 | m_row = false; |
199 | static int id; | 189 | static int id; |
200 | id = startTimer(4000 ); | 190 | id = startTimer(4000 ); |
201 | /* FIXME we want one page to be read! | 191 | /* FIXME we want one page to be read! |
202 | * | 192 | * |
203 | * Calculate that screensize | 193 | * Calculate that screensize |
204 | */ | 194 | */ |
205 | todoWindow()->setReadAhead( 4 ); | 195 | todoWindow()->setReadAhead( 4 ); |
206 | sort(); | 196 | sort(); |
207 | OPimTodoAccess::List::Iterator it, end; | 197 | OPimTodoAccess::List::Iterator it, end; |
208 | it = sorted().begin(); | 198 | it = sorted().begin(); |
209 | end = sorted().end(); | 199 | end = sorted().end(); |
210 | 200 | ||
211 | QTime time; | 201 | QTime time; |
212 | time.start(); | 202 | time.start(); |
213 | m_enablePaint = false; | 203 | m_enablePaint = false; |
214 | setUpdatesEnabled( false ); | 204 | setUpdatesEnabled( false ); |
215 | viewport()->setUpdatesEnabled( false ); | 205 | viewport()->setUpdatesEnabled( false ); |
216 | 206 | ||
217 | setNumRows( it.count() ); | 207 | setNumRows( it.count() ); |
218 | if ( it.count() == 0 ) | 208 | if ( it.count() == 0 ) |
219 | killTimer(id); | 209 | killTimer(id); |
220 | 210 | ||
221 | // int elc = time.elapsed(); | 211 | // int elc = time.elapsed(); |
222 | setUpdatesEnabled( true ); | 212 | setUpdatesEnabled( true ); |
223 | viewport()->setUpdatesEnabled( true ); | 213 | viewport()->setUpdatesEnabled( true ); |
224 | viewport()->update(); | 214 | viewport()->update(); |
225 | 215 | ||
226 | m_enablePaint = true; | 216 | m_enablePaint = true; |
227 | // int el = time.elapsed(); | 217 | // int el = time.elapsed(); |
228 | } | 218 | } |
229 | void TableView::setTodo( int, const OPimTodo&) { | 219 | void TableView::setTodo( int, const OPimTodo&) { |
230 | sort(); | 220 | sort(); |
231 | 221 | ||
232 | /* repaint */ | 222 | /* repaint */ |
233 | repaint(); | 223 | repaint(); |
234 | } | 224 | } |
235 | void TableView::addEvent( const OPimTodo&) { | 225 | void TableView::addEvent( const OPimTodo&) { |
236 | 226 | ||
237 | /* fix problems of not showing the 'Haken' */ | 227 | /* fix problems of not showing the 'Haken' */ |
238 | updateView(); | 228 | updateView(); |
239 | } | 229 | } |
240 | /* | 230 | /* |
241 | * find the event | 231 | * find the event |
242 | * and then replace the complete row | 232 | * and then replace the complete row |
243 | */ | 233 | */ |
244 | void TableView::replaceEvent( const OPimTodo& ev) { | 234 | void TableView::replaceEvent( const OPimTodo& ev) { |
245 | addEvent( ev ); | 235 | addEvent( ev ); |
246 | } | 236 | } |
247 | /* | 237 | /* |
248 | * re aligning table can be slow too | 238 | * re aligning table can be slow too |
249 | * FIXME: look what performs better | 239 | * FIXME: look what performs better |
250 | * either this or the old align table | 240 | * either this or the old align table |
251 | */ | 241 | */ |
252 | void TableView::removeEvent( int ) { | 242 | void TableView::removeEvent( int ) { |
253 | updateView(); | 243 | updateView(); |
254 | } | 244 | } |
255 | void TableView::setShowCompleted( bool ) { | 245 | void TableView::setShowCompleted( bool ) { |
256 | updateView(); | 246 | updateView(); |
257 | } | 247 | } |
258 | void TableView::setShowDeadline( bool b ) { | 248 | void TableView::setShowDeadline( bool b ) { |
259 | if ( b ) | 249 | if ( b ) |
260 | showColumn( 3 ); | 250 | showColumn( 3 ); |
261 | else | 251 | else |
262 | hideColumn( 3 ); | 252 | hideColumn( 3 ); |
263 | 253 | ||
264 | // Try to intelligently size columns | 254 | // Try to intelligently size columns |
265 | // TODO - would use width() below, but doesn't have valid value at time of c'tor | 255 | // TODO - would use width() below, but doesn't have valid value at time of c'tor |
266 | int col2width = 238; | 256 | int col2width = 238; |
267 | int width = m_pic_completed.width(); | 257 | int width = m_pic_completed.width(); |
268 | setColumnWidth( 0, width ); | 258 | setColumnWidth( 0, width ); |
269 | col2width -= width; | 259 | col2width -= width; |
270 | width = fontMetrics().boundingRect( horizontalHeader()->label( 1 ) ).width() + 8; | 260 | width = fontMetrics().boundingRect( horizontalHeader()->label( 1 ) ).width() + 8; |
271 | setColumnWidth( 1, width ); | 261 | setColumnWidth( 1, width ); |
272 | col2width -= width; | 262 | col2width -= width; |
273 | if ( b ) { | 263 | if ( b ) { |
274 | width = fontMetrics().boundingRect( horizontalHeader()->label( 3 ) ).width() + 8; | 264 | width = fontMetrics().boundingRect( horizontalHeader()->label( 3 ) ).width() + 8; |
275 | setColumnWidth( 3, width ); | 265 | setColumnWidth( 3, width ); |
276 | col2width -= width; | 266 | col2width -= width; |
277 | } | 267 | } |
278 | setColumnWidth( 2, col2width ); | 268 | setColumnWidth( 2, col2width ); |
279 | } | 269 | } |
280 | void TableView::setShowCategory( const QString& str) { | 270 | void TableView::setShowCategory( const QString& str) { |
281 | if ( str != m_oleCat || m_first ) | 271 | if ( str != m_oleCat || m_first ) |
282 | updateView(); | 272 | updateView(); |
283 | 273 | ||
284 | m_oleCat = str; | 274 | m_oleCat = str; |
285 | m_first = false; | 275 | m_first = false; |
286 | |||
287 | } | 276 | } |
288 | void TableView::clear() { | 277 | void TableView::clear() { |
289 | setNumRows(0); | 278 | setNumRows(0); |
290 | } | 279 | } |
291 | void TableView::slotClicked(int row, int col, int, | 280 | void TableView::slotClicked(int row, int col, int, |
292 | const QPoint& point) { | 281 | const QPoint& point) { |
293 | if ( m_editorWidget.cellWidget() ) { | 282 | if ( m_editorWidget.cellWidget() ) { |
294 | //setCellContentFromEditor(m_editorWidget.cellRow(), m_editorWidget.cellCol() ); | 283 | //setCellContentFromEditor(m_editorWidget.cellRow(), m_editorWidget.cellCol() ); |
295 | endEdit(m_editorWidget.cellRow(), m_editorWidget.cellCol(), | 284 | endEdit(m_editorWidget.cellRow(), m_editorWidget.cellCol(), |
296 | true, true ); | 285 | true, true ); |
297 | m_editorWidget.releaseCellWidget(); | 286 | m_editorWidget.releaseCellWidget(); |
298 | } | 287 | } |
299 | 288 | ||
300 | if ( !cellGeometry(row, col ).contains(point ) ) | 289 | if ( !cellGeometry(row, col ).contains(point ) ) |
301 | return; | 290 | return; |
302 | 291 | ||
303 | int ui= sorted().uidAt( row ); | 292 | int ui= sorted().uidAt( row ); |
304 | 293 | ||
305 | 294 | ||
306 | switch( col ) { | 295 | switch( col ) { |
307 | case 0:{ | 296 | case 0:{ |
308 | int x = point.x() -columnPos( col ); | 297 | int x = point.x() -columnPos( col ); |
309 | int y = point.y() -rowPos( row ); | 298 | int y = point.y() -rowPos( row ); |
310 | int w = columnWidth( col ); | 299 | int w = columnWidth( col ); |
311 | int h = rowHeight( row ); | 300 | int h = rowHeight( row ); |
312 | if ( x >= ( w - BoxSize ) / 2 && | 301 | if ( x >= ( w - BoxSize ) / 2 && |
313 | x <= ( w - BoxSize ) / 2 + BoxSize && | 302 | x <= ( w - BoxSize ) / 2 + BoxSize && |
314 | y >= ( h - BoxSize ) / 2 && | 303 | y >= ( h - BoxSize ) / 2 && |
315 | y <= ( h - BoxSize ) / 2 + BoxSize ) { | 304 | y <= ( h - BoxSize ) / 2 + BoxSize ) { |
316 | TodoView::complete(sorted()[row] ); | 305 | TodoView::complete(sorted()[row] ); |
317 | } | 306 | } |
318 | } | 307 | } |
319 | break; | 308 | break; |
320 | 309 | ||
321 | // Priority emit a double click... | 310 | // Priority emit a double click... |
322 | case 1:{ | 311 | case 1:{ |
323 | QWidget* wid = beginEdit( row, col, FALSE ); | 312 | QWidget* wid = beginEdit( row, col, FALSE ); |
324 | m_editorWidget.setCellWidget( wid, row, col ); | 313 | m_editorWidget.setCellWidget( wid, row, col ); |
325 | } | 314 | } |
326 | break; | 315 | break; |
327 | 316 | ||
328 | case 2: { | 317 | case 2: { |
329 | m_menuTimer->stop(); | ||
330 | showTodo( ui ); | 318 | showTodo( ui ); |
331 | break; | 319 | break; |
332 | } | 320 | } |
333 | case 3: { | 321 | case 3: { |
334 | m_menuTimer->stop(); | ||
335 | TodoView::edit( ui ); | 322 | TodoView::edit( ui ); |
336 | break; | 323 | break; |
337 | } | 324 | } |
338 | } | 325 | } |
339 | 326 | ||
340 | 327 | ||
341 | } | 328 | } |
342 | void TableView::slotPressed(int row, int col, int, | ||
343 | const QPoint& point) { | ||
344 | |||
345 | m_prevP = point; | ||
346 | /* TextColumn column */ | ||
347 | if ( col == 2 && cellGeometry( row, col ).contains( point ) ) | ||
348 | m_menuTimer->start( 750, TRUE ); | ||
349 | } | ||
350 | void TableView::slotValueChanged( int, int ) { | ||
351 | } | ||
352 | void TableView::slotCurrentChanged(int, int ) { | ||
353 | m_menuTimer->stop(); | ||
354 | } | ||
355 | QWidget* TableView::widget() { | 329 | QWidget* TableView::widget() { |
356 | return this; | 330 | return this; |
357 | } | 331 | } |
358 | /* | 332 | /* |
359 | * We need to overwrite sortColumn | 333 | * We need to overwrite sortColumn |
360 | * because we want to sort whole row | 334 | * because we want to sort whole row |
361 | * based | 335 | * based |
362 | * We event want to set the setOrder | 336 | * We event want to set the setOrder |
363 | * to a sort() and update() | 337 | * to a sort() and update() |
364 | */ | 338 | */ |
365 | void TableView::sortColumn( int col, bool asc, bool ) { | 339 | void TableView::sortColumn( int col, bool asc, bool ) { |
366 | switch(col) { | 340 | switch(col) { |
367 | case 1: | 341 | case 1: |
368 | col = Opie::OPimTodoAccess::Priority; | 342 | col = Opie::OPimTodoAccess::Priority; |
369 | break; | 343 | break; |
370 | case 2: | 344 | case 2: |
371 | col = Opie::OPimTodoAccess::SortSummary; | 345 | col = Opie::OPimTodoAccess::SortSummary; |
372 | break; | 346 | break; |
373 | case 3: | 347 | case 3: |
374 | col = Opie::OPimTodoAccess::Deadline; | 348 | col = Opie::OPimTodoAccess::Deadline; |
375 | break; | 349 | break; |
376 | case 0: | 350 | case 0: |
377 | default: | 351 | default: |
378 | col = Opie::OPimTodoAccess::Completed; | 352 | col = Opie::OPimTodoAccess::Completed; |
379 | break; | 353 | break; |
380 | } | 354 | } |
381 | 355 | ||
382 | setSortOrder( col ); | 356 | setSortOrder( col ); |
383 | setAscending( asc ); | 357 | setAscending( asc ); |
384 | updateView(); | 358 | updateView(); |
385 | } | 359 | } |
386 | void TableView::viewportPaintEvent( QPaintEvent* e) { | 360 | void TableView::viewportPaintEvent( QPaintEvent* e) { |
387 | if (m_enablePaint ) | 361 | if (m_enablePaint ) |
388 | QTable::viewportPaintEvent( e ); | 362 | QTable::viewportPaintEvent( e ); |
389 | } | 363 | } |
390 | /* | 364 | /* |
391 | * This segment is copyrighted by TT | 365 | * This segment is copyrighted by TT |
392 | * it was taken from their todolist | 366 | * it was taken from their todolist |
393 | * application this code is GPL | 367 | * application this code is GPL |
394 | */ | 368 | */ |
395 | void TableView::paintCell(QPainter* p, int row, int col, const QRect& cr, bool ) { | 369 | void TableView::paintCell(QPainter* p, int row, int col, const QRect& cr, bool ) { |
396 | const QColorGroup &cg = colorGroup(); | 370 | const QColorGroup &cg = colorGroup(); |
397 | 371 | ||
398 | p->save(); | 372 | p->save(); |
399 | 373 | ||
400 | OPimTodo task = sorted()[row]; | 374 | OPimTodo task = sorted()[row]; |
401 | 375 | ||
402 | // TODO - give user option for grid or bars? | 376 | // TODO - give user option for grid or bars? |
403 | 377 | ||
404 | // Paint alternating background bars | 378 | // Paint alternating background bars |
405 | if ( (row % 2 ) == 0 ) { | 379 | if ( (row % 2 ) == 0 ) { |
406 | p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Base ) ); | 380 | p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Base ) ); |
407 | p->setPen( QPen( cg.text() ) ); | 381 | p->setPen( QPen( cg.text() ) ); |
408 | } | 382 | } |
409 | else { | 383 | else { |
410 | p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Background ) ); | 384 | p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Background ) ); |
411 | p->setPen( QPen( cg.buttonText() ) ); | 385 | p->setPen( QPen( cg.buttonText() ) ); |
412 | } | 386 | } |
413 | 387 | ||
414 | // Paint grid | 388 | // Paint grid |
415 | //p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Base ) ); | 389 | //p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Base ) ); |
416 | //QPen op = p->pen(); | 390 | //QPen op = p->pen(); |
417 | //p->setPen(cg.mid()); | 391 | //p->setPen(cg.mid()); |
418 | //p->drawLine( 0, cr.height() - 1, cr.width() - 1, cr.height() - 1 ); | 392 | //p->drawLine( 0, cr.height() - 1, cr.width() - 1, cr.height() - 1 ); |
419 | //p->drawLine( cr.width() - 1, 0, cr.width() - 1, cr.height() - 1 ); | 393 | //p->drawLine( cr.width() - 1, 0, cr.width() - 1, cr.height() - 1 ); |
420 | //p->setPen(op); | 394 | //p->setPen(op); |
421 | 395 | ||
422 | QFont f = p->font(); | 396 | QFont f = p->font(); |
423 | QFontMetrics fm(f); | 397 | QFontMetrics fm(f); |
424 | 398 | ||
425 | int marg = ( cr.width() - BoxSize ) / 2; | 399 | int marg = ( cr.width() - BoxSize ) / 2; |
426 | int x = 0; | 400 | int x = 0; |
427 | int y = ( cr.height() - BoxSize ) / 2; | 401 | int y = ( cr.height() - BoxSize ) / 2; |
428 | 402 | ||
429 | switch(col) { | 403 | switch(col) { |
430 | case 0: // completed field | 404 | case 0: // completed field |
431 | { | 405 | { |
432 | //p->setPen( QPen( cg.text() ) ); | 406 | //p->setPen( QPen( cg.text() ) ); |
433 | //p->drawRect( x + marg, y, BoxSize, BoxSize ); | 407 | //p->drawRect( x + marg, y, BoxSize, BoxSize ); |
434 | //p->drawRect( x + marg+1, y+1, BoxSize-2, BoxSize-2 ); | 408 | //p->drawRect( x + marg+1, y+1, BoxSize-2, BoxSize-2 ); |
435 | if ( task.isCompleted() ) { | 409 | if ( task.isCompleted() ) { |
436 | p->drawPixmap( x + marg, y, m_pic_completed ); | 410 | p->drawPixmap( x + marg, y, m_pic_completed ); |
437 | } | 411 | } |
438 | } | 412 | } |
439 | break; | 413 | break; |
440 | case 1: // priority field | 414 | case 1: // priority field |
441 | { | 415 | { |
442 | p->drawPixmap( x + marg, y, m_pic_priority[ task.priority() - 1 ] ); | 416 | p->drawPixmap( x + marg, y, m_pic_priority[ task.priority() - 1 ] ); |
443 | } | 417 | } |
444 | break; | 418 | break; |
445 | case 2: // description field | 419 | case 2: // description field |
446 | { | 420 | { |
447 | QString text = task.summary().isEmpty() ? | 421 | QString text = task.summary().isEmpty() ? |
448 | task.description().left(20) : | 422 | task.description().left(20) : |
449 | task.summary(); | 423 | task.summary(); |
450 | p->drawText(2,2 + fm.ascent(), text); | 424 | p->drawText(2,2 + fm.ascent(), text); |
451 | } | 425 | } |
452 | break; | 426 | break; |
453 | case 3: | 427 | case 3: |
454 | { | 428 | { |
455 | QString text; | 429 | QString text; |
456 | if (task.hasDueDate()) { | 430 | if (task.hasDueDate()) { |
457 | int off = QDate::currentDate().daysTo( task.dueDate() ); | 431 | int off = QDate::currentDate().daysTo( task.dueDate() ); |
458 | text = tr( "%1 day(s)").arg(QString::number(off)); | 432 | text = tr( "%1 day(s)").arg(QString::number(off)); |
459 | /* | 433 | /* |
460 | * set color if not completed | 434 | * set color if not completed |
461 | */ | 435 | */ |
462 | if (!task.isCompleted() ) { | 436 | if (!task.isCompleted() ) { |
463 | QColor color = Qt::black; | 437 | QColor color = Qt::black; |
464 | if ( off < 0 ) | 438 | if ( off < 0 ) |
465 | color = Qt::red; | 439 | color = Qt::red; |
466 | else if ( off == 0 ) | 440 | else if ( off == 0 ) |
467 | color = Qt::yellow; | 441 | color = Qt::yellow; |
468 | else if ( off > 0 ) | 442 | else if ( off > 0 ) |
469 | color = Qt::green; | 443 | color = Qt::green; |
470 | p->setPen(color ); | 444 | p->setPen(color ); |
471 | } | 445 | } |
472 | } else { | 446 | } else { |
473 | text = tr("None"); | 447 | text = tr("None"); |
474 | } | 448 | } |
475 | p->drawText(2,2 + fm.ascent(), text); | 449 | p->drawText(2,2 + fm.ascent(), text); |
476 | } | 450 | } |
477 | break; | 451 | break; |
478 | } | 452 | } |
479 | p->restore(); | 453 | p->restore(); |
480 | } | 454 | } |
481 | QWidget* TableView::createEditor(int row, int col, bool )const { | 455 | QWidget* TableView::createEditor(int row, int col, bool )const { |
482 | switch( col ) { | 456 | switch( col ) { |
483 | case 1: { | 457 | case 1: { |
484 | /* the priority stuff */ | 458 | /* the priority stuff */ |
485 | QComboBox* combo = new QComboBox( viewport() ); | 459 | QComboBox* combo = new QComboBox( viewport() ); |
486 | for ( int i = 0; i < 5; i++ ) { | 460 | for ( int i = 0; i < 5; i++ ) { |
487 | combo->insertItem( m_pic_priority[ i ] ); | 461 | combo->insertItem( m_pic_priority[ i ] ); |
488 | } | 462 | } |
489 | combo->setCurrentItem( sorted()[row].priority()-1 ); | 463 | combo->setCurrentItem( sorted()[row].priority()-1 ); |
490 | return combo; | 464 | return combo; |
491 | } | 465 | } |
492 | /* summary */ | 466 | /* summary */ |
493 | case 2:{ | 467 | case 2:{ |
494 | QLineEdit* edit = new QLineEdit( viewport() ); | 468 | QLineEdit* edit = new QLineEdit( viewport() ); |
495 | edit->setText( sorted()[row].summary() ); | 469 | edit->setText( sorted()[row].summary() ); |
496 | return edit; | 470 | return edit; |
497 | } | 471 | } |
498 | case 0: | 472 | case 0: |
499 | default: | 473 | default: |
500 | return 0l; | 474 | return 0l; |
501 | } | 475 | } |
502 | } | 476 | } |
503 | void TableView::setCellContentFromEditor(int row, int col ) { | 477 | void TableView::setCellContentFromEditor(int row, int col ) { |
504 | if ( col == 1 ) { | 478 | if ( col == 1 ) { |
505 | QWidget* wid = cellWidget(row, 1 ); | 479 | QWidget* wid = cellWidget(row, 1 ); |
506 | if ( wid->inherits("QComboBox") ) { | 480 | if ( wid->inherits("QComboBox") ) { |
507 | int pri = ((QComboBox*)wid)->currentItem() + 1; | 481 | int pri = ((QComboBox*)wid)->currentItem() + 1; |
508 | OPimTodo todo = sorted()[row]; | 482 | OPimTodo todo = sorted()[row]; |
509 | if ( todo.priority() != pri ) { | 483 | if ( todo.priority() != pri ) { |
510 | todo.setPriority( pri ); | 484 | todo.setPriority( pri ); |
511 | TodoView::update( todo.uid(), todo ); | 485 | TodoView::update( todo.uid(), todo ); |
512 | updateView(); | 486 | updateView(); |
513 | } | 487 | } |
514 | } | 488 | } |
515 | }else if ( col == 2) { | 489 | }else if ( col == 2) { |
516 | QWidget* wid = cellWidget(row, 2); | 490 | QWidget* wid = cellWidget(row, 2); |
517 | if ( wid->inherits("QLineEdit") ) { | 491 | if ( wid->inherits("QLineEdit") ) { |
518 | QString text = ((QLineEdit*)wid)->text(); | 492 | QString text = ((QLineEdit*)wid)->text(); |
519 | OPimTodo todo = sorted()[row]; | 493 | OPimTodo todo = sorted()[row]; |
520 | if ( todo.summary() != text ) { | 494 | if ( todo.summary() != text ) { |
521 | todo.setSummary( text ); | 495 | todo.setSummary( text ); |
522 | TodoView::update( todo.uid(), todo ); | 496 | TodoView::update( todo.uid(), todo ); |
523 | updateView(); | 497 | updateView(); |
524 | } | 498 | } |
525 | } | 499 | } |
526 | } | 500 | } |
527 | } | 501 | } |
528 | void TableView::slotPriority() { | 502 | void TableView::slotPriority() { |
529 | setCellContentFromEditor( currentRow(), currentColumn() ); | 503 | setCellContentFromEditor( currentRow(), currentColumn() ); |
530 | } | 504 | } |
531 | /* | 505 | /* |
532 | * We'll use the TimerEvent to read ahead or to keep the cahce always | 506 | * We'll use the TimerEvent to read ahead or to keep the cahce always |
533 | * filled enough. | 507 | * filled enough. |
534 | * We will try to read ahead 4 items in both ways | 508 | * We will try to read ahead 4 items in both ways |
535 | * up and down. On odd or even we will currentRow()+-4 or +-9 | 509 | * up and down. On odd or even we will currentRow()+-4 or +-9 |
536 | * | 510 | * |
537 | */ | 511 | */ |
538 | void TableView::timerEvent( QTimerEvent* ) { | 512 | void TableView::timerEvent( QTimerEvent* ) { |
539 | if (sorted().count() == 0 ) | 513 | if (sorted().count() == 0 ) |
540 | return; | 514 | return; |
541 | 515 | ||
542 | int row = currentRow(); | 516 | int row = currentRow(); |
543 | if ( m_row ) { | 517 | if ( m_row ) { |
544 | int ro = row-4; | 518 | int ro = row-4; |
545 | if (ro < 0 ) ro = 0; | 519 | if (ro < 0 ) ro = 0; |
546 | sorted()[ro]; | 520 | sorted()[ro]; |
547 | 521 | ||
548 | ro = row+4; | 522 | ro = row+4; |
549 | sorted()[ro]; | 523 | sorted()[ro]; |
550 | } else { | 524 | } else { |
551 | int ro = row + 8; | 525 | int ro = row + 8; |
552 | sorted()[ro]; | 526 | sorted()[ro]; |
553 | 527 | ||
554 | ro = row-8; | 528 | ro = row-8; |
555 | if (ro < 0 ) ro = 0; | 529 | if (ro < 0 ) ro = 0; |
556 | sorted()[ro]; | 530 | sorted()[ro]; |
557 | } | 531 | } |
558 | 532 | ||
559 | m_row = !m_row; | 533 | m_row = !m_row; |
560 | } | 534 | } |
561 | 535 | ||
562 | // We want a strike through completed ;) | 536 | // We want a strike through completed ;) |
563 | // durchstreichen to complete | 537 | // durchstreichen to complete |
564 | /* | 538 | /* |
565 | * MouseTracking is off this mean we only receive | 539 | * MouseTracking is off this mean we only receive |
566 | * these events if the mouse button is pressed | 540 | * these events if the mouse button is pressed |
567 | * We've the previous point saved | 541 | * We've the previous point saved |
568 | * We check if the previous and current Point are | 542 | * We check if the previous and current Point are |
569 | * in the same row. | 543 | * in the same row. |
570 | * Then we check if they're some pixel horizontal away | 544 | * Then we check if they're some pixel horizontal away |
571 | * if the distance between the two points is greater than | 545 | * if the distance between the two points is greater than |
572 | * 8 we mark the underlying todo as completed and do a repaint | 546 | * 8 we mark the underlying todo as completed and do a repaint |
573 | * | 547 | * |
574 | * BUG: When clicking on the Due column and it's scrollable | 548 | * BUG: When clicking on the Due column and it's scrollable |
575 | * the todo is marked as completed... | 549 | * the todo is marked as completed... |
576 | * REASON: QTable is doing auto scrolling which leads to a move | 550 | * REASON: QTable is doing auto scrolling which leads to a move |
577 | * in the x coordinate and this way it's able to pass the | 551 | * in the x coordinate and this way it's able to pass the |
578 | * m_completeStrokeWidth criteria | 552 | * m_completeStrokeWidth criteria |
579 | * WORKAROUND: strike through needs to strike through the same | 553 | * WORKAROUND: strike through needs to strike through the same |
580 | * row and two columns! | 554 | * row and two columns! |
581 | */ | 555 | */ |
582 | void TableView::contentsMouseReleaseEvent( QMouseEvent* e) { | 556 | void TableView::contentsMouseReleaseEvent( QMouseEvent *e ) { |
583 | int row = rowAt(m_prevP.y()); | 557 | int row = rowAt(m_prevP.y()); |
584 | int colOld = columnAt(m_prevP.x() ); | 558 | int colOld = columnAt(m_prevP.x() ); |
585 | int colNew = columnAt(e->x() ); | 559 | int colNew = columnAt(e->x() ); |
586 | if ( row == rowAt( e->y() ) && row != -1 && | 560 | if ( row == rowAt( e->y() ) && row != -1 && |
587 | colOld != colNew ) { | 561 | colOld != colNew ) { |
588 | TodoView::complete( sorted()[row] ); | 562 | TodoView::complete( sorted()[row] ); |
589 | return; | 563 | return; |
590 | } | 564 | } |
591 | QTable::contentsMouseReleaseEvent( e ); | 565 | QTable::contentsMouseReleaseEvent( e ); |
592 | } | 566 | } |
593 | void TableView::contentsMouseMoveEvent( QMouseEvent* e ) { | 567 | void TableView::contentsMousePressEvent( QMouseEvent *e ) { |
594 | m_menuTimer->stop(); | 568 | if ( e->button() == RightButton ) { |
595 | QTable::contentsMouseMoveEvent( e ); | 569 | QPopupMenu *menu = todoWindow()->contextMenu( current(), sorted()[currentRow()].recurrence().doesRecur() ); |
570 | menu->exec( QCursor::pos() ); | ||
571 | } | ||
572 | else { | ||
573 | m_prevP = e->pos(); | ||
574 | QTable::contentsMousePressEvent( e ); | ||
575 | } | ||
596 | } | 576 | } |
597 | void TableView::keyPressEvent( QKeyEvent* event) { | 577 | void TableView::keyPressEvent( QKeyEvent* event) { |
598 | if ( m_editorWidget.cellWidget() ) { | 578 | if ( m_editorWidget.cellWidget() ) { |
599 | // setCellContentFromEditor(m_editorWidget.cellRow(), m_editorWidget.cellCol() ); | 579 | // setCellContentFromEditor(m_editorWidget.cellRow(), m_editorWidget.cellCol() ); |
600 | endEdit(m_editorWidget.cellRow(), m_editorWidget.cellCol(), | 580 | endEdit(m_editorWidget.cellRow(), m_editorWidget.cellCol(), |
601 | true, true ); | 581 | true, true ); |
602 | m_editorWidget.releaseCellWidget(); | 582 | m_editorWidget.releaseCellWidget(); |
603 | setFocus(); | 583 | setFocus(); |
604 | } | 584 | } |
605 | 585 | ||
606 | if ( sorted().count() < 1 ) { | 586 | if ( sorted().count() < 1 ) { |
607 | QTable::keyPressEvent( event ); | 587 | QTable::keyPressEvent( event ); |
608 | return; | 588 | return; |
609 | } | 589 | } |
610 | 590 | ||
611 | int row = currentRow(); | 591 | int row = currentRow(); |
612 | int col = currentColumn(); | 592 | int col = currentColumn(); |
613 | 593 | ||
614 | char key = ::toupper( event->ascii() ); | 594 | char key = ::toupper( event->ascii() ); |
615 | /* let QTable also handle the d letter */ | 595 | /* let QTable also handle the d letter */ |
616 | if ( key == 'D' ) { | 596 | if ( key == 'D' ) { |
617 | event->accept(); | 597 | event->accept(); |
618 | removeQuery( sorted().uidAt( row ) ); | 598 | removeQuery( sorted().uidAt( row ) ); |
619 | return; | 599 | return; |
620 | } | 600 | } |
621 | 601 | ||
622 | 602 | ||
623 | switch( event->key() ) { | 603 | switch( event->key() ) { |
624 | case Qt::Key_F33: | 604 | case Qt::Key_F33: |
625 | case Qt::Key_Enter: | 605 | case Qt::Key_Enter: |
626 | case Qt::Key_Return: | 606 | case Qt::Key_Return: |
627 | case Qt::Key_Space: | 607 | case Qt::Key_Space: |
628 | if ( col == 0 ) { | 608 | if ( col == 0 ) { |
629 | TodoView::complete(sorted()[row]); | 609 | TodoView::complete(sorted()[row]); |
630 | }else if ( col == 1 ) { | 610 | }else if ( col == 1 ) { |
631 | QWidget* wid = beginEdit(row, col, FALSE ); | 611 | QWidget* wid = beginEdit(row, col, FALSE ); |
632 | m_editorWidget.setCellWidget( wid, row, col ); | 612 | m_editorWidget.setCellWidget( wid, row, col ); |
633 | }else if ( col == 2 ) { | 613 | }else if ( col == 2 ) { |
634 | showTodo( sorted().uidAt( currentRow() ) ); | 614 | showTodo( sorted().uidAt( currentRow() ) ); |
635 | }else if ( col == 3 ) { | 615 | }else if ( col == 3 ) { |
636 | TodoView::edit( sorted().uidAt(row) ); | 616 | TodoView::edit( sorted().uidAt(row) ); |
637 | } | 617 | } |
638 | event->accept(); | 618 | event->accept(); |
639 | break; | 619 | break; |
640 | default: | 620 | default: |
641 | QTable::keyPressEvent( event ); | 621 | QTable::keyPressEvent( event ); |
642 | } | 622 | } |
643 | } | 623 | } |
644 | 624 | ||
diff --git a/core/pim/todo/tableview.h b/core/pim/todo/tableview.h index 7f78255..46c16e1 100644 --- a/core/pim/todo/tableview.h +++ b/core/pim/todo/tableview.h | |||
@@ -1,130 +1,124 @@ | |||
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 | -_. . . )=. = 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 OPIE_TABLE_VIEW_H | 29 | #ifndef OPIE_TABLE_VIEW_H |
30 | #define OPIE_TABLE_VIEW_H | 30 | #define OPIE_TABLE_VIEW_H |
31 | 31 | ||
32 | #include <qtable.h> | 32 | #include <qtable.h> |
33 | #include <qmap.h> | 33 | #include <qmap.h> |
34 | #include <qpixmap.h> | 34 | #include <qpixmap.h> |
35 | 35 | ||
36 | #include "todoview.h" | 36 | #include "todoview.h" |
37 | 37 | ||
38 | class QTimer; | 38 | class QTimer; |
39 | 39 | ||
40 | namespace Todo { | 40 | namespace Todo { |
41 | class CheckItem; | 41 | class CheckItem; |
42 | class DueTextItem; | 42 | class DueTextItem; |
43 | class TableView : public QTable, public TodoView { | 43 | class TableView : public QTable, public TodoView { |
44 | Q_OBJECT | 44 | Q_OBJECT |
45 | public: | 45 | public: |
46 | TableView( MainWindow*, QWidget* parent ); | 46 | TableView( MainWindow*, QWidget* parent ); |
47 | ~TableView(); | 47 | ~TableView(); |
48 | 48 | ||
49 | 49 | ||
50 | QString type()const; | 50 | QString type()const; |
51 | int current(); | 51 | int current(); |
52 | QString currentRepresentation(); | 52 | QString currentRepresentation(); |
53 | int next(); | 53 | int next(); |
54 | int prev(); | 54 | int prev(); |
55 | 55 | ||
56 | void clear(); | 56 | void clear(); |
57 | void showOverDue( bool ); | 57 | void showOverDue( bool ); |
58 | void updateView(); | 58 | void updateView(); |
59 | void setTodo( int uid, const OPimTodo& ); | 59 | void setTodo( int uid, const OPimTodo& ); |
60 | void addEvent( const OPimTodo& event ); | 60 | void addEvent( const OPimTodo& event ); |
61 | void replaceEvent( const OPimTodo& ); | 61 | void replaceEvent( const OPimTodo& ); |
62 | void removeEvent( int uid ); | 62 | void removeEvent( int uid ); |
63 | void setShowCompleted( bool ); | 63 | void setShowCompleted( bool ); |
64 | void setShowDeadline( bool ); | 64 | void setShowDeadline( bool ); |
65 | 65 | ||
66 | void setShowCategory(const QString& =QString::null ); | 66 | void setShowCategory(const QString& =QString::null ); |
67 | void newDay(); | 67 | void newDay(); |
68 | QWidget* widget(); | 68 | QWidget* widget(); |
69 | void sortColumn(int, bool, bool ); | 69 | void sortColumn(int, bool, bool ); |
70 | 70 | ||
71 | /* | 71 | /* |
72 | * we do our drawing ourselves | 72 | * we do our drawing ourselves |
73 | * because we don't want to have | 73 | * because we don't want to have |
74 | * 40.000 QTableItems for 10.000 | 74 | * 40.000 QTableItems for 10.000 |
75 | * OPimTodos where we only show 10 at a time! | 75 | * OPimTodos where we only show 10 at a time! |
76 | */ | 76 | */ |
77 | void paintCell(QPainter* p, int row, int col, const QRect&, bool ); | 77 | void paintCell(QPainter* p, int row, int col, const QRect&, bool ); |
78 | private: | 78 | private: |
79 | /* reimplented for internal reasons */ | 79 | /* reimplented for internal reasons */ |
80 | void viewportPaintEvent( QPaintEvent* ); | 80 | void viewportPaintEvent( QPaintEvent* ); |
81 | QTimer *m_menuTimer; | ||
82 | bool m_enablePaint:1; | 81 | bool m_enablePaint:1; |
83 | QString m_oleCat; | 82 | QString m_oleCat; |
84 | bool m_first : 1; | 83 | bool m_first : 1; |
85 | 84 | ||
86 | QPixmap m_pic_completed; | 85 | QPixmap m_pic_completed; |
87 | QPixmap m_pic_priority[ 5 ]; | 86 | QPixmap m_pic_priority[ 5 ]; |
88 | 87 | ||
89 | protected: | 88 | protected: |
90 | void keyPressEvent( QKeyEvent* ); | 89 | void keyPressEvent( QKeyEvent* ); |
91 | void contentsMouseReleaseEvent( QMouseEvent* ); | 90 | void contentsMouseReleaseEvent( QMouseEvent *e ); |
92 | void contentsMouseMoveEvent( QMouseEvent* ); | 91 | void contentsMousePressEvent( QMouseEvent *e ); |
93 | void timerEvent( QTimerEvent* e ); | 92 | void timerEvent( QTimerEvent* e ); |
94 | QWidget* createEditor(int row, int col, bool initFromCell )const; | 93 | QWidget* createEditor(int row, int col, bool initFromCell )const; |
95 | void setCellContentFromEditor( int row, int col ); | 94 | void setCellContentFromEditor( int row, int col ); |
96 | /** | 95 | /** |
97 | * for inline editing on single click and to work around some | 96 | * for inline editing on single click and to work around some |
98 | * bug in qt2.3.5 | 97 | * bug in qt2.3.5 |
99 | */ | 98 | */ |
100 | struct EditorWidget { | 99 | struct EditorWidget { |
101 | EditorWidget(); | 100 | EditorWidget(); |
102 | void setCellWidget(QWidget*, int row, int col ); | 101 | void setCellWidget(QWidget*, int row, int col ); |
103 | void releaseCellWidget(); | 102 | void releaseCellWidget(); |
104 | QWidget* cellWidget()const; | 103 | QWidget* cellWidget()const; |
105 | int cellRow()const; | 104 | int cellRow()const; |
106 | int cellCol()const; | 105 | int cellCol()const; |
107 | private: | 106 | private: |
108 | QWidget* m_wid; | 107 | QWidget* m_wid; |
109 | int m_row, m_col; | 108 | int m_row, m_col; |
110 | }; | 109 | }; |
111 | EditorWidget m_editorWidget; | 110 | EditorWidget m_editorWidget; |
112 | 111 | ||
113 | private slots: | 112 | private slots: |
114 | void slotShowMenu(); | ||
115 | void slotClicked(int, int, int, | 113 | void slotClicked(int, int, int, |
116 | const QPoint& ); | 114 | const QPoint& ); |
117 | void slotPressed(int, int, int, | ||
118 | const QPoint& ); | ||
119 | void slotValueChanged(int, int); | ||
120 | void slotCurrentChanged(int, int ); | ||
121 | void slotPriority(); | 115 | void slotPriority(); |
122 | private: | 116 | private: |
123 | void initConfig(); | 117 | void initConfig(); |
124 | int m_completeStrokeWidth; | 118 | int m_completeStrokeWidth; |
125 | bool m_row : 1; | 119 | bool m_row : 1; |
126 | QPoint m_prevP; | 120 | QPoint m_prevP; |
127 | }; | 121 | }; |
128 | }; | 122 | }; |
129 | 123 | ||
130 | #endif | 124 | #endif |
diff --git a/core/pim/todo/templateeditor.cpp b/core/pim/todo/templateeditor.cpp deleted file mode 100644 index ca02173..0000000 --- a/core/pim/todo/templateeditor.cpp +++ b/dev/null | |||
@@ -1,38 +0,0 @@ | |||
1 | #include <qaction.h> | ||
2 | #include <qpopupmenu.h> | ||
3 | |||
4 | #include "mainwindow.h" | ||
5 | #include "todotemplatemanager.h" | ||
6 | |||
7 | #include "templatedialogimpl.h" | ||
8 | #include "templateeditor.h" | ||
9 | |||
10 | using namespace Todo; | ||
11 | |||
12 | TemplateEditor::TemplateEditor( MainWindow* main, | ||
13 | TemplateManager* manager ) | ||
14 | : QObject( main ), m_main( main ), m_man( manager ) | ||
15 | { | ||
16 | init(); | ||
17 | |||
18 | } | ||
19 | TemplateEditor::~TemplateEditor() { | ||
20 | |||
21 | } | ||
22 | /* ok we add us to the Menubar */ | ||
23 | void TemplateEditor::init() { | ||
24 | QAction* a = new QAction( QString::null, QWidget::tr("Configure Templates"), | ||
25 | 0, this, 0, FALSE ); | ||
26 | connect(a, SIGNAL(activated() ), | ||
27 | this, SLOT(setUp() ) ); | ||
28 | |||
29 | a->addTo( m_main->options() ); | ||
30 | } | ||
31 | void TemplateEditor::setUp() { | ||
32 | TemplateDialogImpl dlg(m_main, m_man ); | ||
33 | int ret= dlg.exec(); | ||
34 | if (QDialog::Accepted != ret ) | ||
35 | m_man->load(); | ||
36 | else | ||
37 | m_main->populateTemplates(); | ||
38 | } | ||
diff --git a/core/pim/todo/templateeditor.h b/core/pim/todo/templateeditor.h deleted file mode 100644 index e551328..0000000 --- a/core/pim/todo/templateeditor.h +++ b/dev/null | |||
@@ -1,31 +0,0 @@ | |||
1 | #ifndef OPIE_TEMPLATE_EDITOR_H | ||
2 | #define OPIE_TEMPLATE_EDITOR_H | ||
3 | |||
4 | #include <qobject.h> | ||
5 | #include <qdialog.h> | ||
6 | #include <qstring.h> | ||
7 | |||
8 | namespace Todo { | ||
9 | |||
10 | class MainWindow; | ||
11 | class TemplateManager; | ||
12 | class TemplateEditor : public QObject{ | ||
13 | Q_OBJECT | ||
14 | public: | ||
15 | TemplateEditor( MainWindow* win, | ||
16 | TemplateManager* man); | ||
17 | ~TemplateEditor(); | ||
18 | |||
19 | signals: | ||
20 | void configChanged(); | ||
21 | private: | ||
22 | void init(); | ||
23 | MainWindow* m_main; | ||
24 | TemplateManager* m_man; | ||
25 | private slots: | ||
26 | void setUp(); | ||
27 | |||
28 | }; | ||
29 | }; | ||
30 | |||
31 | #endif | ||
diff --git a/core/pim/todo/todo.pro b/core/pim/todo/todo.pro index 6c082cf..9b60818 100644 --- a/core/pim/todo/todo.pro +++ b/core/pim/todo/todo.pro | |||
@@ -1,49 +1,49 @@ | |||
1 | #TEMPLATE= app | 1 | #TEMPLATE= app |
2 | CONFIG = qt warn_on quick-app | 2 | CONFIG = qt warn_on quick-app |
3 | #DESTDIR = $(OPIEDIR)/bin | 3 | #DESTDIR = $(OPIEDIR)/bin |
4 | 4 | ||
5 | HEADERS= smalltodo.h \ | 5 | HEADERS= smalltodo.h \ |
6 | todomanager.h \ | 6 | todomanager.h \ |
7 | mainwindow.h \ | 7 | mainwindow.h \ |
8 | todoview.h \ | 8 | todoview.h \ |
9 | tableview.h \ | 9 | tableview.h \ |
10 | todotemplatemanager.h \ | 10 | todotemplatemanager.h \ |
11 | todoeditor.h \ | 11 | todoeditor.h \ |
12 | todoshow.h \ | 12 | todoshow.h \ |
13 | textviewshow.h \ | 13 | textviewshow.h \ |
14 | templateeditor.h \ | ||
15 | templatedialog.h \ | 14 | templatedialog.h \ |
16 | templatedialogimpl.h \ | 15 | templatedialogimpl.h \ |
17 | quickedit.h \ | 16 | quickedit.h \ |
18 | quickeditimpl.h \ | 17 | quickeditimpl.h \ |
19 | otaskeditor.h \ | 18 | otaskeditor.h \ |
20 | taskeditoroverview.h \ | 19 | taskeditoroverview.h \ |
21 | taskeditorstatus.h \ | 20 | taskeditorstatus.h \ |
22 | taskeditoralarms.h | 21 | taskeditoralarms.h \ |
22 | newtaskdlg.h | ||
23 | 23 | ||
24 | SOURCES= smalltodo.cpp \ | 24 | SOURCES= smalltodo.cpp \ |
25 | todomanager.cpp \ | 25 | todomanager.cpp \ |
26 | mainwindow.cpp \ | 26 | mainwindow.cpp \ |
27 | # main.cpp \ | 27 | # main.cpp \ |
28 | tableview.cpp \ | 28 | tableview.cpp \ |
29 | todoview.cpp \ | 29 | todoview.cpp \ |
30 | todotemplatemanager.cpp \ | 30 | todotemplatemanager.cpp \ |
31 | todoeditor.cpp \ | 31 | todoeditor.cpp \ |
32 | todoshow.cpp \ | 32 | todoshow.cpp \ |
33 | textviewshow.cpp \ | 33 | textviewshow.cpp \ |
34 | templateeditor.cpp \ | ||
35 | templatedialog.cpp \ | 34 | templatedialog.cpp \ |
36 | templatedialogimpl.cpp \ | 35 | templatedialogimpl.cpp \ |
37 | quickeditimpl.cpp \ | 36 | quickeditimpl.cpp \ |
38 | quickedit.cpp \ | 37 | quickedit.cpp \ |
39 | otaskeditor.cpp \ | 38 | otaskeditor.cpp \ |
40 | taskeditoroverview.cpp \ | 39 | taskeditoroverview.cpp \ |
41 | taskeditorstatus.cpp \ | 40 | taskeditorstatus.cpp \ |
42 | taskeditoralarms.cpp | 41 | taskeditoralarms.cpp \ |
42 | newtaskdlg.cpp | ||
43 | 43 | ||
44 | TARGET = todolist | 44 | TARGET = todolist |
45 | INCLUDEPATH += $(OPIEDIR)/include | 45 | INCLUDEPATH += $(OPIEDIR)/include |
46 | DEPENDPATH+= $(OPIEDIR)/include | 46 | DEPENDPATH+= $(OPIEDIR)/include |
47 | LIBS += -lqpe -lopiecore2 -lopieui2 -lopiepim2 | 47 | LIBS += -lqpe -lopiecore2 -lopieui2 -lopiepim2 |
48 | 48 | ||
49 | include( $(OPIEDIR)/include.pro ) | 49 | include( $(OPIEDIR)/include.pro ) |
diff --git a/core/pim/todo/todomanager.cpp b/core/pim/todo/todomanager.cpp index 7136f9a..fcd5f0e 100644 --- a/core/pim/todo/todomanager.cpp +++ b/core/pim/todo/todomanager.cpp | |||
@@ -1,125 +1,126 @@ | |||
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 | -_. . . )=. = 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 | #include <opie2/odebug.h> | 29 | #include <opie2/odebug.h> |
30 | 30 | ||
31 | #include <qpe/categoryselect.h> | 31 | #include <qpe/categoryselect.h> |
32 | 32 | ||
33 | #include "todomanager.h" | 33 | #include "todomanager.h" |
34 | 34 | ||
35 | using namespace Todo; | 35 | using namespace Todo; |
36 | 36 | ||
37 | TodoManager::TodoManager( QObject *obj ) | 37 | TodoManager::TodoManager( QObject *obj ) |
38 | : QObject( obj ) { | 38 | : QObject( obj ) { |
39 | m_db = 0l; | 39 | m_db = 0l; |
40 | m_cat.load( categoryFileName() ); | ||
40 | } | 41 | } |
41 | TodoManager::~TodoManager() { | 42 | TodoManager::~TodoManager() { |
42 | delete m_db; | 43 | delete m_db; |
43 | } | 44 | } |
44 | OPimTodo TodoManager::event(int uid ) { | 45 | OPimTodo TodoManager::event(int uid ) { |
45 | return m_db->find( uid ); | 46 | return m_db->find( uid ); |
46 | } | 47 | } |
47 | void TodoManager::updateList() { | 48 | void TodoManager::updateList() { |
48 | m_list = m_db->allRecords(); | 49 | m_list = m_db->allRecords(); |
49 | } | 50 | } |
50 | OPimTodoAccess::List TodoManager::list() const{ | 51 | OPimTodoAccess::List TodoManager::list() const{ |
51 | return m_list; | 52 | return m_list; |
52 | } | 53 | } |
53 | OPimTodoAccess::List TodoManager::sorted( bool asc, int so, int f, int cat ) { | 54 | OPimTodoAccess::List TodoManager::sorted( bool asc, int so, int f, int cat ) { |
54 | return m_db->sorted( asc, so, f, cat ); | 55 | return m_db->sorted( asc, so, f, cat ); |
55 | } | 56 | } |
56 | OPimTodoAccess::List::Iterator TodoManager::overDue() { | 57 | OPimTodoAccess::List::Iterator TodoManager::overDue() { |
57 | int filter = Opie::OPimTodoAccess::FilterCategory | Opie::OPimTodoAccess::OnlyOverDue; | 58 | int filter = Opie::OPimTodoAccess::FilterCategory | Opie::OPimTodoAccess::OnlyOverDue; |
58 | m_list = m_db->sorted(m_asc, m_sortOrder, filter, m_ca ); | 59 | m_list = m_db->sorted(m_asc, m_sortOrder, filter, m_ca ); |
59 | m_it = m_list.begin(); | 60 | m_it = m_list.begin(); |
60 | return m_it; | 61 | return m_it; |
61 | } | 62 | } |
62 | OPimTodoAccess::List::Iterator TodoManager::fromTo( const QDate& start, | 63 | OPimTodoAccess::List::Iterator TodoManager::fromTo( const QDate& start, |
63 | const QDate& end ) { | 64 | const QDate& end ) { |
64 | m_list = m_db->effectiveToDos( start, end ); | 65 | m_list = m_db->effectiveToDos( start, end ); |
65 | m_it = m_list.begin(); | 66 | m_it = m_list.begin(); |
66 | return m_it; | 67 | return m_it; |
67 | } | 68 | } |
68 | OPimTodoAccess::List::Iterator TodoManager::query( const OPimTodo& ev, int query ) { | 69 | OPimTodoAccess::List::Iterator TodoManager::query( const OPimTodo& ev, int query ) { |
69 | m_list = m_db->queryByExample( ev, query ); | 70 | m_list = m_db->queryByExample( ev, query ); |
70 | m_it = m_list.begin(); | 71 | m_it = m_list.begin(); |
71 | return m_it; | 72 | return m_it; |
72 | } | 73 | } |
73 | OPimTodoAccess* TodoManager::todoDB() { | 74 | OPimTodoAccess* TodoManager::todoDB() { |
74 | return m_db; | 75 | return m_db; |
75 | } | 76 | } |
76 | void TodoManager::add( const OPimTodo& ev ) { | 77 | void TodoManager::add( const OPimTodo& ev ) { |
77 | m_db->add( ev ); | 78 | m_db->add( ev ); |
78 | } | 79 | } |
79 | void TodoManager::update( int, const SmallTodo& ) { | 80 | void TodoManager::update( int, const SmallTodo& ) { |
80 | 81 | ||
81 | } | 82 | } |
82 | void TodoManager::update( int, const OPimTodo& ev) { | 83 | void TodoManager::update( int, const OPimTodo& ev) { |
83 | m_db->replace( ev ); | 84 | m_db->replace( ev ); |
84 | } | 85 | } |
85 | bool TodoManager::remove( int uid ) { | 86 | bool TodoManager::remove( int uid ) { |
86 | return m_db->remove( uid ); | 87 | return m_db->remove( uid ); |
87 | } | 88 | } |
88 | void TodoManager::removeAll() { | 89 | void TodoManager::removeAll() { |
89 | m_db->clear(); | 90 | m_db->clear(); |
90 | } | 91 | } |
91 | void TodoManager::removeCompleted() { | 92 | void TodoManager::removeCompleted() { |
92 | m_db->removeAllCompleted(); | 93 | m_db->removeAllCompleted(); |
93 | } | 94 | } |
94 | void TodoManager::save() { | 95 | void TodoManager::save() { |
95 | m_db->save(); | 96 | m_db->save(); |
96 | } | 97 | } |
97 | bool TodoManager::saveAll() { | 98 | bool TodoManager::saveAll() { |
98 | return m_db->save(); | 99 | return m_db->save(); |
99 | } | 100 | } |
100 | void TodoManager::reload() { | 101 | void TodoManager::reload() { |
101 | m_db->reload(); | 102 | m_db->reload(); |
102 | } | 103 | } |
103 | QStringList TodoManager::categories() { | 104 | QStringList TodoManager::categories() { |
104 | m_cat.load(categoryFileName() ); | 105 | m_cat.load(categoryFileName() ); |
105 | return m_cat.labels( "Todo List"); | 106 | return m_cat.labels( "Todo List"); |
106 | } | 107 | } |
107 | /* | 108 | /* |
108 | * we rely on load beeing called from populateCategories | 109 | * we rely on load beeing called from populateCategories |
109 | */ | 110 | */ |
110 | int TodoManager::catId( const QString& cats ) { | 111 | int TodoManager::catId( const QString& cats ) { |
111 | return m_cat.id( "Todo List", cats ); | 112 | return m_cat.id( "Todo List", cats ); |
112 | } | 113 | } |
113 | void TodoManager::remove( const QArray<int>& ids) { | 114 | void TodoManager::remove( const QArray<int>& ids) { |
114 | for (uint i=0; i < ids.size(); i++ ) | 115 | for (uint i=0; i < ids.size(); i++ ) |
115 | remove( ids[i] ); | 116 | remove( ids[i] ); |
116 | } | 117 | } |
117 | bool TodoManager::isLoaded()const { | 118 | bool TodoManager::isLoaded()const { |
118 | return (m_db == 0 ); | 119 | return (m_db == 0 ); |
119 | } | 120 | } |
120 | void TodoManager::load() { | 121 | void TodoManager::load() { |
121 | if (!m_db) { | 122 | if (!m_db) { |
122 | m_db = new OPimTodoAccess(); | 123 | m_db = new OPimTodoAccess(); |
123 | m_db->load(); | 124 | m_db->load(); |
124 | } | 125 | } |
125 | } | 126 | } |