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