author | zecke <zecke> | 2003-10-07 12:55:16 (UTC) |
---|---|---|
committer | zecke <zecke> | 2003-10-07 12:55:16 (UTC) |
commit | 898d453b417e561cea25f6b7578814d31cec6e97 (patch) (unidiff) | |
tree | 92ba0e55f17abcaa7b7883410c8850e59e54f516 | |
parent | e65d5c86b5fff521dfb94282a96606546bad9585 (diff) | |
download | opie-898d453b417e561cea25f6b7578814d31cec6e97.zip opie-898d453b417e561cea25f6b7578814d31cec6e97.tar.gz opie-898d453b417e561cea25f6b7578814d31cec6e97.tar.bz2 |
If you decide to close the mainwindow and have say editor and views open as well
call closeAllWindows() after all events are dispatched
-rw-r--r-- | core/pim/todo/mainwindow.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp index ad7899f..7f40645 100644 --- a/core/pim/todo/mainwindow.cpp +++ b/core/pim/todo/mainwindow.cpp | |||
@@ -28,769 +28,769 @@ | |||
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 <qpushbutton.h> | 35 | #include <qpushbutton.h> |
36 | #include <qwidgetstack.h> | 36 | #include <qwidgetstack.h> |
37 | #include <qaction.h> | 37 | #include <qaction.h> |
38 | #include <qtimer.h> | 38 | #include <qtimer.h> |
39 | #include <qvbox.h> | 39 | #include <qvbox.h> |
40 | #include <qlayout.h> | 40 | #include <qlayout.h> |
41 | #include <qlineedit.h> | 41 | #include <qlineedit.h> |
42 | #include <qwhatsthis.h> | 42 | #include <qwhatsthis.h> |
43 | 43 | ||
44 | #include <qpe/applnk.h> | 44 | #include <qpe/applnk.h> |
45 | #include <qpe/config.h> | 45 | #include <qpe/config.h> |
46 | #include <qpe/ir.h> | 46 | #include <qpe/ir.h> |
47 | #include <qpe/resource.h> | 47 | #include <qpe/resource.h> |
48 | #include <qpe/qpemessagebox.h> | 48 | #include <qpe/qpemessagebox.h> |
49 | #include <qpe/alarmserver.h> | 49 | #include <qpe/alarmserver.h> |
50 | #include <qpe/timestring.h> | 50 | #include <qpe/timestring.h> |
51 | #include <qpe/qpeapplication.h> | 51 | #include <qpe/qpeapplication.h> |
52 | 52 | ||
53 | #include <opie/orecur.h> | 53 | #include <opie/orecur.h> |
54 | #include <opie/opimnotifymanager.h> | 54 | #include <opie/opimnotifymanager.h> |
55 | #include <opie/otodoaccessvcal.h> | 55 | #include <opie/otodoaccessvcal.h> |
56 | #include <opie/owidgetstack.h> | 56 | #include <opie/owidgetstack.h> |
57 | 57 | ||
58 | #include <opie/oapplicationfactory.h> | 58 | #include <opie/oapplicationfactory.h> |
59 | 59 | ||
60 | #include "quickeditimpl.h" | 60 | #include "quickeditimpl.h" |
61 | #include "todotemplatemanager.h" | 61 | #include "todotemplatemanager.h" |
62 | #include "templateeditor.h" | 62 | #include "templateeditor.h" |
63 | #include "tableview.h" | 63 | #include "tableview.h" |
64 | 64 | ||
65 | #include "textviewshow.h" | 65 | #include "textviewshow.h" |
66 | #include "todoeditor.h" | 66 | #include "todoeditor.h" |
67 | #include "mainwindow.h" | 67 | #include "mainwindow.h" |
68 | 68 | ||
69 | OPIE_EXPORT_APP( OApplicationFactory<Todo::MainWindow> ) | 69 | OPIE_EXPORT_APP( OApplicationFactory<Todo::MainWindow> ) |
70 | 70 | ||
71 | using namespace Todo; | 71 | using namespace Todo; |
72 | 72 | ||
73 | MainWindow::MainWindow( QWidget* parent, | 73 | MainWindow::MainWindow( QWidget* parent, |
74 | const char* name, WFlags ) | 74 | const char* name, WFlags ) |
75 | : OPimMainWindow( "Todolist", parent, name, WType_TopLevel | WStyle_ContextHelp ) | 75 | : OPimMainWindow( "Todolist", parent, name, WType_TopLevel | WStyle_ContextHelp ) |
76 | { | 76 | { |
77 | if (!name) | 77 | if (!name) |
78 | setName("todo window"); | 78 | setName("todo window"); |
79 | 79 | ||
80 | m_syncing = false; | 80 | m_syncing = false; |
81 | m_showing = false; | 81 | m_showing = false; |
82 | m_counter = 0; | 82 | m_counter = 0; |
83 | m_tempManager = new TemplateManager(); | 83 | m_tempManager = new TemplateManager(); |
84 | m_tempManager->load(); | 84 | m_tempManager->load(); |
85 | 85 | ||
86 | initUI(); | 86 | initUI(); |
87 | initConfig(); | 87 | initConfig(); |
88 | initViews(); | 88 | initViews(); |
89 | initActions(); | 89 | initActions(); |
90 | initEditor(); | 90 | initEditor(); |
91 | initShow(); | 91 | initShow(); |
92 | initTemplate(); | 92 | initTemplate(); |
93 | 93 | ||
94 | populateTemplates(); | 94 | populateTemplates(); |
95 | raiseCurrentView(); | 95 | raiseCurrentView(); |
96 | QTimer::singleShot(0, this, SLOT(populateCategories() ) ); | 96 | QTimer::singleShot(0, this, SLOT(populateCategories() ) ); |
97 | } | 97 | } |
98 | void MainWindow::initTemplate() { | 98 | void MainWindow::initTemplate() { |
99 | m_curTempEd = new TemplateEditor( this, templateManager() ); | 99 | m_curTempEd = new TemplateEditor( this, templateManager() ); |
100 | } | 100 | } |
101 | void MainWindow::initActions() { | 101 | void MainWindow::initActions() { |
102 | 102 | ||
103 | // Data menu | 103 | // Data menu |
104 | m_edit->insertItem(QWidget::tr("New from template"), m_template, | 104 | m_edit->insertItem(QWidget::tr("New from template"), m_template, |
105 | -1, 0 ); | 105 | -1, 0 ); |
106 | 106 | ||
107 | QAction* a = new QAction( QWidget::tr("New Task" ), Resource::loadPixmap( "new" ), | 107 | QAction* a = new QAction( QWidget::tr("New Task" ), Resource::loadPixmap( "new" ), |
108 | QString::null, 0, this, 0 ); | 108 | QString::null, 0, this, 0 ); |
109 | connect(a, SIGNAL( activated() ), | 109 | connect(a, SIGNAL( activated() ), |
110 | this, SLOT( slotNew() ) ); | 110 | this, SLOT( slotNew() ) ); |
111 | a->setWhatsThis( QWidget::tr( "Click here to create a new task." ) ); | 111 | a->setWhatsThis( QWidget::tr( "Click here to create a new task." ) ); |
112 | a->addTo(m_tool ); | 112 | a->addTo(m_tool ); |
113 | a->addTo(m_edit ); | 113 | a->addTo(m_edit ); |
114 | 114 | ||
115 | a = new QAction( QWidget::tr("Edit Task"), Resource::loadIconSet( "edit" ), | 115 | a = new QAction( QWidget::tr("Edit Task"), Resource::loadIconSet( "edit" ), |
116 | QString::null, 0, this, 0 ); | 116 | QString::null, 0, this, 0 ); |
117 | connect(a, SIGNAL(activated() ), | 117 | connect(a, SIGNAL(activated() ), |
118 | this, SLOT( slotEdit() ) ); | 118 | this, SLOT( slotEdit() ) ); |
119 | a->setWhatsThis( QWidget::tr( "Click here to modify the current task." ) ); | 119 | a->setWhatsThis( QWidget::tr( "Click here to modify the current task." ) ); |
120 | a->addTo( m_tool ); | 120 | a->addTo( m_tool ); |
121 | a->addTo( m_edit ); | 121 | a->addTo( m_edit ); |
122 | m_editAction = a; | 122 | m_editAction = a; |
123 | 123 | ||
124 | a = new QAction( QString::null, QWidget::tr("View Task"), 0, this, 0 ); | 124 | a = new QAction( QString::null, QWidget::tr("View Task"), 0, this, 0 ); |
125 | connect(a, SIGNAL( activated() ), | 125 | connect(a, SIGNAL( activated() ), |
126 | this, SLOT( slotShowDetails() ) ); | 126 | this, SLOT( slotShowDetails() ) ); |
127 | a->addTo( m_edit ); | 127 | a->addTo( m_edit ); |
128 | 128 | ||
129 | m_edit->insertSeparator(); | 129 | m_edit->insertSeparator(); |
130 | 130 | ||
131 | a = new QAction( QWidget::tr("Delete..."), Resource::loadIconSet( "trash" ), | 131 | a = new QAction( QWidget::tr("Delete..."), Resource::loadIconSet( "trash" ), |
132 | QString::null, 0, this, 0 ); | 132 | QString::null, 0, this, 0 ); |
133 | connect(a, SIGNAL(activated() ), | 133 | connect(a, SIGNAL(activated() ), |
134 | this, SLOT(slotDelete() ) ); | 134 | this, SLOT(slotDelete() ) ); |
135 | a->setWhatsThis( QWidget::tr( "Click here to remove the current task." ) ); | 135 | a->setWhatsThis( QWidget::tr( "Click here to remove the current task." ) ); |
136 | a->addTo( m_tool ); | 136 | a->addTo( m_tool ); |
137 | a->addTo( m_edit ); | 137 | a->addTo( m_edit ); |
138 | m_deleteAction = a; | 138 | m_deleteAction = a; |
139 | 139 | ||
140 | a = new QAction( QString::null, QWidget::tr("Delete all..."), 0, this, 0 ); | 140 | a = new QAction( QString::null, QWidget::tr("Delete all..."), 0, this, 0 ); |
141 | connect(a, SIGNAL( activated() ), | 141 | connect(a, SIGNAL( activated() ), |
142 | this, SLOT( slotDeleteAll() ) ); | 142 | this, SLOT( slotDeleteAll() ) ); |
143 | a->addTo(m_edit ); | 143 | a->addTo(m_edit ); |
144 | m_deleteAllAction = a; | 144 | m_deleteAllAction = a; |
145 | 145 | ||
146 | a = new QAction( QString::null, QWidget::tr("Delete completed"), | 146 | a = new QAction( QString::null, QWidget::tr("Delete completed"), |
147 | 0, this, 0 ); | 147 | 0, this, 0 ); |
148 | connect(a, SIGNAL( activated() ), | 148 | connect(a, SIGNAL( activated() ), |
149 | this, SLOT( slotDeleteCompleted() ) ); | 149 | this, SLOT( slotDeleteCompleted() ) ); |
150 | a->addTo(m_edit ); | 150 | a->addTo(m_edit ); |
151 | a->setEnabled( TRUE ); | 151 | a->setEnabled( TRUE ); |
152 | m_deleteCompleteAction = a; | 152 | m_deleteCompleteAction = a; |
153 | 153 | ||
154 | m_edit->insertSeparator(); | 154 | m_edit->insertSeparator(); |
155 | 155 | ||
156 | a = new QAction( QString::null, QWidget::tr("Duplicate"), 0, this, 0 ); | 156 | a = new QAction( QString::null, QWidget::tr("Duplicate"), 0, this, 0 ); |
157 | connect(a, SIGNAL( activated() ), | 157 | connect(a, SIGNAL( activated() ), |
158 | this, SLOT( slotDuplicate() ) ); | 158 | this, SLOT( slotDuplicate() ) ); |
159 | a->addTo(m_edit ); | 159 | a->addTo(m_edit ); |
160 | m_duplicateAction = a; | 160 | m_duplicateAction = a; |
161 | 161 | ||
162 | m_edit->insertSeparator(); | 162 | m_edit->insertSeparator(); |
163 | 163 | ||
164 | if ( Ir::supported() ) { | 164 | if ( Ir::supported() ) { |
165 | a = new QAction( QWidget::tr( "Beam" ), Resource::loadPixmap( "beam" ), QString::null, 0, this, 0 ); | 165 | a = new QAction( QWidget::tr( "Beam" ), Resource::loadPixmap( "beam" ), QString::null, 0, this, 0 ); |
166 | connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) ); | 166 | connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) ); |
167 | a->setWhatsThis( QWidget::tr( "Click here to send the current task to another device." ) ); | 167 | a->setWhatsThis( QWidget::tr( "Click here to send the current task to another device." ) ); |
168 | a->addTo( m_edit ); | 168 | a->addTo( m_edit ); |
169 | a->addTo( m_tool ); | 169 | a->addTo( m_tool ); |
170 | } | 170 | } |
171 | 171 | ||
172 | #if 0 | 172 | #if 0 |
173 | // Options menu | 173 | // Options menu |
174 | a = new QAction( QWidget::tr("Find"), Resource::loadIconSet( "mag" ), | 174 | a = new QAction( QWidget::tr("Find"), Resource::loadIconSet( "mag" ), |
175 | QString::null, 0, this, 0 ); | 175 | QString::null, 0, this, 0 ); |
176 | connect(a, SIGNAL( activated() ), this, SLOT( slotFind() ) ); | 176 | connect(a, SIGNAL( activated() ), this, SLOT( slotFind() ) ); |
177 | a->addTo( m_options ); | 177 | a->addTo( m_options ); |
178 | m_findAction = a; | 178 | m_findAction = a; |
179 | 179 | ||
180 | 180 | ||
181 | m_options->insertSeparator(); | 181 | m_options->insertSeparator(); |
182 | #endif | 182 | #endif |
183 | 183 | ||
184 | m_completedAction = new QAction( QString::null, QWidget::tr("Show completed tasks"), | 184 | m_completedAction = new QAction( QString::null, QWidget::tr("Show completed tasks"), |
185 | 0, this, 0, TRUE ); | 185 | 0, this, 0, TRUE ); |
186 | m_completedAction->addTo( m_options ); | 186 | m_completedAction->addTo( m_options ); |
187 | m_completedAction->setOn( showCompleted() ); | 187 | m_completedAction->setOn( showCompleted() ); |
188 | connect(m_completedAction, SIGNAL( toggled(bool) ), this, SLOT(slotShowCompleted(bool) ) ); | 188 | connect(m_completedAction, SIGNAL( toggled(bool) ), this, SLOT(slotShowCompleted(bool) ) ); |
189 | 189 | ||
190 | a = new QAction( QString::null, QWidget::tr("Show only over-due tasks"), | 190 | a = new QAction( QString::null, QWidget::tr("Show only over-due tasks"), |
191 | 0, this, 0, TRUE ); | 191 | 0, this, 0, TRUE ); |
192 | a->addTo( m_options ); | 192 | a->addTo( m_options ); |
193 | a->setOn( showOverDue() ); | 193 | a->setOn( showOverDue() ); |
194 | connect(a, SIGNAL(toggled(bool)), this, SLOT(slotShowDue(bool) ) ); | 194 | connect(a, SIGNAL(toggled(bool)), this, SLOT(slotShowDue(bool) ) ); |
195 | 195 | ||
196 | m_showDeadLineAction = new QAction( QString::null, QWidget::tr("Show task deadlines"), | 196 | m_showDeadLineAction = new QAction( QString::null, QWidget::tr("Show task deadlines"), |
197 | 0, this, 0, TRUE ); | 197 | 0, this, 0, TRUE ); |
198 | m_showDeadLineAction->addTo( m_options ); | 198 | m_showDeadLineAction->addTo( m_options ); |
199 | m_showDeadLineAction->setOn( showDeadline() ); | 199 | m_showDeadLineAction->setOn( showDeadline() ); |
200 | connect(m_showDeadLineAction, SIGNAL(toggled(bool) ), this, SLOT( slotShowDeadLine( bool ) ) ); | 200 | connect(m_showDeadLineAction, SIGNAL(toggled(bool) ), this, SLOT( slotShowDeadLine( bool ) ) ); |
201 | 201 | ||
202 | m_showQuickTaskAction = new QAction( QString::null, QWidget::tr("Show quick task bar"), | 202 | m_showQuickTaskAction = new QAction( QString::null, QWidget::tr("Show quick task bar"), |
203 | 0, this, 0, TRUE ); | 203 | 0, this, 0, TRUE ); |
204 | m_showQuickTaskAction->addTo( m_options ); | 204 | m_showQuickTaskAction->addTo( m_options ); |
205 | m_showQuickTaskAction->setOn( showQuickTask() ); | 205 | m_showQuickTaskAction->setOn( showQuickTask() ); |
206 | connect(m_showQuickTaskAction, SIGNAL( toggled(bool) ), this, SLOT(slotShowQuickTask(bool) ) ); | 206 | connect(m_showQuickTaskAction, SIGNAL( toggled(bool) ), this, SLOT(slotShowQuickTask(bool) ) ); |
207 | 207 | ||
208 | m_options->insertSeparator(); | 208 | m_options->insertSeparator(); |
209 | 209 | ||
210 | m_bar->insertItem( QWidget::tr("Data") ,m_edit ); | 210 | m_bar->insertItem( QWidget::tr("Data") ,m_edit ); |
211 | m_bar->insertItem( QWidget::tr("Category"), m_catMenu ); | 211 | m_bar->insertItem( QWidget::tr("Category"), m_catMenu ); |
212 | m_bar->insertItem( QWidget::tr("Options"), m_options ); | 212 | m_bar->insertItem( QWidget::tr("Options"), m_options ); |
213 | 213 | ||
214 | m_curQuick = new QuickEditImpl( this, m_quicktask ); | 214 | m_curQuick = new QuickEditImpl( this, m_quicktask ); |
215 | addToolBar( (QPEToolBar *)m_curQuick->widget(), QWidget::tr( "QuickEdit" ), QMainWindow::Top, TRUE ); | 215 | addToolBar( (QPEToolBar *)m_curQuick->widget(), QWidget::tr( "QuickEdit" ), QMainWindow::Top, TRUE ); |
216 | m_curQuick->signal()->connect( this, SLOT(slotQuickEntered() ) ); | 216 | m_curQuick->signal()->connect( this, SLOT(slotQuickEntered() ) ); |
217 | 217 | ||
218 | } | 218 | } |
219 | /* m_curCat from Config */ | 219 | /* m_curCat from Config */ |
220 | void MainWindow::initConfig() { | 220 | void MainWindow::initConfig() { |
221 | Config config( "todo" ); | 221 | Config config( "todo" ); |
222 | config.setGroup( "View" ); | 222 | config.setGroup( "View" ); |
223 | m_completed = config.readBoolEntry( "ShowComplete", TRUE ); | 223 | m_completed = config.readBoolEntry( "ShowComplete", TRUE ); |
224 | m_curCat = config.readEntry( "Category", QString::null ); | 224 | m_curCat = config.readEntry( "Category", QString::null ); |
225 | m_deadline = config.readBoolEntry( "ShowDeadLine", TRUE); | 225 | m_deadline = config.readBoolEntry( "ShowDeadLine", TRUE); |
226 | m_overdue = config.readBoolEntry("ShowOverDue", FALSE ); | 226 | m_overdue = config.readBoolEntry("ShowOverDue", FALSE ); |
227 | m_quicktask = config.readBoolEntry("ShowQuickTask", TRUE); | 227 | m_quicktask = config.readBoolEntry("ShowQuickTask", TRUE); |
228 | } | 228 | } |
229 | void MainWindow::initUI() { | 229 | void MainWindow::initUI() { |
230 | 230 | ||
231 | m_stack = new OWidgetStack(this, "main stack"); | 231 | m_stack = new OWidgetStack(this, "main stack"); |
232 | 232 | ||
233 | setCentralWidget( m_stack ); | 233 | setCentralWidget( m_stack ); |
234 | 234 | ||
235 | setToolBarsMovable( FALSE ); | 235 | setToolBarsMovable( FALSE ); |
236 | 236 | ||
237 | QToolBar *menubarholder = new QToolBar( this ); | 237 | QToolBar *menubarholder = new QToolBar( this ); |
238 | menubarholder->setHorizontalStretchable( TRUE ); | 238 | menubarholder->setHorizontalStretchable( TRUE ); |
239 | m_bar = new QMenuBar( menubarholder ); | 239 | m_bar = new QMenuBar( menubarholder ); |
240 | 240 | ||
241 | m_tool = new QToolBar( this ); | 241 | m_tool = new QToolBar( this ); |
242 | 242 | ||
243 | /** QPopupMenu */ | 243 | /** QPopupMenu */ |
244 | m_edit = new QPopupMenu( this ); | 244 | m_edit = new QPopupMenu( this ); |
245 | m_options = new QPopupMenu( this ); | 245 | m_options = new QPopupMenu( this ); |
246 | m_catMenu = new QPopupMenu( this ); | 246 | m_catMenu = new QPopupMenu( this ); |
247 | m_template = new QPopupMenu( this ); | 247 | m_template = new QPopupMenu( this ); |
248 | 248 | ||
249 | m_catMenu->setCheckable( TRUE ); | 249 | m_catMenu->setCheckable( TRUE ); |
250 | m_template->setCheckable( TRUE ); | 250 | m_template->setCheckable( TRUE ); |
251 | 251 | ||
252 | connect(m_catMenu, SIGNAL(activated(int) ), | 252 | connect(m_catMenu, SIGNAL(activated(int) ), |
253 | this, SLOT(setCategory(int) ) ); | 253 | this, SLOT(setCategory(int) ) ); |
254 | connect(m_template, SIGNAL(activated(int) ), | 254 | connect(m_template, SIGNAL(activated(int) ), |
255 | this, SLOT(slotNewFromTemplate(int) ) ); | 255 | this, SLOT(slotNewFromTemplate(int) ) ); |
256 | } | 256 | } |
257 | void MainWindow::initViews() { | 257 | void MainWindow::initViews() { |
258 | 258 | ||
259 | TableView* tableView = new TableView( this, m_stack ); | 259 | TableView* tableView = new TableView( this, m_stack ); |
260 | 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." ) ); | 260 | 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." ) ); |
261 | m_stack->addWidget( tableView, m_counter++ ); | 261 | m_stack->addWidget( tableView, m_counter++ ); |
262 | m_views.append( tableView ); | 262 | m_views.append( tableView ); |
263 | m_curView = tableView; | 263 | m_curView = tableView; |
264 | connectBase( tableView ); | 264 | connectBase( tableView ); |
265 | /* add QString type + QString configname to | 265 | /* add QString type + QString configname to |
266 | * the View menu | 266 | * the View menu |
267 | * and subdirs for multiple views | 267 | * and subdirs for multiple views |
268 | */ | 268 | */ |
269 | } | 269 | } |
270 | void MainWindow::initEditor() { | 270 | void MainWindow::initEditor() { |
271 | m_curEdit = new Editor(); | 271 | m_curEdit = new Editor(); |
272 | } | 272 | } |
273 | void MainWindow::initShow() { | 273 | void MainWindow::initShow() { |
274 | m_curShow = new TextViewShow(this, this); | 274 | m_curShow = new TextViewShow(this, this); |
275 | m_stack->addWidget( m_curShow->widget() , m_counter++ ); | 275 | m_stack->addWidget( m_curShow->widget() , m_counter++ ); |
276 | } | 276 | } |
277 | MainWindow::~MainWindow() { | 277 | MainWindow::~MainWindow() { |
278 | delete templateManager(); | 278 | delete templateManager(); |
279 | } | 279 | } |
280 | void MainWindow::connectBase( ViewBase* ) { | 280 | void MainWindow::connectBase( ViewBase* ) { |
281 | // once templates and signals mix we'll use it again | 281 | // once templates and signals mix we'll use it again |
282 | } | 282 | } |
283 | QPopupMenu* MainWindow::contextMenu( int , bool recur ) { | 283 | QPopupMenu* MainWindow::contextMenu( int , bool recur ) { |
284 | QPopupMenu* menu = new QPopupMenu(); | 284 | QPopupMenu* menu = new QPopupMenu(); |
285 | 285 | ||
286 | m_editAction->addTo( menu ); | 286 | m_editAction->addTo( menu ); |
287 | m_deleteAction->addTo( menu ); | 287 | m_deleteAction->addTo( menu ); |
288 | m_duplicateAction->addTo( menu ); | 288 | m_duplicateAction->addTo( menu ); |
289 | 289 | ||
290 | menu->insertSeparator(); | 290 | menu->insertSeparator(); |
291 | 291 | ||
292 | /* | 292 | /* |
293 | * if this event recurs we allow | 293 | * if this event recurs we allow |
294 | * to detach it. | 294 | * to detach it. |
295 | * remove all | 295 | * remove all |
296 | */ | 296 | */ |
297 | if ( recur ) { | 297 | if ( recur ) { |
298 | ; // FIXME | 298 | ; // FIXME |
299 | } | 299 | } |
300 | 300 | ||
301 | return menu; | 301 | return menu; |
302 | } | 302 | } |
303 | QPopupMenu* MainWindow::options() { | 303 | QPopupMenu* MainWindow::options() { |
304 | qWarning("Options"); | 304 | qWarning("Options"); |
305 | return m_options; | 305 | return m_options; |
306 | } | 306 | } |
307 | QPopupMenu* MainWindow::edit() { | 307 | QPopupMenu* MainWindow::edit() { |
308 | return m_edit; | 308 | return m_edit; |
309 | } | 309 | } |
310 | QToolBar* MainWindow::toolbar() { | 310 | QToolBar* MainWindow::toolbar() { |
311 | return m_tool; | 311 | return m_tool; |
312 | } | 312 | } |
313 | OTodoAccess::List MainWindow::list()const { | 313 | OTodoAccess::List MainWindow::list()const { |
314 | return m_todoMgr.list(); | 314 | return m_todoMgr.list(); |
315 | } | 315 | } |
316 | OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder ) { | 316 | OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder ) { |
317 | int cat = 0; | 317 | int cat = 0; |
318 | if ( m_curCat != QWidget::tr("All Categories") ) | 318 | if ( m_curCat != QWidget::tr("All Categories") ) |
319 | cat = currentCatId(); | 319 | cat = currentCatId(); |
320 | if ( m_curCat == QWidget::tr("Unfiled") ) | 320 | if ( m_curCat == QWidget::tr("Unfiled") ) |
321 | cat = -1; | 321 | cat = -1; |
322 | 322 | ||
323 | qWarning(" Category %d %s", cat, m_curCat.latin1() ); | 323 | qWarning(" Category %d %s", cat, m_curCat.latin1() ); |
324 | 324 | ||
325 | int filter = 1; | 325 | int filter = 1; |
326 | 326 | ||
327 | if (!m_completed ) | 327 | if (!m_completed ) |
328 | filter |= 4; | 328 | filter |= 4; |
329 | if (m_overdue) | 329 | if (m_overdue) |
330 | filter |= 2; | 330 | filter |= 2; |
331 | 331 | ||
332 | return m_todoMgr.sorted( asc, sortOrder, filter, cat ); | 332 | return m_todoMgr.sorted( asc, sortOrder, filter, cat ); |
333 | } | 333 | } |
334 | OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder, int addFilter) { | 334 | OTodoAccess::List MainWindow::sorted( bool asc, int sortOrder, int addFilter) { |
335 | int cat = 0; | 335 | int cat = 0; |
336 | if ( m_curCat != QWidget::tr("All Categories") ) | 336 | if ( m_curCat != QWidget::tr("All Categories") ) |
337 | cat = currentCatId(); | 337 | cat = currentCatId(); |
338 | 338 | ||
339 | if ( m_curCat == QWidget::tr("Unfiled") ) | 339 | if ( m_curCat == QWidget::tr("Unfiled") ) |
340 | cat = -1; | 340 | cat = -1; |
341 | 341 | ||
342 | return m_todoMgr.sorted(asc, sortOrder, addFilter, cat ); | 342 | return m_todoMgr.sorted(asc, sortOrder, addFilter, cat ); |
343 | } | 343 | } |
344 | OTodo MainWindow::event( int uid ) { | 344 | OTodo MainWindow::event( int uid ) { |
345 | return m_todoMgr.event( uid ); | 345 | return m_todoMgr.event( uid ); |
346 | } | 346 | } |
347 | bool MainWindow::isSyncing()const { | 347 | bool MainWindow::isSyncing()const { |
348 | return m_syncing; | 348 | return m_syncing; |
349 | } | 349 | } |
350 | TemplateManager* MainWindow::templateManager() { | 350 | TemplateManager* MainWindow::templateManager() { |
351 | return m_tempManager; | 351 | return m_tempManager; |
352 | } | 352 | } |
353 | Editor* MainWindow::currentEditor() { | 353 | Editor* MainWindow::currentEditor() { |
354 | return m_curEdit; | 354 | return m_curEdit; |
355 | } | 355 | } |
356 | TodoShow* MainWindow::currentShow() { | 356 | TodoShow* MainWindow::currentShow() { |
357 | return m_curShow; | 357 | return m_curShow; |
358 | } | 358 | } |
359 | void MainWindow::slotReload() { | 359 | void MainWindow::slotReload() { |
360 | m_syncing = FALSE; | 360 | m_syncing = FALSE; |
361 | m_todoMgr.reload(); | 361 | m_todoMgr.reload(); |
362 | currentView()->updateView( ); | 362 | currentView()->updateView( ); |
363 | raiseCurrentView(); | 363 | raiseCurrentView(); |
364 | } | 364 | } |
365 | void MainWindow::closeEvent( QCloseEvent* e ) { | 365 | void MainWindow::closeEvent( QCloseEvent* e ) { |
366 | if (m_stack->visibleWidget() == currentShow()->widget() ) { | 366 | if (m_stack->visibleWidget() == currentShow()->widget() ) { |
367 | m_showing = false; | 367 | m_showing = false; |
368 | raiseCurrentView(); | 368 | raiseCurrentView(); |
369 | e->ignore(); | 369 | e->ignore(); |
370 | return; | 370 | return; |
371 | } | 371 | } |
372 | /* | 372 | /* |
373 | * we should have flushed and now we're still saving | 373 | * we should have flushed and now we're still saving |
374 | * so there is no need to flush | 374 | * so there is no need to flush |
375 | */ | 375 | */ |
376 | if (m_syncing ) { | 376 | if (m_syncing ) { |
377 | e->accept(); | 377 | e->accept(); |
378 | return; | 378 | return; |
379 | } | 379 | } |
380 | bool quit = false; | 380 | bool quit = false; |
381 | if ( m_todoMgr.saveAll() ){ | 381 | if ( m_todoMgr.saveAll() ){ |
382 | qWarning("saved"); | 382 | qWarning("saved"); |
383 | quit = true; | 383 | quit = true; |
384 | }else { | 384 | }else { |
385 | if ( QMessageBox::critical( this, QWidget::tr("Out of space"), | 385 | if ( QMessageBox::critical( this, QWidget::tr("Out of space"), |
386 | QWidget::tr("Todo was unable\n" | 386 | QWidget::tr("Todo was unable\n" |
387 | "to save your changes.\n" | 387 | "to save your changes.\n" |
388 | "Free up some space\n" | 388 | "Free up some space\n" |
389 | "and try again.\n" | 389 | "and try again.\n" |
390 | "\nQuit Anyway?"), | 390 | "\nQuit Anyway?"), |
391 | QMessageBox::Yes|QMessageBox::Escape, | 391 | QMessageBox::Yes|QMessageBox::Escape, |
392 | QMessageBox::No|QMessageBox::Default) | 392 | QMessageBox::No|QMessageBox::Default) |
393 | != QMessageBox::No ) { | 393 | != QMessageBox::No ) { |
394 | e->accept(); | 394 | e->accept(); |
395 | quit = true; | 395 | quit = true; |
396 | }else | 396 | }else |
397 | e->ignore(); | 397 | e->ignore(); |
398 | 398 | ||
399 | } | 399 | } |
400 | 400 | ||
401 | if (quit ) { | 401 | if (quit ) { |
402 | Config config( "todo" ); | 402 | Config config( "todo" ); |
403 | config.setGroup( "View" ); | 403 | config.setGroup( "View" ); |
404 | config.writeEntry( "ShowComplete", showCompleted() ); | 404 | config.writeEntry( "ShowComplete", showCompleted() ); |
405 | config.writeEntry( "Category", currentCategory() ); | 405 | config.writeEntry( "Category", currentCategory() ); |
406 | config.writeEntry( "ShowDeadLine", showDeadline()); | 406 | config.writeEntry( "ShowDeadLine", showDeadline()); |
407 | config.writeEntry( "ShowOverDue", showOverDue() ); | 407 | config.writeEntry( "ShowOverDue", showOverDue() ); |
408 | config.writeEntry( "ShowQuickTask", showQuickTask() ); | 408 | config.writeEntry( "ShowQuickTask", showQuickTask() ); |
409 | /* save templates */ | 409 | /* save templates */ |
410 | templateManager()->save(); | 410 | templateManager()->save(); |
411 | e->accept(); | 411 | e->accept(); |
412 | qApp->quit(); | 412 | QTimer::singleShot(0, qApp, SLOT(closeAllWindows()) ); |
413 | } | 413 | } |
414 | } | 414 | } |
415 | void MainWindow::populateTemplates() { | 415 | void MainWindow::populateTemplates() { |
416 | m_template->clear(); | 416 | m_template->clear(); |
417 | QStringList list = templateManager()->templates(); | 417 | QStringList list = templateManager()->templates(); |
418 | QStringList::Iterator it; | 418 | QStringList::Iterator it; |
419 | for ( it = list.begin(); it != list.end(); ++it ) { | 419 | for ( it = list.begin(); it != list.end(); ++it ) { |
420 | m_template->insertItem( (*it) ); | 420 | m_template->insertItem( (*it) ); |
421 | } | 421 | } |
422 | } | 422 | } |
423 | /* | 423 | /* |
424 | * slotNewFromTemplate | 424 | * slotNewFromTemplate |
425 | * We use the edit widget to do | 425 | * We use the edit widget to do |
426 | * the config but we setUid(1) | 426 | * the config but we setUid(1) |
427 | * to get a new uid | 427 | * to get a new uid |
428 | */ | 428 | */ |
429 | /* | 429 | /* |
430 | * first we get the name of the template | 430 | * first we get the name of the template |
431 | * then we will use the TemplateManager | 431 | * then we will use the TemplateManager |
432 | */ | 432 | */ |
433 | void MainWindow::slotNewFromTemplate( int id ) { | 433 | void MainWindow::slotNewFromTemplate( int id ) { |
434 | QString name = m_template->text( id ); | 434 | QString name = m_template->text( id ); |
435 | 435 | ||
436 | OTodo event = templateManager()->templateEvent( name ); | 436 | OTodo event = templateManager()->templateEvent( name ); |
437 | event = currentEditor()->edit(this, | 437 | event = currentEditor()->edit(this, |
438 | event ); | 438 | event ); |
439 | 439 | ||
440 | if ( currentEditor()->accepted() ) { | 440 | if ( currentEditor()->accepted() ) { |
441 | /* assign new todo */ | 441 | /* assign new todo */ |
442 | event.setUid( 1 ); | 442 | event.setUid( 1 ); |
443 | handleAlarms( OTodo(), event ); | 443 | handleAlarms( OTodo(), event ); |
444 | m_todoMgr.add( event ); | 444 | m_todoMgr.add( event ); |
445 | currentView()->addEvent( event ); | 445 | currentView()->addEvent( event ); |
446 | 446 | ||
447 | populateCategories(); | 447 | populateCategories(); |
448 | } | 448 | } |
449 | raiseCurrentView(); | 449 | raiseCurrentView(); |
450 | } | 450 | } |
451 | void MainWindow::slotNew() { | 451 | void MainWindow::slotNew() { |
452 | create(); | 452 | create(); |
453 | } | 453 | } |
454 | void MainWindow::slotDuplicate() { | 454 | void MainWindow::slotDuplicate() { |
455 | if(m_syncing) { | 455 | if(m_syncing) { |
456 | QMessageBox::warning(this, QWidget::tr("Todo"), | 456 | QMessageBox::warning(this, QWidget::tr("Todo"), |
457 | QWidget::tr("Data can not be edited, currently syncing")); | 457 | QWidget::tr("Data can not be edited, currently syncing")); |
458 | return; | 458 | return; |
459 | } | 459 | } |
460 | OTodo ev = m_todoMgr.event( currentView()->current() ); | 460 | OTodo ev = m_todoMgr.event( currentView()->current() ); |
461 | /* let's generate a new uid */ | 461 | /* let's generate a new uid */ |
462 | ev.setUid(1); | 462 | ev.setUid(1); |
463 | m_todoMgr.add( ev ); | 463 | m_todoMgr.add( ev ); |
464 | 464 | ||
465 | currentView()->addEvent( ev ); | 465 | currentView()->addEvent( ev ); |
466 | raiseCurrentView(); | 466 | raiseCurrentView(); |
467 | } | 467 | } |
468 | void MainWindow::slotDelete() { | 468 | void MainWindow::slotDelete() { |
469 | if (!currentView()->current() ) | 469 | if (!currentView()->current() ) |
470 | return; | 470 | return; |
471 | 471 | ||
472 | if(m_syncing) { | 472 | if(m_syncing) { |
473 | QMessageBox::warning(this, QWidget::tr("Todo"), | 473 | QMessageBox::warning(this, QWidget::tr("Todo"), |
474 | QWidget::tr("Data can not be edited, currently syncing")); | 474 | QWidget::tr("Data can not be edited, currently syncing")); |
475 | return; | 475 | return; |
476 | } | 476 | } |
477 | QString strName = currentView()->currentRepresentation(); | 477 | QString strName = currentView()->currentRepresentation(); |
478 | if (!QPEMessageBox::confirmDelete(this, QWidget::tr("Todo"), strName ) ) | 478 | if (!QPEMessageBox::confirmDelete(this, QWidget::tr("Todo"), strName ) ) |
479 | return; | 479 | return; |
480 | 480 | ||
481 | handleAlarms( m_todoMgr.event( currentView()->current() ), OTodo() ); | 481 | handleAlarms( m_todoMgr.event( currentView()->current() ), OTodo() ); |
482 | m_todoMgr.remove( currentView()->current() ); | 482 | m_todoMgr.remove( currentView()->current() ); |
483 | currentView()->removeEvent( currentView()->current() ); | 483 | currentView()->removeEvent( currentView()->current() ); |
484 | raiseCurrentView(); | 484 | raiseCurrentView(); |
485 | } | 485 | } |
486 | void MainWindow::slotDelete(int uid ) { | 486 | void MainWindow::slotDelete(int uid ) { |
487 | if( uid == 0 ) return; | 487 | if( uid == 0 ) return; |
488 | if(m_syncing) { | 488 | if(m_syncing) { |
489 | QMessageBox::warning(this, QWidget::tr("Todo"), | 489 | QMessageBox::warning(this, QWidget::tr("Todo"), |
490 | QWidget::tr("Data can not be edited, currently syncing")); | 490 | QWidget::tr("Data can not be edited, currently syncing")); |
491 | return; | 491 | return; |
492 | } | 492 | } |
493 | OTodo to = m_todoMgr.event(uid); | 493 | OTodo to = m_todoMgr.event(uid); |
494 | if (!QPEMessageBox::confirmDelete(this, QWidget::tr("Todo"), to.toShortText() ) ) | 494 | if (!QPEMessageBox::confirmDelete(this, QWidget::tr("Todo"), to.toShortText() ) ) |
495 | return; | 495 | return; |
496 | 496 | ||
497 | handleAlarms(to, OTodo() ); | 497 | handleAlarms(to, OTodo() ); |
498 | m_todoMgr.remove( to.uid() ); | 498 | m_todoMgr.remove( to.uid() ); |
499 | currentView()->removeEvent( to.uid() ); | 499 | currentView()->removeEvent( to.uid() ); |
500 | raiseCurrentView(); | 500 | raiseCurrentView(); |
501 | } | 501 | } |
502 | void MainWindow::slotDeleteAll() { | 502 | void MainWindow::slotDeleteAll() { |
503 | if(m_syncing) { | 503 | if(m_syncing) { |
504 | QMessageBox::warning(this, QWidget::tr("Todo"), | 504 | QMessageBox::warning(this, QWidget::tr("Todo"), |
505 | QWidget::tr("Data can not be edited, currently syncing")); | 505 | QWidget::tr("Data can not be edited, currently syncing")); |
506 | return; | 506 | return; |
507 | } | 507 | } |
508 | 508 | ||
509 | 509 | ||
510 | if ( !QPEMessageBox::confirmDelete( this, QWidget::tr( "Todo" ), QWidget::tr("all tasks?") ) ) | 510 | if ( !QPEMessageBox::confirmDelete( this, QWidget::tr( "Todo" ), QWidget::tr("all tasks?") ) ) |
511 | return; | 511 | return; |
512 | 512 | ||
513 | m_todoMgr.removeAll(); | 513 | m_todoMgr.removeAll(); |
514 | currentView()->clear(); | 514 | currentView()->clear(); |
515 | 515 | ||
516 | raiseCurrentView(); | 516 | raiseCurrentView(); |
517 | } | 517 | } |
518 | void MainWindow::slotDeleteCompleted() { | 518 | void MainWindow::slotDeleteCompleted() { |
519 | if(m_syncing) { | 519 | if(m_syncing) { |
520 | QMessageBox::warning(this, QWidget::tr("Todo"), | 520 | QMessageBox::warning(this, QWidget::tr("Todo"), |
521 | QWidget::tr("Data can not be edited, currently syncing")); | 521 | QWidget::tr("Data can not be edited, currently syncing")); |
522 | return; | 522 | return; |
523 | } | 523 | } |
524 | 524 | ||
525 | if ( !QPEMessageBox::confirmDelete( this, QWidget::tr( "Todo" ), QWidget::tr("all completed tasks?") ) ) | 525 | if ( !QPEMessageBox::confirmDelete( this, QWidget::tr( "Todo" ), QWidget::tr("all completed tasks?") ) ) |
526 | return; | 526 | return; |
527 | 527 | ||
528 | 528 | ||
529 | m_todoMgr.removeCompleted(); | 529 | m_todoMgr.removeCompleted(); |
530 | currentView()->updateView( ); | 530 | currentView()->updateView( ); |
531 | } | 531 | } |
532 | void MainWindow::slotFind() { | 532 | void MainWindow::slotFind() { |
533 | 533 | ||
534 | } | 534 | } |
535 | void MainWindow::slotEdit() { | 535 | void MainWindow::slotEdit() { |
536 | slotEdit( currentView()->current() ); | 536 | slotEdit( currentView()->current() ); |
537 | } | 537 | } |
538 | /* | 538 | /* |
539 | * set the category | 539 | * set the category |
540 | */ | 540 | */ |
541 | void MainWindow::setCategory( int c) { | 541 | void MainWindow::setCategory( int c) { |
542 | if ( c <= 0 ) return; | 542 | if ( c <= 0 ) return; |
543 | 543 | ||
544 | 544 | ||
545 | qWarning("Iterating over cats %d", c ); | 545 | qWarning("Iterating over cats %d", c ); |
546 | for ( unsigned int i = 1; i < m_catMenu->count(); i++ ) | 546 | for ( unsigned int i = 1; i < m_catMenu->count(); i++ ) |
547 | m_catMenu->setItemChecked(i, c == (int)i ); | 547 | m_catMenu->setItemChecked(i, c == (int)i ); |
548 | 548 | ||
549 | if (c == 1 ) { | 549 | if (c == 1 ) { |
550 | m_curCat = QString::null; | 550 | m_curCat = QString::null; |
551 | setCaption( QWidget::tr("Todo") + " - " + QWidget::tr("All Categories" ) ); | 551 | setCaption( QWidget::tr("Todo") + " - " + QWidget::tr("All Categories" ) ); |
552 | 552 | ||
553 | }else if ( c == (int)m_catMenu->count() - 1 ) { | 553 | }else if ( c == (int)m_catMenu->count() - 1 ) { |
554 | m_curCat = QWidget::tr("Unfiled"); | 554 | m_curCat = QWidget::tr("Unfiled"); |
555 | setCaption( QWidget::tr("Todo") + " - " + QWidget::tr("Unfiled") ); | 555 | setCaption( QWidget::tr("Todo") + " - " + QWidget::tr("Unfiled") ); |
556 | }else { | 556 | }else { |
557 | m_curCat = m_todoMgr.categories()[c-2]; | 557 | m_curCat = m_todoMgr.categories()[c-2]; |
558 | setCaption( QWidget::tr("Todo") + " - " + m_curCat ); | 558 | setCaption( QWidget::tr("Todo") + " - " + m_curCat ); |
559 | } | 559 | } |
560 | m_catMenu->setItemChecked( c, true ); | 560 | m_catMenu->setItemChecked( c, true ); |
561 | 561 | ||
562 | currentView()->setShowCategory( m_curCat ); | 562 | currentView()->setShowCategory( m_curCat ); |
563 | raiseCurrentView(); | 563 | raiseCurrentView(); |
564 | } | 564 | } |
565 | void MainWindow::slotShowDeadLine( bool dead) { | 565 | void MainWindow::slotShowDeadLine( bool dead) { |
566 | m_deadline = dead; | 566 | m_deadline = dead; |
567 | currentView()->setShowDeadline( dead ); | 567 | currentView()->setShowDeadline( dead ); |
568 | } | 568 | } |
569 | void MainWindow::slotShowCompleted( bool show) { | 569 | void MainWindow::slotShowCompleted( bool show) { |
570 | m_completed = show; | 570 | m_completed = show; |
571 | currentView()->setShowCompleted( m_completed ); | 571 | currentView()->setShowCompleted( m_completed ); |
572 | } | 572 | } |
573 | void MainWindow::slotShowQuickTask( bool show ) { | 573 | void MainWindow::slotShowQuickTask( bool show ) { |
574 | m_quicktask = show; | 574 | m_quicktask = show; |
575 | if ( m_quicktask ) | 575 | if ( m_quicktask ) |
576 | m_curQuick->widget()->show(); | 576 | m_curQuick->widget()->show(); |
577 | else | 577 | else |
578 | m_curQuick->widget()->hide(); | 578 | m_curQuick->widget()->hide(); |
579 | } | 579 | } |
580 | bool MainWindow::showOverDue()const { | 580 | bool MainWindow::showOverDue()const { |
581 | return m_overdue; | 581 | return m_overdue; |
582 | } | 582 | } |
583 | void MainWindow::setDocument( const QString& fi) { | 583 | void MainWindow::setDocument( const QString& fi) { |
584 | DocLnk doc(fi); | 584 | DocLnk doc(fi); |
585 | if (doc.isValid() ) | 585 | if (doc.isValid() ) |
586 | receiveFile(doc.file() ); | 586 | receiveFile(doc.file() ); |
587 | else | 587 | else |
588 | receiveFile(fi ); | 588 | receiveFile(fi ); |
589 | } | 589 | } |
590 | 590 | ||
591 | static const char *beamfile = "/tmp/opie-todo.vcs"; | 591 | static const char *beamfile = "/tmp/opie-todo.vcs"; |
592 | void MainWindow::slotBeam() { | 592 | void MainWindow::slotBeam() { |
593 | beam( currentView()->current() ); | 593 | beam( currentView()->current() ); |
594 | } | 594 | } |
595 | void MainWindow::beamDone( Ir* ir) { | 595 | void MainWindow::beamDone( Ir* ir) { |
596 | delete ir; | 596 | delete ir; |
597 | ::unlink( beamfile ); | 597 | ::unlink( beamfile ); |
598 | } | 598 | } |
599 | void MainWindow::receiveFile( const QString& filename ) { | 599 | void MainWindow::receiveFile( const QString& filename ) { |
600 | OTodoAccessVCal* cal = new OTodoAccessVCal(filename ); | 600 | OTodoAccessVCal* cal = new OTodoAccessVCal(filename ); |
601 | 601 | ||
602 | OTodoAccess acc( cal ); | 602 | OTodoAccess acc( cal ); |
603 | acc.load(); | 603 | acc.load(); |
604 | OTodoAccess::List list = acc.allRecords(); | 604 | OTodoAccess::List list = acc.allRecords(); |
605 | 605 | ||
606 | if (list.count()){ | 606 | if (list.count()){ |
607 | 607 | ||
608 | QString message = QWidget::tr("<P>%1 new tasks arrived.<p>Would you like to add them to your Todolist?").arg(list.count() ); | 608 | QString message = QWidget::tr("<P>%1 new tasks arrived.<p>Would you like to add them to your Todolist?").arg(list.count() ); |
609 | 609 | ||
610 | if ( QMessageBox::information(this, QWidget::tr("New Tasks"), | 610 | if ( QMessageBox::information(this, QWidget::tr("New Tasks"), |
611 | message, QMessageBox::Ok, | 611 | message, QMessageBox::Ok, |
612 | QMessageBox::Cancel ) == QMessageBox::Ok ) { | 612 | QMessageBox::Cancel ) == QMessageBox::Ok ) { |
613 | OTodoAccess::List::Iterator it; | 613 | OTodoAccess::List::Iterator it; |
614 | for ( it = list.begin(); it != list.end(); ++it ) | 614 | for ( it = list.begin(); it != list.end(); ++it ) |
615 | m_todoMgr.add( (*it) ); | 615 | m_todoMgr.add( (*it) ); |
616 | 616 | ||
617 | currentView()->updateView(); | 617 | currentView()->updateView(); |
618 | } | 618 | } |
619 | } | 619 | } |
620 | } | 620 | } |
621 | 621 | ||
622 | void MainWindow::slotFlush() { | 622 | void MainWindow::slotFlush() { |
623 | m_syncing = TRUE; | 623 | m_syncing = TRUE; |
624 | m_todoMgr.save(); | 624 | m_todoMgr.save(); |
625 | } | 625 | } |
626 | void MainWindow::slotShowDetails() { | 626 | void MainWindow::slotShowDetails() { |
627 | slotShow( currentView()->current() ); | 627 | slotShow( currentView()->current() ); |
628 | } | 628 | } |
629 | /* | 629 | /* |
630 | * populate the Categories | 630 | * populate the Categories |
631 | * Menu | 631 | * Menu |
632 | */ | 632 | */ |
633 | void MainWindow::populateCategories() { | 633 | void MainWindow::populateCategories() { |
634 | m_todoMgr.load(); | 634 | m_todoMgr.load(); |
635 | 635 | ||
636 | m_catMenu->clear(); | 636 | m_catMenu->clear(); |
637 | int id, rememberId; | 637 | int id, rememberId; |
638 | id = 1; | 638 | id = 1; |
639 | rememberId = 1; | 639 | rememberId = 1; |
640 | 640 | ||
641 | m_catMenu->insertItem( QWidget::tr( "All Categories" ), id++ ); | 641 | m_catMenu->insertItem( QWidget::tr( "All Categories" ), id++ ); |
642 | m_catMenu->insertSeparator(); | 642 | m_catMenu->insertSeparator(); |
643 | QStringList categories = m_todoMgr.categories(); | 643 | QStringList categories = m_todoMgr.categories(); |
644 | categories.append( QWidget::tr( "Unfiled" ) ); | 644 | categories.append( QWidget::tr( "Unfiled" ) ); |
645 | for ( QStringList::Iterator it = categories.begin(); | 645 | for ( QStringList::Iterator it = categories.begin(); |
646 | it != categories.end(); ++it ) { | 646 | it != categories.end(); ++it ) { |
647 | m_catMenu->insertItem( *it, id ); | 647 | m_catMenu->insertItem( *it, id ); |
648 | if ( *it == currentCategory() ) | 648 | if ( *it == currentCategory() ) |
649 | rememberId = id; | 649 | rememberId = id; |
650 | ++id; | 650 | ++id; |
651 | } | 651 | } |
652 | setCategory( rememberId ); | 652 | setCategory( rememberId ); |
653 | } | 653 | } |
654 | bool MainWindow::showCompleted()const { | 654 | bool MainWindow::showCompleted()const { |
655 | return m_completed; | 655 | return m_completed; |
656 | } | 656 | } |
657 | bool MainWindow::showDeadline()const { | 657 | bool MainWindow::showDeadline()const { |
658 | return m_deadline; | 658 | return m_deadline; |
659 | } | 659 | } |
660 | bool MainWindow::showQuickTask()const { | 660 | bool MainWindow::showQuickTask()const { |
661 | return m_quicktask; | 661 | return m_quicktask; |
662 | } | 662 | } |
663 | QString MainWindow::currentCategory()const { | 663 | QString MainWindow::currentCategory()const { |
664 | return m_curCat; | 664 | return m_curCat; |
665 | } | 665 | } |
666 | int MainWindow::currentCatId() { | 666 | int MainWindow::currentCatId() { |
667 | return m_todoMgr.catId( m_curCat ); | 667 | return m_todoMgr.catId( m_curCat ); |
668 | } | 668 | } |
669 | ViewBase* MainWindow::currentView() { | 669 | ViewBase* MainWindow::currentView() { |
670 | return m_curView; | 670 | return m_curView; |
671 | } | 671 | } |
672 | void MainWindow::raiseCurrentView() { | 672 | void MainWindow::raiseCurrentView() { |
673 | // due QPE/Application/todolist show(int) | 673 | // due QPE/Application/todolist show(int) |
674 | // we might not have the populateCategories slot called once | 674 | // we might not have the populateCategories slot called once |
675 | // we would show the otodo but then imediately switch to the currentView | 675 | // we would show the otodo but then imediately switch to the currentView |
676 | // if we're initially showing we shouldn't raise the table | 676 | // if we're initially showing we shouldn't raise the table |
677 | // in returnFromView we fix up m_showing | 677 | // in returnFromView we fix up m_showing |
678 | if (m_showing ) return; | 678 | if (m_showing ) return; |
679 | 679 | ||
680 | m_stack->raiseWidget( m_curView->widget() ); | 680 | m_stack->raiseWidget( m_curView->widget() ); |
681 | } | 681 | } |
682 | void MainWindow::slotShowDue(bool ov) { | 682 | void MainWindow::slotShowDue(bool ov) { |
683 | m_overdue = ov; | 683 | m_overdue = ov; |
684 | currentView()->showOverDue( ov ); | 684 | currentView()->showOverDue( ov ); |
685 | raiseCurrentView(); | 685 | raiseCurrentView(); |
686 | } | 686 | } |
687 | void MainWindow::slotShow( int uid ) { | 687 | void MainWindow::slotShow( int uid ) { |
688 | if ( uid == 0 ) return; | 688 | if ( uid == 0 ) return; |
689 | qWarning("slotShow"); | 689 | qWarning("slotShow"); |
690 | currentShow()->slotShow( event( uid ) ); | 690 | currentShow()->slotShow( event( uid ) ); |
691 | m_stack->raiseWidget( currentShow()->widget() ); | 691 | m_stack->raiseWidget( currentShow()->widget() ); |
692 | } | 692 | } |
693 | void MainWindow::slotShowNext() { | 693 | void MainWindow::slotShowNext() { |
694 | int l = currentView()->next(); | 694 | int l = currentView()->next(); |
695 | if (l!=0) | 695 | if (l!=0) |
696 | slotShow(l); | 696 | slotShow(l); |
697 | } | 697 | } |
698 | void MainWindow::slotShowPrev() { | 698 | void MainWindow::slotShowPrev() { |
699 | int l = currentView()->prev(); | 699 | int l = currentView()->prev(); |
700 | if (l!=0) | 700 | if (l!=0) |
701 | slotShow(l); | 701 | slotShow(l); |
702 | } | 702 | } |
703 | void MainWindow::slotEdit( int uid ) { | 703 | void MainWindow::slotEdit( int uid ) { |
704 | if (uid == 0 ) return; | 704 | if (uid == 0 ) return; |
705 | if(m_syncing) { | 705 | if(m_syncing) { |
706 | QMessageBox::warning(this, QWidget::tr("Todo"), | 706 | QMessageBox::warning(this, QWidget::tr("Todo"), |
707 | QWidget::tr("Data can't be edited, currently syncing")); | 707 | QWidget::tr("Data can't be edited, currently syncing")); |
708 | return; | 708 | return; |
709 | } | 709 | } |
710 | 710 | ||
711 | OTodo old_todo = m_todoMgr.event( uid ); | 711 | OTodo old_todo = m_todoMgr.event( uid ); |
712 | 712 | ||
713 | OTodo todo = currentEditor()->edit(this, old_todo ); | 713 | OTodo todo = currentEditor()->edit(this, old_todo ); |
714 | 714 | ||
715 | /* if completed */ | 715 | /* if completed */ |
716 | if ( currentEditor()->accepted() ) { | 716 | if ( currentEditor()->accepted() ) { |
717 | handleAlarms( old_todo, todo ); | 717 | handleAlarms( old_todo, todo ); |
718 | m_todoMgr.update( todo.uid(), todo ); | 718 | m_todoMgr.update( todo.uid(), todo ); |
719 | currentView()->replaceEvent( todo ); | 719 | currentView()->replaceEvent( todo ); |
720 | /* a Category might have changed */ | 720 | /* a Category might have changed */ |
721 | populateCategories(); | 721 | populateCategories(); |
722 | } | 722 | } |
723 | 723 | ||
724 | raiseCurrentView(); | 724 | raiseCurrentView(); |
725 | } | 725 | } |
726 | /* | 726 | /* |
727 | void MainWindow::slotUpdate1( int uid, const SmallTodo& ev) { | 727 | void MainWindow::slotUpdate1( int uid, const SmallTodo& ev) { |
728 | m_todoMgr.update( uid, ev ); | 728 | m_todoMgr.update( uid, ev ); |
729 | } | 729 | } |
730 | */ | 730 | */ |
731 | void MainWindow::updateTodo( const OTodo& ev) { | 731 | void MainWindow::updateTodo( const OTodo& ev) { |
732 | m_todoMgr.update( ev.uid() , ev ); | 732 | m_todoMgr.update( ev.uid() , ev ); |
733 | } | 733 | } |
734 | /* The view changed it's configuration | 734 | /* The view changed it's configuration |
735 | * update the view menu | 735 | * update the view menu |
736 | */ | 736 | */ |
737 | void MainWindow::slotUpdate3( QWidget* ) { | 737 | void MainWindow::slotUpdate3( QWidget* ) { |
738 | 738 | ||
739 | } | 739 | } |
740 | void MainWindow::updateList() { | 740 | void MainWindow::updateList() { |
741 | m_todoMgr.updateList(); | 741 | m_todoMgr.updateList(); |
742 | } | 742 | } |
743 | void MainWindow::setReadAhead( uint count ) { | 743 | void MainWindow::setReadAhead( uint count ) { |
744 | if (m_todoMgr.todoDB() ) | 744 | if (m_todoMgr.todoDB() ) |
745 | m_todoMgr.todoDB()->setReadAhead( count ); | 745 | m_todoMgr.todoDB()->setReadAhead( count ); |
746 | } | 746 | } |
747 | void MainWindow::slotQuickEntered() { | 747 | void MainWindow::slotQuickEntered() { |
748 | qWarning("entered"); | 748 | qWarning("entered"); |
749 | OTodo todo = quickEditor()->todo(); | 749 | OTodo todo = quickEditor()->todo(); |
750 | if (todo.isEmpty() ) | 750 | if (todo.isEmpty() ) |
751 | return; | 751 | return; |
752 | 752 | ||
753 | m_todoMgr.add( todo ); | 753 | m_todoMgr.add( todo ); |
754 | currentView()->addEvent( todo ); | 754 | currentView()->addEvent( todo ); |
755 | raiseCurrentView(); | 755 | raiseCurrentView(); |
756 | } | 756 | } |
757 | QuickEditBase* MainWindow::quickEditor() { | 757 | QuickEditBase* MainWindow::quickEditor() { |
758 | return m_curQuick; | 758 | return m_curQuick; |
759 | } | 759 | } |
760 | void MainWindow::slotComplete( int uid ) { | 760 | void MainWindow::slotComplete( int uid ) { |
761 | slotComplete( event(uid) ); | 761 | slotComplete( event(uid) ); |
762 | } | 762 | } |
763 | void MainWindow::slotComplete( const OTodo& todo ) { | 763 | void MainWindow::slotComplete( const OTodo& todo ) { |
764 | OTodo to = todo; | 764 | OTodo to = todo; |
765 | to.setCompleted( !to.isCompleted() ); | 765 | to.setCompleted( !to.isCompleted() ); |
766 | to.setCompletedDate( QDate::currentDate() ); | 766 | to.setCompletedDate( QDate::currentDate() ); |
767 | 767 | ||
768 | /* | 768 | /* |
769 | * if the item does recur | 769 | * if the item does recur |
770 | * we need to spin it off | 770 | * we need to spin it off |
771 | * and update the items duedate to the next | 771 | * and update the items duedate to the next |
772 | * possible recurrance of this item... | 772 | * possible recurrance of this item... |
773 | * the spinned off one will loose the | 773 | * the spinned off one will loose the |
774 | * recurrence. | 774 | * recurrence. |
775 | * We calculate the difference between the old due date and the | 775 | * We calculate the difference between the old due date and the |
776 | * new one and add this diff to start, completed and alarm dates | 776 | * new one and add this diff to start, completed and alarm dates |
777 | * -zecke | 777 | * -zecke |
778 | */ | 778 | */ |
779 | if ( to.hasRecurrence() && to.isCompleted() ) { | 779 | if ( to.hasRecurrence() && to.isCompleted() ) { |
780 | OTodo to2( to ); | 780 | OTodo to2( to ); |
781 | 781 | ||
782 | /* the spinned off one won't recur anymore */ | 782 | /* the spinned off one won't recur anymore */ |
783 | to.setRecurrence( ORecur() ); | 783 | to.setRecurrence( ORecur() ); |
784 | 784 | ||
785 | ORecur rec = to2.recurrence(); | 785 | ORecur rec = to2.recurrence(); |
786 | rec.setStart( to.dueDate() ); | 786 | rec.setStart( to.dueDate() ); |
787 | to2.setRecurrence( rec ); | 787 | to2.setRecurrence( rec ); |
788 | /* | 788 | /* |
789 | * if there is a next occurence | 789 | * if there is a next occurence |
790 | * from the duedate of the last recurrance | 790 | * from the duedate of the last recurrance |
791 | */ | 791 | */ |
792 | QDate date; | 792 | QDate date; |
793 | if ( to2.recurrence().nextOcurrence( to2.dueDate().addDays(1), date ) ) { | 793 | if ( to2.recurrence().nextOcurrence( to2.dueDate().addDays(1), date ) ) { |
794 | int dayDiff = to.dueDate().daysTo( date ); | 794 | int dayDiff = to.dueDate().daysTo( date ); |
795 | qWarning("day diff is %d", dayDiff ); | 795 | qWarning("day diff is %d", dayDiff ); |
796 | QDate inval; | 796 | QDate inval; |