summaryrefslogtreecommitdiff
path: root/core/pim/todo/mainwindow.cpp
Unidiff
Diffstat (limited to 'core/pim/todo/mainwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/todo/mainwindow.cpp70
1 files changed, 43 insertions, 27 deletions
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp
index 0ab6230..f0aa455 100644
--- a/core/pim/todo/mainwindow.cpp
+++ b/core/pim/todo/mainwindow.cpp
@@ -24,12 +24,13 @@
24 Inc., 59 Temple Place - Suite 330, 24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29#include <unistd.h> 29#include <unistd.h>
30#include <stdio.h>
30 31
31#include <qmenubar.h> 32#include <qmenubar.h>
32#include <qmessagebox.h> 33#include <qmessagebox.h>
33#include <qtoolbar.h> 34#include <qtoolbar.h>
34#include <qpopupmenu.h> 35#include <qpopupmenu.h>
35#include <qwidgetstack.h> 36#include <qwidgetstack.h>
@@ -40,12 +41,13 @@
40 41
41#include <qpe/applnk.h> 42#include <qpe/applnk.h>
42#include <qpe/config.h> 43#include <qpe/config.h>
43#include <qpe/ir.h> 44#include <qpe/ir.h>
44#include <qpe/resource.h> 45#include <qpe/resource.h>
45#include <qpe/qpemessagebox.h> 46#include <qpe/qpemessagebox.h>
47#include <qpe/qpetoolbar.h>
46 48
47#include <opie/orecur.h> 49#include <opie/orecur.h>
48#include <opie/otodoaccessvcal.h> 50#include <opie/otodoaccessvcal.h>
49 51
50#include "quickeditimpl.h" 52#include "quickeditimpl.h"
51#include "todotemplatemanager.h" 53#include "todotemplatemanager.h"
@@ -82,12 +84,17 @@ MainWindow::MainWindow( QWidget* parent,
82 QTimer::singleShot(0, this, SLOT(populateCategories() ) ); 84 QTimer::singleShot(0, this, SLOT(populateCategories() ) );
83} 85}
84void MainWindow::initTemplate() { 86void MainWindow::initTemplate() {
85 m_curTempEd = new TemplateEditor( this, templateManager() ); 87 m_curTempEd = new TemplateEditor( this, templateManager() );
86} 88}
87void MainWindow::initActions() { 89void MainWindow::initActions() {
90
91 // Data menu
92 m_edit->insertItem(tr("New from template"), m_template,
93 -1, 0 );
94
88 QAction* a = new QAction( tr("New Task" ), Resource::loadPixmap( "new" ), 95 QAction* a = new QAction( tr("New Task" ), Resource::loadPixmap( "new" ),
89 QString::null, 0, this, 0 ); 96 QString::null, 0, this, 0 );
90 connect(a, SIGNAL( activated() ), 97 connect(a, SIGNAL( activated() ),
91 this, SLOT( slotNew() ) ); 98 this, SLOT( slotNew() ) );
92 a->addTo(m_tool ); 99 a->addTo(m_tool );
93 a->addTo(m_edit ); 100 a->addTo(m_edit );
@@ -145,77 +152,75 @@ void MainWindow::initActions() {
145 connect( a, SIGNAL( activated() ), 152 connect( a, SIGNAL( activated() ),
146 this, SLOT( slotBeam() ) ); 153 this, SLOT( slotBeam() ) );
147 a->addTo( m_edit ); 154 a->addTo( m_edit );
148 a->addTo( m_tool ); 155 a->addTo( m_tool );
149 } 156 }
150 157
158 // Options menu
151 a = new QAction( tr("Find"), Resource::loadIconSet( "mag" ), 159 a = new QAction( tr("Find"), Resource::loadIconSet( "mag" ),
152 QString::null, 0, this, 0 ); 160 QString::null, 0, this, 0 );
153 connect(a, SIGNAL( activated() ), 161 connect(a, SIGNAL( activated() ), this, SLOT( slotFind() ) );
154 this, SLOT( slotFind() ) );
155 a->addTo( m_options ); 162 a->addTo( m_options );
156 m_findAction = a; 163 m_findAction = a;
157 164
158 m_options->insertSeparator(); 165 m_options->insertSeparator();
159 166
160 m_completedAction = new QAction( QString::null, tr("Completed tasks"), 167 m_completedAction = new QAction( QString::null, tr("Show completed tasks"),
161 0, this, 0, TRUE ); 168 0, this, 0, TRUE );
162 m_completedAction->addTo( m_options ); 169 m_completedAction->addTo( m_options );
163 m_completedAction->setOn( showCompleted() ); 170 m_completedAction->setOn( showCompleted() );
164 connect(m_completedAction, SIGNAL( toggled(bool) ), 171 connect(m_completedAction, SIGNAL( toggled(bool) ), this, SLOT(slotShowCompleted(bool) ) );
165 this, SLOT(slotShowCompleted(bool) ) );
166 172
167 m_showDeadLineAction = new QAction( QString::null, tr("Show Deadline"), 173 a = new QAction( QString::null, tr("Show only over-due tasks"),
174 0, this, 0, TRUE );
175 a->addTo( m_options );
176 a->setOn( showOverDue() );
177 connect(a, SIGNAL(toggled(bool)), this, SLOT(slotShowDue(bool) ) );
178
179 m_showDeadLineAction = new QAction( QString::null, tr("Show task deadlines"),
168 0, this, 0, TRUE ); 180 0, this, 0, TRUE );
169 m_showDeadLineAction->addTo( m_options ); 181 m_showDeadLineAction->addTo( m_options );
170 m_showDeadLineAction->setOn( showDeadline() ); 182 m_showDeadLineAction->setOn( showDeadline() );
171 connect(m_showDeadLineAction, SIGNAL(toggled(bool) ), 183 connect(m_showDeadLineAction, SIGNAL(toggled(bool) ), this, SLOT( slotShowDeadLine( bool ) ) );
172 this, SLOT( slotShowDeadLine( bool ) ) ); 184
185 m_showQuickTaskAction = new QAction( QString::null, tr("Show quick task bar"),
186 0, this, 0, TRUE );
187 m_showQuickTaskAction->addTo( m_options );
188 m_showQuickTaskAction->setOn( showQuickTask() );
189 connect(m_showQuickTaskAction, SIGNAL( toggled(bool) ), this, SLOT(slotShowQuickTask(bool) ) );
173 190
174 m_options->insertSeparator(); 191 m_options->insertSeparator();
175 192
176 m_bar->insertItem( tr("Data") ,m_edit ); 193 m_bar->insertItem( tr("Data") ,m_edit );
177 m_bar->insertItem( tr("Category"), m_catMenu ); 194 m_bar->insertItem( tr("Category"), m_catMenu );
178 m_bar->insertItem( tr("Options"), m_options ); 195 m_bar->insertItem( tr("Options"), m_options );
179 196
180 /* initialize the view menu */ 197 m_curQuick = new QuickEditImpl( this, m_quicktask );
181 a = new QAction( QString::null, tr("Show only over due"), 198 addToolBar( (QPEToolBar *)m_curQuick->widget(), tr( "QuickEdit" ), QMainWindow::Top, TRUE );
182 0, this, 0, TRUE ); 199 m_curQuick->signal()->connect( this, SLOT(slotQuickEntered() ) );
183 a->addTo( m_options );
184 a->setOn( showOverDue() );
185 connect(a, SIGNAL(toggled(bool)),
186 this, SLOT(slotShowDue(bool) ) );
187
188 /* templates */
189 m_edit->insertItem(tr("New from template"), m_template,
190 -1, 0 );
191 200
192} 201}
193/* m_curCat from Config */ 202/* m_curCat from Config */
194void MainWindow::initConfig() { 203void MainWindow::initConfig() {
195 Config config( "todo" ); 204 Config config( "todo" );
196 config.setGroup( "View" ); 205 config.setGroup( "View" );
197 m_completed = config.readBoolEntry( "ShowComplete", TRUE ); 206 m_completed = config.readBoolEntry( "ShowComplete", TRUE );
198 m_curCat = config.readEntry( "Category", QString::null ); 207 m_curCat = config.readEntry( "Category", QString::null );
199 m_deadline = config.readBoolEntry( "ShowDeadLine", TRUE); 208 m_deadline = config.readBoolEntry( "ShowDeadLine", TRUE);
200 m_overdue = config.readBoolEntry("ShowOverDue", TRUE ); 209 m_overdue = config.readBoolEntry("ShowOverDue", FALSE );
210 m_quicktask = config.readBoolEntry("ShowQuickTask", TRUE);
201} 211}
202void MainWindow::initUI() { 212void MainWindow::initUI() {
203 m_mainBox = new QVBox(this, "main box "); 213 m_mainBox = new QVBox(this, "main box ");
204 m_curQuick = new QuickEditImpl(this, m_mainBox );
205 m_curQuick->signal()->connect( this, SLOT(slotQuickEntered() ) );
206 m_quickEdit.append( m_curQuick );
207
208
209 214
210 m_stack = new QWidgetStack(m_mainBox, "main stack"); 215 m_stack = new QWidgetStack(m_mainBox, "main stack");
211 setCentralWidget( m_mainBox ); 216 setCentralWidget( m_mainBox );
212 217
213 setToolBarsMovable( FALSE ); 218 setToolBarsMovable( FALSE );
214 219
215 m_tool = new QToolBar( this ); 220 m_tool = new QPEToolBar( this );
216 m_tool->setHorizontalStretchable( TRUE ); 221 m_tool->setHorizontalStretchable( TRUE );
217 222
218 m_bar = new QMenuBar( m_tool ); 223 m_bar = new QMenuBar( m_tool );
219 224
220 /** QPopupMenu */ 225 /** QPopupMenu */
221 m_edit = new QPopupMenu( this ); 226 m_edit = new QPopupMenu( this );
@@ -368,13 +373,14 @@ void MainWindow::closeEvent( QCloseEvent* e ) {
368 Config config( "todo" ); 373 Config config( "todo" );
369 config.setGroup( "View" ); 374 config.setGroup( "View" );
370 config.writeEntry( "ShowComplete", showCompleted() ); 375 config.writeEntry( "ShowComplete", showCompleted() );
371 config.writeEntry( "Category", currentCategory() ); 376 config.writeEntry( "Category", currentCategory() );
372 config.writeEntry( "ShowDeadLine", showDeadline()); 377 config.writeEntry( "ShowDeadLine", showDeadline());
373 config.writeEntry( "ShowOverDue", showOverDue() ); 378 config.writeEntry( "ShowOverDue", showOverDue() );
374 /* svae templates */ 379 config.writeEntry( "ShowQuickTask", showQuickTask() );
380 /* save templates */
375 templateManager()->save(); 381 templateManager()->save();
376 e->accept(); 382 e->accept();
377 } 383 }
378} 384}
379void MainWindow::populateTemplates() { 385void MainWindow::populateTemplates() {
380 m_template->clear(); 386 m_template->clear();
@@ -512,12 +518,19 @@ void MainWindow::slotShowDeadLine( bool dead) {
512 currentView()->setShowDeadline( dead ); 518 currentView()->setShowDeadline( dead );
513} 519}
514void MainWindow::slotShowCompleted( bool show) { 520void MainWindow::slotShowCompleted( bool show) {
515 m_completed = show; 521 m_completed = show;
516 currentView()->setShowCompleted( m_completed ); 522 currentView()->setShowCompleted( m_completed );
517} 523}
524void MainWindow::slotShowQuickTask( bool show ) {
525 m_quicktask = show;
526 if ( m_quicktask )
527 m_curQuick->widget()->show();
528 else
529 m_curQuick->widget()->hide();
530}
518bool MainWindow::showOverDue()const { 531bool MainWindow::showOverDue()const {
519 return m_overdue; 532 return m_overdue;
520} 533}
521void MainWindow::setDocument( const QString& fi) { 534void MainWindow::setDocument( const QString& fi) {
522 DocLnk doc(fi); 535 DocLnk doc(fi);
523 if (doc.isValid() ) 536 if (doc.isValid() )
@@ -588,12 +601,15 @@ void MainWindow::populateCategories() {
588bool MainWindow::showCompleted()const { 601bool MainWindow::showCompleted()const {
589 return m_completed; 602 return m_completed;
590} 603}
591bool MainWindow::showDeadline()const { 604bool MainWindow::showDeadline()const {
592 return m_deadline; 605 return m_deadline;
593} 606}
607bool MainWindow::showQuickTask()const {
608 return m_quicktask;
609}
594QString MainWindow::currentCategory()const { 610QString MainWindow::currentCategory()const {
595 return m_curCat; 611 return m_curCat;
596} 612}
597int MainWindow::currentCatId() { 613int MainWindow::currentCatId() {
598 return m_todoMgr.catId( m_curCat ); 614 return m_todoMgr.catId( m_curCat );
599} 615}