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