author | zecke <zecke> | 2002-10-07 14:39:07 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-10-07 14:39:07 (UTC) |
commit | a7b03f9c31f515747663f07b6665744369e57ba8 (patch) (unidiff) | |
tree | 3799a9001d60eac5d8212596c6ce012082d42cf6 | |
parent | add436706a938a71a487db019dcd6ff236207bfc (diff) | |
download | opie-a7b03f9c31f515747663f07b6665744369e57ba8.zip opie-a7b03f9c31f515747663f07b6665744369e57ba8.tar.gz opie-a7b03f9c31f515747663f07b6665744369e57ba8.tar.bz2 |
TodoView is a mess because I tried hard to make
it work with templates... I've to clean this up
Then I made the way free to use sorted
my next step is to make the paint hack work
-rw-r--r-- | core/pim/todo/mainwindow.cpp | 32 | ||||
-rw-r--r-- | core/pim/todo/mainwindow.h | 6 | ||||
-rw-r--r-- | core/pim/todo/tableview.cpp | 16 | ||||
-rw-r--r-- | core/pim/todo/tableview.h | 3 | ||||
-rw-r--r-- | core/pim/todo/todomanager.cpp | 11 | ||||
-rw-r--r-- | core/pim/todo/todomanager.h | 5 | ||||
-rw-r--r-- | core/pim/todo/todoview.cpp | 25 | ||||
-rw-r--r-- | core/pim/todo/todoview.h | 18 |
8 files changed, 78 insertions, 38 deletions
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp index a8f4c9c..47c0160 100644 --- a/core/pim/todo/mainwindow.cpp +++ b/core/pim/todo/mainwindow.cpp | |||
@@ -1,621 +1,637 @@ | |||
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 <qmenubar.h> | 29 | #include <qmenubar.h> |
30 | #include <qmessagebox.h> | 30 | #include <qmessagebox.h> |
31 | #include <qtoolbar.h> | 31 | #include <qtoolbar.h> |
32 | #include <qpopupmenu.h> | 32 | #include <qpopupmenu.h> |
33 | #include <qwidgetstack.h> | 33 | #include <qwidgetstack.h> |
34 | #include <qaction.h> | 34 | #include <qaction.h> |
35 | #include <qtimer.h> | 35 | #include <qtimer.h> |
36 | 36 | ||
37 | #include <qpe/config.h> | 37 | #include <qpe/config.h> |
38 | #include <qpe/ir.h> | 38 | #include <qpe/ir.h> |
39 | #include <qpe/resource.h> | 39 | #include <qpe/resource.h> |
40 | #include <qpe/qpemessagebox.h> | 40 | #include <qpe/qpemessagebox.h> |
41 | 41 | ||
42 | 42 | ||
43 | #include "todotemplatemanager.h" | 43 | #include "todotemplatemanager.h" |
44 | #include "templateeditor.h" | 44 | #include "templateeditor.h" |
45 | #include "todoentryimpl.h" | 45 | #include "todoentryimpl.h" |
46 | #include "tableview.h" | 46 | #include "tableview.h" |
47 | 47 | ||
48 | #include "textviewshow.h" | 48 | #include "textviewshow.h" |
49 | #include "todoeditor.h" | 49 | #include "todoeditor.h" |
50 | #include "mainwindow.h" | 50 | #include "mainwindow.h" |
51 | 51 | ||
52 | 52 | ||
53 | using namespace Todo; | 53 | using namespace Todo; |
54 | 54 | ||
55 | MainWindow::MainWindow( QWidget* parent, | 55 | MainWindow::MainWindow( QWidget* parent, |
56 | const char* name ) { | 56 | const char* name ) { |
57 | 57 | ||
58 | m_syncing = false; | 58 | m_syncing = false; |
59 | m_counter = 0; | 59 | m_counter = 0; |
60 | m_tempManager = new TemplateManager(); | 60 | m_tempManager = new TemplateManager(); |
61 | m_tempManager->load(); | 61 | m_tempManager->load(); |
62 | 62 | ||
63 | initUI(); | 63 | initUI(); |
64 | initConfig(); | 64 | initConfig(); |
65 | initViews(); | 65 | initViews(); |
66 | initActions(); | 66 | initActions(); |
67 | initEditor(); | 67 | initEditor(); |
68 | initShow(); | 68 | initShow(); |
69 | initTemplate(); | 69 | initTemplate(); |
70 | 70 | ||
71 | populateTemplates(); | 71 | populateTemplates(); |
72 | raiseCurrentView(); | 72 | raiseCurrentView(); |
73 | QTimer::singleShot(0, this, SLOT(populateCategories() ) ); | 73 | QTimer::singleShot(0, this, SLOT(populateCategories() ) ); |
74 | } | 74 | } |
75 | void MainWindow::initTemplate() { | 75 | void MainWindow::initTemplate() { |
76 | m_curTempEd = new TemplateEditor( this, templateManager() ); | 76 | m_curTempEd = new TemplateEditor( this, templateManager() ); |
77 | } | 77 | } |
78 | void MainWindow::initActions() { | 78 | void MainWindow::initActions() { |
79 | QAction* a = new QAction( tr("New Task" ), Resource::loadPixmap( "new" ), | 79 | QAction* a = new QAction( tr("New Task" ), Resource::loadPixmap( "new" ), |
80 | QString::null, 0, this, 0 ); | 80 | QString::null, 0, this, 0 ); |
81 | connect(a, SIGNAL( activated() ), | 81 | connect(a, SIGNAL( activated() ), |
82 | this, SLOT( slotNew() ) ); | 82 | this, SLOT( slotNew() ) ); |
83 | a->addTo(m_tool ); | 83 | a->addTo(m_tool ); |
84 | a->addTo(m_edit ); | 84 | a->addTo(m_edit ); |
85 | 85 | ||
86 | a = new QAction( tr("Edit Task"), Resource::loadIconSet( "edit" ), | 86 | a = new QAction( tr("Edit Task"), Resource::loadIconSet( "edit" ), |
87 | QString::null, 0, this, 0 ); | 87 | QString::null, 0, this, 0 ); |
88 | connect(a, SIGNAL(activated() ), | 88 | connect(a, SIGNAL(activated() ), |
89 | this, SLOT( slotEdit() ) ); | 89 | this, SLOT( slotEdit() ) ); |
90 | a->addTo( m_tool ); | 90 | a->addTo( m_tool ); |
91 | a->addTo( m_edit ); | 91 | a->addTo( m_edit ); |
92 | m_editAction = a; | 92 | m_editAction = a; |
93 | 93 | ||
94 | a = new QAction( QString::null, tr("View Task"), 0, this, 0 ); | 94 | a = new QAction( QString::null, tr("View Task"), 0, this, 0 ); |
95 | connect(a, SIGNAL( activated() ), | 95 | connect(a, SIGNAL( activated() ), |
96 | this, SLOT( slotShowDetails() ) ); | 96 | this, SLOT( slotShowDetails() ) ); |
97 | a->addTo( m_edit ); | 97 | a->addTo( m_edit ); |
98 | 98 | ||
99 | m_edit->insertSeparator(); | 99 | m_edit->insertSeparator(); |
100 | 100 | ||
101 | a = new QAction( tr("Delete..."), Resource::loadIconSet( "trash" ), | 101 | a = new QAction( tr("Delete..."), Resource::loadIconSet( "trash" ), |
102 | QString::null, 0, this, 0 ); | 102 | QString::null, 0, this, 0 ); |
103 | connect(a, SIGNAL(activated() ), | 103 | connect(a, SIGNAL(activated() ), |
104 | this, SLOT(slotDelete() ) ); | 104 | this, SLOT(slotDelete() ) ); |
105 | a->addTo( m_tool ); | 105 | a->addTo( m_tool ); |
106 | a->addTo( m_edit ); | 106 | a->addTo( m_edit ); |
107 | m_deleteAction = a; | 107 | m_deleteAction = a; |
108 | 108 | ||
109 | a = new QAction( QString::null, tr("Delete all..."), 0, this, 0 ); | 109 | a = new QAction( QString::null, tr("Delete all..."), 0, this, 0 ); |
110 | connect(a, SIGNAL( activated() ), | 110 | connect(a, SIGNAL( activated() ), |
111 | this, SLOT( slotDeleteAll() ) ); | 111 | this, SLOT( slotDeleteAll() ) ); |
112 | a->addTo(m_edit ); | 112 | a->addTo(m_edit ); |
113 | m_deleteAllAction = a; | 113 | m_deleteAllAction = a; |
114 | 114 | ||
115 | a = new QAction( QString::null, tr("Delete completed"), | 115 | a = new QAction( QString::null, tr("Delete completed"), |
116 | 0, this, 0 ); | 116 | 0, this, 0 ); |
117 | connect(a, SIGNAL( activated() ), | 117 | connect(a, SIGNAL( activated() ), |
118 | this, SLOT( slotDeleteCompleted() ) ); | 118 | this, SLOT( slotDeleteCompleted() ) ); |
119 | a->addTo(m_edit ); | 119 | a->addTo(m_edit ); |
120 | a->setEnabled( TRUE ); | 120 | a->setEnabled( TRUE ); |
121 | m_deleteCompleteAction = a; | 121 | m_deleteCompleteAction = a; |
122 | 122 | ||
123 | m_edit->insertSeparator(); | 123 | m_edit->insertSeparator(); |
124 | 124 | ||
125 | a = new QAction( QString::null, tr("Duplicate"), 0, this, 0 ); | 125 | a = new QAction( QString::null, tr("Duplicate"), 0, this, 0 ); |
126 | connect(a, SIGNAL( activated() ), | 126 | connect(a, SIGNAL( activated() ), |
127 | this, SLOT( slotDuplicate() ) ); | 127 | this, SLOT( slotDuplicate() ) ); |
128 | a->addTo(m_edit ); | 128 | a->addTo(m_edit ); |
129 | m_duplicateAction = a; | 129 | m_duplicateAction = a; |
130 | 130 | ||
131 | m_edit->insertSeparator(); | 131 | m_edit->insertSeparator(); |
132 | 132 | ||
133 | if ( Ir::supported() ) { | 133 | if ( Ir::supported() ) { |
134 | a = new QAction( tr( "Beam" ), Resource::loadPixmap( "beam" ), | 134 | a = new QAction( tr( "Beam" ), Resource::loadPixmap( "beam" ), |
135 | QString::null, 0, this, 0 ); | 135 | QString::null, 0, this, 0 ); |
136 | connect( a, SIGNAL( activated() ), | 136 | connect( a, SIGNAL( activated() ), |
137 | this, SLOT( slotBeam() ) ); | 137 | this, SLOT( slotBeam() ) ); |
138 | a->addTo( m_edit ); | 138 | a->addTo( m_edit ); |
139 | a->addTo( m_tool ); | 139 | a->addTo( m_tool ); |
140 | } | 140 | } |
141 | 141 | ||
142 | a = new QAction( tr("Find"), Resource::loadIconSet( "mag" ), | 142 | a = new QAction( tr("Find"), Resource::loadIconSet( "mag" ), |
143 | QString::null, 0, this, 0 ); | 143 | QString::null, 0, this, 0 ); |
144 | connect(a, SIGNAL( activated() ), | 144 | connect(a, SIGNAL( activated() ), |
145 | this, SLOT( slotFind() ) ); | 145 | this, SLOT( slotFind() ) ); |
146 | a->addTo( m_options ); | 146 | a->addTo( m_options ); |
147 | m_findAction = a; | 147 | m_findAction = a; |
148 | 148 | ||
149 | m_options->insertSeparator(); | 149 | m_options->insertSeparator(); |
150 | 150 | ||
151 | m_completedAction = new QAction( QString::null, tr("Completed tasks"), | 151 | m_completedAction = new QAction( QString::null, tr("Completed tasks"), |
152 | 0, this, 0, TRUE ); | 152 | 0, this, 0, TRUE ); |
153 | m_completedAction->addTo( m_options ); | 153 | m_completedAction->addTo( m_options ); |
154 | m_completedAction->setOn( showCompleted() ); | 154 | m_completedAction->setOn( showCompleted() ); |
155 | connect(m_completedAction, SIGNAL( toggled(bool) ), | 155 | connect(m_completedAction, SIGNAL( toggled(bool) ), |
156 | this, SLOT(slotShowCompleted(bool) ) ); | 156 | this, SLOT(slotShowCompleted(bool) ) ); |
157 | 157 | ||
158 | m_showDeadLineAction = new QAction( QString::null, tr("Show Deadline"), | 158 | m_showDeadLineAction = new QAction( QString::null, tr("Show Deadline"), |
159 | 0, this, 0, TRUE ); | 159 | 0, this, 0, TRUE ); |
160 | m_showDeadLineAction->addTo( m_options ); | 160 | m_showDeadLineAction->addTo( m_options ); |
161 | m_showDeadLineAction->setOn( showDeadline() ); | 161 | m_showDeadLineAction->setOn( showDeadline() ); |
162 | connect(m_showDeadLineAction, SIGNAL(toggled(bool) ), | 162 | connect(m_showDeadLineAction, SIGNAL(toggled(bool) ), |
163 | this, SLOT( slotShowDeadLine( bool ) ) ); | 163 | this, SLOT( slotShowDeadLine( bool ) ) ); |
164 | 164 | ||
165 | m_options->insertSeparator(); | 165 | m_options->insertSeparator(); |
166 | 166 | ||
167 | m_bar->insertItem( tr("Data") ,m_edit ); | 167 | m_bar->insertItem( tr("Data") ,m_edit ); |
168 | m_bar->insertItem( tr("Category"), m_catMenu ); | 168 | m_bar->insertItem( tr("Category"), m_catMenu ); |
169 | m_bar->insertItem( tr("Options"), m_options ); | 169 | m_bar->insertItem( tr("Options"), m_options ); |
170 | 170 | ||
171 | /* initialize the view menu */ | 171 | /* initialize the view menu */ |
172 | a = new QAction( QString::null, tr("Show over due"), | 172 | a = new QAction( QString::null, tr("Show over due"), |
173 | 0, this, 0, TRUE ); | 173 | 0, this, 0, TRUE ); |
174 | a->addTo( m_view ); | 174 | a->addTo( m_view ); |
175 | a->setOn( showOverDue() ); | 175 | a->setOn( showOverDue() ); |
176 | connect(a, SIGNAL(toggled(bool)), | 176 | connect(a, SIGNAL(toggled(bool)), |
177 | this, SLOT(slotShowDue(bool) ) ); | 177 | this, SLOT(slotShowDue(bool) ) ); |
178 | m_view->insertSeparator(); | 178 | m_view->insertSeparator(); |
179 | 179 | ||
180 | m_bar->insertItem( tr("View"), m_view ); | 180 | m_bar->insertItem( tr("View"), m_view ); |
181 | 181 | ||
182 | /* templates */ | 182 | /* templates */ |
183 | m_edit->insertItem(tr("New from template"), m_template, | 183 | m_edit->insertItem(tr("New from template"), m_template, |
184 | -1, 0 ); | 184 | -1, 0 ); |
185 | 185 | ||
186 | } | 186 | } |
187 | /* m_curCat from Config */ | 187 | /* m_curCat from Config */ |
188 | void MainWindow::initConfig() { | 188 | void MainWindow::initConfig() { |
189 | Config config( "todo" ); | 189 | Config config( "todo" ); |
190 | config.setGroup( "View" ); | 190 | config.setGroup( "View" ); |
191 | m_completed = config.readBoolEntry( "ShowComplete", TRUE ); | 191 | m_completed = config.readBoolEntry( "ShowComplete", TRUE ); |
192 | m_curCat = config.readEntry( "Category", QString::null ); | 192 | m_curCat = config.readEntry( "Category", QString::null ); |
193 | m_deadline = config.readBoolEntry( "ShowDeadLine", TRUE); | 193 | m_deadline = config.readBoolEntry( "ShowDeadLine", TRUE); |
194 | m_overdue = config.readBoolEntry("ShowOverDue", TRUE ); | 194 | m_overdue = config.readBoolEntry("ShowOverDue", TRUE ); |
195 | } | 195 | } |
196 | void MainWindow::initUI() { | 196 | void MainWindow::initUI() { |
197 | m_stack = new QWidgetStack(this, "main stack"); | 197 | m_stack = new QWidgetStack(this, "main stack"); |
198 | setCentralWidget( m_stack ); | 198 | setCentralWidget( m_stack ); |
199 | 199 | ||
200 | setToolBarsMovable( FALSE ); | 200 | setToolBarsMovable( FALSE ); |
201 | 201 | ||
202 | m_tool = new QToolBar( this ); | 202 | m_tool = new QToolBar( this ); |
203 | m_tool->setHorizontalStretchable( TRUE ); | 203 | m_tool->setHorizontalStretchable( TRUE ); |
204 | 204 | ||
205 | m_bar = new QMenuBar( m_tool ); | 205 | m_bar = new QMenuBar( m_tool ); |
206 | 206 | ||
207 | /** QPopupMenu */ | 207 | /** QPopupMenu */ |
208 | m_edit = new QPopupMenu( this ); | 208 | m_edit = new QPopupMenu( this ); |
209 | m_options = new QPopupMenu( this ); | 209 | m_options = new QPopupMenu( this ); |
210 | m_view = new QPopupMenu( this ); | 210 | m_view = new QPopupMenu( this ); |
211 | m_catMenu = new QPopupMenu( this ); | 211 | m_catMenu = new QPopupMenu( this ); |
212 | m_template = new QPopupMenu( this ); | 212 | m_template = new QPopupMenu( this ); |
213 | 213 | ||
214 | m_catMenu->setCheckable( TRUE ); | 214 | m_catMenu->setCheckable( TRUE ); |
215 | m_template->setCheckable( TRUE ); | 215 | m_template->setCheckable( TRUE ); |
216 | 216 | ||
217 | connect(m_catMenu, SIGNAL(activated(int) ), | 217 | connect(m_catMenu, SIGNAL(activated(int) ), |
218 | this, SLOT(setCategory(int) ) ); | 218 | this, SLOT(setCategory(int) ) ); |
219 | connect(m_template, SIGNAL(activated(int) ), | 219 | connect(m_template, SIGNAL(activated(int) ), |
220 | this, SLOT(slotNewFromTemplate(int) ) ); | 220 | this, SLOT(slotNewFromTemplate(int) ) ); |
221 | } | 221 | } |
222 | void MainWindow::initViews() { | 222 | void MainWindow::initViews() { |
223 | TableView* tableView = new TableView( this, this ); | 223 | TableView* tableView = new TableView( this, this ); |
224 | m_stack->addWidget( tableView, m_counter++ ); | 224 | m_stack->addWidget( tableView, m_counter++ ); |
225 | m_views.append( tableView ); | 225 | m_views.append( tableView ); |
226 | m_curView = tableView; | 226 | m_curView = tableView; |
227 | connectBase( tableView ); | 227 | connectBase( tableView ); |
228 | // tableView->setTodos( begin(), end() ); we call populateCategories | ||
229 | |||
230 | /* add QString type + QString configname to | 228 | /* add QString type + QString configname to |
231 | * the View menu | 229 | * the View menu |
232 | * and subdirs for multiple views | 230 | * and subdirs for multiple views |
233 | */ | 231 | */ |
234 | } | 232 | } |
235 | void MainWindow::initEditor() { | 233 | void MainWindow::initEditor() { |
236 | m_curEdit = new Editor(); | 234 | m_curEdit = new Editor(); |
237 | } | 235 | } |
238 | void MainWindow::initShow() { | 236 | void MainWindow::initShow() { |
239 | m_curShow = new TextViewShow(this); | 237 | m_curShow = new TextViewShow(this); |
240 | m_stack->addWidget( m_curShow->widget() , m_counter++ ); | 238 | m_stack->addWidget( m_curShow->widget() , m_counter++ ); |
241 | } | 239 | } |
242 | MainWindow::~MainWindow() { | 240 | MainWindow::~MainWindow() { |
243 | delete templateManager(); | 241 | delete templateManager(); |
244 | } | 242 | } |
245 | void MainWindow::connectBase( ViewBase* base) { | 243 | void MainWindow::connectBase( ViewBase* base) { |
246 | base->connectShow( this, SLOT(slotShow(int) ) ); | 244 | base->connectShow( this, SLOT(slotShow(int) ) ); |
247 | base->connectEdit( this, SLOT(slotEdit(int) ) ); | 245 | base->connectEdit( this, SLOT(slotEdit(int) ) ); |
248 | base->connectUpdateSmall( this, | 246 | base->connectUpdateSmall( this, |
249 | SLOT(slotUpate1(int, const Todo::SmallTodo&) )); | 247 | SLOT(slotUpate1(int, const Todo::SmallTodo&) )); |
250 | base->connectUpdateBig( this, | 248 | base->connectUpdateBig( this, |
251 | SLOT(slotUpate2(int, const OTodo& ) ) ); | 249 | SLOT(slotUpate2(int, const OTodo& ) ) ); |
252 | base->connectUpdateView( this, SLOT(slotUpdate3( QWidget* ) ) ) ; | 250 | base->connectUpdateView( this, SLOT(slotUpdate3( QWidget* ) ) ) ; |
253 | base->connectRemove(&m_todoMgr, | 251 | base->connectRemove(&m_todoMgr, |
254 | SLOT(remove(int)) ); | 252 | SLOT(remove(int)) ); |
255 | } | 253 | } |
256 | QPopupMenu* MainWindow::contextMenu( int uid ) { | 254 | QPopupMenu* MainWindow::contextMenu( int uid ) { |
257 | QPopupMenu* menu = new QPopupMenu(); | 255 | QPopupMenu* menu = new QPopupMenu(); |
258 | 256 | ||
259 | m_editAction->addTo( menu ); | 257 | m_editAction->addTo( menu ); |
260 | m_deleteAction->addTo( menu ); | 258 | m_deleteAction->addTo( menu ); |
261 | m_duplicateAction->addTo( menu ); | 259 | m_duplicateAction->addTo( menu ); |
262 | menu->insertSeparator(); | 260 | menu->insertSeparator(); |
263 | 261 | ||
264 | return menu; | 262 | return menu; |
265 | } | 263 | } |
266 | QPopupMenu* MainWindow::options() { | 264 | QPopupMenu* MainWindow::options() { |
267 | qWarning("Options"); | 265 | qWarning("Options"); |
268 | return m_options; | 266 | return m_options; |
269 | } | 267 | } |
270 | QPopupMenu* MainWindow::edit() { | 268 | QPopupMenu* MainWindow::edit() { |
271 | return m_edit; | 269 | return m_edit; |
272 | } | 270 | } |
273 | QPopupMenu* MainWindow::view() { | 271 | QPopupMenu* MainWindow::view() { |
274 | return m_view; | 272 | return m_view; |
275 | } | 273 | } |
276 | QToolBar* MainWindow::toolbar() { | 274 | QToolBar* MainWindow::toolbar() { |
277 | return m_tool; | 275 | return m_tool; |
278 | } | 276 | } |
279 | OTodoAccess::List::Iterator MainWindow::begin() { | 277 | OTodoAccess::List MainWindow::list()const { |
280 | return m_todoMgr.begin(); | 278 | return m_todoMgr.list(); |
279 | } | ||
280 | OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder ) { | ||
281 | int cat = 0; | ||
282 | if ( m_curCat == tr("All Categories") ) | ||
283 | cat = currentCatId(); | ||
284 | |||
285 | int filter = 1; | ||
286 | |||
287 | if (!m_completed ) | ||
288 | filter |= 4; | ||
289 | if (m_overdue) | ||
290 | filter |= 2; | ||
291 | |||
292 | return m_todoMgr.sorted( asc, sortOrder, filter, cat ); | ||
281 | } | 293 | } |
282 | OTodoAccess::List::Iterator MainWindow::end() { | 294 | OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder, int addFilter) { |
283 | return m_todoMgr.end(); | 295 | int cat = 0; |
296 | if ( m_curCat == tr("All Categories") ) | ||
297 | cat = currentCatId(); | ||
298 | |||
299 | return m_todoMgr.sorted(asc, sortOrder, addFilter, cat ); | ||
284 | } | 300 | } |
285 | OTodo MainWindow::event( int uid ) { | 301 | OTodo MainWindow::event( int uid ) { |
286 | return m_todoMgr.event( uid ); | 302 | return m_todoMgr.event( uid ); |
287 | } | 303 | } |
288 | bool MainWindow::isSyncing()const { | 304 | bool MainWindow::isSyncing()const { |
289 | return m_syncing; | 305 | return m_syncing; |
290 | } | 306 | } |
291 | TemplateManager* MainWindow::templateManager() { | 307 | TemplateManager* MainWindow::templateManager() { |
292 | return m_tempManager; | 308 | return m_tempManager; |
293 | } | 309 | } |
294 | Editor* MainWindow::currentEditor() { | 310 | Editor* MainWindow::currentEditor() { |
295 | return m_curEdit; | 311 | return m_curEdit; |
296 | } | 312 | } |
297 | TodoShow* MainWindow::currentShow() { | 313 | TodoShow* MainWindow::currentShow() { |
298 | return m_curShow; | 314 | return m_curShow; |
299 | } | 315 | } |
300 | void MainWindow::slotReload() { | 316 | void MainWindow::slotReload() { |
301 | m_todoMgr.reload(); | 317 | m_todoMgr.reload(); |
302 | currentView()->setTodos( begin(), end() ); | 318 | currentView()->updateView( ); |
303 | raiseCurrentView(); | 319 | raiseCurrentView(); |
304 | } | 320 | } |
305 | void MainWindow::closeEvent( QCloseEvent* e ) { | 321 | void MainWindow::closeEvent( QCloseEvent* e ) { |
306 | if (m_stack->visibleWidget() == currentShow()->widget() ) { | 322 | if (m_stack->visibleWidget() == currentShow()->widget() ) { |
307 | raiseCurrentView(); | 323 | raiseCurrentView(); |
308 | e->ignore(); | 324 | e->ignore(); |
309 | return; | 325 | return; |
310 | } | 326 | } |
311 | /* | 327 | /* |
312 | * we should have flushed and now we're still saving | 328 | * we should have flushed and now we're still saving |
313 | * so there is no need to flush | 329 | * so there is no need to flush |
314 | */ | 330 | */ |
315 | if (m_syncing ) { | 331 | if (m_syncing ) { |
316 | e->accept(); | 332 | e->accept(); |
317 | return; | 333 | return; |
318 | } | 334 | } |
319 | bool quit = false; | 335 | bool quit = false; |
320 | if ( m_todoMgr.saveAll() ){ | 336 | if ( m_todoMgr.saveAll() ){ |
321 | qWarning("saved"); | 337 | qWarning("saved"); |
322 | quit = true; | 338 | quit = true; |
323 | }else { | 339 | }else { |
324 | if ( QMessageBox::critical( this, tr("Out of space"), | 340 | if ( QMessageBox::critical( this, tr("Out of space"), |
325 | tr("Todo was unable\n" | 341 | tr("Todo was unable\n" |
326 | "to save your changes.\n" | 342 | "to save your changes.\n" |
327 | "Free up some space\n" | 343 | "Free up some space\n" |
328 | "and try again.\n" | 344 | "and try again.\n" |
329 | "\nQuit Anyway?"), | 345 | "\nQuit Anyway?"), |
330 | QMessageBox::Yes|QMessageBox::Escape, | 346 | QMessageBox::Yes|QMessageBox::Escape, |
331 | QMessageBox::No|QMessageBox::Default) | 347 | QMessageBox::No|QMessageBox::Default) |
332 | != QMessageBox::No ) { | 348 | != QMessageBox::No ) { |
333 | e->accept(); | 349 | e->accept(); |
334 | quit = true; | 350 | quit = true; |
335 | }else | 351 | }else |
336 | e->ignore(); | 352 | e->ignore(); |
337 | 353 | ||
338 | } | 354 | } |
339 | 355 | ||
340 | if (quit ) { | 356 | if (quit ) { |
341 | Config config( "todo" ); | 357 | Config config( "todo" ); |
342 | config.setGroup( "View" ); | 358 | config.setGroup( "View" ); |
343 | config.writeEntry( "ShowComplete", showCompleted() ); | 359 | config.writeEntry( "ShowComplete", showCompleted() ); |
344 | config.writeEntry( "Category", currentCategory() ); | 360 | config.writeEntry( "Category", currentCategory() ); |
345 | config.writeEntry( "ShowDeadLine", showDeadline()); | 361 | config.writeEntry( "ShowDeadLine", showDeadline()); |
346 | config.writeEntry( "ShowOverDue", showOverDue() ); | 362 | config.writeEntry( "ShowOverDue", showOverDue() ); |
347 | /* svae templates */ | 363 | /* svae templates */ |
348 | templateManager()->save(); | 364 | templateManager()->save(); |
349 | e->accept(); | 365 | e->accept(); |
350 | } | 366 | } |
351 | } | 367 | } |
352 | void MainWindow::populateTemplates() { | 368 | void MainWindow::populateTemplates() { |
353 | m_template->clear(); | 369 | m_template->clear(); |
354 | QStringList list = templateManager()->templates(); | 370 | QStringList list = templateManager()->templates(); |
355 | QStringList::Iterator it; | 371 | QStringList::Iterator it; |
356 | for ( it = list.begin(); it != list.end(); ++it ) { | 372 | for ( it = list.begin(); it != list.end(); ++it ) { |
357 | m_template->insertItem( (*it) ); | 373 | m_template->insertItem( (*it) ); |
358 | } | 374 | } |
359 | } | 375 | } |
360 | /* | 376 | /* |
361 | * slotNewFromTemplate | 377 | * slotNewFromTemplate |
362 | * We use the edit widget to do | 378 | * We use the edit widget to do |
363 | * the config but we setUid(-1) | 379 | * the config but we setUid(-1) |
364 | * to get a new uid | 380 | * to get a new uid |
365 | */ | 381 | */ |
366 | /* | 382 | /* |
367 | * first we get the name of the template | 383 | * first we get the name of the template |
368 | * then we will use the TemplateManager | 384 | * then we will use the TemplateManager |
369 | */ | 385 | */ |
370 | void MainWindow::slotNewFromTemplate( int id ) { | 386 | void MainWindow::slotNewFromTemplate( int id ) { |
371 | QString name = m_template->text( id ); | 387 | QString name = m_template->text( id ); |
372 | 388 | ||
373 | OTodo event = templateManager()->templateEvent( name ); | 389 | OTodo event = templateManager()->templateEvent( name ); |
374 | event = currentEditor()->edit(this, | 390 | event = currentEditor()->edit(this, |
375 | event ); | 391 | event ); |
376 | 392 | ||
377 | if ( currentEditor()->accepted() ) { | 393 | if ( currentEditor()->accepted() ) { |
378 | /* assign new todo */ | 394 | /* assign new todo */ |
379 | event.setUid( -1 ); | 395 | event.setUid( -1 ); |
380 | currentView()->addEvent( event ); | 396 | currentView()->addEvent( event ); |
381 | m_todoMgr.add( event ); | 397 | m_todoMgr.add( event ); |
382 | 398 | ||
383 | populateCategories(); | 399 | populateCategories(); |
384 | } | 400 | } |
385 | } | 401 | } |
386 | void MainWindow::slotNew() { | 402 | void MainWindow::slotNew() { |
387 | if(m_syncing) { | 403 | if(m_syncing) { |
388 | QMessageBox::warning(this, tr("Todo"), | 404 | QMessageBox::warning(this, tr("Todo"), |
389 | tr("Can not edit data, currently syncing")); | 405 | tr("Can not edit data, currently syncing")); |
390 | return; | 406 | return; |
391 | } | 407 | } |
392 | 408 | ||
393 | 409 | ||
394 | OTodo todo = currentEditor()->newTodo( currentCatId(), | 410 | OTodo todo = currentEditor()->newTodo( currentCatId(), |
395 | this ); | 411 | this ); |
396 | 412 | ||
397 | if ( currentEditor()->accepted() ) { | 413 | if ( currentEditor()->accepted() ) { |
398 | //todo.assignUid(); | 414 | //todo.assignUid(); |
399 | currentView()->addEvent( todo ); | 415 | currentView()->addEvent( todo ); |
400 | m_todoMgr.add( todo ); | 416 | m_todoMgr.add( todo ); |
401 | 417 | ||
402 | // I'm afraid we must call this every time now, otherwise | 418 | // I'm afraid we must call this every time now, otherwise |
403 | // spend expensive time comparing all these strings... | 419 | // spend expensive time comparing all these strings... |
404 | // but only call if we changed something -zecke | 420 | // but only call if we changed something -zecke |
405 | populateCategories(); | 421 | populateCategories(); |
406 | } | 422 | } |
407 | 423 | ||
408 | raiseCurrentView( ); | 424 | raiseCurrentView( ); |
409 | } | 425 | } |
410 | void MainWindow::slotDuplicate() { | 426 | void MainWindow::slotDuplicate() { |
411 | if(m_syncing) { | 427 | if(m_syncing) { |
412 | QMessageBox::warning(this, tr("Todo"), | 428 | QMessageBox::warning(this, tr("Todo"), |
413 | tr("Can not edit data, currently syncing")); | 429 | tr("Can not edit data, currently syncing")); |
414 | return; | 430 | return; |
415 | } | 431 | } |
416 | OTodo ev = m_todoMgr.event( currentView()->current() ); | 432 | OTodo ev = m_todoMgr.event( currentView()->current() ); |
417 | /* let's generate a new uid */ | 433 | /* let's generate a new uid */ |
418 | ev.setUid(-1); | 434 | ev.setUid(-1); |
419 | m_todoMgr.add( ev ); | 435 | m_todoMgr.add( ev ); |
420 | 436 | ||
421 | currentView()->addEvent( ev ); | 437 | currentView()->addEvent( ev ); |
422 | raiseCurrentView(); | 438 | raiseCurrentView(); |
423 | } | 439 | } |
424 | void MainWindow::slotDelete() { | 440 | void MainWindow::slotDelete() { |
425 | if (!currentView()->current() ) | 441 | if (!currentView()->current() ) |
426 | return; | 442 | return; |
427 | 443 | ||
428 | if(m_syncing) { | 444 | if(m_syncing) { |
429 | QMessageBox::warning(this, tr("Todo"), | 445 | QMessageBox::warning(this, tr("Todo"), |
430 | tr("Can not edit data, currently syncing")); | 446 | tr("Can not edit data, currently syncing")); |
431 | return; | 447 | return; |
432 | } | 448 | } |
433 | QString strName = currentView()->currentRepresentation(); | 449 | QString strName = currentView()->currentRepresentation(); |
434 | if (!QPEMessageBox::confirmDelete(this, tr("Todo"), strName ) ) | 450 | if (!QPEMessageBox::confirmDelete(this, tr("Todo"), strName ) ) |
435 | return; | 451 | return; |
436 | 452 | ||
437 | m_todoMgr.remove( currentView()->current() ); | 453 | m_todoMgr.remove( currentView()->current() ); |
438 | currentView()->removeEvent( currentView()->current() ); | 454 | currentView()->removeEvent( currentView()->current() ); |
439 | raiseCurrentView(); | 455 | raiseCurrentView(); |
440 | } | 456 | } |
441 | void MainWindow::slotDeleteAll() { | 457 | void MainWindow::slotDeleteAll() { |
442 | if(m_syncing) { | 458 | if(m_syncing) { |
443 | QMessageBox::warning(this, tr("Todo"), | 459 | QMessageBox::warning(this, tr("Todo"), |
444 | tr("Can not edit data, currently syncing")); | 460 | tr("Can not edit data, currently syncing")); |
445 | return; | 461 | return; |
446 | } | 462 | } |
447 | 463 | ||
448 | //QString strName = table->text( table->currentRow(), 2 ).left( 30 ); | 464 | //QString strName = table->text( table->currentRow(), 2 ).left( 30 ); |
449 | 465 | ||
450 | if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("all tasks?") ) ) | 466 | if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("all tasks?") ) ) |
451 | return; | 467 | return; |
452 | 468 | ||
453 | m_todoMgr.removeAll(); | 469 | m_todoMgr.removeAll(); |
454 | currentView()->clear(); | 470 | currentView()->clear(); |
455 | 471 | ||
456 | raiseCurrentView(); | 472 | raiseCurrentView(); |
457 | } | 473 | } |
458 | void MainWindow::slotDeleteCompleted() { | 474 | void MainWindow::slotDeleteCompleted() { |
459 | if(m_syncing) { | 475 | if(m_syncing) { |
460 | QMessageBox::warning(this, tr("Todo"), | 476 | QMessageBox::warning(this, tr("Todo"), |
461 | tr("Can not edit data, currently syncing")); | 477 | tr("Can not edit data, currently syncing")); |
462 | return; | 478 | return; |
463 | } | 479 | } |
464 | 480 | ||
465 | if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("all completed tasks?") ) ) | 481 | if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("all completed tasks?") ) ) |
466 | return; | 482 | return; |
467 | 483 | ||
468 | m_todoMgr.remove( currentView()->completed() ); | 484 | m_todoMgr.remove( currentView()->completed() ); |
469 | currentView()->setTodos( begin(), end() ); | 485 | currentView()->updateView( ); |
470 | } | 486 | } |
471 | void MainWindow::slotFind() { | 487 | void MainWindow::slotFind() { |
472 | 488 | ||
473 | } | 489 | } |
474 | void MainWindow::slotEdit() { | 490 | void MainWindow::slotEdit() { |
475 | slotEdit( currentView()->current() ); | 491 | slotEdit( currentView()->current() ); |
476 | } | 492 | } |
477 | /* | 493 | /* |
478 | * set the category | 494 | * set the category |
479 | */ | 495 | */ |
480 | void MainWindow::setCategory( int c) { | 496 | void MainWindow::setCategory( int c) { |
481 | if ( c <= 0 ) return; | 497 | if ( c <= 0 ) return; |
482 | 498 | ||
483 | qWarning("Iterating over cats %d", c ); | 499 | qWarning("Iterating over cats %d", c ); |
484 | for ( unsigned int i = 1; i < m_catMenu->count(); i++ ) | 500 | for ( unsigned int i = 1; i < m_catMenu->count(); i++ ) |
485 | m_catMenu->setItemChecked(i, c == (int)i ); | 501 | m_catMenu->setItemChecked(i, c == (int)i ); |
486 | 502 | ||
487 | if (c == 1 ) { | 503 | if (c == 1 ) { |
488 | m_curCat = QString::null; | 504 | m_curCat = QString::null; |
489 | setCaption( tr("Todo") + " - " + tr("All Categories" ) ); | 505 | setCaption( tr("Todo") + " - " + tr("All Categories" ) ); |
490 | 506 | ||
491 | }else if ( c == (int)m_catMenu->count() - 1 ) { | 507 | }else if ( c == (int)m_catMenu->count() - 1 ) { |
492 | m_curCat = tr("Unfiled"); | 508 | m_curCat = tr("Unfiled"); |
493 | setCaption( tr("Todo") + " - " + tr("Unfiled") ); | 509 | setCaption( tr("Todo") + " - " + tr("Unfiled") ); |
494 | }else { | 510 | }else { |
495 | m_curCat = m_todoMgr.categories()[c-2]; | 511 | m_curCat = m_todoMgr.categories()[c-2]; |
496 | setCaption( tr("Todo") + " - " + m_curCat ); | 512 | setCaption( tr("Todo") + " - " + m_curCat ); |
497 | } | 513 | } |
498 | m_catMenu->setItemChecked( c, true ); | 514 | m_catMenu->setItemChecked( c, true ); |
499 | currentView()->setShowCategory( m_curCat ); | 515 | currentView()->setShowCategory( m_curCat ); |
500 | raiseCurrentView(); | 516 | raiseCurrentView(); |
501 | } | 517 | } |
502 | void MainWindow::slotShowDeadLine( bool dead) { | 518 | void MainWindow::slotShowDeadLine( bool dead) { |
503 | m_deadline = dead; | 519 | m_deadline = dead; |
504 | currentView()->setShowDeadline( dead ); | 520 | currentView()->setShowDeadline( dead ); |
505 | } | 521 | } |
506 | void MainWindow::slotShowCompleted( bool show) { | 522 | void MainWindow::slotShowCompleted( bool show) { |
507 | m_completed = show; | 523 | m_completed = show; |
508 | currentView()->setShowCompleted( m_completed ); | 524 | currentView()->setShowCompleted( m_completed ); |
509 | } | 525 | } |
510 | bool MainWindow::showOverDue()const { | 526 | bool MainWindow::showOverDue()const { |
511 | return m_overdue; | 527 | return m_overdue; |
512 | } | 528 | } |
513 | void MainWindow::setDocument( const QString& ) { | 529 | void MainWindow::setDocument( const QString& ) { |
514 | 530 | ||
515 | } | 531 | } |
516 | void MainWindow::slotBeam() { | 532 | void MainWindow::slotBeam() { |
517 | 533 | ||
518 | } | 534 | } |
519 | void MainWindow::beamDone( Ir* ) { | 535 | void MainWindow::beamDone( Ir* ) { |
520 | 536 | ||
521 | } | 537 | } |
522 | 538 | ||
523 | void MainWindow::slotFlush() { | 539 | void MainWindow::slotFlush() { |
524 | m_syncing = FALSE; | 540 | m_syncing = FALSE; |
525 | m_todoMgr.save(); | 541 | m_todoMgr.save(); |
526 | } | 542 | } |
527 | void MainWindow::slotShowDetails() { | 543 | void MainWindow::slotShowDetails() { |
528 | slotShow( currentView()->current() ); | 544 | slotShow( currentView()->current() ); |
529 | } | 545 | } |
530 | /* | 546 | /* |
531 | * populate the Categories | 547 | * populate the Categories |
532 | * Menu | 548 | * Menu |
533 | */ | 549 | */ |
534 | void MainWindow::populateCategories() { | 550 | void MainWindow::populateCategories() { |
535 | if (m_todoMgr.isLoaded() ) | 551 | if (m_todoMgr.isLoaded() ) |
536 | m_todoMgr.load(); | 552 | m_todoMgr.load(); |
537 | 553 | ||
538 | m_catMenu->clear(); | 554 | m_catMenu->clear(); |
539 | int id, rememberId; | 555 | int id, rememberId; |
540 | id = 1; | 556 | id = 1; |
541 | rememberId = 1; | 557 | rememberId = 1; |
542 | 558 | ||
543 | m_catMenu->insertItem( tr( "All Categories" ), id++ ); | 559 | m_catMenu->insertItem( tr( "All Categories" ), id++ ); |
544 | m_catMenu->insertSeparator(); | 560 | m_catMenu->insertSeparator(); |
545 | QStringList categories = m_todoMgr.categories(); | 561 | QStringList categories = m_todoMgr.categories(); |
546 | categories.append( tr( "Unfiled" ) ); | 562 | categories.append( tr( "Unfiled" ) ); |
547 | for ( QStringList::Iterator it = categories.begin(); | 563 | for ( QStringList::Iterator it = categories.begin(); |
548 | it != categories.end(); ++it ) { | 564 | it != categories.end(); ++it ) { |
549 | m_catMenu->insertItem( *it, id ); | 565 | m_catMenu->insertItem( *it, id ); |
550 | if ( *it == currentCategory() ) | 566 | if ( *it == currentCategory() ) |
551 | rememberId = id; | 567 | rememberId = id; |
552 | ++id; | 568 | ++id; |
553 | } | 569 | } |
554 | setCategory( rememberId ); | 570 | setCategory( rememberId ); |
555 | } | 571 | } |
556 | bool MainWindow::showCompleted()const { | 572 | bool MainWindow::showCompleted()const { |
557 | return m_completed; | 573 | return m_completed; |
558 | } | 574 | } |
559 | bool MainWindow::showDeadline()const { | 575 | bool MainWindow::showDeadline()const { |
560 | return m_deadline; | 576 | return m_deadline; |
561 | } | 577 | } |
562 | QString MainWindow::currentCategory()const { | 578 | QString MainWindow::currentCategory()const { |
563 | return m_curCat; | 579 | return m_curCat; |
564 | } | 580 | } |
565 | int MainWindow::currentCatId() { | 581 | int MainWindow::currentCatId() { |
566 | return m_todoMgr.catId( m_curCat ); | 582 | return m_todoMgr.catId( m_curCat ); |
567 | } | 583 | } |
568 | ViewBase* MainWindow::currentView() { | 584 | ViewBase* MainWindow::currentView() { |
569 | return m_curView; | 585 | return m_curView; |
570 | } | 586 | } |
571 | void MainWindow::raiseCurrentView() { | 587 | void MainWindow::raiseCurrentView() { |
572 | m_stack->raiseWidget( m_curView->widget() ); | 588 | m_stack->raiseWidget( m_curView->widget() ); |
573 | } | 589 | } |
574 | void MainWindow::slotShowDue(bool ov) { | 590 | void MainWindow::slotShowDue(bool ov) { |
575 | m_overdue = ov; | 591 | m_overdue = ov; |
576 | currentView()->showOverDue( ov ); | 592 | currentView()->showOverDue( ov ); |
577 | raiseCurrentView(); | 593 | raiseCurrentView(); |
578 | } | 594 | } |
579 | void MainWindow::slotShow( int uid ) { | 595 | void MainWindow::slotShow( int uid ) { |
580 | qWarning("slotShow"); | 596 | qWarning("slotShow"); |
581 | currentShow()->slotShow( event( uid ) ); | 597 | currentShow()->slotShow( event( uid ) ); |
582 | m_stack->raiseWidget( currentShow()->widget() ); | 598 | m_stack->raiseWidget( currentShow()->widget() ); |
583 | } | 599 | } |
584 | void MainWindow::slotEdit( int uid ) { | 600 | void MainWindow::slotEdit( int uid ) { |
585 | if(m_syncing) { | 601 | if(m_syncing) { |
586 | QMessageBox::warning(this, tr("Todo"), | 602 | QMessageBox::warning(this, tr("Todo"), |
587 | tr("Can not edit data, currently syncing")); | 603 | tr("Can not edit data, currently syncing")); |
588 | return; | 604 | return; |
589 | } | 605 | } |
590 | 606 | ||
591 | OTodo todo = m_todoMgr.event( uid ); | 607 | OTodo todo = m_todoMgr.event( uid ); |
592 | 608 | ||
593 | todo = currentEditor()->edit(this, todo ); | 609 | todo = currentEditor()->edit(this, todo ); |
594 | 610 | ||
595 | /* if completed */ | 611 | /* if completed */ |
596 | if ( currentEditor()->accepted() ) { | 612 | if ( currentEditor()->accepted() ) { |
597 | qWarning("Replacing now" ); | 613 | qWarning("Replacing now" ); |
598 | m_todoMgr.update( todo.uid(), todo ); | 614 | m_todoMgr.update( todo.uid(), todo ); |
599 | currentView()->replaceEvent( todo ); | 615 | currentView()->replaceEvent( todo ); |
600 | populateCategories(); | 616 | populateCategories(); |
601 | } | 617 | } |
602 | 618 | ||
603 | raiseCurrentView(); | 619 | raiseCurrentView(); |
604 | } | 620 | } |
605 | /* | 621 | /* |
606 | void MainWindow::slotUpdate1( int uid, const SmallTodo& ev) { | 622 | void MainWindow::slotUpdate1( int uid, const SmallTodo& ev) { |
607 | m_todoMgr.update( uid, ev ); | 623 | m_todoMgr.update( uid, ev ); |
608 | } | 624 | } |
609 | */ | 625 | */ |
610 | void MainWindow::updateTodo( const OTodo& ev) { | 626 | void MainWindow::updateTodo( const OTodo& ev) { |
611 | m_todoMgr.update( ev.uid() , ev ); | 627 | m_todoMgr.update( ev.uid() , ev ); |
612 | } | 628 | } |
613 | /* The view changed it's configuration | 629 | /* The view changed it's configuration |
614 | * update the view menu | 630 | * update the view menu |
615 | */ | 631 | */ |
616 | void MainWindow::slotUpdate3( QWidget* ) { | 632 | void MainWindow::slotUpdate3( QWidget* ) { |
617 | 633 | ||
618 | } | 634 | } |
619 | void MainWindow::updateList() { | 635 | void MainWindow::updateList() { |
620 | m_todoMgr.updateList(); | 636 | m_todoMgr.updateList(); |
621 | } | 637 | } |
diff --git a/core/pim/todo/mainwindow.h b/core/pim/todo/mainwindow.h index 43666f0..598c3af 100644 --- a/core/pim/todo/mainwindow.h +++ b/core/pim/todo/mainwindow.h | |||
@@ -1,175 +1,175 @@ | |||
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 | #include <qmainwindow.h> | 33 | #include <qmainwindow.h> |
34 | 34 | ||
35 | #include <opie/otodoaccess.h> | 35 | #include <opie/otodoaccess.h> |
36 | #include <opie/otodo.h> | 36 | #include <opie/otodo.h> |
37 | 37 | ||
38 | #include "smalltodo.h" | 38 | #include "smalltodo.h" |
39 | #include "todoview.h" | 39 | #include "todoview.h" |
40 | #include "todomanager.h" | 40 | #include "todomanager.h" |
41 | 41 | ||
42 | class QPopupMenu; | 42 | class QPopupMenu; |
43 | class QMenuBar; | 43 | class QMenuBar; |
44 | class QToolBar; | 44 | class QToolBar; |
45 | class QAction; | 45 | class QAction; |
46 | class QWidgetStack; | 46 | class QWidgetStack; |
47 | class Ir; | 47 | class Ir; |
48 | 48 | ||
49 | 49 | ||
50 | namespace Todo { | 50 | namespace Todo { |
51 | typedef TodoView View; | 51 | typedef TodoView View; |
52 | class TemplateManager; | 52 | class TemplateManager; |
53 | class Editor; | 53 | class Editor; |
54 | class TodoShow; | 54 | class TodoShow; |
55 | class TemplateEditor; | 55 | class TemplateEditor; |
56 | 56 | ||
57 | class MainWindow : public QMainWindow { | 57 | class MainWindow : public QMainWindow { |
58 | Q_OBJECT | 58 | Q_OBJECT |
59 | public: | 59 | public: |
60 | MainWindow( QWidget *parent = 0, | 60 | MainWindow( QWidget *parent = 0, |
61 | const char* name = 0 ); | 61 | const char* name = 0 ); |
62 | ~MainWindow(); | 62 | ~MainWindow(); |
63 | 63 | ||
64 | /** return a context menu for an OTodo */ | 64 | /** return a context menu for an OTodo */ |
65 | QPopupMenu* contextMenu(int uid ); | 65 | QPopupMenu* contextMenu(int uid ); |
66 | QPopupMenu* options(); | 66 | QPopupMenu* options(); |
67 | QPopupMenu* edit(); | 67 | QPopupMenu* edit(); |
68 | QPopupMenu* view(); | 68 | QPopupMenu* view(); |
69 | QToolBar* toolbar(); | 69 | QToolBar* toolbar(); |
70 | 70 | ||
71 | 71 | ||
72 | void updateList(); | 72 | void updateList(); |
73 | OTodoAccess::List::Iterator begin(); | 73 | OTodoAccess::List list()const; |
74 | OTodoAccess::List::Iterator end(); | 74 | OTodoAccess::List sorted( bool asc, int sortOrder ); |
75 | // OTodoAccess::List::Iterator &iterator(); | 75 | OTodoAccess::List sorted( bool asc, int sortOrder, int addFilter ); |
76 | 76 | ||
77 | OTodo event(int uid ); | 77 | OTodo event(int uid ); |
78 | 78 | ||
79 | bool isSyncing()const; | 79 | bool isSyncing()const; |
80 | bool showCompleted()const; | 80 | bool showCompleted()const; |
81 | bool showDeadline()const; | 81 | bool showDeadline()const; |
82 | bool showOverDue()const; | 82 | bool showOverDue()const; |
83 | QString currentCategory()const; | 83 | QString currentCategory()const; |
84 | int currentCatId(); | 84 | int currentCatId(); |
85 | TemplateManager* templateManager(); | 85 | TemplateManager* templateManager(); |
86 | 86 | ||
87 | void updateTodo( const OTodo& ); | 87 | void updateTodo( const OTodo& ); |
88 | void populateTemplates(); | 88 | void populateTemplates(); |
89 | Editor* currentEditor(); | 89 | Editor* currentEditor(); |
90 | private slots: | 90 | private slots: |
91 | void populateCategories(); | 91 | void populateCategories(); |
92 | void slotReload(); | 92 | void slotReload(); |
93 | void slotFlush(); | 93 | void slotFlush(); |
94 | 94 | ||
95 | protected: | 95 | protected: |
96 | void closeEvent( QCloseEvent* e ); | 96 | void closeEvent( QCloseEvent* e ); |
97 | 97 | ||
98 | private: | 98 | private: |
99 | void connectBase( ViewBase* ); | 99 | void connectBase( ViewBase* ); |
100 | void initUI(); | 100 | void initUI(); |
101 | void initActions(); | 101 | void initActions(); |
102 | void initConfig(); | 102 | void initConfig(); |
103 | void initViews(); | 103 | void initViews(); |
104 | void initEditor(); | 104 | void initEditor(); |
105 | void initShow(); | 105 | void initShow(); |
106 | void initTemplate(); | 106 | void initTemplate(); |
107 | void raiseCurrentView(); | 107 | void raiseCurrentView(); |
108 | ViewBase* currentView(); | 108 | ViewBase* currentView(); |
109 | ViewBase* m_curView; | 109 | ViewBase* m_curView; |
110 | Editor* m_curEdit; | 110 | Editor* m_curEdit; |
111 | TodoShow* currentShow(); | 111 | TodoShow* currentShow(); |
112 | TodoShow* m_curShow; | 112 | TodoShow* m_curShow; |
113 | TemplateEditor* currentTemplateEditor(); | 113 | TemplateEditor* currentTemplateEditor(); |
114 | TemplateEditor* m_curTempEd; | 114 | TemplateEditor* m_curTempEd; |
115 | 115 | ||
116 | QMenuBar* m_bar; | 116 | QMenuBar* m_bar; |
117 | QToolBar* m_tool; | 117 | QToolBar* m_tool; |
118 | QAction* m_editAction, | 118 | QAction* m_editAction, |
119 | *m_deleteAction, | 119 | *m_deleteAction, |
120 | *m_findAction, | 120 | *m_findAction, |
121 | *m_completedAction, | 121 | *m_completedAction, |
122 | *m_showDeadLineAction, | 122 | *m_showDeadLineAction, |
123 | *m_deleteAllAction, | 123 | *m_deleteAllAction, |
124 | *m_deleteCompleteAction, | 124 | *m_deleteCompleteAction, |
125 | *m_duplicateAction, | 125 | *m_duplicateAction, |
126 | *m_showOverDueAction, | 126 | *m_showOverDueAction, |
127 | *m_effectiveAction; | 127 | *m_effectiveAction; |
128 | QWidgetStack *m_stack; | 128 | QWidgetStack *m_stack; |
129 | QPopupMenu* m_catMenu, | 129 | QPopupMenu* m_catMenu, |
130 | *m_edit, | 130 | *m_edit, |
131 | *m_options, | 131 | *m_options, |
132 | *m_view, | 132 | *m_view, |
133 | *m_template; | 133 | *m_template; |
134 | 134 | ||
135 | bool m_syncing:1; | 135 | bool m_syncing:1; |
136 | bool m_deadline:1; | 136 | bool m_deadline:1; |
137 | bool m_completed:1; | 137 | bool m_completed:1; |
138 | bool m_overdue:1; | 138 | bool m_overdue:1; |
139 | TodoManager m_todoMgr; | 139 | TodoManager m_todoMgr; |
140 | QString m_curCat; | 140 | QString m_curCat; |
141 | QList<ViewBase> m_views; | 141 | QList<ViewBase> m_views; |
142 | uint m_counter; | 142 | uint m_counter; |
143 | TemplateManager* m_tempManager; | 143 | TemplateManager* m_tempManager; |
144 | 144 | ||
145 | private slots: | 145 | private slots: |
146 | void slotShow(int); | 146 | void slotShow(int); |
147 | void slotEdit(int); | 147 | void slotEdit(int); |
148 | private slots: | 148 | private slots: |
149 | void slotUpdate3( QWidget* ); | 149 | void slotUpdate3( QWidget* ); |
150 | void slotNewFromTemplate(int id ); | 150 | void slotNewFromTemplate(int id ); |
151 | void slotNew(); | 151 | void slotNew(); |
152 | void slotDuplicate(); | 152 | void slotDuplicate(); |
153 | void slotDelete(); | 153 | void slotDelete(); |
154 | void slotDeleteAll(); | 154 | void slotDeleteAll(); |
155 | void slotDeleteCompleted(); | 155 | void slotDeleteCompleted(); |
156 | 156 | ||
157 | void slotEdit(); | 157 | void slotEdit(); |
158 | void slotFind(); | 158 | void slotFind(); |
159 | 159 | ||
160 | void setCategory( int ); | 160 | void setCategory( int ); |
161 | 161 | ||
162 | void slotShowDeadLine( bool ); | 162 | void slotShowDeadLine( bool ); |
163 | void slotShowCompleted( bool ); | 163 | void slotShowCompleted( bool ); |
164 | 164 | ||
165 | void setDocument( const QString& ); | 165 | void setDocument( const QString& ); |
166 | 166 | ||
167 | 167 | ||
168 | void slotBeam(); | 168 | void slotBeam(); |
169 | void beamDone( Ir* ); | 169 | void beamDone( Ir* ); |
170 | void slotShowDetails(); | 170 | void slotShowDetails(); |
171 | void slotShowDue( bool ); | 171 | void slotShowDue( bool ); |
172 | }; | 172 | }; |
173 | }; | 173 | }; |
174 | 174 | ||
175 | #endif | 175 | #endif |
diff --git a/core/pim/todo/tableview.cpp b/core/pim/todo/tableview.cpp index 8cd2e7e..097af39 100644 --- a/core/pim/todo/tableview.cpp +++ b/core/pim/todo/tableview.cpp | |||
@@ -1,363 +1,365 @@ | |||
1 | /* | 1 | /* |
2 | =. This file is part of the OPIE Project | 2 | =. This file is part of the OPIE Project |
3 | .=l. Copyright (c) 2002 <> | 3 | .=l. Copyright (c) 2002 <> |
4 | .>+-= | 4 | .>+-= |
5 | _;:, .> :=|. This program is free software; you can | 5 | _;:, .> :=|. This program is free software; you can |
6 | .> <`_, > . <= redistribute it and/or modify it under | 6 | .> <`_, > . <= redistribute it and/or modify it under |
7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
8 | .="- .-=="i, .._ License as published by the Free Software | 8 | .="- .-=="i, .._ License as published by the Free Software |
9 | - . .-<_> .<> Foundation; either version 2 of the License, | 9 | - . .-<_> .<> Foundation; either version 2 of the License, |
10 | ._= =} : or (at your option) any later version. | 10 | ._= =} : or (at your option) any later version. |
11 | .%`+i> _;_. | 11 | .%`+i> _;_. |
12 | .i_,=:_. -<s. This program is distributed in the hope that | 12 | .i_,=:_. -<s. This program is distributed in the hope that |
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
14 | : .. .:, . . . without even the implied warranty of | 14 | : .. .:, . . . without even the implied warranty of |
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
17 | ..}^=.= = ; Library General Public License for more | 17 | ..}^=.= = ; Library General Public License for more |
18 | ++= -. .` .: details. | 18 | ++= -. .` .: details. |
19 | : = ...= . :.=- | 19 | : = ...= . :.=- |
20 | -. .:....=;==+<; You should have received a copy of the GNU | 20 | -. .:....=;==+<; You should have received a copy of the GNU |
21 | -_. . . )=. = Library General Public License along with | 21 | -_. . . )=. = Library General Public License along with |
22 | -- :-=` this library; see the file COPYING.LIB. | 22 | -- :-=` this library; see the file COPYING.LIB. |
23 | If not, write to the Free Software Foundation, | 23 | If not, write to the Free Software Foundation, |
24 | Inc., 59 Temple Place - Suite 330, | 24 | Inc., 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include <qtimer.h> | 29 | #include <qtimer.h> |
30 | #include <qpoint.h> | 30 | #include <qpoint.h> |
31 | #include <qpopupmenu.h> | 31 | #include <qpopupmenu.h> |
32 | 32 | ||
33 | #include "mainwindow.h" | 33 | #include "mainwindow.h" |
34 | //#include "tableitems.h" | 34 | //#include "tableitems.h" |
35 | #include "tableview.h" | 35 | #include "tableview.h" |
36 | 36 | ||
37 | using namespace Todo; | 37 | using namespace Todo; |
38 | 38 | ||
39 | 39 | ||
40 | TableView::TableView( MainWindow* window, QWidget* wid ) | 40 | TableView::TableView( MainWindow* window, QWidget* wid ) |
41 | : QTable( wid ), TodoView( window ) { | 41 | : QTable( wid ), TodoView( window ) { |
42 | setUpdatesEnabled( false ); | 42 | setUpdatesEnabled( false ); |
43 | viewport()->setUpdatesEnabled( false ); | 43 | viewport()->setUpdatesEnabled( false ); |
44 | m_enablePaint = false; | 44 | m_enablePaint = false; |
45 | setNumRows(0); | 45 | setNumRows(0); |
46 | setNumCols(4); | 46 | setNumCols(4); |
47 | 47 | ||
48 | setSorting( TRUE ); | 48 | setSorting( TRUE ); |
49 | setSelectionMode( NoSelection ); | 49 | setSelectionMode( NoSelection ); |
50 | setColumnStretchable( 2, TRUE ); | 50 | setColumnStretchable( 2, TRUE ); |
51 | setColumnWidth(0, 20 ); | 51 | setColumnWidth(0, 20 ); |
52 | setColumnWidth(1, 35 ); | 52 | setColumnWidth(1, 35 ); |
53 | 53 | ||
54 | setLeftMargin( 0 ); | 54 | setLeftMargin( 0 ); |
55 | verticalHeader()->hide(); | 55 | verticalHeader()->hide(); |
56 | 56 | ||
57 | horizontalHeader()->setLabel(0, tr("C.") ); | 57 | horizontalHeader()->setLabel(0, tr("C.") ); |
58 | horizontalHeader()->setLabel(1, tr("Prior.") ); | 58 | horizontalHeader()->setLabel(1, tr("Prior.") ); |
59 | horizontalHeader()->setLabel(2, tr("Description" ) ); | 59 | horizontalHeader()->setLabel(2, tr("Description" ) ); |
60 | 60 | ||
61 | setColumnStretchable(3, FALSE ); | 61 | setColumnStretchable(3, FALSE ); |
62 | setColumnWidth(3, 20 ); | 62 | setColumnWidth(3, 20 ); |
63 | horizontalHeader()->setLabel(3, tr("Deadline") ); | 63 | horizontalHeader()->setLabel(3, tr("Deadline") ); |
64 | 64 | ||
65 | if ( todoWindow()->showDeadline() ) | 65 | if ( todoWindow()->showDeadline() ) |
66 | showColumn( 3); | 66 | showColumn( 3); |
67 | else | 67 | else |
68 | hideColumn(3 ); | 68 | hideColumn(3 ); |
69 | 69 | ||
70 | connect((QTable*)this, SIGNAL( clicked( int, int, int, const QPoint& ) ), | 70 | connect((QTable*)this, SIGNAL( clicked( int, int, int, const QPoint& ) ), |
71 | this, SLOT( slotClicked(int, int, int, const QPoint& ) ) ); | 71 | this, SLOT( slotClicked(int, int, int, const QPoint& ) ) ); |
72 | connect((QTable*)this, SIGNAL( pressed( int, int, int, const QPoint& ) ), | 72 | connect((QTable*)this, SIGNAL( pressed( int, int, int, const QPoint& ) ), |
73 | this, SLOT( slotPressed(int, int, int, const QPoint& ) ) ); | 73 | this, SLOT( slotPressed(int, int, int, const QPoint& ) ) ); |
74 | connect((QTable*)this, SIGNAL(valueChanged(int, int) ), | 74 | connect((QTable*)this, SIGNAL(valueChanged(int, int) ), |
75 | this, SLOT( slotValueChanged(int, int) ) ); | 75 | this, SLOT( slotValueChanged(int, int) ) ); |
76 | connect((QTable*)this, SIGNAL(currentChanged(int, int) ), | 76 | connect((QTable*)this, SIGNAL(currentChanged(int, int) ), |
77 | this, SLOT( slotCurrentChanged(int, int) ) ); | 77 | this, SLOT( slotCurrentChanged(int, int) ) ); |
78 | 78 | ||
79 | m_menuTimer = new QTimer( this ); | 79 | m_menuTimer = new QTimer( this ); |
80 | connect( m_menuTimer, SIGNAL(timeout()), | 80 | connect( m_menuTimer, SIGNAL(timeout()), |
81 | this, SLOT(slotShowMenu()) ); | 81 | this, SLOT(slotShowMenu()) ); |
82 | 82 | ||
83 | m_enablePaint = true; | 83 | m_enablePaint = true; |
84 | setUpdatesEnabled( true ); | 84 | setUpdatesEnabled( true ); |
85 | viewport()->setUpdatesEnabled( true ); | 85 | viewport()->setUpdatesEnabled( true ); |
86 | viewport()->update(); | 86 | viewport()->update(); |
87 | } | 87 | } |
88 | /* a new day has started | 88 | /* a new day has started |
89 | * update the day | 89 | * update the day |
90 | */ | 90 | */ |
91 | void TableView::newDay() { | 91 | void TableView::newDay() { |
92 | clear(); | 92 | clear(); |
93 | setTodos( begin(),end() ); | 93 | updateView(); |
94 | } | 94 | } |
95 | TableView::~TableView() { | 95 | TableView::~TableView() { |
96 | 96 | ||
97 | } | 97 | } |
98 | void TableView::slotShowMenu() { | 98 | void TableView::slotShowMenu() { |
99 | QPopupMenu *menu = todoWindow()->contextMenu( current() ); | 99 | QPopupMenu *menu = todoWindow()->contextMenu( current() ); |
100 | menu->exec(QCursor::pos() ); | 100 | menu->exec(QCursor::pos() ); |
101 | delete menu; | 101 | delete menu; |
102 | } | 102 | } |
103 | OTodo TableView::find(int uid ) { | 103 | OTodo TableView::find(int uid ) { |
104 | OTodo ev = TodoView::event( uid ); | 104 | OTodo ev = TodoView::event( uid ); |
105 | return ev; | 105 | return ev; |
106 | } | 106 | } |
107 | void TableView::updateFromTable( const OTodo& ev, CheckItem* item ) { | 107 | void TableView::updateFromTable( const OTodo& ev, CheckItem* item ) { |
108 | TodoView::update( ev.uid(), ev ); | 108 | TodoView::update( ev.uid(), ev ); |
109 | 109 | ||
110 | /* update the other columns */ | 110 | /* update the other columns */ |
111 | /* if completed or not we need to update | 111 | /* if completed or not we need to update |
112 | * the table | 112 | * the table |
113 | * | 113 | * |
114 | * We've two cases | 114 | * We've two cases |
115 | * either item or !item | 115 | * either item or !item |
116 | * this makes cases more easy | 116 | * this makes cases more easy |
117 | */ | 117 | */ |
118 | if ( !item ) { | 118 | if ( !item ) { |
119 | item = m_cache[ev.uid()]; | 119 | item = m_cache[ev.uid()]; |
120 | } | 120 | } |
121 | DueTextItem *due = dueItem( item->row() ); | 121 | DueTextItem *due = dueItem( item->row() ); |
122 | due->setCompleted( ev.isCompleted() ); | 122 | due->setCompleted( ev.isCompleted() ); |
123 | } | 123 | } |
124 | QString TableView::type() const { | 124 | QString TableView::type() const { |
125 | return QString::fromLatin1( tr("Table View") ); | 125 | return QString::fromLatin1( tr("Table View") ); |
126 | } | 126 | } |
127 | int TableView::current() { | 127 | int TableView::current() { |
128 | int cur = 0; | 128 | int cur = 0; |
129 | CheckItem* i = checkItem( currentRow() ); | 129 | CheckItem* i = checkItem( currentRow() ); |
130 | if (i ) | 130 | if (i ) |
131 | cur = i->uid(); | 131 | cur = i->uid(); |
132 | 132 | ||
133 | return cur; | 133 | return cur; |
134 | } | 134 | } |
135 | QString TableView::currentRepresentation() { | 135 | QString TableView::currentRepresentation() { |
136 | return text( currentRow(), 2); | 136 | return text( currentRow(), 2); |
137 | } | 137 | } |
138 | /* show overdue */ | 138 | /* show overdue */ |
139 | void TableView::showOverDue( bool ) { | 139 | void TableView::showOverDue( bool ) { |
140 | clear(); | 140 | clear(); |
141 | setTodos( begin(), end() ); | 141 | updateView(); |
142 | } | 142 | } |
143 | 143 | ||
144 | void TableView::setTodos( OTodoAccess::List::Iterator it, | 144 | void TableView::updateView( ) { |
145 | OTodoAccess::List::Iterator end ) { | 145 | OTodoAccess::List::Iterator it, end; |
146 | it = list().begin(); | ||
147 | end = list().end(); | ||
146 | qWarning("setTodos"); | 148 | qWarning("setTodos"); |
147 | QTime time; | 149 | QTime time; |
148 | time.start(); | 150 | time.start(); |
149 | m_enablePaint = false; | 151 | m_enablePaint = false; |
150 | setUpdatesEnabled( false ); | 152 | setUpdatesEnabled( false ); |
151 | viewport()->setUpdatesEnabled( false ); | 153 | viewport()->setUpdatesEnabled( false ); |
152 | clear(); | 154 | clear(); |
153 | QString currentCat = todoWindow()->currentCategory(); | 155 | QString currentCat = todoWindow()->currentCategory(); |
154 | bool showCompleted = todoWindow()->showCompleted(); | 156 | bool showCompleted = todoWindow()->showCompleted(); |
155 | bool showOverDue = todoWindow()->showOverDue(); | 157 | bool showOverDue = todoWindow()->showOverDue(); |
156 | qWarning( "Current Category:" + todoWindow()->currentCategory() ); | 158 | qWarning( "Current Category:" + todoWindow()->currentCategory() ); |
157 | int id = todoWindow()->currentCatId(); | 159 | int id = todoWindow()->currentCatId(); |
158 | QTime t; | 160 | QTime t; |
159 | t.start(); | 161 | t.start(); |
160 | setNumRows( it.count() ); | 162 | setNumRows( it.count() ); |
161 | uint i = 0; | 163 | uint i = 0; |
162 | for (; it != end; ++it ) { | 164 | for (; it != end; ++it ) { |
163 | OTodo todo = (*it); | 165 | OTodo todo = (*it); |
164 | /* test if the categories match */ | 166 | /* test if the categories match */ |
165 | if ( !currentCat.isEmpty() && | 167 | if ( !currentCat.isEmpty() && |
166 | !todo.categories().contains( id ) ) { | 168 | !todo.categories().contains( id ) ) { |
167 | continue; | 169 | continue; |
168 | } | 170 | } |
169 | /* the item is completed but we shouldn't show it */ | 171 | /* the item is completed but we shouldn't show it */ |
170 | if ( !showCompleted && todo.isCompleted() ) { | 172 | if ( !showCompleted && todo.isCompleted() ) { |
171 | qWarning("isCompleted "); | 173 | qWarning("isCompleted "); |
172 | continue; | 174 | continue; |
173 | } | 175 | } |
174 | /* the item is not overdue but we should only show overdue */ | 176 | /* the item is not overdue but we should only show overdue */ |
175 | if ( showOverDue && !todo.isOverdue() ) { | 177 | if ( showOverDue && !todo.isOverdue() ) { |
176 | continue; | 178 | continue; |
177 | } | 179 | } |
178 | /* now it's fine to add it */ | 180 | /* now it's fine to add it */ |
179 | insertTodo( todo, i ); | 181 | insertTodo( todo, i ); |
180 | i++; | 182 | i++; |
181 | } | 183 | } |
182 | setNumRows( i ); | 184 | setNumRows( i ); |
183 | int elc = time.elapsed(); | 185 | int elc = time.elapsed(); |
184 | qWarning("Adding took %d", elc/1000 ); | 186 | qWarning("Adding took %d", elc/1000 ); |
185 | setUpdatesEnabled( true ); | 187 | setUpdatesEnabled( true ); |
186 | viewport()->setUpdatesEnabled( true ); | 188 | viewport()->setUpdatesEnabled( true ); |
187 | viewport()->update(); | 189 | viewport()->update(); |
188 | m_enablePaint = true; | 190 | m_enablePaint = true; |
189 | int el = time.elapsed(); | 191 | int el = time.elapsed(); |
190 | qWarning("adding took %d", el/1000 ); | 192 | qWarning("adding took %d", el/1000 ); |
191 | } | 193 | } |
192 | void TableView::setTodo( int uid, const OTodo& ev ) { | 194 | void TableView::setTodo( int uid, const OTodo& ev ) { |
193 | QMap<int, CheckItem*>::Iterator it = m_cache.find( uid ); | 195 | QMap<int, CheckItem*>::Iterator it = m_cache.find( uid ); |
194 | 196 | ||
195 | if ( it != m_cache.end() ) { | 197 | if ( it != m_cache.end() ) { |
196 | int row = it.data()->row(); | 198 | int row = it.data()->row(); |
197 | 199 | ||
198 | /* update checked */ | 200 | /* update checked */ |
199 | CheckItem* check = checkItem(row ); | 201 | CheckItem* check = checkItem(row ); |
200 | if (check) | 202 | if (check) |
201 | check->setChecked( ev.isCompleted() ); | 203 | check->setChecked( ev.isCompleted() ); |
202 | 204 | ||
203 | /* update the text */ | 205 | /* update the text */ |
204 | QString sum = ev.summary(); | 206 | QString sum = ev.summary(); |
205 | setText(row, 2, sum.isEmpty() ? | 207 | setText(row, 2, sum.isEmpty() ? |
206 | ev.description().left(40).simplifyWhiteSpace() : | 208 | ev.description().left(40).simplifyWhiteSpace() : |
207 | sum ); | 209 | sum ); |
208 | 210 | ||
209 | /* update priority */ | 211 | /* update priority */ |
210 | setText(row, 1, QString::number( ev.priority() ) ); | 212 | setText(row, 1, QString::number( ev.priority() ) ); |
211 | 213 | ||
212 | /* update DueDate */ | 214 | /* update DueDate */ |
213 | DueTextItem *due = dueItem( row ); | 215 | DueTextItem *due = dueItem( row ); |
214 | due->setToDoEvent( ev ); | 216 | due->setToDoEvent( ev ); |
215 | } | 217 | } |
216 | } | 218 | } |
217 | void TableView::addEvent( const OTodo& ev) { | 219 | void TableView::addEvent( const OTodo& ev) { |
218 | int row= numRows(); | 220 | int row= numRows(); |
219 | setNumRows( row + 1 ); | 221 | setNumRows( row + 1 ); |
220 | insertTodo( ev, row ); | 222 | insertTodo( ev, row ); |
221 | } | 223 | } |
222 | /* | 224 | /* |
223 | * find the event | 225 | * find the event |
224 | * and then replace the complete row | 226 | * and then replace the complete row |
225 | */ | 227 | */ |
226 | void TableView::replaceEvent( const OTodo& ev) { | 228 | void TableView::replaceEvent( const OTodo& ev) { |
227 | setTodo( ev.uid(), ev ); | 229 | setTodo( ev.uid(), ev ); |
228 | } | 230 | } |
229 | /* | 231 | /* |
230 | * re aligning table can be slow too | 232 | * re aligning table can be slow too |
231 | * FIXME: look what performs better | 233 | * FIXME: look what performs better |
232 | * either this or the old align table | 234 | * either this or the old align table |
233 | */ | 235 | */ |
234 | void TableView::removeEvent( int ) { | 236 | void TableView::removeEvent( int ) { |
235 | clear(); | 237 | clear(); |
236 | setTodos( begin(), end() ); | 238 | updateView(); |
237 | } | 239 | } |
238 | void TableView::setShowCompleted( bool b) { | 240 | void TableView::setShowCompleted( bool b) { |
239 | qWarning("Show Completed %d" + b ); | 241 | qWarning("Show Completed %d" + b ); |
240 | setTodos( begin(), end() ); | 242 | updateView(); |
241 | } | 243 | } |
242 | void TableView::setShowDeadline( bool b) { | 244 | void TableView::setShowDeadline( bool b) { |
243 | qWarning("Show DeadLine %d" + b ); | 245 | qWarning("Show DeadLine %d" + b ); |
244 | if (b) | 246 | if (b) |
245 | showColumn(3 ); | 247 | showColumn(3 ); |
246 | else | 248 | else |
247 | hideColumn(3 ); | 249 | hideColumn(3 ); |
248 | } | 250 | } |
249 | void TableView::setShowCategory( const QString& ) { | 251 | void TableView::setShowCategory( const QString& ) { |
250 | qWarning("setShowCategory"); | 252 | qWarning("setShowCategory"); |
251 | setTodos( begin(), end() ); | 253 | updateView(); |
252 | } | 254 | } |
253 | void TableView::clear() { | 255 | void TableView::clear() { |
254 | m_cache.clear(); | 256 | m_cache.clear(); |
255 | int rows = numRows(); | 257 | int rows = numRows(); |
256 | for (int r = 0; r < rows; r++ ) { | 258 | for (int r = 0; r < rows; r++ ) { |
257 | for (int c = 0; c < numCols(); c++ ) { | 259 | for (int c = 0; c < numCols(); c++ ) { |
258 | if ( cellWidget(r, c) ) | 260 | if ( cellWidget(r, c) ) |
259 | clearCellWidget(r, c ); | 261 | clearCellWidget(r, c ); |
260 | clearCell(r, c); | 262 | clearCell(r, c); |
261 | } | 263 | } |
262 | } | 264 | } |
263 | setNumRows( 0); | 265 | setNumRows( 0); |
264 | } | 266 | } |
265 | QArray<int> TableView::completed() { | 267 | QArray<int> TableView::completed() { |
266 | int row = numRows(); | 268 | int row = numRows(); |
267 | QArray<int> ids( row ); | 269 | QArray<int> ids( row ); |
268 | 270 | ||
269 | int j=0; | 271 | int j=0; |
270 | for (int i = 0; i < row; i++ ) { | 272 | for (int i = 0; i < row; i++ ) { |
271 | CheckItem* item = checkItem(i ); | 273 | CheckItem* item = checkItem(i ); |
272 | if (item->isChecked() ) { | 274 | if (item->isChecked() ) { |
273 | ids[j] = item->uid(); | 275 | ids[j] = item->uid(); |
274 | j++; | 276 | j++; |
275 | } | 277 | } |
276 | } | 278 | } |
277 | ids.resize( j ); | 279 | ids.resize( j ); |
278 | return ids; | 280 | return ids; |
279 | } | 281 | } |
280 | void TableView::slotClicked(int row, int col, int, | 282 | void TableView::slotClicked(int row, int col, int, |
281 | const QPoint& point) { | 283 | const QPoint& point) { |
282 | if ( !cellGeometry(row, col ).contains(point ) ) | 284 | if ( !cellGeometry(row, col ).contains(point ) ) |
283 | return; | 285 | return; |
284 | 286 | ||
285 | 287 | ||
286 | switch( col ) { | 288 | switch( col ) { |
287 | case 0: { | 289 | case 0: { |
288 | CheckItem* item = checkItem( row ); | 290 | CheckItem* item = checkItem( row ); |
289 | /* | 291 | /* |
290 | * let's see if we centered clicked | 292 | * let's see if we centered clicked |
291 | */ | 293 | */ |
292 | if ( item ) { | 294 | if ( item ) { |
293 | int x = point.x() -columnPos( col ); | 295 | int x = point.x() -columnPos( col ); |
294 | int y = point.y() -rowPos( row ); | 296 | int y = point.y() -rowPos( row ); |
295 | int w = columnWidth( col ); | 297 | int w = columnWidth( col ); |
296 | int h = rowHeight( row ); | 298 | int h = rowHeight( row ); |
297 | if ( x >= ( w - OCheckItem::BoxSize ) / 2 && | 299 | if ( x >= ( w - OCheckItem::BoxSize ) / 2 && |
298 | x <= ( w - OCheckItem::BoxSize ) / 2 + OCheckItem::BoxSize && | 300 | x <= ( w - OCheckItem::BoxSize ) / 2 + OCheckItem::BoxSize && |
299 | y >= ( h - OCheckItem::BoxSize ) / 2 && | 301 | y >= ( h - OCheckItem::BoxSize ) / 2 && |
300 | y <= ( h - OCheckItem::BoxSize ) / 2 + OCheckItem::BoxSize ) | 302 | y <= ( h - OCheckItem::BoxSize ) / 2 + OCheckItem::BoxSize ) |
301 | item->toggle(); | 303 | item->toggle(); |
302 | } | 304 | } |
303 | } | 305 | } |
304 | break; | 306 | break; |
305 | 307 | ||
306 | case 1: | 308 | case 1: |
307 | break; | 309 | break; |
308 | 310 | ||
309 | case 2: { | 311 | case 2: { |
310 | m_menuTimer->stop(); | 312 | m_menuTimer->stop(); |
311 | showTodo( checkItem(row)->uid() ); | 313 | showTodo( checkItem(row)->uid() ); |
312 | break; | 314 | break; |
313 | } | 315 | } |
314 | case 3: { | 316 | case 3: { |
315 | m_menuTimer->stop(); | 317 | m_menuTimer->stop(); |
316 | TodoView::edit( checkItem(row)->uid() ); | 318 | TodoView::edit( checkItem(row)->uid() ); |
317 | break; | 319 | break; |
318 | } | 320 | } |
319 | } | 321 | } |
320 | 322 | ||
321 | 323 | ||
322 | } | 324 | } |
323 | void TableView::slotPressed(int row, int col, int, | 325 | void TableView::slotPressed(int row, int col, int, |
324 | const QPoint& point) { | 326 | const QPoint& point) { |
325 | 327 | ||
326 | /* TextColumn column */ | 328 | /* TextColumn column */ |
327 | if ( col == 2 && cellGeometry( row, col ).contains( point ) ) | 329 | if ( col == 2 && cellGeometry( row, col ).contains( point ) ) |
328 | m_menuTimer->start( 750, TRUE ); | 330 | m_menuTimer->start( 750, TRUE ); |
329 | } | 331 | } |
330 | void TableView::slotValueChanged( int, int ) { | 332 | void TableView::slotValueChanged( int, int ) { |
331 | qWarning("Value Changed"); | 333 | qWarning("Value Changed"); |
332 | } | 334 | } |
333 | void TableView::slotCurrentChanged(int, int ) { | 335 | void TableView::slotCurrentChanged(int, int ) { |
334 | m_menuTimer->stop(); | 336 | m_menuTimer->stop(); |
335 | } | 337 | } |
336 | /* | 338 | /* |
337 | * hardcode to column 0 | 339 | * hardcode to column 0 |
338 | */ | 340 | */ |
339 | CheckItem* TableView::checkItem( int row ) { | 341 | CheckItem* TableView::checkItem( int row ) { |
340 | CheckItem *i = static_cast<CheckItem*>( item( row, 0 ) ); | 342 | CheckItem *i = static_cast<CheckItem*>( item( row, 0 ) ); |
341 | return i; | 343 | return i; |
342 | } | 344 | } |
343 | DueTextItem* TableView::dueItem( int row ) { | 345 | DueTextItem* TableView::dueItem( int row ) { |
344 | DueTextItem* i = static_cast<DueTextItem*> ( item(row, 3 ) ); | 346 | DueTextItem* i = static_cast<DueTextItem*> ( item(row, 3 ) ); |
345 | return i; | 347 | return i; |
346 | } | 348 | } |
347 | QWidget* TableView::widget() { | 349 | QWidget* TableView::widget() { |
348 | return this; | 350 | return this; |
349 | } | 351 | } |
350 | /* | 352 | /* |
351 | * We need to overwrite sortColumn | 353 | * We need to overwrite sortColumn |
352 | * because we want to sort whole row | 354 | * because we want to sort whole row |
353 | * based | 355 | * based |
354 | */ | 356 | */ |
355 | void TableView::sortColumn( int row, bool asc, bool ) { | 357 | void TableView::sortColumn( int row, bool asc, bool ) { |
356 | QTable::sortColumn( row, asc, TRUE ); | 358 | QTable::sortColumn( row, asc, TRUE ); |
357 | 359 | ||
358 | } | 360 | } |
359 | void TableView::viewportPaintEvent( QPaintEvent* e) { | 361 | void TableView::viewportPaintEvent( QPaintEvent* e) { |
360 | qWarning("Paint event" ); | 362 | qWarning("Paint event" ); |
361 | if (m_enablePaint ) | 363 | if (m_enablePaint ) |
362 | QTable::viewportPaintEvent( e ); | 364 | QTable::viewportPaintEvent( e ); |
363 | } | 365 | } |
diff --git a/core/pim/todo/tableview.h b/core/pim/todo/tableview.h index 721b40b..1fa21b2 100644 --- a/core/pim/todo/tableview.h +++ b/core/pim/todo/tableview.h | |||
@@ -1,120 +1,119 @@ | |||
1 | /* | 1 | /* |
2 | =. This file is part of the OPIE Project | 2 | =. This file is part of the OPIE Project |
3 | .=l. Copyright (c) 2002 <> | 3 | .=l. Copyright (c) 2002 <> |
4 | .>+-= | 4 | .>+-= |
5 | _;:, .> :=|. This program is free software; you can | 5 | _;:, .> :=|. This program is free software; you can |
6 | .> <`_, > . <= redistribute it and/or modify it under | 6 | .> <`_, > . <= redistribute it and/or modify it under |
7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
8 | .="- .-=="i, .._ License as published by the Free Software | 8 | .="- .-=="i, .._ License as published by the Free Software |
9 | - . .-<_> .<> Foundation; either version 2 of the License, | 9 | - . .-<_> .<> Foundation; either version 2 of the License, |
10 | ._= =} : or (at your option) any later version. | 10 | ._= =} : or (at your option) any later version. |
11 | .%`+i> _;_. | 11 | .%`+i> _;_. |
12 | .i_,=:_. -<s. This program is distributed in the hope that | 12 | .i_,=:_. -<s. This program is distributed in the hope that |
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
14 | : .. .:, . . . without even the implied warranty of | 14 | : .. .:, . . . without even the implied warranty of |
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
17 | ..}^=.= = ; Library General Public License for more | 17 | ..}^=.= = ; Library General Public License for more |
18 | ++= -. .` .: details. | 18 | ++= -. .` .: details. |
19 | : = ...= . :.=- | 19 | : = ...= . :.=- |
20 | -. .:....=;==+<; You should have received a copy of the GNU | 20 | -. .:....=;==+<; You should have received a copy of the GNU |
21 | -_. . . )=. = Library General Public License along with | 21 | -_. . . )=. = Library General Public License along with |
22 | -- :-=` this library; see the file COPYING.LIB. | 22 | -- :-=` this library; see the file COPYING.LIB. |
23 | If not, write to the Free Software Foundation, | 23 | If not, write to the Free Software Foundation, |
24 | Inc., 59 Temple Place - Suite 330, | 24 | Inc., 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | 28 | ||
29 | #ifndef OPIE_TABLE_VIEW_H | 29 | #ifndef OPIE_TABLE_VIEW_H |
30 | #define OPIE_TABLE_VIEW_H | 30 | #define OPIE_TABLE_VIEW_H |
31 | 31 | ||
32 | #include <qtable.h> | 32 | #include <qtable.h> |
33 | #include <qmap.h> | 33 | #include <qmap.h> |
34 | 34 | ||
35 | #include "tableitems.h" | 35 | #include "tableitems.h" |
36 | #include "todoview.h" | 36 | #include "todoview.h" |
37 | 37 | ||
38 | class QTimer; | 38 | class QTimer; |
39 | 39 | ||
40 | namespace Todo { | 40 | namespace Todo { |
41 | class CheckItem; | 41 | class CheckItem; |
42 | class DueTextItem; | 42 | class DueTextItem; |
43 | class TableView : public QTable, public TodoView { | 43 | class TableView : public QTable, public TodoView { |
44 | Q_OBJECT | 44 | Q_OBJECT |
45 | public: | 45 | public: |
46 | TableView( MainWindow*, QWidget* parent ); | 46 | TableView( MainWindow*, QWidget* parent ); |
47 | ~TableView(); | 47 | ~TableView(); |
48 | 48 | ||
49 | void updateFromTable( const OTodo&, CheckItem* = 0 ); | 49 | void updateFromTable( const OTodo&, CheckItem* = 0 ); |
50 | OTodo find(int uid); | 50 | OTodo find(int uid); |
51 | 51 | ||
52 | QString type()const; | 52 | QString type()const; |
53 | int current(); | 53 | int current(); |
54 | QString currentRepresentation(); | 54 | QString currentRepresentation(); |
55 | 55 | ||
56 | void showOverDue( bool ); | 56 | void showOverDue( bool ); |
57 | void setTodos( OTodoAccess::List::Iterator it, | 57 | void updateView(); |
58 | OTodoAccess::List::Iterator end ); | ||
59 | void setTodo( int uid, const OTodo& ); | 58 | void setTodo( int uid, const OTodo& ); |
60 | void addEvent( const OTodo& event ); | 59 | void addEvent( const OTodo& event ); |
61 | void replaceEvent( const OTodo& ); | 60 | void replaceEvent( const OTodo& ); |
62 | void removeEvent( int uid ); | 61 | void removeEvent( int uid ); |
63 | void setShowCompleted( bool ); | 62 | void setShowCompleted( bool ); |
64 | void setShowDeadline( bool ); | 63 | void setShowDeadline( bool ); |
65 | 64 | ||
66 | void setShowCategory(const QString& =QString::null ); | 65 | void setShowCategory(const QString& =QString::null ); |
67 | void clear(); | 66 | void clear(); |
68 | void newDay(); | 67 | void newDay(); |
69 | QArray<int> completed(); | 68 | QArray<int> completed(); |
70 | QWidget* widget(); | 69 | QWidget* widget(); |
71 | void sortColumn(int, bool, bool ); | 70 | void sortColumn(int, bool, bool ); |
72 | private: | 71 | private: |
73 | /* reimplented for internal reasons */ | 72 | /* reimplented for internal reasons */ |
74 | void viewportPaintEvent( QPaintEvent* ); | 73 | void viewportPaintEvent( QPaintEvent* ); |
75 | inline void insertTodo( const OTodo&, int row ); | 74 | inline void insertTodo( const OTodo&, int row ); |
76 | CheckItem* checkItem( int row ); | 75 | CheckItem* checkItem( int row ); |
77 | DueTextItem* dueItem( int row ); | 76 | DueTextItem* dueItem( int row ); |
78 | QTimer *m_menuTimer; | 77 | QTimer *m_menuTimer; |
79 | QMap<int, CheckItem*> m_cache; | 78 | QMap<int, CheckItem*> m_cache; |
80 | bool m_enablePaint:1; | 79 | bool m_enablePaint:1; |
81 | 80 | ||
82 | private slots: | 81 | private slots: |
83 | void slotShowMenu(); | 82 | void slotShowMenu(); |
84 | void slotClicked(int, int, int, | 83 | void slotClicked(int, int, int, |
85 | const QPoint& ); | 84 | const QPoint& ); |
86 | void slotPressed(int, int, int, | 85 | void slotPressed(int, int, int, |
87 | const QPoint& ); | 86 | const QPoint& ); |
88 | void slotValueChanged(int, int); | 87 | void slotValueChanged(int, int); |
89 | void slotCurrentChanged(int, int ); | 88 | void slotCurrentChanged(int, int ); |
90 | }; | 89 | }; |
91 | inline void TableView::insertTodo( const OTodo& event, int row ) { | 90 | inline void TableView::insertTodo( const OTodo& event, int row ) { |
92 | 91 | ||
93 | 92 | ||
94 | QString sortKey = (char) ( (event.isCompleted() ? 'a' : 'A' ) | 93 | QString sortKey = (char) ( (event.isCompleted() ? 'a' : 'A' ) |
95 | + event.priority() ) | 94 | + event.priority() ) |
96 | + Qtopia::buildSortKey( event.description() ); | 95 | + Qtopia::buildSortKey( event.description() ); |
97 | CheckItem *chk = new CheckItem( this, sortKey, event.uid(), event.categories() ); | 96 | CheckItem *chk = new CheckItem( this, sortKey, event.uid(), event.categories() ); |
98 | chk->setChecked( event.isCompleted() ); | 97 | chk->setChecked( event.isCompleted() ); |
99 | 98 | ||
100 | ComboItem *cmb = new ComboItem(this, QTableItem::WhenCurrent ); | 99 | ComboItem *cmb = new ComboItem(this, QTableItem::WhenCurrent ); |
101 | cmb->setText( QString::number( event.priority() ) ); | 100 | cmb->setText( QString::number( event.priority() ) ); |
102 | 101 | ||
103 | QString sum = event.summary(); | 102 | QString sum = event.summary(); |
104 | QTableItem* ti = new TodoTextItem( this, sum.isEmpty() ? | 103 | QTableItem* ti = new TodoTextItem( this, sum.isEmpty() ? |
105 | event.description().left(40).simplifyWhiteSpace() : | 104 | event.description().left(40).simplifyWhiteSpace() : |
106 | sum ); | 105 | sum ); |
107 | ti->setReplaceable( FALSE ); | 106 | ti->setReplaceable( FALSE ); |
108 | 107 | ||
109 | DueTextItem *due = new DueTextItem(this, event ); | 108 | DueTextItem *due = new DueTextItem(this, event ); |
110 | 109 | ||
111 | setItem( row, 0, chk ); | 110 | setItem( row, 0, chk ); |
112 | setItem( row, 1, cmb ); | 111 | setItem( row, 1, cmb ); |
113 | setItem( row, 2, ti ); | 112 | setItem( row, 2, ti ); |
114 | setItem( row, 3, due ); | 113 | setItem( row, 3, due ); |
115 | 114 | ||
116 | m_cache.insert( event.uid(), chk ); | 115 | m_cache.insert( event.uid(), chk ); |
117 | } | 116 | } |
118 | }; | 117 | }; |
119 | 118 | ||
120 | #endif | 119 | #endif |
diff --git a/core/pim/todo/todomanager.cpp b/core/pim/todo/todomanager.cpp index 8e3fa88..ebf9e8a 100644 --- a/core/pim/todo/todomanager.cpp +++ b/core/pim/todo/todomanager.cpp | |||
@@ -1,125 +1,124 @@ | |||
1 | /* | 1 | /* |
2 | =. This file is part of the OPIE Project | 2 | =. This file is part of the OPIE Project |
3 | .=l. Copyright (c) 2002 <> | 3 | .=l. Copyright (c) 2002 <> |
4 | .>+-= | 4 | .>+-= |
5 | _;:, .> :=|. This program is free software; you can | 5 | _;:, .> :=|. This program is free software; you can |
6 | .> <`_, > . <= redistribute it and/or modify it under | 6 | .> <`_, > . <= redistribute it and/or modify it under |
7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
8 | .="- .-=="i, .._ License as published by the Free Software | 8 | .="- .-=="i, .._ License as published by the Free Software |
9 | - . .-<_> .<> Foundation; either version 2 of the License, | 9 | - . .-<_> .<> Foundation; either version 2 of the License, |
10 | ._= =} : or (at your option) any later version. | 10 | ._= =} : or (at your option) any later version. |
11 | .%`+i> _;_. | 11 | .%`+i> _;_. |
12 | .i_,=:_. -<s. This program is distributed in the hope that | 12 | .i_,=:_. -<s. This program is distributed in the hope that |
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
14 | : .. .:, . . . without even the implied warranty of | 14 | : .. .:, . . . without even the implied warranty of |
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
17 | ..}^=.= = ; Library General Public License for more | 17 | ..}^=.= = ; Library General Public License for more |
18 | ++= -. .` .: details. | 18 | ++= -. .` .: details. |
19 | : = ...= . :.=- | 19 | : = ...= . :.=- |
20 | -. .:....=;==+<; You should have received a copy of the GNU | 20 | -. .:....=;==+<; You should have received a copy of the GNU |
21 | -_. . . )=. = Library General Public License along with | 21 | -_. . . )=. = Library General Public License along with |
22 | -- :-=` this library; see the file COPYING.LIB. | 22 | -- :-=` this library; see the file COPYING.LIB. |
23 | If not, write to the Free Software Foundation, | 23 | If not, write to the Free Software Foundation, |
24 | Inc., 59 Temple Place - Suite 330, | 24 | Inc., 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | #include <qdatetime.h> | 28 | #include <qdatetime.h> |
29 | #include <qpe/categoryselect.h> | 29 | #include <qpe/categoryselect.h> |
30 | 30 | ||
31 | #include "todomanager.h" | 31 | #include "todomanager.h" |
32 | 32 | ||
33 | using namespace Todo; | 33 | using namespace Todo; |
34 | 34 | ||
35 | TodoManager::TodoManager( QObject *obj ) | 35 | TodoManager::TodoManager( QObject *obj ) |
36 | : QObject( obj ) { | 36 | : QObject( obj ) { |
37 | m_db = 0l; | 37 | m_db = 0l; |
38 | QTime time; | 38 | QTime time; |
39 | time.start(); | 39 | time.start(); |
40 | int el = time.elapsed(); | 40 | int el = time.elapsed(); |
41 | qWarning("QTimer for loading %d", el/1000 ); | 41 | qWarning("QTimer for loading %d", el/1000 ); |
42 | } | 42 | } |
43 | TodoManager::~TodoManager() { | 43 | TodoManager::~TodoManager() { |
44 | delete m_db; | 44 | delete m_db; |
45 | } | 45 | } |
46 | OTodo TodoManager::event(int uid ) { | 46 | OTodo TodoManager::event(int uid ) { |
47 | return m_db->find( uid ); | 47 | return m_db->find( uid ); |
48 | } | 48 | } |
49 | void TodoManager::updateList() { | 49 | void TodoManager::updateList() { |
50 | m_list = m_db->allRecords(); | 50 | m_list = m_db->allRecords(); |
51 | } | 51 | } |
52 | OTodoAccess::List::Iterator TodoManager::begin() { | 52 | OTodoAccess::List TodoManager::list() const{ |
53 | m_it = m_list.begin(); | 53 | return m_list; |
54 | return m_it; | ||
55 | } | 54 | } |
56 | OTodoAccess::List::Iterator TodoManager::end() { | 55 | OTodoAccess::List TodoManager::sorted( bool asc, int so, int f, int cat ) { |
57 | return m_list.end(); | 56 | return m_db->sorted( asc, so, f, cat ); |
58 | } | 57 | } |
59 | OTodoAccess::List::Iterator TodoManager::overDue() { | 58 | OTodoAccess::List::Iterator TodoManager::overDue() { |
60 | int filter = 2 & 1; | 59 | int filter = 2 | 1; |
61 | m_list = m_db->sorted(m_asc, m_sortOrder, filter, m_ca ); | 60 | m_list = m_db->sorted(m_asc, m_sortOrder, filter, m_ca ); |
62 | m_it = m_list.begin(); | 61 | m_it = m_list.begin(); |
63 | return m_it; | 62 | return m_it; |
64 | } | 63 | } |
65 | OTodoAccess::List::Iterator TodoManager::fromTo( const QDate& start, | 64 | OTodoAccess::List::Iterator TodoManager::fromTo( const QDate& start, |
66 | const QDate& end ) { | 65 | const QDate& end ) { |
67 | m_list = m_db->effectiveToDos( start, end ); | 66 | m_list = m_db->effectiveToDos( start, end ); |
68 | m_it = m_list.begin(); | 67 | m_it = m_list.begin(); |
69 | return m_it; | 68 | return m_it; |
70 | } | 69 | } |
71 | OTodoAccess::List::Iterator TodoManager::query( const OTodo& ev, int query ) { | 70 | OTodoAccess::List::Iterator TodoManager::query( const OTodo& ev, int query ) { |
72 | m_list = m_db->queryByExample( ev, query ); | 71 | m_list = m_db->queryByExample( ev, query ); |
73 | m_it = m_list.begin(); | 72 | m_it = m_list.begin(); |
74 | return m_it; | 73 | return m_it; |
75 | } | 74 | } |
76 | OTodoAccess* TodoManager::todoDB() { | 75 | OTodoAccess* TodoManager::todoDB() { |
77 | return m_db; | 76 | return m_db; |
78 | } | 77 | } |
79 | void TodoManager::add( const OTodo& ev ) { | 78 | void TodoManager::add( const OTodo& ev ) { |
80 | m_db->add( ev ); | 79 | m_db->add( ev ); |
81 | } | 80 | } |
82 | void TodoManager::update( int, const SmallTodo& ) { | 81 | void TodoManager::update( int, const SmallTodo& ) { |
83 | 82 | ||
84 | } | 83 | } |
85 | void TodoManager::update( int, const OTodo& ev) { | 84 | void TodoManager::update( int, const OTodo& ev) { |
86 | m_db->replace( ev ); | 85 | m_db->replace( ev ); |
87 | } | 86 | } |
88 | void TodoManager::remove( int uid ) { | 87 | void TodoManager::remove( int uid ) { |
89 | m_db->remove( uid ); | 88 | m_db->remove( uid ); |
90 | } | 89 | } |
91 | void TodoManager::removeAll() { | 90 | void TodoManager::removeAll() { |
92 | m_db->clear(); | 91 | m_db->clear(); |
93 | } | 92 | } |
94 | void TodoManager::save() { | 93 | void TodoManager::save() { |
95 | m_db->save(); | 94 | m_db->save(); |
96 | } | 95 | } |
97 | bool TodoManager::saveAll() { | 96 | bool TodoManager::saveAll() { |
98 | return m_db->save(); | 97 | return m_db->save(); |
99 | } | 98 | } |
100 | void TodoManager::reload() { | 99 | void TodoManager::reload() { |
101 | m_db->reload(); | 100 | m_db->reload(); |
102 | } | 101 | } |
103 | QStringList TodoManager::categories() { | 102 | QStringList TodoManager::categories() { |
104 | m_cat.load(categoryFileName() ); | 103 | m_cat.load(categoryFileName() ); |
105 | return m_cat.labels( "Todo List"); | 104 | return m_cat.labels( "Todo List"); |
106 | } | 105 | } |
107 | /* | 106 | /* |
108 | * we rely on load beeing called from populateCategories | 107 | * we rely on load beeing called from populateCategories |
109 | */ | 108 | */ |
110 | int TodoManager::catId( const QString& cats ) { | 109 | int TodoManager::catId( const QString& cats ) { |
111 | return m_cat.id( "Todo List", cats ); | 110 | return m_cat.id( "Todo List", cats ); |
112 | } | 111 | } |
113 | void TodoManager::remove( const QArray<int>& ids) { | 112 | void TodoManager::remove( const QArray<int>& ids) { |
114 | for (uint i=0; i < ids.size(); i++ ) | 113 | for (uint i=0; i < ids.size(); i++ ) |
115 | remove( ids[i] ); | 114 | remove( ids[i] ); |
116 | } | 115 | } |
117 | bool TodoManager::isLoaded()const { | 116 | bool TodoManager::isLoaded()const { |
118 | return (m_db == 0 ); | 117 | return (m_db == 0 ); |
119 | } | 118 | } |
120 | void TodoManager::load() { | 119 | void TodoManager::load() { |
121 | if (!m_db) { | 120 | if (!m_db) { |
122 | m_db = new OTodoAccess(); | 121 | m_db = new OTodoAccess(); |
123 | m_db->load(); | 122 | m_db->load(); |
124 | } | 123 | } |
125 | } | 124 | } |
diff --git a/core/pim/todo/todomanager.h b/core/pim/todo/todomanager.h index 1f9e288..b03b598 100644 --- a/core/pim/todo/todomanager.h +++ b/core/pim/todo/todomanager.h | |||
@@ -1,107 +1,106 @@ | |||
1 | /* | 1 | /* |
2 | =. This file is part of the OPIE Project | 2 | =. This file is part of the OPIE Project |
3 | .=l. Copyright (c) 2002 <> | 3 | .=l. Copyright (c) 2002 <> |
4 | .>+-= | 4 | .>+-= |
5 | _;:, .> :=|. This program is free software; you can | 5 | _;:, .> :=|. This program is free software; you can |
6 | .> <`_, > . <= redistribute it and/or modify it under | 6 | .> <`_, > . <= redistribute it and/or modify it under |
7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
8 | .="- .-=="i, .._ License as published by the Free Software | 8 | .="- .-=="i, .._ License as published by the Free Software |
9 | - . .-<_> .<> Foundation; either version 2 of the License, | 9 | - . .-<_> .<> Foundation; either version 2 of the License, |
10 | ._= =} : or (at your option) any later version. | 10 | ._= =} : or (at your option) any later version. |
11 | .%`+i> _;_. | 11 | .%`+i> _;_. |
12 | .i_,=:_. -<s. This program is distributed in the hope that | 12 | .i_,=:_. -<s. This program is distributed in the hope that |
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
14 | : .. .:, . . . without even the implied warranty of | 14 | : .. .:, . . . without even the implied warranty of |
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
17 | ..}^=.= = ; Library General Public License for more | 17 | ..}^=.= = ; Library General Public License for more |
18 | ++= -. .` .: details. | 18 | ++= -. .` .: details. |
19 | : = ...= . :.=- | 19 | : = ...= . :.=- |
20 | -. .:....=;==+<; You should have received a copy of the GNU | 20 | -. .:....=;==+<; You should have received a copy of the GNU |
21 | -_. . . )=. = Library General Public License along with | 21 | -_. . . )=. = Library General Public License along with |
22 | -- :-=` this library; see the file COPYING.LIB. | 22 | -- :-=` this library; see the file COPYING.LIB. |
23 | If not, write to the Free Software Foundation, | 23 | If not, write to the Free Software Foundation, |
24 | Inc., 59 Temple Place - Suite 330, | 24 | Inc., 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | 28 | ||
29 | #ifndef OPIE_TODO_MANAGER_H | 29 | #ifndef OPIE_TODO_MANAGER_H |
30 | #define OPIE_TODO_MANAGER_H | 30 | #define OPIE_TODO_MANAGER_H |
31 | 31 | ||
32 | #include <qarray.h> | 32 | #include <qarray.h> |
33 | #include <qobject.h> | 33 | #include <qobject.h> |
34 | #include <qstring.h> | 34 | #include <qstring.h> |
35 | 35 | ||
36 | #include <qpe/categories.h> | 36 | #include <qpe/categories.h> |
37 | 37 | ||
38 | #include <opie/otodo.h> | 38 | #include <opie/otodo.h> |
39 | #include <opie/otodoaccess.h> | 39 | #include <opie/otodoaccess.h> |
40 | 40 | ||
41 | #include "smalltodo.h" | 41 | #include "smalltodo.h" |
42 | 42 | ||
43 | 43 | ||
44 | namespace Todo { | 44 | namespace Todo { |
45 | class TodoManager : public QObject{ | 45 | class TodoManager : public QObject{ |
46 | Q_OBJECT | 46 | Q_OBJECT |
47 | public: | 47 | public: |
48 | bool isLoaded()const; | 48 | bool isLoaded()const; |
49 | void load(); | 49 | void load(); |
50 | TodoManager(QObject* obj = 0); | 50 | TodoManager(QObject* obj = 0); |
51 | ~TodoManager(); | 51 | ~TodoManager(); |
52 | 52 | ||
53 | QStringList categories()/*const*/; | 53 | QStringList categories()/*const*/; |
54 | int catId(const QString&); | 54 | int catId(const QString&); |
55 | OTodo event(int uid ); | 55 | OTodo event(int uid ); |
56 | 56 | ||
57 | void updateList(); | 57 | void updateList(); |
58 | /** returns the iterator sorted if set sorted*/ | 58 | /** returns the iterator sorted if set sorted*/ |
59 | OTodoAccess::List::Iterator begin(); | 59 | OTodoAccess::List list()const; |
60 | OTodoAccess::List::Iterator end(); | 60 | OTodoAccess::List sorted( bool asc, int so, int f, int cat ); |
61 | OTodoAccess::List& list(); | ||
62 | 61 | ||
63 | OTodoAccess::List::Iterator overDue(); | 62 | OTodoAccess::List::Iterator overDue(); |
64 | OTodoAccess::List::Iterator fromTo( const QDate& start, | 63 | OTodoAccess::List::Iterator fromTo( const QDate& start, |
65 | const QDate& end ); | 64 | const QDate& end ); |
66 | OTodoAccess::List::Iterator query( const OTodo& ev, int query ); | 65 | OTodoAccess::List::Iterator query( const OTodo& ev, int query ); |
67 | 66 | ||
68 | void setCategory( bool sort, int category = -1); | 67 | void setCategory( bool sort, int category = -1); |
69 | void setShowOverDue( bool show ); | 68 | void setShowOverDue( bool show ); |
70 | void setSortOrder( int sortOrder ); | 69 | void setSortOrder( int sortOrder ); |
71 | void setSortASC( bool ); | 70 | void setSortASC( bool ); |
72 | void sort(); | 71 | void sort(); |
73 | 72 | ||
74 | OTodoAccess* todoDB(); | 73 | OTodoAccess* todoDB(); |
75 | bool saveAll(); | 74 | bool saveAll(); |
76 | 75 | ||
77 | 76 | ||
78 | signals: | 77 | signals: |
79 | void update(); | 78 | void update(); |
80 | void updateCategories(); | 79 | void updateCategories(); |
81 | 80 | ||
82 | public slots: | 81 | public slots: |
83 | void add( const OTodo& ); | 82 | void add( const OTodo& ); |
84 | void update( int uid, const SmallTodo& ); | 83 | void update( int uid, const SmallTodo& ); |
85 | void update( int uid, const OTodo& ); | 84 | void update( int uid, const OTodo& ); |
86 | void remove( int uid ); | 85 | void remove( int uid ); |
87 | void remove( const QArray<int>& ); | 86 | void remove( const QArray<int>& ); |
88 | void removeAll(); | 87 | void removeAll(); |
89 | void reload(); | 88 | void reload(); |
90 | void save(); | 89 | void save(); |
91 | 90 | ||
92 | private: | 91 | private: |
93 | OTodoAccess* m_db; | 92 | OTodoAccess* m_db; |
94 | OTodoAccess::List m_list; | 93 | OTodoAccess::List m_list; |
95 | OTodoAccess::List::Iterator m_it; | 94 | OTodoAccess::List::Iterator m_it; |
96 | OTodoAccess::List m_sorted; | 95 | OTodoAccess::List m_sorted; |
97 | Categories m_cat; | 96 | Categories m_cat; |
98 | int m_ca; | 97 | int m_ca; |
99 | /* sort cat */ | 98 | /* sort cat */ |
100 | bool m_shCat; | 99 | bool m_shCat; |
101 | int m_sortOrder; | 100 | int m_sortOrder; |
102 | bool m_asc; | 101 | bool m_asc; |
103 | 102 | ||
104 | }; | 103 | }; |
105 | }; | 104 | }; |
106 | 105 | ||
107 | #endif | 106 | #endif |
diff --git a/core/pim/todo/todoview.cpp b/core/pim/todo/todoview.cpp index 5362b23..b77baed 100644 --- a/core/pim/todo/todoview.cpp +++ b/core/pim/todo/todoview.cpp | |||
@@ -1,62 +1,77 @@ | |||
1 | #include "mainwindow.h" | 1 | #include "mainwindow.h" |
2 | 2 | ||
3 | #include "todoview.h" | 3 | #include "todoview.h" |
4 | 4 | ||
5 | using namespace Todo; | 5 | using namespace Todo; |
6 | 6 | ||
7 | TodoView::TodoView( MainWindow* win ) | 7 | TodoView::TodoView( MainWindow* win ) |
8 | : m_main( win ) | 8 | : m_main( win ) |
9 | { | 9 | { |
10 | hack = new InternQtHack; | 10 | hack = new InternQtHack; |
11 | m_asc = false; | ||
12 | m_sortOrder = -1; | ||
11 | } | 13 | } |
12 | TodoView::~TodoView() { | 14 | TodoView::~TodoView() { |
13 | delete hack; | 15 | delete hack; |
14 | }; | 16 | }; |
15 | 17 | ||
16 | void TodoView::connectShow(QObject* obj, | 18 | void TodoView::connectShow(QObject* obj, |
17 | const char* slot ) { | 19 | const char* slot ) { |
18 | QObject::connect( hack, SIGNAL(showTodo(int) ), | 20 | QObject::connect( hack, SIGNAL(showTodo(int) ), |
19 | obj, slot ); | 21 | obj, slot ); |
20 | } | 22 | } |
21 | void TodoView::connectEdit( QObject* obj, | 23 | void TodoView::connectEdit( QObject* obj, |
22 | const char* slot ) { | 24 | const char* slot ) { |
23 | QObject::connect( hack, SIGNAL(edit(int) ), | 25 | QObject::connect( hack, SIGNAL(edit(int) ), |
24 | obj, slot ); | 26 | obj, slot ); |
25 | } | 27 | } |
26 | void TodoView::connectUpdateSmall( QObject* obj, | 28 | void TodoView::connectUpdateSmall( QObject* obj, |
27 | const char* slot ) { | 29 | const char* slot ) { |
28 | QObject::connect( hack, SIGNAL(update(int, const Todo::SmallTodo& ) ), | 30 | QObject::connect( hack, SIGNAL(update(int, const Todo::SmallTodo& ) ), |
29 | obj, slot ); | 31 | obj, slot ); |
30 | } | 32 | } |
31 | void TodoView::connectUpdateBig( QObject* obj, | 33 | void TodoView::connectUpdateBig( QObject* obj, |
32 | const char* slot ) { | 34 | const char* slot ) { |
33 | QObject::connect( hack, SIGNAL(update(int, const OTodo& ) ), | 35 | QObject::connect( hack, SIGNAL(update(int, const OTodo& ) ), |
34 | obj, slot ); | 36 | obj, slot ); |
35 | } | 37 | } |
36 | void TodoView::connectUpdateView( QObject* obj, | 38 | void TodoView::connectUpdateView( QObject* obj, |
37 | const char* slot ) { | 39 | const char* slot ) { |
38 | QObject::connect( hack, SIGNAL(update(QWidget*) ), | 40 | QObject::connect( hack, SIGNAL(update(QWidget*) ), |
39 | obj, slot ); | 41 | obj, slot ); |
40 | } | 42 | } |
41 | void TodoView::connectRemove( QObject* obj, | 43 | void TodoView::connectRemove( QObject* obj, |
42 | const char* slot ) { | 44 | const char* slot ) { |
43 | QObject::connect( hack, SIGNAL(remove(int) ), | 45 | QObject::connect( hack, SIGNAL(remove(int) ), |
44 | obj, slot ); | 46 | obj, slot ); |
45 | } | 47 | } |
46 | MainWindow* TodoView::todoWindow() { | 48 | MainWindow* TodoView::todoWindow() { |
47 | return m_main; | 49 | return m_main; |
48 | } | 50 | } |
49 | 51 | ||
50 | OTodo TodoView::event(int uid ) { return m_main->event( uid ); } | 52 | OTodo TodoView::event(int uid ) { return m_main->event( uid ); } |
51 | OTodoAccess::List::Iterator TodoView::begin() { | 53 | OTodoAccess::List TodoView::list(){ |
52 | m_main->updateList(); | 54 | todoWindow()->updateList(); |
53 | return m_main->begin(); | 55 | return todoWindow()->list(); |
56 | } | ||
57 | OTodoAccess::List TodoView::sorted(){ | ||
58 | return m_sort; | ||
59 | } | ||
60 | void TodoView::sort() { | ||
61 | m_sort = todoWindow()->sorted(m_asc,m_sortOrder ); | ||
62 | } | ||
63 | void TodoView::sort(int sort) { | ||
64 | m_sort = todoWindow()->sorted(m_asc, m_sortOrder, sort ); | ||
65 | } | ||
66 | void TodoView::setSortOrder( int order ) { | ||
67 | m_sortOrder = order; | ||
68 | } | ||
69 | void TodoView::setAscending( bool b ) { | ||
70 | m_asc = b; | ||
54 | } | 71 | } |
55 | OTodoAccess::List::Iterator TodoView::end() { return m_main->end(); } | ||
56 | |||
57 | void TodoView::update(int uid, const SmallTodo& to ) { | 72 | void TodoView::update(int uid, const SmallTodo& to ) { |
58 | //m_main->slotUpate1( uid, to ); | 73 | //m_main->slotUpate1( uid, to ); |
59 | } | 74 | } |
60 | void TodoView::update(int uid, const OTodo& ev ) { | 75 | void TodoView::update(int uid, const OTodo& ev ) { |
61 | m_main->updateTodo( ev ); | 76 | m_main->updateTodo( ev ); |
62 | } | 77 | } |
diff --git a/core/pim/todo/todoview.h b/core/pim/todo/todoview.h index e4985a7..81ace3a 100644 --- a/core/pim/todo/todoview.h +++ b/core/pim/todo/todoview.h | |||
@@ -1,178 +1,188 @@ | |||
1 | /* | 1 | /* |
2 | =. This file is part of the OPIE Project | 2 | =. This file is part of the OPIE Project |
3 | .=l. Copyright (c) 2002 <> | 3 | .=l. Copyright (c) 2002 <> |
4 | .>+-= | 4 | .>+-= |
5 | _;:, .> :=|. This program is free software; you can | 5 | _;:, .> :=|. This program is free software; you can |
6 | .> <`_, > . <= redistribute it and/or modify it under | 6 | .> <`_, > . <= redistribute it and/or modify it under |
7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
8 | .="- .-=="i, .._ License as published by the Free Software | 8 | .="- .-=="i, .._ License as published by the Free Software |
9 | - . .-<_> .<> Foundation; either version 2 of the License, | 9 | - . .-<_> .<> Foundation; either version 2 of the License, |
10 | ._= =} : or (at your option) any later version. | 10 | ._= =} : or (at your option) any later version. |
11 | .%`+i> _;_. | 11 | .%`+i> _;_. |
12 | .i_,=:_. -<s. This program is distributed in the hope that | 12 | .i_,=:_. -<s. This program is distributed in the hope that |
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
14 | : .. .:, . . . without even the implied warranty of | 14 | : .. .:, . . . without even the implied warranty of |
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
17 | ..}^=.= = ; Library General Public License for more | 17 | ..}^=.= = ; Library General Public License for more |
18 | ++= -. .` .: details. | 18 | ++= -. .` .: details. |
19 | : = ...= . :.=- | 19 | : = ...= . :.=- |
20 | -. .:....=;==+<; You should have received a copy of the GNU | 20 | -. .:....=;==+<; You should have received a copy of the GNU |
21 | -_. . . )=. = Library General Public License along with | 21 | -_. . . )=. = Library General Public License along with |
22 | -- :-=` this library; see the file COPYING.LIB. | 22 | -- :-=` this library; see the file COPYING.LIB. |
23 | If not, write to the Free Software Foundation, | 23 | If not, write to the Free Software Foundation, |
24 | Inc., 59 Temple Place - Suite 330, | 24 | Inc., 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | 28 | ||
29 | #ifndef TODO_VIEW_H | 29 | #ifndef TODO_VIEW_H |
30 | #define TODO_VIEW_H | 30 | #define TODO_VIEW_H |
31 | 31 | ||
32 | #include <qarray.h> | 32 | #include <qarray.h> |
33 | #include <qstring.h> | 33 | #include <qstring.h> |
34 | #include <qvaluelist.h> | 34 | #include <qvaluelist.h> |
35 | #include <qwidget.h> | 35 | #include <qwidget.h> |
36 | 36 | ||
37 | #include <opie/otodoaccess.h> | 37 | #include <opie/otodoaccess.h> |
38 | 38 | ||
39 | #include "smalltodo.h" | 39 | #include "smalltodo.h" |
40 | 40 | ||
41 | 41 | ||
42 | namespace Todo { | 42 | namespace Todo { |
43 | 43 | ||
44 | /** | 44 | /** |
45 | * According to tronical it's not possible | 45 | * According to tronical it's not possible |
46 | * to have Q_OBJECT in a template at all | 46 | * to have Q_OBJECT in a template at all |
47 | * so this is a hack widget not meant | 47 | * so this is a hack widget not meant |
48 | * to be public | 48 | * to be public |
49 | */ | 49 | */ |
50 | class InternQtHack : public QObject { | 50 | class InternQtHack : public QObject { |
51 | Q_OBJECT | 51 | Q_OBJECT |
52 | public: | 52 | public: |
53 | InternQtHack() : QObject() {}; | 53 | InternQtHack() : QObject() {}; |
54 | void emitShow(int uid) { emit showTodo(uid); } | 54 | void emitShow(int uid) { emit showTodo(uid); } |
55 | void emitEdit(int uid) { emit edit(uid ); } | 55 | void emitEdit(int uid) { emit edit(uid ); } |
56 | void emitUpdate( int uid, | 56 | void emitUpdate( int uid, |
57 | const SmallTodo& to) { | 57 | const SmallTodo& to) { |
58 | emit update(uid, to ); | 58 | emit update(uid, to ); |
59 | } | 59 | } |
60 | void emitUpdate( int uid, | 60 | void emitUpdate( int uid, |
61 | const OTodo& ev ){ | 61 | const OTodo& ev ){ |
62 | emit update(uid, ev ); | 62 | emit update(uid, ev ); |
63 | } | 63 | } |
64 | void emitRemove( int uid ) { | 64 | void emitRemove( int uid ) { |
65 | emit remove( uid ); | 65 | emit remove( uid ); |
66 | } | 66 | } |
67 | void emitUpdate( QWidget* wid ) { | 67 | void emitUpdate( QWidget* wid ) { |
68 | emit update( wid ); | 68 | emit update( wid ); |
69 | } | 69 | } |
70 | signals: | 70 | signals: |
71 | void showTodo(int uid ); | 71 | void showTodo(int uid ); |
72 | void edit(int uid ); | 72 | void edit(int uid ); |
73 | void update( int uid, const Todo::SmallTodo& ); | 73 | void update( int uid, const Todo::SmallTodo& ); |
74 | void update( int uid, const OTodo& ); | 74 | void update( int uid, const OTodo& ); |
75 | /* sorry you need to cast */; | 75 | /* sorry you need to cast */; |
76 | void update( QWidget* wid ); | 76 | void update( QWidget* wid ); |
77 | void remove( int uid ); | 77 | void remove( int uid ); |
78 | 78 | ||
79 | }; | 79 | }; |
80 | class MainWindow; | 80 | class MainWindow; |
81 | 81 | ||
82 | /** | 82 | /** |
83 | * due to inheretince problems we need this base class | 83 | * due to inheretince problems we need this base class |
84 | */ | 84 | */ |
85 | class ViewBase { | 85 | class ViewBase { |
86 | public: | 86 | public: |
87 | virtual QWidget* widget() = 0; | 87 | virtual QWidget* widget() = 0; |
88 | virtual QString type()const = 0; | 88 | virtual QString type()const = 0; |
89 | virtual int current() = 0; | 89 | virtual int current() = 0; |
90 | virtual QString currentRepresentation() = 0; | 90 | virtual QString currentRepresentation() = 0; |
91 | virtual void showOverDue( bool ) = 0; | 91 | virtual void showOverDue( bool ) = 0; |
92 | virtual void setTodos( OTodoAccess::List::Iterator it, | 92 | |
93 | OTodoAccess::List::Iterator end ) = 0; | 93 | /* |
94 | * update the view | ||
95 | */ | ||
96 | virtual void updateView() = 0; | ||
94 | 97 | ||
95 | virtual void addEvent( const OTodo& ) = 0; | 98 | virtual void addEvent( const OTodo& ) = 0; |
96 | virtual void replaceEvent( const OTodo& ) = 0; | 99 | virtual void replaceEvent( const OTodo& ) = 0; |
97 | virtual void removeEvent( int uid ) = 0; | 100 | virtual void removeEvent( int uid ) = 0; |
98 | virtual void setShowCompleted( bool ) = 0; | 101 | virtual void setShowCompleted( bool ) = 0; |
99 | virtual void setShowDeadline( bool ) = 0; | 102 | virtual void setShowDeadline( bool ) = 0; |
100 | virtual void setShowCategory( const QString& = QString::null ) = 0; | 103 | virtual void setShowCategory( const QString& = QString::null ) = 0; |
101 | virtual void clear() = 0; | 104 | virtual void clear() = 0; |
102 | virtual QArray<int> completed() = 0; | 105 | virtual QArray<int> completed() = 0; |
103 | virtual void newDay() = 0; | 106 | virtual void newDay() = 0; |
104 | 107 | ||
105 | virtual void connectShow( QObject*, const char* ) = 0; | 108 | virtual void connectShow( QObject*, const char* ) = 0; |
106 | virtual void connectEdit( QObject*, const char* ) = 0; | 109 | virtual void connectEdit( QObject*, const char* ) = 0; |
107 | virtual void connectUpdateSmall( QObject*, const char* ) = 0; | 110 | virtual void connectUpdateSmall( QObject*, const char* ) = 0; |
108 | virtual void connectUpdateBig( QObject*, const char* ) = 0; | 111 | virtual void connectUpdateBig( QObject*, const char* ) = 0; |
109 | virtual void connectUpdateView( QObject*, const char*) = 0; | 112 | virtual void connectUpdateView( QObject*, const char*) = 0; |
110 | virtual void connectRemove( QObject*, const char* ) = 0; | 113 | virtual void connectRemove( QObject*, const char* ) = 0; |
111 | 114 | ||
112 | }; | 115 | }; |
113 | 116 | ||
114 | /** | 117 | /** |
115 | * A base class for all TodoView which are showing | 118 | * A base class for all TodoView which are showing |
116 | * a list of todos. | 119 | * a list of todos. |
117 | * Either in a QTable, QListView or any other QWidget | 120 | * Either in a QTable, QListView or any other QWidget |
118 | * derived class | 121 | * derived class |
119 | * Through the MainWindow( dispatcher ) one can access | 122 | * Through the MainWindow( dispatcher ) one can access |
120 | * the relevant informations | 123 | * the relevant informations |
121 | * | 124 | * |
122 | * It's not possible to have signal and slots from within | 125 | * It's not possible to have signal and slots from within |
123 | * templates this way you've to register for a signal | 126 | * templates this way you've to register for a signal |
124 | */ | 127 | */ |
125 | class TodoView : public ViewBase{ | 128 | class TodoView : public ViewBase{ |
126 | 129 | ||
127 | public: | 130 | public: |
128 | /** | 131 | /** |
129 | * c'tor | 132 | * c'tor |
130 | */ | 133 | */ |
131 | TodoView( MainWindow* win ); | 134 | TodoView( MainWindow* win ); |
132 | 135 | ||
133 | /** | 136 | /** |
134 | *d'tor | 137 | *d'tor |
135 | */ | 138 | */ |
136 | virtual ~TodoView(); | 139 | virtual ~TodoView(); |
137 | 140 | ||
138 | /* connect to the show signal */ | 141 | /* connect to the show signal */ |
139 | void connectShow(QObject* obj, | 142 | void connectShow(QObject* obj, |
140 | const char* slot ); | 143 | const char* slot ); |
141 | 144 | ||
142 | /* connect to edit */ | 145 | /* connect to edit */ |
143 | void connectEdit( QObject* obj, | 146 | void connectEdit( QObject* obj, |
144 | const char* slot ); | 147 | const char* slot ); |
145 | void connectUpdateSmall( QObject* obj, | 148 | void connectUpdateSmall( QObject* obj, |
146 | const char* slot ); | 149 | const char* slot ); |
147 | void connectUpdateBig( QObject* obj, | 150 | void connectUpdateBig( QObject* obj, |
148 | const char* slot ) ; | 151 | const char* slot ) ; |
149 | void connectUpdateView( QObject* obj, | 152 | void connectUpdateView( QObject* obj, |
150 | const char* slot ); | 153 | const char* slot ); |
151 | void connectRemove( QObject* obj, | 154 | void connectRemove( QObject* obj, |
152 | const char* slot ); | 155 | const char* slot ); |
153 | protected: | 156 | protected: |
154 | MainWindow* todoWindow(); | 157 | MainWindow* todoWindow(); |
155 | OTodo event(int uid ); | 158 | OTodo event(int uid ); |
156 | OTodoAccess::List::Iterator begin(); | 159 | OTodoAccess::List list(); |
157 | OTodoAccess::List::Iterator end(); | 160 | OTodoAccess::List sorted(); |
161 | void sort(); | ||
162 | void sort(int sort ); | ||
163 | void setSortOrder( int order ); | ||
164 | void setAscending( bool ); | ||
158 | 165 | ||
159 | /* | 166 | /* |
160 | These things needs to be implemented | 167 | These things needs to be implemented |
161 | in a implementation | 168 | in a implementation |
162 | signals: | 169 | signals: |
163 | */ | 170 | */ |
164 | protected: | 171 | protected: |
165 | void showTodo( int uid ) { hack->emitShow(uid); } | 172 | void showTodo( int uid ) { hack->emitShow(uid); } |
166 | void edit( int uid ) { hack->emitEdit(uid); } | 173 | void edit( int uid ) { hack->emitEdit(uid); } |
167 | void update(int uid, const SmallTodo& to ); | 174 | void update(int uid, const SmallTodo& to ); |
168 | void update(int uid, const OTodo& ev); | 175 | void update(int uid, const OTodo& ev); |
169 | void remove( int uid ) { | 176 | void remove( int uid ) { |
170 | hack->emitRemove( uid ); | 177 | hack->emitRemove( uid ); |
171 | } | 178 | } |
172 | private: | 179 | private: |
173 | InternQtHack* hack; | 180 | InternQtHack* hack; |
174 | MainWindow *m_main; | 181 | MainWindow *m_main; |
182 | OTodoAccess::List m_sort; | ||
183 | bool m_asc : 1; | ||
184 | int m_sortOrder; | ||
175 | }; | 185 | }; |
176 | }; | 186 | }; |
177 | 187 | ||
178 | #endif | 188 | #endif |