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