author | zecke <zecke> | 2002-11-30 11:20:47 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-11-30 11:20:47 (UTC) |
commit | fdda15344fdf7f71fd9e1e4db15ecc5e12224ddb (patch) (unidiff) | |
tree | 32e68b5b483dd3ce8041542e7d95f0b6d8dbf644 | |
parent | bd692f7ebe04e23151cce39baf311b925ccf91b1 (diff) | |
download | opie-fdda15344fdf7f71fd9e1e4db15ecc5e12224ddb.zip opie-fdda15344fdf7f71fd9e1e4db15ecc5e12224ddb.tar.gz opie-fdda15344fdf7f71fd9e1e4db15ecc5e12224ddb.tar.bz2 |
Back from hospital with new power
This versions clean up m failure on templates with Qt... in todoview
Implements Recurrance( backends to not safe it yet )
OPimState and Maintainer mode in some ways
and much more
This one also implements the OPimMainWindow specs
and has a small Memu replacement to get the toolbar in one line
-rw-r--r-- | core/pim/todo/mainwindow.cpp | 213 | ||||
-rw-r--r-- | core/pim/todo/mainwindow.h | 24 | ||||
-rw-r--r-- | core/pim/todo/otaskeditor.cpp | 35 | ||||
-rw-r--r-- | core/pim/todo/otaskeditor.h | 5 | ||||
-rw-r--r-- | core/pim/todo/tableview.cpp | 27 | ||||
-rw-r--r-- | core/pim/todo/taskeditoradvanced.ui | 8 | ||||
-rw-r--r-- | core/pim/todo/taskeditoroverviewimpl.cpp | 55 | ||||
-rw-r--r-- | core/pim/todo/taskeditoroverviewimpl.h | 1 | ||||
-rw-r--r-- | core/pim/todo/todo.pro | 6 | ||||
-rw-r--r-- | core/pim/todo/todomanager.cpp | 7 | ||||
-rw-r--r-- | core/pim/todo/todomanager.h | 7 | ||||
-rw-r--r-- | core/pim/todo/todoview.cpp | 55 | ||||
-rw-r--r-- | core/pim/todo/todoview.h | 82 |
13 files changed, 310 insertions, 215 deletions
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp index 9b2423b..b2b3b8f 100644 --- a/core/pim/todo/mainwindow.cpp +++ b/core/pim/todo/mainwindow.cpp | |||
@@ -1,706 +1,805 @@ | |||
1 | /* | 1 | /* |
2 | =. This file is part of the OPIE Project | 2 | =. This file is part of the OPIE Project |
3 | .=l. Copyright (c) 2002 <> | 3 | .=l. Copyright (c) 2002 <> |
4 | .>+-= | 4 | .>+-= |
5 | _;:, .> :=|. This program is free software; you can | 5 | _;:, .> :=|. This program is free software; you can |
6 | .> <`_, > . <= redistribute it and/or modify it under | 6 | .> <`_, > . <= redistribute it and/or modify it under |
7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
8 | .="- .-=="i, .._ License as published by the Free Software | 8 | .="- .-=="i, .._ License as published by the Free Software |
9 | - . .-<_> .<> Foundation; either version 2 of the License, | 9 | - . .-<_> .<> Foundation; either version 2 of the License, |
10 | ._= =} : or (at your option) any later version. | 10 | ._= =} : or (at your option) any later version. |
11 | .%`+i> _;_. | 11 | .%`+i> _;_. |
12 | .i_,=:_. -<s. This program is distributed in the hope that | 12 | .i_,=:_. -<s. This program is distributed in the hope that |
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
14 | : .. .:, . . . without even the implied warranty of | 14 | : .. .:, . . . without even the implied warranty of |
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
17 | ..}^=.= = ; Library General Public License for more | 17 | ..}^=.= = ; Library General Public License for more |
18 | ++= -. .` .: details. | 18 | ++= -. .` .: details. |
19 | : = ...= . :.=- | 19 | : = ...= . :.=- |
20 | -. .:....=;==+<; You should have received a copy of the GNU | 20 | -. .:....=;==+<; You should have received a copy of the GNU |
21 | -_. . . )=. = General Public License along with | 21 | -_. . . )=. = General Public License along with |
22 | -- :-=` this library; see the file COPYING.LIB. | 22 | -- :-=` this library; see the file COPYING.LIB. |
23 | If not, write to the Free Software Foundation, | 23 | If not, write to the Free Software Foundation, |
24 | Inc., 59 Temple Place - Suite 330, | 24 | Inc., 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include <unistd.h> | 29 | #include <unistd.h> |
30 | 30 | ||
31 | #include <qmenubar.h> | 31 | #include <qmenubar.h> |
32 | #include <qmessagebox.h> | 32 | #include <qmessagebox.h> |
33 | #include <qtoolbar.h> | 33 | #include <qtoolbar.h> |
34 | #include <qpopupmenu.h> | 34 | #include <qpopupmenu.h> |
35 | #include <qwidgetstack.h> | 35 | #include <qwidgetstack.h> |
36 | #include <qaction.h> | 36 | #include <qaction.h> |
37 | #include <qtimer.h> | 37 | #include <qtimer.h> |
38 | #include <qvbox.h> | 38 | #include <qvbox.h> |
39 | #include <qlineedit.h> | 39 | #include <qlineedit.h> |
40 | 40 | ||
41 | #include <qpe/applnk.h> | 41 | #include <qpe/applnk.h> |
42 | #include <qpe/config.h> | 42 | #include <qpe/config.h> |
43 | #include <qpe/ir.h> | 43 | #include <qpe/ir.h> |
44 | #include <qpe/resource.h> | 44 | #include <qpe/resource.h> |
45 | #include <qpe/qpemessagebox.h> | 45 | #include <qpe/qpemessagebox.h> |
46 | 46 | ||
47 | #include <opie/orecur.h> | ||
47 | #include <opie/otodoaccessvcal.h> | 48 | #include <opie/otodoaccessvcal.h> |
48 | 49 | ||
49 | #include "quickeditimpl.h" | 50 | #include "quickeditimpl.h" |
50 | #include "todotemplatemanager.h" | 51 | #include "todotemplatemanager.h" |
51 | #include "templateeditor.h" | 52 | #include "templateeditor.h" |
52 | #include "tableview.h" | 53 | #include "tableview.h" |
53 | 54 | ||
54 | #include "textviewshow.h" | 55 | #include "textviewshow.h" |
55 | #include "todoeditor.h" | 56 | #include "todoeditor.h" |
56 | #include "mainwindow.h" | 57 | #include "mainwindow.h" |
57 | 58 | ||
58 | 59 | ||
59 | using namespace Todo; | 60 | using namespace Todo; |
60 | 61 | ||
61 | MainWindow::MainWindow( QWidget* parent, | 62 | MainWindow::MainWindow( QWidget* parent, |
62 | const char* name ) { | 63 | const char* name ) |
64 | : OPimMainWindow("Todolist") | ||
65 | { | ||
63 | 66 | ||
64 | m_syncing = false; | 67 | m_syncing = false; |
65 | m_counter = 0; | 68 | m_counter = 0; |
66 | m_tempManager = new TemplateManager(); | 69 | m_tempManager = new TemplateManager(); |
67 | m_tempManager->load(); | 70 | m_tempManager->load(); |
68 | 71 | ||
69 | initUI(); | 72 | initUI(); |
70 | initConfig(); | 73 | initConfig(); |
71 | initViews(); | 74 | initViews(); |
72 | initActions(); | 75 | initActions(); |
73 | initEditor(); | 76 | initEditor(); |
74 | initShow(); | 77 | initShow(); |
75 | initTemplate(); | 78 | initTemplate(); |
76 | 79 | ||
77 | populateTemplates(); | 80 | populateTemplates(); |
78 | raiseCurrentView(); | 81 | raiseCurrentView(); |
79 | QTimer::singleShot(0, this, SLOT(populateCategories() ) ); | 82 | QTimer::singleShot(0, this, SLOT(populateCategories() ) ); |
80 | } | 83 | } |
81 | void MainWindow::initTemplate() { | 84 | void MainWindow::initTemplate() { |
82 | m_curTempEd = new TemplateEditor( this, templateManager() ); | 85 | m_curTempEd = new TemplateEditor( this, templateManager() ); |
83 | } | 86 | } |
84 | void MainWindow::initActions() { | 87 | void MainWindow::initActions() { |
85 | QAction* a = new QAction( tr("New Task" ), Resource::loadPixmap( "new" ), | 88 | QAction* a = new QAction( tr("New Task" ), Resource::loadPixmap( "new" ), |
86 | QString::null, 0, this, 0 ); | 89 | QString::null, 0, this, 0 ); |
87 | connect(a, SIGNAL( activated() ), | 90 | connect(a, SIGNAL( activated() ), |
88 | this, SLOT( slotNew() ) ); | 91 | this, SLOT( slotNew() ) ); |
89 | a->addTo(m_tool ); | 92 | a->addTo(m_tool ); |
90 | a->addTo(m_edit ); | 93 | a->addTo(m_edit ); |
91 | 94 | ||
92 | a = new QAction( tr("Edit Task"), Resource::loadIconSet( "edit" ), | 95 | a = new QAction( tr("Edit Task"), Resource::loadIconSet( "edit" ), |
93 | QString::null, 0, this, 0 ); | 96 | QString::null, 0, this, 0 ); |
94 | connect(a, SIGNAL(activated() ), | 97 | connect(a, SIGNAL(activated() ), |
95 | this, SLOT( slotEdit() ) ); | 98 | this, SLOT( slotEdit() ) ); |
96 | a->addTo( m_tool ); | 99 | a->addTo( m_tool ); |
97 | a->addTo( m_edit ); | 100 | a->addTo( m_edit ); |
98 | m_editAction = a; | 101 | m_editAction = a; |
99 | 102 | ||
100 | a = new QAction( QString::null, tr("View Task"), 0, this, 0 ); | 103 | a = new QAction( QString::null, tr("View Task"), 0, this, 0 ); |
101 | connect(a, SIGNAL( activated() ), | 104 | connect(a, SIGNAL( activated() ), |
102 | this, SLOT( slotShowDetails() ) ); | 105 | this, SLOT( slotShowDetails() ) ); |
103 | a->addTo( m_edit ); | 106 | a->addTo( m_edit ); |
104 | 107 | ||
105 | m_edit->insertSeparator(); | 108 | m_edit->insertSeparator(); |
106 | 109 | ||
107 | a = new QAction( tr("Delete..."), Resource::loadIconSet( "trash" ), | 110 | a = new QAction( tr("Delete..."), Resource::loadIconSet( "trash" ), |
108 | QString::null, 0, this, 0 ); | 111 | QString::null, 0, this, 0 ); |
109 | connect(a, SIGNAL(activated() ), | 112 | connect(a, SIGNAL(activated() ), |
110 | this, SLOT(slotDelete() ) ); | 113 | this, SLOT(slotDelete() ) ); |
111 | a->addTo( m_tool ); | 114 | a->addTo( m_tool ); |
112 | a->addTo( m_edit ); | 115 | a->addTo( m_edit ); |
113 | m_deleteAction = a; | 116 | m_deleteAction = a; |
114 | 117 | ||
115 | a = new QAction( QString::null, tr("Delete all..."), 0, this, 0 ); | 118 | a = new QAction( QString::null, tr("Delete all..."), 0, this, 0 ); |
116 | connect(a, SIGNAL( activated() ), | 119 | connect(a, SIGNAL( activated() ), |
117 | this, SLOT( slotDeleteAll() ) ); | 120 | this, SLOT( slotDeleteAll() ) ); |
118 | a->addTo(m_edit ); | 121 | a->addTo(m_edit ); |
119 | m_deleteAllAction = a; | 122 | m_deleteAllAction = a; |
120 | 123 | ||
121 | a = new QAction( QString::null, tr("Delete completed"), | 124 | a = new QAction( QString::null, tr("Delete completed"), |
122 | 0, this, 0 ); | 125 | 0, this, 0 ); |
123 | connect(a, SIGNAL( activated() ), | 126 | connect(a, SIGNAL( activated() ), |
124 | this, SLOT( slotDeleteCompleted() ) ); | 127 | this, SLOT( slotDeleteCompleted() ) ); |
125 | a->addTo(m_edit ); | 128 | a->addTo(m_edit ); |
126 | a->setEnabled( TRUE ); | 129 | a->setEnabled( TRUE ); |
127 | m_deleteCompleteAction = a; | 130 | m_deleteCompleteAction = a; |
128 | 131 | ||
129 | m_edit->insertSeparator(); | 132 | m_edit->insertSeparator(); |
130 | 133 | ||
131 | a = new QAction( QString::null, tr("Duplicate"), 0, this, 0 ); | 134 | a = new QAction( QString::null, tr("Duplicate"), 0, this, 0 ); |
132 | connect(a, SIGNAL( activated() ), | 135 | connect(a, SIGNAL( activated() ), |
133 | this, SLOT( slotDuplicate() ) ); | 136 | this, SLOT( slotDuplicate() ) ); |
134 | a->addTo(m_edit ); | 137 | a->addTo(m_edit ); |
135 | m_duplicateAction = a; | 138 | m_duplicateAction = a; |
136 | 139 | ||
137 | m_edit->insertSeparator(); | 140 | m_edit->insertSeparator(); |
138 | 141 | ||
139 | if ( Ir::supported() ) { | 142 | if ( Ir::supported() ) { |
140 | a = new QAction( tr( "Beam" ), Resource::loadPixmap( "beam" ), | 143 | a = new QAction( tr( "Beam" ), Resource::loadPixmap( "beam" ), |
141 | QString::null, 0, this, 0 ); | 144 | QString::null, 0, this, 0 ); |
142 | connect( a, SIGNAL( activated() ), | 145 | connect( a, SIGNAL( activated() ), |
143 | this, SLOT( slotBeam() ) ); | 146 | this, SLOT( slotBeam() ) ); |
144 | a->addTo( m_edit ); | 147 | a->addTo( m_edit ); |
145 | a->addTo( m_tool ); | 148 | a->addTo( m_tool ); |
146 | } | 149 | } |
147 | 150 | ||
148 | a = new QAction( tr("Find"), Resource::loadIconSet( "mag" ), | 151 | a = new QAction( tr("Find"), Resource::loadIconSet( "mag" ), |
149 | QString::null, 0, this, 0 ); | 152 | QString::null, 0, this, 0 ); |
150 | connect(a, SIGNAL( activated() ), | 153 | connect(a, SIGNAL( activated() ), |
151 | this, SLOT( slotFind() ) ); | 154 | this, SLOT( slotFind() ) ); |
152 | a->addTo( m_options ); | 155 | a->addTo( m_options ); |
153 | m_findAction = a; | 156 | m_findAction = a; |
154 | 157 | ||
155 | m_options->insertSeparator(); | 158 | m_options->insertSeparator(); |
156 | 159 | ||
157 | m_completedAction = new QAction( QString::null, tr("Completed tasks"), | 160 | m_completedAction = new QAction( QString::null, tr("Completed tasks"), |
158 | 0, this, 0, TRUE ); | 161 | 0, this, 0, TRUE ); |
159 | m_completedAction->addTo( m_options ); | 162 | m_completedAction->addTo( m_options ); |
160 | m_completedAction->setOn( showCompleted() ); | 163 | m_completedAction->setOn( showCompleted() ); |
161 | connect(m_completedAction, SIGNAL( toggled(bool) ), | 164 | connect(m_completedAction, SIGNAL( toggled(bool) ), |
162 | this, SLOT(slotShowCompleted(bool) ) ); | 165 | this, SLOT(slotShowCompleted(bool) ) ); |
163 | 166 | ||
164 | m_showDeadLineAction = new QAction( QString::null, tr("Show Deadline"), | 167 | m_showDeadLineAction = new QAction( QString::null, tr("Show Deadline"), |
165 | 0, this, 0, TRUE ); | 168 | 0, this, 0, TRUE ); |
166 | m_showDeadLineAction->addTo( m_options ); | 169 | m_showDeadLineAction->addTo( m_options ); |
167 | m_showDeadLineAction->setOn( showDeadline() ); | 170 | m_showDeadLineAction->setOn( showDeadline() ); |
168 | connect(m_showDeadLineAction, SIGNAL(toggled(bool) ), | 171 | connect(m_showDeadLineAction, SIGNAL(toggled(bool) ), |
169 | this, SLOT( slotShowDeadLine( bool ) ) ); | 172 | this, SLOT( slotShowDeadLine( bool ) ) ); |
170 | 173 | ||
171 | m_options->insertSeparator(); | 174 | m_options->insertSeparator(); |
172 | 175 | ||
173 | m_bar->insertItem( tr("Data") ,m_edit ); | 176 | m_bar->insertItem( tr("Data") ,m_edit ); |
174 | m_bar->insertItem( tr("Category"), m_catMenu ); | 177 | m_bar->insertItem( tr("Category"), m_catMenu ); |
175 | m_bar->insertItem( tr("Options"), m_options ); | 178 | m_bar->insertItem( tr("Options"), m_options ); |
176 | 179 | ||
177 | /* initialize the view menu */ | 180 | /* initialize the view menu */ |
178 | a = new QAction( QString::null, tr("Show only over due"), | 181 | a = new QAction( QString::null, tr("Show only over due"), |
179 | 0, this, 0, TRUE ); | 182 | 0, this, 0, TRUE ); |
180 | a->addTo( m_view ); | 183 | a->addTo( m_options ); |
181 | a->setOn( showOverDue() ); | 184 | a->setOn( showOverDue() ); |
182 | connect(a, SIGNAL(toggled(bool)), | 185 | connect(a, SIGNAL(toggled(bool)), |
183 | this, SLOT(slotShowDue(bool) ) ); | 186 | this, SLOT(slotShowDue(bool) ) ); |
184 | m_view->insertSeparator(); | ||
185 | |||
186 | m_bar->insertItem( tr("View"), m_view ); | ||
187 | 187 | ||
188 | /* templates */ | 188 | /* templates */ |
189 | m_edit->insertItem(tr("New from template"), m_template, | 189 | m_edit->insertItem(tr("New from template"), m_template, |
190 | -1, 0 ); | 190 | -1, 0 ); |
191 | 191 | ||
192 | } | 192 | } |
193 | /* m_curCat from Config */ | 193 | /* m_curCat from Config */ |
194 | void MainWindow::initConfig() { | 194 | void MainWindow::initConfig() { |
195 | Config config( "todo" ); | 195 | Config config( "todo" ); |
196 | config.setGroup( "View" ); | 196 | config.setGroup( "View" ); |
197 | m_completed = config.readBoolEntry( "ShowComplete", TRUE ); | 197 | m_completed = config.readBoolEntry( "ShowComplete", TRUE ); |
198 | m_curCat = config.readEntry( "Category", QString::null ); | 198 | m_curCat = config.readEntry( "Category", QString::null ); |
199 | m_deadline = config.readBoolEntry( "ShowDeadLine", TRUE); | 199 | m_deadline = config.readBoolEntry( "ShowDeadLine", TRUE); |
200 | m_overdue = config.readBoolEntry("ShowOverDue", TRUE ); | 200 | m_overdue = config.readBoolEntry("ShowOverDue", TRUE ); |
201 | } | 201 | } |
202 | void MainWindow::initUI() { | 202 | void MainWindow::initUI() { |
203 | m_mainBox = new QVBox(this, "main box "); | 203 | m_mainBox = new QVBox(this, "main box "); |
204 | m_curQuick = new QuickEditImpl(this, m_mainBox ); | 204 | m_curQuick = new QuickEditImpl(this, m_mainBox ); |
205 | m_curQuick->signal()->connect( this, SLOT(slotQuickEntered() ) ); | 205 | m_curQuick->signal()->connect( this, SLOT(slotQuickEntered() ) ); |
206 | m_quickEdit.append( m_curQuick ); | 206 | m_quickEdit.append( m_curQuick ); |
207 | 207 | ||
208 | 208 | ||
209 | 209 | ||
210 | m_stack = new QWidgetStack(m_mainBox, "main stack"); | 210 | m_stack = new QWidgetStack(m_mainBox, "main stack"); |
211 | setCentralWidget( m_mainBox ); | 211 | setCentralWidget( m_mainBox ); |
212 | 212 | ||
213 | setToolBarsMovable( FALSE ); | 213 | setToolBarsMovable( FALSE ); |
214 | 214 | ||
215 | m_tool = new QToolBar( this ); | 215 | m_tool = new QToolBar( this ); |
216 | m_tool->setHorizontalStretchable( TRUE ); | 216 | m_tool->setHorizontalStretchable( TRUE ); |
217 | 217 | ||
218 | m_bar = new QMenuBar( m_tool ); | 218 | m_bar = new QMenuBar( m_tool ); |
219 | 219 | ||
220 | /** QPopupMenu */ | 220 | /** QPopupMenu */ |
221 | m_edit = new QPopupMenu( this ); | 221 | m_edit = new QPopupMenu( this ); |
222 | m_options = new QPopupMenu( this ); | 222 | m_options = new QPopupMenu( this ); |
223 | m_view = new QPopupMenu( this ); | ||
224 | m_catMenu = new QPopupMenu( this ); | 223 | m_catMenu = new QPopupMenu( this ); |
225 | m_template = new QPopupMenu( this ); | 224 | m_template = new QPopupMenu( this ); |
226 | 225 | ||
227 | m_catMenu->setCheckable( TRUE ); | 226 | m_catMenu->setCheckable( TRUE ); |
228 | m_template->setCheckable( TRUE ); | 227 | m_template->setCheckable( TRUE ); |
229 | 228 | ||
230 | connect(m_catMenu, SIGNAL(activated(int) ), | 229 | connect(m_catMenu, SIGNAL(activated(int) ), |
231 | this, SLOT(setCategory(int) ) ); | 230 | this, SLOT(setCategory(int) ) ); |
232 | connect(m_template, SIGNAL(activated(int) ), | 231 | connect(m_template, SIGNAL(activated(int) ), |
233 | this, SLOT(slotNewFromTemplate(int) ) ); | 232 | this, SLOT(slotNewFromTemplate(int) ) ); |
234 | } | 233 | } |
235 | void MainWindow::initViews() { | 234 | void MainWindow::initViews() { |
236 | TableView* tableView = new TableView( this, m_stack ); | 235 | TableView* tableView = new TableView( this, m_stack ); |
237 | m_stack->addWidget( tableView, m_counter++ ); | 236 | m_stack->addWidget( tableView, m_counter++ ); |
238 | m_views.append( tableView ); | 237 | m_views.append( tableView ); |
239 | m_curView = tableView; | 238 | m_curView = tableView; |
240 | connectBase( tableView ); | 239 | connectBase( tableView ); |
241 | /* add QString type + QString configname to | 240 | /* add QString type + QString configname to |
242 | * the View menu | 241 | * the View menu |
243 | * and subdirs for multiple views | 242 | * and subdirs for multiple views |
244 | */ | 243 | */ |
245 | } | 244 | } |
246 | void MainWindow::initEditor() { | 245 | void MainWindow::initEditor() { |
247 | m_curEdit = new Editor(); | 246 | m_curEdit = new Editor(); |
248 | } | 247 | } |
249 | void MainWindow::initShow() { | 248 | void MainWindow::initShow() { |
250 | m_curShow = new TextViewShow(this); | 249 | m_curShow = new TextViewShow(this); |
251 | m_stack->addWidget( m_curShow->widget() , m_counter++ ); | 250 | m_stack->addWidget( m_curShow->widget() , m_counter++ ); |
252 | } | 251 | } |
253 | MainWindow::~MainWindow() { | 252 | MainWindow::~MainWindow() { |
254 | delete templateManager(); | 253 | delete templateManager(); |
255 | } | 254 | } |
256 | void MainWindow::connectBase( ViewBase* base) { | 255 | void MainWindow::connectBase( ViewBase* base) { |
257 | base->connectShow( this, SLOT(slotShow(int) ) ); | 256 | // once templates and signals mix we'll use it again |
258 | base->connectEdit( this, SLOT(slotEdit(int) ) ); | 257 | } |
259 | base->connectUpdateSmall( this, | 258 | QPopupMenu* MainWindow::contextMenu( int , bool recur ) { |
260 | SLOT(slotUpate1(int, const Todo::SmallTodo&) )); | ||
261 | base->connectUpdateBig( this, | ||
262 | SLOT(slotUpate2(int, const OTodo& ) ) ); | ||
263 | base->connectUpdateView( this, SLOT(slotUpdate3( QWidget* ) ) ) ; | ||
264 | base->connectRemove(&m_todoMgr, | ||
265 | SLOT(remove(int)) ); | ||
266 | } | ||
267 | QPopupMenu* MainWindow::contextMenu( int uid ) { | ||
268 | QPopupMenu* menu = new QPopupMenu(); | 259 | QPopupMenu* menu = new QPopupMenu(); |
269 | 260 | ||
270 | m_editAction->addTo( menu ); | 261 | m_editAction->addTo( menu ); |
271 | m_deleteAction->addTo( menu ); | 262 | m_deleteAction->addTo( menu ); |
272 | m_duplicateAction->addTo( menu ); | 263 | m_duplicateAction->addTo( menu ); |
264 | |||
273 | menu->insertSeparator(); | 265 | menu->insertSeparator(); |
274 | 266 | ||
267 | /* | ||
268 | * if this event recurs we allow | ||
269 | * to detach it. | ||
270 | * remove all | ||
271 | */ | ||
272 | if ( recur ) { | ||
273 | ; // FIXME | ||
274 | } | ||
275 | |||
275 | return menu; | 276 | return menu; |
276 | } | 277 | } |
277 | QPopupMenu* MainWindow::options() { | 278 | QPopupMenu* MainWindow::options() { |
278 | qWarning("Options"); | 279 | qWarning("Options"); |
279 | return m_options; | 280 | return m_options; |
280 | } | 281 | } |
281 | QPopupMenu* MainWindow::edit() { | 282 | QPopupMenu* MainWindow::edit() { |
282 | return m_edit; | 283 | return m_edit; |
283 | } | 284 | } |
284 | QPopupMenu* MainWindow::view() { | ||
285 | return m_view; | ||
286 | } | ||
287 | QToolBar* MainWindow::toolbar() { | 285 | QToolBar* MainWindow::toolbar() { |
288 | return m_tool; | 286 | return m_tool; |
289 | } | 287 | } |
290 | OTodoAccess::List MainWindow::list()const { | 288 | OTodoAccess::List MainWindow::list()const { |
291 | return m_todoMgr.list(); | 289 | return m_todoMgr.list(); |
292 | } | 290 | } |
293 | OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder ) { | 291 | OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder ) { |
294 | int cat = 0; | 292 | int cat = 0; |
295 | if ( m_curCat != tr("All Categories") ) | 293 | if ( m_curCat != tr("All Categories") ) |
296 | cat = currentCatId(); | 294 | cat = currentCatId(); |
297 | 295 | ||
298 | int filter = 1; | 296 | int filter = 1; |
299 | 297 | ||
300 | if (!m_completed ) | 298 | if (!m_completed ) |
301 | filter |= 4; | 299 | filter |= 4; |
302 | if (m_overdue) | 300 | if (m_overdue) |
303 | filter |= 2; | 301 | filter |= 2; |
304 | 302 | ||
305 | return m_todoMgr.sorted( asc, sortOrder, filter, cat ); | 303 | return m_todoMgr.sorted( asc, sortOrder, filter, cat ); |
306 | } | 304 | } |
307 | OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder, int addFilter) { | 305 | OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder, int addFilter) { |
308 | int cat = 0; | 306 | int cat = 0; |
309 | if ( m_curCat != tr("All Categories") ) | 307 | if ( m_curCat != tr("All Categories") ) |
310 | cat = currentCatId(); | 308 | cat = currentCatId(); |
311 | 309 | ||
312 | return m_todoMgr.sorted(asc, sortOrder, addFilter, cat ); | 310 | return m_todoMgr.sorted(asc, sortOrder, addFilter, cat ); |
313 | } | 311 | } |
314 | OTodo MainWindow::event( int uid ) { | 312 | OTodo MainWindow::event( int uid ) { |
315 | return m_todoMgr.event( uid ); | 313 | return m_todoMgr.event( uid ); |
316 | } | 314 | } |
317 | bool MainWindow::isSyncing()const { | 315 | bool MainWindow::isSyncing()const { |
318 | return m_syncing; | 316 | return m_syncing; |
319 | } | 317 | } |
320 | TemplateManager* MainWindow::templateManager() { | 318 | TemplateManager* MainWindow::templateManager() { |
321 | return m_tempManager; | 319 | return m_tempManager; |
322 | } | 320 | } |
323 | Editor* MainWindow::currentEditor() { | 321 | Editor* MainWindow::currentEditor() { |
324 | return m_curEdit; | 322 | return m_curEdit; |
325 | } | 323 | } |
326 | TodoShow* MainWindow::currentShow() { | 324 | TodoShow* MainWindow::currentShow() { |
327 | return m_curShow; | 325 | return m_curShow; |
328 | } | 326 | } |
329 | void MainWindow::slotReload() { | 327 | void MainWindow::slotReload() { |
330 | m_todoMgr.reload(); | 328 | m_todoMgr.reload(); |
331 | currentView()->updateView( ); | 329 | currentView()->updateView( ); |
332 | raiseCurrentView(); | 330 | raiseCurrentView(); |
333 | } | 331 | } |
334 | void MainWindow::closeEvent( QCloseEvent* e ) { | 332 | void MainWindow::closeEvent( QCloseEvent* e ) { |
335 | if (m_stack->visibleWidget() == currentShow()->widget() ) { | 333 | if (m_stack->visibleWidget() == currentShow()->widget() ) { |
336 | raiseCurrentView(); | 334 | raiseCurrentView(); |
337 | e->ignore(); | 335 | e->ignore(); |
338 | return; | 336 | return; |
339 | } | 337 | } |
340 | /* | 338 | /* |
341 | * we should have flushed and now we're still saving | 339 | * we should have flushed and now we're still saving |
342 | * so there is no need to flush | 340 | * so there is no need to flush |
343 | */ | 341 | */ |
344 | if (m_syncing ) { | 342 | if (m_syncing ) { |
345 | e->accept(); | 343 | e->accept(); |
346 | return; | 344 | return; |
347 | } | 345 | } |
348 | bool quit = false; | 346 | bool quit = false; |
349 | if ( m_todoMgr.saveAll() ){ | 347 | if ( m_todoMgr.saveAll() ){ |
350 | qWarning("saved"); | 348 | qWarning("saved"); |
351 | quit = true; | 349 | quit = true; |
352 | }else { | 350 | }else { |
353 | if ( QMessageBox::critical( this, tr("Out of space"), | 351 | if ( QMessageBox::critical( this, tr("Out of space"), |
354 | tr("Todo was unable\n" | 352 | tr("Todo was unable\n" |
355 | "to save your changes.\n" | 353 | "to save your changes.\n" |
356 | "Free up some space\n" | 354 | "Free up some space\n" |
357 | "and try again.\n" | 355 | "and try again.\n" |
358 | "\nQuit Anyway?"), | 356 | "\nQuit Anyway?"), |
359 | QMessageBox::Yes|QMessageBox::Escape, | 357 | QMessageBox::Yes|QMessageBox::Escape, |
360 | QMessageBox::No|QMessageBox::Default) | 358 | QMessageBox::No|QMessageBox::Default) |
361 | != QMessageBox::No ) { | 359 | != QMessageBox::No ) { |
362 | e->accept(); | 360 | e->accept(); |
363 | quit = true; | 361 | quit = true; |
364 | }else | 362 | }else |
365 | e->ignore(); | 363 | e->ignore(); |
366 | 364 | ||
367 | } | 365 | } |
368 | 366 | ||
369 | if (quit ) { | 367 | if (quit ) { |
370 | Config config( "todo" ); | 368 | Config config( "todo" ); |
371 | config.setGroup( "View" ); | 369 | config.setGroup( "View" ); |
372 | config.writeEntry( "ShowComplete", showCompleted() ); | 370 | config.writeEntry( "ShowComplete", showCompleted() ); |
373 | config.writeEntry( "Category", currentCategory() ); | 371 | config.writeEntry( "Category", currentCategory() ); |
374 | config.writeEntry( "ShowDeadLine", showDeadline()); | 372 | config.writeEntry( "ShowDeadLine", showDeadline()); |
375 | config.writeEntry( "ShowOverDue", showOverDue() ); | 373 | config.writeEntry( "ShowOverDue", showOverDue() ); |
376 | /* svae templates */ | 374 | /* svae templates */ |
377 | templateManager()->save(); | 375 | templateManager()->save(); |
378 | e->accept(); | 376 | e->accept(); |
379 | } | 377 | } |
380 | } | 378 | } |
381 | void MainWindow::populateTemplates() { | 379 | void MainWindow::populateTemplates() { |
382 | m_template->clear(); | 380 | m_template->clear(); |
383 | QStringList list = templateManager()->templates(); | 381 | QStringList list = templateManager()->templates(); |
384 | QStringList::Iterator it; | 382 | QStringList::Iterator it; |
385 | for ( it = list.begin(); it != list.end(); ++it ) { | 383 | for ( it = list.begin(); it != list.end(); ++it ) { |
386 | m_template->insertItem( (*it) ); | 384 | m_template->insertItem( (*it) ); |
387 | } | 385 | } |
388 | } | 386 | } |
389 | /* | 387 | /* |
390 | * slotNewFromTemplate | 388 | * slotNewFromTemplate |
391 | * We use the edit widget to do | 389 | * We use the edit widget to do |
392 | * the config but we setUid(-1) | 390 | * the config but we setUid(-1) |
393 | * to get a new uid | 391 | * to get a new uid |
394 | */ | 392 | */ |
395 | /* | 393 | /* |
396 | * first we get the name of the template | 394 | * first we get the name of the template |
397 | * then we will use the TemplateManager | 395 | * then we will use the TemplateManager |
398 | */ | 396 | */ |
399 | void MainWindow::slotNewFromTemplate( int id ) { | 397 | void MainWindow::slotNewFromTemplate( int id ) { |
400 | QString name = m_template->text( id ); | 398 | QString name = m_template->text( id ); |
401 | 399 | ||
402 | OTodo event = templateManager()->templateEvent( name ); | 400 | OTodo event = templateManager()->templateEvent( name ); |
403 | event = currentEditor()->edit(this, | 401 | event = currentEditor()->edit(this, |
404 | event ); | 402 | event ); |
405 | 403 | ||
406 | if ( currentEditor()->accepted() ) { | 404 | if ( currentEditor()->accepted() ) { |
407 | /* assign new todo */ | 405 | /* assign new todo */ |
408 | event.setUid( -1 ); | 406 | event.setUid( -1 ); |
409 | currentView()->addEvent( event ); | 407 | currentView()->addEvent( event ); |
410 | m_todoMgr.add( event ); | 408 | m_todoMgr.add( event ); |
411 | 409 | ||
412 | populateCategories(); | 410 | populateCategories(); |
413 | } | 411 | } |
414 | } | 412 | } |
415 | void MainWindow::slotNew() { | 413 | void MainWindow::slotNew() { |
416 | if(m_syncing) { | 414 | create(); |
417 | QMessageBox::warning(this, tr("Todo"), | ||
418 | tr("Can not edit data, currently syncing")); | ||
419 | return; | ||
420 | } | ||
421 | |||
422 | |||
423 | OTodo todo = currentEditor()->newTodo( currentCatId(), | ||
424 | this ); | ||
425 | |||
426 | if ( currentEditor()->accepted() ) { | ||
427 | //todo.assignUid(); | ||
428 | m_todoMgr.add( todo ); | ||
429 | currentView()->addEvent( todo ); | ||
430 | |||
431 | |||
432 | // I'm afraid we must call this every time now, otherwise | ||
433 | // spend expensive time comparing all these strings... | ||
434 | // but only call if we changed something -zecke | ||
435 | populateCategories(); | ||
436 | } | ||
437 | raiseCurrentView( ); | ||
438 | } | 415 | } |
439 | void MainWindow::slotDuplicate() { | 416 | void MainWindow::slotDuplicate() { |
440 | if(m_syncing) { | 417 | if(m_syncing) { |
441 | QMessageBox::warning(this, tr("Todo"), | 418 | QMessageBox::warning(this, tr("Todo"), |
442 | tr("Can not edit data, currently syncing")); | 419 | tr("Can not edit data, currently syncing")); |
443 | return; | 420 | return; |
444 | } | 421 | } |
445 | OTodo ev = m_todoMgr.event( currentView()->current() ); | 422 | OTodo ev = m_todoMgr.event( currentView()->current() ); |
446 | /* let's generate a new uid */ | 423 | /* let's generate a new uid */ |
447 | ev.setUid(-1); | 424 | ev.setUid(-1); |
448 | m_todoMgr.add( ev ); | 425 | m_todoMgr.add( ev ); |
449 | 426 | ||
450 | currentView()->addEvent( ev ); | 427 | currentView()->addEvent( ev ); |
451 | raiseCurrentView(); | 428 | raiseCurrentView(); |
452 | } | 429 | } |
453 | void MainWindow::slotDelete() { | 430 | void MainWindow::slotDelete() { |
454 | if (!currentView()->current() ) | 431 | if (!currentView()->current() ) |
455 | return; | 432 | return; |
456 | 433 | ||
457 | if(m_syncing) { | 434 | if(m_syncing) { |
458 | QMessageBox::warning(this, tr("Todo"), | 435 | QMessageBox::warning(this, tr("Todo"), |
459 | tr("Can not edit data, currently syncing")); | 436 | tr("Can not edit data, currently syncing")); |
460 | return; | 437 | return; |
461 | } | 438 | } |
462 | QString strName = currentView()->currentRepresentation(); | 439 | QString strName = currentView()->currentRepresentation(); |
463 | if (!QPEMessageBox::confirmDelete(this, tr("Todo"), strName ) ) | 440 | if (!QPEMessageBox::confirmDelete(this, tr("Todo"), strName ) ) |
464 | return; | 441 | return; |
465 | 442 | ||
466 | m_todoMgr.remove( currentView()->current() ); | 443 | m_todoMgr.remove( currentView()->current() ); |
467 | currentView()->removeEvent( currentView()->current() ); | 444 | currentView()->removeEvent( currentView()->current() ); |
468 | raiseCurrentView(); | 445 | raiseCurrentView(); |
469 | } | 446 | } |
470 | void MainWindow::slotDeleteAll() { | 447 | void MainWindow::slotDeleteAll() { |
471 | if(m_syncing) { | 448 | if(m_syncing) { |
472 | QMessageBox::warning(this, tr("Todo"), | 449 | QMessageBox::warning(this, tr("Todo"), |
473 | tr("Can not edit data, currently syncing")); | 450 | tr("Can not edit data, currently syncing")); |
474 | return; | 451 | return; |
475 | } | 452 | } |
476 | 453 | ||
477 | //QString strName = table->text( table->currentRow(), 2 ).left( 30 ); | ||
478 | 454 | ||
479 | if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("all tasks?") ) ) | 455 | if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("all tasks?") ) ) |
480 | return; | 456 | return; |
481 | 457 | ||
482 | m_todoMgr.removeAll(); | 458 | m_todoMgr.removeAll(); |
483 | currentView()->clear(); | 459 | currentView()->clear(); |
484 | 460 | ||
485 | raiseCurrentView(); | 461 | raiseCurrentView(); |
486 | } | 462 | } |
487 | void MainWindow::slotDeleteCompleted() { | 463 | void MainWindow::slotDeleteCompleted() { |
488 | if(m_syncing) { | 464 | if(m_syncing) { |
489 | QMessageBox::warning(this, tr("Todo"), | 465 | QMessageBox::warning(this, tr("Todo"), |
490 | tr("Can not edit data, currently syncing")); | 466 | tr("Can not edit data, currently syncing")); |
491 | return; | 467 | return; |
492 | } | 468 | } |
493 | 469 | ||
494 | if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("all completed tasks?") ) ) | 470 | if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("all completed tasks?") ) ) |
495 | return; | 471 | return; |
496 | 472 | ||
497 | // FIXME | 473 | |
498 | //m_todoMgr.remove( currentView()->completed() ); | 474 | m_todoMgr.removeCompleted(); |
499 | currentView()->updateView( ); | 475 | currentView()->updateView( ); |
500 | } | 476 | } |
501 | void MainWindow::slotFind() { | 477 | void MainWindow::slotFind() { |
502 | 478 | ||
503 | } | 479 | } |
504 | void MainWindow::slotEdit() { | 480 | void MainWindow::slotEdit() { |
505 | slotEdit( currentView()->current() ); | 481 | slotEdit( currentView()->current() ); |
506 | } | 482 | } |
507 | /* | 483 | /* |
508 | * set the category | 484 | * set the category |
509 | */ | 485 | */ |
510 | void MainWindow::setCategory( int c) { | 486 | void MainWindow::setCategory( int c) { |
511 | if ( c <= 0 ) return; | 487 | if ( c <= 0 ) return; |
512 | 488 | ||
513 | 489 | ||
514 | qWarning("Iterating over cats %d", c ); | 490 | qWarning("Iterating over cats %d", c ); |
515 | for ( unsigned int i = 1; i < m_catMenu->count(); i++ ) | 491 | for ( unsigned int i = 1; i < m_catMenu->count(); i++ ) |
516 | m_catMenu->setItemChecked(i, c == (int)i ); | 492 | m_catMenu->setItemChecked(i, c == (int)i ); |
517 | 493 | ||
518 | if (c == 1 ) { | 494 | if (c == 1 ) { |
519 | m_curCat = QString::null; | 495 | m_curCat = QString::null; |
520 | setCaption( tr("Todo") + " - " + tr("All Categories" ) ); | 496 | setCaption( tr("Todo") + " - " + tr("All Categories" ) ); |
521 | 497 | ||
522 | }else if ( c == (int)m_catMenu->count() - 1 ) { | 498 | }else if ( c == (int)m_catMenu->count() - 1 ) { |
523 | m_curCat = tr("Unfiled"); | 499 | m_curCat = tr("Unfiled"); |
524 | setCaption( tr("Todo") + " - " + tr("Unfiled") ); | 500 | setCaption( tr("Todo") + " - " + tr("Unfiled") ); |
525 | }else { | 501 | }else { |
526 | m_curCat = m_todoMgr.categories()[c-2]; | 502 | m_curCat = m_todoMgr.categories()[c-2]; |
527 | setCaption( tr("Todo") + " - " + m_curCat ); | 503 | setCaption( tr("Todo") + " - " + m_curCat ); |
528 | } | 504 | } |
529 | m_catMenu->setItemChecked( c, true ); | 505 | m_catMenu->setItemChecked( c, true ); |
530 | 506 | ||
531 | currentView()->setShowCategory( m_curCat ); | 507 | currentView()->setShowCategory( m_curCat ); |
532 | raiseCurrentView(); | 508 | raiseCurrentView(); |
533 | } | 509 | } |
534 | void MainWindow::slotShowDeadLine( bool dead) { | 510 | void MainWindow::slotShowDeadLine( bool dead) { |
535 | m_deadline = dead; | 511 | m_deadline = dead; |
536 | currentView()->setShowDeadline( dead ); | 512 | currentView()->setShowDeadline( dead ); |
537 | } | 513 | } |
538 | void MainWindow::slotShowCompleted( bool show) { | 514 | void MainWindow::slotShowCompleted( bool show) { |
539 | m_completed = show; | 515 | m_completed = show; |
540 | currentView()->setShowCompleted( m_completed ); | 516 | currentView()->setShowCompleted( m_completed ); |
541 | } | 517 | } |
542 | bool MainWindow::showOverDue()const { | 518 | bool MainWindow::showOverDue()const { |
543 | return m_overdue; | 519 | return m_overdue; |
544 | } | 520 | } |
545 | void MainWindow::setDocument( const QString& fi) { | 521 | void MainWindow::setDocument( const QString& fi) { |
546 | DocLnk doc(fi); | 522 | DocLnk doc(fi); |
547 | if (doc.isValid() ) | 523 | if (doc.isValid() ) |
548 | receiveFile(doc.file() ); | 524 | receiveFile(doc.file() ); |
549 | else | 525 | else |
550 | receiveFile(fi ); | 526 | receiveFile(fi ); |
551 | } | 527 | } |
552 | 528 | ||
553 | static const char *beamfile = "/tmp/opie-todo.vcs"; | 529 | static const char *beamfile = "/tmp/opie-todo.vcs"; |
554 | void MainWindow::slotBeam() { | 530 | void MainWindow::slotBeam() { |
555 | ::unlink( beamfile ); | 531 | beam( currentView()->current() ); |
556 | OTodo todo = event( currentView()->current() ); | ||
557 | OTodoAccessVCal* cal = new OTodoAccessVCal(QString::fromLatin1(beamfile) ); | ||
558 | OTodoAccess acc( cal ); | ||
559 | acc.load(); | ||
560 | acc.add( todo ); | ||
561 | acc.save(); | ||
562 | Ir* ir = new Ir(this ); | ||
563 | connect(ir, SIGNAL(done(Ir*) ), | ||
564 | this, SLOT(beamDone(Ir*) ) ); | ||
565 | ir->send( beamfile, todo.summary(), "text/x-vCalendar" ); | ||
566 | |||
567 | } | 532 | } |
568 | void MainWindow::beamDone( Ir* ir) { | 533 | void MainWindow::beamDone( Ir* ir) { |
569 | delete ir; | 534 | delete ir; |
570 | ::unlink( beamfile ); | 535 | ::unlink( beamfile ); |
571 | } | 536 | } |
572 | void MainWindow::receiveFile( const QString& filename ) { | 537 | void MainWindow::receiveFile( const QString& filename ) { |
573 | OTodoAccessVCal* cal = new OTodoAccessVCal(filename ); | 538 | OTodoAccessVCal* cal = new OTodoAccessVCal(filename ); |
574 | OTodoAccess acc( cal ); | 539 | OTodoAccess acc( cal ); |
575 | acc.load(); | 540 | acc.load(); |
576 | OTodoAccess::List list = acc.allRecords(); | 541 | OTodoAccess::List list = acc.allRecords(); |
577 | 542 | ||
578 | QString message = tr("<P>%1 new tasks arrived.<p>Would you like to add them to your Todolist?").arg(list.count() ); | 543 | QString message = tr("<P>%1 new tasks arrived.<p>Would you like to add them to your Todolist?").arg(list.count() ); |
579 | 544 | ||
580 | if ( QMessageBox::information(this, tr("New Tasks"), | 545 | if ( QMessageBox::information(this, tr("New Tasks"), |
581 | message, QMessageBox::Ok, | 546 | message, QMessageBox::Ok, |
582 | QMessageBox::Cancel ) == QMessageBox::Ok ) { | 547 | QMessageBox::Cancel ) == QMessageBox::Ok ) { |
583 | OTodoAccess::List::Iterator it; | 548 | OTodoAccess::List::Iterator it; |
584 | for ( it = list.begin(); it != list.end(); ++it ) | 549 | for ( it = list.begin(); it != list.end(); ++it ) |
585 | m_todoMgr.add( (*it) ); | 550 | m_todoMgr.add( (*it) ); |
586 | 551 | ||
587 | currentView()->updateView(); | 552 | currentView()->updateView(); |
588 | } | 553 | } |
589 | } | 554 | } |
590 | 555 | ||
591 | void MainWindow::slotFlush() { | 556 | void MainWindow::slotFlush() { |
592 | m_syncing = FALSE; | 557 | m_syncing = FALSE; |
593 | m_todoMgr.save(); | 558 | m_todoMgr.save(); |
594 | } | 559 | } |
595 | void MainWindow::slotShowDetails() { | 560 | void MainWindow::slotShowDetails() { |
596 | slotShow( currentView()->current() ); | 561 | slotShow( currentView()->current() ); |
597 | } | 562 | } |
598 | /* | 563 | /* |
599 | * populate the Categories | 564 | * populate the Categories |
600 | * Menu | 565 | * Menu |
601 | */ | 566 | */ |
602 | void MainWindow::populateCategories() { | 567 | void MainWindow::populateCategories() { |
603 | m_todoMgr.load(); | 568 | m_todoMgr.load(); |
604 | 569 | ||
605 | m_catMenu->clear(); | 570 | m_catMenu->clear(); |
606 | int id, rememberId; | 571 | int id, rememberId; |
607 | id = 1; | 572 | id = 1; |
608 | rememberId = 1; | 573 | rememberId = 1; |
609 | 574 | ||
610 | m_catMenu->insertItem( tr( "All Categories" ), id++ ); | 575 | m_catMenu->insertItem( tr( "All Categories" ), id++ ); |
611 | m_catMenu->insertSeparator(); | 576 | m_catMenu->insertSeparator(); |
612 | QStringList categories = m_todoMgr.categories(); | 577 | QStringList categories = m_todoMgr.categories(); |
613 | categories.append( tr( "Unfiled" ) ); | 578 | categories.append( tr( "Unfiled" ) ); |
614 | for ( QStringList::Iterator it = categories.begin(); | 579 | for ( QStringList::Iterator it = categories.begin(); |
615 | it != categories.end(); ++it ) { | 580 | it != categories.end(); ++it ) { |
616 | m_catMenu->insertItem( *it, id ); | 581 | m_catMenu->insertItem( *it, id ); |
617 | if ( *it == currentCategory() ) | 582 | if ( *it == currentCategory() ) |
618 | rememberId = id; | 583 | rememberId = id; |
619 | ++id; | 584 | ++id; |
620 | } | 585 | } |
621 | setCategory( rememberId ); | 586 | setCategory( rememberId ); |
622 | } | 587 | } |
623 | bool MainWindow::showCompleted()const { | 588 | bool MainWindow::showCompleted()const { |
624 | return m_completed; | 589 | return m_completed; |
625 | } | 590 | } |
626 | bool MainWindow::showDeadline()const { | 591 | bool MainWindow::showDeadline()const { |
627 | return m_deadline; | 592 | return m_deadline; |
628 | } | 593 | } |
629 | QString MainWindow::currentCategory()const { | 594 | QString MainWindow::currentCategory()const { |
630 | return m_curCat; | 595 | return m_curCat; |
631 | } | 596 | } |
632 | int MainWindow::currentCatId() { | 597 | int MainWindow::currentCatId() { |
633 | return m_todoMgr.catId( m_curCat ); | 598 | return m_todoMgr.catId( m_curCat ); |
634 | } | 599 | } |
635 | ViewBase* MainWindow::currentView() { | 600 | ViewBase* MainWindow::currentView() { |
636 | return m_curView; | 601 | return m_curView; |
637 | } | 602 | } |
638 | void MainWindow::raiseCurrentView() { | 603 | void MainWindow::raiseCurrentView() { |
639 | m_stack->raiseWidget( m_curView->widget() ); | 604 | m_stack->raiseWidget( m_curView->widget() ); |
640 | } | 605 | } |
641 | void MainWindow::slotShowDue(bool ov) { | 606 | void MainWindow::slotShowDue(bool ov) { |
642 | m_overdue = ov; | 607 | m_overdue = ov; |
643 | currentView()->showOverDue( ov ); | 608 | currentView()->showOverDue( ov ); |
644 | raiseCurrentView(); | 609 | raiseCurrentView(); |
645 | } | 610 | } |
646 | void MainWindow::slotShow( int uid ) { | 611 | void MainWindow::slotShow( int uid ) { |
647 | qWarning("slotShow"); | 612 | qWarning("slotShow"); |
648 | currentShow()->slotShow( event( uid ) ); | 613 | currentShow()->slotShow( event( uid ) ); |
649 | m_stack->raiseWidget( currentShow()->widget() ); | 614 | m_stack->raiseWidget( currentShow()->widget() ); |
650 | } | 615 | } |
651 | void MainWindow::slotEdit( int uid ) { | 616 | void MainWindow::slotEdit( int uid ) { |
652 | if(m_syncing) { | 617 | if(m_syncing) { |
653 | QMessageBox::warning(this, tr("Todo"), | 618 | QMessageBox::warning(this, tr("Todo"), |
654 | tr("Can not edit data, currently syncing")); | 619 | tr("Can not edit data, currently syncing")); |
655 | return; | 620 | return; |
656 | } | 621 | } |
657 | 622 | ||
658 | OTodo todo = m_todoMgr.event( uid ); | 623 | OTodo todo = m_todoMgr.event( uid ); |
659 | 624 | ||
660 | todo = currentEditor()->edit(this, todo ); | 625 | todo = currentEditor()->edit(this, todo ); |
661 | 626 | ||
662 | /* if completed */ | 627 | /* if completed */ |
663 | if ( currentEditor()->accepted() ) { | 628 | if ( currentEditor()->accepted() ) { |
664 | qWarning("Replacing now" ); | 629 | qWarning("Replacing now" ); |
665 | m_todoMgr.update( todo.uid(), todo ); | 630 | m_todoMgr.update( todo.uid(), todo ); |
666 | currentView()->replaceEvent( todo ); | 631 | currentView()->replaceEvent( todo ); |
667 | /* a Category might have changed */ | 632 | /* a Category might have changed */ |
668 | populateCategories(); | 633 | populateCategories(); |
669 | } | 634 | } |
670 | 635 | ||
671 | raiseCurrentView(); | 636 | raiseCurrentView(); |
672 | } | 637 | } |
673 | /* | 638 | /* |
674 | void MainWindow::slotUpdate1( int uid, const SmallTodo& ev) { | 639 | void MainWindow::slotUpdate1( int uid, const SmallTodo& ev) { |
675 | m_todoMgr.update( uid, ev ); | 640 | m_todoMgr.update( uid, ev ); |
676 | } | 641 | } |
677 | */ | 642 | */ |
678 | void MainWindow::updateTodo( const OTodo& ev) { | 643 | void MainWindow::updateTodo( const OTodo& ev) { |
679 | m_todoMgr.update( ev.uid() , ev ); | 644 | m_todoMgr.update( ev.uid() , ev ); |
680 | } | 645 | } |
681 | /* The view changed it's configuration | 646 | /* The view changed it's configuration |
682 | * update the view menu | 647 | * update the view menu |
683 | */ | 648 | */ |
684 | void MainWindow::slotUpdate3( QWidget* ) { | 649 | void MainWindow::slotUpdate3( QWidget* ) { |
685 | 650 | ||
686 | } | 651 | } |
687 | void MainWindow::updateList() { | 652 | void MainWindow::updateList() { |
688 | m_todoMgr.updateList(); | 653 | m_todoMgr.updateList(); |
689 | } | 654 | } |
690 | void MainWindow::setReadAhead( uint count ) { | 655 | void MainWindow::setReadAhead( uint count ) { |
691 | if (m_todoMgr.todoDB() ) | 656 | if (m_todoMgr.todoDB() ) |
692 | m_todoMgr.todoDB()->setReadAhead( count ); | 657 | m_todoMgr.todoDB()->setReadAhead( count ); |
693 | } | 658 | } |
694 | void MainWindow::slotQuickEntered() { | 659 | void MainWindow::slotQuickEntered() { |
695 | qWarning("entered"); | 660 | qWarning("entered"); |
696 | OTodo todo = quickEditor()->todo(); | 661 | OTodo todo = quickEditor()->todo(); |
697 | if (todo.isEmpty() ) | 662 | if (todo.isEmpty() ) |
698 | return; | 663 | return; |
699 | 664 | ||
700 | m_todoMgr.add( todo ); | 665 | m_todoMgr.add( todo ); |
701 | currentView()->addEvent( todo ); | 666 | currentView()->addEvent( todo ); |
702 | raiseCurrentView(); | 667 | raiseCurrentView(); |
703 | } | 668 | } |
704 | QuickEditBase* MainWindow::quickEditor() { | 669 | QuickEditBase* MainWindow::quickEditor() { |
705 | return m_curQuick; | 670 | return m_curQuick; |
706 | } | 671 | } |
672 | void MainWindow::slotComplete( int uid ) { | ||
673 | slotComplete( event(uid) ); | ||
674 | } | ||
675 | void MainWindow::slotComplete( const OTodo& todo ) { | ||
676 | OTodo to = todo; | ||
677 | to.setCompleted( !to.isCompleted() ); | ||
678 | to.setCompletedDate( QDate::currentDate() ); | ||
679 | |||
680 | /* | ||
681 | * if the item does recur | ||
682 | * we need to spin it off | ||
683 | * and update the items duedate to the next | ||
684 | * possible recurrance of this item... | ||
685 | * the spinned off one will loose the | ||
686 | */ | ||
687 | if ( to.recurrence().doesRecur() && to.isCompleted() ) { | ||
688 | OTodo to2( to ); | ||
689 | |||
690 | /* the spinned off one won't recur anymore */ | ||
691 | to.setRecurrence( ORecur() ); | ||
692 | |||
693 | ORecur rec = to2.recurrence(); | ||
694 | rec.setStart( to.dueDate() ); | ||
695 | to2.setRecurrence( rec ); | ||
696 | /* | ||
697 | * if there is a next occurence | ||
698 | * from the duedate of the last recurrance | ||
699 | */ | ||
700 | QDate date; | ||
701 | if ( to2.recurrence().nextOcurrence( to2.dueDate().addDays(1), date ) ) { | ||
702 | QDate inval; | ||
703 | /* generate a new uid for the old record */ | ||
704 | to.setUid( 1 ); | ||
705 | |||
706 | /* add the old one cause it has a new UID here cause it was spin off */ | ||
707 | m_todoMgr.add( to ); | ||
708 | |||
709 | /* | ||
710 | * update the due date | ||
711 | * start date | ||
712 | * and complete date | ||
713 | */ | ||
714 | to2.setDueDate( date ); | ||
715 | to2.setStartDate( inval ); | ||
716 | to2.setCompletedDate( inval ); | ||
717 | to2.setCompleted( false ); | ||
718 | updateTodo( to2 ); | ||
719 | }else | ||
720 | updateTodo( to ); | ||
721 | }else | ||
722 | updateTodo( to ); | ||
723 | |||
724 | currentView()->updateView(); | ||
725 | raiseCurrentView(); | ||
726 | } | ||
727 | void MainWindow::flush() { | ||
728 | slotFlush(); | ||
729 | } | ||
730 | void MainWindow::reload() { | ||
731 | slotReload(); | ||
732 | } | ||
733 | int MainWindow::create() { | ||
734 | int uid = 0; | ||
735 | if(m_syncing) { | ||
736 | QMessageBox::warning(this, tr("Todo"), | ||
737 | tr("Can not edit data, currently syncing")); | ||
738 | return uid; | ||
739 | } | ||
740 | |||
741 | |||
742 | OTodo todo = currentEditor()->newTodo( currentCatId(), | ||
743 | this ); | ||
744 | |||
745 | if ( currentEditor()->accepted() ) { | ||
746 | //todo.assignUid(); | ||
747 | uid = todo.uid(); | ||
748 | m_todoMgr.add( todo ); | ||
749 | currentView()->addEvent( todo ); | ||
750 | |||
751 | |||
752 | // I'm afraid we must call this every time now, otherwise | ||
753 | // spend expensive time comparing all these strings... | ||
754 | // but only call if we changed something -zecke | ||
755 | populateCategories(); | ||
756 | } | ||
757 | raiseCurrentView( ); | ||
758 | |||
759 | return uid; | ||
760 | } | ||
761 | /* delete it silently... */ | ||
762 | bool MainWindow::remove( int uid ) { | ||
763 | if (m_syncing) return false; | ||
764 | |||
765 | return m_todoMgr.remove( uid ); | ||
766 | } | ||
767 | void MainWindow::beam( int uid, int ) { | ||
768 | ::unlink( beamfile ); | ||
769 | OTodo todo = event( uid ); | ||
770 | OTodoAccessVCal* cal = new OTodoAccessVCal(QString::fromLatin1(beamfile) ); | ||
771 | OTodoAccess acc( cal ); | ||
772 | acc.load(); | ||
773 | acc.add( todo ); | ||
774 | acc.save(); | ||
775 | Ir* ir = new Ir(this ); | ||
776 | connect(ir, SIGNAL(done(Ir*) ), | ||
777 | this, SLOT(beamDone(Ir*) ) ); | ||
778 | ir->send( beamfile, todo.summary(), "text/x-vCalendar" ); | ||
779 | } | ||
780 | void MainWindow::show( int uid ) { | ||
781 | slotShow( uid ); | ||
782 | } | ||
783 | void MainWindow::edit( int uid ) { | ||
784 | slotEdit( uid ); | ||
785 | } | ||
786 | void MainWindow::add( const OPimRecord& rec) { | ||
787 | if ( rec.rtti() != OTodo::rtti() ) return; | ||
788 | |||
789 | const OTodo& todo = static_cast<const OTodo&>(rec); | ||
790 | |||
791 | m_todoMgr.add(todo ); | ||
792 | currentView()->addEvent( todo ); | ||
793 | |||
794 | |||
795 | // I'm afraid we must call this every time now, otherwise | ||
796 | // spend expensive time comparing all these strings... | ||
797 | // but only call if we changed something -zecke | ||
798 | populateCategories(); | ||
799 | } | ||
800 | /* todo does not have the QDataStream<< and >> operators implemented :( | ||
801 | * FIXME | ||
802 | */ | ||
803 | OPimRecord* MainWindow::record( int rtti, const QByteArray& ) { | ||
804 | return 0l; | ||
805 | } | ||
diff --git a/core/pim/todo/mainwindow.h b/core/pim/todo/mainwindow.h index 270cbd1..14cfa82 100644 --- a/core/pim/todo/mainwindow.h +++ b/core/pim/todo/mainwindow.h | |||
@@ -1,191 +1,203 @@ | |||
1 | /* | 1 | /* |
2 | =. This file is part of the OPIE Project | 2 | =. This file is part of the OPIE Project |
3 | .=l. Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 3 | .=l. Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
4 | .>+-= | 4 | .>+-= |
5 | _;:, .> :=|. This program is free software; you can | 5 | _;:, .> :=|. This program is free software; you can |
6 | .> <`_, > . <= redistribute it and/or modify it under | 6 | .> <`_, > . <= redistribute it and/or modify it under |
7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
8 | .="- .-=="i, .._ License as published by the Free Software | 8 | .="- .-=="i, .._ License as published by the Free Software |
9 | - . .-<_> .<> Foundation; either version 2 of the License, | 9 | - . .-<_> .<> Foundation; either version 2 of the License, |
10 | ._= =} : or (at your option) any later version. | 10 | ._= =} : or (at your option) any later version. |
11 | .%`+i> _;_. | 11 | .%`+i> _;_. |
12 | .i_,=:_. -<s. This program is distributed in the hope that | 12 | .i_,=:_. -<s. This program is distributed in the hope that |
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
14 | : .. .:, . . . without even the implied warranty of | 14 | : .. .:, . . . without even the implied warranty of |
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
17 | ..}^=.= = ; Library General Public License for more | 17 | ..}^=.= = ; Library General Public License for more |
18 | ++= -. .` .: details. | 18 | ++= -. .` .: details. |
19 | : = ...= . :.=- | 19 | : = ...= . :.=- |
20 | -. .:....=;==+<; You should have received a copy of the GNU | 20 | -. .:....=;==+<; You should have received a copy of the GNU |
21 | -_. . . )=. = Library General Public License along with | 21 | -_. . . )=. = Library General Public License along with |
22 | -- :-=` this library; see the file COPYING.LIB. | 22 | -- :-=` this library; see the file COPYING.LIB. |
23 | If not, write to the Free Software Foundation, | 23 | If not, write to the Free Software Foundation, |
24 | Inc., 59 Temple Place - Suite 330, | 24 | Inc., 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | 28 | ||
29 | #ifndef TODO_MAIN_WINDOW_H | 29 | #ifndef TODO_MAIN_WINDOW_H |
30 | #define TODO_MAIN_WINDOW_H | 30 | #define TODO_MAIN_WINDOW_H |
31 | 31 | ||
32 | #include <qlist.h> | 32 | #include <qlist.h> |
33 | #include <qmainwindow.h> | ||
34 | 33 | ||
35 | #include <opie/otodoaccess.h> | 34 | #include <opie/otodoaccess.h> |
36 | #include <opie/otodo.h> | 35 | #include <opie/otodo.h> |
36 | #include <opie/opimmainwindow.h> | ||
37 | 37 | ||
38 | #include "smalltodo.h" | 38 | #include "smalltodo.h" |
39 | #include "todoview.h" | 39 | #include "todoview.h" |
40 | #include "quickedit.h" | 40 | #include "quickedit.h" |
41 | #include "todomanager.h" | 41 | #include "todomanager.h" |
42 | 42 | ||
43 | class QPopupMenu; | 43 | class QPopupMenu; |
44 | class QMenuBar; | 44 | class QMenuBar; |
45 | class QToolBar; | 45 | class QToolBar; |
46 | class QAction; | 46 | class QAction; |
47 | class QWidgetStack; | 47 | class QWidgetStack; |
48 | class Ir; | 48 | class Ir; |
49 | class QVBox; | 49 | class QVBox; |
50 | 50 | ||
51 | namespace Todo { | 51 | namespace Todo { |
52 | typedef TodoView View; | 52 | typedef TodoView View; |
53 | class TemplateManager; | 53 | class TemplateManager; |
54 | class Editor; | 54 | class Editor; |
55 | class TodoShow; | 55 | class TodoShow; |
56 | class TemplateEditor; | 56 | class TemplateEditor; |
57 | struct QuickEditBase; | 57 | struct QuickEditBase; |
58 | 58 | ||
59 | class MainWindow : public QMainWindow { | 59 | class MainWindow : public OPimMainWindow { |
60 | Q_OBJECT | 60 | Q_OBJECT |
61 | friend class TodoView; // avoid QObject here.... | ||
61 | public: | 62 | public: |
62 | MainWindow( QWidget *parent = 0, | 63 | MainWindow( QWidget *parent = 0, |
63 | const char* name = 0 ); | 64 | const char* name = 0 ); |
64 | ~MainWindow(); | 65 | ~MainWindow(); |
65 | 66 | ||
66 | /** return a context menu for an OTodo */ | 67 | /** return a context menu for an OTodo */ |
67 | QPopupMenu* contextMenu(int uid ); | 68 | QPopupMenu* contextMenu(int uid, bool doesRecur = FALSE ); |
68 | QPopupMenu* options(); | 69 | QPopupMenu* options(); |
69 | QPopupMenu* edit(); | 70 | QPopupMenu* edit(); |
70 | QPopupMenu* view(); | ||
71 | QToolBar* toolbar(); | 71 | QToolBar* toolbar(); |
72 | 72 | ||
73 | 73 | ||
74 | void updateList(); | 74 | void updateList(); |
75 | OTodoAccess::List list()const; | 75 | OTodoAccess::List list()const; |
76 | OTodoAccess::List sorted( bool asc, int sortOrder ); | 76 | OTodoAccess::List sorted( bool asc, int sortOrder ); |
77 | OTodoAccess::List sorted( bool asc, int sortOrder, int addFilter ); | 77 | OTodoAccess::List sorted( bool asc, int sortOrder, int addFilter ); |
78 | 78 | ||
79 | OTodo event(int uid ); | 79 | OTodo event(int uid ); |
80 | 80 | ||
81 | bool isSyncing()const; | 81 | bool isSyncing()const; |
82 | bool showCompleted()const; | 82 | bool showCompleted()const; |
83 | bool showDeadline()const; | 83 | bool showDeadline()const; |
84 | bool showOverDue()const; | 84 | bool showOverDue()const; |
85 | QString currentCategory()const; | 85 | QString currentCategory()const; |
86 | int currentCatId(); | 86 | int currentCatId(); |
87 | TemplateManager* templateManager(); | 87 | TemplateManager* templateManager(); |
88 | QuickEditBase* quickEditor(); | 88 | QuickEditBase* quickEditor(); |
89 | 89 | ||
90 | void updateTodo( const OTodo& ); | 90 | void updateTodo( const OTodo& ); |
91 | void populateTemplates(); | 91 | void populateTemplates(); |
92 | Editor* currentEditor(); | 92 | Editor* currentEditor(); |
93 | void setReadAhead(uint count ); | 93 | void setReadAhead(uint count ); |
94 | private slots: | 94 | private slots: |
95 | void slotQuickEntered(); | 95 | void slotQuickEntered(); |
96 | void populateCategories(); | 96 | void populateCategories(); |
97 | void slotReload(); | 97 | void slotReload(); |
98 | void slotFlush(); | 98 | void slotFlush(); |
99 | 99 | ||
100 | protected: | 100 | protected: |
101 | void closeEvent( QCloseEvent* e ); | 101 | void closeEvent( QCloseEvent* e ); |
102 | 102 | ||
103 | private: | 103 | private: |
104 | void receiveFile( const QString& filename ); | 104 | void receiveFile( const QString& filename ); |
105 | void connectBase( ViewBase* ); | 105 | void connectBase( ViewBase* ); |
106 | void initUI(); | 106 | void initUI(); |
107 | void initActions(); | 107 | void initActions(); |
108 | void initConfig(); | 108 | void initConfig(); |
109 | void initViews(); | 109 | void initViews(); |
110 | void initEditor(); | 110 | void initEditor(); |
111 | void initShow(); | 111 | void initShow(); |
112 | void initTemplate(); | 112 | void initTemplate(); |
113 | void raiseCurrentView(); | 113 | void raiseCurrentView(); |
114 | ViewBase* currentView(); | 114 | ViewBase* currentView(); |
115 | ViewBase* m_curView; | 115 | ViewBase* m_curView; |
116 | QuickEditBase* m_curQuick; | 116 | QuickEditBase* m_curQuick; |
117 | Editor* m_curEdit; | 117 | Editor* m_curEdit; |
118 | TodoShow* currentShow(); | 118 | TodoShow* currentShow(); |
119 | TodoShow* m_curShow; | 119 | TodoShow* m_curShow; |
120 | TemplateEditor* currentTemplateEditor(); | 120 | TemplateEditor* currentTemplateEditor(); |
121 | TemplateEditor* m_curTempEd; | 121 | TemplateEditor* m_curTempEd; |
122 | 122 | ||
123 | QMenuBar* m_bar; | 123 | QMenuBar* m_bar; |
124 | QToolBar* m_tool; | 124 | QToolBar* m_tool; |
125 | QAction* m_editAction, | 125 | QAction* m_editAction, |
126 | *m_deleteAction, | 126 | *m_deleteAction, |
127 | *m_findAction, | 127 | *m_findAction, |
128 | *m_completedAction, | 128 | *m_completedAction, |
129 | *m_showDeadLineAction, | 129 | *m_showDeadLineAction, |
130 | *m_deleteAllAction, | 130 | *m_deleteAllAction, |
131 | *m_deleteCompleteAction, | 131 | *m_deleteCompleteAction, |
132 | *m_duplicateAction, | 132 | *m_duplicateAction, |
133 | *m_showOverDueAction, | 133 | *m_showOverDueAction, |
134 | *m_effectiveAction; | 134 | *m_effectiveAction; |
135 | QWidgetStack *m_stack; | 135 | QWidgetStack *m_stack; |
136 | QPopupMenu* m_catMenu, | 136 | QPopupMenu* m_catMenu, |
137 | *m_edit, | 137 | *m_edit, |
138 | *m_options, | 138 | *m_options, |
139 | *m_view, | ||
140 | *m_template; | 139 | *m_template; |
141 | /* box with two rows | 140 | /* box with two rows |
142 | * top will be the quick edit | 141 | * top will be the quick edit |
143 | * this will bite my ass once | 142 | * this will bite my ass once |
144 | * we want to have all parts | 143 | * we want to have all parts |
145 | * exchangeable | 144 | * exchangeable |
146 | */ | 145 | */ |
147 | QVBox* m_mainBox; | 146 | QVBox* m_mainBox; |
148 | 147 | ||
149 | bool m_syncing:1; | 148 | bool m_syncing:1; |
150 | bool m_deadline:1; | 149 | bool m_deadline:1; |
151 | bool m_completed:1; | 150 | bool m_completed:1; |
152 | bool m_overdue:1; | 151 | bool m_overdue:1; |
153 | TodoManager m_todoMgr; | 152 | TodoManager m_todoMgr; |
154 | QString m_curCat; | 153 | QString m_curCat; |
155 | QList<ViewBase> m_views; | 154 | QList<ViewBase> m_views; |
156 | QList<QuickEditBase> m_quickEdit; | 155 | QList<QuickEditBase> m_quickEdit; |
157 | uint m_counter; | 156 | uint m_counter; |
158 | TemplateManager* m_tempManager; | 157 | TemplateManager* m_tempManager; |
159 | 158 | ||
160 | 159 | ||
161 | private slots: | 160 | private slots: |
162 | void slotShow(int); | 161 | void slotShow(int); |
163 | void slotEdit(int); | 162 | void slotEdit(int); |
164 | private slots: | ||
165 | void slotUpdate3( QWidget* ); | 163 | void slotUpdate3( QWidget* ); |
164 | void slotComplete( int uid ); | ||
165 | void slotComplete( const OTodo& ev ); | ||
166 | void slotNewFromTemplate(int id ); | 166 | void slotNewFromTemplate(int id ); |
167 | void slotNew(); | 167 | void slotNew(); |
168 | void slotDuplicate(); | 168 | void slotDuplicate(); |
169 | |||
169 | void slotDelete(); | 170 | void slotDelete(); |
170 | void slotDeleteAll(); | 171 | void slotDeleteAll(); |
171 | void slotDeleteCompleted(); | 172 | void slotDeleteCompleted(); |
172 | 173 | ||
173 | void slotEdit(); | 174 | void slotEdit(); |
174 | void slotFind(); | 175 | void slotFind(); |
175 | 176 | ||
176 | void setCategory( int ); | 177 | void setCategory( int ); |
177 | 178 | ||
178 | void slotShowDeadLine( bool ); | 179 | void slotShowDeadLine( bool ); |
179 | void slotShowCompleted( bool ); | 180 | void slotShowCompleted( bool ); |
180 | 181 | ||
181 | void setDocument( const QString& ); | 182 | void setDocument( const QString& ); |
182 | 183 | ||
183 | 184 | ||
184 | void slotBeam(); | 185 | void slotBeam(); |
185 | void beamDone( Ir* ); | 186 | void beamDone( Ir* ); |
186 | void slotShowDetails(); | 187 | void slotShowDetails(); |
187 | void slotShowDue( bool ); | 188 | void slotShowDue( bool ); |
189 | /* reimplementation from opimmainwindow */ | ||
190 | protected slots: | ||
191 | void flush(); | ||
192 | void reload(); | ||
193 | int create(); | ||
194 | bool remove( int uid ); | ||
195 | void beam(int uid, int transport = IrDa ); | ||
196 | void show( int uid ); | ||
197 | void edit( int uid ); | ||
198 | void add( const OPimRecord& ); | ||
199 | OPimRecord* record( int rtti, const QByteArray& ); | ||
188 | }; | 200 | }; |
189 | }; | 201 | }; |
190 | 202 | ||
191 | #endif | 203 | #endif |
diff --git a/core/pim/todo/otaskeditor.cpp b/core/pim/todo/otaskeditor.cpp index 8b261de..eeb3c0c 100644 --- a/core/pim/todo/otaskeditor.cpp +++ b/core/pim/todo/otaskeditor.cpp | |||
@@ -1,91 +1,100 @@ | |||
1 | #include <qdatetime.h> | 1 | #include <qdatetime.h> |
2 | #include <qlayout.h> | 2 | #include <qlayout.h> |
3 | #include <qlabel.h> | 3 | #include <qlabel.h> |
4 | #include <qmultilineedit.h> | 4 | #include <qmultilineedit.h> |
5 | #include <qscrollview.h> | ||
5 | 6 | ||
6 | #include <opie/orecurrancewidget.h> | 7 | #include <opie/orecurrancewidget.h> |
7 | 8 | ||
8 | #include "taskeditoroverviewimpl.h" | 9 | #include "taskeditoroverviewimpl.h" |
9 | #include "taskeditoradvanced.h" | 10 | #include "taskeditoradvancedimpl.h" |
10 | #include "taskeditoralarms.h" | 11 | #include "taskeditoralarms.h" |
11 | 12 | ||
12 | #include "otaskeditor.h" | 13 | #include "otaskeditor.h" |
13 | 14 | ||
14 | OTaskEditor::OTaskEditor(int cur) | 15 | OTaskEditor::OTaskEditor(int cur) |
15 | : QDialog(0, 0, TRUE ) { | 16 | : QDialog(0, 0, TRUE ) { |
16 | init(); | 17 | init(); |
17 | init( cur ); | 18 | init( cur ); |
18 | } | 19 | } |
19 | OTaskEditor::OTaskEditor( const OTodo& to) | 20 | OTaskEditor::OTaskEditor( const OTodo& to) |
20 | : QDialog(0, 0, TRUE ) { | 21 | : QDialog(0, 0, TRUE ) { |
21 | init(); | 22 | init(); |
22 | init( to ); | 23 | init( to ); |
23 | } | 24 | } |
24 | OTaskEditor::~OTaskEditor() { | 25 | OTaskEditor::~OTaskEditor() { |
25 | 26 | ||
26 | } | 27 | } |
27 | void OTaskEditor::init( int cur ) { | 28 | void OTaskEditor::init( int cur ) { |
28 | OTodo to; | 29 | OTodo to; |
29 | if ( cur != 0 ) | 30 | if ( cur != 0 ) |
30 | to.setCategories( cur ); | 31 | to.setCategories( cur ); |
31 | load(to); | 32 | load(to); |
32 | m_uid = 1; // generate a new one | 33 | m_uid = 1; // generate a new one |
33 | } | 34 | } |
34 | void OTaskEditor::init( const OTodo& to ) { | 35 | void OTaskEditor::init( const OTodo& to ) { |
35 | load( to ); | 36 | load( to ); |
36 | m_uid = to.uid(); | 37 | m_uid = to.uid(); |
37 | } | 38 | } |
38 | OTodo OTaskEditor::todo()const{ | 39 | OTodo OTaskEditor::todo()const{ |
39 | qWarning("saving!"); | 40 | qWarning("saving!"); |
40 | OTodo to; | 41 | OTodo to; |
41 | to.setUid(m_uid ); | 42 | to.setUid(m_uid ); |
42 | m_overView->save( to ); | 43 | m_overView->save( to ); |
43 | to.setDescription( m_line->text() ); | 44 | m_adv->save( to ); |
45 | to.setRecurrence( m_rec->recurrence() ); | ||
44 | 46 | ||
45 | return to; | 47 | return to; |
46 | } | 48 | } |
47 | void OTaskEditor::load(const OTodo& to) { | 49 | void OTaskEditor::load(const OTodo& to) { |
48 | m_overView->load( to ); | 50 | m_overView->load( to ); |
49 | m_line->setText( to.description() ); | 51 | m_adv->load( to ); |
52 | m_rec->setRecurrence( to.recurrence(), to.hasDueDate() ? to.dueDate() : QDate::currentDate() ); | ||
50 | } | 53 | } |
51 | void OTaskEditor::init() { | 54 | void OTaskEditor::init() { |
52 | QVBoxLayout* lay = new QVBoxLayout(this); | 55 | QVBoxLayout* lay = new QVBoxLayout(this ); |
56 | QScrollView* view = new QScrollView( this ); | ||
57 | view->setResizePolicy( QScrollView::AutoOneFit ); | ||
58 | lay->addWidget( view ); | ||
59 | |||
53 | setCaption("Task Editor"); | 60 | setCaption("Task Editor"); |
54 | m_tab = new OTabWidget(this); | 61 | QWidget* container = new QWidget( view->viewport() ); |
62 | view->addChild( container ); | ||
55 | 63 | ||
64 | QVBoxLayout* layo = new QVBoxLayout( container ); | ||
65 | m_tab = new OTabWidget(container ); | ||
66 | layo->addWidget( m_tab ); | ||
56 | /* | 67 | /* |
57 | * Add the Widgets | 68 | * Add the Widgets |
58 | */ | 69 | */ |
59 | m_overView = new TaskEditorOverViewImpl(m_tab ); | 70 | m_overView = new TaskEditorOverViewImpl(m_tab ); |
60 | m_tab->addTab( m_overView, QString::null, tr("Overview") ); | 71 | m_tab->addTab( m_overView, QString::null, tr("Overview") ); |
61 | 72 | ||
62 | m_adv = new TaskEditorAdvanced( m_tab ); | 73 | m_adv = new TaskEditorAdvancedImpl( m_tab ); |
63 | m_line = new QMultiLineEdit(m_adv ); | ||
64 | m_line->setWordWrap( QMultiLineEdit::WidgetWidth ); | ||
65 | QLabel* label = new QLabel(m_adv ); | ||
66 | label->setText( tr("Description") ); | ||
67 | ((QGridLayout*) m_adv->layout() )->addWidget( label,3, 0 ); | ||
68 | ((QGridLayout*) m_adv->layout())->addWidget( m_line,4,0 ); | ||
69 | m_tab->addTab( m_adv, QString::null, tr("Advanced") ); | 74 | m_tab->addTab( m_adv, QString::null, tr("Advanced") ); |
70 | 75 | ||
71 | m_alarm = new TaskEditorAlarms( m_tab ); | 76 | m_alarm = new TaskEditorAlarms( m_tab ); |
72 | m_tab->addTab( m_alarm, QString::null, tr("Alarms") ); | 77 | m_tab->addTab( m_alarm, QString::null, tr("Alarms") ); |
73 | 78 | ||
74 | m_remind = new TaskEditorAlarms( m_tab ); | 79 | m_remind = new TaskEditorAlarms( m_tab ); |
75 | m_tab->addTab( m_remind, QString::null, tr("Reminders") ); | 80 | m_tab->addTab( m_remind, QString::null, tr("Reminders") ); |
76 | 81 | ||
77 | QLabel* lbl = new QLabel(m_tab ); | 82 | QLabel* lbl = new QLabel(m_tab ); |
78 | lbl->setText( tr("X-Ref") ); | 83 | lbl->setText( tr("X-Ref") ); |
79 | m_tab->addTab( lbl, QString::null, tr("X-Ref") ); | 84 | m_tab->addTab( lbl, QString::null, tr("X-Ref") ); |
80 | 85 | ||
81 | m_rec = new ORecurranceWidget( true, QDate::currentDate(), this ); | 86 | m_rec = new ORecurranceWidget( true, QDate::currentDate(), this ); |
82 | m_tab->addTab( m_rec, QString::null, tr("Recurrance") ); | 87 | m_tab->addTab( m_rec, QString::null, tr("Recurrance") ); |
83 | 88 | ||
84 | lay->addWidget(m_tab ); | ||
85 | 89 | ||
86 | /* signal and slots */ | 90 | /* signal and slots */ |
87 | connect(m_overView, SIGNAL(recurranceEnabled(bool) ), | 91 | connect(m_overView, SIGNAL(recurranceEnabled(bool) ), |
88 | m_rec, SLOT(setEnabled(bool) ) ); | 92 | m_rec, SLOT(setEnabled(bool) ) ); |
89 | 93 | ||
94 | /* connect due date changed to the recurrence tab */ | ||
95 | connect(m_overView, SIGNAL(dueDateChanged(const QDate&) ), | ||
96 | m_rec, SLOT(setStartDate(const QDate& ) ) ); | ||
97 | |||
98 | |||
90 | m_tab->setCurrentTab( m_overView ); | 99 | m_tab->setCurrentTab( m_overView ); |
91 | } | 100 | } |
diff --git a/core/pim/todo/otaskeditor.h b/core/pim/todo/otaskeditor.h index bcbd543..b43abbf 100644 --- a/core/pim/todo/otaskeditor.h +++ b/core/pim/todo/otaskeditor.h | |||
@@ -1,44 +1,43 @@ | |||
1 | #ifndef OPIE_TASK_EDITOR_H | 1 | #ifndef OPIE_TASK_EDITOR_H |
2 | #define OPIE_TASK_EDITOR_H | 2 | #define OPIE_TASK_EDITOR_H |
3 | 3 | ||
4 | #include <qdialog.h> | 4 | #include <qdialog.h> |
5 | 5 | ||
6 | #include <opie/otodo.h> | 6 | #include <opie/otodo.h> |
7 | #include <opie/otabwidget.h> | 7 | #include <opie/otabwidget.h> |
8 | 8 | ||
9 | class TaskEditorOverViewImpl; | 9 | class TaskEditorOverViewImpl; |
10 | class TaskEditorAdvanced; | 10 | class TaskEditorAdvancedImpl; |
11 | class TaskEditorAlarms; | 11 | class TaskEditorAlarms; |
12 | class ORecurranceWidget; | 12 | class ORecurranceWidget; |
13 | class QMultiLineEdit; | 13 | class QMultiLineEdit; |
14 | class OTaskEditor : public QDialog { | 14 | class OTaskEditor : public QDialog { |
15 | Q_OBJECT | 15 | Q_OBJECT |
16 | public: | 16 | public: |
17 | OTaskEditor(int cur); | 17 | OTaskEditor(int cur); |
18 | OTaskEditor( const OTodo& todo ); | 18 | OTaskEditor( const OTodo& todo ); |
19 | ~OTaskEditor(); | 19 | ~OTaskEditor(); |
20 | 20 | ||
21 | /* | 21 | /* |
22 | * same as the c'tor but this gives us the | 22 | * same as the c'tor but this gives us the |
23 | * power to 'preload' the dialog | 23 | * power to 'preload' the dialog |
24 | */ | 24 | */ |
25 | void init( int cur ); | 25 | void init( int cur ); |
26 | void init( const OTodo& todo ); | 26 | void init( const OTodo& todo ); |
27 | 27 | ||
28 | OTodo todo()const; | 28 | OTodo todo()const; |
29 | private: | 29 | private: |
30 | void load( const OTodo& ); | 30 | void load( const OTodo& ); |
31 | void init(); | 31 | void init(); |
32 | 32 | ||
33 | OTabWidget *m_tab; | 33 | OTabWidget *m_tab; |
34 | TaskEditorOverViewImpl* m_overView; | 34 | TaskEditorOverViewImpl* m_overView; |
35 | TaskEditorAdvanced *m_adv; | 35 | TaskEditorAdvancedImpl *m_adv; |
36 | TaskEditorAlarms *m_alarm; | 36 | TaskEditorAlarms *m_alarm; |
37 | TaskEditorAlarms* m_remind; | 37 | TaskEditorAlarms* m_remind; |
38 | ORecurranceWidget* m_rec; | 38 | ORecurranceWidget* m_rec; |
39 | QMultiLineEdit* m_line; | ||
40 | int m_uid; | 39 | int m_uid; |
41 | 40 | ||
42 | }; | 41 | }; |
43 | 42 | ||
44 | #endif | 43 | #endif |
diff --git a/core/pim/todo/tableview.cpp b/core/pim/todo/tableview.cpp index ded2dbd..0f683c9 100644 --- a/core/pim/todo/tableview.cpp +++ b/core/pim/todo/tableview.cpp | |||
@@ -1,527 +1,524 @@ | |||
1 | /* | 1 | /* |
2 | =. This file is part of the OPIE Project | 2 | =. This file is part of the OPIE Project |
3 | .=l. Copyright (c) 2002 <zecke> | 3 | .=l. Copyright (c) 2002 <zecke> |
4 | .>+-= | 4 | .>+-= |
5 | _;:, .> :=|. This program is free software; you can | 5 | _;:, .> :=|. This program is free software; you can |
6 | .> <`_, > . <= redistribute it and/or modify it under | 6 | .> <`_, > . <= redistribute it and/or modify it under |
7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
8 | .="- .-=="i, .._ License as published by the Free Software | 8 | .="- .-=="i, .._ License as published by the Free Software |
9 | - . .-<_> .<> Foundation; either version 2 of the License, | 9 | - . .-<_> .<> Foundation; either version 2 of the License, |
10 | ._= =} : or (at your option) any later version. | 10 | ._= =} : or (at your option) any later version. |
11 | .%`+i> _;_. | 11 | .%`+i> _;_. |
12 | .i_,=:_. -<s. This program is distributed in the hope that | 12 | .i_,=:_. -<s. This program is distributed in the hope that |
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
14 | : .. .:, . . . without even the implied warranty of | 14 | : .. .:, . . . without even the implied warranty of |
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
17 | ..}^=.= = ; Library General Public License for more | 17 | ..}^=.= = ; Library General Public License for more |
18 | ++= -. .` .: details. | 18 | ++= -. .` .: details. |
19 | : = ...= . :.=- | 19 | : = ...= . :.=- |
20 | -. .:....=;==+<; You should have received a copy of the GNU | 20 | -. .:....=;==+<; You should have received a copy of the GNU |
21 | -_. . . )=. = Library General Public License along with | 21 | -_. . . )=. = Library General Public License along with |
22 | -- :-=` this library; see the file COPYING.LIB. | 22 | -- :-=` this library; see the file COPYING.LIB. |
23 | If not, write to the Free Software Foundation, | 23 | If not, write to the Free Software Foundation, |
24 | Inc., 59 Temple Place - Suite 330, | 24 | Inc., 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | #include <stdlib.h> | 28 | #include <stdlib.h> |
29 | #include <cmath> | 29 | #include <cmath> |
30 | 30 | ||
31 | #include <qlineedit.h> | 31 | #include <qlineedit.h> |
32 | #include <qtimer.h> | 32 | #include <qtimer.h> |
33 | #include <qpoint.h> | 33 | #include <qpoint.h> |
34 | #include <qpopupmenu.h> | 34 | #include <qpopupmenu.h> |
35 | 35 | ||
36 | #include <qpe/config.h> | 36 | #include <qpe/config.h> |
37 | 37 | ||
38 | #include <opie/orecur.h> | ||
39 | |||
38 | #include "mainwindow.h" | 40 | #include "mainwindow.h" |
39 | //#include "tableitems.h" | 41 | //#include "tableitems.h" |
40 | #include "tableview.h" | 42 | #include "tableview.h" |
41 | 43 | ||
42 | using namespace Todo; | 44 | using namespace Todo; |
43 | 45 | ||
44 | namespace { | 46 | namespace { |
45 | static const int BoxSize = 14; | 47 | static const int BoxSize = 14; |
46 | static const int RowHeight = 20; | 48 | static const int RowHeight = 20; |
47 | } | 49 | } |
48 | 50 | ||
49 | 51 | ||
50 | void TableView::initConfig() { | 52 | void TableView::initConfig() { |
51 | Config config( "todo" ); | 53 | Config config( "todo" ); |
52 | config.setGroup( "Options" ); | 54 | config.setGroup( "Options" ); |
53 | m_completeStrokeWidth = config.readNumEntry( "CompleteStrokeWidth", 8 ); | 55 | m_completeStrokeWidth = config.readNumEntry( "CompleteStrokeWidth", 8 ); |
54 | } | 56 | } |
55 | 57 | ||
56 | TableView::TableView( MainWindow* window, QWidget* wid ) | 58 | TableView::TableView( MainWindow* window, QWidget* wid ) |
57 | : QTable( wid ), TodoView( window ) { | 59 | : QTable( wid ), TodoView( window ) { |
58 | setUpdatesEnabled( false ); | 60 | setUpdatesEnabled( false ); |
59 | viewport()->setUpdatesEnabled( false ); | 61 | viewport()->setUpdatesEnabled( false ); |
60 | m_enablePaint = false; | 62 | m_enablePaint = false; |
61 | setNumRows(0); | 63 | setNumRows(0); |
62 | setNumCols(4); | 64 | setNumCols(4); |
63 | 65 | ||
64 | setSorting( TRUE ); | 66 | setSorting( TRUE ); |
65 | setSelectionMode( NoSelection ); | 67 | setSelectionMode( NoSelection ); |
66 | // setColumnStretchable( 2, TRUE ); | 68 | // setColumnStretchable( 2, TRUE ); |
67 | setColumnStretchable( 3, FALSE ); | 69 | setColumnStretchable( 3, FALSE ); |
68 | setColumnWidth(0, 20 ); | 70 | setColumnWidth(0, 20 ); |
69 | setColumnWidth(1, 35 ); | 71 | setColumnWidth(1, 35 ); |
70 | setColumnWidth(3, 18 ); | 72 | setColumnWidth(3, 18 ); |
71 | 73 | ||
72 | setLeftMargin( 0 ); | 74 | setLeftMargin( 0 ); |
73 | verticalHeader()->hide(); | 75 | verticalHeader()->hide(); |
74 | 76 | ||
75 | horizontalHeader()->setLabel(0, tr("C.") ); | 77 | horizontalHeader()->setLabel(0, tr("C.") ); |
76 | horizontalHeader()->setLabel(1, tr("Prior.") ); | 78 | horizontalHeader()->setLabel(1, tr("Prior.") ); |
77 | horizontalHeader()->setLabel(2, tr("Description" ) ); | 79 | horizontalHeader()->setLabel(2, tr("Description" ) ); |
78 | 80 | ||
79 | // setColumnStretchable(3, FALSE ); | 81 | // setColumnStretchable(3, FALSE ); |
80 | 82 | ||
81 | horizontalHeader()->setLabel(3, tr("Deadline") ); | 83 | horizontalHeader()->setLabel(3, tr("Deadline") ); |
82 | 84 | ||
83 | if ( todoWindow()->showDeadline() ) | 85 | if ( todoWindow()->showDeadline() ) |
84 | showColumn( 3); | 86 | showColumn( 3); |
85 | else | 87 | else |
86 | hideColumn(3 ); | 88 | hideColumn(3 ); |
87 | 89 | ||
88 | connect((QTable*)this, SIGNAL( clicked( int, int, int, const QPoint& ) ), | 90 | connect((QTable*)this, SIGNAL( clicked( int, int, int, const QPoint& ) ), |
89 | this, SLOT( slotClicked(int, int, int, const QPoint& ) ) ); | 91 | this, SLOT( slotClicked(int, int, int, const QPoint& ) ) ); |
90 | connect((QTable*)this, SIGNAL( pressed( int, int, int, const QPoint& ) ), | 92 | connect((QTable*)this, SIGNAL( pressed( int, int, int, const QPoint& ) ), |
91 | this, SLOT( slotPressed(int, int, int, const QPoint& ) ) ); | 93 | this, SLOT( slotPressed(int, int, int, const QPoint& ) ) ); |
92 | connect((QTable*)this, SIGNAL(valueChanged(int, int) ), | 94 | connect((QTable*)this, SIGNAL(valueChanged(int, int) ), |
93 | this, SLOT( slotValueChanged(int, int) ) ); | 95 | this, SLOT( slotValueChanged(int, int) ) ); |
94 | connect((QTable*)this, SIGNAL(currentChanged(int, int) ), | 96 | connect((QTable*)this, SIGNAL(currentChanged(int, int) ), |
95 | this, SLOT( slotCurrentChanged(int, int) ) ); | 97 | this, SLOT( slotCurrentChanged(int, int) ) ); |
96 | 98 | ||
97 | m_menuTimer = new QTimer( this ); | 99 | m_menuTimer = new QTimer( this ); |
98 | connect( m_menuTimer, SIGNAL(timeout()), | 100 | connect( m_menuTimer, SIGNAL(timeout()), |
99 | this, SLOT(slotShowMenu()) ); | 101 | this, SLOT(slotShowMenu()) ); |
100 | 102 | ||
101 | m_enablePaint = true; | 103 | m_enablePaint = true; |
102 | setUpdatesEnabled( true ); | 104 | setUpdatesEnabled( true ); |
103 | viewport()->setUpdatesEnabled( true ); | 105 | viewport()->setUpdatesEnabled( true ); |
104 | viewport()->update(); | 106 | viewport()->update(); |
105 | setSortOrder( 0 ); | 107 | setSortOrder( 0 ); |
106 | setAscending( TRUE ); | 108 | setAscending( TRUE ); |
107 | m_first = true; | 109 | m_first = true; |
108 | 110 | ||
109 | /* now let's init the config */ | 111 | /* now let's init the config */ |
110 | initConfig(); | 112 | initConfig(); |
111 | } | 113 | } |
112 | /* a new day has started | 114 | /* a new day has started |
113 | * update the day | 115 | * update the day |
114 | */ | 116 | */ |
115 | void TableView::newDay() { | 117 | void TableView::newDay() { |
116 | clear(); | 118 | clear(); |
117 | updateView(); | 119 | updateView(); |
118 | } | 120 | } |
119 | TableView::~TableView() { | 121 | TableView::~TableView() { |
120 | 122 | ||
121 | } | 123 | } |
122 | void TableView::slotShowMenu() { | 124 | void TableView::slotShowMenu() { |
123 | QPopupMenu *menu = todoWindow()->contextMenu( current() ); | 125 | QPopupMenu *menu = todoWindow()->contextMenu( current(), sorted()[currentRow()].recurrence().doesRecur() ); |
124 | menu->exec(QCursor::pos() ); | 126 | menu->exec(QCursor::pos() ); |
125 | delete menu; | 127 | delete menu; |
126 | } | 128 | } |
127 | QString TableView::type() const { | 129 | QString TableView::type() const { |
128 | return QString::fromLatin1( tr("Table View") ); | 130 | return QString::fromLatin1( tr("Table View") ); |
129 | } | 131 | } |
130 | int TableView::current() { | 132 | int TableView::current() { |
131 | int uid = sorted().uidAt(currentRow() ); | 133 | int uid = sorted().uidAt(currentRow() ); |
132 | qWarning("uid %d", uid ); | 134 | |
133 | return uid; | 135 | return uid; |
134 | } | 136 | } |
135 | QString TableView::currentRepresentation() { | 137 | QString TableView::currentRepresentation() { |
136 | return text( currentRow(), 2); | 138 | OTodo to = sorted()[currentRow()]; |
139 | return to.summary().isEmpty() ? to.description().left(20) : to.summary() ; | ||
137 | } | 140 | } |
138 | /* show overdue */ | 141 | /* show overdue */ |
139 | void TableView::showOverDue( bool ) { | 142 | void TableView::showOverDue( bool ) { |
140 | clear(); | 143 | clear(); |
141 | updateView(); | 144 | updateView(); |
142 | } | 145 | } |
143 | 146 | ||
144 | void TableView::updateView( ) { | 147 | void TableView::updateView( ) { |
145 | qWarning("update view"); | 148 | qWarning("update view"); |
146 | m_row = false; | 149 | m_row = false; |
147 | static int id; | 150 | static int id; |
148 | id = startTimer(2000 ); | 151 | id = startTimer(4000 ); |
149 | /* FIXME we want one page to be read! | 152 | /* FIXME we want one page to be read! |
150 | * | 153 | * |
151 | * Calculate that screensize | 154 | * Calculate that screensize |
152 | */ | 155 | */ |
153 | todoWindow()->setReadAhead( 4 ); | 156 | todoWindow()->setReadAhead( 4 ); |
154 | sort(); | 157 | sort(); |
155 | OTodoAccess::List::Iterator it, end; | 158 | OTodoAccess::List::Iterator it, end; |
156 | it = sorted().begin(); | 159 | it = sorted().begin(); |
157 | end = sorted().end(); | 160 | end = sorted().end(); |
158 | 161 | ||
159 | qWarning("setTodos"); | 162 | qWarning("setTodos"); |
160 | QTime time; | 163 | QTime time; |
161 | time.start(); | 164 | time.start(); |
162 | m_enablePaint = false; | 165 | m_enablePaint = false; |
163 | setUpdatesEnabled( false ); | 166 | setUpdatesEnabled( false ); |
164 | viewport()->setUpdatesEnabled( false ); | 167 | viewport()->setUpdatesEnabled( false ); |
165 | 168 | ||
166 | setNumRows( it.count() ); | 169 | setNumRows( it.count() ); |
167 | if ( it.count() == 0 ) | 170 | if ( it.count() == 0 ) |
168 | killTimer(id); | 171 | killTimer(id); |
169 | 172 | ||
170 | int elc = time.elapsed(); | 173 | int elc = time.elapsed(); |
171 | setUpdatesEnabled( true ); | 174 | setUpdatesEnabled( true ); |
172 | viewport()->setUpdatesEnabled( true ); | 175 | viewport()->setUpdatesEnabled( true ); |
173 | viewport()->update(); | 176 | viewport()->update(); |
174 | 177 | ||
175 | m_enablePaint = true; | 178 | m_enablePaint = true; |
176 | int el = time.elapsed(); | 179 | int el = time.elapsed(); |
177 | } | 180 | } |
178 | void TableView::setTodo( int, const OTodo&) { | 181 | void TableView::setTodo( int, const OTodo&) { |
179 | sort(); | 182 | sort(); |
180 | 183 | ||
181 | /* repaint */ | 184 | /* repaint */ |
182 | repaint(); | 185 | repaint(); |
183 | } | 186 | } |
184 | void TableView::addEvent( const OTodo&) { | 187 | void TableView::addEvent( const OTodo&) { |
185 | 188 | ||
186 | /* fix problems of not showing the 'Haken' */ | 189 | /* fix problems of not showing the 'Haken' */ |
187 | updateView(); | 190 | updateView(); |
188 | } | 191 | } |
189 | /* | 192 | /* |
190 | * find the event | 193 | * find the event |
191 | * and then replace the complete row | 194 | * and then replace the complete row |
192 | */ | 195 | */ |
193 | void TableView::replaceEvent( const OTodo& ev) { | 196 | void TableView::replaceEvent( const OTodo& ev) { |
194 | addEvent( ev ); | 197 | addEvent( ev ); |
195 | } | 198 | } |
196 | /* | 199 | /* |
197 | * re aligning table can be slow too | 200 | * re aligning table can be slow too |
198 | * FIXME: look what performs better | 201 | * FIXME: look what performs better |
199 | * either this or the old align table | 202 | * either this or the old align table |
200 | */ | 203 | */ |
201 | void TableView::removeEvent( int ) { | 204 | void TableView::removeEvent( int ) { |
202 | updateView(); | 205 | updateView(); |
203 | } | 206 | } |
204 | void TableView::setShowCompleted( bool b) { | 207 | void TableView::setShowCompleted( bool b) { |
205 | qWarning("Show Completed %d" + b ); | 208 | qWarning("Show Completed %d" + b ); |
206 | updateView(); | 209 | updateView(); |
207 | } | 210 | } |
208 | void TableView::setShowDeadline( bool b) { | 211 | void TableView::setShowDeadline( bool b) { |
209 | qWarning("Show DeadLine %d" + b ); | 212 | qWarning("Show DeadLine %d" + b ); |
210 | if (b) | 213 | if (b) |
211 | showColumn(3 ); | 214 | showColumn(3 ); |
212 | else | 215 | else |
213 | hideColumn(3 ); | 216 | hideColumn(3 ); |
214 | } | 217 | } |
215 | void TableView::setShowCategory( const QString& str) { | 218 | void TableView::setShowCategory( const QString& str) { |
216 | qWarning("setShowCategory"); | 219 | qWarning("setShowCategory"); |
217 | if ( str != m_oleCat || m_first ) | 220 | if ( str != m_oleCat || m_first ) |
218 | updateView(); | 221 | updateView(); |
219 | 222 | ||
220 | m_oleCat = str; | 223 | m_oleCat = str; |
221 | m_first = false; | 224 | m_first = false; |
222 | 225 | ||
223 | } | 226 | } |
224 | void TableView::clear() { | 227 | void TableView::clear() { |
225 | setNumRows(0); | 228 | setNumRows(0); |
226 | } | 229 | } |
227 | void TableView::slotClicked(int row, int col, int, | 230 | void TableView::slotClicked(int row, int col, int, |
228 | const QPoint& point) { | 231 | const QPoint& point) { |
229 | if ( !cellGeometry(row, col ).contains(point ) ) | 232 | if ( !cellGeometry(row, col ).contains(point ) ) |
230 | return; | 233 | return; |
231 | 234 | ||
232 | int ui= sorted().uidAt( row ); | 235 | int ui= sorted().uidAt( row ); |
233 | 236 | ||
234 | 237 | ||
235 | switch( col ) { | 238 | switch( col ) { |
236 | case 0:{ | 239 | case 0:{ |
237 | int x = point.x() -columnPos( col ); | 240 | int x = point.x() -columnPos( col ); |
238 | int y = point.y() -rowPos( row ); | 241 | int y = point.y() -rowPos( row ); |
239 | int w = columnWidth( col ); | 242 | int w = columnWidth( col ); |
240 | int h = rowHeight( row ); | 243 | int h = rowHeight( row ); |
241 | if ( x >= ( w - BoxSize ) / 2 && | 244 | if ( x >= ( w - BoxSize ) / 2 && |
242 | x <= ( w - BoxSize ) / 2 + BoxSize && | 245 | x <= ( w - BoxSize ) / 2 + BoxSize && |
243 | y >= ( h - BoxSize ) / 2 && | 246 | y >= ( h - BoxSize ) / 2 && |
244 | y <= ( h - BoxSize ) / 2 + BoxSize ) { | 247 | y <= ( h - BoxSize ) / 2 + BoxSize ) { |
245 | OTodo todo = sorted()[row]; | 248 | TodoView::complete(sorted()[row] ); |
246 | todo.setCompleted( !todo.isCompleted() ); | ||
247 | TodoView::update( todo.uid(), todo ); | ||
248 | updateView(); | ||
249 | } | 249 | } |
250 | } | 250 | } |
251 | break; | 251 | break; |
252 | 252 | ||
253 | case 1: | 253 | case 1: |
254 | break; | 254 | break; |
255 | 255 | ||
256 | case 2: { | 256 | case 2: { |
257 | m_menuTimer->stop(); | 257 | m_menuTimer->stop(); |
258 | showTodo( ui ); | 258 | showTodo( ui ); |
259 | break; | 259 | break; |
260 | } | 260 | } |
261 | case 3: { | 261 | case 3: { |
262 | m_menuTimer->stop(); | 262 | m_menuTimer->stop(); |
263 | TodoView::edit( ui ); | 263 | TodoView::edit( ui ); |
264 | break; | 264 | break; |
265 | } | 265 | } |
266 | } | 266 | } |
267 | 267 | ||
268 | 268 | ||
269 | } | 269 | } |
270 | void TableView::slotPressed(int row, int col, int, | 270 | void TableView::slotPressed(int row, int col, int, |
271 | const QPoint& point) { | 271 | const QPoint& point) { |
272 | 272 | ||
273 | qWarning("pressed row %d col %d x:%d+y:%d", row,col,point.x(),point.y() ); | 273 | qWarning("pressed row %d col %d x:%d+y:%d", row,col,point.x(),point.y() ); |
274 | m_prevP = point; | 274 | m_prevP = point; |
275 | /* TextColumn column */ | 275 | /* TextColumn column */ |
276 | if ( col == 2 && cellGeometry( row, col ).contains( point ) ) | 276 | if ( col == 2 && cellGeometry( row, col ).contains( point ) ) |
277 | m_menuTimer->start( 750, TRUE ); | 277 | m_menuTimer->start( 750, TRUE ); |
278 | } | 278 | } |
279 | void TableView::slotValueChanged( int, int ) { | 279 | void TableView::slotValueChanged( int, int ) { |
280 | qWarning("Value Changed"); | 280 | qWarning("Value Changed"); |
281 | } | 281 | } |
282 | void TableView::slotCurrentChanged(int, int ) { | 282 | void TableView::slotCurrentChanged(int, int ) { |
283 | m_menuTimer->stop(); | 283 | m_menuTimer->stop(); |
284 | } | 284 | } |
285 | QWidget* TableView::widget() { | 285 | QWidget* TableView::widget() { |
286 | return this; | 286 | return this; |
287 | } | 287 | } |
288 | /* | 288 | /* |
289 | * We need to overwrite sortColumn | 289 | * We need to overwrite sortColumn |
290 | * because we want to sort whole row | 290 | * because we want to sort whole row |
291 | * based | 291 | * based |
292 | * We event want to set the setOrder | 292 | * We event want to set the setOrder |
293 | * to a sort() and update() | 293 | * to a sort() and update() |
294 | */ | 294 | */ |
295 | void TableView::sortColumn( int col, bool asc, bool ) { | 295 | void TableView::sortColumn( int col, bool asc, bool ) { |
296 | qWarning("bool %d", asc ); | 296 | qWarning("bool %d", asc ); |
297 | setSortOrder( col ); | 297 | setSortOrder( col ); |
298 | setAscending( asc ); | 298 | setAscending( asc ); |
299 | updateView(); | 299 | updateView(); |
300 | } | 300 | } |
301 | void TableView::viewportPaintEvent( QPaintEvent* e) { | 301 | void TableView::viewportPaintEvent( QPaintEvent* e) { |
302 | if (m_enablePaint ) | 302 | if (m_enablePaint ) |
303 | QTable::viewportPaintEvent( e ); | 303 | QTable::viewportPaintEvent( e ); |
304 | } | 304 | } |
305 | /* | 305 | /* |
306 | * This segment is copyrighted by TT | 306 | * This segment is copyrighted by TT |
307 | * it was taken from their todolist | 307 | * it was taken from their todolist |
308 | * application this code is GPL | 308 | * application this code is GPL |
309 | */ | 309 | */ |
310 | void TableView::paintCell(QPainter* p, int row, int col, const QRect& cr, bool ) { | 310 | void TableView::paintCell(QPainter* p, int row, int col, const QRect& cr, bool ) { |
311 | const QColorGroup &cg = colorGroup(); | 311 | const QColorGroup &cg = colorGroup(); |
312 | 312 | ||
313 | p->save(); | 313 | p->save(); |
314 | 314 | ||
315 | OTodo task = sorted()[row]; | 315 | OTodo task = sorted()[row]; |
316 | 316 | ||
317 | p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Base ) ); | 317 | p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Base ) ); |
318 | 318 | ||
319 | QPen op = p->pen(); | 319 | QPen op = p->pen(); |
320 | p->setPen(cg.mid()); | 320 | p->setPen(cg.mid()); |
321 | p->drawLine( 0, cr.height() - 1, cr.width() - 1, cr.height() - 1 ); | 321 | p->drawLine( 0, cr.height() - 1, cr.width() - 1, cr.height() - 1 ); |
322 | p->drawLine( cr.width() - 1, 0, cr.width() - 1, cr.height() - 1 ); | 322 | p->drawLine( cr.width() - 1, 0, cr.width() - 1, cr.height() - 1 ); |
323 | p->setPen(op); | 323 | p->setPen(op); |
324 | 324 | ||
325 | QFont f = p->font(); | 325 | QFont f = p->font(); |
326 | QFontMetrics fm(f); | 326 | QFontMetrics fm(f); |
327 | 327 | ||
328 | switch(col) { | 328 | switch(col) { |
329 | case 0: | 329 | case 0: |
330 | { | 330 | { |
331 | // completed field | 331 | // completed field |
332 | int marg = ( cr.width() - BoxSize ) / 2; | 332 | int marg = ( cr.width() - BoxSize ) / 2; |
333 | int x = 0; | 333 | int x = 0; |
334 | int y = ( cr.height() - BoxSize ) / 2; | 334 | int y = ( cr.height() - BoxSize ) / 2; |
335 | p->setPen( QPen( cg.text() ) ); | 335 | p->setPen( QPen( cg.text() ) ); |
336 | p->drawRect( x + marg, y, BoxSize, BoxSize ); | 336 | p->drawRect( x + marg, y, BoxSize, BoxSize ); |
337 | p->drawRect( x + marg+1, y+1, BoxSize-2, BoxSize-2 ); | 337 | p->drawRect( x + marg+1, y+1, BoxSize-2, BoxSize-2 ); |
338 | p->setPen( darkGreen ); | 338 | p->setPen( darkGreen ); |
339 | x += 1; | 339 | x += 1; |
340 | y += 1; | 340 | y += 1; |
341 | if ( task.isCompleted() ) { | 341 | if ( task.isCompleted() ) { |
342 | QPointArray a( 9*2 ); | 342 | QPointArray a( 9*2 ); |
343 | int i, xx, yy; | 343 | int i, xx, yy; |
344 | xx = x+2+marg; | 344 | xx = x+2+marg; |
345 | yy = y+4; | 345 | yy = y+4; |
346 | for ( i=0; i<4; i++ ) { | 346 | for ( i=0; i<4; i++ ) { |
347 | a.setPoint( 2*i, xx, yy ); | 347 | a.setPoint( 2*i, xx, yy ); |
348 | a.setPoint( 2*i+1, xx, yy+2 ); | 348 | a.setPoint( 2*i+1, xx, yy+2 ); |
349 | xx++; yy++; | 349 | xx++; yy++; |
350 | } | 350 | } |
351 | yy -= 2; | 351 | yy -= 2; |
352 | for ( i=4; i<9; i++ ) { | 352 | for ( i=4; i<9; i++ ) { |
353 | a.setPoint( 2*i, xx, yy ); | 353 | a.setPoint( 2*i, xx, yy ); |
354 | a.setPoint( 2*i+1, xx, yy+2 ); | 354 | a.setPoint( 2*i+1, xx, yy+2 ); |
355 | xx++; yy--; | 355 | xx++; yy--; |
356 | } | 356 | } |
357 | p->drawLineSegments( a ); | 357 | p->drawLineSegments( a ); |
358 | } | 358 | } |
359 | } | 359 | } |
360 | break; | 360 | break; |
361 | case 1: | 361 | case 1: |
362 | // priority field | 362 | // priority field |
363 | { | 363 | { |
364 | QString text = QString::number(task.priority()); | 364 | QString text = QString::number(task.priority()); |
365 | p->drawText(2,2 + fm.ascent(), text); | 365 | p->drawText(2,2 + fm.ascent(), text); |
366 | } | 366 | } |
367 | break; | 367 | break; |
368 | case 2: | 368 | case 2: |
369 | // description field | 369 | // description field |
370 | { | 370 | { |
371 | QString text = task.summary().isEmpty() ? | 371 | QString text = task.summary().isEmpty() ? |
372 | task.description() : | 372 | task.description().left(20) : |
373 | task.summary(); | 373 | task.summary(); |
374 | p->drawText(2,2 + fm.ascent(), text); | 374 | p->drawText(2,2 + fm.ascent(), text); |
375 | } | 375 | } |
376 | break; | 376 | break; |
377 | case 3: | 377 | case 3: |
378 | { | 378 | { |
379 | QString text; | 379 | QString text; |
380 | if (task.hasDueDate()) { | 380 | if (task.hasDueDate()) { |
381 | int off = QDate::currentDate().daysTo( task.dueDate() ); | 381 | int off = QDate::currentDate().daysTo( task.dueDate() ); |
382 | text = QString::number(off) + tr(" day(s)"); | 382 | text = QString::number(off) + tr(" day(s)"); |
383 | /* | 383 | /* |
384 | * set color if not completed | 384 | * set color if not completed |
385 | */ | 385 | */ |
386 | if (!task.isCompleted() ) { | 386 | if (!task.isCompleted() ) { |
387 | QColor color = Qt::black; | 387 | QColor color = Qt::black; |
388 | if ( off < 0 ) | 388 | if ( off < 0 ) |
389 | color = Qt::red; | 389 | color = Qt::red; |
390 | else if ( off == 0 ) | 390 | else if ( off == 0 ) |
391 | color = Qt::yellow; | 391 | color = Qt::yellow; |
392 | else if ( off > 0 ) | 392 | else if ( off > 0 ) |
393 | color = Qt::green; | 393 | color = Qt::green; |
394 | p->setPen(color ); | 394 | p->setPen(color ); |
395 | } | 395 | } |
396 | } else { | 396 | } else { |
397 | text = tr("None"); | 397 | text = tr("None"); |
398 | } | 398 | } |
399 | p->drawText(2,2 + fm.ascent(), text); | 399 | p->drawText(2,2 + fm.ascent(), text); |
400 | } | 400 | } |
401 | break; | 401 | break; |
402 | } | 402 | } |
403 | p->restore(); | 403 | p->restore(); |
404 | } | 404 | } |
405 | QWidget* TableView::createEditor(int row, int col, bool )const { | 405 | QWidget* TableView::createEditor(int row, int col, bool )const { |
406 | switch( col ) { | 406 | switch( col ) { |
407 | case 1: { | 407 | case 1: { |
408 | /* the priority stuff */ | 408 | /* the priority stuff */ |
409 | QComboBox* combo = new QComboBox( viewport() ); | 409 | QComboBox* combo = new QComboBox( viewport() ); |
410 | combo->insertItem( "1" ); | 410 | combo->insertItem( "1" ); |
411 | combo->insertItem( "2" ); | 411 | combo->insertItem( "2" ); |
412 | combo->insertItem( "3" ); | 412 | combo->insertItem( "3" ); |
413 | combo->insertItem( "4" ); | 413 | combo->insertItem( "4" ); |
414 | combo->insertItem( "5" ); | 414 | combo->insertItem( "5" ); |
415 | combo->setCurrentItem( sorted()[row].priority()-1 ); | 415 | combo->setCurrentItem( sorted()[row].priority()-1 ); |
416 | return combo; | 416 | return combo; |
417 | } | 417 | } |
418 | /* summary */ | 418 | /* summary */ |
419 | case 2:{ | 419 | case 2:{ |
420 | QLineEdit* edit = new QLineEdit( viewport() ); | 420 | QLineEdit* edit = new QLineEdit( viewport() ); |
421 | edit->setText( sorted()[row].summary() ); | 421 | edit->setText( sorted()[row].summary() ); |
422 | return edit; | 422 | return edit; |
423 | } | 423 | } |
424 | case 0: | 424 | case 0: |
425 | default: | 425 | default: |
426 | return 0l; | 426 | return 0l; |
427 | } | 427 | } |
428 | } | 428 | } |
429 | void TableView::setCellContentFromEditor(int row, int col ) { | 429 | void TableView::setCellContentFromEditor(int row, int col ) { |
430 | if ( col == 1 ) { | 430 | if ( col == 1 ) { |
431 | QWidget* wid = cellWidget(row, 1 ); | 431 | QWidget* wid = cellWidget(row, 1 ); |
432 | if ( wid->inherits("QComboBox") ) { | 432 | if ( wid->inherits("QComboBox") ) { |
433 | int pri = ((QComboBox*)wid)->currentItem() + 1; | 433 | int pri = ((QComboBox*)wid)->currentItem() + 1; |
434 | OTodo todo = sorted()[row]; | 434 | OTodo todo = sorted()[row]; |
435 | if ( todo.priority() != pri ) { | 435 | if ( todo.priority() != pri ) { |
436 | todo.setPriority( pri ); | 436 | todo.setPriority( pri ); |
437 | TodoView::update( todo.uid(), todo ); | 437 | TodoView::update( todo.uid(), todo ); |
438 | updateView(); | 438 | updateView(); |
439 | } | 439 | } |
440 | } | 440 | } |
441 | }else if ( col == 2) { | 441 | }else if ( col == 2) { |
442 | QWidget* wid = cellWidget(row, 2); | 442 | QWidget* wid = cellWidget(row, 2); |
443 | if ( wid->inherits("QLineEdit") ) { | 443 | if ( wid->inherits("QLineEdit") ) { |
444 | QString text = ((QLineEdit*)wid)->text(); | 444 | QString text = ((QLineEdit*)wid)->text(); |
445 | OTodo todo = sorted()[row]; | 445 | OTodo todo = sorted()[row]; |
446 | if ( todo.summary() != text ) { | 446 | if ( todo.summary() != text ) { |
447 | todo.setSummary( text ); | 447 | todo.setSummary( text ); |
448 | TodoView::update( todo.uid(), todo ); | 448 | TodoView::update( todo.uid(), todo ); |
449 | updateView(); | 449 | updateView(); |
450 | } | 450 | } |
451 | } | 451 | } |
452 | } | 452 | } |
453 | } | 453 | } |
454 | void TableView::slotPriority() { | 454 | void TableView::slotPriority() { |
455 | setCellContentFromEditor( currentRow(), currentColumn() ); | 455 | setCellContentFromEditor( currentRow(), currentColumn() ); |
456 | } | 456 | } |
457 | /* | 457 | /* |
458 | * We'll use the TimerEvent to read ahead or to keep the cahce always | 458 | * We'll use the TimerEvent to read ahead or to keep the cahce always |
459 | * filled enough. | 459 | * filled enough. |
460 | * We will try to read ahead 4 items in both ways | 460 | * We will try to read ahead 4 items in both ways |
461 | * up and down. On odd or even we will currentRow()+-4 or +-9 | 461 | * up and down. On odd or even we will currentRow()+-4 or +-9 |
462 | * | 462 | * |
463 | */ | 463 | */ |
464 | void TableView::timerEvent( QTimerEvent* ev ) { | 464 | void TableView::timerEvent( QTimerEvent* ev ) { |
465 | qWarning("sorted %d", sorted().count() ); | 465 | // qWarning("sorted %d", sorted().count() ); |
466 | if (sorted().count() == 0 ) | 466 | if (sorted().count() == 0 ) |
467 | return; | 467 | return; |
468 | 468 | ||
469 | int row = currentRow(); | 469 | int row = currentRow(); |
470 | if ( m_row ) { | 470 | if ( m_row ) { |
471 | int ro = row-4; | 471 | int ro = row-4; |
472 | if (ro < 0 ) ro = 0; | 472 | if (ro < 0 ) ro = 0; |
473 | sorted()[ro]; | 473 | sorted()[ro]; |
474 | 474 | ||
475 | ro = row+4; | 475 | ro = row+4; |
476 | sorted()[ro]; | 476 | sorted()[ro]; |
477 | } else { | 477 | } else { |
478 | int ro = row + 8; | 478 | int ro = row + 8; |
479 | sorted()[ro]; | 479 | sorted()[ro]; |
480 | 480 | ||
481 | ro = row-8; | 481 | ro = row-8; |
482 | if (ro < 0 ) ro = 0; | 482 | if (ro < 0 ) ro = 0; |
483 | sorted()[ro]; | 483 | sorted()[ro]; |
484 | } | 484 | } |
485 | 485 | ||
486 | m_row = !m_row; | 486 | m_row = !m_row; |
487 | } | 487 | } |
488 | 488 | ||
489 | // We want a strike through completed ;) | 489 | // We want a strike through completed ;) |
490 | // durchstreichen to complete | 490 | // durchstreichen to complete |
491 | /* | 491 | /* |
492 | * MouseTracking is off this mean we only receive | 492 | * MouseTracking is off this mean we only receive |
493 | * these events if the mouse button is pressed | 493 | * these events if the mouse button is pressed |
494 | * We've the previous point saved | 494 | * We've the previous point saved |
495 | * We check if the previous and current Point are | 495 | * We check if the previous and current Point are |
496 | * in the same row. | 496 | * in the same row. |
497 | * Then we check if they're some pixel horizontal away | 497 | * Then we check if they're some pixel horizontal away |
498 | * if the distance between the two points is greater than | 498 | * if the distance between the two points is greater than |
499 | * 8 we mark the underlying todo as completed and do a repaint | 499 | * 8 we mark the underlying todo as completed and do a repaint |
500 | * | 500 | * |
501 | * BUG: When clicking on the Due column and it's scrollable | 501 | * BUG: When clicking on the Due column and it's scrollable |
502 | * the todo is marked as completed... | 502 | * the todo is marked as completed... |
503 | * REASON: QTable is doing auto scrolling which leads to a move | 503 | * REASON: QTable is doing auto scrolling which leads to a move |
504 | * in the x coordinate and this way it's able to pass the | 504 | * in the x coordinate and this way it's able to pass the |
505 | * m_completeStrokeWidth criteria | 505 | * m_completeStrokeWidth criteria |
506 | * WORKAROUND: strike through needs to strike through the same | 506 | * WORKAROUND: strike through needs to strike through the same |
507 | * row and two columns! | 507 | * row and two columns! |
508 | */ | 508 | */ |
509 | void TableView::contentsMouseReleaseEvent( QMouseEvent* e) { | 509 | void TableView::contentsMouseReleaseEvent( QMouseEvent* e) { |
510 | int row = rowAt(m_prevP.y()); | 510 | int row = rowAt(m_prevP.y()); |
511 | int colOld = columnAt(m_prevP.x() ); | 511 | int colOld = columnAt(m_prevP.x() ); |
512 | int colNew = columnAt(e->x() ); | 512 | int colNew = columnAt(e->x() ); |
513 | qWarning("colNew: %d colOld: %d", colNew, colOld ); | 513 | qWarning("colNew: %d colOld: %d", colNew, colOld ); |
514 | if ( row == rowAt( e->y() ) && row != -1 && | 514 | if ( row == rowAt( e->y() ) && row != -1 && |
515 | colOld != colNew ) { | 515 | colOld != colNew ) { |
516 | OTodo todo = sorted()[row]; | 516 | TodoView::complete( sorted()[row] ); |
517 | todo.setCompleted( !todo.isCompleted() ); | 517 | return; |
518 | TodoView::update( todo.uid(), todo ); | ||
519 | updateView(); | ||
520 | return; | ||
521 | } | 518 | } |
522 | QTable::contentsMouseReleaseEvent( e ); | 519 | QTable::contentsMouseReleaseEvent( e ); |
523 | } | 520 | } |
524 | void TableView::contentsMouseMoveEvent( QMouseEvent* e ) { | 521 | void TableView::contentsMouseMoveEvent( QMouseEvent* e ) { |
525 | m_menuTimer->stop(); | 522 | m_menuTimer->stop(); |
526 | QTable::contentsMouseMoveEvent( e ); | 523 | QTable::contentsMouseMoveEvent( e ); |
527 | } | 524 | } |
diff --git a/core/pim/todo/taskeditoradvanced.ui b/core/pim/todo/taskeditoradvanced.ui index 3ea1346..6160712 100644 --- a/core/pim/todo/taskeditoradvanced.ui +++ b/core/pim/todo/taskeditoradvanced.ui | |||
@@ -1,222 +1,228 @@ | |||
1 | <!DOCTYPE UI><UI> | 1 | <!DOCTYPE UI><UI> |
2 | <class>TaskEditorAdvanced</class> | 2 | <class>TaskEditorAdvanced</class> |
3 | <widget> | 3 | <widget> |
4 | <class>QWidget</class> | 4 | <class>QWidget</class> |
5 | <property stdset="1"> | 5 | <property stdset="1"> |
6 | <name>name</name> | 6 | <name>name</name> |
7 | <cstring>TaskEditorAdvanced</cstring> | 7 | <cstring>TaskEditorAdvanced</cstring> |
8 | </property> | 8 | </property> |
9 | <property stdset="1"> | 9 | <property stdset="1"> |
10 | <name>geometry</name> | 10 | <name>geometry</name> |
11 | <rect> | 11 | <rect> |
12 | <x>0</x> | 12 | <x>0</x> |
13 | <y>0</y> | 13 | <y>0</y> |
14 | <width>236</width> | 14 | <width>232</width> |
15 | <height>307</height> | 15 | <height>307</height> |
16 | </rect> | 16 | </rect> |
17 | </property> | 17 | </property> |
18 | <property stdset="1"> | 18 | <property stdset="1"> |
19 | <name>caption</name> | 19 | <name>caption</name> |
20 | <string>Form2</string> | 20 | <string>Form2</string> |
21 | </property> | 21 | </property> |
22 | <property> | 22 | <property> |
23 | <name>layoutMargin</name> | 23 | <name>layoutMargin</name> |
24 | </property> | 24 | </property> |
25 | <property> | 25 | <property> |
26 | <name>layoutSpacing</name> | 26 | <name>layoutSpacing</name> |
27 | </property> | 27 | </property> |
28 | <grid> | 28 | <grid> |
29 | <property stdset="1"> | 29 | <property stdset="1"> |
30 | <name>margin</name> | 30 | <name>margin</name> |
31 | <number>8</number> | 31 | <number>8</number> |
32 | </property> | 32 | </property> |
33 | <property stdset="1"> | 33 | <property stdset="1"> |
34 | <name>spacing</name> | 34 | <name>spacing</name> |
35 | <number>6</number> | 35 | <number>6</number> |
36 | </property> | 36 | </property> |
37 | <widget row="0" column="0" > | 37 | <widget row="0" column="0" > |
38 | <class>QLayoutWidget</class> | 38 | <class>QLayoutWidget</class> |
39 | <property stdset="1"> | 39 | <property stdset="1"> |
40 | <name>name</name> | 40 | <name>name</name> |
41 | <cstring>Layout13</cstring> | 41 | <cstring>Layout13</cstring> |
42 | </property> | 42 | </property> |
43 | <hbox> | 43 | <hbox> |
44 | <property stdset="1"> | 44 | <property stdset="1"> |
45 | <name>margin</name> | 45 | <name>margin</name> |
46 | <number>0</number> | 46 | <number>0</number> |
47 | </property> | 47 | </property> |
48 | <property stdset="1"> | 48 | <property stdset="1"> |
49 | <name>spacing</name> | 49 | <name>spacing</name> |
50 | <number>6</number> | 50 | <number>6</number> |
51 | </property> | 51 | </property> |
52 | <widget> | 52 | <widget> |
53 | <class>QLabel</class> | 53 | <class>QLabel</class> |
54 | <property stdset="1"> | 54 | <property stdset="1"> |
55 | <name>name</name> | 55 | <name>name</name> |
56 | <cstring>lblState</cstring> | 56 | <cstring>lblState</cstring> |
57 | </property> | 57 | </property> |
58 | <property stdset="1"> | 58 | <property stdset="1"> |
59 | <name>text</name> | 59 | <name>text</name> |
60 | <string>State:</string> | 60 | <string>State:</string> |
61 | </property> | 61 | </property> |
62 | </widget> | 62 | </widget> |
63 | <widget> | 63 | <widget> |
64 | <class>QComboBox</class> | 64 | <class>QComboBox</class> |
65 | <item> | 65 | <item> |
66 | <property> | 66 | <property> |
67 | <name>text</name> | 67 | <name>text</name> |
68 | <string>Started</string> | 68 | <string>Started</string> |
69 | </property> | 69 | </property> |
70 | </item> | 70 | </item> |
71 | <item> | 71 | <item> |
72 | <property> | 72 | <property> |
73 | <name>text</name> | 73 | <name>text</name> |
74 | <string>Postponed</string> | 74 | <string>Postponed</string> |
75 | </property> | 75 | </property> |
76 | </item> | 76 | </item> |
77 | <item> | 77 | <item> |
78 | <property> | 78 | <property> |
79 | <name>text</name> | 79 | <name>text</name> |
80 | <string>Finished</string> | 80 | <string>Finished</string> |
81 | </property> | 81 | </property> |
82 | </item> | 82 | </item> |
83 | <item> | 83 | <item> |
84 | <property> | 84 | <property> |
85 | <name>text</name> | 85 | <name>text</name> |
86 | <string>Not started</string> | 86 | <string>Not started</string> |
87 | </property> | 87 | </property> |
88 | </item> | 88 | </item> |
89 | <property stdset="1"> | 89 | <property stdset="1"> |
90 | <name>name</name> | 90 | <name>name</name> |
91 | <cstring>cmbState</cstring> | 91 | <cstring>cmbState</cstring> |
92 | </property> | 92 | </property> |
93 | </widget> | 93 | </widget> |
94 | </hbox> | 94 | </hbox> |
95 | </widget> | 95 | </widget> |
96 | <widget row="2" column="0" > | 96 | <widget row="2" column="0" > |
97 | <class>QLayoutWidget</class> | 97 | <class>QLayoutWidget</class> |
98 | <property stdset="1"> | 98 | <property stdset="1"> |
99 | <name>name</name> | 99 | <name>name</name> |
100 | <cstring>Layout17</cstring> | 100 | <cstring>Layout17</cstring> |
101 | </property> | 101 | </property> |
102 | <hbox> | 102 | <hbox> |
103 | <property stdset="1"> | 103 | <property stdset="1"> |
104 | <name>margin</name> | 104 | <name>margin</name> |
105 | <number>0</number> | 105 | <number>0</number> |
106 | </property> | 106 | </property> |
107 | <property stdset="1"> | 107 | <property stdset="1"> |
108 | <name>spacing</name> | 108 | <name>spacing</name> |
109 | <number>6</number> | 109 | <number>6</number> |
110 | </property> | 110 | </property> |
111 | <widget> | 111 | <widget> |
112 | <class>QLabel</class> | 112 | <class>QLabel</class> |
113 | <property stdset="1"> | 113 | <property stdset="1"> |
114 | <name>name</name> | 114 | <name>name</name> |
115 | <cstring>lblMaintainer</cstring> | 115 | <cstring>lblMaintainer</cstring> |
116 | </property> | 116 | </property> |
117 | <property stdset="1"> | 117 | <property stdset="1"> |
118 | <name>text</name> | 118 | <name>text</name> |
119 | <string>Maintainer</string> | 119 | <string>Maintainer</string> |
120 | </property> | 120 | </property> |
121 | </widget> | 121 | </widget> |
122 | <widget> | 122 | <widget> |
123 | <class>QLabel</class> | 123 | <class>QLabel</class> |
124 | <property stdset="1"> | 124 | <property stdset="1"> |
125 | <name>name</name> | 125 | <name>name</name> |
126 | <cstring>txtMaintainer</cstring> | 126 | <cstring>txtMaintainer</cstring> |
127 | </property> | 127 | </property> |
128 | <property stdset="1"> | 128 | <property stdset="1"> |
129 | <name>text</name> | 129 | <name>text</name> |
130 | <string>test</string> | 130 | <string>test</string> |
131 | </property> | 131 | </property> |
132 | <property stdset="1"> | 132 | <property stdset="1"> |
133 | <name>textFormat</name> | 133 | <name>textFormat</name> |
134 | <enum>RichText</enum> | 134 | <enum>RichText</enum> |
135 | </property> | 135 | </property> |
136 | </widget> | 136 | </widget> |
137 | <widget> | 137 | <widget> |
138 | <class>QLayoutWidget</class> | 138 | <class>QLayoutWidget</class> |
139 | <property stdset="1"> | 139 | <property stdset="1"> |
140 | <name>name</name> | 140 | <name>name</name> |
141 | <cstring>Layout16</cstring> | 141 | <cstring>Layout16</cstring> |
142 | </property> | 142 | </property> |
143 | <vbox> | 143 | <vbox> |
144 | <property stdset="1"> | 144 | <property stdset="1"> |
145 | <name>margin</name> | 145 | <name>margin</name> |
146 | <number>0</number> | 146 | <number>0</number> |
147 | </property> | 147 | </property> |
148 | <property stdset="1"> | 148 | <property stdset="1"> |
149 | <name>spacing</name> | 149 | <name>spacing</name> |
150 | <number>6</number> | 150 | <number>6</number> |
151 | </property> | 151 | </property> |
152 | <widget> | 152 | <widget> |
153 | <class>QToolButton</class> | 153 | <class>QToolButton</class> |
154 | <property stdset="1"> | 154 | <property stdset="1"> |
155 | <name>name</name> | 155 | <name>name</name> |
156 | <cstring>tbtMaintainer</cstring> | 156 | <cstring>tbtMaintainer</cstring> |
157 | </property> | 157 | </property> |
158 | <property stdset="1"> | 158 | <property stdset="1"> |
159 | <name>text</name> | 159 | <name>text</name> |
160 | <string>...</string> | 160 | <string>...</string> |
161 | </property> | 161 | </property> |
162 | </widget> | 162 | </widget> |
163 | </vbox> | 163 | </vbox> |
164 | </widget> | 164 | </widget> |
165 | </hbox> | 165 | </hbox> |
166 | </widget> | 166 | </widget> |
167 | <widget row="1" column="0" > | 167 | <widget row="1" column="0" > |
168 | <class>QLayoutWidget</class> | 168 | <class>QLayoutWidget</class> |
169 | <property stdset="1"> | 169 | <property stdset="1"> |
170 | <name>name</name> | 170 | <name>name</name> |
171 | <cstring>Layout4</cstring> | 171 | <cstring>Layout4</cstring> |
172 | </property> | 172 | </property> |
173 | <hbox> | 173 | <hbox> |
174 | <property stdset="1"> | 174 | <property stdset="1"> |
175 | <name>margin</name> | 175 | <name>margin</name> |
176 | <number>0</number> | 176 | <number>0</number> |
177 | </property> | 177 | </property> |
178 | <property stdset="1"> | 178 | <property stdset="1"> |
179 | <name>spacing</name> | 179 | <name>spacing</name> |
180 | <number>6</number> | 180 | <number>6</number> |
181 | </property> | 181 | </property> |
182 | <widget> | 182 | <widget> |
183 | <class>QLabel</class> | 183 | <class>QLabel</class> |
184 | <property stdset="1"> | 184 | <property stdset="1"> |
185 | <name>name</name> | 185 | <name>name</name> |
186 | <cstring>txtMode</cstring> | 186 | <cstring>txtMode</cstring> |
187 | </property> | 187 | </property> |
188 | <property stdset="1"> | 188 | <property stdset="1"> |
189 | <name>text</name> | 189 | <name>text</name> |
190 | <string>Maintain Mode:</string> | 190 | <string>Maintain Mode:</string> |
191 | </property> | 191 | </property> |
192 | </widget> | 192 | </widget> |
193 | <widget> | 193 | <widget> |
194 | <class>QComboBox</class> | 194 | <class>QComboBox</class> |
195 | <item> | 195 | <item> |
196 | <property> | 196 | <property> |
197 | <name>text</name> | 197 | <name>text</name> |
198 | <string>Nothing</string> | ||
199 | </property> | ||
200 | </item> | ||
201 | <item> | ||
202 | <property> | ||
203 | <name>text</name> | ||
198 | <string>Responsible</string> | 204 | <string>Responsible</string> |
199 | </property> | 205 | </property> |
200 | </item> | 206 | </item> |
201 | <item> | 207 | <item> |
202 | <property> | 208 | <property> |
203 | <name>text</name> | 209 | <name>text</name> |
204 | <string>Done By</string> | 210 | <string>Done By</string> |
205 | </property> | 211 | </property> |
206 | </item> | 212 | </item> |
207 | <item> | 213 | <item> |
208 | <property> | 214 | <property> |
209 | <name>text</name> | 215 | <name>text</name> |
210 | <string>Coordinating</string> | 216 | <string>Coordinating</string> |
211 | </property> | 217 | </property> |
212 | </item> | 218 | </item> |
213 | <property stdset="1"> | 219 | <property stdset="1"> |
214 | <name>name</name> | 220 | <name>name</name> |
215 | <cstring>cmbMode</cstring> | 221 | <cstring>cmbMode</cstring> |
216 | </property> | 222 | </property> |
217 | </widget> | 223 | </widget> |
218 | </hbox> | 224 | </hbox> |
219 | </widget> | 225 | </widget> |
220 | </grid> | 226 | </grid> |
221 | </widget> | 227 | </widget> |
222 | </UI> | 228 | </UI> |
diff --git a/core/pim/todo/taskeditoroverviewimpl.cpp b/core/pim/todo/taskeditoroverviewimpl.cpp index 24b3386..aef3b1d 100644 --- a/core/pim/todo/taskeditoroverviewimpl.cpp +++ b/core/pim/todo/taskeditoroverviewimpl.cpp | |||
@@ -1,182 +1,221 @@ | |||
1 | #include <qapplication.h> | 1 | #include <qapplication.h> |
2 | #include <qcheckbox.h> | 2 | #include <qcheckbox.h> |
3 | #include <qcombobox.h> | 3 | #include <qcombobox.h> |
4 | #include <qpopupmenu.h> | 4 | #include <qpopupmenu.h> |
5 | 5 | ||
6 | #include <qpe/datebookmonth.h> | 6 | #include <qpe/datebookmonth.h> |
7 | #include <qpe/categoryselect.h> | 7 | #include <qpe/categoryselect.h> |
8 | #include <qpe/timestring.h> | 8 | #include <qpe/timestring.h> |
9 | 9 | ||
10 | #include <opie/orecur.h> | ||
11 | |||
10 | #include "taskeditoroverviewimpl.h" | 12 | #include "taskeditoroverviewimpl.h" |
11 | 13 | ||
12 | /* | 14 | /* |
13 | * we need to hack | 15 | * we need to hack |
14 | */ | 16 | */ |
15 | 17 | ||
16 | TaskEditorOverViewImpl::TaskEditorOverViewImpl( QWidget* parent, const char* name ) | 18 | TaskEditorOverViewImpl::TaskEditorOverViewImpl( QWidget* parent, const char* name ) |
17 | : TaskEditorOverView( parent, name ) { | 19 | : TaskEditorOverView( parent, name ) { |
18 | init(); | 20 | init(); |
19 | } | 21 | } |
20 | TaskEditorOverViewImpl::~TaskEditorOverViewImpl() { | 22 | TaskEditorOverViewImpl::~TaskEditorOverViewImpl() { |
21 | } | 23 | } |
22 | void TaskEditorOverViewImpl::load( const OTodo& todo) { | 24 | void TaskEditorOverViewImpl::load( const OTodo& todo) { |
23 | /* | 25 | /* |
24 | * now that we're 'preloaded' we | 26 | * now that we're 'preloaded' we |
25 | * need to disable the buttons | 27 | * need to disable the buttons |
26 | * holding the dat | 28 | * holding the dat |
27 | */ | 29 | */ |
28 | btnDue-> setEnabled( FALSE ); | 30 | btnDue-> setEnabled( FALSE ); |
29 | btnComp-> setEnabled( FALSE ); | 31 | btnComp-> setEnabled( FALSE ); |
30 | btnStart->setEnabled( FALSE ); | 32 | btnStart->setEnabled( FALSE ); |
31 | 33 | ||
32 | 34 | /* | |
35 | * get some basic dateinfos for now | ||
36 | */ | ||
33 | QDate date = QDate::currentDate(); | 37 | QDate date = QDate::currentDate(); |
34 | QString str = TimeString::longDateString( date ); | 38 | QString str = TimeString::longDateString( date ); |
35 | 39 | ||
36 | emit recurranceEnabled( FALSE ); | 40 | CheckBox7->setChecked( todo.recurrence().doesRecur() ); |
37 | ckbStart->setChecked( FALSE ); | 41 | emit recurranceEnabled( todo.recurrence().doesRecur() ); |
38 | btnStart->setText( str ); | 42 | |
39 | 43 | ||
40 | ckbComp->setChecked( FALSE ); | 44 | ckbStart->setChecked( todo.hasStartDate() ); |
41 | btnComp->setText( str ); | 45 | btnStart->setEnabled( todo.hasStartDate() ); |
46 | if ( todo.hasStartDate() ) { | ||
47 | m_start = todo.startDate(); | ||
48 | btnStart->setText( TimeString::longDateString( m_start ) ); | ||
49 | } else | ||
50 | btnStart->setText( str ); | ||
51 | |||
52 | ckbComp->setChecked( todo.hasCompletedDate() ); | ||
53 | btnComp->setEnabled( todo.hasCompletedDate() ); | ||
54 | if ( todo.hasCompletedDate() ) { | ||
55 | m_comp = todo.completedDate(); | ||
56 | btnComp->setText( TimeString::longDateString( m_comp ) ); | ||
57 | }else | ||
58 | btnComp->setText( str ); | ||
42 | 59 | ||
43 | cmbProgress->setCurrentItem( todo.progress()/20 ); | 60 | cmbProgress->setCurrentItem( todo.progress()/20 ); |
44 | cmbSum->insertItem( todo.summary(), 0 ); | 61 | cmbSum->insertItem( todo.summary(), 0 ); |
45 | cmbSum->setCurrentItem( 0 ); | 62 | cmbSum->setCurrentItem( 0 ); |
46 | 63 | ||
47 | ckbDue->setChecked( todo.hasDueDate() ); | 64 | ckbDue->setChecked( todo.hasDueDate() ); |
48 | btnDue->setText( TimeString::longDateString( todo.dueDate() ) ); | 65 | btnDue->setText( TimeString::longDateString( todo.dueDate() ) ); |
49 | btnDue->setEnabled( todo.hasDueDate() ); | 66 | btnDue->setEnabled( todo.hasDueDate() ); |
67 | m_due = todo.dueDate(); | ||
50 | 68 | ||
51 | cmbPrio->setCurrentItem( todo.priority() -1 ); | 69 | cmbPrio->setCurrentItem( todo.priority() -1 ); |
52 | ckbCompleted->setChecked( todo.isCompleted() ); | 70 | ckbCompleted->setChecked( todo.isCompleted() ); |
53 | 71 | ||
54 | comboCategory->setCategories( todo.categories(), "Todo List", tr("Todo List") ); | 72 | comboCategory->setCategories( todo.categories(), "Todo List", tr("Todo List") ); |
55 | 73 | ||
56 | } | 74 | } |
57 | void TaskEditorOverViewImpl::save( OTodo& to) { | 75 | void TaskEditorOverViewImpl::save( OTodo& to) { |
58 | qWarning("save it now"); | 76 | /* a invalid date */ |
77 | QDate inval; | ||
78 | /* save our info back */ | ||
79 | |||
80 | /* due date */ | ||
59 | if ( ckbDue->isChecked() ) { | 81 | if ( ckbDue->isChecked() ) { |
60 | to.setDueDate( m_due ); | 82 | to.setDueDate( m_due ); |
61 | to.setHasDueDate( true ); | 83 | to.setHasDueDate( true ); |
62 | }else | 84 | }else |
63 | to.setHasDueDate( false ); | 85 | to.setHasDueDate( false ); |
86 | |||
87 | /* start date */ | ||
88 | if ( ckbStart->isChecked() ) { | ||
89 | to.setStartDate( m_start ); | ||
90 | }else | ||
91 | to.setStartDate( inval ); | ||
92 | |||
93 | /* comp date */ | ||
94 | if ( ckbComp->isChecked() ) { | ||
95 | qWarning("completed checked"); | ||
96 | to.setCompletedDate( m_comp ); | ||
97 | }else | ||
98 | to.setCompletedDate( inval ); | ||
99 | |||
100 | |||
64 | if ( comboCategory->currentCategory() != -1 ) { | 101 | if ( comboCategory->currentCategory() != -1 ) { |
65 | QArray<int> arr = comboCategory->currentCategories(); | 102 | QArray<int> arr = comboCategory->currentCategories(); |
66 | to.setCategories( arr ); | 103 | to.setCategories( arr ); |
67 | } | 104 | } |
68 | to.setPriority( cmbPrio->currentItem() + 1 ); | 105 | to.setPriority( cmbPrio->currentItem() + 1 ); |
69 | to.setCompleted( ckbCompleted->isChecked() ); | 106 | to.setCompleted( ckbCompleted->isChecked() ); |
70 | to.setSummary( cmbSum->currentText() ); | 107 | to.setSummary( cmbSum->currentText() ); |
71 | to.setProgress( cmbProgress->currentItem() * 20 ); | 108 | to.setProgress( cmbProgress->currentItem() * 20 ); |
72 | } | 109 | } |
73 | /* | 110 | /* |
74 | * here we will init the basic view | 111 | * here we will init the basic view |
75 | * one Popup for each Date Button | 112 | * one Popup for each Date Button |
76 | * and some other signal and slots connection | 113 | * and some other signal and slots connection |
77 | */ | 114 | */ |
78 | void TaskEditorOverViewImpl::init() { | 115 | void TaskEditorOverViewImpl::init() { |
79 | QDate curDate = QDate::currentDate(); | 116 | QDate curDate = QDate::currentDate(); |
80 | m_start = m_comp = m_due = curDate; | 117 | m_start = m_comp = m_due = curDate; |
81 | QString str = TimeString::longDateString( curDate ); | 118 | QString str = TimeString::longDateString( curDate ); |
82 | 119 | ||
83 | 120 | ||
84 | 121 | ||
85 | /* Start Date Picker */ | 122 | /* Start Date Picker */ |
86 | m_startPop = new QPopupMenu(this); | 123 | m_startPop = new QPopupMenu(this); |
87 | m_startBook = new DateBookMonth(m_startPop, 0, TRUE ); | 124 | m_startBook = new DateBookMonth(m_startPop, 0, TRUE ); |
88 | m_startPop->insertItem( m_startBook ); | 125 | m_startPop->insertItem( m_startBook ); |
89 | connect( m_startBook, SIGNAL( dateClicked(int, int, int) ), | 126 | connect( m_startBook, SIGNAL( dateClicked(int, int, int) ), |
90 | this, SLOT(slotStartChanged(int, int, int) ) ); | 127 | this, SLOT(slotStartChanged(int, int, int) ) ); |
91 | 128 | ||
92 | 129 | ||
93 | /* Due Date Picker */ | 130 | /* Due Date Picker */ |
94 | m_duePop = new QPopupMenu(this); | 131 | m_duePop = new QPopupMenu(this); |
95 | m_dueBook = new DateBookMonth(m_duePop, 0, TRUE ); | 132 | m_dueBook = new DateBookMonth(m_duePop, 0, TRUE ); |
96 | m_duePop->insertItem( m_dueBook ); | 133 | m_duePop->insertItem( m_dueBook ); |
97 | connect( m_dueBook, SIGNAL( dateClicked(int, int, int) ), | 134 | connect( m_dueBook, SIGNAL( dateClicked(int, int, int) ), |
98 | this, SLOT(slotDueChanged(int, int, int) ) ); | 135 | this, SLOT(slotDueChanged(int, int, int) ) ); |
99 | 136 | ||
100 | m_compPop = new QPopupMenu(this); | 137 | m_compPop = new QPopupMenu(this); |
101 | m_compBook = new DateBookMonth(m_compPop, 0, TRUE ); | 138 | m_compBook = new DateBookMonth(m_compPop, 0, TRUE ); |
102 | m_compPop->insertItem(m_compBook ); | 139 | m_compPop->insertItem(m_compBook ); |
103 | connect( m_compBook, SIGNAL(dateClicked(int, int, int) ), | 140 | connect( m_compBook, SIGNAL(dateClicked(int, int, int) ), |
104 | this, SLOT(slotCompletedChanged(int, int, int) ) ); | 141 | this, SLOT(slotCompletedChanged(int, int, int) ) ); |
105 | 142 | ||
106 | 143 | ||
107 | /* | 144 | /* |
108 | * another part of the hack | 145 | * another part of the hack |
109 | * it's deprecated in Qt2 but | 146 | * it's deprecated in Qt2 but |
110 | * still available in my qt-copy of Qt3.1beta2 | 147 | * still available in my qt-copy of Qt3.1beta2 |
111 | */ | 148 | */ |
112 | btnDue->setIsMenuButton( TRUE ); | 149 | btnDue->setIsMenuButton( TRUE ); |
113 | btnStart->setIsMenuButton( TRUE ); | 150 | btnStart->setIsMenuButton( TRUE ); |
114 | btnComp->setIsMenuButton( TRUE ); | 151 | btnComp->setIsMenuButton( TRUE ); |
115 | 152 | ||
116 | /* now connect the hack */ | 153 | /* now connect the hack */ |
117 | connect(btnDue, SIGNAL(clicked() ), | 154 | connect(btnDue, SIGNAL(clicked() ), |
118 | this, SLOT(hackySlotHack2() ) ); | 155 | this, SLOT(hackySlotHack2() ) ); |
119 | connect(btnStart, SIGNAL(clicked() ), | 156 | connect(btnStart, SIGNAL(clicked() ), |
120 | this, SLOT(hackySlotHack1() ) ); | 157 | this, SLOT(hackySlotHack1() ) ); |
121 | connect(btnComp, SIGNAL(clicked() ), | 158 | connect(btnComp, SIGNAL(clicked() ), |
122 | this, SLOT(hackySlotHack3() ) ); | 159 | this, SLOT(hackySlotHack3() ) ); |
123 | 160 | ||
124 | /* recurrance */ | 161 | /* recurrance */ |
125 | connect(CheckBox7, SIGNAL(clicked() ), | 162 | connect(CheckBox7, SIGNAL(clicked() ), |
126 | this, SLOT(slotRecClicked() ) ); | 163 | this, SLOT(slotRecClicked() ) ); |
127 | } | 164 | } |
128 | 165 | ||
129 | void TaskEditorOverViewImpl::slotStartChecked() { | 166 | void TaskEditorOverViewImpl::slotStartChecked() { |
130 | qWarning("slotStartChecked"); | 167 | qWarning("slotStartChecked"); |
131 | btnStart->setEnabled( ckbStart->isChecked() ); | 168 | btnStart->setEnabled( ckbStart->isChecked() ); |
132 | } | 169 | } |
133 | void TaskEditorOverViewImpl::slotStartChanged(int y, int m, int d) { | 170 | void TaskEditorOverViewImpl::slotStartChanged(int y, int m, int d) { |
134 | m_start.setYMD( y, m, d ); | 171 | m_start.setYMD( y, m, d ); |
135 | btnStart->setText( TimeString::longDateString( m_start ) ); | 172 | btnStart->setText( TimeString::longDateString( m_start ) ); |
136 | } | 173 | } |
137 | void TaskEditorOverViewImpl::slotDueChecked() { | 174 | void TaskEditorOverViewImpl::slotDueChecked() { |
138 | btnDue->setEnabled( ckbDue->isChecked() ); | 175 | btnDue->setEnabled( ckbDue->isChecked() ); |
176 | emit dueDateChanged( m_due ); | ||
139 | qWarning("slotDueChecked"); | 177 | qWarning("slotDueChecked"); |
140 | } | 178 | } |
141 | void TaskEditorOverViewImpl::slotDueChanged(int y, int m, int d ) { | 179 | void TaskEditorOverViewImpl::slotDueChanged(int y, int m, int d ) { |
142 | m_due.setYMD(y, m, d ); | 180 | m_due.setYMD(y, m, d ); |
143 | btnDue->setText( TimeString::longDateString( m_due ) ); | 181 | btnDue->setText( TimeString::longDateString( m_due ) ); |
182 | emit dueDateChanged( m_due ); | ||
144 | } | 183 | } |
145 | void TaskEditorOverViewImpl::slotCompletedChecked() { | 184 | void TaskEditorOverViewImpl::slotCompletedChecked() { |
146 | btnComp->setEnabled( ckbComp->isChecked() ); | 185 | btnComp->setEnabled( ckbComp->isChecked() ); |
147 | qWarning("slotCompletedChecked"); | 186 | qWarning("slotCompletedChecked"); |
148 | } | 187 | } |
149 | void TaskEditorOverViewImpl::slotCompletedChanged(int y, int m, int d) { | 188 | void TaskEditorOverViewImpl::slotCompletedChanged(int y, int m, int d) { |
150 | m_comp.setYMD( y, m, d ); | 189 | m_comp.setYMD( y, m, d ); |
151 | btnComp->setText( TimeString::longDateString( m_comp ) ); | 190 | btnComp->setText( TimeString::longDateString( m_comp ) ); |
152 | } | 191 | } |
153 | /* | 192 | /* |
154 | * called by a button pressed event... | 193 | * called by a button pressed event... |
155 | * three slots to avoid ugly name() tests | 194 | * three slots to avoid ugly name() tests |
156 | * to sender() | 195 | * to sender() |
157 | */ | 196 | */ |
158 | void TaskEditorOverViewImpl::hackySlotHack1() { | 197 | void TaskEditorOverViewImpl::hackySlotHack1() { |
159 | btnStart->setDown( FALSE ); | 198 | btnStart->setDown( FALSE ); |
160 | popup( btnStart, m_startPop ); | 199 | popup( btnStart, m_startPop ); |
161 | } | 200 | } |
162 | void TaskEditorOverViewImpl::hackySlotHack2() { | 201 | void TaskEditorOverViewImpl::hackySlotHack2() { |
163 | btnDue->setDown( FALSE ); | 202 | btnDue->setDown( FALSE ); |
164 | popup( btnDue, m_duePop ); | 203 | popup( btnDue, m_duePop ); |
165 | } | 204 | } |
166 | void TaskEditorOverViewImpl::hackySlotHack3() { | 205 | void TaskEditorOverViewImpl::hackySlotHack3() { |
167 | btnComp->setDown( FALSE ); | 206 | btnComp->setDown( FALSE ); |
168 | popup( btnComp, m_compPop ); | 207 | popup( btnComp, m_compPop ); |
169 | } | 208 | } |
170 | void TaskEditorOverViewImpl::slotRecClicked() { | 209 | void TaskEditorOverViewImpl::slotRecClicked() { |
171 | qWarning("enabled recurrance"); | 210 | qWarning("enabled recurrance"); |
172 | emit recurranceEnabled( CheckBox7->isChecked() ); | 211 | emit recurranceEnabled( CheckBox7->isChecked() ); |
173 | } | 212 | } |
174 | /* | 213 | /* |
175 | * GPL from TT QPushButton code | 214 | * GPL from TT QPushButton code |
176 | */ | 215 | */ |
177 | void TaskEditorOverViewImpl::popup( QPushButton* pu, QPopupMenu* pop) { | 216 | void TaskEditorOverViewImpl::popup( QPushButton* pu, QPopupMenu* pop) { |
178 | if ( pu->mapToGlobal( QPoint(0, pu->rect().bottom() ) ).y() + pop->sizeHint().height() <= qApp->desktop()->height() ) | 217 | if ( pu->mapToGlobal( QPoint(0, pu->rect().bottom() ) ).y() + pop->sizeHint().height() <= qApp->desktop()->height() ) |
179 | pop->exec( pu->mapToGlobal( pu->rect().bottomLeft() ) ); | 218 | pop->exec( pu->mapToGlobal( pu->rect().bottomLeft() ) ); |
180 | else | 219 | else |
181 | pop->exec( pu->mapToGlobal( pu->rect().topLeft() - QPoint(0, pu->sizeHint().height() ) ) ); | 220 | pop->exec( pu->mapToGlobal( pu->rect().topLeft() - QPoint(0, pu->sizeHint().height() ) ) ); |
182 | } | 221 | } |
diff --git a/core/pim/todo/taskeditoroverviewimpl.h b/core/pim/todo/taskeditoroverviewimpl.h index 4fab381..5ee985e 100644 --- a/core/pim/todo/taskeditoroverviewimpl.h +++ b/core/pim/todo/taskeditoroverviewimpl.h | |||
@@ -1,54 +1,55 @@ | |||
1 | #ifndef OPIE_TASK_EDITOR_VIEW_IMPL_H | 1 | #ifndef OPIE_TASK_EDITOR_VIEW_IMPL_H |
2 | #define OPIE_TASK_EDITOR_VIEW_IMPL_H | 2 | #define OPIE_TASK_EDITOR_VIEW_IMPL_H |
3 | 3 | ||
4 | #include <qsize.h> | 4 | #include <qsize.h> |
5 | 5 | ||
6 | #include <opie/otodo.h> | 6 | #include <opie/otodo.h> |
7 | 7 | ||
8 | #include "taskeditoroverview.h" | 8 | #include "taskeditoroverview.h" |
9 | 9 | ||
10 | class DateBookMonth; | 10 | class DateBookMonth; |
11 | class QPushButton; | 11 | class QPushButton; |
12 | class QPopupMenu; | 12 | class QPopupMenu; |
13 | class TaskEditorOverViewImpl : public TaskEditorOverView { | 13 | class TaskEditorOverViewImpl : public TaskEditorOverView { |
14 | Q_OBJECT | 14 | Q_OBJECT |
15 | public: | 15 | public: |
16 | TaskEditorOverViewImpl(QWidget* parent, const char* name = 0); | 16 | TaskEditorOverViewImpl(QWidget* parent, const char* name = 0); |
17 | ~TaskEditorOverViewImpl(); | 17 | ~TaskEditorOverViewImpl(); |
18 | 18 | ||
19 | void load( const OTodo& ); | 19 | void load( const OTodo& ); |
20 | void save( OTodo& ); | 20 | void save( OTodo& ); |
21 | signals: | 21 | signals: |
22 | void recurranceEnabled( bool ); | 22 | void recurranceEnabled( bool ); |
23 | void dueDateChanged( const QDate& date ); | ||
23 | 24 | ||
24 | private: | 25 | private: |
25 | void init(); | 26 | void init(); |
26 | void popup(QPushButton*, QPopupMenu*); | 27 | void popup(QPushButton*, QPopupMenu*); |
27 | DateBookMonth* m_dueBook; | 28 | DateBookMonth* m_dueBook; |
28 | DateBookMonth* m_startBook; | 29 | DateBookMonth* m_startBook; |
29 | DateBookMonth* m_compBook; | 30 | DateBookMonth* m_compBook; |
30 | QDate m_start; | 31 | QDate m_start; |
31 | QDate m_comp; | 32 | QDate m_comp; |
32 | QDate m_due; | 33 | QDate m_due; |
33 | QPopupMenu* m_startPop; | 34 | QPopupMenu* m_startPop; |
34 | QPopupMenu* m_compPop; | 35 | QPopupMenu* m_compPop; |
35 | QPopupMenu* m_duePop; | 36 | QPopupMenu* m_duePop; |
36 | bool m_bDue : 1; | 37 | bool m_bDue : 1; |
37 | 38 | ||
38 | private slots: | 39 | private slots: |
39 | void slotStartChecked(); | 40 | void slotStartChecked(); |
40 | void slotStartChanged(int, int, int ); | 41 | void slotStartChanged(int, int, int ); |
41 | void slotDueChecked(); | 42 | void slotDueChecked(); |
42 | void slotDueChanged(int, int, int ); | 43 | void slotDueChanged(int, int, int ); |
43 | void slotCompletedChecked(); | 44 | void slotCompletedChecked(); |
44 | void slotCompletedChanged(int, int, int ); | 45 | void slotCompletedChanged(int, int, int ); |
45 | 46 | ||
46 | void hackySlotHack1(); | 47 | void hackySlotHack1(); |
47 | void hackySlotHack2(); | 48 | void hackySlotHack2(); |
48 | void hackySlotHack3(); | 49 | void hackySlotHack3(); |
49 | 50 | ||
50 | void slotRecClicked(); | 51 | void slotRecClicked(); |
51 | }; | 52 | }; |
52 | 53 | ||
53 | 54 | ||
54 | #endif | 55 | #endif |
diff --git a/core/pim/todo/todo.pro b/core/pim/todo/todo.pro index 8f21416..40a5f28 100644 --- a/core/pim/todo/todo.pro +++ b/core/pim/todo/todo.pro | |||
@@ -1,61 +1,63 @@ | |||
1 | TEMPLATE= app | 1 | TEMPLATE= app |
2 | CONFIG = qt warn_on release | 2 | CONFIG = qt warn_on release |
3 | DESTDIR = $(OPIEDIR)/bin | 3 | DESTDIR = $(OPIEDIR)/bin |
4 | 4 | ||
5 | HEADERS= smalltodo.h \ | 5 | HEADERS= smalltodo.h \ |
6 | todomanager.h \ | 6 | todomanager.h \ |
7 | mainwindow.h \ | 7 | mainwindow.h \ |
8 | todoview.h \ | 8 | todoview.h \ |
9 | tableview.h \ | 9 | tableview.h \ |
10 | tableitems.h \ | 10 | tableitems.h \ |
11 | todotemplatemanager.h \ | 11 | todotemplatemanager.h \ |
12 | todoeditor.h \ | 12 | todoeditor.h \ |
13 | todoshow.h \ | 13 | todoshow.h \ |
14 | textviewshow.h \ | 14 | textviewshow.h \ |
15 | templateeditor.h \ | 15 | templateeditor.h \ |
16 | templatedialog.h \ | 16 | templatedialog.h \ |
17 | templatedialogimpl.h \ | 17 | templatedialogimpl.h \ |
18 | quickedit.h \ | 18 | quickedit.h \ |
19 | quickeditimpl.h \ | 19 | quickeditimpl.h \ |
20 | otaskeditor.h \ | 20 | otaskeditor.h \ |
21 | taskeditoroverviewimpl.h | 21 | taskeditoroverviewimpl.h \ |
22 | taskeditoradvancedimpl.h | ||
22 | 23 | ||
23 | SOURCES= smalltodo.cpp \ | 24 | SOURCES= smalltodo.cpp \ |
24 | todomanager.cpp \ | 25 | todomanager.cpp \ |
25 | mainwindow.cpp \ | 26 | mainwindow.cpp \ |
26 | main.cpp \ | 27 | main.cpp \ |
27 | tableview.cpp \ | 28 | tableview.cpp \ |
28 | tableitems.cpp \ | 29 | tableitems.cpp \ |
29 | todoview.cpp \ | 30 | todoview.cpp \ |
30 | todotemplatemanager.cpp \ | 31 | todotemplatemanager.cpp \ |
31 | todoeditor.cpp \ | 32 | todoeditor.cpp \ |
32 | todoshow.cpp \ | 33 | todoshow.cpp \ |
33 | textviewshow.cpp \ | 34 | textviewshow.cpp \ |
34 | templateeditor.cpp \ | 35 | templateeditor.cpp \ |
35 | templatedialog.cpp \ | 36 | templatedialog.cpp \ |
36 | templatedialogimpl.cpp \ | 37 | templatedialogimpl.cpp \ |
37 | quickeditimpl.cpp \ | 38 | quickeditimpl.cpp \ |
38 | quickedit.cpp \ | 39 | quickedit.cpp \ |
39 | otaskeditor.cpp \ | 40 | otaskeditor.cpp \ |
40 | taskeditoroverviewimpl.cpp | 41 | taskeditoroverviewimpl.cpp \ |
42 | taskeditoradvancedimpl.cpp | ||
41 | 43 | ||
42 | INTERFACES= taskeditoradvanced.ui taskeditoralarms.ui taskeditoroverview.ui | 44 | INTERFACES= taskeditoradvanced.ui taskeditoralarms.ui taskeditoroverview.ui |
43 | TARGET = todolist | 45 | TARGET = todolist |
44 | INCLUDEPATH += $(OPIEDIR)/include | 46 | INCLUDEPATH += $(OPIEDIR)/include |
45 | DEPENDPATH+= $(OPIEDIR)/include | 47 | DEPENDPATH+= $(OPIEDIR)/include |
46 | LIBS += -lqpe -lopie | 48 | LIBS += -lqpe -lopie |
47 | 49 | ||
48 | TRANSLATIONS = ../../../i18n/de/todolist.ts \ | 50 | TRANSLATIONS = ../../../i18n/de/todolist.ts \ |
49 | ../../../i18n/en/todolist.ts \ | 51 | ../../../i18n/en/todolist.ts \ |
50 | ../../../i18n/es/todolist.ts \ | 52 | ../../../i18n/es/todolist.ts \ |
51 | ../../../i18n/fr/todolist.ts \ | 53 | ../../../i18n/fr/todolist.ts \ |
52 | ../../../i18n/hu/todolist.ts \ | 54 | ../../../i18n/hu/todolist.ts \ |
53 | ../../../i18n/ja/todolist.ts \ | 55 | ../../../i18n/ja/todolist.ts \ |
54 | ../../../i18n/ko/todolist.ts \ | 56 | ../../../i18n/ko/todolist.ts \ |
55 | ../../../i18n/no/todolist.ts \ | 57 | ../../../i18n/no/todolist.ts \ |
56 | ../../../i18n/pl/todolist.ts \ | 58 | ../../../i18n/pl/todolist.ts \ |
57 | ../../../i18n/pt/todolist.ts \ | 59 | ../../../i18n/pt/todolist.ts \ |
58 | ../../../i18n/pt_BR/todolist.ts \ | 60 | ../../../i18n/pt_BR/todolist.ts \ |
59 | ../../../i18n/sl/todolist.ts \ | 61 | ../../../i18n/sl/todolist.ts \ |
60 | ../../../i18n/zh_CN/todolist.ts \ | 62 | ../../../i18n/zh_CN/todolist.ts \ |
61 | ../../../i18n/zh_TW/todolist.ts | 63 | ../../../i18n/zh_TW/todolist.ts |
diff --git a/core/pim/todo/todomanager.cpp b/core/pim/todo/todomanager.cpp index 1f81539..b5b87de 100644 --- a/core/pim/todo/todomanager.cpp +++ b/core/pim/todo/todomanager.cpp | |||
@@ -1,126 +1,129 @@ | |||
1 | /* | 1 | /* |
2 | =. This file is part of the OPIE Project | 2 | =. This file is part of the OPIE Project |
3 | .=l. Copyright (c) 2002 <> | 3 | .=l. Copyright (c) 2002 <> |
4 | .>+-= | 4 | .>+-= |
5 | _;:, .> :=|. This program is free software; you can | 5 | _;:, .> :=|. This program is free software; you can |
6 | .> <`_, > . <= redistribute it and/or modify it under | 6 | .> <`_, > . <= redistribute it and/or modify it under |
7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
8 | .="- .-=="i, .._ License as published by the Free Software | 8 | .="- .-=="i, .._ License as published by the Free Software |
9 | - . .-<_> .<> Foundation; either version 2 of the License, | 9 | - . .-<_> .<> Foundation; either version 2 of the License, |
10 | ._= =} : or (at your option) any later version. | 10 | ._= =} : or (at your option) any later version. |
11 | .%`+i> _;_. | 11 | .%`+i> _;_. |
12 | .i_,=:_. -<s. This program is distributed in the hope that | 12 | .i_,=:_. -<s. This program is distributed in the hope that |
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
14 | : .. .:, . . . without even the implied warranty of | 14 | : .. .:, . . . without even the implied warranty of |
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
17 | ..}^=.= = ; Library General Public License for more | 17 | ..}^=.= = ; Library General Public License for more |
18 | ++= -. .` .: details. | 18 | ++= -. .` .: details. |
19 | : = ...= . :.=- | 19 | : = ...= . :.=- |
20 | -. .:....=;==+<; You should have received a copy of the GNU | 20 | -. .:....=;==+<; You should have received a copy of the GNU |
21 | -_. . . )=. = Library General Public License along with | 21 | -_. . . )=. = Library General Public License along with |
22 | -- :-=` this library; see the file COPYING.LIB. | 22 | -- :-=` this library; see the file COPYING.LIB. |
23 | If not, write to the Free Software Foundation, | 23 | If not, write to the Free Software Foundation, |
24 | Inc., 59 Temple Place - Suite 330, | 24 | Inc., 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | #include <qdatetime.h> | 28 | #include <qdatetime.h> |
29 | #include <qpe/categoryselect.h> | 29 | #include <qpe/categoryselect.h> |
30 | 30 | ||
31 | #include "todomanager.h" | 31 | #include "todomanager.h" |
32 | 32 | ||
33 | using namespace Todo; | 33 | using namespace Todo; |
34 | 34 | ||
35 | TodoManager::TodoManager( QObject *obj ) | 35 | TodoManager::TodoManager( QObject *obj ) |
36 | : QObject( obj ) { | 36 | : QObject( obj ) { |
37 | m_db = 0l; | 37 | m_db = 0l; |
38 | QTime time; | 38 | QTime time; |
39 | time.start(); | 39 | time.start(); |
40 | int el = time.elapsed(); | 40 | int el = time.elapsed(); |
41 | qWarning("QTimer for loading %d", el/1000 ); | 41 | qWarning("QTimer for loading %d", el/1000 ); |
42 | } | 42 | } |
43 | TodoManager::~TodoManager() { | 43 | TodoManager::~TodoManager() { |
44 | delete m_db; | 44 | delete m_db; |
45 | } | 45 | } |
46 | OTodo TodoManager::event(int uid ) { | 46 | OTodo TodoManager::event(int uid ) { |
47 | return m_db->find( uid ); | 47 | return m_db->find( uid ); |
48 | } | 48 | } |
49 | void TodoManager::updateList() { | 49 | void TodoManager::updateList() { |
50 | qWarning("update list"); | 50 | qWarning("update list"); |
51 | m_list = m_db->allRecords(); | 51 | m_list = m_db->allRecords(); |
52 | } | 52 | } |
53 | OTodoAccess::List TodoManager::list() const{ | 53 | OTodoAccess::List TodoManager::list() const{ |
54 | return m_list; | 54 | return m_list; |
55 | } | 55 | } |
56 | OTodoAccess::List TodoManager::sorted( bool asc, int so, int f, int cat ) { | 56 | OTodoAccess::List TodoManager::sorted( bool asc, int so, int f, int cat ) { |
57 | return m_db->sorted( asc, so, f, cat ); | 57 | return m_db->sorted( asc, so, f, cat ); |
58 | } | 58 | } |
59 | OTodoAccess::List::Iterator TodoManager::overDue() { | 59 | OTodoAccess::List::Iterator TodoManager::overDue() { |
60 | int filter = 2 | 1; | 60 | int filter = 2 | 1; |
61 | m_list = m_db->sorted(m_asc, m_sortOrder, filter, m_ca ); | 61 | m_list = m_db->sorted(m_asc, m_sortOrder, filter, m_ca ); |
62 | m_it = m_list.begin(); | 62 | m_it = m_list.begin(); |
63 | return m_it; | 63 | return m_it; |
64 | } | 64 | } |
65 | OTodoAccess::List::Iterator TodoManager::fromTo( const QDate& start, | 65 | OTodoAccess::List::Iterator TodoManager::fromTo( const QDate& start, |
66 | const QDate& end ) { | 66 | const QDate& end ) { |
67 | m_list = m_db->effectiveToDos( start, end ); | 67 | m_list = m_db->effectiveToDos( start, end ); |
68 | m_it = m_list.begin(); | 68 | m_it = m_list.begin(); |
69 | return m_it; | 69 | return m_it; |
70 | } | 70 | } |
71 | OTodoAccess::List::Iterator TodoManager::query( const OTodo& ev, int query ) { | 71 | OTodoAccess::List::Iterator TodoManager::query( const OTodo& ev, int query ) { |
72 | m_list = m_db->queryByExample( ev, query ); | 72 | m_list = m_db->queryByExample( ev, query ); |
73 | m_it = m_list.begin(); | 73 | m_it = m_list.begin(); |
74 | return m_it; | 74 | return m_it; |
75 | } | 75 | } |
76 | OTodoAccess* TodoManager::todoDB() { | 76 | OTodoAccess* TodoManager::todoDB() { |
77 | return m_db; | 77 | return m_db; |
78 | } | 78 | } |
79 | void TodoManager::add( const OTodo& ev ) { | 79 | void TodoManager::add( const OTodo& ev ) { |
80 | m_db->add( ev ); | 80 | m_db->add( ev ); |
81 | } | 81 | } |
82 | void TodoManager::update( int, const SmallTodo& ) { | 82 | void TodoManager::update( int, const SmallTodo& ) { |
83 | 83 | ||
84 | } | 84 | } |
85 | void TodoManager::update( int, const OTodo& ev) { | 85 | void TodoManager::update( int, const OTodo& ev) { |
86 | m_db->replace( ev ); | 86 | m_db->replace( ev ); |
87 | } | 87 | } |
88 | void TodoManager::remove( int uid ) { | 88 | bool TodoManager::remove( int uid ) { |
89 | m_db->remove( uid ); | 89 | return m_db->remove( uid ); |
90 | } | 90 | } |
91 | void TodoManager::removeAll() { | 91 | void TodoManager::removeAll() { |
92 | m_db->clear(); | 92 | m_db->clear(); |
93 | } | 93 | } |
94 | void TodoManager::removeCompleted() { | ||
95 | m_db->removeAllCompleted(); | ||
96 | } | ||
94 | void TodoManager::save() { | 97 | void TodoManager::save() { |
95 | m_db->save(); | 98 | m_db->save(); |
96 | } | 99 | } |
97 | bool TodoManager::saveAll() { | 100 | bool TodoManager::saveAll() { |
98 | return m_db->save(); | 101 | return m_db->save(); |
99 | } | 102 | } |
100 | void TodoManager::reload() { | 103 | void TodoManager::reload() { |
101 | m_db->reload(); | 104 | m_db->reload(); |
102 | } | 105 | } |
103 | QStringList TodoManager::categories() { | 106 | QStringList TodoManager::categories() { |
104 | m_cat.load(categoryFileName() ); | 107 | m_cat.load(categoryFileName() ); |
105 | return m_cat.labels( "Todo List"); | 108 | return m_cat.labels( "Todo List"); |
106 | } | 109 | } |
107 | /* | 110 | /* |
108 | * we rely on load beeing called from populateCategories | 111 | * we rely on load beeing called from populateCategories |
109 | */ | 112 | */ |
110 | int TodoManager::catId( const QString& cats ) { | 113 | int TodoManager::catId( const QString& cats ) { |
111 | return m_cat.id( "Todo List", cats ); | 114 | return m_cat.id( "Todo List", cats ); |
112 | } | 115 | } |
113 | void TodoManager::remove( const QArray<int>& ids) { | 116 | void TodoManager::remove( const QArray<int>& ids) { |
114 | for (uint i=0; i < ids.size(); i++ ) | 117 | for (uint i=0; i < ids.size(); i++ ) |
115 | remove( ids[i] ); | 118 | remove( ids[i] ); |
116 | } | 119 | } |
117 | bool TodoManager::isLoaded()const { | 120 | bool TodoManager::isLoaded()const { |
118 | return (m_db == 0 ); | 121 | return (m_db == 0 ); |
119 | } | 122 | } |
120 | void TodoManager::load() { | 123 | void TodoManager::load() { |
121 | if (!m_db) { | 124 | if (!m_db) { |
122 | qWarning("loading!"); | 125 | qWarning("loading!"); |
123 | m_db = new OTodoAccess(); | 126 | m_db = new OTodoAccess(); |
124 | m_db->load(); | 127 | m_db->load(); |
125 | } | 128 | } |
126 | } | 129 | } |
diff --git a/core/pim/todo/todomanager.h b/core/pim/todo/todomanager.h index b03b598..8544277 100644 --- a/core/pim/todo/todomanager.h +++ b/core/pim/todo/todomanager.h | |||
@@ -1,106 +1,111 @@ | |||
1 | /* | 1 | /* |
2 | =. This file is part of the OPIE Project | 2 | =. This file is part of the OPIE Project |
3 | .=l. Copyright (c) 2002 <> | 3 | .=l. Copyright (c) 2002 <> |
4 | .>+-= | 4 | .>+-= |
5 | _;:, .> :=|. This program is free software; you can | 5 | _;:, .> :=|. This program is free software; you can |
6 | .> <`_, > . <= redistribute it and/or modify it under | 6 | .> <`_, > . <= redistribute it and/or modify it under |
7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
8 | .="- .-=="i, .._ License as published by the Free Software | 8 | .="- .-=="i, .._ License as published by the Free Software |
9 | - . .-<_> .<> Foundation; either version 2 of the License, | 9 | - . .-<_> .<> Foundation; either version 2 of the License, |
10 | ._= =} : or (at your option) any later version. | 10 | ._= =} : or (at your option) any later version. |
11 | .%`+i> _;_. | 11 | .%`+i> _;_. |
12 | .i_,=:_. -<s. This program is distributed in the hope that | 12 | .i_,=:_. -<s. This program is distributed in the hope that |
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
14 | : .. .:, . . . without even the implied warranty of | 14 | : .. .:, . . . without even the implied warranty of |
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
17 | ..}^=.= = ; Library General Public License for more | 17 | ..}^=.= = ; Library General Public License for more |
18 | ++= -. .` .: details. | 18 | ++= -. .` .: details. |
19 | : = ...= . :.=- | 19 | : = ...= . :.=- |
20 | -. .:....=;==+<; You should have received a copy of the GNU | 20 | -. .:....=;==+<; You should have received a copy of the GNU |
21 | -_. . . )=. = Library General Public License along with | 21 | -_. . . )=. = Library General Public License along with |
22 | -- :-=` this library; see the file COPYING.LIB. | 22 | -- :-=` this library; see the file COPYING.LIB. |
23 | If not, write to the Free Software Foundation, | 23 | If not, write to the Free Software Foundation, |
24 | Inc., 59 Temple Place - Suite 330, | 24 | Inc., 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | 28 | ||
29 | #ifndef OPIE_TODO_MANAGER_H | 29 | #ifndef OPIE_TODO_MANAGER_H |
30 | #define OPIE_TODO_MANAGER_H | 30 | #define OPIE_TODO_MANAGER_H |
31 | 31 | ||
32 | #include <qarray.h> | 32 | #include <qarray.h> |
33 | #include <qobject.h> | 33 | #include <qobject.h> |
34 | #include <qstring.h> | 34 | #include <qstring.h> |
35 | 35 | ||
36 | #include <qpe/categories.h> | 36 | #include <qpe/categories.h> |
37 | 37 | ||
38 | #include <opie/otodo.h> | 38 | #include <opie/otodo.h> |
39 | #include <opie/otodoaccess.h> | 39 | #include <opie/otodoaccess.h> |
40 | 40 | ||
41 | #include "smalltodo.h" | 41 | #include "smalltodo.h" |
42 | 42 | ||
43 | 43 | ||
44 | namespace Todo { | 44 | namespace Todo { |
45 | class TodoManager : public QObject{ | 45 | class TodoManager : public QObject{ |
46 | Q_OBJECT | 46 | Q_OBJECT |
47 | public: | 47 | public: |
48 | bool isLoaded()const; | 48 | bool isLoaded()const; |
49 | void load(); | 49 | void load(); |
50 | TodoManager(QObject* obj = 0); | 50 | TodoManager(QObject* obj = 0); |
51 | ~TodoManager(); | 51 | ~TodoManager(); |
52 | 52 | ||
53 | QStringList categories()/*const*/; | 53 | QStringList categories()/*const*/; |
54 | int catId(const QString&); | 54 | int catId(const QString&); |
55 | OTodo event(int uid ); | 55 | OTodo event(int uid ); |
56 | 56 | ||
57 | void updateList(); | 57 | void updateList(); |
58 | /** returns the iterator sorted if set sorted*/ | 58 | /** returns the iterator sorted if set sorted*/ |
59 | OTodoAccess::List list()const; | 59 | OTodoAccess::List list()const; |
60 | OTodoAccess::List sorted( bool asc, int so, int f, int cat ); | 60 | OTodoAccess::List sorted( bool asc, int so, int f, int cat ); |
61 | 61 | ||
62 | OTodoAccess::List::Iterator overDue(); | 62 | OTodoAccess::List::Iterator overDue(); |
63 | OTodoAccess::List::Iterator fromTo( const QDate& start, | 63 | OTodoAccess::List::Iterator fromTo( const QDate& start, |
64 | const QDate& end ); | 64 | const QDate& end ); |
65 | OTodoAccess::List::Iterator query( const OTodo& ev, int query ); | 65 | OTodoAccess::List::Iterator query( const OTodo& ev, int query ); |
66 | 66 | ||
67 | void setCategory( bool sort, int category = -1); | 67 | void setCategory( bool sort, int category = -1); |
68 | void setShowOverDue( bool show ); | 68 | void setShowOverDue( bool show ); |
69 | void setSortOrder( int sortOrder ); | 69 | void setSortOrder( int sortOrder ); |
70 | void setSortASC( bool ); | 70 | void setSortASC( bool ); |
71 | void sort(); | 71 | void sort(); |
72 | 72 | ||
73 | OTodoAccess* todoDB(); | 73 | OTodoAccess* todoDB(); |
74 | bool saveAll(); | 74 | bool saveAll(); |
75 | 75 | ||
76 | 76 | ||
77 | signals: | 77 | signals: |
78 | void update(); | 78 | void update(); |
79 | void updateCategories(); | 79 | void updateCategories(); |
80 | 80 | ||
81 | public slots: | 81 | public slots: |
82 | void add( const OTodo& ); | 82 | void add( const OTodo& ); |
83 | void update( int uid, const SmallTodo& ); | 83 | void update( int uid, const SmallTodo& ); |
84 | void update( int uid, const OTodo& ); | 84 | void update( int uid, const OTodo& ); |
85 | void remove( int uid ); | 85 | bool remove( int uid ); |
86 | void remove( const QArray<int>& ); | 86 | void remove( const QArray<int>& ); |
87 | |||
88 | /** | ||
89 | * remove all completed | ||
90 | */ | ||
91 | void removeCompleted(); | ||
87 | void removeAll(); | 92 | void removeAll(); |
88 | void reload(); | 93 | void reload(); |
89 | void save(); | 94 | void save(); |
90 | 95 | ||
91 | private: | 96 | private: |
92 | OTodoAccess* m_db; | 97 | OTodoAccess* m_db; |
93 | OTodoAccess::List m_list; | 98 | OTodoAccess::List m_list; |
94 | OTodoAccess::List::Iterator m_it; | 99 | OTodoAccess::List::Iterator m_it; |
95 | OTodoAccess::List m_sorted; | 100 | OTodoAccess::List m_sorted; |
96 | Categories m_cat; | 101 | Categories m_cat; |
97 | int m_ca; | 102 | int m_ca; |
98 | /* sort cat */ | 103 | /* sort cat */ |
99 | bool m_shCat; | 104 | bool m_shCat; |
100 | int m_sortOrder; | 105 | int m_sortOrder; |
101 | bool m_asc; | 106 | bool m_asc; |
102 | 107 | ||
103 | }; | 108 | }; |
104 | }; | 109 | }; |
105 | 110 | ||
106 | #endif | 111 | #endif |
diff --git a/core/pim/todo/todoview.cpp b/core/pim/todo/todoview.cpp index 4cf7d30..3e808e7 100644 --- a/core/pim/todo/todoview.cpp +++ b/core/pim/todo/todoview.cpp | |||
@@ -1,79 +1,66 @@ | |||
1 | #include "mainwindow.h" | 1 | #include "mainwindow.h" |
2 | 2 | ||
3 | #include "todoview.h" | 3 | #include "todoview.h" |
4 | 4 | ||
5 | using namespace Todo; | 5 | using namespace Todo; |
6 | 6 | ||
7 | |||
8 | |||
9 | |||
7 | TodoView::TodoView( MainWindow* win ) | 10 | TodoView::TodoView( MainWindow* win ) |
8 | : m_main( win ) | 11 | : m_main( win ) |
9 | { | 12 | { |
10 | hack = new InternQtHack; | ||
11 | m_asc = false; | 13 | m_asc = false; |
12 | m_sortOrder = -1; | 14 | m_sortOrder = -1; |
13 | } | 15 | } |
14 | TodoView::~TodoView() { | 16 | TodoView::~TodoView() { |
15 | delete hack; | ||
16 | }; | 17 | }; |
17 | |||
18 | void TodoView::connectShow(QObject* obj, | ||
19 | const char* slot ) { | ||
20 | QObject::connect( hack, SIGNAL(showTodo(int) ), | ||
21 | obj, slot ); | ||
22 | } | ||
23 | void TodoView::connectEdit( QObject* obj, | ||
24 | const char* slot ) { | ||
25 | QObject::connect( hack, SIGNAL(edit(int) ), | ||
26 | obj, slot ); | ||
27 | } | ||
28 | void TodoView::connectUpdateSmall( QObject* obj, | ||
29 | const char* slot ) { | ||
30 | QObject::connect( hack, SIGNAL(update(int, const Todo::SmallTodo& ) ), | ||
31 | obj, slot ); | ||
32 | } | ||
33 | void TodoView::connectUpdateBig( QObject* obj, | ||
34 | const char* slot ) { | ||
35 | QObject::connect( hack, SIGNAL(update(int, const OTodo& ) ), | ||
36 | obj, slot ); | ||
37 | } | ||
38 | void TodoView::connectUpdateView( QObject* obj, | ||
39 | const char* slot ) { | ||
40 | QObject::connect( hack, SIGNAL(update(QWidget*) ), | ||
41 | obj, slot ); | ||
42 | } | ||
43 | void TodoView::connectRemove( QObject* obj, | ||
44 | const char* slot ) { | ||
45 | QObject::connect( hack, SIGNAL(remove(int) ), | ||
46 | obj, slot ); | ||
47 | } | ||
48 | MainWindow* TodoView::todoWindow() { | 18 | MainWindow* TodoView::todoWindow() { |
49 | return m_main; | 19 | return m_main; |
50 | } | 20 | } |
51 | 21 | ||
52 | OTodo TodoView::event(int uid ) { return m_main->event( uid ); } | 22 | OTodo TodoView::event(int uid ) { |
23 | return m_main->event( uid ); | ||
24 | } | ||
53 | OTodoAccess::List TodoView::list(){ | 25 | OTodoAccess::List TodoView::list(){ |
54 | todoWindow()->updateList(); | 26 | todoWindow()->updateList(); |
55 | return todoWindow()->list(); | 27 | return todoWindow()->list(); |
56 | } | 28 | } |
57 | OTodoAccess::List TodoView::sorted()const{ | 29 | OTodoAccess::List TodoView::sorted()const{ |
58 | return m_sort; | 30 | return m_sort; |
59 | } | 31 | } |
60 | void TodoView::sort() { | 32 | void TodoView::sort() { |
61 | m_sort = todoWindow()->sorted(m_asc,m_sortOrder ); | 33 | m_sort = todoWindow()->sorted(m_asc,m_sortOrder ); |
62 | qWarning("m_sort.count() = %d", m_sort.count() ); | 34 | qWarning("m_sort.count() = %d", m_sort.count() ); |
63 | } | 35 | } |
64 | void TodoView::sort(int sort) { | 36 | void TodoView::sort(int sort) { |
65 | m_sort = todoWindow()->sorted(m_asc, m_sortOrder, sort ); | 37 | m_sort = todoWindow()->sorted(m_asc, m_sortOrder, sort ); |
66 | } | 38 | } |
67 | void TodoView::setSortOrder( int order ) { | 39 | void TodoView::setSortOrder( int order ) { |
68 | m_sortOrder = order; | 40 | m_sortOrder = order; |
69 | } | 41 | } |
70 | void TodoView::setAscending( bool b ) { | 42 | void TodoView::setAscending( bool b ) { |
71 | qWarning("setAscending %d", b ); | 43 | qWarning("setAscending %d", b ); |
72 | m_asc = b; | 44 | m_asc = b; |
73 | } | 45 | } |
74 | void TodoView::update(int, const SmallTodo& ) { | 46 | void TodoView::update(int, const SmallTodo& ) { |
75 | //m_main->slotUpate1( uid, to ); | 47 | //m_main->slotUpate1( uid, to ); |
76 | } | 48 | } |
77 | void TodoView::update(int , const OTodo& ev ) { | 49 | void TodoView::update(int , const OTodo& ev ) { |
78 | m_main->updateTodo( ev ); | 50 | m_main->updateTodo( ev ); |
79 | } | 51 | } |
52 | void TodoView::showTodo( int uid ) { | ||
53 | m_main->slotShow( uid ); | ||
54 | } | ||
55 | void TodoView::edit( int uid ) { | ||
56 | m_main->slotEdit( uid ); | ||
57 | } | ||
58 | void TodoView::remove( int uid ) { | ||
59 | m_main->m_todoMgr.remove( uid ); | ||
60 | } | ||
61 | void TodoView::complete( int uid ) { | ||
62 | m_main->slotComplete( uid ); | ||
63 | } | ||
64 | void TodoView::complete( const OTodo& ev ) { | ||
65 | m_main->slotComplete( ev ); | ||
66 | } | ||
diff --git a/core/pim/todo/todoview.h b/core/pim/todo/todoview.h index e5c77f9..e73e808 100644 --- a/core/pim/todo/todoview.h +++ b/core/pim/todo/todoview.h | |||
@@ -1,188 +1,124 @@ | |||
1 | /* | 1 | /* |
2 | =. This file is part of the OPIE Project | 2 | =. This file is part of the OPIE Project |
3 | .=l. Copyright (c) 2002 <> | 3 | .=l. Copyright (c) 2002 <> |
4 | .>+-= | 4 | .>+-= |
5 | _;:, .> :=|. This program is free software; you can | 5 | _;:, .> :=|. This program is free software; you can |
6 | .> <`_, > . <= redistribute it and/or modify it under | 6 | .> <`_, > . <= redistribute it and/or modify it under |
7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
8 | .="- .-=="i, .._ License as published by the Free Software | 8 | .="- .-=="i, .._ License as published by the Free Software |
9 | - . .-<_> .<> Foundation; either version 2 of the License, | 9 | - . .-<_> .<> Foundation; either version 2 of the License, |
10 | ._= =} : or (at your option) any later version. | 10 | ._= =} : or (at your option) any later version. |
11 | .%`+i> _;_. | 11 | .%`+i> _;_. |
12 | .i_,=:_. -<s. This program is distributed in the hope that | 12 | .i_,=:_. -<s. This program is distributed in the hope that |
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
14 | : .. .:, . . . without even the implied warranty of | 14 | : .. .:, . . . without even the implied warranty of |
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
17 | ..}^=.= = ; Library General Public License for more | 17 | ..}^=.= = ; Library General Public License for more |
18 | ++= -. .` .: details. | 18 | ++= -. .` .: details. |
19 | : = ...= . :.=- | 19 | : = ...= . :.=- |
20 | -. .:....=;==+<; You should have received a copy of the GNU | 20 | -. .:....=;==+<; You should have received a copy of the GNU |
21 | -_. . . )=. = Library General Public License along with | 21 | -_. . . )=. = Library General Public License along with |
22 | -- :-=` this library; see the file COPYING.LIB. | 22 | -- :-=` this library; see the file COPYING.LIB. |
23 | If not, write to the Free Software Foundation, | 23 | If not, write to the Free Software Foundation, |
24 | Inc., 59 Temple Place - Suite 330, | 24 | Inc., 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | 28 | ||
29 | #ifndef TODO_VIEW_H | 29 | #ifndef TODO_VIEW_H |
30 | #define TODO_VIEW_H | 30 | #define TODO_VIEW_H |
31 | 31 | ||
32 | #include <qarray.h> | 32 | #include <qarray.h> |
33 | #include <qstring.h> | 33 | #include <qstring.h> |
34 | #include <qvaluelist.h> | 34 | #include <qvaluelist.h> |
35 | #include <qwidget.h> | 35 | #include <qwidget.h> |
36 | 36 | ||
37 | #include <opie/otodoaccess.h> | 37 | #include <opie/otodoaccess.h> |
38 | 38 | ||
39 | #include "smalltodo.h" | 39 | #include "smalltodo.h" |
40 | 40 | ||
41 | 41 | ||
42 | namespace Todo { | 42 | namespace Todo { |
43 | |||
44 | /** | ||
45 | * According to tronical it's not possible | ||
46 | * to have Q_OBJECT in a template at all | ||
47 | * so this is a hack widget not meant | ||
48 | * to be public | ||
49 | */ | ||
50 | class InternQtHack : public QObject { | ||
51 | Q_OBJECT | ||
52 | public: | ||
53 | InternQtHack() : QObject() {}; | ||
54 | void emitShow(int uid) { emit showTodo(uid); } | ||
55 | void emitEdit(int uid) { emit edit(uid ); } | ||
56 | void emitUpdate( int uid, | ||
57 | const SmallTodo& to) { | ||
58 | emit update(uid, to ); | ||
59 | } | ||
60 | void emitUpdate( int uid, | ||
61 | const OTodo& ev ){ | ||
62 | emit update(uid, ev ); | ||
63 | } | ||
64 | void emitRemove( int uid ) { | ||
65 | emit remove( uid ); | ||
66 | } | ||
67 | void emitUpdate( QWidget* wid ) { | ||
68 | emit update( wid ); | ||
69 | } | ||
70 | signals: | ||
71 | void showTodo(int uid ); | ||
72 | void edit(int uid ); | ||
73 | void update( int uid, const Todo::SmallTodo& ); | ||
74 | void update( int uid, const OTodo& ); | ||
75 | /* sorry you need to cast */; | ||
76 | void update( QWidget* wid ); | ||
77 | void remove( int uid ); | ||
78 | |||
79 | }; | ||
80 | class MainWindow; | 43 | class MainWindow; |
81 | 44 | ||
82 | /** | 45 | /** |
83 | * due to inheretince problems we need this base class | 46 | * due to inheretince problems we need this base class |
84 | */ | 47 | */ |
85 | class ViewBase { | 48 | struct ViewBase { |
86 | public: | 49 | public: |
87 | virtual QWidget* widget() = 0; | 50 | virtual QWidget* widget() = 0; |
88 | virtual QString type()const = 0; | 51 | virtual QString type()const = 0; |
89 | virtual int current() = 0; | 52 | virtual int current() = 0; |
90 | virtual QString currentRepresentation() = 0; | 53 | virtual QString currentRepresentation() = 0; |
91 | virtual void showOverDue( bool ) = 0; | 54 | virtual void showOverDue( bool ) = 0; |
92 | 55 | ||
93 | /* | 56 | /* |
94 | * update the view | 57 | * update the view |
95 | */ | 58 | */ |
96 | virtual void updateView() = 0; | 59 | virtual void updateView() = 0; |
97 | 60 | ||
98 | virtual void addEvent( const OTodo& ) = 0; | 61 | virtual void addEvent( const OTodo& ) = 0; |
99 | virtual void replaceEvent( const OTodo& ) = 0; | 62 | virtual void replaceEvent( const OTodo& ) = 0; |
100 | virtual void removeEvent( int uid ) = 0; | 63 | virtual void removeEvent( int uid ) = 0; |
101 | virtual void setShowCompleted( bool ) = 0; | 64 | virtual void setShowCompleted( bool ) = 0; |
102 | virtual void setShowDeadline( bool ) = 0; | 65 | virtual void setShowDeadline( bool ) = 0; |
103 | virtual void setShowCategory( const QString& = QString::null ) = 0; | 66 | virtual void setShowCategory( const QString& = QString::null ) = 0; |
104 | virtual void clear() = 0; | 67 | virtual void clear() = 0; |
105 | /* virtual QArray<int> completed() = 0; */ | ||
106 | virtual void newDay() = 0; | 68 | virtual void newDay() = 0; |
107 | |||
108 | virtual void connectShow( QObject*, const char* ) = 0; | ||
109 | virtual void connectEdit( QObject*, const char* ) = 0; | ||
110 | virtual void connectUpdateSmall( QObject*, const char* ) = 0; | ||
111 | virtual void connectUpdateBig( QObject*, const char* ) = 0; | ||
112 | virtual void connectUpdateView( QObject*, const char*) = 0; | ||
113 | virtual void connectRemove( QObject*, const char* ) = 0; | ||
114 | |||
115 | }; | 69 | }; |
116 | 70 | ||
117 | /** | 71 | /** |
118 | * A base class for all TodoView which are showing | 72 | * A base class for all TodoView which are showing |
119 | * a list of todos. | 73 | * a list of todos. |
120 | * Either in a QTable, QListView or any other QWidget | 74 | * Either in a QTable, QListView or any other QWidget |
121 | * derived class | 75 | * derived class |
122 | * Through the MainWindow( dispatcher ) one can access | 76 | * Through the MainWindow( dispatcher ) one can access |
123 | * the relevant informations | 77 | * the relevant informations |
124 | * | 78 | * |
125 | * It's not possible to have signal and slots from within | 79 | * It's not possible to have signal and slots from within |
126 | * templates this way you've to register for a signal | 80 | * templates this way you've to register for a signal |
127 | */ | 81 | */ |
128 | class TodoView : public ViewBase{ | 82 | class TodoView : public ViewBase{ |
129 | 83 | ||
130 | public: | 84 | public: |
131 | /** | 85 | /** |
132 | * c'tor | 86 | * c'tor |
133 | */ | 87 | */ |
134 | TodoView( MainWindow* win ); | 88 | TodoView( MainWindow* win ); |
135 | 89 | ||
136 | /** | 90 | /** |
137 | *d'tor | 91 | *d'tor |
138 | */ | 92 | */ |
139 | virtual ~TodoView(); | 93 | virtual ~TodoView(); |
140 | 94 | ||
141 | /* connect to the show signal */ | ||
142 | void connectShow(QObject* obj, | ||
143 | const char* slot ); | ||
144 | |||
145 | /* connect to edit */ | ||
146 | void connectEdit( QObject* obj, | ||
147 | const char* slot ); | ||
148 | void connectUpdateSmall( QObject* obj, | ||
149 | const char* slot ); | ||
150 | void connectUpdateBig( QObject* obj, | ||
151 | const char* slot ) ; | ||
152 | void connectUpdateView( QObject* obj, | ||
153 | const char* slot ); | ||
154 | void connectRemove( QObject* obj, | ||
155 | const char* slot ); | ||
156 | protected: | 95 | protected: |
157 | MainWindow* todoWindow(); | 96 | MainWindow* todoWindow(); |
158 | OTodo event(int uid ); | 97 | OTodo event(int uid ); |
159 | OTodoAccess::List list(); | 98 | OTodoAccess::List list(); |
160 | OTodoAccess::List sorted()const; | 99 | OTodoAccess::List sorted()const; |
161 | void sort(); | 100 | void sort(); |
162 | void sort(int sort ); | 101 | void sort(int sort ); |
163 | void setSortOrder( int order ); | 102 | void setSortOrder( int order ); |
164 | void setAscending( bool ); | 103 | void setAscending( bool ); |
165 | 104 | ||
166 | /* | 105 | /* |
167 | These things needs to be implemented | 106 | * These things needs to be implemented |
168 | in a implementation | 107 | * in a implementation |
169 | signals: | 108 | */ |
170 | */ | 109 | void showTodo( int uid ); |
171 | protected: | 110 | void edit( int uid ); |
172 | void showTodo( int uid ) { hack->emitShow(uid); } | ||
173 | void edit( int uid ) { hack->emitEdit(uid); } | ||
174 | void update(int uid, const SmallTodo& to ); | 111 | void update(int uid, const SmallTodo& to ); |
175 | void update(int uid, const OTodo& ev); | 112 | void update(int uid, const OTodo& ev); |
176 | void remove( int uid ) { | 113 | void remove( int uid ); |
177 | hack->emitRemove( uid ); | 114 | void complete( int uid ); |
178 | } | 115 | void complete( const OTodo& ev ); |
179 | private: | 116 | private: |
180 | InternQtHack* hack; | ||
181 | MainWindow *m_main; | 117 | MainWindow *m_main; |
182 | OTodoAccess::List m_sort; | 118 | OTodoAccess::List m_sort; |
183 | bool m_asc : 1; | 119 | bool m_asc : 1; |
184 | int m_sortOrder; | 120 | int m_sortOrder; |
185 | }; | 121 | }; |
186 | }; | 122 | }; |
187 | 123 | ||
188 | #endif | 124 | #endif |