author | zecke <zecke> | 2003-09-06 06:31:13 (UTC) |
---|---|---|
committer | zecke <zecke> | 2003-09-06 06:31:13 (UTC) |
commit | e06de75edc6c01d97248050030f197bd8f21fb10 (patch) (side-by-side diff) | |
tree | 4696ac60c9cdb5fc80c28c862eb856c64b7b7c8c | |
parent | eaf6da2bd05eac392c118c11fd5be1bab8586b6a (diff) | |
download | opie-e06de75edc6c01d97248050030f197bd8f21fb10.zip opie-e06de75edc6c01d97248050030f197bd8f21fb10.tar.gz opie-e06de75edc6c01d97248050030f197bd8f21fb10.tar.bz2 |
-Switch to OWidgetStack actually only three lines touch by this
-the really quit on closeEvent and don't wait for the last window
-use setName eases debugging
-rw-r--r-- | core/pim/todo/mainwindow.cpp | 7 | ||||
-rw-r--r-- | core/pim/todo/mainwindow.h | 4 | ||||
-rw-r--r-- | core/pim/todo/tableview.cpp | 1 |
3 files changed, 9 insertions, 3 deletions
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp index ecb4e40..ad7899f 100644 --- a/core/pim/todo/mainwindow.cpp +++ b/core/pim/todo/mainwindow.cpp @@ -8,116 +8,120 @@ .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This program is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include <unistd.h> #include <qmenubar.h> #include <qmessagebox.h> #include <qtoolbar.h> #include <qpopupmenu.h> #include <qpushbutton.h> #include <qwidgetstack.h> #include <qaction.h> #include <qtimer.h> #include <qvbox.h> #include <qlayout.h> #include <qlineedit.h> #include <qwhatsthis.h> #include <qpe/applnk.h> #include <qpe/config.h> #include <qpe/ir.h> #include <qpe/resource.h> #include <qpe/qpemessagebox.h> #include <qpe/alarmserver.h> #include <qpe/timestring.h> #include <qpe/qpeapplication.h> #include <opie/orecur.h> #include <opie/opimnotifymanager.h> #include <opie/otodoaccessvcal.h> +#include <opie/owidgetstack.h> #include <opie/oapplicationfactory.h> #include "quickeditimpl.h" #include "todotemplatemanager.h" #include "templateeditor.h" #include "tableview.h" #include "textviewshow.h" #include "todoeditor.h" #include "mainwindow.h" OPIE_EXPORT_APP( OApplicationFactory<Todo::MainWindow> ) using namespace Todo; MainWindow::MainWindow( QWidget* parent, const char* name, WFlags ) : OPimMainWindow( "Todolist", parent, name, WType_TopLevel | WStyle_ContextHelp ) { + if (!name) + setName("todo window"); + m_syncing = false; m_showing = false; m_counter = 0; m_tempManager = new TemplateManager(); m_tempManager->load(); initUI(); initConfig(); initViews(); initActions(); initEditor(); initShow(); initTemplate(); populateTemplates(); raiseCurrentView(); QTimer::singleShot(0, this, SLOT(populateCategories() ) ); } void MainWindow::initTemplate() { m_curTempEd = new TemplateEditor( this, templateManager() ); } void MainWindow::initActions() { // Data menu m_edit->insertItem(QWidget::tr("New from template"), m_template, -1, 0 ); QAction* a = new QAction( QWidget::tr("New Task" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); connect(a, SIGNAL( activated() ), this, SLOT( slotNew() ) ); a->setWhatsThis( QWidget::tr( "Click here to create a new task." ) ); a->addTo(m_tool ); a->addTo(m_edit ); a = new QAction( QWidget::tr("Edit Task"), Resource::loadIconSet( "edit" ), QString::null, 0, this, 0 ); connect(a, SIGNAL(activated() ), this, SLOT( slotEdit() ) ); a->setWhatsThis( QWidget::tr( "Click here to modify the current task." ) ); a->addTo( m_tool ); a->addTo( m_edit ); m_editAction = a; a = new QAction( QString::null, QWidget::tr("View Task"), 0, this, 0 ); connect(a, SIGNAL( activated() ), this, SLOT( slotShowDetails() ) ); a->addTo( m_edit ); @@ -179,97 +183,97 @@ void MainWindow::initActions() { m_completedAction = new QAction( QString::null, QWidget::tr("Show completed tasks"), 0, this, 0, TRUE ); m_completedAction->addTo( m_options ); m_completedAction->setOn( showCompleted() ); connect(m_completedAction, SIGNAL( toggled(bool) ), this, SLOT(slotShowCompleted(bool) ) ); a = new QAction( QString::null, QWidget::tr("Show only over-due tasks"), 0, this, 0, TRUE ); a->addTo( m_options ); a->setOn( showOverDue() ); connect(a, SIGNAL(toggled(bool)), this, SLOT(slotShowDue(bool) ) ); m_showDeadLineAction = new QAction( QString::null, QWidget::tr("Show task deadlines"), 0, this, 0, TRUE ); m_showDeadLineAction->addTo( m_options ); m_showDeadLineAction->setOn( showDeadline() ); connect(m_showDeadLineAction, SIGNAL(toggled(bool) ), this, SLOT( slotShowDeadLine( bool ) ) ); m_showQuickTaskAction = new QAction( QString::null, QWidget::tr("Show quick task bar"), 0, this, 0, TRUE ); m_showQuickTaskAction->addTo( m_options ); m_showQuickTaskAction->setOn( showQuickTask() ); connect(m_showQuickTaskAction, SIGNAL( toggled(bool) ), this, SLOT(slotShowQuickTask(bool) ) ); m_options->insertSeparator(); m_bar->insertItem( QWidget::tr("Data") ,m_edit ); m_bar->insertItem( QWidget::tr("Category"), m_catMenu ); m_bar->insertItem( QWidget::tr("Options"), m_options ); m_curQuick = new QuickEditImpl( this, m_quicktask ); addToolBar( (QPEToolBar *)m_curQuick->widget(), QWidget::tr( "QuickEdit" ), QMainWindow::Top, TRUE ); m_curQuick->signal()->connect( this, SLOT(slotQuickEntered() ) ); } /* m_curCat from Config */ void MainWindow::initConfig() { Config config( "todo" ); config.setGroup( "View" ); m_completed = config.readBoolEntry( "ShowComplete", TRUE ); m_curCat = config.readEntry( "Category", QString::null ); m_deadline = config.readBoolEntry( "ShowDeadLine", TRUE); m_overdue = config.readBoolEntry("ShowOverDue", FALSE ); m_quicktask = config.readBoolEntry("ShowQuickTask", TRUE); } void MainWindow::initUI() { - m_stack = new QWidgetStack(this, "main stack"); + m_stack = new OWidgetStack(this, "main stack"); setCentralWidget( m_stack ); setToolBarsMovable( FALSE ); QToolBar *menubarholder = new QToolBar( this ); menubarholder->setHorizontalStretchable( TRUE ); m_bar = new QMenuBar( menubarholder ); m_tool = new QToolBar( this ); /** QPopupMenu */ m_edit = new QPopupMenu( this ); m_options = new QPopupMenu( this ); m_catMenu = new QPopupMenu( this ); m_template = new QPopupMenu( this ); m_catMenu->setCheckable( TRUE ); m_template->setCheckable( TRUE ); connect(m_catMenu, SIGNAL(activated(int) ), this, SLOT(setCategory(int) ) ); connect(m_template, SIGNAL(activated(int) ), this, SLOT(slotNewFromTemplate(int) ) ); } void MainWindow::initViews() { TableView* tableView = new TableView( this, m_stack ); 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." ) ); m_stack->addWidget( tableView, m_counter++ ); m_views.append( tableView ); m_curView = tableView; connectBase( tableView ); /* add QString type + QString configname to * the View menu * and subdirs for multiple views */ } void MainWindow::initEditor() { m_curEdit = new Editor(); } void MainWindow::initShow() { m_curShow = new TextViewShow(this, this); m_stack->addWidget( m_curShow->widget() , m_counter++ ); } MainWindow::~MainWindow() { delete templateManager(); } @@ -360,96 +364,97 @@ void MainWindow::slotReload() { } void MainWindow::closeEvent( QCloseEvent* e ) { if (m_stack->visibleWidget() == currentShow()->widget() ) { m_showing = false; raiseCurrentView(); e->ignore(); return; } /* * we should have flushed and now we're still saving * so there is no need to flush */ if (m_syncing ) { e->accept(); return; } bool quit = false; if ( m_todoMgr.saveAll() ){ qWarning("saved"); quit = true; }else { if ( QMessageBox::critical( this, QWidget::tr("Out of space"), QWidget::tr("Todo was unable\n" "to save your changes.\n" "Free up some space\n" "and try again.\n" "\nQuit Anyway?"), QMessageBox::Yes|QMessageBox::Escape, QMessageBox::No|QMessageBox::Default) != QMessageBox::No ) { e->accept(); quit = true; }else e->ignore(); } if (quit ) { Config config( "todo" ); config.setGroup( "View" ); config.writeEntry( "ShowComplete", showCompleted() ); config.writeEntry( "Category", currentCategory() ); config.writeEntry( "ShowDeadLine", showDeadline()); config.writeEntry( "ShowOverDue", showOverDue() ); config.writeEntry( "ShowQuickTask", showQuickTask() ); /* save templates */ templateManager()->save(); e->accept(); + qApp->quit(); } } void MainWindow::populateTemplates() { m_template->clear(); QStringList list = templateManager()->templates(); QStringList::Iterator it; for ( it = list.begin(); it != list.end(); ++it ) { m_template->insertItem( (*it) ); } } /* * slotNewFromTemplate * We use the edit widget to do * the config but we setUid(1) * to get a new uid */ /* * first we get the name of the template * then we will use the TemplateManager */ void MainWindow::slotNewFromTemplate( int id ) { QString name = m_template->text( id ); OTodo event = templateManager()->templateEvent( name ); event = currentEditor()->edit(this, event ); if ( currentEditor()->accepted() ) { /* assign new todo */ event.setUid( 1 ); handleAlarms( OTodo(), event ); m_todoMgr.add( event ); currentView()->addEvent( event ); populateCategories(); } raiseCurrentView(); } void MainWindow::slotNew() { create(); } void MainWindow::slotDuplicate() { if(m_syncing) { QMessageBox::warning(this, QWidget::tr("Todo"), QWidget::tr("Data can not be edited, currently syncing")); return; } OTodo ev = m_todoMgr.event( currentView()->current() ); diff --git a/core/pim/todo/mainwindow.h b/core/pim/todo/mainwindow.h index bd341c2..fd0e1bd 100644 --- a/core/pim/todo/mainwindow.h +++ b/core/pim/todo/mainwindow.h @@ -1,95 +1,95 @@ /* =. This file is part of the OPIE Project .=l. Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> .>+-= _;:, .> :=|. This program is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This program is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef TODO_MAIN_WINDOW_H #define TODO_MAIN_WINDOW_H #include <qlist.h> #include <opie/otodoaccess.h> #include <opie/otodo.h> #include <opie/opimmainwindow.h> #include "smalltodo.h" #include "todoview.h" #include "quickedit.h" #include "todomanager.h" class QPopupMenu; class QMenuBar; class QToolBar; class QAction; -class QWidgetStack; +class OWidgetStack; class Ir; class QVBox; class QLineEdit; namespace Todo { typedef TodoView View; class TemplateManager; class Editor; class TodoShow; class TemplateEditor; struct QuickEditBase; class MainWindow : public OPimMainWindow { Q_OBJECT friend class TodoView; // avoid QObject here.... friend class TodoShow; // avoid QObject public: /* OApplicationFactory application Name */ static QString appName() { return QString::fromLatin1("todolist"); } MainWindow( QWidget *parent = 0, const char* name = 0, WFlags fl = 0 ); ~MainWindow(); /** return a context menu for an OTodo */ QPopupMenu* contextMenu(int uid, bool doesRecur = FALSE ); QPopupMenu* options(); QPopupMenu* edit(); QToolBar* toolbar(); void updateList(); OTodoAccess::List list()const; OTodoAccess::List sorted( bool asc, int sortOrder ); OTodoAccess::List sorted( bool asc, int sortOrder, int addFilter ); OTodo event(int uid ); bool isSyncing()const; bool showCompleted()const; bool showDeadline()const; bool showOverDue()const; bool showQuickTask()const; QString currentCategory()const; int currentCatId(); TemplateManager* templateManager(); QuickEditBase* quickEditor(); @@ -97,97 +97,97 @@ namespace Todo { void populateTemplates(); Editor* currentEditor(); void setReadAhead(uint count ); private slots: void slotQuickEntered(); void populateCategories(); void slotReload(); void slotFlush(); protected: void closeEvent( QCloseEvent* e ); private: /* handle setting and removing alarms */ void handleAlarms( const OTodo& oldTodo, const OTodo& newTodo ); void receiveFile( const QString& filename ); void connectBase( ViewBase* ); void initUI(); void initActions(); void initConfig(); void initViews(); void initEditor(); void initShow(); void initTemplate(); void raiseCurrentView(); ViewBase* currentView(); ViewBase* m_curView; bool m_showing : 1; // used to see if we show a todo in the cases we shouldn't change the table QuickEditBase* m_curQuick; Editor* m_curEdit; TodoShow* currentShow(); TodoShow* m_curShow; TemplateEditor* currentTemplateEditor(); TemplateEditor* m_curTempEd; QMenuBar* m_bar; QToolBar* m_tool; QAction* m_editAction, *m_deleteAction, *m_findAction, *m_completedAction, *m_showDeadLineAction, *m_deleteAllAction, *m_deleteCompleteAction, *m_duplicateAction, *m_showOverDueAction, *m_showQuickTaskAction, *m_effectiveAction; - QWidgetStack *m_stack; + OWidgetStack *m_stack; QPopupMenu* m_catMenu, *m_edit, *m_options, *m_template; bool m_syncing:1; bool m_deadline:1; bool m_completed:1; bool m_overdue:1; bool m_quicktask:1; TodoManager m_todoMgr; QString m_curCat; QList<ViewBase> m_views; uint m_counter; TemplateManager* m_tempManager; private slots: void slotShow(int); void slotEdit(int); void slotUpdate3( QWidget* ); void slotComplete( int uid ); void slotComplete( const OTodo& ev ); void slotNewFromTemplate(int id ); void slotNew(); void slotDuplicate(); void slotDelete(); void slotDelete(int uid ); void slotDeleteAll(); void slotDeleteCompleted(); void slotEdit(); void slotFind(); void setCategory( int ); void slotShowDeadLine( bool ); void slotShowCompleted( bool ); void slotShowQuickTask( bool ); void setDocument( const QString& ); void slotBeam(); void beamDone( Ir* ); void slotShowDetails(); void slotShowNext(); diff --git a/core/pim/todo/tableview.cpp b/core/pim/todo/tableview.cpp index 2e252d5..def0efb 100644 --- a/core/pim/todo/tableview.cpp +++ b/core/pim/todo/tableview.cpp @@ -40,96 +40,97 @@ #include <opie/orecur.h> #include "mainwindow.h" //#include "tableitems.h" #include "tableview.h" using namespace Todo; namespace { static const int BoxSize = 14; static const int RowHeight = 20; } TableView::EditorWidget::EditorWidget() : m_wid(0l), m_row(-1), m_col(-1) { } void TableView::EditorWidget::setCellWidget(QWidget* wid, int row, int col ) { m_wid = wid; m_row = row; m_col = col; } void TableView::EditorWidget::releaseCellWidget() { m_wid = 0; m_row = m_col = -1; } QWidget* TableView::EditorWidget::cellWidget()const { return m_wid; } int TableView::EditorWidget::cellRow()const { return m_row; } int TableView::EditorWidget::cellCol()const { return m_col; } void TableView::initConfig() { Config config( "todo" ); config.setGroup( "Options" ); m_completeStrokeWidth = config.readNumEntry( "CompleteStrokeWidth", 8 ); for (int i = 0; i < numCols(); i++ ) { int width = config.readNumEntry("Width"+QString::number(i), -1 ); setColumnWidth(i, width == -1 ? columnWidth(i) : width ); } } TableView::TableView( MainWindow* window, QWidget* wid ) : QTable( wid ), TodoView( window ) { + setName("TableView"); // Load icons // TODO - probably should be done globally somewhere else, // see also quickeditimpl.cpp/h, taskeditoroverview.cpp/h m_pic_completed = Resource::loadPixmap( "todo/completed" ); QString namestr; for ( unsigned int i = 1; i < 6; i++ ) { namestr = "todo/priority"; namestr.append( QString::number( i ) ); m_pic_priority[ i - 1 ] = Resource::loadPixmap( namestr ); } setUpdatesEnabled( false ); viewport()->setUpdatesEnabled( false ); m_enablePaint = false; setNumRows(0); setNumCols(4); horizontalHeader()->setLabel( 0, QWidget::tr("C.") ); horizontalHeader()->setLabel( 1, QWidget::tr("Priority") ); horizontalHeader()->setLabel( 2, QWidget::tr("Description" ) ); horizontalHeader()->setLabel( 3, QWidget::tr("Deadline") ); setShowDeadline( todoWindow()->showDeadline() ); setSorting( TRUE ); setSelectionMode( NoSelection ); setLeftMargin( 0 ); verticalHeader()->hide(); connect((QTable*)this, SIGNAL( clicked( int, int, int, const QPoint& ) ), this, SLOT( slotClicked(int, int, int, const QPoint& ) ) ); connect((QTable*)this, SIGNAL( pressed( int, int, int, const QPoint& ) ), this, SLOT( slotPressed(int, int, int, const QPoint& ) ) ); connect((QTable*)this, SIGNAL(valueChanged(int, int) ), this, SLOT( slotValueChanged(int, int) ) ); connect((QTable*)this, SIGNAL(currentChanged(int, int) ), this, SLOT( slotCurrentChanged(int, int) ) ); m_menuTimer = new QTimer( this ); connect( m_menuTimer, SIGNAL(timeout()), this, SLOT(slotShowMenu()) ); /* now let's init the config */ initConfig(); m_enablePaint = true; |