-rw-r--r-- | core/pim/todo/mainwindow.cpp | 10 | ||||
-rw-r--r-- | core/pim/todo/mainwindow.h | 1 | ||||
-rw-r--r-- | core/pim/todo/tableview.cpp | 4 | ||||
-rw-r--r-- | core/pim/todo/todoeditor.cpp | 2 |
4 files changed, 5 insertions, 12 deletions
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp index b2b3b8f..0ab6230 100644 --- a/core/pim/todo/mainwindow.cpp +++ b/core/pim/todo/mainwindow.cpp | |||
@@ -1,805 +1,799 @@ | |||
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 <qwidgetstack.h> | 35 | #include <qwidgetstack.h> |
36 | #include <qaction.h> | 36 | #include <qaction.h> |
37 | #include <qtimer.h> | 37 | #include <qtimer.h> |
38 | #include <qvbox.h> | 38 | #include <qvbox.h> |
39 | #include <qlineedit.h> | 39 | #include <qlineedit.h> |
40 | 40 | ||
41 | #include <qpe/applnk.h> | 41 | #include <qpe/applnk.h> |
42 | #include <qpe/config.h> | 42 | #include <qpe/config.h> |
43 | #include <qpe/ir.h> | 43 | #include <qpe/ir.h> |
44 | #include <qpe/resource.h> | 44 | #include <qpe/resource.h> |
45 | #include <qpe/qpemessagebox.h> | 45 | #include <qpe/qpemessagebox.h> |
46 | 46 | ||
47 | #include <opie/orecur.h> | 47 | #include <opie/orecur.h> |
48 | #include <opie/otodoaccessvcal.h> | 48 | #include <opie/otodoaccessvcal.h> |
49 | 49 | ||
50 | #include "quickeditimpl.h" | 50 | #include "quickeditimpl.h" |
51 | #include "todotemplatemanager.h" | 51 | #include "todotemplatemanager.h" |
52 | #include "templateeditor.h" | 52 | #include "templateeditor.h" |
53 | #include "tableview.h" | 53 | #include "tableview.h" |
54 | 54 | ||
55 | #include "textviewshow.h" | 55 | #include "textviewshow.h" |
56 | #include "todoeditor.h" | 56 | #include "todoeditor.h" |
57 | #include "mainwindow.h" | 57 | #include "mainwindow.h" |
58 | 58 | ||
59 | 59 | ||
60 | using namespace Todo; | 60 | using namespace Todo; |
61 | 61 | ||
62 | MainWindow::MainWindow( QWidget* parent, | 62 | MainWindow::MainWindow( QWidget* parent, |
63 | const char* name ) | 63 | const char* name ) |
64 | : OPimMainWindow("Todolist") | 64 | : OPimMainWindow("Todolist", parent, name) |
65 | { | 65 | { |
66 | 66 | ||
67 | m_syncing = false; | 67 | m_syncing = false; |
68 | m_counter = 0; | 68 | m_counter = 0; |
69 | m_tempManager = new TemplateManager(); | 69 | m_tempManager = new TemplateManager(); |
70 | m_tempManager->load(); | 70 | m_tempManager->load(); |
71 | 71 | ||
72 | initUI(); | 72 | initUI(); |
73 | initConfig(); | 73 | initConfig(); |
74 | initViews(); | 74 | initViews(); |
75 | initActions(); | 75 | initActions(); |
76 | initEditor(); | 76 | initEditor(); |
77 | initShow(); | 77 | initShow(); |
78 | initTemplate(); | 78 | initTemplate(); |
79 | 79 | ||
80 | populateTemplates(); | 80 | populateTemplates(); |
81 | raiseCurrentView(); | 81 | raiseCurrentView(); |
82 | QTimer::singleShot(0, this, SLOT(populateCategories() ) ); | 82 | QTimer::singleShot(0, this, SLOT(populateCategories() ) ); |
83 | } | 83 | } |
84 | void MainWindow::initTemplate() { | 84 | void MainWindow::initTemplate() { |
85 | m_curTempEd = new TemplateEditor( this, templateManager() ); | 85 | m_curTempEd = new TemplateEditor( this, templateManager() ); |
86 | } | 86 | } |
87 | void MainWindow::initActions() { | 87 | void MainWindow::initActions() { |
88 | QAction* a = new QAction( tr("New Task" ), Resource::loadPixmap( "new" ), | 88 | QAction* a = new QAction( tr("New Task" ), Resource::loadPixmap( "new" ), |
89 | QString::null, 0, this, 0 ); | 89 | QString::null, 0, this, 0 ); |
90 | connect(a, SIGNAL( activated() ), | 90 | connect(a, SIGNAL( activated() ), |
91 | this, SLOT( slotNew() ) ); | 91 | this, SLOT( slotNew() ) ); |
92 | a->addTo(m_tool ); | 92 | a->addTo(m_tool ); |
93 | a->addTo(m_edit ); | 93 | a->addTo(m_edit ); |
94 | 94 | ||
95 | a = new QAction( tr("Edit Task"), Resource::loadIconSet( "edit" ), | 95 | a = new QAction( tr("Edit Task"), Resource::loadIconSet( "edit" ), |
96 | QString::null, 0, this, 0 ); | 96 | QString::null, 0, this, 0 ); |
97 | connect(a, SIGNAL(activated() ), | 97 | connect(a, SIGNAL(activated() ), |
98 | this, SLOT( slotEdit() ) ); | 98 | this, SLOT( slotEdit() ) ); |
99 | a->addTo( m_tool ); | 99 | a->addTo( m_tool ); |
100 | a->addTo( m_edit ); | 100 | a->addTo( m_edit ); |
101 | m_editAction = a; | 101 | m_editAction = a; |
102 | 102 | ||
103 | a = new QAction( QString::null, tr("View Task"), 0, this, 0 ); | 103 | a = new QAction( QString::null, tr("View Task"), 0, this, 0 ); |
104 | connect(a, SIGNAL( activated() ), | 104 | connect(a, SIGNAL( activated() ), |
105 | this, SLOT( slotShowDetails() ) ); | 105 | this, SLOT( slotShowDetails() ) ); |
106 | a->addTo( m_edit ); | 106 | a->addTo( m_edit ); |
107 | 107 | ||
108 | m_edit->insertSeparator(); | 108 | m_edit->insertSeparator(); |
109 | 109 | ||
110 | a = new QAction( tr("Delete..."), Resource::loadIconSet( "trash" ), | 110 | a = new QAction( tr("Delete..."), Resource::loadIconSet( "trash" ), |
111 | QString::null, 0, this, 0 ); | 111 | QString::null, 0, this, 0 ); |
112 | connect(a, SIGNAL(activated() ), | 112 | connect(a, SIGNAL(activated() ), |
113 | this, SLOT(slotDelete() ) ); | 113 | this, SLOT(slotDelete() ) ); |
114 | a->addTo( m_tool ); | 114 | a->addTo( m_tool ); |
115 | a->addTo( m_edit ); | 115 | a->addTo( m_edit ); |
116 | m_deleteAction = a; | 116 | m_deleteAction = a; |
117 | 117 | ||
118 | a = new QAction( QString::null, tr("Delete all..."), 0, this, 0 ); | 118 | a = new QAction( QString::null, tr("Delete all..."), 0, this, 0 ); |
119 | connect(a, SIGNAL( activated() ), | 119 | connect(a, SIGNAL( activated() ), |
120 | this, SLOT( slotDeleteAll() ) ); | 120 | this, SLOT( slotDeleteAll() ) ); |
121 | a->addTo(m_edit ); | 121 | a->addTo(m_edit ); |
122 | m_deleteAllAction = a; | 122 | m_deleteAllAction = a; |
123 | 123 | ||
124 | a = new QAction( QString::null, tr("Delete completed"), | 124 | a = new QAction( QString::null, tr("Delete completed"), |
125 | 0, this, 0 ); | 125 | 0, this, 0 ); |
126 | connect(a, SIGNAL( activated() ), | 126 | connect(a, SIGNAL( activated() ), |
127 | this, SLOT( slotDeleteCompleted() ) ); | 127 | this, SLOT( slotDeleteCompleted() ) ); |
128 | a->addTo(m_edit ); | 128 | a->addTo(m_edit ); |
129 | a->setEnabled( TRUE ); | 129 | a->setEnabled( TRUE ); |
130 | m_deleteCompleteAction = a; | 130 | m_deleteCompleteAction = a; |
131 | 131 | ||
132 | m_edit->insertSeparator(); | 132 | m_edit->insertSeparator(); |
133 | 133 | ||
134 | a = new QAction( QString::null, tr("Duplicate"), 0, this, 0 ); | 134 | a = new QAction( QString::null, tr("Duplicate"), 0, this, 0 ); |
135 | connect(a, SIGNAL( activated() ), | 135 | connect(a, SIGNAL( activated() ), |
136 | this, SLOT( slotDuplicate() ) ); | 136 | this, SLOT( slotDuplicate() ) ); |
137 | a->addTo(m_edit ); | 137 | a->addTo(m_edit ); |
138 | m_duplicateAction = a; | 138 | m_duplicateAction = a; |
139 | 139 | ||
140 | m_edit->insertSeparator(); | 140 | m_edit->insertSeparator(); |
141 | 141 | ||
142 | if ( Ir::supported() ) { | 142 | if ( Ir::supported() ) { |
143 | a = new QAction( tr( "Beam" ), Resource::loadPixmap( "beam" ), | 143 | a = new QAction( tr( "Beam" ), Resource::loadPixmap( "beam" ), |
144 | QString::null, 0, this, 0 ); | 144 | QString::null, 0, this, 0 ); |
145 | connect( a, SIGNAL( activated() ), | 145 | connect( a, SIGNAL( activated() ), |
146 | this, SLOT( slotBeam() ) ); | 146 | this, SLOT( slotBeam() ) ); |
147 | a->addTo( m_edit ); | 147 | a->addTo( m_edit ); |
148 | a->addTo( m_tool ); | 148 | a->addTo( m_tool ); |
149 | } | 149 | } |
150 | 150 | ||
151 | a = new QAction( tr("Find"), Resource::loadIconSet( "mag" ), | 151 | a = new QAction( tr("Find"), Resource::loadIconSet( "mag" ), |
152 | QString::null, 0, this, 0 ); | 152 | QString::null, 0, this, 0 ); |
153 | connect(a, SIGNAL( activated() ), | 153 | connect(a, SIGNAL( activated() ), |
154 | this, SLOT( slotFind() ) ); | 154 | this, SLOT( slotFind() ) ); |
155 | a->addTo( m_options ); | 155 | a->addTo( m_options ); |
156 | m_findAction = a; | 156 | m_findAction = a; |
157 | 157 | ||
158 | m_options->insertSeparator(); | 158 | m_options->insertSeparator(); |
159 | 159 | ||
160 | m_completedAction = new QAction( QString::null, tr("Completed tasks"), | 160 | m_completedAction = new QAction( QString::null, tr("Completed tasks"), |
161 | 0, this, 0, TRUE ); | 161 | 0, this, 0, TRUE ); |
162 | m_completedAction->addTo( m_options ); | 162 | m_completedAction->addTo( m_options ); |
163 | m_completedAction->setOn( showCompleted() ); | 163 | m_completedAction->setOn( showCompleted() ); |
164 | connect(m_completedAction, SIGNAL( toggled(bool) ), | 164 | connect(m_completedAction, SIGNAL( toggled(bool) ), |
165 | this, SLOT(slotShowCompleted(bool) ) ); | 165 | this, SLOT(slotShowCompleted(bool) ) ); |
166 | 166 | ||
167 | m_showDeadLineAction = new QAction( QString::null, tr("Show Deadline"), | 167 | m_showDeadLineAction = new QAction( QString::null, tr("Show Deadline"), |
168 | 0, this, 0, TRUE ); | 168 | 0, this, 0, TRUE ); |
169 | m_showDeadLineAction->addTo( m_options ); | 169 | m_showDeadLineAction->addTo( m_options ); |
170 | m_showDeadLineAction->setOn( showDeadline() ); | 170 | m_showDeadLineAction->setOn( showDeadline() ); |
171 | connect(m_showDeadLineAction, SIGNAL(toggled(bool) ), | 171 | connect(m_showDeadLineAction, SIGNAL(toggled(bool) ), |
172 | this, SLOT( slotShowDeadLine( bool ) ) ); | 172 | this, SLOT( slotShowDeadLine( bool ) ) ); |
173 | 173 | ||
174 | m_options->insertSeparator(); | 174 | m_options->insertSeparator(); |
175 | 175 | ||
176 | m_bar->insertItem( tr("Data") ,m_edit ); | 176 | m_bar->insertItem( tr("Data") ,m_edit ); |
177 | m_bar->insertItem( tr("Category"), m_catMenu ); | 177 | m_bar->insertItem( tr("Category"), m_catMenu ); |
178 | m_bar->insertItem( tr("Options"), m_options ); | 178 | m_bar->insertItem( tr("Options"), m_options ); |
179 | 179 | ||
180 | /* initialize the view menu */ | 180 | /* initialize the view menu */ |
181 | a = new QAction( QString::null, tr("Show only over due"), | 181 | a = new QAction( QString::null, tr("Show only over due"), |
182 | 0, this, 0, TRUE ); | 182 | 0, this, 0, TRUE ); |
183 | a->addTo( m_options ); | 183 | a->addTo( m_options ); |
184 | a->setOn( showOverDue() ); | 184 | a->setOn( showOverDue() ); |
185 | connect(a, SIGNAL(toggled(bool)), | 185 | connect(a, SIGNAL(toggled(bool)), |
186 | this, SLOT(slotShowDue(bool) ) ); | 186 | this, SLOT(slotShowDue(bool) ) ); |
187 | 187 | ||
188 | /* templates */ | 188 | /* templates */ |
189 | m_edit->insertItem(tr("New from template"), m_template, | 189 | m_edit->insertItem(tr("New from template"), m_template, |
190 | -1, 0 ); | 190 | -1, 0 ); |
191 | 191 | ||
192 | } | 192 | } |
193 | /* m_curCat from Config */ | 193 | /* m_curCat from Config */ |
194 | void MainWindow::initConfig() { | 194 | void MainWindow::initConfig() { |
195 | Config config( "todo" ); | 195 | Config config( "todo" ); |
196 | config.setGroup( "View" ); | 196 | config.setGroup( "View" ); |
197 | m_completed = config.readBoolEntry( "ShowComplete", TRUE ); | 197 | m_completed = config.readBoolEntry( "ShowComplete", TRUE ); |
198 | m_curCat = config.readEntry( "Category", QString::null ); | 198 | m_curCat = config.readEntry( "Category", QString::null ); |
199 | m_deadline = config.readBoolEntry( "ShowDeadLine", TRUE); | 199 | m_deadline = config.readBoolEntry( "ShowDeadLine", TRUE); |
200 | m_overdue = config.readBoolEntry("ShowOverDue", TRUE ); | 200 | m_overdue = config.readBoolEntry("ShowOverDue", TRUE ); |
201 | } | 201 | } |
202 | void MainWindow::initUI() { | 202 | void MainWindow::initUI() { |
203 | m_mainBox = new QVBox(this, "main box "); | 203 | m_mainBox = new QVBox(this, "main box "); |
204 | m_curQuick = new QuickEditImpl(this, m_mainBox ); | 204 | m_curQuick = new QuickEditImpl(this, m_mainBox ); |
205 | m_curQuick->signal()->connect( this, SLOT(slotQuickEntered() ) ); | 205 | m_curQuick->signal()->connect( this, SLOT(slotQuickEntered() ) ); |
206 | m_quickEdit.append( m_curQuick ); | 206 | m_quickEdit.append( m_curQuick ); |
207 | 207 | ||
208 | 208 | ||
209 | 209 | ||
210 | m_stack = new QWidgetStack(m_mainBox, "main stack"); | 210 | m_stack = new QWidgetStack(m_mainBox, "main stack"); |
211 | setCentralWidget( m_mainBox ); | 211 | setCentralWidget( m_mainBox ); |
212 | 212 | ||
213 | setToolBarsMovable( FALSE ); | 213 | setToolBarsMovable( FALSE ); |
214 | 214 | ||
215 | m_tool = new QToolBar( this ); | 215 | m_tool = new QToolBar( this ); |
216 | m_tool->setHorizontalStretchable( TRUE ); | 216 | m_tool->setHorizontalStretchable( TRUE ); |
217 | 217 | ||
218 | m_bar = new QMenuBar( m_tool ); | 218 | m_bar = new QMenuBar( m_tool ); |
219 | 219 | ||
220 | /** QPopupMenu */ | 220 | /** QPopupMenu */ |
221 | m_edit = new QPopupMenu( this ); | 221 | m_edit = new QPopupMenu( this ); |
222 | m_options = new QPopupMenu( this ); | 222 | m_options = new QPopupMenu( this ); |
223 | m_catMenu = new QPopupMenu( this ); | 223 | m_catMenu = new QPopupMenu( this ); |
224 | m_template = new QPopupMenu( this ); | 224 | m_template = new QPopupMenu( this ); |
225 | 225 | ||
226 | m_catMenu->setCheckable( TRUE ); | 226 | m_catMenu->setCheckable( TRUE ); |
227 | m_template->setCheckable( TRUE ); | 227 | m_template->setCheckable( TRUE ); |
228 | 228 | ||
229 | connect(m_catMenu, SIGNAL(activated(int) ), | 229 | connect(m_catMenu, SIGNAL(activated(int) ), |
230 | this, SLOT(setCategory(int) ) ); | 230 | this, SLOT(setCategory(int) ) ); |
231 | connect(m_template, SIGNAL(activated(int) ), | 231 | connect(m_template, SIGNAL(activated(int) ), |
232 | this, SLOT(slotNewFromTemplate(int) ) ); | 232 | this, SLOT(slotNewFromTemplate(int) ) ); |
233 | } | 233 | } |
234 | void MainWindow::initViews() { | 234 | void MainWindow::initViews() { |
235 | TableView* tableView = new TableView( this, m_stack ); | 235 | TableView* tableView = new TableView( this, m_stack ); |
236 | m_stack->addWidget( tableView, m_counter++ ); | 236 | m_stack->addWidget( tableView, m_counter++ ); |
237 | m_views.append( tableView ); | 237 | m_views.append( tableView ); |
238 | m_curView = tableView; | 238 | m_curView = tableView; |
239 | connectBase( tableView ); | 239 | connectBase( tableView ); |
240 | /* add QString type + QString configname to | 240 | /* add QString type + QString configname to |
241 | * the View menu | 241 | * the View menu |
242 | * and subdirs for multiple views | 242 | * and subdirs for multiple views |
243 | */ | 243 | */ |
244 | } | 244 | } |
245 | void MainWindow::initEditor() { | 245 | void MainWindow::initEditor() { |
246 | m_curEdit = new Editor(); | 246 | m_curEdit = new Editor(); |
247 | } | 247 | } |
248 | void MainWindow::initShow() { | 248 | void MainWindow::initShow() { |
249 | m_curShow = new TextViewShow(this); | 249 | m_curShow = new TextViewShow(this); |
250 | m_stack->addWidget( m_curShow->widget() , m_counter++ ); | 250 | m_stack->addWidget( m_curShow->widget() , m_counter++ ); |
251 | } | 251 | } |
252 | MainWindow::~MainWindow() { | 252 | MainWindow::~MainWindow() { |
253 | delete templateManager(); | 253 | delete templateManager(); |
254 | } | 254 | } |
255 | void MainWindow::connectBase( ViewBase* base) { | 255 | void MainWindow::connectBase( ViewBase* ) { |
256 | // once templates and signals mix we'll use it again | 256 | // once templates and signals mix we'll use it again |
257 | } | 257 | } |
258 | QPopupMenu* MainWindow::contextMenu( int , bool recur ) { | 258 | QPopupMenu* MainWindow::contextMenu( int , bool recur ) { |
259 | QPopupMenu* menu = new QPopupMenu(); | 259 | QPopupMenu* menu = new QPopupMenu(); |
260 | 260 | ||
261 | m_editAction->addTo( menu ); | 261 | m_editAction->addTo( menu ); |
262 | m_deleteAction->addTo( menu ); | 262 | m_deleteAction->addTo( menu ); |
263 | m_duplicateAction->addTo( menu ); | 263 | m_duplicateAction->addTo( menu ); |
264 | 264 | ||
265 | menu->insertSeparator(); | 265 | menu->insertSeparator(); |
266 | 266 | ||
267 | /* | 267 | /* |
268 | * if this event recurs we allow | 268 | * if this event recurs we allow |
269 | * to detach it. | 269 | * to detach it. |
270 | * remove all | 270 | * remove all |
271 | */ | 271 | */ |
272 | if ( recur ) { | 272 | if ( recur ) { |
273 | ; // FIXME | 273 | ; // FIXME |
274 | } | 274 | } |
275 | 275 | ||
276 | return menu; | 276 | return menu; |
277 | } | 277 | } |
278 | QPopupMenu* MainWindow::options() { | 278 | QPopupMenu* MainWindow::options() { |
279 | qWarning("Options"); | 279 | qWarning("Options"); |
280 | return m_options; | 280 | return m_options; |
281 | } | 281 | } |
282 | QPopupMenu* MainWindow::edit() { | 282 | QPopupMenu* MainWindow::edit() { |
283 | return m_edit; | 283 | return m_edit; |
284 | } | 284 | } |
285 | QToolBar* MainWindow::toolbar() { | 285 | QToolBar* MainWindow::toolbar() { |
286 | return m_tool; | 286 | return m_tool; |
287 | } | 287 | } |
288 | OTodoAccess::List MainWindow::list()const { | 288 | OTodoAccess::List MainWindow::list()const { |
289 | return m_todoMgr.list(); | 289 | return m_todoMgr.list(); |
290 | } | 290 | } |
291 | OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder ) { | 291 | OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder ) { |
292 | int cat = 0; | 292 | int cat = 0; |
293 | if ( m_curCat != tr("All Categories") ) | 293 | if ( m_curCat != tr("All Categories") ) |
294 | cat = currentCatId(); | 294 | cat = currentCatId(); |
295 | 295 | ||
296 | int filter = 1; | 296 | int filter = 1; |
297 | 297 | ||
298 | if (!m_completed ) | 298 | if (!m_completed ) |
299 | filter |= 4; | 299 | filter |= 4; |
300 | if (m_overdue) | 300 | if (m_overdue) |
301 | filter |= 2; | 301 | filter |= 2; |
302 | 302 | ||
303 | return m_todoMgr.sorted( asc, sortOrder, filter, cat ); | 303 | return m_todoMgr.sorted( asc, sortOrder, filter, cat ); |
304 | } | 304 | } |
305 | OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder, int addFilter) { | 305 | OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder, int addFilter) { |
306 | int cat = 0; | 306 | int cat = 0; |
307 | if ( m_curCat != tr("All Categories") ) | 307 | if ( m_curCat != tr("All Categories") ) |
308 | cat = currentCatId(); | 308 | cat = currentCatId(); |
309 | 309 | ||
310 | return m_todoMgr.sorted(asc, sortOrder, addFilter, cat ); | 310 | return m_todoMgr.sorted(asc, sortOrder, addFilter, cat ); |
311 | } | 311 | } |
312 | OTodo MainWindow::event( int uid ) { | 312 | OTodo MainWindow::event( int uid ) { |
313 | return m_todoMgr.event( uid ); | 313 | return m_todoMgr.event( uid ); |
314 | } | 314 | } |
315 | bool MainWindow::isSyncing()const { | 315 | bool MainWindow::isSyncing()const { |
316 | return m_syncing; | 316 | return m_syncing; |
317 | } | 317 | } |
318 | TemplateManager* MainWindow::templateManager() { | 318 | TemplateManager* MainWindow::templateManager() { |
319 | return m_tempManager; | 319 | return m_tempManager; |
320 | } | 320 | } |
321 | Editor* MainWindow::currentEditor() { | 321 | Editor* MainWindow::currentEditor() { |
322 | return m_curEdit; | 322 | return m_curEdit; |
323 | } | 323 | } |
324 | TodoShow* MainWindow::currentShow() { | 324 | TodoShow* MainWindow::currentShow() { |
325 | return m_curShow; | 325 | return m_curShow; |
326 | } | 326 | } |
327 | void MainWindow::slotReload() { | 327 | void MainWindow::slotReload() { |
328 | m_todoMgr.reload(); | 328 | m_todoMgr.reload(); |
329 | currentView()->updateView( ); | 329 | currentView()->updateView( ); |
330 | raiseCurrentView(); | 330 | raiseCurrentView(); |
331 | } | 331 | } |
332 | void MainWindow::closeEvent( QCloseEvent* e ) { | 332 | void MainWindow::closeEvent( QCloseEvent* e ) { |
333 | if (m_stack->visibleWidget() == currentShow()->widget() ) { | 333 | if (m_stack->visibleWidget() == currentShow()->widget() ) { |
334 | raiseCurrentView(); | 334 | raiseCurrentView(); |
335 | e->ignore(); | 335 | e->ignore(); |
336 | return; | 336 | return; |
337 | } | 337 | } |
338 | /* | 338 | /* |
339 | * we should have flushed and now we're still saving | 339 | * we should have flushed and now we're still saving |
340 | * so there is no need to flush | 340 | * so there is no need to flush |
341 | */ | 341 | */ |
342 | if (m_syncing ) { | 342 | if (m_syncing ) { |
343 | e->accept(); | 343 | e->accept(); |
344 | return; | 344 | return; |
345 | } | 345 | } |
346 | bool quit = false; | 346 | bool quit = false; |
347 | if ( m_todoMgr.saveAll() ){ | 347 | if ( m_todoMgr.saveAll() ){ |
348 | qWarning("saved"); | 348 | qWarning("saved"); |
349 | quit = true; | 349 | quit = true; |
350 | }else { | 350 | }else { |
351 | if ( QMessageBox::critical( this, tr("Out of space"), | 351 | if ( QMessageBox::critical( this, tr("Out of space"), |
352 | tr("Todo was unable\n" | 352 | tr("Todo was unable\n" |
353 | "to save your changes.\n" | 353 | "to save your changes.\n" |
354 | "Free up some space\n" | 354 | "Free up some space\n" |
355 | "and try again.\n" | 355 | "and try again.\n" |
356 | "\nQuit Anyway?"), | 356 | "\nQuit Anyway?"), |
357 | QMessageBox::Yes|QMessageBox::Escape, | 357 | QMessageBox::Yes|QMessageBox::Escape, |
358 | QMessageBox::No|QMessageBox::Default) | 358 | QMessageBox::No|QMessageBox::Default) |
359 | != QMessageBox::No ) { | 359 | != QMessageBox::No ) { |
360 | e->accept(); | 360 | e->accept(); |
361 | quit = true; | 361 | quit = true; |
362 | }else | 362 | }else |
363 | e->ignore(); | 363 | e->ignore(); |
364 | 364 | ||
365 | } | 365 | } |
366 | 366 | ||
367 | if (quit ) { | 367 | if (quit ) { |
368 | Config config( "todo" ); | 368 | Config config( "todo" ); |
369 | config.setGroup( "View" ); | 369 | config.setGroup( "View" ); |
370 | config.writeEntry( "ShowComplete", showCompleted() ); | 370 | config.writeEntry( "ShowComplete", showCompleted() ); |
371 | config.writeEntry( "Category", currentCategory() ); | 371 | config.writeEntry( "Category", currentCategory() ); |
372 | config.writeEntry( "ShowDeadLine", showDeadline()); | 372 | config.writeEntry( "ShowDeadLine", showDeadline()); |
373 | config.writeEntry( "ShowOverDue", showOverDue() ); | 373 | config.writeEntry( "ShowOverDue", showOverDue() ); |
374 | /* svae templates */ | 374 | /* svae templates */ |
375 | templateManager()->save(); | 375 | templateManager()->save(); |
376 | e->accept(); | 376 | e->accept(); |
377 | } | 377 | } |
378 | } | 378 | } |
379 | void MainWindow::populateTemplates() { | 379 | void MainWindow::populateTemplates() { |
380 | m_template->clear(); | 380 | m_template->clear(); |
381 | QStringList list = templateManager()->templates(); | 381 | QStringList list = templateManager()->templates(); |
382 | QStringList::Iterator it; | 382 | QStringList::Iterator it; |
383 | for ( it = list.begin(); it != list.end(); ++it ) { | 383 | for ( it = list.begin(); it != list.end(); ++it ) { |
384 | m_template->insertItem( (*it) ); | 384 | m_template->insertItem( (*it) ); |
385 | } | 385 | } |
386 | } | 386 | } |
387 | /* | 387 | /* |
388 | * slotNewFromTemplate | 388 | * slotNewFromTemplate |
389 | * We use the edit widget to do | 389 | * We use the edit widget to do |
390 | * the config but we setUid(-1) | 390 | * the config but we setUid(-1) |
391 | * to get a new uid | 391 | * to get a new uid |
392 | */ | 392 | */ |
393 | /* | 393 | /* |
394 | * first we get the name of the template | 394 | * first we get the name of the template |
395 | * then we will use the TemplateManager | 395 | * then we will use the TemplateManager |
396 | */ | 396 | */ |
397 | void MainWindow::slotNewFromTemplate( int id ) { | 397 | void MainWindow::slotNewFromTemplate( int id ) { |
398 | QString name = m_template->text( id ); | 398 | QString name = m_template->text( id ); |
399 | 399 | ||
400 | OTodo event = templateManager()->templateEvent( name ); | 400 | OTodo event = templateManager()->templateEvent( name ); |
401 | event = currentEditor()->edit(this, | 401 | event = currentEditor()->edit(this, |
402 | event ); | 402 | event ); |
403 | 403 | ||
404 | if ( currentEditor()->accepted() ) { | 404 | if ( currentEditor()->accepted() ) { |
405 | /* assign new todo */ | 405 | /* assign new todo */ |
406 | event.setUid( -1 ); | 406 | event.setUid( -1 ); |
407 | currentView()->addEvent( event ); | 407 | currentView()->addEvent( event ); |
408 | m_todoMgr.add( event ); | 408 | m_todoMgr.add( event ); |
409 | 409 | ||
410 | populateCategories(); | 410 | populateCategories(); |
411 | } | 411 | } |
412 | } | 412 | } |
413 | void MainWindow::slotNew() { | 413 | void MainWindow::slotNew() { |
414 | create(); | 414 | create(); |
415 | } | 415 | } |
416 | void MainWindow::slotDuplicate() { | 416 | void MainWindow::slotDuplicate() { |
417 | if(m_syncing) { | 417 | if(m_syncing) { |
418 | QMessageBox::warning(this, tr("Todo"), | 418 | QMessageBox::warning(this, tr("Todo"), |
419 | tr("Can not edit data, currently syncing")); | 419 | tr("Can not edit data, currently syncing")); |
420 | return; | 420 | return; |
421 | } | 421 | } |
422 | OTodo ev = m_todoMgr.event( currentView()->current() ); | 422 | OTodo ev = m_todoMgr.event( currentView()->current() ); |
423 | /* let's generate a new uid */ | 423 | /* let's generate a new uid */ |
424 | ev.setUid(-1); | 424 | ev.setUid(-1); |
425 | m_todoMgr.add( ev ); | 425 | m_todoMgr.add( ev ); |
426 | 426 | ||
427 | currentView()->addEvent( ev ); | 427 | currentView()->addEvent( ev ); |
428 | raiseCurrentView(); | 428 | raiseCurrentView(); |
429 | } | 429 | } |
430 | void MainWindow::slotDelete() { | 430 | void MainWindow::slotDelete() { |
431 | if (!currentView()->current() ) | 431 | if (!currentView()->current() ) |
432 | return; | 432 | return; |
433 | 433 | ||
434 | if(m_syncing) { | 434 | if(m_syncing) { |
435 | QMessageBox::warning(this, tr("Todo"), | 435 | QMessageBox::warning(this, tr("Todo"), |
436 | tr("Can not edit data, currently syncing")); | 436 | tr("Can not edit data, currently syncing")); |
437 | return; | 437 | return; |
438 | } | 438 | } |
439 | QString strName = currentView()->currentRepresentation(); | 439 | QString strName = currentView()->currentRepresentation(); |
440 | if (!QPEMessageBox::confirmDelete(this, tr("Todo"), strName ) ) | 440 | if (!QPEMessageBox::confirmDelete(this, tr("Todo"), strName ) ) |
441 | return; | 441 | return; |
442 | 442 | ||
443 | m_todoMgr.remove( currentView()->current() ); | 443 | m_todoMgr.remove( currentView()->current() ); |
444 | currentView()->removeEvent( currentView()->current() ); | 444 | currentView()->removeEvent( currentView()->current() ); |
445 | raiseCurrentView(); | 445 | raiseCurrentView(); |
446 | } | 446 | } |
447 | void MainWindow::slotDeleteAll() { | 447 | void MainWindow::slotDeleteAll() { |
448 | if(m_syncing) { | 448 | if(m_syncing) { |
449 | QMessageBox::warning(this, tr("Todo"), | 449 | QMessageBox::warning(this, tr("Todo"), |
450 | tr("Can not edit data, currently syncing")); | 450 | tr("Can not edit data, currently syncing")); |
451 | return; | 451 | return; |
452 | } | 452 | } |
453 | 453 | ||
454 | 454 | ||
455 | if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("all tasks?") ) ) | 455 | if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("all tasks?") ) ) |
456 | return; | 456 | return; |
457 | 457 | ||
458 | m_todoMgr.removeAll(); | 458 | m_todoMgr.removeAll(); |
459 | currentView()->clear(); | 459 | currentView()->clear(); |
460 | 460 | ||
461 | raiseCurrentView(); | 461 | raiseCurrentView(); |
462 | } | 462 | } |
463 | void MainWindow::slotDeleteCompleted() { | 463 | void MainWindow::slotDeleteCompleted() { |
464 | if(m_syncing) { | 464 | if(m_syncing) { |
465 | QMessageBox::warning(this, tr("Todo"), | 465 | QMessageBox::warning(this, tr("Todo"), |
466 | tr("Can not edit data, currently syncing")); | 466 | tr("Can not edit data, currently syncing")); |
467 | return; | 467 | return; |
468 | } | 468 | } |
469 | 469 | ||
470 | if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("all completed tasks?") ) ) | 470 | if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("all completed tasks?") ) ) |
471 | return; | 471 | return; |
472 | 472 | ||
473 | 473 | ||
474 | m_todoMgr.removeCompleted(); | 474 | m_todoMgr.removeCompleted(); |
475 | currentView()->updateView( ); | 475 | currentView()->updateView( ); |
476 | } | 476 | } |
477 | void MainWindow::slotFind() { | 477 | void MainWindow::slotFind() { |
478 | 478 | ||
479 | } | 479 | } |
480 | void MainWindow::slotEdit() { | 480 | void MainWindow::slotEdit() { |
481 | slotEdit( currentView()->current() ); | 481 | slotEdit( currentView()->current() ); |
482 | } | 482 | } |
483 | /* | 483 | /* |
484 | * set the category | 484 | * set the category |
485 | */ | 485 | */ |
486 | void MainWindow::setCategory( int c) { | 486 | void MainWindow::setCategory( int c) { |
487 | if ( c <= 0 ) return; | 487 | if ( c <= 0 ) return; |
488 | 488 | ||
489 | 489 | ||
490 | qWarning("Iterating over cats %d", c ); | 490 | qWarning("Iterating over cats %d", c ); |
491 | for ( unsigned int i = 1; i < m_catMenu->count(); i++ ) | 491 | for ( unsigned int i = 1; i < m_catMenu->count(); i++ ) |
492 | m_catMenu->setItemChecked(i, c == (int)i ); | 492 | m_catMenu->setItemChecked(i, c == (int)i ); |
493 | 493 | ||
494 | if (c == 1 ) { | 494 | if (c == 1 ) { |
495 | m_curCat = QString::null; | 495 | m_curCat = QString::null; |
496 | setCaption( tr("Todo") + " - " + tr("All Categories" ) ); | 496 | setCaption( tr("Todo") + " - " + tr("All Categories" ) ); |
497 | 497 | ||
498 | }else if ( c == (int)m_catMenu->count() - 1 ) { | 498 | }else if ( c == (int)m_catMenu->count() - 1 ) { |
499 | m_curCat = tr("Unfiled"); | 499 | m_curCat = tr("Unfiled"); |
500 | setCaption( tr("Todo") + " - " + tr("Unfiled") ); | 500 | setCaption( tr("Todo") + " - " + tr("Unfiled") ); |
501 | }else { | 501 | }else { |
502 | m_curCat = m_todoMgr.categories()[c-2]; | 502 | m_curCat = m_todoMgr.categories()[c-2]; |
503 | setCaption( tr("Todo") + " - " + m_curCat ); | 503 | setCaption( tr("Todo") + " - " + m_curCat ); |
504 | } | 504 | } |
505 | m_catMenu->setItemChecked( c, true ); | 505 | m_catMenu->setItemChecked( c, true ); |
506 | 506 | ||
507 | currentView()->setShowCategory( m_curCat ); | 507 | currentView()->setShowCategory( m_curCat ); |
508 | raiseCurrentView(); | 508 | raiseCurrentView(); |
509 | } | 509 | } |
510 | void MainWindow::slotShowDeadLine( bool dead) { | 510 | void MainWindow::slotShowDeadLine( bool dead) { |
511 | m_deadline = dead; | 511 | m_deadline = dead; |
512 | currentView()->setShowDeadline( dead ); | 512 | currentView()->setShowDeadline( dead ); |
513 | } | 513 | } |
514 | void MainWindow::slotShowCompleted( bool show) { | 514 | void MainWindow::slotShowCompleted( bool show) { |
515 | m_completed = show; | 515 | m_completed = show; |
516 | currentView()->setShowCompleted( m_completed ); | 516 | currentView()->setShowCompleted( m_completed ); |
517 | } | 517 | } |
518 | bool MainWindow::showOverDue()const { | 518 | bool MainWindow::showOverDue()const { |
519 | return m_overdue; | 519 | return m_overdue; |
520 | } | 520 | } |
521 | void MainWindow::setDocument( const QString& fi) { | 521 | void MainWindow::setDocument( const QString& fi) { |
522 | DocLnk doc(fi); | 522 | DocLnk doc(fi); |
523 | if (doc.isValid() ) | 523 | if (doc.isValid() ) |
524 | receiveFile(doc.file() ); | 524 | receiveFile(doc.file() ); |
525 | else | 525 | else |
526 | receiveFile(fi ); | 526 | receiveFile(fi ); |
527 | } | 527 | } |
528 | 528 | ||
529 | static const char *beamfile = "/tmp/opie-todo.vcs"; | 529 | static const char *beamfile = "/tmp/opie-todo.vcs"; |
530 | void MainWindow::slotBeam() { | 530 | void MainWindow::slotBeam() { |
531 | beam( currentView()->current() ); | 531 | beam( currentView()->current() ); |
532 | } | 532 | } |
533 | void MainWindow::beamDone( Ir* ir) { | 533 | void MainWindow::beamDone( Ir* ir) { |
534 | delete ir; | 534 | delete ir; |
535 | ::unlink( beamfile ); | 535 | ::unlink( beamfile ); |
536 | } | 536 | } |
537 | void MainWindow::receiveFile( const QString& filename ) { | 537 | void MainWindow::receiveFile( const QString& filename ) { |
538 | OTodoAccessVCal* cal = new OTodoAccessVCal(filename ); | 538 | OTodoAccessVCal* cal = new OTodoAccessVCal(filename ); |
539 | OTodoAccess acc( cal ); | 539 | OTodoAccess acc( cal ); |
540 | acc.load(); | 540 | acc.load(); |
541 | OTodoAccess::List list = acc.allRecords(); | 541 | OTodoAccess::List list = acc.allRecords(); |
542 | 542 | ||
543 | QString message = tr("<P>%1 new tasks arrived.<p>Would you like to add them to your Todolist?").arg(list.count() ); | 543 | QString message = tr("<P>%1 new tasks arrived.<p>Would you like to add them to your Todolist?").arg(list.count() ); |
544 | 544 | ||
545 | if ( QMessageBox::information(this, tr("New Tasks"), | 545 | if ( QMessageBox::information(this, tr("New Tasks"), |
546 | message, QMessageBox::Ok, | 546 | message, QMessageBox::Ok, |
547 | QMessageBox::Cancel ) == QMessageBox::Ok ) { | 547 | QMessageBox::Cancel ) == QMessageBox::Ok ) { |
548 | OTodoAccess::List::Iterator it; | 548 | OTodoAccess::List::Iterator it; |
549 | for ( it = list.begin(); it != list.end(); ++it ) | 549 | for ( it = list.begin(); it != list.end(); ++it ) |
550 | m_todoMgr.add( (*it) ); | 550 | m_todoMgr.add( (*it) ); |
551 | 551 | ||
552 | currentView()->updateView(); | 552 | currentView()->updateView(); |
553 | } | 553 | } |
554 | } | 554 | } |
555 | 555 | ||
556 | void MainWindow::slotFlush() { | 556 | void MainWindow::slotFlush() { |
557 | m_syncing = FALSE; | 557 | m_syncing = FALSE; |
558 | m_todoMgr.save(); | 558 | m_todoMgr.save(); |
559 | } | 559 | } |
560 | void MainWindow::slotShowDetails() { | 560 | void MainWindow::slotShowDetails() { |
561 | slotShow( currentView()->current() ); | 561 | slotShow( currentView()->current() ); |
562 | } | 562 | } |
563 | /* | 563 | /* |
564 | * populate the Categories | 564 | * populate the Categories |
565 | * Menu | 565 | * Menu |
566 | */ | 566 | */ |
567 | void MainWindow::populateCategories() { | 567 | void MainWindow::populateCategories() { |
568 | m_todoMgr.load(); | 568 | m_todoMgr.load(); |
569 | 569 | ||
570 | m_catMenu->clear(); | 570 | m_catMenu->clear(); |
571 | int id, rememberId; | 571 | int id, rememberId; |
572 | id = 1; | 572 | id = 1; |
573 | rememberId = 1; | 573 | rememberId = 1; |
574 | 574 | ||
575 | m_catMenu->insertItem( tr( "All Categories" ), id++ ); | 575 | m_catMenu->insertItem( tr( "All Categories" ), id++ ); |
576 | m_catMenu->insertSeparator(); | 576 | m_catMenu->insertSeparator(); |
577 | QStringList categories = m_todoMgr.categories(); | 577 | QStringList categories = m_todoMgr.categories(); |
578 | categories.append( tr( "Unfiled" ) ); | 578 | categories.append( tr( "Unfiled" ) ); |
579 | for ( QStringList::Iterator it = categories.begin(); | 579 | for ( QStringList::Iterator it = categories.begin(); |
580 | it != categories.end(); ++it ) { | 580 | it != categories.end(); ++it ) { |
581 | m_catMenu->insertItem( *it, id ); | 581 | m_catMenu->insertItem( *it, id ); |
582 | if ( *it == currentCategory() ) | 582 | if ( *it == currentCategory() ) |
583 | rememberId = id; | 583 | rememberId = id; |
584 | ++id; | 584 | ++id; |
585 | } | 585 | } |
586 | setCategory( rememberId ); | 586 | setCategory( rememberId ); |
587 | } | 587 | } |
588 | bool MainWindow::showCompleted()const { | 588 | bool MainWindow::showCompleted()const { |
589 | return m_completed; | 589 | return m_completed; |
590 | } | 590 | } |
591 | bool MainWindow::showDeadline()const { | 591 | bool MainWindow::showDeadline()const { |
592 | return m_deadline; | 592 | return m_deadline; |
593 | } | 593 | } |
594 | QString MainWindow::currentCategory()const { | 594 | QString MainWindow::currentCategory()const { |
595 | return m_curCat; | 595 | return m_curCat; |
596 | } | 596 | } |
597 | int MainWindow::currentCatId() { | 597 | int MainWindow::currentCatId() { |
598 | return m_todoMgr.catId( m_curCat ); | 598 | return m_todoMgr.catId( m_curCat ); |
599 | } | 599 | } |
600 | ViewBase* MainWindow::currentView() { | 600 | ViewBase* MainWindow::currentView() { |
601 | return m_curView; | 601 | return m_curView; |
602 | } | 602 | } |
603 | void MainWindow::raiseCurrentView() { | 603 | void MainWindow::raiseCurrentView() { |
604 | m_stack->raiseWidget( m_curView->widget() ); | 604 | m_stack->raiseWidget( m_curView->widget() ); |
605 | } | 605 | } |
606 | void MainWindow::slotShowDue(bool ov) { | 606 | void MainWindow::slotShowDue(bool ov) { |
607 | m_overdue = ov; | 607 | m_overdue = ov; |
608 | currentView()->showOverDue( ov ); | 608 | currentView()->showOverDue( ov ); |
609 | raiseCurrentView(); | 609 | raiseCurrentView(); |
610 | } | 610 | } |
611 | void MainWindow::slotShow( int uid ) { | 611 | void MainWindow::slotShow( int uid ) { |
612 | qWarning("slotShow"); | 612 | qWarning("slotShow"); |
613 | currentShow()->slotShow( event( uid ) ); | 613 | currentShow()->slotShow( event( uid ) ); |
614 | m_stack->raiseWidget( currentShow()->widget() ); | 614 | m_stack->raiseWidget( currentShow()->widget() ); |
615 | } | 615 | } |
616 | void MainWindow::slotEdit( int uid ) { | 616 | void MainWindow::slotEdit( int uid ) { |
617 | if(m_syncing) { | 617 | if(m_syncing) { |
618 | QMessageBox::warning(this, tr("Todo"), | 618 | QMessageBox::warning(this, tr("Todo"), |
619 | tr("Can not edit data, currently syncing")); | 619 | tr("Can not edit data, currently syncing")); |
620 | return; | 620 | return; |
621 | } | 621 | } |
622 | 622 | ||
623 | OTodo todo = m_todoMgr.event( uid ); | 623 | OTodo todo = m_todoMgr.event( uid ); |
624 | 624 | ||
625 | todo = currentEditor()->edit(this, todo ); | 625 | todo = currentEditor()->edit(this, todo ); |
626 | 626 | ||
627 | /* if completed */ | 627 | /* if completed */ |
628 | if ( currentEditor()->accepted() ) { | 628 | if ( currentEditor()->accepted() ) { |
629 | qWarning("Replacing now" ); | 629 | qWarning("Replacing now" ); |
630 | m_todoMgr.update( todo.uid(), todo ); | 630 | m_todoMgr.update( todo.uid(), todo ); |
631 | currentView()->replaceEvent( todo ); | 631 | currentView()->replaceEvent( todo ); |
632 | /* a Category might have changed */ | 632 | /* a Category might have changed */ |
633 | populateCategories(); | 633 | populateCategories(); |
634 | } | 634 | } |
635 | 635 | ||
636 | raiseCurrentView(); | 636 | raiseCurrentView(); |
637 | } | 637 | } |
638 | /* | 638 | /* |
639 | void MainWindow::slotUpdate1( int uid, const SmallTodo& ev) { | 639 | void MainWindow::slotUpdate1( int uid, const SmallTodo& ev) { |
640 | m_todoMgr.update( uid, ev ); | 640 | m_todoMgr.update( uid, ev ); |
641 | } | 641 | } |
642 | */ | 642 | */ |
643 | void MainWindow::updateTodo( const OTodo& ev) { | 643 | void MainWindow::updateTodo( const OTodo& ev) { |
644 | m_todoMgr.update( ev.uid() , ev ); | 644 | m_todoMgr.update( ev.uid() , ev ); |
645 | } | 645 | } |
646 | /* The view changed it's configuration | 646 | /* The view changed it's configuration |
647 | * update the view menu | 647 | * update the view menu |
648 | */ | 648 | */ |
649 | void MainWindow::slotUpdate3( QWidget* ) { | 649 | void MainWindow::slotUpdate3( QWidget* ) { |
650 | 650 | ||
651 | } | 651 | } |
652 | void MainWindow::updateList() { | 652 | void MainWindow::updateList() { |
653 | m_todoMgr.updateList(); | 653 | m_todoMgr.updateList(); |
654 | } | 654 | } |
655 | void MainWindow::setReadAhead( uint count ) { | 655 | void MainWindow::setReadAhead( uint count ) { |
656 | if (m_todoMgr.todoDB() ) | 656 | if (m_todoMgr.todoDB() ) |
657 | m_todoMgr.todoDB()->setReadAhead( count ); | 657 | m_todoMgr.todoDB()->setReadAhead( count ); |
658 | } | 658 | } |
659 | void MainWindow::slotQuickEntered() { | 659 | void MainWindow::slotQuickEntered() { |
660 | qWarning("entered"); | 660 | qWarning("entered"); |
661 | OTodo todo = quickEditor()->todo(); | 661 | OTodo todo = quickEditor()->todo(); |
662 | if (todo.isEmpty() ) | 662 | if (todo.isEmpty() ) |
663 | return; | 663 | return; |
664 | 664 | ||
665 | m_todoMgr.add( todo ); | 665 | m_todoMgr.add( todo ); |
666 | currentView()->addEvent( todo ); | 666 | currentView()->addEvent( todo ); |
667 | raiseCurrentView(); | 667 | raiseCurrentView(); |
668 | } | 668 | } |
669 | QuickEditBase* MainWindow::quickEditor() { | 669 | QuickEditBase* MainWindow::quickEditor() { |
670 | return m_curQuick; | 670 | return m_curQuick; |
671 | } | 671 | } |
672 | void MainWindow::slotComplete( int uid ) { | 672 | void MainWindow::slotComplete( int uid ) { |
673 | slotComplete( event(uid) ); | 673 | slotComplete( event(uid) ); |
674 | } | 674 | } |
675 | void MainWindow::slotComplete( const OTodo& todo ) { | 675 | void MainWindow::slotComplete( const OTodo& todo ) { |
676 | OTodo to = todo; | 676 | OTodo to = todo; |
677 | to.setCompleted( !to.isCompleted() ); | 677 | to.setCompleted( !to.isCompleted() ); |
678 | to.setCompletedDate( QDate::currentDate() ); | 678 | to.setCompletedDate( QDate::currentDate() ); |
679 | 679 | ||
680 | /* | 680 | /* |
681 | * if the item does recur | 681 | * if the item does recur |
682 | * we need to spin it off | 682 | * we need to spin it off |
683 | * and update the items duedate to the next | 683 | * and update the items duedate to the next |
684 | * possible recurrance of this item... | 684 | * possible recurrance of this item... |
685 | * the spinned off one will loose the | 685 | * the spinned off one will loose the |
686 | */ | 686 | */ |
687 | if ( to.recurrence().doesRecur() && to.isCompleted() ) { | 687 | if ( to.recurrence().doesRecur() && to.isCompleted() ) { |
688 | OTodo to2( to ); | 688 | OTodo to2( to ); |
689 | 689 | ||
690 | /* the spinned off one won't recur anymore */ | 690 | /* the spinned off one won't recur anymore */ |
691 | to.setRecurrence( ORecur() ); | 691 | to.setRecurrence( ORecur() ); |
692 | 692 | ||
693 | ORecur rec = to2.recurrence(); | 693 | ORecur rec = to2.recurrence(); |
694 | rec.setStart( to.dueDate() ); | 694 | rec.setStart( to.dueDate() ); |
695 | to2.setRecurrence( rec ); | 695 | to2.setRecurrence( rec ); |
696 | /* | 696 | /* |
697 | * if there is a next occurence | 697 | * if there is a next occurence |
698 | * from the duedate of the last recurrance | 698 | * from the duedate of the last recurrance |
699 | */ | 699 | */ |
700 | QDate date; | 700 | QDate date; |
701 | if ( to2.recurrence().nextOcurrence( to2.dueDate().addDays(1), date ) ) { | 701 | if ( to2.recurrence().nextOcurrence( to2.dueDate().addDays(1), date ) ) { |
702 | QDate inval; | 702 | QDate inval; |
703 | /* generate a new uid for the old record */ | 703 | /* generate a new uid for the old record */ |
704 | to.setUid( 1 ); | 704 | to.setUid( 1 ); |
705 | 705 | ||
706 | /* add the old one cause it has a new UID here cause it was spin off */ | 706 | /* add the old one cause it has a new UID here cause it was spin off */ |
707 | m_todoMgr.add( to ); | 707 | m_todoMgr.add( to ); |
708 | 708 | ||
709 | /* | 709 | /* |
710 | * update the due date | 710 | * update the due date |
711 | * start date | 711 | * start date |
712 | * and complete date | 712 | * and complete date |
713 | */ | 713 | */ |
714 | to2.setDueDate( date ); | 714 | to2.setDueDate( date ); |
715 | to2.setStartDate( inval ); | 715 | to2.setStartDate( inval ); |
716 | to2.setCompletedDate( inval ); | 716 | to2.setCompletedDate( inval ); |
717 | to2.setCompleted( false ); | 717 | to2.setCompleted( false ); |
718 | updateTodo( to2 ); | 718 | updateTodo( to2 ); |
719 | }else | 719 | }else |
720 | updateTodo( to ); | 720 | updateTodo( to ); |
721 | }else | 721 | }else |
722 | updateTodo( to ); | 722 | updateTodo( to ); |
723 | 723 | ||
724 | currentView()->updateView(); | 724 | currentView()->updateView(); |
725 | raiseCurrentView(); | 725 | raiseCurrentView(); |
726 | } | 726 | } |
727 | void MainWindow::flush() { | 727 | void MainWindow::flush() { |
728 | slotFlush(); | 728 | slotFlush(); |
729 | } | 729 | } |
730 | void MainWindow::reload() { | 730 | void MainWindow::reload() { |
731 | slotReload(); | 731 | slotReload(); |
732 | } | 732 | } |
733 | int MainWindow::create() { | 733 | int MainWindow::create() { |
734 | int uid = 0; | 734 | int uid = 0; |
735 | if(m_syncing) { | 735 | if(m_syncing) { |
736 | QMessageBox::warning(this, tr("Todo"), | 736 | QMessageBox::warning(this, tr("Todo"), |
737 | tr("Can not edit data, currently syncing")); | 737 | tr("Can not edit data, currently syncing")); |
738 | return uid; | 738 | return uid; |
739 | } | 739 | } |
740 | 740 | ||
741 | 741 | ||
742 | OTodo todo = currentEditor()->newTodo( currentCatId(), | 742 | OTodo todo = currentEditor()->newTodo( currentCatId(), |
743 | this ); | 743 | this ); |
744 | 744 | ||
745 | if ( currentEditor()->accepted() ) { | 745 | if ( currentEditor()->accepted() ) { |
746 | //todo.assignUid(); | 746 | //todo.assignUid(); |
747 | uid = todo.uid(); | 747 | uid = todo.uid(); |
748 | m_todoMgr.add( todo ); | 748 | m_todoMgr.add( todo ); |
749 | currentView()->addEvent( todo ); | 749 | currentView()->addEvent( todo ); |
750 | 750 | ||
751 | 751 | ||
752 | // I'm afraid we must call this every time now, otherwise | 752 | // I'm afraid we must call this every time now, otherwise |
753 | // spend expensive time comparing all these strings... | 753 | // spend expensive time comparing all these strings... |
754 | // but only call if we changed something -zecke | 754 | // but only call if we changed something -zecke |
755 | populateCategories(); | 755 | populateCategories(); |
756 | } | 756 | } |
757 | raiseCurrentView( ); | 757 | raiseCurrentView( ); |
758 | 758 | ||
759 | return uid; | 759 | return uid; |
760 | } | 760 | } |
761 | /* delete it silently... */ | 761 | /* delete it silently... */ |
762 | bool MainWindow::remove( int uid ) { | 762 | bool MainWindow::remove( int uid ) { |
763 | if (m_syncing) return false; | 763 | if (m_syncing) return false; |
764 | 764 | ||
765 | return m_todoMgr.remove( uid ); | 765 | return m_todoMgr.remove( uid ); |
766 | } | 766 | } |
767 | void MainWindow::beam( int uid, int ) { | 767 | void MainWindow::beam( int uid, int ) { |
768 | ::unlink( beamfile ); | 768 | ::unlink( beamfile ); |
769 | OTodo todo = event( uid ); | 769 | OTodo todo = event( uid ); |
770 | OTodoAccessVCal* cal = new OTodoAccessVCal(QString::fromLatin1(beamfile) ); | 770 | OTodoAccessVCal* cal = new OTodoAccessVCal(QString::fromLatin1(beamfile) ); |
771 | OTodoAccess acc( cal ); | 771 | OTodoAccess acc( cal ); |
772 | acc.load(); | 772 | acc.load(); |
773 | acc.add( todo ); | 773 | acc.add( todo ); |
774 | acc.save(); | 774 | acc.save(); |
775 | Ir* ir = new Ir(this ); | 775 | Ir* ir = new Ir(this ); |
776 | connect(ir, SIGNAL(done(Ir*) ), | 776 | connect(ir, SIGNAL(done(Ir*) ), |
777 | this, SLOT(beamDone(Ir*) ) ); | 777 | this, SLOT(beamDone(Ir*) ) ); |
778 | ir->send( beamfile, todo.summary(), "text/x-vCalendar" ); | 778 | ir->send( beamfile, todo.summary(), "text/x-vCalendar" ); |
779 | } | 779 | } |
780 | void MainWindow::show( int uid ) { | 780 | void MainWindow::show( int uid ) { |
781 | slotShow( uid ); | 781 | slotShow( uid ); |
782 | } | 782 | } |
783 | void MainWindow::edit( int uid ) { | 783 | void MainWindow::edit( int uid ) { |
784 | slotEdit( uid ); | 784 | slotEdit( uid ); |
785 | } | 785 | } |
786 | void MainWindow::add( const OPimRecord& rec) { | 786 | void MainWindow::add( const OPimRecord& rec) { |
787 | if ( rec.rtti() != OTodo::rtti() ) return; | 787 | if ( rec.rtti() != OTodo::rtti() ) return; |
788 | 788 | ||
789 | const OTodo& todo = static_cast<const OTodo&>(rec); | 789 | const OTodo& todo = static_cast<const OTodo&>(rec); |
790 | 790 | ||
791 | m_todoMgr.add(todo ); | 791 | m_todoMgr.add(todo ); |
792 | currentView()->addEvent( todo ); | 792 | currentView()->addEvent( todo ); |
793 | 793 | ||
794 | 794 | ||
795 | // I'm afraid we must call this every time now, otherwise | 795 | // I'm afraid we must call this every time now, otherwise |
796 | // spend expensive time comparing all these strings... | 796 | // spend expensive time comparing all these strings... |
797 | // but only call if we changed something -zecke | 797 | // but only call if we changed something -zecke |
798 | populateCategories(); | 798 | populateCategories(); |
799 | } | 799 | } |
800 | /* todo does not have the QDataStream<< and >> operators implemented :( | ||
801 | * FIXME | ||
802 | */ | ||
803 | OPimRecord* MainWindow::record( int rtti, const QByteArray& ) { | ||
804 | return 0l; | ||
805 | } | ||
diff --git a/core/pim/todo/mainwindow.h b/core/pim/todo/mainwindow.h index 14cfa82..87a9133 100644 --- a/core/pim/todo/mainwindow.h +++ b/core/pim/todo/mainwindow.h | |||
@@ -1,203 +1,202 @@ | |||
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 QWidgetStack; |
48 | class Ir; | 48 | class Ir; |
49 | class QVBox; | 49 | class QVBox; |
50 | 50 | ||
51 | namespace Todo { | 51 | namespace Todo { |
52 | typedef TodoView View; | 52 | typedef TodoView View; |
53 | class TemplateManager; | 53 | class TemplateManager; |
54 | class Editor; | 54 | class Editor; |
55 | class TodoShow; | 55 | class TodoShow; |
56 | class TemplateEditor; | 56 | class TemplateEditor; |
57 | struct QuickEditBase; | 57 | struct QuickEditBase; |
58 | 58 | ||
59 | class MainWindow : public OPimMainWindow { | 59 | class MainWindow : public OPimMainWindow { |
60 | Q_OBJECT | 60 | Q_OBJECT |
61 | friend class TodoView; // avoid QObject here.... | 61 | friend class TodoView; // avoid QObject here.... |
62 | public: | 62 | public: |
63 | MainWindow( QWidget *parent = 0, | 63 | MainWindow( QWidget *parent = 0, |
64 | const char* name = 0 ); | 64 | const char* name = 0 ); |
65 | ~MainWindow(); | 65 | ~MainWindow(); |
66 | 66 | ||
67 | /** return a context menu for an OTodo */ | 67 | /** return a context menu for an OTodo */ |
68 | QPopupMenu* contextMenu(int uid, bool doesRecur = FALSE ); | 68 | QPopupMenu* contextMenu(int uid, bool doesRecur = FALSE ); |
69 | QPopupMenu* options(); | 69 | QPopupMenu* options(); |
70 | QPopupMenu* edit(); | 70 | QPopupMenu* edit(); |
71 | QToolBar* toolbar(); | 71 | QToolBar* toolbar(); |
72 | 72 | ||
73 | 73 | ||
74 | void updateList(); | 74 | void updateList(); |
75 | OTodoAccess::List list()const; | 75 | OTodoAccess::List list()const; |
76 | OTodoAccess::List sorted( bool asc, int sortOrder ); | 76 | OTodoAccess::List sorted( bool asc, int sortOrder ); |
77 | OTodoAccess::List sorted( bool asc, int sortOrder, int addFilter ); | 77 | OTodoAccess::List sorted( bool asc, int sortOrder, int addFilter ); |
78 | 78 | ||
79 | OTodo event(int uid ); | 79 | OTodo event(int uid ); |
80 | 80 | ||
81 | bool isSyncing()const; | 81 | bool isSyncing()const; |
82 | bool showCompleted()const; | 82 | bool showCompleted()const; |
83 | bool showDeadline()const; | 83 | bool showDeadline()const; |
84 | bool showOverDue()const; | 84 | bool showOverDue()const; |
85 | QString currentCategory()const; | 85 | QString currentCategory()const; |
86 | int currentCatId(); | 86 | int currentCatId(); |
87 | TemplateManager* templateManager(); | 87 | TemplateManager* templateManager(); |
88 | QuickEditBase* quickEditor(); | 88 | QuickEditBase* quickEditor(); |
89 | 89 | ||
90 | void updateTodo( const OTodo& ); | 90 | void updateTodo( const OTodo& ); |
91 | void populateTemplates(); | 91 | void populateTemplates(); |
92 | Editor* currentEditor(); | 92 | Editor* currentEditor(); |
93 | void setReadAhead(uint count ); | 93 | void setReadAhead(uint count ); |
94 | private slots: | 94 | private slots: |
95 | void slotQuickEntered(); | 95 | void slotQuickEntered(); |
96 | void populateCategories(); | 96 | void populateCategories(); |
97 | void slotReload(); | 97 | void slotReload(); |
98 | void slotFlush(); | 98 | void slotFlush(); |
99 | 99 | ||
100 | protected: | 100 | protected: |
101 | void closeEvent( QCloseEvent* e ); | 101 | void closeEvent( QCloseEvent* e ); |
102 | 102 | ||
103 | private: | 103 | private: |
104 | void receiveFile( const QString& filename ); | 104 | void receiveFile( const QString& filename ); |
105 | void connectBase( ViewBase* ); | 105 | void connectBase( ViewBase* ); |
106 | void initUI(); | 106 | void initUI(); |
107 | void initActions(); | 107 | void initActions(); |
108 | void initConfig(); | 108 | void initConfig(); |
109 | void initViews(); | 109 | void initViews(); |
110 | void initEditor(); | 110 | void initEditor(); |
111 | void initShow(); | 111 | void initShow(); |
112 | void initTemplate(); | 112 | void initTemplate(); |
113 | void raiseCurrentView(); | 113 | void raiseCurrentView(); |
114 | ViewBase* currentView(); | 114 | ViewBase* currentView(); |
115 | ViewBase* m_curView; | 115 | ViewBase* m_curView; |
116 | QuickEditBase* m_curQuick; | 116 | QuickEditBase* m_curQuick; |
117 | Editor* m_curEdit; | 117 | Editor* m_curEdit; |
118 | TodoShow* currentShow(); | 118 | TodoShow* currentShow(); |
119 | TodoShow* m_curShow; | 119 | TodoShow* m_curShow; |
120 | TemplateEditor* currentTemplateEditor(); | 120 | TemplateEditor* currentTemplateEditor(); |
121 | TemplateEditor* m_curTempEd; | 121 | TemplateEditor* m_curTempEd; |
122 | 122 | ||
123 | QMenuBar* m_bar; | 123 | QMenuBar* m_bar; |
124 | QToolBar* m_tool; | 124 | QToolBar* m_tool; |
125 | QAction* m_editAction, | 125 | QAction* m_editAction, |
126 | *m_deleteAction, | 126 | *m_deleteAction, |
127 | *m_findAction, | 127 | *m_findAction, |
128 | *m_completedAction, | 128 | *m_completedAction, |
129 | *m_showDeadLineAction, | 129 | *m_showDeadLineAction, |
130 | *m_deleteAllAction, | 130 | *m_deleteAllAction, |
131 | *m_deleteCompleteAction, | 131 | *m_deleteCompleteAction, |
132 | *m_duplicateAction, | 132 | *m_duplicateAction, |
133 | *m_showOverDueAction, | 133 | *m_showOverDueAction, |
134 | *m_effectiveAction; | 134 | *m_effectiveAction; |
135 | QWidgetStack *m_stack; | 135 | QWidgetStack *m_stack; |
136 | QPopupMenu* m_catMenu, | 136 | QPopupMenu* m_catMenu, |
137 | *m_edit, | 137 | *m_edit, |
138 | *m_options, | 138 | *m_options, |
139 | *m_template; | 139 | *m_template; |
140 | /* box with two rows | 140 | /* box with two rows |
141 | * top will be the quick edit | 141 | * top will be the quick edit |
142 | * this will bite my ass once | 142 | * this will bite my ass once |
143 | * we want to have all parts | 143 | * we want to have all parts |
144 | * exchangeable | 144 | * exchangeable |
145 | */ | 145 | */ |
146 | QVBox* m_mainBox; | 146 | QVBox* m_mainBox; |
147 | 147 | ||
148 | bool m_syncing:1; | 148 | bool m_syncing:1; |
149 | bool m_deadline:1; | 149 | bool m_deadline:1; |
150 | bool m_completed:1; | 150 | bool m_completed:1; |
151 | bool m_overdue:1; | 151 | bool m_overdue:1; |
152 | TodoManager m_todoMgr; | 152 | TodoManager m_todoMgr; |
153 | QString m_curCat; | 153 | QString m_curCat; |
154 | QList<ViewBase> m_views; | 154 | QList<ViewBase> m_views; |
155 | QList<QuickEditBase> m_quickEdit; | 155 | QList<QuickEditBase> m_quickEdit; |
156 | uint m_counter; | 156 | uint m_counter; |
157 | TemplateManager* m_tempManager; | 157 | TemplateManager* m_tempManager; |
158 | 158 | ||
159 | 159 | ||
160 | private slots: | 160 | private slots: |
161 | void slotShow(int); | 161 | void slotShow(int); |
162 | void slotEdit(int); | 162 | void slotEdit(int); |
163 | void slotUpdate3( QWidget* ); | 163 | void slotUpdate3( QWidget* ); |
164 | void slotComplete( int uid ); | 164 | void slotComplete( int uid ); |
165 | void slotComplete( const OTodo& ev ); | 165 | void slotComplete( const OTodo& ev ); |
166 | void slotNewFromTemplate(int id ); | 166 | void slotNewFromTemplate(int id ); |
167 | void slotNew(); | 167 | void slotNew(); |
168 | void slotDuplicate(); | 168 | void slotDuplicate(); |
169 | 169 | ||
170 | void slotDelete(); | 170 | void slotDelete(); |
171 | void slotDeleteAll(); | 171 | void slotDeleteAll(); |
172 | void slotDeleteCompleted(); | 172 | void slotDeleteCompleted(); |
173 | 173 | ||
174 | void slotEdit(); | 174 | void slotEdit(); |
175 | void slotFind(); | 175 | void slotFind(); |
176 | 176 | ||
177 | void setCategory( int ); | 177 | void setCategory( int ); |
178 | 178 | ||
179 | void slotShowDeadLine( bool ); | 179 | void slotShowDeadLine( bool ); |
180 | void slotShowCompleted( bool ); | 180 | void slotShowCompleted( bool ); |
181 | 181 | ||
182 | void setDocument( const QString& ); | 182 | void setDocument( const QString& ); |
183 | 183 | ||
184 | 184 | ||
185 | void slotBeam(); | 185 | void slotBeam(); |
186 | void beamDone( Ir* ); | 186 | void beamDone( Ir* ); |
187 | void slotShowDetails(); | 187 | void slotShowDetails(); |
188 | void slotShowDue( bool ); | 188 | void slotShowDue( bool ); |
189 | /* reimplementation from opimmainwindow */ | 189 | /* reimplementation from opimmainwindow */ |
190 | protected slots: | 190 | protected slots: |
191 | void flush(); | 191 | void flush(); |
192 | void reload(); | 192 | void reload(); |
193 | int create(); | 193 | int create(); |
194 | bool remove( int uid ); | 194 | bool remove( int uid ); |
195 | void beam(int uid, int transport = IrDa ); | 195 | void beam(int uid, int transport = IrDa ); |
196 | void show( int uid ); | 196 | void show( int uid ); |
197 | void edit( int uid ); | 197 | void edit( int uid ); |
198 | void add( const OPimRecord& ); | 198 | void add( const OPimRecord& ); |
199 | OPimRecord* record( int rtti, const QByteArray& ); | ||
200 | }; | 199 | }; |
201 | }; | 200 | }; |
202 | 201 | ||
203 | #endif | 202 | #endif |
diff --git a/core/pim/todo/tableview.cpp b/core/pim/todo/tableview.cpp index 0f683c9..2434150 100644 --- a/core/pim/todo/tableview.cpp +++ b/core/pim/todo/tableview.cpp | |||
@@ -1,524 +1,524 @@ | |||
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 | 30 | ||
31 | #include <qlineedit.h> | 31 | #include <qlineedit.h> |
32 | #include <qtimer.h> | 32 | #include <qtimer.h> |
33 | #include <qpoint.h> | 33 | #include <qpoint.h> |
34 | #include <qpopupmenu.h> | 34 | #include <qpopupmenu.h> |
35 | 35 | ||
36 | #include <qpe/config.h> | 36 | #include <qpe/config.h> |
37 | 37 | ||
38 | #include <opie/orecur.h> | 38 | #include <opie/orecur.h> |
39 | 39 | ||
40 | #include "mainwindow.h" | 40 | #include "mainwindow.h" |
41 | //#include "tableitems.h" | 41 | //#include "tableitems.h" |
42 | #include "tableview.h" | 42 | #include "tableview.h" |
43 | 43 | ||
44 | using namespace Todo; | 44 | using namespace Todo; |
45 | 45 | ||
46 | namespace { | 46 | namespace { |
47 | static const int BoxSize = 14; | 47 | static const int BoxSize = 14; |
48 | static const int RowHeight = 20; | 48 | static const int RowHeight = 20; |
49 | } | 49 | } |
50 | 50 | ||
51 | 51 | ||
52 | void TableView::initConfig() { | 52 | void TableView::initConfig() { |
53 | Config config( "todo" ); | 53 | Config config( "todo" ); |
54 | config.setGroup( "Options" ); | 54 | config.setGroup( "Options" ); |
55 | m_completeStrokeWidth = config.readNumEntry( "CompleteStrokeWidth", 8 ); | 55 | m_completeStrokeWidth = config.readNumEntry( "CompleteStrokeWidth", 8 ); |
56 | } | 56 | } |
57 | 57 | ||
58 | TableView::TableView( MainWindow* window, QWidget* wid ) | 58 | TableView::TableView( MainWindow* window, QWidget* wid ) |
59 | : QTable( wid ), TodoView( window ) { | 59 | : QTable( wid ), TodoView( window ) { |
60 | setUpdatesEnabled( false ); | 60 | setUpdatesEnabled( false ); |
61 | viewport()->setUpdatesEnabled( false ); | 61 | viewport()->setUpdatesEnabled( false ); |
62 | m_enablePaint = false; | 62 | m_enablePaint = false; |
63 | setNumRows(0); | 63 | setNumRows(0); |
64 | setNumCols(4); | 64 | setNumCols(4); |
65 | 65 | ||
66 | setSorting( TRUE ); | 66 | setSorting( TRUE ); |
67 | setSelectionMode( NoSelection ); | 67 | setSelectionMode( NoSelection ); |
68 | // setColumnStretchable( 2, TRUE ); | 68 | // setColumnStretchable( 2, TRUE ); |
69 | setColumnStretchable( 3, FALSE ); | 69 | setColumnStretchable( 3, FALSE ); |
70 | setColumnWidth(0, 20 ); | 70 | setColumnWidth(0, 20 ); |
71 | setColumnWidth(1, 35 ); | 71 | setColumnWidth(1, 35 ); |
72 | setColumnWidth(3, 18 ); | 72 | setColumnWidth(3, 18 ); |
73 | 73 | ||
74 | setLeftMargin( 0 ); | 74 | setLeftMargin( 0 ); |
75 | verticalHeader()->hide(); | 75 | verticalHeader()->hide(); |
76 | 76 | ||
77 | horizontalHeader()->setLabel(0, tr("C.") ); | 77 | horizontalHeader()->setLabel(0, tr("C.") ); |
78 | horizontalHeader()->setLabel(1, tr("Prior.") ); | 78 | horizontalHeader()->setLabel(1, tr("Prior.") ); |
79 | horizontalHeader()->setLabel(2, tr("Description" ) ); | 79 | horizontalHeader()->setLabel(2, tr("Description" ) ); |
80 | 80 | ||
81 | // setColumnStretchable(3, FALSE ); | 81 | // setColumnStretchable(3, FALSE ); |
82 | 82 | ||
83 | horizontalHeader()->setLabel(3, tr("Deadline") ); | 83 | horizontalHeader()->setLabel(3, tr("Deadline") ); |
84 | 84 | ||
85 | if ( todoWindow()->showDeadline() ) | 85 | if ( todoWindow()->showDeadline() ) |
86 | showColumn( 3); | 86 | showColumn( 3); |
87 | else | 87 | else |
88 | hideColumn(3 ); | 88 | hideColumn(3 ); |
89 | 89 | ||
90 | connect((QTable*)this, SIGNAL( clicked( int, int, int, const QPoint& ) ), | 90 | connect((QTable*)this, SIGNAL( clicked( int, int, int, const QPoint& ) ), |
91 | this, SLOT( slotClicked(int, int, int, const QPoint& ) ) ); | 91 | this, SLOT( slotClicked(int, int, int, const QPoint& ) ) ); |
92 | connect((QTable*)this, SIGNAL( pressed( int, int, int, const QPoint& ) ), | 92 | connect((QTable*)this, SIGNAL( pressed( int, int, int, const QPoint& ) ), |
93 | this, SLOT( slotPressed(int, int, int, const QPoint& ) ) ); | 93 | this, SLOT( slotPressed(int, int, int, const QPoint& ) ) ); |
94 | connect((QTable*)this, SIGNAL(valueChanged(int, int) ), | 94 | connect((QTable*)this, SIGNAL(valueChanged(int, int) ), |
95 | this, SLOT( slotValueChanged(int, int) ) ); | 95 | this, SLOT( slotValueChanged(int, int) ) ); |
96 | connect((QTable*)this, SIGNAL(currentChanged(int, int) ), | 96 | connect((QTable*)this, SIGNAL(currentChanged(int, int) ), |
97 | this, SLOT( slotCurrentChanged(int, int) ) ); | 97 | this, SLOT( slotCurrentChanged(int, int) ) ); |
98 | 98 | ||
99 | m_menuTimer = new QTimer( this ); | 99 | m_menuTimer = new QTimer( this ); |
100 | connect( m_menuTimer, SIGNAL(timeout()), | 100 | connect( m_menuTimer, SIGNAL(timeout()), |
101 | this, SLOT(slotShowMenu()) ); | 101 | this, SLOT(slotShowMenu()) ); |
102 | 102 | ||
103 | m_enablePaint = true; | 103 | m_enablePaint = true; |
104 | setUpdatesEnabled( true ); | 104 | setUpdatesEnabled( true ); |
105 | viewport()->setUpdatesEnabled( true ); | 105 | viewport()->setUpdatesEnabled( true ); |
106 | viewport()->update(); | 106 | viewport()->update(); |
107 | setSortOrder( 0 ); | 107 | setSortOrder( 0 ); |
108 | setAscending( TRUE ); | 108 | setAscending( TRUE ); |
109 | m_first = true; | 109 | m_first = true; |
110 | 110 | ||
111 | /* now let's init the config */ | 111 | /* now let's init the config */ |
112 | initConfig(); | 112 | initConfig(); |
113 | } | 113 | } |
114 | /* a new day has started | 114 | /* a new day has started |
115 | * update the day | 115 | * update the day |
116 | */ | 116 | */ |
117 | void TableView::newDay() { | 117 | void TableView::newDay() { |
118 | clear(); | 118 | clear(); |
119 | updateView(); | 119 | updateView(); |
120 | } | 120 | } |
121 | TableView::~TableView() { | 121 | TableView::~TableView() { |
122 | 122 | ||
123 | } | 123 | } |
124 | void TableView::slotShowMenu() { | 124 | void TableView::slotShowMenu() { |
125 | QPopupMenu *menu = todoWindow()->contextMenu( current(), sorted()[currentRow()].recurrence().doesRecur() ); | 125 | QPopupMenu *menu = todoWindow()->contextMenu( current(), sorted()[currentRow()].recurrence().doesRecur() ); |
126 | menu->exec(QCursor::pos() ); | 126 | menu->exec(QCursor::pos() ); |
127 | delete menu; | 127 | delete menu; |
128 | } | 128 | } |
129 | QString TableView::type() const { | 129 | QString TableView::type() const { |
130 | return QString::fromLatin1( tr("Table View") ); | 130 | return QString::fromLatin1( tr("Table View") ); |
131 | } | 131 | } |
132 | int TableView::current() { | 132 | int TableView::current() { |
133 | int uid = sorted().uidAt(currentRow() ); | 133 | int uid = sorted().uidAt(currentRow() ); |
134 | 134 | ||
135 | return uid; | 135 | return uid; |
136 | } | 136 | } |
137 | QString TableView::currentRepresentation() { | 137 | QString TableView::currentRepresentation() { |
138 | OTodo to = sorted()[currentRow()]; | 138 | OTodo to = sorted()[currentRow()]; |
139 | return to.summary().isEmpty() ? to.description().left(20) : to.summary() ; | 139 | return to.summary().isEmpty() ? to.description().left(20) : to.summary() ; |
140 | } | 140 | } |
141 | /* show overdue */ | 141 | /* show overdue */ |
142 | void TableView::showOverDue( bool ) { | 142 | void TableView::showOverDue( bool ) { |
143 | clear(); | 143 | clear(); |
144 | updateView(); | 144 | updateView(); |
145 | } | 145 | } |
146 | 146 | ||
147 | void TableView::updateView( ) { | 147 | void TableView::updateView( ) { |
148 | qWarning("update view"); | 148 | qWarning("update view"); |
149 | m_row = false; | 149 | m_row = false; |
150 | static int id; | 150 | static int id; |
151 | id = startTimer(4000 ); | 151 | id = startTimer(4000 ); |
152 | /* FIXME we want one page to be read! | 152 | /* FIXME we want one page to be read! |
153 | * | 153 | * |
154 | * Calculate that screensize | 154 | * Calculate that screensize |
155 | */ | 155 | */ |
156 | todoWindow()->setReadAhead( 4 ); | 156 | todoWindow()->setReadAhead( 4 ); |
157 | sort(); | 157 | sort(); |
158 | OTodoAccess::List::Iterator it, end; | 158 | OTodoAccess::List::Iterator it, end; |
159 | it = sorted().begin(); | 159 | it = sorted().begin(); |
160 | end = sorted().end(); | 160 | end = sorted().end(); |
161 | 161 | ||
162 | qWarning("setTodos"); | 162 | qWarning("setTodos"); |
163 | QTime time; | 163 | QTime time; |
164 | time.start(); | 164 | time.start(); |
165 | m_enablePaint = false; | 165 | m_enablePaint = false; |
166 | setUpdatesEnabled( false ); | 166 | setUpdatesEnabled( false ); |
167 | viewport()->setUpdatesEnabled( false ); | 167 | viewport()->setUpdatesEnabled( false ); |
168 | 168 | ||
169 | setNumRows( it.count() ); | 169 | setNumRows( it.count() ); |
170 | if ( it.count() == 0 ) | 170 | if ( it.count() == 0 ) |
171 | killTimer(id); | 171 | killTimer(id); |
172 | 172 | ||
173 | int elc = time.elapsed(); | 173 | // int elc = time.elapsed(); |
174 | setUpdatesEnabled( true ); | 174 | setUpdatesEnabled( true ); |
175 | viewport()->setUpdatesEnabled( true ); | 175 | viewport()->setUpdatesEnabled( true ); |
176 | viewport()->update(); | 176 | viewport()->update(); |
177 | 177 | ||
178 | m_enablePaint = true; | 178 | m_enablePaint = true; |
179 | int el = time.elapsed(); | 179 | // int el = time.elapsed(); |
180 | } | 180 | } |
181 | void TableView::setTodo( int, const OTodo&) { | 181 | void TableView::setTodo( int, const OTodo&) { |
182 | sort(); | 182 | sort(); |
183 | 183 | ||
184 | /* repaint */ | 184 | /* repaint */ |
185 | repaint(); | 185 | repaint(); |
186 | } | 186 | } |
187 | void TableView::addEvent( const OTodo&) { | 187 | void TableView::addEvent( const OTodo&) { |
188 | 188 | ||
189 | /* fix problems of not showing the 'Haken' */ | 189 | /* fix problems of not showing the 'Haken' */ |
190 | updateView(); | 190 | updateView(); |
191 | } | 191 | } |
192 | /* | 192 | /* |
193 | * find the event | 193 | * find the event |
194 | * and then replace the complete row | 194 | * and then replace the complete row |
195 | */ | 195 | */ |
196 | void TableView::replaceEvent( const OTodo& ev) { | 196 | void TableView::replaceEvent( const OTodo& ev) { |
197 | addEvent( ev ); | 197 | addEvent( ev ); |
198 | } | 198 | } |
199 | /* | 199 | /* |
200 | * re aligning table can be slow too | 200 | * re aligning table can be slow too |
201 | * FIXME: look what performs better | 201 | * FIXME: look what performs better |
202 | * either this or the old align table | 202 | * either this or the old align table |
203 | */ | 203 | */ |
204 | void TableView::removeEvent( int ) { | 204 | void TableView::removeEvent( int ) { |
205 | updateView(); | 205 | updateView(); |
206 | } | 206 | } |
207 | void TableView::setShowCompleted( bool b) { | 207 | void TableView::setShowCompleted( bool b) { |
208 | qWarning("Show Completed %d" + b ); | 208 | qWarning("Show Completed %d" + b ); |
209 | updateView(); | 209 | updateView(); |
210 | } | 210 | } |
211 | void TableView::setShowDeadline( bool b) { | 211 | void TableView::setShowDeadline( bool b) { |
212 | qWarning("Show DeadLine %d" + b ); | 212 | qWarning("Show DeadLine %d" + b ); |
213 | if (b) | 213 | if (b) |
214 | showColumn(3 ); | 214 | showColumn(3 ); |
215 | else | 215 | else |
216 | hideColumn(3 ); | 216 | hideColumn(3 ); |
217 | } | 217 | } |
218 | void TableView::setShowCategory( const QString& str) { | 218 | void TableView::setShowCategory( const QString& str) { |
219 | qWarning("setShowCategory"); | 219 | qWarning("setShowCategory"); |
220 | if ( str != m_oleCat || m_first ) | 220 | if ( str != m_oleCat || m_first ) |
221 | updateView(); | 221 | updateView(); |
222 | 222 | ||
223 | m_oleCat = str; | 223 | m_oleCat = str; |
224 | m_first = false; | 224 | m_first = false; |
225 | 225 | ||
226 | } | 226 | } |
227 | void TableView::clear() { | 227 | void TableView::clear() { |
228 | setNumRows(0); | 228 | setNumRows(0); |
229 | } | 229 | } |
230 | void TableView::slotClicked(int row, int col, int, | 230 | void TableView::slotClicked(int row, int col, int, |
231 | const QPoint& point) { | 231 | const QPoint& point) { |
232 | if ( !cellGeometry(row, col ).contains(point ) ) | 232 | if ( !cellGeometry(row, col ).contains(point ) ) |
233 | return; | 233 | return; |
234 | 234 | ||
235 | int ui= sorted().uidAt( row ); | 235 | int ui= sorted().uidAt( row ); |
236 | 236 | ||
237 | 237 | ||
238 | switch( col ) { | 238 | switch( col ) { |
239 | case 0:{ | 239 | case 0:{ |
240 | int x = point.x() -columnPos( col ); | 240 | int x = point.x() -columnPos( col ); |
241 | int y = point.y() -rowPos( row ); | 241 | int y = point.y() -rowPos( row ); |
242 | int w = columnWidth( col ); | 242 | int w = columnWidth( col ); |
243 | int h = rowHeight( row ); | 243 | int h = rowHeight( row ); |
244 | if ( x >= ( w - BoxSize ) / 2 && | 244 | if ( x >= ( w - BoxSize ) / 2 && |
245 | x <= ( w - BoxSize ) / 2 + BoxSize && | 245 | x <= ( w - BoxSize ) / 2 + BoxSize && |
246 | y >= ( h - BoxSize ) / 2 && | 246 | y >= ( h - BoxSize ) / 2 && |
247 | y <= ( h - BoxSize ) / 2 + BoxSize ) { | 247 | y <= ( h - BoxSize ) / 2 + BoxSize ) { |
248 | TodoView::complete(sorted()[row] ); | 248 | TodoView::complete(sorted()[row] ); |
249 | } | 249 | } |
250 | } | 250 | } |
251 | break; | 251 | break; |
252 | 252 | ||
253 | case 1: | 253 | case 1: |
254 | break; | 254 | break; |
255 | 255 | ||
256 | case 2: { | 256 | case 2: { |
257 | m_menuTimer->stop(); | 257 | m_menuTimer->stop(); |
258 | showTodo( ui ); | 258 | showTodo( ui ); |
259 | break; | 259 | break; |
260 | } | 260 | } |
261 | case 3: { | 261 | case 3: { |
262 | m_menuTimer->stop(); | 262 | m_menuTimer->stop(); |
263 | TodoView::edit( ui ); | 263 | TodoView::edit( ui ); |
264 | break; | 264 | break; |
265 | } | 265 | } |
266 | } | 266 | } |
267 | 267 | ||
268 | 268 | ||
269 | } | 269 | } |
270 | void TableView::slotPressed(int row, int col, int, | 270 | void TableView::slotPressed(int row, int col, int, |
271 | const QPoint& point) { | 271 | const QPoint& point) { |
272 | 272 | ||
273 | qWarning("pressed row %d col %d x:%d+y:%d", row,col,point.x(),point.y() ); | 273 | qWarning("pressed row %d col %d x:%d+y:%d", row,col,point.x(),point.y() ); |
274 | m_prevP = point; | 274 | m_prevP = point; |
275 | /* TextColumn column */ | 275 | /* TextColumn column */ |
276 | if ( col == 2 && cellGeometry( row, col ).contains( point ) ) | 276 | if ( col == 2 && cellGeometry( row, col ).contains( point ) ) |
277 | m_menuTimer->start( 750, TRUE ); | 277 | m_menuTimer->start( 750, TRUE ); |
278 | } | 278 | } |
279 | void TableView::slotValueChanged( int, int ) { | 279 | void TableView::slotValueChanged( int, int ) { |
280 | qWarning("Value Changed"); | 280 | qWarning("Value Changed"); |
281 | } | 281 | } |
282 | void TableView::slotCurrentChanged(int, int ) { | 282 | void TableView::slotCurrentChanged(int, int ) { |
283 | m_menuTimer->stop(); | 283 | m_menuTimer->stop(); |
284 | } | 284 | } |
285 | QWidget* TableView::widget() { | 285 | QWidget* TableView::widget() { |
286 | return this; | 286 | return this; |
287 | } | 287 | } |
288 | /* | 288 | /* |
289 | * We need to overwrite sortColumn | 289 | * We need to overwrite sortColumn |
290 | * because we want to sort whole row | 290 | * because we want to sort whole row |
291 | * based | 291 | * based |
292 | * We event want to set the setOrder | 292 | * We event want to set the setOrder |
293 | * to a sort() and update() | 293 | * to a sort() and update() |
294 | */ | 294 | */ |
295 | void TableView::sortColumn( int col, bool asc, bool ) { | 295 | void TableView::sortColumn( int col, bool asc, bool ) { |
296 | qWarning("bool %d", asc ); | 296 | qWarning("bool %d", asc ); |
297 | setSortOrder( col ); | 297 | setSortOrder( col ); |
298 | setAscending( asc ); | 298 | setAscending( asc ); |
299 | updateView(); | 299 | updateView(); |
300 | } | 300 | } |
301 | void TableView::viewportPaintEvent( QPaintEvent* e) { | 301 | void TableView::viewportPaintEvent( QPaintEvent* e) { |
302 | if (m_enablePaint ) | 302 | if (m_enablePaint ) |
303 | QTable::viewportPaintEvent( e ); | 303 | QTable::viewportPaintEvent( e ); |
304 | } | 304 | } |
305 | /* | 305 | /* |
306 | * This segment is copyrighted by TT | 306 | * This segment is copyrighted by TT |
307 | * it was taken from their todolist | 307 | * it was taken from their todolist |
308 | * application this code is GPL | 308 | * application this code is GPL |
309 | */ | 309 | */ |
310 | void TableView::paintCell(QPainter* p, int row, int col, const QRect& cr, bool ) { | 310 | void TableView::paintCell(QPainter* p, int row, int col, const QRect& cr, bool ) { |
311 | const QColorGroup &cg = colorGroup(); | 311 | const QColorGroup &cg = colorGroup(); |
312 | 312 | ||
313 | p->save(); | 313 | p->save(); |
314 | 314 | ||
315 | OTodo task = sorted()[row]; | 315 | OTodo task = sorted()[row]; |
316 | 316 | ||
317 | p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Base ) ); | 317 | p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Base ) ); |
318 | 318 | ||
319 | QPen op = p->pen(); | 319 | QPen op = p->pen(); |
320 | p->setPen(cg.mid()); | 320 | p->setPen(cg.mid()); |
321 | p->drawLine( 0, cr.height() - 1, cr.width() - 1, cr.height() - 1 ); | 321 | p->drawLine( 0, cr.height() - 1, cr.width() - 1, cr.height() - 1 ); |
322 | p->drawLine( cr.width() - 1, 0, cr.width() - 1, cr.height() - 1 ); | 322 | p->drawLine( cr.width() - 1, 0, cr.width() - 1, cr.height() - 1 ); |
323 | p->setPen(op); | 323 | p->setPen(op); |
324 | 324 | ||
325 | QFont f = p->font(); | 325 | QFont f = p->font(); |
326 | QFontMetrics fm(f); | 326 | QFontMetrics fm(f); |
327 | 327 | ||
328 | switch(col) { | 328 | switch(col) { |
329 | case 0: | 329 | case 0: |
330 | { | 330 | { |
331 | // completed field | 331 | // completed field |
332 | int marg = ( cr.width() - BoxSize ) / 2; | 332 | int marg = ( cr.width() - BoxSize ) / 2; |
333 | int x = 0; | 333 | int x = 0; |
334 | int y = ( cr.height() - BoxSize ) / 2; | 334 | int y = ( cr.height() - BoxSize ) / 2; |
335 | p->setPen( QPen( cg.text() ) ); | 335 | p->setPen( QPen( cg.text() ) ); |
336 | p->drawRect( x + marg, y, BoxSize, BoxSize ); | 336 | p->drawRect( x + marg, y, BoxSize, BoxSize ); |
337 | p->drawRect( x + marg+1, y+1, BoxSize-2, BoxSize-2 ); | 337 | p->drawRect( x + marg+1, y+1, BoxSize-2, BoxSize-2 ); |
338 | p->setPen( darkGreen ); | 338 | p->setPen( darkGreen ); |
339 | x += 1; | 339 | x += 1; |
340 | y += 1; | 340 | y += 1; |
341 | if ( task.isCompleted() ) { | 341 | if ( task.isCompleted() ) { |
342 | QPointArray a( 9*2 ); | 342 | QPointArray a( 9*2 ); |
343 | int i, xx, yy; | 343 | int i, xx, yy; |
344 | xx = x+2+marg; | 344 | xx = x+2+marg; |
345 | yy = y+4; | 345 | yy = y+4; |
346 | for ( i=0; i<4; i++ ) { | 346 | for ( i=0; i<4; i++ ) { |
347 | a.setPoint( 2*i, xx, yy ); | 347 | a.setPoint( 2*i, xx, yy ); |
348 | a.setPoint( 2*i+1, xx, yy+2 ); | 348 | a.setPoint( 2*i+1, xx, yy+2 ); |
349 | xx++; yy++; | 349 | xx++; yy++; |
350 | } | 350 | } |
351 | yy -= 2; | 351 | yy -= 2; |
352 | for ( i=4; i<9; i++ ) { | 352 | for ( i=4; i<9; i++ ) { |
353 | a.setPoint( 2*i, xx, yy ); | 353 | a.setPoint( 2*i, xx, yy ); |
354 | a.setPoint( 2*i+1, xx, yy+2 ); | 354 | a.setPoint( 2*i+1, xx, yy+2 ); |
355 | xx++; yy--; | 355 | xx++; yy--; |
356 | } | 356 | } |
357 | p->drawLineSegments( a ); | 357 | p->drawLineSegments( a ); |
358 | } | 358 | } |
359 | } | 359 | } |
360 | break; | 360 | break; |
361 | case 1: | 361 | case 1: |
362 | // priority field | 362 | // priority field |
363 | { | 363 | { |
364 | QString text = QString::number(task.priority()); | 364 | QString text = QString::number(task.priority()); |
365 | p->drawText(2,2 + fm.ascent(), text); | 365 | p->drawText(2,2 + fm.ascent(), text); |
366 | } | 366 | } |
367 | break; | 367 | break; |
368 | case 2: | 368 | case 2: |
369 | // description field | 369 | // description field |
370 | { | 370 | { |
371 | QString text = task.summary().isEmpty() ? | 371 | QString text = task.summary().isEmpty() ? |
372 | task.description().left(20) : | 372 | task.description().left(20) : |
373 | task.summary(); | 373 | task.summary(); |
374 | p->drawText(2,2 + fm.ascent(), text); | 374 | p->drawText(2,2 + fm.ascent(), text); |
375 | } | 375 | } |
376 | break; | 376 | break; |
377 | case 3: | 377 | case 3: |
378 | { | 378 | { |
379 | QString text; | 379 | QString text; |
380 | if (task.hasDueDate()) { | 380 | if (task.hasDueDate()) { |
381 | int off = QDate::currentDate().daysTo( task.dueDate() ); | 381 | int off = QDate::currentDate().daysTo( task.dueDate() ); |
382 | text = QString::number(off) + tr(" day(s)"); | 382 | text = QString::number(off) + tr(" day(s)"); |
383 | /* | 383 | /* |
384 | * set color if not completed | 384 | * set color if not completed |
385 | */ | 385 | */ |
386 | if (!task.isCompleted() ) { | 386 | if (!task.isCompleted() ) { |
387 | QColor color = Qt::black; | 387 | QColor color = Qt::black; |
388 | if ( off < 0 ) | 388 | if ( off < 0 ) |
389 | color = Qt::red; | 389 | color = Qt::red; |
390 | else if ( off == 0 ) | 390 | else if ( off == 0 ) |
391 | color = Qt::yellow; | 391 | color = Qt::yellow; |
392 | else if ( off > 0 ) | 392 | else if ( off > 0 ) |
393 | color = Qt::green; | 393 | color = Qt::green; |
394 | p->setPen(color ); | 394 | p->setPen(color ); |
395 | } | 395 | } |
396 | } else { | 396 | } else { |
397 | text = tr("None"); | 397 | text = tr("None"); |
398 | } | 398 | } |
399 | p->drawText(2,2 + fm.ascent(), text); | 399 | p->drawText(2,2 + fm.ascent(), text); |
400 | } | 400 | } |
401 | break; | 401 | break; |
402 | } | 402 | } |
403 | p->restore(); | 403 | p->restore(); |
404 | } | 404 | } |
405 | QWidget* TableView::createEditor(int row, int col, bool )const { | 405 | QWidget* TableView::createEditor(int row, int col, bool )const { |
406 | switch( col ) { | 406 | switch( col ) { |
407 | case 1: { | 407 | case 1: { |
408 | /* the priority stuff */ | 408 | /* the priority stuff */ |
409 | QComboBox* combo = new QComboBox( viewport() ); | 409 | QComboBox* combo = new QComboBox( viewport() ); |
410 | combo->insertItem( "1" ); | 410 | combo->insertItem( "1" ); |
411 | combo->insertItem( "2" ); | 411 | combo->insertItem( "2" ); |
412 | combo->insertItem( "3" ); | 412 | combo->insertItem( "3" ); |
413 | combo->insertItem( "4" ); | 413 | combo->insertItem( "4" ); |
414 | combo->insertItem( "5" ); | 414 | combo->insertItem( "5" ); |
415 | combo->setCurrentItem( sorted()[row].priority()-1 ); | 415 | combo->setCurrentItem( sorted()[row].priority()-1 ); |
416 | return combo; | 416 | return combo; |
417 | } | 417 | } |
418 | /* summary */ | 418 | /* summary */ |
419 | case 2:{ | 419 | case 2:{ |
420 | QLineEdit* edit = new QLineEdit( viewport() ); | 420 | QLineEdit* edit = new QLineEdit( viewport() ); |
421 | edit->setText( sorted()[row].summary() ); | 421 | edit->setText( sorted()[row].summary() ); |
422 | return edit; | 422 | return edit; |
423 | } | 423 | } |
424 | case 0: | 424 | case 0: |
425 | default: | 425 | default: |
426 | return 0l; | 426 | return 0l; |
427 | } | 427 | } |
428 | } | 428 | } |
429 | void TableView::setCellContentFromEditor(int row, int col ) { | 429 | void TableView::setCellContentFromEditor(int row, int col ) { |
430 | if ( col == 1 ) { | 430 | if ( col == 1 ) { |
431 | QWidget* wid = cellWidget(row, 1 ); | 431 | QWidget* wid = cellWidget(row, 1 ); |
432 | if ( wid->inherits("QComboBox") ) { | 432 | if ( wid->inherits("QComboBox") ) { |
433 | int pri = ((QComboBox*)wid)->currentItem() + 1; | 433 | int pri = ((QComboBox*)wid)->currentItem() + 1; |
434 | OTodo todo = sorted()[row]; | 434 | OTodo todo = sorted()[row]; |
435 | if ( todo.priority() != pri ) { | 435 | if ( todo.priority() != pri ) { |
436 | todo.setPriority( pri ); | 436 | todo.setPriority( pri ); |
437 | TodoView::update( todo.uid(), todo ); | 437 | TodoView::update( todo.uid(), todo ); |
438 | updateView(); | 438 | updateView(); |
439 | } | 439 | } |
440 | } | 440 | } |
441 | }else if ( col == 2) { | 441 | }else if ( col == 2) { |
442 | QWidget* wid = cellWidget(row, 2); | 442 | QWidget* wid = cellWidget(row, 2); |
443 | if ( wid->inherits("QLineEdit") ) { | 443 | if ( wid->inherits("QLineEdit") ) { |
444 | QString text = ((QLineEdit*)wid)->text(); | 444 | QString text = ((QLineEdit*)wid)->text(); |
445 | OTodo todo = sorted()[row]; | 445 | OTodo todo = sorted()[row]; |
446 | if ( todo.summary() != text ) { | 446 | if ( todo.summary() != text ) { |
447 | todo.setSummary( text ); | 447 | todo.setSummary( text ); |
448 | TodoView::update( todo.uid(), todo ); | 448 | TodoView::update( todo.uid(), todo ); |
449 | updateView(); | 449 | updateView(); |
450 | } | 450 | } |
451 | } | 451 | } |
452 | } | 452 | } |
453 | } | 453 | } |
454 | void TableView::slotPriority() { | 454 | void TableView::slotPriority() { |
455 | setCellContentFromEditor( currentRow(), currentColumn() ); | 455 | setCellContentFromEditor( currentRow(), currentColumn() ); |
456 | } | 456 | } |
457 | /* | 457 | /* |
458 | * We'll use the TimerEvent to read ahead or to keep the cahce always | 458 | * We'll use the TimerEvent to read ahead or to keep the cahce always |
459 | * filled enough. | 459 | * filled enough. |
460 | * We will try to read ahead 4 items in both ways | 460 | * We will try to read ahead 4 items in both ways |
461 | * up and down. On odd or even we will currentRow()+-4 or +-9 | 461 | * up and down. On odd or even we will currentRow()+-4 or +-9 |
462 | * | 462 | * |
463 | */ | 463 | */ |
464 | void TableView::timerEvent( QTimerEvent* ev ) { | 464 | void TableView::timerEvent( QTimerEvent* ev ) { |
465 | // qWarning("sorted %d", sorted().count() ); | 465 | // qWarning("sorted %d", sorted().count() ); |
466 | if (sorted().count() == 0 ) | 466 | if (sorted().count() == 0 ) |
467 | return; | 467 | return; |
468 | 468 | ||
469 | int row = currentRow(); | 469 | int row = currentRow(); |
470 | if ( m_row ) { | 470 | if ( m_row ) { |
471 | int ro = row-4; | 471 | int ro = row-4; |
472 | if (ro < 0 ) ro = 0; | 472 | if (ro < 0 ) ro = 0; |
473 | sorted()[ro]; | 473 | sorted()[ro]; |
474 | 474 | ||
475 | ro = row+4; | 475 | ro = row+4; |
476 | sorted()[ro]; | 476 | sorted()[ro]; |
477 | } else { | 477 | } else { |
478 | int ro = row + 8; | 478 | int ro = row + 8; |
479 | sorted()[ro]; | 479 | sorted()[ro]; |
480 | 480 | ||
481 | ro = row-8; | 481 | ro = row-8; |
482 | if (ro < 0 ) ro = 0; | 482 | if (ro < 0 ) ro = 0; |
483 | sorted()[ro]; | 483 | sorted()[ro]; |
484 | } | 484 | } |
485 | 485 | ||
486 | m_row = !m_row; | 486 | m_row = !m_row; |
487 | } | 487 | } |
488 | 488 | ||
489 | // We want a strike through completed ;) | 489 | // We want a strike through completed ;) |
490 | // durchstreichen to complete | 490 | // durchstreichen to complete |
491 | /* | 491 | /* |
492 | * MouseTracking is off this mean we only receive | 492 | * MouseTracking is off this mean we only receive |
493 | * these events if the mouse button is pressed | 493 | * these events if the mouse button is pressed |
494 | * We've the previous point saved | 494 | * We've the previous point saved |
495 | * We check if the previous and current Point are | 495 | * We check if the previous and current Point are |
496 | * in the same row. | 496 | * in the same row. |
497 | * Then we check if they're some pixel horizontal away | 497 | * Then we check if they're some pixel horizontal away |
498 | * if the distance between the two points is greater than | 498 | * if the distance between the two points is greater than |
499 | * 8 we mark the underlying todo as completed and do a repaint | 499 | * 8 we mark the underlying todo as completed and do a repaint |
500 | * | 500 | * |
501 | * BUG: When clicking on the Due column and it's scrollable | 501 | * BUG: When clicking on the Due column and it's scrollable |
502 | * the todo is marked as completed... | 502 | * the todo is marked as completed... |
503 | * REASON: QTable is doing auto scrolling which leads to a move | 503 | * REASON: QTable is doing auto scrolling which leads to a move |
504 | * in the x coordinate and this way it's able to pass the | 504 | * in the x coordinate and this way it's able to pass the |
505 | * m_completeStrokeWidth criteria | 505 | * m_completeStrokeWidth criteria |
506 | * WORKAROUND: strike through needs to strike through the same | 506 | * WORKAROUND: strike through needs to strike through the same |
507 | * row and two columns! | 507 | * row and two columns! |
508 | */ | 508 | */ |
509 | void TableView::contentsMouseReleaseEvent( QMouseEvent* e) { | 509 | void TableView::contentsMouseReleaseEvent( QMouseEvent* e) { |
510 | int row = rowAt(m_prevP.y()); | 510 | int row = rowAt(m_prevP.y()); |
511 | int colOld = columnAt(m_prevP.x() ); | 511 | int colOld = columnAt(m_prevP.x() ); |
512 | int colNew = columnAt(e->x() ); | 512 | int colNew = columnAt(e->x() ); |
513 | qWarning("colNew: %d colOld: %d", colNew, colOld ); | 513 | qWarning("colNew: %d colOld: %d", colNew, colOld ); |
514 | if ( row == rowAt( e->y() ) && row != -1 && | 514 | if ( row == rowAt( e->y() ) && row != -1 && |
515 | colOld != colNew ) { | 515 | colOld != colNew ) { |
516 | TodoView::complete( sorted()[row] ); | 516 | TodoView::complete( sorted()[row] ); |
517 | return; | 517 | return; |
518 | } | 518 | } |
519 | QTable::contentsMouseReleaseEvent( e ); | 519 | QTable::contentsMouseReleaseEvent( e ); |
520 | } | 520 | } |
521 | void TableView::contentsMouseMoveEvent( QMouseEvent* e ) { | 521 | void TableView::contentsMouseMoveEvent( QMouseEvent* e ) { |
522 | m_menuTimer->stop(); | 522 | m_menuTimer->stop(); |
523 | QTable::contentsMouseMoveEvent( e ); | 523 | QTable::contentsMouseMoveEvent( e ); |
524 | } | 524 | } |
diff --git a/core/pim/todo/todoeditor.cpp b/core/pim/todo/todoeditor.cpp index 9b8c5cb..5aa7097 100644 --- a/core/pim/todo/todoeditor.cpp +++ b/core/pim/todo/todoeditor.cpp | |||
@@ -1,67 +1,67 @@ | |||
1 | 1 | ||
2 | #include "otaskeditor.h" | 2 | #include "otaskeditor.h" |
3 | #include "todoeditor.h" | 3 | #include "todoeditor.h" |
4 | 4 | ||
5 | using namespace Todo; | 5 | using namespace Todo; |
6 | 6 | ||
7 | Editor::Editor() { | 7 | Editor::Editor() { |
8 | m_accepted = false; | 8 | m_accepted = false; |
9 | m_self = 0l; | 9 | m_self = 0l; |
10 | } | 10 | } |
11 | Editor::~Editor() { | 11 | Editor::~Editor() { |
12 | delete m_self; | 12 | delete m_self; |
13 | m_self = 0; | 13 | m_self = 0; |
14 | } | 14 | } |
15 | OTodo Editor::newTodo( int cur, | 15 | OTodo Editor::newTodo( int cur, |
16 | QWidget*) { | 16 | QWidget*) { |
17 | 17 | ||
18 | OTaskEditor *e = self(); | 18 | OTaskEditor *e = self(); |
19 | e->setCaption( QObject::tr("Enter Task") ); | 19 | e->setCaption( QObject::tr("Enter Task") ); |
20 | e->init( cur ); | 20 | e->init( cur ); |
21 | 21 | ||
22 | 22 | ||
23 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 23 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
24 | e->showMaximized(); | 24 | e->showMaximized(); |
25 | #endif | 25 | #endif |
26 | 26 | ||
27 | int ret = e->exec(); | 27 | int ret = e->exec(); |
28 | if ( QDialog::Accepted == ret ) { | 28 | if ( QDialog::Accepted == ret ) { |
29 | m_accepted = true; | 29 | m_accepted = true; |
30 | }else | 30 | }else |
31 | m_accepted = false; | 31 | m_accepted = false; |
32 | 32 | ||
33 | OTodo ev = e->todo(); | 33 | OTodo ev = e->todo(); |
34 | qWarning("Todo uid"); | 34 | qWarning("Todo uid"); |
35 | qWarning("Todo %s %d %d", ev.summary().latin1(), ev.progress(), ev.isCompleted() ); | 35 | qWarning("Todo %s %d %d", ev.summary().latin1(), ev.progress(), ev.isCompleted() ); |
36 | ev.setUid(1); | 36 | ev.setUid(1); |
37 | 37 | ||
38 | return ev; | 38 | return ev; |
39 | } | 39 | } |
40 | OTodo Editor::edit( QWidget *wid, | 40 | OTodo Editor::edit( QWidget *, |
41 | const OTodo& todo ) { | 41 | const OTodo& todo ) { |
42 | OTaskEditor *e = self(); | 42 | OTaskEditor *e = self(); |
43 | e->init( todo ); | 43 | e->init( todo ); |
44 | e->setCaption( QObject::tr( "Edit Task" ) ); | 44 | e->setCaption( QObject::tr( "Edit Task" ) ); |
45 | 45 | ||
46 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 46 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
47 | e->showMaximized(); | 47 | e->showMaximized(); |
48 | #endif | 48 | #endif |
49 | int ret = e->exec(); | 49 | int ret = e->exec(); |
50 | 50 | ||
51 | OTodo ev = e->todo(); | 51 | OTodo ev = e->todo(); |
52 | if ( ret == QDialog::Accepted ) | 52 | if ( ret == QDialog::Accepted ) |
53 | m_accepted = true; | 53 | m_accepted = true; |
54 | else | 54 | else |
55 | m_accepted = false; | 55 | m_accepted = false; |
56 | 56 | ||
57 | return ev; | 57 | return ev; |
58 | } | 58 | } |
59 | bool Editor::accepted()const { | 59 | bool Editor::accepted()const { |
60 | return m_accepted; | 60 | return m_accepted; |
61 | } | 61 | } |
62 | OTaskEditor* Editor::self() { | 62 | OTaskEditor* Editor::self() { |
63 | if (!m_self ) | 63 | if (!m_self ) |
64 | m_self = new OTaskEditor(0); | 64 | m_self = new OTaskEditor(0); |
65 | 65 | ||
66 | return m_self; | 66 | return m_self; |
67 | } | 67 | } |