summaryrefslogtreecommitdiff
authorzecke <zecke>2003-09-06 06:31:13 (UTC)
committer zecke <zecke>2003-09-06 06:31:13 (UTC)
commite06de75edc6c01d97248050030f197bd8f21fb10 (patch) (side-by-side diff)
tree4696ac60c9cdb5fc80c28c862eb856c64b7b7c8c
parenteaf6da2bd05eac392c118c11fd5be1bab8586b6a (diff)
downloadopie-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
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/todo/mainwindow.cpp7
-rw-r--r--core/pim/todo/mainwindow.h4
-rw-r--r--core/pim/todo/tableview.cpp1
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
@@ -24,84 +24,88 @@
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." ) );
@@ -195,65 +199,65 @@ void MainWindow::initActions() {
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;
@@ -376,64 +380,65 @@ void MainWindow::closeEvent( QCloseEvent* e ) {
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 );
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
@@ -15,65 +15,65 @@
    =_        +     =;=|` 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();
@@ -113,65 +113,65 @@ private slots:
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();
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
@@ -56,64 +56,65 @@ 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& ) ) );