author | zecke <zecke> | 2002-10-21 23:07:17 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-10-21 23:07:17 (UTC) |
commit | cfc75c71bea57ca49367242204f9d3fbfca92deb (patch) (unidiff) | |
tree | 3604c59b1905d7d767aefeaaa22d0574bd2f02c8 | |
parent | 0b0f3dccd3b6dbb01fd268e2c737fd1a6c163379 (diff) | |
download | opie-cfc75c71bea57ca49367242204f9d3fbfca92deb.zip opie-cfc75c71bea57ca49367242204f9d3fbfca92deb.tar.gz opie-cfc75c71bea57ca49367242204f9d3fbfca92deb.tar.bz2 |
Now it should compile just fine
-rw-r--r-- | core/pim/todo/mainwindow.cpp | 1 |
1 files changed, 0 insertions, 1 deletions
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp index bf9fc23..71e6750 100644 --- a/core/pim/todo/mainwindow.cpp +++ b/core/pim/todo/mainwindow.cpp | |||
@@ -1,707 +1,706 @@ | |||
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/otodoaccessvcal.h> | 47 | #include <opie/otodoaccessvcal.h> |
48 | 48 | ||
49 | #include "quickeditimpl.h" | 49 | #include "quickeditimpl.h" |
50 | #include "todotemplatemanager.h" | 50 | #include "todotemplatemanager.h" |
51 | #include "templateeditor.h" | 51 | #include "templateeditor.h" |
52 | #include "todoentryimpl.h" | ||
53 | #include "tableview.h" | 52 | #include "tableview.h" |
54 | 53 | ||
55 | #include "textviewshow.h" | 54 | #include "textviewshow.h" |
56 | #include "todoeditor.h" | 55 | #include "todoeditor.h" |
57 | #include "mainwindow.h" | 56 | #include "mainwindow.h" |
58 | 57 | ||
59 | 58 | ||
60 | using namespace Todo; | 59 | using namespace Todo; |
61 | 60 | ||
62 | MainWindow::MainWindow( QWidget* parent, | 61 | MainWindow::MainWindow( QWidget* parent, |
63 | const char* name ) { | 62 | const char* name ) { |
64 | 63 | ||
65 | m_syncing = false; | 64 | m_syncing = false; |
66 | m_counter = 0; | 65 | m_counter = 0; |
67 | m_tempManager = new TemplateManager(); | 66 | m_tempManager = new TemplateManager(); |
68 | m_tempManager->load(); | 67 | m_tempManager->load(); |
69 | 68 | ||
70 | initUI(); | 69 | initUI(); |
71 | initConfig(); | 70 | initConfig(); |
72 | initViews(); | 71 | initViews(); |
73 | initActions(); | 72 | initActions(); |
74 | initEditor(); | 73 | initEditor(); |
75 | initShow(); | 74 | initShow(); |
76 | initTemplate(); | 75 | initTemplate(); |
77 | 76 | ||
78 | populateTemplates(); | 77 | populateTemplates(); |
79 | raiseCurrentView(); | 78 | raiseCurrentView(); |
80 | QTimer::singleShot(0, this, SLOT(populateCategories() ) ); | 79 | QTimer::singleShot(0, this, SLOT(populateCategories() ) ); |
81 | } | 80 | } |
82 | void MainWindow::initTemplate() { | 81 | void MainWindow::initTemplate() { |
83 | m_curTempEd = new TemplateEditor( this, templateManager() ); | 82 | m_curTempEd = new TemplateEditor( this, templateManager() ); |
84 | } | 83 | } |
85 | void MainWindow::initActions() { | 84 | void MainWindow::initActions() { |
86 | QAction* a = new QAction( tr("New Task" ), Resource::loadPixmap( "new" ), | 85 | QAction* a = new QAction( tr("New Task" ), Resource::loadPixmap( "new" ), |
87 | QString::null, 0, this, 0 ); | 86 | QString::null, 0, this, 0 ); |
88 | connect(a, SIGNAL( activated() ), | 87 | connect(a, SIGNAL( activated() ), |
89 | this, SLOT( slotNew() ) ); | 88 | this, SLOT( slotNew() ) ); |
90 | a->addTo(m_tool ); | 89 | a->addTo(m_tool ); |
91 | a->addTo(m_edit ); | 90 | a->addTo(m_edit ); |
92 | 91 | ||
93 | a = new QAction( tr("Edit Task"), Resource::loadIconSet( "edit" ), | 92 | a = new QAction( tr("Edit Task"), Resource::loadIconSet( "edit" ), |
94 | QString::null, 0, this, 0 ); | 93 | QString::null, 0, this, 0 ); |
95 | connect(a, SIGNAL(activated() ), | 94 | connect(a, SIGNAL(activated() ), |
96 | this, SLOT( slotEdit() ) ); | 95 | this, SLOT( slotEdit() ) ); |
97 | a->addTo( m_tool ); | 96 | a->addTo( m_tool ); |
98 | a->addTo( m_edit ); | 97 | a->addTo( m_edit ); |
99 | m_editAction = a; | 98 | m_editAction = a; |
100 | 99 | ||
101 | a = new QAction( QString::null, tr("View Task"), 0, this, 0 ); | 100 | a = new QAction( QString::null, tr("View Task"), 0, this, 0 ); |
102 | connect(a, SIGNAL( activated() ), | 101 | connect(a, SIGNAL( activated() ), |
103 | this, SLOT( slotShowDetails() ) ); | 102 | this, SLOT( slotShowDetails() ) ); |
104 | a->addTo( m_edit ); | 103 | a->addTo( m_edit ); |
105 | 104 | ||
106 | m_edit->insertSeparator(); | 105 | m_edit->insertSeparator(); |
107 | 106 | ||
108 | a = new QAction( tr("Delete..."), Resource::loadIconSet( "trash" ), | 107 | a = new QAction( tr("Delete..."), Resource::loadIconSet( "trash" ), |
109 | QString::null, 0, this, 0 ); | 108 | QString::null, 0, this, 0 ); |
110 | connect(a, SIGNAL(activated() ), | 109 | connect(a, SIGNAL(activated() ), |
111 | this, SLOT(slotDelete() ) ); | 110 | this, SLOT(slotDelete() ) ); |
112 | a->addTo( m_tool ); | 111 | a->addTo( m_tool ); |
113 | a->addTo( m_edit ); | 112 | a->addTo( m_edit ); |
114 | m_deleteAction = a; | 113 | m_deleteAction = a; |
115 | 114 | ||
116 | a = new QAction( QString::null, tr("Delete all..."), 0, this, 0 ); | 115 | a = new QAction( QString::null, tr("Delete all..."), 0, this, 0 ); |
117 | connect(a, SIGNAL( activated() ), | 116 | connect(a, SIGNAL( activated() ), |
118 | this, SLOT( slotDeleteAll() ) ); | 117 | this, SLOT( slotDeleteAll() ) ); |
119 | a->addTo(m_edit ); | 118 | a->addTo(m_edit ); |
120 | m_deleteAllAction = a; | 119 | m_deleteAllAction = a; |
121 | 120 | ||
122 | a = new QAction( QString::null, tr("Delete completed"), | 121 | a = new QAction( QString::null, tr("Delete completed"), |
123 | 0, this, 0 ); | 122 | 0, this, 0 ); |
124 | connect(a, SIGNAL( activated() ), | 123 | connect(a, SIGNAL( activated() ), |
125 | this, SLOT( slotDeleteCompleted() ) ); | 124 | this, SLOT( slotDeleteCompleted() ) ); |
126 | a->addTo(m_edit ); | 125 | a->addTo(m_edit ); |
127 | a->setEnabled( TRUE ); | 126 | a->setEnabled( TRUE ); |
128 | m_deleteCompleteAction = a; | 127 | m_deleteCompleteAction = a; |
129 | 128 | ||
130 | m_edit->insertSeparator(); | 129 | m_edit->insertSeparator(); |
131 | 130 | ||
132 | a = new QAction( QString::null, tr("Duplicate"), 0, this, 0 ); | 131 | a = new QAction( QString::null, tr("Duplicate"), 0, this, 0 ); |
133 | connect(a, SIGNAL( activated() ), | 132 | connect(a, SIGNAL( activated() ), |
134 | this, SLOT( slotDuplicate() ) ); | 133 | this, SLOT( slotDuplicate() ) ); |
135 | a->addTo(m_edit ); | 134 | a->addTo(m_edit ); |
136 | m_duplicateAction = a; | 135 | m_duplicateAction = a; |
137 | 136 | ||
138 | m_edit->insertSeparator(); | 137 | m_edit->insertSeparator(); |
139 | 138 | ||
140 | if ( Ir::supported() ) { | 139 | if ( Ir::supported() ) { |
141 | a = new QAction( tr( "Beam" ), Resource::loadPixmap( "beam" ), | 140 | a = new QAction( tr( "Beam" ), Resource::loadPixmap( "beam" ), |
142 | QString::null, 0, this, 0 ); | 141 | QString::null, 0, this, 0 ); |
143 | connect( a, SIGNAL( activated() ), | 142 | connect( a, SIGNAL( activated() ), |
144 | this, SLOT( slotBeam() ) ); | 143 | this, SLOT( slotBeam() ) ); |
145 | a->addTo( m_edit ); | 144 | a->addTo( m_edit ); |
146 | a->addTo( m_tool ); | 145 | a->addTo( m_tool ); |
147 | } | 146 | } |
148 | 147 | ||
149 | a = new QAction( tr("Find"), Resource::loadIconSet( "mag" ), | 148 | a = new QAction( tr("Find"), Resource::loadIconSet( "mag" ), |
150 | QString::null, 0, this, 0 ); | 149 | QString::null, 0, this, 0 ); |
151 | connect(a, SIGNAL( activated() ), | 150 | connect(a, SIGNAL( activated() ), |
152 | this, SLOT( slotFind() ) ); | 151 | this, SLOT( slotFind() ) ); |
153 | a->addTo( m_options ); | 152 | a->addTo( m_options ); |
154 | m_findAction = a; | 153 | m_findAction = a; |
155 | 154 | ||
156 | m_options->insertSeparator(); | 155 | m_options->insertSeparator(); |
157 | 156 | ||
158 | m_completedAction = new QAction( QString::null, tr("Completed tasks"), | 157 | m_completedAction = new QAction( QString::null, tr("Completed tasks"), |
159 | 0, this, 0, TRUE ); | 158 | 0, this, 0, TRUE ); |
160 | m_completedAction->addTo( m_options ); | 159 | m_completedAction->addTo( m_options ); |
161 | m_completedAction->setOn( showCompleted() ); | 160 | m_completedAction->setOn( showCompleted() ); |
162 | connect(m_completedAction, SIGNAL( toggled(bool) ), | 161 | connect(m_completedAction, SIGNAL( toggled(bool) ), |
163 | this, SLOT(slotShowCompleted(bool) ) ); | 162 | this, SLOT(slotShowCompleted(bool) ) ); |
164 | 163 | ||
165 | m_showDeadLineAction = new QAction( QString::null, tr("Show Deadline"), | 164 | m_showDeadLineAction = new QAction( QString::null, tr("Show Deadline"), |
166 | 0, this, 0, TRUE ); | 165 | 0, this, 0, TRUE ); |
167 | m_showDeadLineAction->addTo( m_options ); | 166 | m_showDeadLineAction->addTo( m_options ); |
168 | m_showDeadLineAction->setOn( showDeadline() ); | 167 | m_showDeadLineAction->setOn( showDeadline() ); |
169 | connect(m_showDeadLineAction, SIGNAL(toggled(bool) ), | 168 | connect(m_showDeadLineAction, SIGNAL(toggled(bool) ), |
170 | this, SLOT( slotShowDeadLine( bool ) ) ); | 169 | this, SLOT( slotShowDeadLine( bool ) ) ); |
171 | 170 | ||
172 | m_options->insertSeparator(); | 171 | m_options->insertSeparator(); |
173 | 172 | ||
174 | m_bar->insertItem( tr("Data") ,m_edit ); | 173 | m_bar->insertItem( tr("Data") ,m_edit ); |
175 | m_bar->insertItem( tr("Category"), m_catMenu ); | 174 | m_bar->insertItem( tr("Category"), m_catMenu ); |
176 | m_bar->insertItem( tr("Options"), m_options ); | 175 | m_bar->insertItem( tr("Options"), m_options ); |
177 | 176 | ||
178 | /* initialize the view menu */ | 177 | /* initialize the view menu */ |
179 | a = new QAction( QString::null, tr("Show over due"), | 178 | a = new QAction( QString::null, tr("Show over due"), |
180 | 0, this, 0, TRUE ); | 179 | 0, this, 0, TRUE ); |
181 | a->addTo( m_view ); | 180 | a->addTo( m_view ); |
182 | a->setOn( showOverDue() ); | 181 | a->setOn( showOverDue() ); |
183 | connect(a, SIGNAL(toggled(bool)), | 182 | connect(a, SIGNAL(toggled(bool)), |
184 | this, SLOT(slotShowDue(bool) ) ); | 183 | this, SLOT(slotShowDue(bool) ) ); |
185 | m_view->insertSeparator(); | 184 | m_view->insertSeparator(); |
186 | 185 | ||
187 | m_bar->insertItem( tr("View"), m_view ); | 186 | m_bar->insertItem( tr("View"), m_view ); |
188 | 187 | ||
189 | /* templates */ | 188 | /* templates */ |
190 | m_edit->insertItem(tr("New from template"), m_template, | 189 | m_edit->insertItem(tr("New from template"), m_template, |
191 | -1, 0 ); | 190 | -1, 0 ); |
192 | 191 | ||
193 | } | 192 | } |
194 | /* m_curCat from Config */ | 193 | /* m_curCat from Config */ |
195 | void MainWindow::initConfig() { | 194 | void MainWindow::initConfig() { |
196 | Config config( "todo" ); | 195 | Config config( "todo" ); |
197 | config.setGroup( "View" ); | 196 | config.setGroup( "View" ); |
198 | m_completed = config.readBoolEntry( "ShowComplete", TRUE ); | 197 | m_completed = config.readBoolEntry( "ShowComplete", TRUE ); |
199 | m_curCat = config.readEntry( "Category", QString::null ); | 198 | m_curCat = config.readEntry( "Category", QString::null ); |
200 | m_deadline = config.readBoolEntry( "ShowDeadLine", TRUE); | 199 | m_deadline = config.readBoolEntry( "ShowDeadLine", TRUE); |
201 | m_overdue = config.readBoolEntry("ShowOverDue", TRUE ); | 200 | m_overdue = config.readBoolEntry("ShowOverDue", TRUE ); |
202 | } | 201 | } |
203 | void MainWindow::initUI() { | 202 | void MainWindow::initUI() { |
204 | m_mainBox = new QVBox(this, "main box "); | 203 | m_mainBox = new QVBox(this, "main box "); |
205 | m_curQuick = new QuickEditImpl(this, m_mainBox ); | 204 | m_curQuick = new QuickEditImpl(this, m_mainBox ); |
206 | m_curQuick->signal()->connect( this, SLOT(slotQuickEntered() ) ); | 205 | m_curQuick->signal()->connect( this, SLOT(slotQuickEntered() ) ); |
207 | m_quickEdit.append( m_curQuick ); | 206 | m_quickEdit.append( m_curQuick ); |
208 | 207 | ||
209 | 208 | ||
210 | 209 | ||
211 | m_stack = new QWidgetStack(m_mainBox, "main stack"); | 210 | m_stack = new QWidgetStack(m_mainBox, "main stack"); |
212 | setCentralWidget( m_mainBox ); | 211 | setCentralWidget( m_mainBox ); |
213 | 212 | ||
214 | setToolBarsMovable( FALSE ); | 213 | setToolBarsMovable( FALSE ); |
215 | 214 | ||
216 | m_tool = new QToolBar( this ); | 215 | m_tool = new QToolBar( this ); |
217 | m_tool->setHorizontalStretchable( TRUE ); | 216 | m_tool->setHorizontalStretchable( TRUE ); |
218 | 217 | ||
219 | m_bar = new QMenuBar( m_tool ); | 218 | m_bar = new QMenuBar( m_tool ); |
220 | 219 | ||
221 | /** QPopupMenu */ | 220 | /** QPopupMenu */ |
222 | m_edit = new QPopupMenu( this ); | 221 | m_edit = new QPopupMenu( this ); |
223 | m_options = new QPopupMenu( this ); | 222 | m_options = new QPopupMenu( this ); |
224 | m_view = new QPopupMenu( this ); | 223 | m_view = new QPopupMenu( this ); |
225 | m_catMenu = new QPopupMenu( this ); | 224 | m_catMenu = new QPopupMenu( this ); |
226 | m_template = new QPopupMenu( this ); | 225 | m_template = new QPopupMenu( this ); |
227 | 226 | ||
228 | m_catMenu->setCheckable( TRUE ); | 227 | m_catMenu->setCheckable( TRUE ); |
229 | m_template->setCheckable( TRUE ); | 228 | m_template->setCheckable( TRUE ); |
230 | 229 | ||
231 | connect(m_catMenu, SIGNAL(activated(int) ), | 230 | connect(m_catMenu, SIGNAL(activated(int) ), |
232 | this, SLOT(setCategory(int) ) ); | 231 | this, SLOT(setCategory(int) ) ); |
233 | connect(m_template, SIGNAL(activated(int) ), | 232 | connect(m_template, SIGNAL(activated(int) ), |
234 | this, SLOT(slotNewFromTemplate(int) ) ); | 233 | this, SLOT(slotNewFromTemplate(int) ) ); |
235 | } | 234 | } |
236 | void MainWindow::initViews() { | 235 | void MainWindow::initViews() { |
237 | TableView* tableView = new TableView( this, m_stack ); | 236 | TableView* tableView = new TableView( this, m_stack ); |
238 | m_stack->addWidget( tableView, m_counter++ ); | 237 | m_stack->addWidget( tableView, m_counter++ ); |
239 | m_views.append( tableView ); | 238 | m_views.append( tableView ); |
240 | m_curView = tableView; | 239 | m_curView = tableView; |
241 | connectBase( tableView ); | 240 | connectBase( tableView ); |
242 | /* add QString type + QString configname to | 241 | /* add QString type + QString configname to |
243 | * the View menu | 242 | * the View menu |
244 | * and subdirs for multiple views | 243 | * and subdirs for multiple views |
245 | */ | 244 | */ |
246 | } | 245 | } |
247 | void MainWindow::initEditor() { | 246 | void MainWindow::initEditor() { |
248 | m_curEdit = new Editor(); | 247 | m_curEdit = new Editor(); |
249 | } | 248 | } |
250 | void MainWindow::initShow() { | 249 | void MainWindow::initShow() { |
251 | m_curShow = new TextViewShow(this); | 250 | m_curShow = new TextViewShow(this); |
252 | m_stack->addWidget( m_curShow->widget() , m_counter++ ); | 251 | m_stack->addWidget( m_curShow->widget() , m_counter++ ); |
253 | } | 252 | } |
254 | MainWindow::~MainWindow() { | 253 | MainWindow::~MainWindow() { |
255 | delete templateManager(); | 254 | delete templateManager(); |
256 | } | 255 | } |
257 | void MainWindow::connectBase( ViewBase* base) { | 256 | void MainWindow::connectBase( ViewBase* base) { |
258 | base->connectShow( this, SLOT(slotShow(int) ) ); | 257 | base->connectShow( this, SLOT(slotShow(int) ) ); |
259 | base->connectEdit( this, SLOT(slotEdit(int) ) ); | 258 | base->connectEdit( this, SLOT(slotEdit(int) ) ); |
260 | base->connectUpdateSmall( this, | 259 | base->connectUpdateSmall( this, |
261 | SLOT(slotUpate1(int, const Todo::SmallTodo&) )); | 260 | SLOT(slotUpate1(int, const Todo::SmallTodo&) )); |
262 | base->connectUpdateBig( this, | 261 | base->connectUpdateBig( this, |
263 | SLOT(slotUpate2(int, const OTodo& ) ) ); | 262 | SLOT(slotUpate2(int, const OTodo& ) ) ); |
264 | base->connectUpdateView( this, SLOT(slotUpdate3( QWidget* ) ) ) ; | 263 | base->connectUpdateView( this, SLOT(slotUpdate3( QWidget* ) ) ) ; |
265 | base->connectRemove(&m_todoMgr, | 264 | base->connectRemove(&m_todoMgr, |
266 | SLOT(remove(int)) ); | 265 | SLOT(remove(int)) ); |
267 | } | 266 | } |
268 | QPopupMenu* MainWindow::contextMenu( int uid ) { | 267 | QPopupMenu* MainWindow::contextMenu( int uid ) { |
269 | QPopupMenu* menu = new QPopupMenu(); | 268 | QPopupMenu* menu = new QPopupMenu(); |
270 | 269 | ||
271 | m_editAction->addTo( menu ); | 270 | m_editAction->addTo( menu ); |
272 | m_deleteAction->addTo( menu ); | 271 | m_deleteAction->addTo( menu ); |
273 | m_duplicateAction->addTo( menu ); | 272 | m_duplicateAction->addTo( menu ); |
274 | menu->insertSeparator(); | 273 | menu->insertSeparator(); |
275 | 274 | ||
276 | return menu; | 275 | return menu; |
277 | } | 276 | } |
278 | QPopupMenu* MainWindow::options() { | 277 | QPopupMenu* MainWindow::options() { |
279 | qWarning("Options"); | 278 | qWarning("Options"); |
280 | return m_options; | 279 | return m_options; |
281 | } | 280 | } |
282 | QPopupMenu* MainWindow::edit() { | 281 | QPopupMenu* MainWindow::edit() { |
283 | return m_edit; | 282 | return m_edit; |
284 | } | 283 | } |
285 | QPopupMenu* MainWindow::view() { | 284 | QPopupMenu* MainWindow::view() { |
286 | return m_view; | 285 | return m_view; |
287 | } | 286 | } |
288 | QToolBar* MainWindow::toolbar() { | 287 | QToolBar* MainWindow::toolbar() { |
289 | return m_tool; | 288 | return m_tool; |
290 | } | 289 | } |
291 | OTodoAccess::List MainWindow::list()const { | 290 | OTodoAccess::List MainWindow::list()const { |
292 | return m_todoMgr.list(); | 291 | return m_todoMgr.list(); |
293 | } | 292 | } |
294 | OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder ) { | 293 | OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder ) { |
295 | int cat = 0; | 294 | int cat = 0; |
296 | if ( m_curCat != tr("All Categories") ) | 295 | if ( m_curCat != tr("All Categories") ) |
297 | cat = currentCatId(); | 296 | cat = currentCatId(); |
298 | 297 | ||
299 | int filter = 1; | 298 | int filter = 1; |
300 | 299 | ||
301 | if (!m_completed ) | 300 | if (!m_completed ) |
302 | filter |= 4; | 301 | filter |= 4; |
303 | if (m_overdue) | 302 | if (m_overdue) |
304 | filter |= 2; | 303 | filter |= 2; |
305 | 304 | ||
306 | return m_todoMgr.sorted( asc, sortOrder, filter, cat ); | 305 | return m_todoMgr.sorted( asc, sortOrder, filter, cat ); |
307 | } | 306 | } |
308 | OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder, int addFilter) { | 307 | OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder, int addFilter) { |
309 | int cat = 0; | 308 | int cat = 0; |
310 | if ( m_curCat != tr("All Categories") ) | 309 | if ( m_curCat != tr("All Categories") ) |
311 | cat = currentCatId(); | 310 | cat = currentCatId(); |
312 | 311 | ||
313 | return m_todoMgr.sorted(asc, sortOrder, addFilter, cat ); | 312 | return m_todoMgr.sorted(asc, sortOrder, addFilter, cat ); |
314 | } | 313 | } |
315 | OTodo MainWindow::event( int uid ) { | 314 | OTodo MainWindow::event( int uid ) { |
316 | return m_todoMgr.event( uid ); | 315 | return m_todoMgr.event( uid ); |
317 | } | 316 | } |
318 | bool MainWindow::isSyncing()const { | 317 | bool MainWindow::isSyncing()const { |
319 | return m_syncing; | 318 | return m_syncing; |
320 | } | 319 | } |
321 | TemplateManager* MainWindow::templateManager() { | 320 | TemplateManager* MainWindow::templateManager() { |
322 | return m_tempManager; | 321 | return m_tempManager; |
323 | } | 322 | } |
324 | Editor* MainWindow::currentEditor() { | 323 | Editor* MainWindow::currentEditor() { |
325 | return m_curEdit; | 324 | return m_curEdit; |
326 | } | 325 | } |
327 | TodoShow* MainWindow::currentShow() { | 326 | TodoShow* MainWindow::currentShow() { |
328 | return m_curShow; | 327 | return m_curShow; |
329 | } | 328 | } |
330 | void MainWindow::slotReload() { | 329 | void MainWindow::slotReload() { |
331 | m_todoMgr.reload(); | 330 | m_todoMgr.reload(); |
332 | currentView()->updateView( ); | 331 | currentView()->updateView( ); |
333 | raiseCurrentView(); | 332 | raiseCurrentView(); |
334 | } | 333 | } |
335 | void MainWindow::closeEvent( QCloseEvent* e ) { | 334 | void MainWindow::closeEvent( QCloseEvent* e ) { |
336 | if (m_stack->visibleWidget() == currentShow()->widget() ) { | 335 | if (m_stack->visibleWidget() == currentShow()->widget() ) { |
337 | raiseCurrentView(); | 336 | raiseCurrentView(); |
338 | e->ignore(); | 337 | e->ignore(); |
339 | return; | 338 | return; |
340 | } | 339 | } |
341 | /* | 340 | /* |
342 | * we should have flushed and now we're still saving | 341 | * we should have flushed and now we're still saving |
343 | * so there is no need to flush | 342 | * so there is no need to flush |
344 | */ | 343 | */ |
345 | if (m_syncing ) { | 344 | if (m_syncing ) { |
346 | e->accept(); | 345 | e->accept(); |
347 | return; | 346 | return; |
348 | } | 347 | } |
349 | bool quit = false; | 348 | bool quit = false; |
350 | if ( m_todoMgr.saveAll() ){ | 349 | if ( m_todoMgr.saveAll() ){ |
351 | qWarning("saved"); | 350 | qWarning("saved"); |
352 | quit = true; | 351 | quit = true; |
353 | }else { | 352 | }else { |
354 | if ( QMessageBox::critical( this, tr("Out of space"), | 353 | if ( QMessageBox::critical( this, tr("Out of space"), |
355 | tr("Todo was unable\n" | 354 | tr("Todo was unable\n" |
356 | "to save your changes.\n" | 355 | "to save your changes.\n" |
357 | "Free up some space\n" | 356 | "Free up some space\n" |
358 | "and try again.\n" | 357 | "and try again.\n" |
359 | "\nQuit Anyway?"), | 358 | "\nQuit Anyway?"), |
360 | QMessageBox::Yes|QMessageBox::Escape, | 359 | QMessageBox::Yes|QMessageBox::Escape, |
361 | QMessageBox::No|QMessageBox::Default) | 360 | QMessageBox::No|QMessageBox::Default) |
362 | != QMessageBox::No ) { | 361 | != QMessageBox::No ) { |
363 | e->accept(); | 362 | e->accept(); |
364 | quit = true; | 363 | quit = true; |
365 | }else | 364 | }else |
366 | e->ignore(); | 365 | e->ignore(); |
367 | 366 | ||
368 | } | 367 | } |
369 | 368 | ||
370 | if (quit ) { | 369 | if (quit ) { |
371 | Config config( "todo" ); | 370 | Config config( "todo" ); |
372 | config.setGroup( "View" ); | 371 | config.setGroup( "View" ); |
373 | config.writeEntry( "ShowComplete", showCompleted() ); | 372 | config.writeEntry( "ShowComplete", showCompleted() ); |
374 | config.writeEntry( "Category", currentCategory() ); | 373 | config.writeEntry( "Category", currentCategory() ); |
375 | config.writeEntry( "ShowDeadLine", showDeadline()); | 374 | config.writeEntry( "ShowDeadLine", showDeadline()); |
376 | config.writeEntry( "ShowOverDue", showOverDue() ); | 375 | config.writeEntry( "ShowOverDue", showOverDue() ); |
377 | /* svae templates */ | 376 | /* svae templates */ |
378 | templateManager()->save(); | 377 | templateManager()->save(); |
379 | e->accept(); | 378 | e->accept(); |
380 | } | 379 | } |
381 | } | 380 | } |
382 | void MainWindow::populateTemplates() { | 381 | void MainWindow::populateTemplates() { |
383 | m_template->clear(); | 382 | m_template->clear(); |
384 | QStringList list = templateManager()->templates(); | 383 | QStringList list = templateManager()->templates(); |
385 | QStringList::Iterator it; | 384 | QStringList::Iterator it; |
386 | for ( it = list.begin(); it != list.end(); ++it ) { | 385 | for ( it = list.begin(); it != list.end(); ++it ) { |
387 | m_template->insertItem( (*it) ); | 386 | m_template->insertItem( (*it) ); |
388 | } | 387 | } |
389 | } | 388 | } |
390 | /* | 389 | /* |
391 | * slotNewFromTemplate | 390 | * slotNewFromTemplate |
392 | * We use the edit widget to do | 391 | * We use the edit widget to do |
393 | * the config but we setUid(-1) | 392 | * the config but we setUid(-1) |
394 | * to get a new uid | 393 | * to get a new uid |
395 | */ | 394 | */ |
396 | /* | 395 | /* |
397 | * first we get the name of the template | 396 | * first we get the name of the template |
398 | * then we will use the TemplateManager | 397 | * then we will use the TemplateManager |
399 | */ | 398 | */ |
400 | void MainWindow::slotNewFromTemplate( int id ) { | 399 | void MainWindow::slotNewFromTemplate( int id ) { |
401 | QString name = m_template->text( id ); | 400 | QString name = m_template->text( id ); |
402 | 401 | ||
403 | OTodo event = templateManager()->templateEvent( name ); | 402 | OTodo event = templateManager()->templateEvent( name ); |
404 | event = currentEditor()->edit(this, | 403 | event = currentEditor()->edit(this, |
405 | event ); | 404 | event ); |
406 | 405 | ||
407 | if ( currentEditor()->accepted() ) { | 406 | if ( currentEditor()->accepted() ) { |
408 | /* assign new todo */ | 407 | /* assign new todo */ |
409 | event.setUid( -1 ); | 408 | event.setUid( -1 ); |
410 | currentView()->addEvent( event ); | 409 | currentView()->addEvent( event ); |
411 | m_todoMgr.add( event ); | 410 | m_todoMgr.add( event ); |
412 | 411 | ||
413 | populateCategories(); | 412 | populateCategories(); |
414 | } | 413 | } |
415 | } | 414 | } |
416 | void MainWindow::slotNew() { | 415 | void MainWindow::slotNew() { |
417 | if(m_syncing) { | 416 | if(m_syncing) { |
418 | QMessageBox::warning(this, tr("Todo"), | 417 | QMessageBox::warning(this, tr("Todo"), |
419 | tr("Can not edit data, currently syncing")); | 418 | tr("Can not edit data, currently syncing")); |
420 | return; | 419 | return; |
421 | } | 420 | } |
422 | 421 | ||
423 | 422 | ||
424 | OTodo todo = currentEditor()->newTodo( currentCatId(), | 423 | OTodo todo = currentEditor()->newTodo( currentCatId(), |
425 | this ); | 424 | this ); |
426 | 425 | ||
427 | if ( currentEditor()->accepted() ) { | 426 | if ( currentEditor()->accepted() ) { |
428 | //todo.assignUid(); | 427 | //todo.assignUid(); |
429 | m_todoMgr.add( todo ); | 428 | m_todoMgr.add( todo ); |
430 | currentView()->addEvent( todo ); | 429 | currentView()->addEvent( todo ); |
431 | 430 | ||
432 | 431 | ||
433 | // I'm afraid we must call this every time now, otherwise | 432 | // I'm afraid we must call this every time now, otherwise |
434 | // spend expensive time comparing all these strings... | 433 | // spend expensive time comparing all these strings... |
435 | // but only call if we changed something -zecke | 434 | // but only call if we changed something -zecke |
436 | populateCategories(); | 435 | populateCategories(); |
437 | } | 436 | } |
438 | raiseCurrentView( ); | 437 | raiseCurrentView( ); |
439 | } | 438 | } |
440 | void MainWindow::slotDuplicate() { | 439 | void MainWindow::slotDuplicate() { |
441 | if(m_syncing) { | 440 | if(m_syncing) { |
442 | QMessageBox::warning(this, tr("Todo"), | 441 | QMessageBox::warning(this, tr("Todo"), |
443 | tr("Can not edit data, currently syncing")); | 442 | tr("Can not edit data, currently syncing")); |
444 | return; | 443 | return; |
445 | } | 444 | } |
446 | OTodo ev = m_todoMgr.event( currentView()->current() ); | 445 | OTodo ev = m_todoMgr.event( currentView()->current() ); |
447 | /* let's generate a new uid */ | 446 | /* let's generate a new uid */ |
448 | ev.setUid(-1); | 447 | ev.setUid(-1); |
449 | m_todoMgr.add( ev ); | 448 | m_todoMgr.add( ev ); |
450 | 449 | ||
451 | currentView()->addEvent( ev ); | 450 | currentView()->addEvent( ev ); |
452 | raiseCurrentView(); | 451 | raiseCurrentView(); |
453 | } | 452 | } |
454 | void MainWindow::slotDelete() { | 453 | void MainWindow::slotDelete() { |
455 | if (!currentView()->current() ) | 454 | if (!currentView()->current() ) |
456 | return; | 455 | return; |
457 | 456 | ||
458 | if(m_syncing) { | 457 | if(m_syncing) { |
459 | QMessageBox::warning(this, tr("Todo"), | 458 | QMessageBox::warning(this, tr("Todo"), |
460 | tr("Can not edit data, currently syncing")); | 459 | tr("Can not edit data, currently syncing")); |
461 | return; | 460 | return; |
462 | } | 461 | } |
463 | QString strName = currentView()->currentRepresentation(); | 462 | QString strName = currentView()->currentRepresentation(); |
464 | if (!QPEMessageBox::confirmDelete(this, tr("Todo"), strName ) ) | 463 | if (!QPEMessageBox::confirmDelete(this, tr("Todo"), strName ) ) |
465 | return; | 464 | return; |
466 | 465 | ||
467 | m_todoMgr.remove( currentView()->current() ); | 466 | m_todoMgr.remove( currentView()->current() ); |
468 | currentView()->removeEvent( currentView()->current() ); | 467 | currentView()->removeEvent( currentView()->current() ); |
469 | raiseCurrentView(); | 468 | raiseCurrentView(); |
470 | } | 469 | } |
471 | void MainWindow::slotDeleteAll() { | 470 | void MainWindow::slotDeleteAll() { |
472 | if(m_syncing) { | 471 | if(m_syncing) { |
473 | QMessageBox::warning(this, tr("Todo"), | 472 | QMessageBox::warning(this, tr("Todo"), |
474 | tr("Can not edit data, currently syncing")); | 473 | tr("Can not edit data, currently syncing")); |
475 | return; | 474 | return; |
476 | } | 475 | } |
477 | 476 | ||
478 | //QString strName = table->text( table->currentRow(), 2 ).left( 30 ); | 477 | //QString strName = table->text( table->currentRow(), 2 ).left( 30 ); |
479 | 478 | ||
480 | if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("all tasks?") ) ) | 479 | if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("all tasks?") ) ) |
481 | return; | 480 | return; |
482 | 481 | ||
483 | m_todoMgr.removeAll(); | 482 | m_todoMgr.removeAll(); |
484 | currentView()->clear(); | 483 | currentView()->clear(); |
485 | 484 | ||
486 | raiseCurrentView(); | 485 | raiseCurrentView(); |
487 | } | 486 | } |
488 | void MainWindow::slotDeleteCompleted() { | 487 | void MainWindow::slotDeleteCompleted() { |
489 | if(m_syncing) { | 488 | if(m_syncing) { |
490 | QMessageBox::warning(this, tr("Todo"), | 489 | QMessageBox::warning(this, tr("Todo"), |
491 | tr("Can not edit data, currently syncing")); | 490 | tr("Can not edit data, currently syncing")); |
492 | return; | 491 | return; |
493 | } | 492 | } |
494 | 493 | ||
495 | if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("all completed tasks?") ) ) | 494 | if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("all completed tasks?") ) ) |
496 | return; | 495 | return; |
497 | 496 | ||
498 | // FIXME | 497 | // FIXME |
499 | //m_todoMgr.remove( currentView()->completed() ); | 498 | //m_todoMgr.remove( currentView()->completed() ); |
500 | currentView()->updateView( ); | 499 | currentView()->updateView( ); |
501 | } | 500 | } |
502 | void MainWindow::slotFind() { | 501 | void MainWindow::slotFind() { |
503 | 502 | ||
504 | } | 503 | } |
505 | void MainWindow::slotEdit() { | 504 | void MainWindow::slotEdit() { |
506 | slotEdit( currentView()->current() ); | 505 | slotEdit( currentView()->current() ); |
507 | } | 506 | } |
508 | /* | 507 | /* |
509 | * set the category | 508 | * set the category |
510 | */ | 509 | */ |
511 | void MainWindow::setCategory( int c) { | 510 | void MainWindow::setCategory( int c) { |
512 | if ( c <= 0 ) return; | 511 | if ( c <= 0 ) return; |
513 | 512 | ||
514 | 513 | ||
515 | qWarning("Iterating over cats %d", c ); | 514 | qWarning("Iterating over cats %d", c ); |
516 | for ( unsigned int i = 1; i < m_catMenu->count(); i++ ) | 515 | for ( unsigned int i = 1; i < m_catMenu->count(); i++ ) |
517 | m_catMenu->setItemChecked(i, c == (int)i ); | 516 | m_catMenu->setItemChecked(i, c == (int)i ); |
518 | 517 | ||
519 | if (c == 1 ) { | 518 | if (c == 1 ) { |
520 | m_curCat = QString::null; | 519 | m_curCat = QString::null; |
521 | setCaption( tr("Todo") + " - " + tr("All Categories" ) ); | 520 | setCaption( tr("Todo") + " - " + tr("All Categories" ) ); |
522 | 521 | ||
523 | }else if ( c == (int)m_catMenu->count() - 1 ) { | 522 | }else if ( c == (int)m_catMenu->count() - 1 ) { |
524 | m_curCat = tr("Unfiled"); | 523 | m_curCat = tr("Unfiled"); |
525 | setCaption( tr("Todo") + " - " + tr("Unfiled") ); | 524 | setCaption( tr("Todo") + " - " + tr("Unfiled") ); |
526 | }else { | 525 | }else { |
527 | m_curCat = m_todoMgr.categories()[c-2]; | 526 | m_curCat = m_todoMgr.categories()[c-2]; |
528 | setCaption( tr("Todo") + " - " + m_curCat ); | 527 | setCaption( tr("Todo") + " - " + m_curCat ); |
529 | } | 528 | } |
530 | m_catMenu->setItemChecked( c, true ); | 529 | m_catMenu->setItemChecked( c, true ); |
531 | 530 | ||
532 | currentView()->setShowCategory( m_curCat ); | 531 | currentView()->setShowCategory( m_curCat ); |
533 | raiseCurrentView(); | 532 | raiseCurrentView(); |
534 | } | 533 | } |
535 | void MainWindow::slotShowDeadLine( bool dead) { | 534 | void MainWindow::slotShowDeadLine( bool dead) { |
536 | m_deadline = dead; | 535 | m_deadline = dead; |
537 | currentView()->setShowDeadline( dead ); | 536 | currentView()->setShowDeadline( dead ); |
538 | } | 537 | } |
539 | void MainWindow::slotShowCompleted( bool show) { | 538 | void MainWindow::slotShowCompleted( bool show) { |
540 | m_completed = show; | 539 | m_completed = show; |
541 | currentView()->setShowCompleted( m_completed ); | 540 | currentView()->setShowCompleted( m_completed ); |
542 | } | 541 | } |
543 | bool MainWindow::showOverDue()const { | 542 | bool MainWindow::showOverDue()const { |
544 | return m_overdue; | 543 | return m_overdue; |
545 | } | 544 | } |
546 | void MainWindow::setDocument( const QString& fi) { | 545 | void MainWindow::setDocument( const QString& fi) { |
547 | DocLnk doc(fi); | 546 | DocLnk doc(fi); |
548 | if (doc.isValid() ) | 547 | if (doc.isValid() ) |
549 | receiveFile(doc.file() ); | 548 | receiveFile(doc.file() ); |
550 | else | 549 | else |
551 | receiveFile(fi ); | 550 | receiveFile(fi ); |
552 | } | 551 | } |
553 | 552 | ||
554 | static const char *beamfile = "/tmp/opie-todo.vcs"; | 553 | static const char *beamfile = "/tmp/opie-todo.vcs"; |
555 | void MainWindow::slotBeam() { | 554 | void MainWindow::slotBeam() { |
556 | ::unlink( beamfile ); | 555 | ::unlink( beamfile ); |
557 | OTodo todo = event( currentView()->current() ); | 556 | OTodo todo = event( currentView()->current() ); |
558 | OTodoAccessVCal* cal = new OTodoAccessVCal(QString::fromLatin1(beamfile) ); | 557 | OTodoAccessVCal* cal = new OTodoAccessVCal(QString::fromLatin1(beamfile) ); |
559 | OTodoAccess acc( cal ); | 558 | OTodoAccess acc( cal ); |
560 | acc.load(); | 559 | acc.load(); |
561 | acc.add( todo ); | 560 | acc.add( todo ); |
562 | acc.save(); | 561 | acc.save(); |
563 | Ir* ir = new Ir(this ); | 562 | Ir* ir = new Ir(this ); |
564 | connect(ir, SIGNAL(done(Ir*) ), | 563 | connect(ir, SIGNAL(done(Ir*) ), |
565 | this, SLOT(beamDone(Ir*) ) ); | 564 | this, SLOT(beamDone(Ir*) ) ); |
566 | ir->send( beamfile, todo.summary(), "text/x-vCalendar" ); | 565 | ir->send( beamfile, todo.summary(), "text/x-vCalendar" ); |
567 | 566 | ||
568 | } | 567 | } |
569 | void MainWindow::beamDone( Ir* ir) { | 568 | void MainWindow::beamDone( Ir* ir) { |
570 | delete ir; | 569 | delete ir; |
571 | ::unlink( beamfile ); | 570 | ::unlink( beamfile ); |
572 | } | 571 | } |
573 | void MainWindow::receiveFile( const QString& filename ) { | 572 | void MainWindow::receiveFile( const QString& filename ) { |
574 | OTodoAccessVCal* cal = new OTodoAccessVCal(filename ); | 573 | OTodoAccessVCal* cal = new OTodoAccessVCal(filename ); |
575 | OTodoAccess acc( cal ); | 574 | OTodoAccess acc( cal ); |
576 | acc.load(); | 575 | acc.load(); |
577 | OTodoAccess::List list = acc.allRecords(); | 576 | OTodoAccess::List list = acc.allRecords(); |
578 | 577 | ||
579 | QString message = tr("<P>%1 new tasks arrived.<p>Would you like to add them to your Todolist?").arg(list.count() ); | 578 | QString message = tr("<P>%1 new tasks arrived.<p>Would you like to add them to your Todolist?").arg(list.count() ); |
580 | 579 | ||
581 | if ( QMessageBox::information(this, tr("New Tasks"), | 580 | if ( QMessageBox::information(this, tr("New Tasks"), |
582 | message, QMessageBox::Ok, | 581 | message, QMessageBox::Ok, |
583 | QMessageBox::Cancel ) == QMessageBox::Ok ) { | 582 | QMessageBox::Cancel ) == QMessageBox::Ok ) { |
584 | OTodoAccess::List::Iterator it; | 583 | OTodoAccess::List::Iterator it; |
585 | for ( it = list.begin(); it != list.end(); ++it ) | 584 | for ( it = list.begin(); it != list.end(); ++it ) |
586 | m_todoMgr.add( (*it) ); | 585 | m_todoMgr.add( (*it) ); |
587 | 586 | ||
588 | currentView()->updateView(); | 587 | currentView()->updateView(); |
589 | } | 588 | } |
590 | } | 589 | } |
591 | 590 | ||
592 | void MainWindow::slotFlush() { | 591 | void MainWindow::slotFlush() { |
593 | m_syncing = FALSE; | 592 | m_syncing = FALSE; |
594 | m_todoMgr.save(); | 593 | m_todoMgr.save(); |
595 | } | 594 | } |
596 | void MainWindow::slotShowDetails() { | 595 | void MainWindow::slotShowDetails() { |
597 | slotShow( currentView()->current() ); | 596 | slotShow( currentView()->current() ); |
598 | } | 597 | } |
599 | /* | 598 | /* |
600 | * populate the Categories | 599 | * populate the Categories |
601 | * Menu | 600 | * Menu |
602 | */ | 601 | */ |
603 | void MainWindow::populateCategories() { | 602 | void MainWindow::populateCategories() { |
604 | m_todoMgr.load(); | 603 | m_todoMgr.load(); |
605 | 604 | ||
606 | m_catMenu->clear(); | 605 | m_catMenu->clear(); |
607 | int id, rememberId; | 606 | int id, rememberId; |
608 | id = 1; | 607 | id = 1; |
609 | rememberId = 1; | 608 | rememberId = 1; |
610 | 609 | ||
611 | m_catMenu->insertItem( tr( "All Categories" ), id++ ); | 610 | m_catMenu->insertItem( tr( "All Categories" ), id++ ); |
612 | m_catMenu->insertSeparator(); | 611 | m_catMenu->insertSeparator(); |
613 | QStringList categories = m_todoMgr.categories(); | 612 | QStringList categories = m_todoMgr.categories(); |
614 | categories.append( tr( "Unfiled" ) ); | 613 | categories.append( tr( "Unfiled" ) ); |
615 | for ( QStringList::Iterator it = categories.begin(); | 614 | for ( QStringList::Iterator it = categories.begin(); |
616 | it != categories.end(); ++it ) { | 615 | it != categories.end(); ++it ) { |
617 | m_catMenu->insertItem( *it, id ); | 616 | m_catMenu->insertItem( *it, id ); |
618 | if ( *it == currentCategory() ) | 617 | if ( *it == currentCategory() ) |
619 | rememberId = id; | 618 | rememberId = id; |
620 | ++id; | 619 | ++id; |
621 | } | 620 | } |
622 | setCategory( rememberId ); | 621 | setCategory( rememberId ); |
623 | } | 622 | } |
624 | bool MainWindow::showCompleted()const { | 623 | bool MainWindow::showCompleted()const { |
625 | return m_completed; | 624 | return m_completed; |
626 | } | 625 | } |
627 | bool MainWindow::showDeadline()const { | 626 | bool MainWindow::showDeadline()const { |
628 | return m_deadline; | 627 | return m_deadline; |
629 | } | 628 | } |
630 | QString MainWindow::currentCategory()const { | 629 | QString MainWindow::currentCategory()const { |
631 | return m_curCat; | 630 | return m_curCat; |
632 | } | 631 | } |
633 | int MainWindow::currentCatId() { | 632 | int MainWindow::currentCatId() { |
634 | return m_todoMgr.catId( m_curCat ); | 633 | return m_todoMgr.catId( m_curCat ); |
635 | } | 634 | } |
636 | ViewBase* MainWindow::currentView() { | 635 | ViewBase* MainWindow::currentView() { |
637 | return m_curView; | 636 | return m_curView; |
638 | } | 637 | } |
639 | void MainWindow::raiseCurrentView() { | 638 | void MainWindow::raiseCurrentView() { |
640 | m_stack->raiseWidget( m_curView->widget() ); | 639 | m_stack->raiseWidget( m_curView->widget() ); |
641 | } | 640 | } |
642 | void MainWindow::slotShowDue(bool ov) { | 641 | void MainWindow::slotShowDue(bool ov) { |
643 | m_overdue = ov; | 642 | m_overdue = ov; |
644 | currentView()->showOverDue( ov ); | 643 | currentView()->showOverDue( ov ); |
645 | raiseCurrentView(); | 644 | raiseCurrentView(); |
646 | } | 645 | } |
647 | void MainWindow::slotShow( int uid ) { | 646 | void MainWindow::slotShow( int uid ) { |
648 | qWarning("slotShow"); | 647 | qWarning("slotShow"); |
649 | currentShow()->slotShow( event( uid ) ); | 648 | currentShow()->slotShow( event( uid ) ); |
650 | m_stack->raiseWidget( currentShow()->widget() ); | 649 | m_stack->raiseWidget( currentShow()->widget() ); |
651 | } | 650 | } |
652 | void MainWindow::slotEdit( int uid ) { | 651 | void MainWindow::slotEdit( int uid ) { |
653 | if(m_syncing) { | 652 | if(m_syncing) { |
654 | QMessageBox::warning(this, tr("Todo"), | 653 | QMessageBox::warning(this, tr("Todo"), |
655 | tr("Can not edit data, currently syncing")); | 654 | tr("Can not edit data, currently syncing")); |
656 | return; | 655 | return; |
657 | } | 656 | } |
658 | 657 | ||
659 | OTodo todo = m_todoMgr.event( uid ); | 658 | OTodo todo = m_todoMgr.event( uid ); |
660 | 659 | ||
661 | todo = currentEditor()->edit(this, todo ); | 660 | todo = currentEditor()->edit(this, todo ); |
662 | 661 | ||
663 | /* if completed */ | 662 | /* if completed */ |
664 | if ( currentEditor()->accepted() ) { | 663 | if ( currentEditor()->accepted() ) { |
665 | qWarning("Replacing now" ); | 664 | qWarning("Replacing now" ); |
666 | m_todoMgr.update( todo.uid(), todo ); | 665 | m_todoMgr.update( todo.uid(), todo ); |
667 | currentView()->replaceEvent( todo ); | 666 | currentView()->replaceEvent( todo ); |
668 | /* a Category might have changed */ | 667 | /* a Category might have changed */ |
669 | populateCategories(); | 668 | populateCategories(); |
670 | } | 669 | } |
671 | 670 | ||
672 | raiseCurrentView(); | 671 | raiseCurrentView(); |
673 | } | 672 | } |
674 | /* | 673 | /* |
675 | void MainWindow::slotUpdate1( int uid, const SmallTodo& ev) { | 674 | void MainWindow::slotUpdate1( int uid, const SmallTodo& ev) { |
676 | m_todoMgr.update( uid, ev ); | 675 | m_todoMgr.update( uid, ev ); |
677 | } | 676 | } |
678 | */ | 677 | */ |
679 | void MainWindow::updateTodo( const OTodo& ev) { | 678 | void MainWindow::updateTodo( const OTodo& ev) { |
680 | m_todoMgr.update( ev.uid() , ev ); | 679 | m_todoMgr.update( ev.uid() , ev ); |
681 | } | 680 | } |
682 | /* The view changed it's configuration | 681 | /* The view changed it's configuration |
683 | * update the view menu | 682 | * update the view menu |
684 | */ | 683 | */ |
685 | void MainWindow::slotUpdate3( QWidget* ) { | 684 | void MainWindow::slotUpdate3( QWidget* ) { |
686 | 685 | ||
687 | } | 686 | } |
688 | void MainWindow::updateList() { | 687 | void MainWindow::updateList() { |
689 | m_todoMgr.updateList(); | 688 | m_todoMgr.updateList(); |
690 | } | 689 | } |
691 | void MainWindow::setReadAhead( uint count ) { | 690 | void MainWindow::setReadAhead( uint count ) { |
692 | if (m_todoMgr.todoDB() ) | 691 | if (m_todoMgr.todoDB() ) |
693 | m_todoMgr.todoDB()->setReadAhead( count ); | 692 | m_todoMgr.todoDB()->setReadAhead( count ); |
694 | } | 693 | } |
695 | void MainWindow::slotQuickEntered() { | 694 | void MainWindow::slotQuickEntered() { |
696 | qWarning("entered"); | 695 | qWarning("entered"); |
697 | OTodo todo = quickEditor()->todo(); | 696 | OTodo todo = quickEditor()->todo(); |
698 | if (todo.isEmpty() ) | 697 | if (todo.isEmpty() ) |
699 | return; | 698 | return; |
700 | 699 | ||
701 | m_todoMgr.add( todo ); | 700 | m_todoMgr.add( todo ); |
702 | currentView()->addEvent( todo ); | 701 | currentView()->addEvent( todo ); |
703 | raiseCurrentView(); | 702 | raiseCurrentView(); |
704 | } | 703 | } |
705 | QuickEditBase* MainWindow::quickEditor() { | 704 | QuickEditBase* MainWindow::quickEditor() { |
706 | return m_curQuick; | 705 | return m_curQuick; |
707 | } | 706 | } |