summaryrefslogtreecommitdiff
authorharlekin <harlekin>2003-04-10 20:33:24 (UTC)
committer harlekin <harlekin>2003-04-10 20:33:24 (UTC)
commit097706f265bf96a45932e227eb3d5d49bb3ba727 (patch) (unidiff)
treeab816a1ce85920828d9b6e837467c9c25d76f79f
parent0740e2ef7132c53ebe29cc3b548647012bc75d05 (diff)
downloadopie-097706f265bf96a45932e227eb3d5d49bb3ba727.zip
opie-097706f265bf96a45932e227eb3d5d49bb3ba727.tar.gz
opie-097706f265bf96a45932e227eb3d5d49bb3ba727.tar.bz2
have icons on the right side
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/todo/mainwindow.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp
index 58981ca..77cbe17 100644
--- a/core/pim/todo/mainwindow.cpp
+++ b/core/pim/todo/mainwindow.cpp
@@ -1,430 +1,434 @@
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 <qlayout.h>
39#include <qlineedit.h> 40#include <qlineedit.h>
40#include <qwhatsthis.h> 41#include <qwhatsthis.h>
41 42
42#include <qpe/applnk.h> 43#include <qpe/applnk.h>
43#include <qpe/config.h> 44#include <qpe/config.h>
44#include <qpe/ir.h> 45#include <qpe/ir.h>
45#include <qpe/resource.h> 46#include <qpe/resource.h>
46#include <qpe/qpemessagebox.h> 47#include <qpe/qpemessagebox.h>
47#include <qpe/qpetoolbar.h>
48 48
49#include <opie/orecur.h> 49#include <opie/orecur.h>
50#include <opie/otodoaccessvcal.h> 50#include <opie/otodoaccessvcal.h>
51 51
52#include "quickeditimpl.h" 52#include "quickeditimpl.h"
53#include "todotemplatemanager.h" 53#include "todotemplatemanager.h"
54#include "templateeditor.h" 54#include "templateeditor.h"
55#include "tableview.h" 55#include "tableview.h"
56 56
57#include "textviewshow.h" 57#include "textviewshow.h"
58#include "todoeditor.h" 58#include "todoeditor.h"
59#include "mainwindow.h" 59#include "mainwindow.h"
60 60
61 61
62using namespace Todo; 62using namespace Todo;
63 63
64MainWindow::MainWindow( QWidget* parent, 64MainWindow::MainWindow( QWidget* parent,
65 const char* name ) 65 const char* name )
66 : OPimMainWindow( "Todolist", parent, name, WType_TopLevel | WStyle_ContextHelp ) 66 : OPimMainWindow( "Todolist", parent, name, WType_TopLevel | WStyle_ContextHelp )
67{ 67{
68 m_syncing = false; 68 m_syncing = false;
69 m_counter = 0; 69 m_counter = 0;
70 m_tempManager = new TemplateManager(); 70 m_tempManager = new TemplateManager();
71 m_tempManager->load(); 71 m_tempManager->load();
72 72
73 initUI(); 73 initUI();
74 initConfig(); 74 initConfig();
75 initViews(); 75 initViews();
76 initActions(); 76 initActions();
77 initEditor(); 77 initEditor();
78 initShow(); 78 initShow();
79 initTemplate(); 79 initTemplate();
80 80
81 populateTemplates(); 81 populateTemplates();
82 raiseCurrentView(); 82 raiseCurrentView();
83 QTimer::singleShot(0, this, SLOT(populateCategories() ) ); 83 QTimer::singleShot(0, this, SLOT(populateCategories() ) );
84} 84}
85void MainWindow::initTemplate() { 85void MainWindow::initTemplate() {
86 m_curTempEd = new TemplateEditor( this, templateManager() ); 86 m_curTempEd = new TemplateEditor( this, templateManager() );
87} 87}
88void MainWindow::initActions() { 88void MainWindow::initActions() {
89 89
90 // Data menu 90 // Data menu
91 m_edit->insertItem(QWidget::tr("New from template"), m_template, 91 m_edit->insertItem(QWidget::tr("New from template"), m_template,
92 -1, 0 ); 92 -1, 0 );
93 93
94 QAction* a = new QAction( QWidget::tr("New Task" ), Resource::loadPixmap( "new" ), 94 QAction* a = new QAction( QWidget::tr("New Task" ), Resource::loadPixmap( "new" ),
95 QString::null, 0, this, 0 ); 95 QString::null, 0, this, 0 );
96 connect(a, SIGNAL( activated() ), 96 connect(a, SIGNAL( activated() ),
97 this, SLOT( slotNew() ) ); 97 this, SLOT( slotNew() ) );
98 a->setWhatsThis( QWidget::tr( "Click here to create a new task." ) ); 98 a->setWhatsThis( QWidget::tr( "Click here to create a new task." ) );
99 a->addTo(m_tool ); 99 a->addTo(m_tool );
100 a->addTo(m_edit ); 100 a->addTo(m_edit );
101 101
102 a = new QAction( QWidget::tr("Edit Task"), Resource::loadIconSet( "edit" ), 102 a = new QAction( QWidget::tr("Edit Task"), Resource::loadIconSet( "edit" ),
103 QString::null, 0, this, 0 ); 103 QString::null, 0, this, 0 );
104 connect(a, SIGNAL(activated() ), 104 connect(a, SIGNAL(activated() ),
105 this, SLOT( slotEdit() ) ); 105 this, SLOT( slotEdit() ) );
106 a->setWhatsThis( QWidget::tr( "Click here to modify the current task." ) ); 106 a->setWhatsThis( QWidget::tr( "Click here to modify the current task." ) );
107 a->addTo( m_tool ); 107 a->addTo( m_tool );
108 a->addTo( m_edit ); 108 a->addTo( m_edit );
109 m_editAction = a; 109 m_editAction = a;
110 110
111 a = new QAction( QString::null, QWidget::tr("View Task"), 0, this, 0 ); 111 a = new QAction( QString::null, QWidget::tr("View Task"), 0, this, 0 );
112 connect(a, SIGNAL( activated() ), 112 connect(a, SIGNAL( activated() ),
113 this, SLOT( slotShowDetails() ) ); 113 this, SLOT( slotShowDetails() ) );
114 a->addTo( m_edit ); 114 a->addTo( m_edit );
115 115
116 m_edit->insertSeparator(); 116 m_edit->insertSeparator();
117 117
118 a = new QAction( QWidget::tr("Delete..."), Resource::loadIconSet( "trash" ), 118 a = new QAction( QWidget::tr("Delete..."), Resource::loadIconSet( "trash" ),
119 QString::null, 0, this, 0 ); 119 QString::null, 0, this, 0 );
120 connect(a, SIGNAL(activated() ), 120 connect(a, SIGNAL(activated() ),
121 this, SLOT(slotDelete() ) ); 121 this, SLOT(slotDelete() ) );
122 a->setWhatsThis( QWidget::tr( "Click here to remove the current task." ) ); 122 a->setWhatsThis( QWidget::tr( "Click here to remove the current task." ) );
123 a->addTo( m_tool ); 123 a->addTo( m_tool );
124 a->addTo( m_edit ); 124 a->addTo( m_edit );
125 m_deleteAction = a; 125 m_deleteAction = a;
126 126
127 a = new QAction( QString::null, QWidget::tr("Delete all..."), 0, this, 0 ); 127 a = new QAction( QString::null, QWidget::tr("Delete all..."), 0, this, 0 );
128 connect(a, SIGNAL( activated() ), 128 connect(a, SIGNAL( activated() ),
129 this, SLOT( slotDeleteAll() ) ); 129 this, SLOT( slotDeleteAll() ) );
130 a->addTo(m_edit ); 130 a->addTo(m_edit );
131 m_deleteAllAction = a; 131 m_deleteAllAction = a;
132 132
133 a = new QAction( QString::null, QWidget::tr("Delete completed"), 133 a = new QAction( QString::null, QWidget::tr("Delete completed"),
134 0, this, 0 ); 134 0, this, 0 );
135 connect(a, SIGNAL( activated() ), 135 connect(a, SIGNAL( activated() ),
136 this, SLOT( slotDeleteCompleted() ) ); 136 this, SLOT( slotDeleteCompleted() ) );
137 a->addTo(m_edit ); 137 a->addTo(m_edit );
138 a->setEnabled( TRUE ); 138 a->setEnabled( TRUE );
139 m_deleteCompleteAction = a; 139 m_deleteCompleteAction = a;
140 140
141 m_edit->insertSeparator(); 141 m_edit->insertSeparator();
142 142
143 a = new QAction( QString::null, QWidget::tr("Duplicate"), 0, this, 0 ); 143 a = new QAction( QString::null, QWidget::tr("Duplicate"), 0, this, 0 );
144 connect(a, SIGNAL( activated() ), 144 connect(a, SIGNAL( activated() ),
145 this, SLOT( slotDuplicate() ) ); 145 this, SLOT( slotDuplicate() ) );
146 a->addTo(m_edit ); 146 a->addTo(m_edit );
147 m_duplicateAction = a; 147 m_duplicateAction = a;
148 148
149 m_edit->insertSeparator(); 149 m_edit->insertSeparator();
150 150
151 if ( Ir::supported() ) { 151 if ( Ir::supported() ) {
152 a = new QAction( QWidget::tr( "Beam" ), Resource::loadPixmap( "beam" ), QString::null, 0, this, 0 ); 152 a = new QAction( QWidget::tr( "Beam" ), Resource::loadPixmap( "beam" ), QString::null, 0, this, 0 );
153 connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) ); 153 connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) );
154 a->setWhatsThis( QWidget::tr( "Click here to send the current task to another device." ) ); 154 a->setWhatsThis( QWidget::tr( "Click here to send the current task to another device." ) );
155 a->addTo( m_edit ); 155 a->addTo( m_edit );
156 a->addTo( m_tool ); 156 a->addTo( m_tool );
157 } 157 }
158 158
159 // Options menu 159 // Options menu
160 a = new QAction( QWidget::tr("Find"), Resource::loadIconSet( "mag" ), 160 a = new QAction( QWidget::tr("Find"), Resource::loadIconSet( "mag" ),
161 QString::null, 0, this, 0 ); 161 QString::null, 0, this, 0 );
162 connect(a, SIGNAL( activated() ), this, SLOT( slotFind() ) ); 162 connect(a, SIGNAL( activated() ), this, SLOT( slotFind() ) );
163 a->addTo( m_options ); 163 a->addTo( m_options );
164 m_findAction = a; 164 m_findAction = a;
165 165
166 m_options->insertSeparator(); 166 m_options->insertSeparator();
167 167
168 m_completedAction = new QAction( QString::null, QWidget::tr("Show completed tasks"), 168 m_completedAction = new QAction( QString::null, QWidget::tr("Show completed tasks"),
169 0, this, 0, TRUE ); 169 0, this, 0, TRUE );
170 m_completedAction->addTo( m_options ); 170 m_completedAction->addTo( m_options );
171 m_completedAction->setOn( showCompleted() ); 171 m_completedAction->setOn( showCompleted() );
172 connect(m_completedAction, SIGNAL( toggled(bool) ), this, SLOT(slotShowCompleted(bool) ) ); 172 connect(m_completedAction, SIGNAL( toggled(bool) ), this, SLOT(slotShowCompleted(bool) ) );
173 173
174 a = new QAction( QString::null, QWidget::tr("Show only over-due tasks"), 174 a = new QAction( QString::null, QWidget::tr("Show only over-due tasks"),
175 0, this, 0, TRUE ); 175 0, this, 0, TRUE );
176 a->addTo( m_options ); 176 a->addTo( m_options );
177 a->setOn( showOverDue() ); 177 a->setOn( showOverDue() );
178 connect(a, SIGNAL(toggled(bool)), this, SLOT(slotShowDue(bool) ) ); 178 connect(a, SIGNAL(toggled(bool)), this, SLOT(slotShowDue(bool) ) );
179 179
180 m_showDeadLineAction = new QAction( QString::null, QWidget::tr("Show task deadlines"), 180 m_showDeadLineAction = new QAction( QString::null, QWidget::tr("Show task deadlines"),
181 0, this, 0, TRUE ); 181 0, this, 0, TRUE );
182 m_showDeadLineAction->addTo( m_options ); 182 m_showDeadLineAction->addTo( m_options );
183 m_showDeadLineAction->setOn( showDeadline() ); 183 m_showDeadLineAction->setOn( showDeadline() );
184 connect(m_showDeadLineAction, SIGNAL(toggled(bool) ), this, SLOT( slotShowDeadLine( bool ) ) ); 184 connect(m_showDeadLineAction, SIGNAL(toggled(bool) ), this, SLOT( slotShowDeadLine( bool ) ) );
185 185
186 m_showQuickTaskAction = new QAction( QString::null, QWidget::tr("Show quick task bar"), 186 m_showQuickTaskAction = new QAction( QString::null, QWidget::tr("Show quick task bar"),
187 0, this, 0, TRUE ); 187 0, this, 0, TRUE );
188 m_showQuickTaskAction->addTo( m_options ); 188 m_showQuickTaskAction->addTo( m_options );
189 m_showQuickTaskAction->setOn( showQuickTask() ); 189 m_showQuickTaskAction->setOn( showQuickTask() );
190 connect(m_showQuickTaskAction, SIGNAL( toggled(bool) ), this, SLOT(slotShowQuickTask(bool) ) ); 190 connect(m_showQuickTaskAction, SIGNAL( toggled(bool) ), this, SLOT(slotShowQuickTask(bool) ) );
191 191
192 m_options->insertSeparator(); 192 m_options->insertSeparator();
193 193
194 m_bar->insertItem( QWidget::tr("Data") ,m_edit ); 194 m_bar->insertItem( QWidget::tr("Data") ,m_edit );
195 m_bar->insertItem( QWidget::tr("Category"), m_catMenu ); 195 m_bar->insertItem( QWidget::tr("Category"), m_catMenu );
196 m_bar->insertItem( QWidget::tr("Options"), m_options ); 196 m_bar->insertItem( QWidget::tr("Options"), m_options );
197 197
198 m_curQuick = new QuickEditImpl( this, m_quicktask ); 198 m_curQuick = new QuickEditImpl( this, m_quicktask );
199 addToolBar( (QPEToolBar *)m_curQuick->widget(), QWidget::tr( "QuickEdit" ), QMainWindow::Top, TRUE ); 199 addToolBar( (QPEToolBar *)m_curQuick->widget(), QWidget::tr( "QuickEdit" ), QMainWindow::Top, TRUE );
200 m_curQuick->signal()->connect( this, SLOT(slotQuickEntered() ) ); 200 m_curQuick->signal()->connect( this, SLOT(slotQuickEntered() ) );
201 201
202} 202}
203/* m_curCat from Config */ 203/* m_curCat from Config */
204void MainWindow::initConfig() { 204void MainWindow::initConfig() {
205 Config config( "todo" ); 205 Config config( "todo" );
206 config.setGroup( "View" ); 206 config.setGroup( "View" );
207 m_completed = config.readBoolEntry( "ShowComplete", TRUE ); 207 m_completed = config.readBoolEntry( "ShowComplete", TRUE );
208 m_curCat = config.readEntry( "Category", QString::null ); 208 m_curCat = config.readEntry( "Category", QString::null );
209 m_deadline = config.readBoolEntry( "ShowDeadLine", TRUE); 209 m_deadline = config.readBoolEntry( "ShowDeadLine", TRUE);
210 m_overdue = config.readBoolEntry("ShowOverDue", FALSE ); 210 m_overdue = config.readBoolEntry("ShowOverDue", FALSE );
211 m_quicktask = config.readBoolEntry("ShowQuickTask", TRUE); 211 m_quicktask = config.readBoolEntry("ShowQuickTask", TRUE);
212} 212}
213void MainWindow::initUI() { 213void MainWindow::initUI() {
214
214 m_stack = new QWidgetStack(this, "main stack"); 215 m_stack = new QWidgetStack(this, "main stack");
216
215 setCentralWidget( m_stack ); 217 setCentralWidget( m_stack );
216 218
217 setToolBarsMovable( FALSE ); 219 setToolBarsMovable( FALSE );
218 220
219 m_tool = new QPEToolBar( this ); 221 QToolBar *menubarholder = new QToolBar( this );
220 m_tool->setHorizontalStretchable( TRUE ); 222 menubarholder->setHorizontalStretchable( TRUE );
223 m_bar = new QMenuBar( menubarholder );
221 224
222 m_bar = new QMenuBar( m_tool ); 225 m_tool = new QToolBar( this );
223 226
224 /** QPopupMenu */ 227 /** QPopupMenu */
225 m_edit = new QPopupMenu( this ); 228 m_edit = new QPopupMenu( this );
226 m_options = new QPopupMenu( this ); 229 m_options = new QPopupMenu( this );
227 m_catMenu = new QPopupMenu( this ); 230 m_catMenu = new QPopupMenu( this );
228 m_template = new QPopupMenu( this ); 231 m_template = new QPopupMenu( this );
229 232
230 m_catMenu->setCheckable( TRUE ); 233 m_catMenu->setCheckable( TRUE );
231 m_template->setCheckable( TRUE ); 234 m_template->setCheckable( TRUE );
232 235
233 connect(m_catMenu, SIGNAL(activated(int) ), 236 connect(m_catMenu, SIGNAL(activated(int) ),
234 this, SLOT(setCategory(int) ) ); 237 this, SLOT(setCategory(int) ) );
235 connect(m_template, SIGNAL(activated(int) ), 238 connect(m_template, SIGNAL(activated(int) ),
236 this, SLOT(slotNewFromTemplate(int) ) ); 239 this, SLOT(slotNewFromTemplate(int) ) );
237} 240}
238void MainWindow::initViews() { 241void MainWindow::initViews() {
242
239 TableView* tableView = new TableView( this, m_stack ); 243 TableView* tableView = new TableView( this, m_stack );
240 QWhatsThis::add( tableView, QWidget::tr( "This is a listing of all current tasks.\n\nThe list displays the following information:\n1. Completed - A green checkmark indicates task is completed. Click here to complete a task.\n2. Priority - a graphical representation of task priority. Double-click here to modify.\n3. Description - description of task. Click here to select the task.\n4. Deadline - shows when task is due. This column can be shown or hidden by selecting Options->'Show task deadlines' from the menu above." ) ); 244 QWhatsThis::add( tableView, QWidget::tr( "This is a listing of all current tasks.\n\nThe list displays the following information:\n1. Completed - A green checkmark indicates task is completed. Click here to complete a task.\n2. Priority - a graphical representation of task priority. Double-click here to modify.\n3. Description - description of task. Click here to select the task.\n4. Deadline - shows when task is due. This column can be shown or hidden by selecting Options->'Show task deadlines' from the menu above." ) );
241 m_stack->addWidget( tableView, m_counter++ ); 245 m_stack->addWidget( tableView, m_counter++ );
242 m_views.append( tableView ); 246 m_views.append( tableView );
243 m_curView = tableView; 247 m_curView = tableView;
244 connectBase( tableView ); 248 connectBase( tableView );
245 /* add QString type + QString configname to 249 /* add QString type + QString configname to
246 * the View menu 250 * the View menu
247 * and subdirs for multiple views 251 * and subdirs for multiple views
248 */ 252 */
249} 253}
250void MainWindow::initEditor() { 254void MainWindow::initEditor() {
251 m_curEdit = new Editor(); 255 m_curEdit = new Editor();
252} 256}
253void MainWindow::initShow() { 257void MainWindow::initShow() {
254 m_curShow = new TextViewShow(this, this); 258 m_curShow = new TextViewShow(this, this);
255 m_stack->addWidget( m_curShow->widget() , m_counter++ ); 259 m_stack->addWidget( m_curShow->widget() , m_counter++ );
256} 260}
257MainWindow::~MainWindow() { 261MainWindow::~MainWindow() {
258 delete templateManager(); 262 delete templateManager();
259} 263}
260void MainWindow::connectBase( ViewBase* ) { 264void MainWindow::connectBase( ViewBase* ) {
261 // once templates and signals mix we'll use it again 265 // once templates and signals mix we'll use it again
262} 266}
263QPopupMenu* MainWindow::contextMenu( int , bool recur ) { 267QPopupMenu* MainWindow::contextMenu( int , bool recur ) {
264 QPopupMenu* menu = new QPopupMenu(); 268 QPopupMenu* menu = new QPopupMenu();
265 269
266 m_editAction->addTo( menu ); 270 m_editAction->addTo( menu );
267 m_deleteAction->addTo( menu ); 271 m_deleteAction->addTo( menu );
268 m_duplicateAction->addTo( menu ); 272 m_duplicateAction->addTo( menu );
269 273
270 menu->insertSeparator(); 274 menu->insertSeparator();
271 275
272 /* 276 /*
273 * if this event recurs we allow 277 * if this event recurs we allow
274 * to detach it. 278 * to detach it.
275 * remove all 279 * remove all
276 */ 280 */
277 if ( recur ) { 281 if ( recur ) {
278 ; // FIXME 282 ; // FIXME
279 } 283 }
280 284
281 return menu; 285 return menu;
282} 286}
283QPopupMenu* MainWindow::options() { 287QPopupMenu* MainWindow::options() {
284 qWarning("Options"); 288 qWarning("Options");
285 return m_options; 289 return m_options;
286} 290}
287QPopupMenu* MainWindow::edit() { 291QPopupMenu* MainWindow::edit() {
288 return m_edit; 292 return m_edit;
289} 293}
290QToolBar* MainWindow::toolbar() { 294QToolBar* MainWindow::toolbar() {
291 return m_tool; 295 return m_tool;
292} 296}
293OTodoAccess::List MainWindow::list()const { 297OTodoAccess::List MainWindow::list()const {
294 return m_todoMgr.list(); 298 return m_todoMgr.list();
295} 299}
296OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder ) { 300OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder ) {
297 int cat = 0; 301 int cat = 0;
298 if ( m_curCat != QWidget::tr("All Categories") ) 302 if ( m_curCat != QWidget::tr("All Categories") )
299 cat = currentCatId(); 303 cat = currentCatId();
300 304
301 int filter = 1; 305 int filter = 1;
302 306
303 if (!m_completed ) 307 if (!m_completed )
304 filter |= 4; 308 filter |= 4;
305 if (m_overdue) 309 if (m_overdue)
306 filter |= 2; 310 filter |= 2;
307 311
308 return m_todoMgr.sorted( asc, sortOrder, filter, cat ); 312 return m_todoMgr.sorted( asc, sortOrder, filter, cat );
309} 313}
310OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder, int addFilter) { 314OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder, int addFilter) {
311 int cat = 0; 315 int cat = 0;
312 if ( m_curCat != QWidget::tr("All Categories") ) 316 if ( m_curCat != QWidget::tr("All Categories") )
313 cat = currentCatId(); 317 cat = currentCatId();
314 318
315 return m_todoMgr.sorted(asc, sortOrder, addFilter, cat ); 319 return m_todoMgr.sorted(asc, sortOrder, addFilter, cat );
316} 320}
317OTodo MainWindow::event( int uid ) { 321OTodo MainWindow::event( int uid ) {
318 return m_todoMgr.event( uid ); 322 return m_todoMgr.event( uid );
319} 323}
320bool MainWindow::isSyncing()const { 324bool MainWindow::isSyncing()const {
321 return m_syncing; 325 return m_syncing;
322} 326}
323TemplateManager* MainWindow::templateManager() { 327TemplateManager* MainWindow::templateManager() {
324 return m_tempManager; 328 return m_tempManager;
325} 329}
326Editor* MainWindow::currentEditor() { 330Editor* MainWindow::currentEditor() {
327 return m_curEdit; 331 return m_curEdit;
328} 332}
329TodoShow* MainWindow::currentShow() { 333TodoShow* MainWindow::currentShow() {
330 return m_curShow; 334 return m_curShow;
331} 335}
332void MainWindow::slotReload() { 336void MainWindow::slotReload() {
333 m_todoMgr.reload(); 337 m_todoMgr.reload();
334 currentView()->updateView( ); 338 currentView()->updateView( );
335 raiseCurrentView(); 339 raiseCurrentView();
336} 340}
337void MainWindow::closeEvent( QCloseEvent* e ) { 341void MainWindow::closeEvent( QCloseEvent* e ) {
338 if (m_stack->visibleWidget() == currentShow()->widget() ) { 342 if (m_stack->visibleWidget() == currentShow()->widget() ) {
339 raiseCurrentView(); 343 raiseCurrentView();
340 e->ignore(); 344 e->ignore();
341 return; 345 return;
342 } 346 }
343 /* 347 /*
344 * we should have flushed and now we're still saving 348 * we should have flushed and now we're still saving
345 * so there is no need to flush 349 * so there is no need to flush
346 */ 350 */
347 if (m_syncing ) { 351 if (m_syncing ) {
348 e->accept(); 352 e->accept();
349 return; 353 return;
350 } 354 }
351 bool quit = false; 355 bool quit = false;
352 if ( m_todoMgr.saveAll() ){ 356 if ( m_todoMgr.saveAll() ){
353 qWarning("saved"); 357 qWarning("saved");
354 quit = true; 358 quit = true;
355 }else { 359 }else {
356 if ( QMessageBox::critical( this, QWidget::tr("Out of space"), 360 if ( QMessageBox::critical( this, QWidget::tr("Out of space"),
357 QWidget::tr("Todo was unable\n" 361 QWidget::tr("Todo was unable\n"
358 "to save your changes.\n" 362 "to save your changes.\n"
359 "Free up some space\n" 363 "Free up some space\n"
360 "and try again.\n" 364 "and try again.\n"
361 "\nQuit Anyway?"), 365 "\nQuit Anyway?"),
362 QMessageBox::Yes|QMessageBox::Escape, 366 QMessageBox::Yes|QMessageBox::Escape,
363 QMessageBox::No|QMessageBox::Default) 367 QMessageBox::No|QMessageBox::Default)
364 != QMessageBox::No ) { 368 != QMessageBox::No ) {
365 e->accept(); 369 e->accept();
366 quit = true; 370 quit = true;
367 }else 371 }else
368 e->ignore(); 372 e->ignore();
369 373
370 } 374 }
371 375
372 if (quit ) { 376 if (quit ) {
373 Config config( "todo" ); 377 Config config( "todo" );
374 config.setGroup( "View" ); 378 config.setGroup( "View" );
375 config.writeEntry( "ShowComplete", showCompleted() ); 379 config.writeEntry( "ShowComplete", showCompleted() );
376 config.writeEntry( "Category", currentCategory() ); 380 config.writeEntry( "Category", currentCategory() );
377 config.writeEntry( "ShowDeadLine", showDeadline()); 381 config.writeEntry( "ShowDeadLine", showDeadline());
378 config.writeEntry( "ShowOverDue", showOverDue() ); 382 config.writeEntry( "ShowOverDue", showOverDue() );
379 config.writeEntry( "ShowQuickTask", showQuickTask() ); 383 config.writeEntry( "ShowQuickTask", showQuickTask() );
380 /* save templates */ 384 /* save templates */
381 templateManager()->save(); 385 templateManager()->save();
382 e->accept(); 386 e->accept();
383 } 387 }
384} 388}
385void MainWindow::populateTemplates() { 389void MainWindow::populateTemplates() {
386 m_template->clear(); 390 m_template->clear();
387 QStringList list = templateManager()->templates(); 391 QStringList list = templateManager()->templates();
388 QStringList::Iterator it; 392 QStringList::Iterator it;
389 for ( it = list.begin(); it != list.end(); ++it ) { 393 for ( it = list.begin(); it != list.end(); ++it ) {
390 m_template->insertItem( (*it) ); 394 m_template->insertItem( (*it) );
391 } 395 }
392} 396}
393/* 397/*
394 * slotNewFromTemplate 398 * slotNewFromTemplate
395 * We use the edit widget to do 399 * We use the edit widget to do
396 * the config but we setUid(-1) 400 * the config but we setUid(-1)
397 * to get a new uid 401 * to get a new uid
398 */ 402 */
399/* 403/*
400 * first we get the name of the template 404 * first we get the name of the template
401 * then we will use the TemplateManager 405 * then we will use the TemplateManager
402 */ 406 */
403void MainWindow::slotNewFromTemplate( int id ) { 407void MainWindow::slotNewFromTemplate( int id ) {
404 QString name = m_template->text( id ); 408 QString name = m_template->text( id );
405 409
406 OTodo event = templateManager()->templateEvent( name ); 410 OTodo event = templateManager()->templateEvent( name );
407 event = currentEditor()->edit(this, 411 event = currentEditor()->edit(this,
408 event ); 412 event );
409 413
410 if ( currentEditor()->accepted() ) { 414 if ( currentEditor()->accepted() ) {
411 /* assign new todo */ 415 /* assign new todo */
412 event.setUid( -1 ); 416 event.setUid( -1 );
413 currentView()->addEvent( event ); 417 currentView()->addEvent( event );
414 m_todoMgr.add( event ); 418 m_todoMgr.add( event );
415 419
416 populateCategories(); 420 populateCategories();
417 } 421 }
418} 422}
419void MainWindow::slotNew() { 423void MainWindow::slotNew() {
420 create(); 424 create();
421} 425}
422void MainWindow::slotDuplicate() { 426void MainWindow::slotDuplicate() {
423 if(m_syncing) { 427 if(m_syncing) {
424 QMessageBox::warning(this, QWidget::tr("Todo"), 428 QMessageBox::warning(this, QWidget::tr("Todo"),
425 QWidget::tr("Can not edit data, currently syncing")); 429 QWidget::tr("Can not edit data, currently syncing"));
426 return; 430 return;
427 } 431 }
428 OTodo ev = m_todoMgr.event( currentView()->current() ); 432 OTodo ev = m_todoMgr.event( currentView()->current() );
429 /* let's generate a new uid */ 433 /* let's generate a new uid */
430 ev.setUid(-1); 434 ev.setUid(-1);