author | zecke <zecke> | 2002-04-23 12:45:20 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-04-23 12:45:20 (UTC) |
commit | e25c5384f3f3025be64ed26d244c59afc5862711 (patch) (side-by-side diff) | |
tree | 603f32b0550ecda9cbe95a93807a2a89b32cabcd | |
parent | 367304a610dd618ad45ddce8256ba4d7d8ded442 (diff) | |
download | opie-e25c5384f3f3025be64ed26d244c59afc5862711.zip opie-e25c5384f3f3025be64ed26d244c59afc5862711.tar.gz opie-e25c5384f3f3025be64ed26d244c59afc5862711.tar.bz2 |
Patch from Stefan Eilers for overview
merged by hand
-rw-r--r-- | core/pim/todo/TODO | 3 | ||||
-rw-r--r-- | core/pim/todo/mainwindow.cpp | 68 | ||||
-rw-r--r-- | core/pim/todo/mainwindow.h | 14 | ||||
-rw-r--r-- | core/pim/todo/opie-todo.control | 2 | ||||
-rw-r--r-- | core/pim/todo/todo.pro | 6 | ||||
-rw-r--r-- | core/pim/todo/todolabel.cc | 58 | ||||
-rw-r--r-- | core/pim/todo/todolabel.h | 51 | ||||
-rw-r--r-- | core/pim/todo/todotable.cpp | 10 | ||||
-rw-r--r-- | core/pim/todo/todotable.h | 2 |
9 files changed, 194 insertions, 20 deletions
diff --git a/core/pim/todo/TODO b/core/pim/todo/TODO index 7601dd2..b00450c 100644 --- a/core/pim/todo/TODO +++ b/core/pim/todo/TODO @@ -1,4 +1 @@ --fix the journal (wip ) --fix day wrapping update all DueDateItems -when checking the C. box update the deadline --TodoLabel : public TextView diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp index fc17c5f..d3f4cb4 100644 --- a/core/pim/todo/mainwindow.cpp +++ b/core/pim/todo/mainwindow.cpp @@ -1,212 +1,226 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. - Copyright (C) 2002 zecke - Copyright (C) 2002 Stefan Eilers +** Copyright (C) 2002 zecke +** Copyright (C) 2002 Stefan Eilers (se, eilers.stefan@epost.de) ** ** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #define QTOPIA_INTERNAL_FD #include "mainwindow.h" #include "todoentryimpl.h" #include "todotable.h" +#include "todolabel.h" #include <opie/tododb.h> #include <opie/todovcalresource.h> #include <opie/ofontmenu.h> #include <qpe/qpeapplication.h> #include <qpe/config.h> #include <qpe/finddialog.h> #include <qpe/global.h> #include <qpe/ir.h> #include <qpe/qpemenubar.h> #include <qpe/qpemessagebox.h> #include <qpe/resource.h> //#include <qpe/task.h> #include <qpe/qpetoolbar.h> #include <qaction.h> #include <qarray.h> #include <qdatastream.h> #include <qdatetime.h> #include <qfile.h> #include <qmessagebox.h> #include <qpopupmenu.h> +#include <qwidgetstack.h> #include <sys/stat.h> #include <sys/types.h> #include <fcntl.h> #include <unistd.h> #include <stdlib.h> static QString todolistXMLFilename() { return Global::applicationFileName("todolist","todolist.xml"); } static QString categoriesXMLFilename() { return Global::applicationFileName("todolist","categories.xml"); } TodoWindow::TodoWindow( QWidget *parent, const char *name, WFlags f = 0 ) : QMainWindow( parent, name, f ), syncing(FALSE) { // QTime t; // t.start(); - + mView = 0l; + mStack = new QWidgetStack(this, "main stack"); setCaption( tr("Todo") ); QString str; table = new TodoTable( this ); table->setColumnWidth( 2, 10 ); table->setPaintingEnabled( FALSE ); table->setUpdatesEnabled( FALSE ); table->viewport()->setUpdatesEnabled( FALSE ); { str = todolistXMLFilename(); if ( str.isNull() ) QMessageBox::critical( this, tr("Out of Space"), tr("Unable to create startup files\n" "Free up some space\n" "before you enter any data") ); else table->load( str ); } // repeat for categories... str = categoriesXMLFilename(); if ( str.isNull() ) QMessageBox::critical( this, tr( "Out of Space" ), tr( "Unable to create startup files\n" "Free up some space\n" "before you enter any data") ); - setCentralWidget( table ); + mStack->addWidget(table, 1 ); + mStack->raiseWidget( 1 ); + setCentralWidget( mStack ); setToolBarsMovable( FALSE ); // qDebug("after load: t=%d", t.elapsed() ); Config config( "todo" ); config.setGroup( "View" ); bool complete = config.readBoolEntry( "ShowComplete", true ); table->setShowCompleted( complete ); bool showdeadline = config.readBoolEntry("ShowDeadLine", true); table->setShowDeadline (showdeadline); QString category = config.readEntry( "Category", QString::null ); table->setShowCategory( category ); QPEToolBar *bar = new QPEToolBar( this ); bar->setHorizontalStretchable( TRUE ); QPEMenuBar *mb = new QPEMenuBar( bar ); catMenu = new QPopupMenu( this ); QPopupMenu *edit = new QPopupMenu( this ); QPopupMenu *options = new QPopupMenu(this ); contextMenu = new QPopupMenu( this ); bar = new QPEToolBar( this ); QAction *a = new QAction( tr( "New Task" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); connect( a, SIGNAL( activated() ), this, SLOT( slotNew() ) ); a->addTo( bar ); a->addTo( edit ); a = new QAction( tr( "Edit Task" ), Resource::loadIconSet( "edit" ), QString::null, 0, this, 0 ); connect( a, SIGNAL( activated() ), this, SLOT( slotEdit() ) ); a->addTo( bar ); a->addTo( edit ); a->addTo( contextMenu ); a->setEnabled( FALSE ); editAction = a; + + a = new QAction( QString::null, tr("View Task"), 0, this, 0 ); + a->addTo( edit ); + a->addTo( contextMenu ); + connect( a, SIGNAL( activated() ), + this, SLOT(slotShowDetails() ) ); + edit->insertSeparator(); a = new QAction( tr( "Delete..." ), Resource::loadIconSet( "trash" ), QString::null, 0, this, 0 ); connect( a, SIGNAL( activated() ), this, SLOT( slotDelete() ) ); a->addTo( bar ); a->addTo( edit ); a->addTo( contextMenu ); a->setEnabled( FALSE ); deleteAction = a; // delete All in category is missing.... // set All Done // set All Done in category a = new QAction( QString::null, tr( "Delete all..."), 0, this, 0 ); connect(a, SIGNAL( activated() ), this, SLOT( slotDeleteAll() ) ); a->addTo(edit ); a->setEnabled( FALSE ); deleteAllAction = a; edit->insertSeparator(); a = new QAction( QString::null, tr("Duplicate" ), 0, this, 0 ); connect(a, SIGNAL( activated() ), this, SLOT( slotDuplicate() ) ); a->addTo(edit ); a->setEnabled( FALSE ); duplicateAction = a; - edit->insertSeparator(); + + + if ( Ir::supported() ) { a = new QAction( tr( "Beam" ), Resource::loadPixmap( "beam" ), QString::null, 0, this, 0 ); connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) ); a->addTo( edit ); a->addTo( bar ); } a = new QAction( tr( "Find" ), Resource::loadIconSet( "mag" ), QString::null, 0, this, 0 ); connect( a, SIGNAL( activated() ), this, SLOT( slotFind() ) ); a->addTo( bar ); a->addTo( options ); options->insertSeparator(); if ( table->numRows() ) a->setEnabled( TRUE ); else a->setEnabled( FALSE ); //a->setEnabled( FALSE ); findAction = a; // qDebug("mainwindow #2: t=%d", t.elapsed() ); completedAction = new QAction( QString::null, tr("Completed tasks"), 0, this, 0, TRUE ); showdeadlineAction = new QAction( QString::null, tr( "Show Deadline" ), 0, this, 0, TRUE ); catMenu->setCheckable( true ); populateCategories(); @@ -220,287 +234,309 @@ TodoWindow::TodoWindow( QWidget *parent, const char *name, WFlags f = 0 ) : QList<QWidget> list; list.append(table ); OFontMenu *menu = new OFontMenu(this, "menu",list ); menu->forceSize( table->horizontalHeader(), 10 ); //catMenu->insertItem(tr("Fonts"), menu ); list.clear(); options->insertItem( tr("Fonts"), menu ); mb->insertItem( tr( "Data" ), edit ); mb->insertItem( tr( "Category" ), catMenu ); mb->insertItem( tr( "Options"), options ); resize( 200, 300 ); if ( table->numRows() > 0 ) currentEntryChanged( 0, 0 ); connect( table, SIGNAL( signalEdit() ), this, SLOT( slotEdit() ) ); connect( table, SIGNAL(signalShowMenu(const QPoint &)), this, SLOT( slotShowPopup(const QPoint &)) ); // qDebug("mainwindow #3: t=%d", t.elapsed() ); table->updateVisible(); table->setUpdatesEnabled( TRUE ); table->setPaintingEnabled( TRUE ); table->viewport()->setUpdatesEnabled( TRUE ); connect( completedAction, SIGNAL( toggled(bool) ), this, SLOT( showCompleted(bool) ) ); connect( showdeadlineAction, SIGNAL( toggled(bool) ), this, SLOT( showDeadline(bool) ) ); connect( catMenu, SIGNAL(activated(int)), this, SLOT(setCategory(int)) ); connect( table, SIGNAL( currentChanged( int, int ) ), this, SLOT( currentEntryChanged( int, int ) ) ); + connect( table, SIGNAL(showDetails(const ToDoEvent &) ), + this, SLOT(slotShowDetails(const ToDoEvent & ) ) ); // qDebug("done: t=%d", t.elapsed() ); } void TodoWindow::slotNew() { if(syncing) { QMessageBox::warning(this, tr("Todo"), tr("Can not edit data, currently syncing")); return; } int id; id = -1; QArray<int> ids; ids = table->currentEntry().categories(); if ( ids.count() ) id = ids[0]; NewTaskDialog e( id, this, 0, TRUE ); ToDoEvent todo; #if defined(Q_WS_QWS) || defined(_WS_QWS_) e.showMaximized(); #endif int ret = e.exec(); // qWarning("finished" ); if ( ret == QDialog::Accepted ) { table->setPaintingEnabled( false ); todo = e.todoEntry(); //todo.assignUid(); table->addEntry( todo ); table->setPaintingEnabled( true ); findAction->setEnabled( TRUE ); } // I'm afraid we must call this every time now, otherwise // spend expensive time comparing all these strings... populateCategories(); + mStack->raiseWidget(1 ); } TodoWindow::~TodoWindow() { } void TodoWindow::slotDelete() { if(syncing) { QMessageBox::warning(this, tr("Todo"), tr("Can not edit data, currently syncing")); return; } if ( table->currentRow() == -1 ) return; QString strName = table->text( table->currentRow(), 2 ).left( 30 ); if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), strName ) ) return; table->setPaintingEnabled( false ); table->removeCurrentEntry(); table->setPaintingEnabled( true ); if ( table->numRows() == 0 ) { currentEntryChanged( -1, 0 ); findAction->setEnabled( FALSE ); } + mStack->raiseWidget(1); } void TodoWindow::slotDeleteAll() { if(syncing) { QMessageBox::warning(this, tr("Todo"), tr("Can not edit data, currently syncing")); return; } //QString strName = table->text( table->currentRow(), 2 ).left( 30 ); - if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("Should I delete all tasks?") ) ) + if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("Delete all tasks?") ) ) return; table->setPaintingEnabled( false ); table->removeAllEntries(); table->setPaintingEnabled( true ); if ( table->numRows() == 0 ) { currentEntryChanged( -1, 0 ); findAction->setEnabled( FALSE ); } + mStack->raiseWidget(1 ); } void TodoWindow::slotEdit() { if(syncing) { QMessageBox::warning(this, tr("Todo"), tr("Can not edit data, currently syncing")); return; } ToDoEvent todo = table->currentEntry(); NewTaskDialog e( todo, this, 0, TRUE ); e.setCaption( tr( "Edit Task" ) ); #if defined(Q_WS_QWS) || defined(_WS_QWS_) e.showMaximized(); #endif int ret = e.exec(); if ( ret == QDialog::Accepted ) { table->setPaintingEnabled( false ); todo = e.todoEntry(); table->replaceCurrentEntry( todo ); table->setPaintingEnabled( true ); } populateCategories(); - + mStack->raiseWidget( 1 ); } void TodoWindow::slotDuplicate() { if(syncing) { QMessageBox::warning(this, tr("Todo"), tr("Can not edit data, currently syncing")); return; } ToDoEvent ev = table->currentEntry(); - ToDoEvent ev2 = ToDoEvent( ev ); + ToDoEvent ev2 = ToDoEvent( ev ); // what about the uid + int uid; + { // uid + Qtopia::UidGen *uidgen = new Qtopia::UidGen(); + uid = uidgen->generate(); + delete uidgen; + } + ev2.setUid( uid ); table->setPaintingEnabled( false ); table->addEntry( ev2 ); table->setPaintingEnabled( true ); + + mStack->raiseWidget( 1 ); } void TodoWindow::slotShowPopup( const QPoint &p ) { contextMenu->popup( p ); } void TodoWindow::showCompleted( bool s ) { if ( !table->isUpdatesEnabled() ) return; table->setPaintingEnabled( false ); table->setShowCompleted( s ); table->setPaintingEnabled( true ); } void TodoWindow::currentEntryChanged( int r, int ) { if ( r != -1 && table->rowHeight( r ) > 0 ) { editAction->setEnabled( TRUE ); deleteAction->setEnabled( TRUE ); duplicateAction->setEnabled( TRUE ); deleteAllAction->setEnabled( TRUE ); } else { editAction->setEnabled( FALSE ); deleteAction->setEnabled( FALSE ); duplicateAction->setEnabled( FALSE ); deleteAllAction->setEnabled( FALSE ); } } void TodoWindow::setCategory( int c ) { if ( c <= 0 ) return; if ( !table->isUpdatesEnabled() ) return; table->setPaintingEnabled( false ); for ( unsigned int i = 1; i < catMenu->count(); i++ ) catMenu->setItemChecked( i, c == (int)i ); if ( c == 1 ) { table->setShowCategory( QString::null ); setCaption( tr("Todo") + " - " + tr( "All Categories" ) ); } else if ( c == (int)catMenu->count() - 1 ) { table->setShowCategory( tr( "Unfiled" ) ); setCaption( tr("Todo") + " - " + tr( "Unfiled" ) ); } else { QString cat = table->categories()[c - 2]; table->setShowCategory( cat ); setCaption( tr("Todo") + " - " + cat ); } table->setPaintingEnabled( true ); + + mStack->raiseWidget( 1 ); } void TodoWindow::populateCategories() { catMenu->clear(); int id, rememberId; id = 1; + rememberId = 0; catMenu->insertItem( tr( "All Categories" ), id++ ); catMenu->insertSeparator(); QStringList categories = table->categories(); categories.append( tr( "Unfiled" ) ); for ( QStringList::Iterator it = categories.begin(); it != categories.end(); ++it ) { catMenu->insertItem( *it, id ); if ( *it == table->showCategory() ) rememberId = id; ++id; } if ( table->showCategory().isEmpty() ) setCategory( 1 ); else setCategory( rememberId ); } void TodoWindow::reload() { table->clear(); table->load( todolistXMLFilename() ); syncing = FALSE; } void TodoWindow::flush() { syncing = TRUE; table->save( todolistXMLFilename() ); } void TodoWindow::closeEvent( QCloseEvent *e ) { + if( mStack->visibleWidget() != table ){ + mStack->raiseWidget( 1 ); + e->ignore(); + return; + } if(syncing) { /* no need to save if in the middle of syncing */ e->accept(); return; } if ( table->save( todolistXMLFilename() ) ) { e->accept(); // repeat for categories... // if writing configs fail, it will emit an // error, but I feel that it is "ok" for us to exit // espically since we aren't told if the write succeeded... Config config( "todo" ); config.setGroup( "View" ); config.writeEntry( "ShowComplete", table->showCompleted() ); config.writeEntry( "Category", table->showCategory() ); /* added 20.01.2k2 by se */ config.writeEntry( "ShowDeadLine", table->showDeadline()); } else { if ( QMessageBox::critical( this, tr("Out of space"), 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(); else e->ignore(); } @@ -533,39 +569,53 @@ void TodoWindow::setDocument( const QString &filename ) { if ( filename.find(".vcs") != int(filename.length()) - 4 ) return; ToDoDB todoDB(filename, new ToDoVCalResource() ); QValueList<ToDoEvent> tl = todoDB.rawToDos(); for( QValueList<ToDoEvent>::Iterator it = tl.begin(); it != tl.end(); ++it ) { table->addEntry( *it ); } } static const char * beamfile = "/tmp/obex/todo.vcs"; void TodoWindow::slotBeam() { unlink( beamfile ); // delete if exists ToDoEvent c = table->currentEntry(); mkdir("/tmp/obex/", 0755); ToDoDB todoDB( beamfile, new ToDoVCalResource() ); todoDB.addEvent( c ); todoDB.save(); Ir *ir = new Ir( this ); connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); QString description = c.description(); ir->send( beamfile, description, "text/x-vCalendar" ); } void TodoWindow::beamDone( Ir *ir ) { delete ir; unlink( beamfile ); } -/* added 20.01.2k2 by se */ void TodoWindow::showDeadline( bool s ) { table->setPaintingEnabled( false ); table->setShowDeadline( s ); table->setPaintingEnabled( true ); } +void TodoWindow::slotShowDetails() +{ + ToDoEvent event = table->currentEntry(); + slotShowDetails( event ); +} +void TodoWindow::slotShowDetails( const ToDoEvent &event ) +{ + if( mView == 0l ){ + mView = new TodoLabel(mStack); + mStack->addWidget( mView, 2 ); + } + mView->init( event ); + mView->sync(); + mStack->raiseWidget( 2); +} diff --git a/core/pim/todo/mainwindow.h b/core/pim/todo/mainwindow.h index b9172e1..f62ec6e 100644 --- a/core/pim/todo/mainwindow.h +++ b/core/pim/todo/mainwindow.h @@ -1,86 +1,96 @@ /********************************************************************** - Copyright (C) 2002 Holger 'zecke' Freyther <freyther@kde.org> +** Copyright (C) 2002 Holger 'zecke' Freyther <freyther@kde.org> +** Copyright (C) 2002 by Stefan Eilers (se, eilers.stefan@epost.de) ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of Qtopia and Opi Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #ifndef MAINWINDOW_H #define MAINWINDOW_H #include <qmainwindow.h> class TodoTable; class QAction; class QPopupMenu; class Ir; class OFontMenu; +class TodoLabel; +class ToDoDB; +class QWidgetStack; +class ToDoEvent; class TodoWindow : public QMainWindow { Q_OBJECT public: TodoWindow( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); ~TodoWindow(); public slots: void flush(); void reload(); protected slots: void slotNew(); void slotDelete(); void slotEdit(); void slotShowPopup( const QPoint & ); void showCompleted( bool ); - /* added 20.01.2k2 by se */ void showDeadline( bool ); + void slotShowDetails(const ToDoEvent &event ); + void slotShowDetails(); + void currentEntryChanged( int r, int c ); void setCategory( int ); void slotFind(); void setDocument( const QString & ); void slotBeam(); void beamDone( Ir * ); void slotDeleteAll(); void slotDuplicate(); protected: void closeEvent( QCloseEvent *e ); private: void populateCategories(); + //inline void switchToTable(); // move back to the normal view private: TodoTable *table; + TodoLabel *mView; QAction *editAction, *deleteAction, *findAction, *completedAction, *showdeadlineAction, *deleteAllAction, *duplicateAction; QPopupMenu *contextMenu, *catMenu; + QWidgetStack *mStack; bool syncing; }; #endif diff --git a/core/pim/todo/opie-todo.control b/core/pim/todo/opie-todo.control index cb9b110..71929af 100644 --- a/core/pim/todo/opie-todo.control +++ b/core/pim/todo/opie-todo.control @@ -1,9 +1,9 @@ Files: bin/todolist apps/Applications/todo.desktop Priority: optional Section: opie/applications -Maintainer: Warwick Allison <warwick@trolltech.com> +Maintainer: Holger 'zecke' Freyther <zecke@handhelds.org> Architecture: arm Version: $QPE_VERSION-$SUB_VERSION Depends: opie-base ($QPE_VERSION) Description: TODO-list manager A Todo-list manager for the Opie environment. diff --git a/core/pim/todo/todo.pro b/core/pim/todo/todo.pro index a46fb47..a365081 100644 --- a/core/pim/todo/todo.pro +++ b/core/pim/todo/todo.pro @@ -1,30 +1,32 @@ TEMPLATE = app CONFIG = qt warn_on release DESTDIR = $(OPIEDIR)/bin HEADERS = mainwindow.h \ todotable.h \ - todoentryimpl.h + todoentryimpl.h \ + todolabel.h SOURCES = main.cpp \ mainwindow.cpp \ todotable.cpp \ - todoentryimpl.cpp + todoentryimpl.cpp \ + todolabel.cc INTERFACES = todoentry.ui TARGET = todolist INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe -lopie TRANSLATIONS = ../i18n/pt_BR/todolist.ts TRANSLATIONS += ../i18n/de/todolist.ts TRANSLATIONS += ../i18n/en/todolist.ts TRANSLATIONS += ../i18n/hu/todolist.ts TRANSLATIONS += ../i18n/sl/todolist.ts TRANSLATIONS += ../i18n/pl/todolist.ts TRANSLATIONS += ../i18n/ja/todolist.ts TRANSLATIONS += ../i18n/ko/todolist.ts TRANSLATIONS += ../i18n/no/todolist.ts TRANSLATIONS += ../i18n/zh_CN/todolist.ts TRANSLATIONS += ../i18n/zh_TW/todolist.ts TRANSLATIONS += ../i18n/fr/todolist.ts diff --git a/core/pim/todo/todolabel.cc b/core/pim/todo/todolabel.cc new file mode 100644 index 0000000..4ce3499 --- a/dev/null +++ b/core/pim/todo/todolabel.cc @@ -0,0 +1,58 @@ +/********************************************************************** +** Copyright (C) 2002 by Stefan Eilers (se, eilers.stefan@epost.de) +** Copyright (C) 2002 Holger 'zecke' Freyther <freyther@kde.org> +** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. +** +** This file is part of the Qtopia Environment. +** +** This file may be distributed and/or modified under the terms of the +** GNU General Public License version 2 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +** See http://www.trolltech.com/gpl/ for GPL licensing information. +** +** Contact info@trolltech.com if any conditions of this licensing are +** not clear to you. +** +**********************************************************************/ + + + +#include <qpe/stringutil.h> + +#include <qregexp.h> +#include <qstylesheet.h> + + +#include "todolabel.h" + +TodoLabel::TodoLabel( QWidget *parent, const char *name ) + : QTextView( parent, name ) +{ +} + +TodoLabel::~TodoLabel() +{ +} + +void TodoLabel::init( const ToDoEvent &item ) +{ + m_item = item; +} + +void TodoLabel::sync() +{ + QString text = m_item.richText(); + setText( text ); +} + +void TodoLabel::keyPressEvent( QKeyEvent *e ) +{ + if ( e->key() == Qt::Key_F33 ) { + emit okPressed(); + } +} diff --git a/core/pim/todo/todolabel.h b/core/pim/todo/todolabel.h new file mode 100644 index 0000000..b6d67af --- a/dev/null +++ b/core/pim/todo/todolabel.h @@ -0,0 +1,51 @@ +/********************************************************************** +** Copyright (C) 2002 by Stefan Eilers (se, eilers.stefan@epost.de) +** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. +** +** This file is part of the Qtopia Environment. +** +** This file may be distributed and/or modified under the terms of the +** GNU General Public License version 2 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +** See http://www.trolltech.com/gpl/ for GPL licensing information. +** +** Contact info@trolltech.com if any conditions of this licensing are +** not clear to you. +** +**********************************************************************/ +#ifndef TODOLABEL_H +#define TODOLABEL_H + +#include <opie/todoevent.h> + +#include <qtextview.h> + +class TodoLabel : public QTextView +{ + Q_OBJECT + +public: + TodoLabel( QWidget *parent, const char *name = 0 ); + ~TodoLabel(); + +public slots: + void init( const ToDoEvent &item); + void sync(); + +signals: + void okPressed(); + +protected: + void keyPressEvent( QKeyEvent * ); + +private: + ToDoEvent m_item; + +}; + +#endif diff --git a/core/pim/todo/todotable.cpp b/core/pim/todo/todotable.cpp index d0bc61c..753c036 100644 --- a/core/pim/todo/todotable.cpp +++ b/core/pim/todo/todotable.cpp @@ -279,102 +279,108 @@ void TodoTable::addEntry( const ToDoEvent &todo ) setCurrentCell(row, currentColumn()); updateVisible(); } void TodoTable::slotClicked( int row, int col, int, const QPoint &pos ) { if ( !cellGeometry( row, col ).contains(pos) ) return; // let's switch on the column number... switch ( col ) { case 0: { CheckItem *i = static_cast<CheckItem*>(item( row, col )); if ( i ) { int x = pos.x() - columnPos( col ); int y = pos.y() - rowPos( row ); int w = columnWidth( col ); int h = rowHeight( row ); if ( i && x >= ( w - BoxSize ) / 2 && x <= ( w - BoxSize ) / 2 + BoxSize && y >= ( h - BoxSize ) / 2 && y <= ( h - BoxSize ) / 2 + BoxSize ) { i->toggle(); } emit signalDoneChanged( i->isChecked() ); } } break; case 1: break; case 2: // may as well edit it... // menuTimer->stop(); // emit signalEdit(); - // fall through + // Show detailed view of the selected entry + { + menuTimer->stop(); + ToDoEvent *todo = todoList[static_cast<CheckItem*>(item(row, 0))]; + emit showDetails( *todo ); + } + break; case 3: // may as well edit it... menuTimer->stop(); // emit signalEdit(); break; } } void TodoTable::slotPressed( int row, int col, int, const QPoint &pos ) { if ( col == 2 && cellGeometry( row, col ).contains(pos) ) menuTimer->start( 750, TRUE ); } void TodoTable::slotShowMenu() { emit signalShowMenu( QCursor::pos() ); } void TodoTable::slotCurrentChanged( int, int ) { menuTimer->stop(); } void TodoTable::internalAddEntries( QList<ToDoEvent> &list ) { setNumRows( list.count() ); int row = 0; ToDoEvent *it; for ( it = list.first(); it; it = list.next() ) insertIntoTable( it, row++ ); } ToDoEvent TodoTable::currentEntry() const { - printf ("in currentEntry\n"); + //qWarning ("in currentEntry\n"); QTableItem *i = item( currentRow(), 0 ); if ( !i || rowHeight( currentRow() ) <= 0 ) return ToDoEvent(); ToDoEvent *todo = todoList[(CheckItem*)i]; todo->setCompleted( ( (CheckItem*)item( currentRow(), 0 ) )->isChecked() ); todo->setPriority( ( (ComboItem*)item( currentRow(), 1 ) )->text().toInt() ); return *todo; } void TodoTable::replaceCurrentEntry( const ToDoEvent &todo, bool fromTableItem ) { int row = currentRow(); updateJournal( todo, ACTION_REPLACE); if ( !fromTableItem ) { journalFreeReplaceEntry( todo, row ); updateVisible(); } } void TodoTable::removeCurrentEntry() { ToDoEvent *oldTodo; int row = currentRow(); CheckItem *chk; chk = static_cast<CheckItem*>(item(row, 0 )); if ( !chk ) return; oldTodo = todoList[chk]; todoList.remove( chk ); diff --git a/core/pim/todo/todotable.h b/core/pim/todo/todotable.h index 458e07a..2f6e635 100644 --- a/core/pim/todo/todotable.h +++ b/core/pim/todo/todotable.h @@ -113,65 +113,65 @@ public: bool showCompleted() const { return showComp; } void setShowDeadline (bool sd) {showDeadl = sd; updateVisible();} bool showDeadline() const { return showDeadl;} void setShowCategory( const QString &c ) { showCat = c; updateVisible(); } const QString &showCategory() const { return showCat; } int showCategoryId() const; bool save( const QString &fn ); void load( const QString &fn ); void applyJournal( ); void clear(); void removeCurrentEntry(); void removeAllEntries() { clear(); }; //void removeAllEntriesInCategory(const QString &category ); void setPaintingEnabled( bool e ); virtual void sortColumn( int col, bool ascending, bool /*wholeRows*/ ); // int rowHeight( int ) const; // int rowPos( int row ) const; // virtual int rowAt( int pos ) const; signals: void signalEdit(); void signalDoneChanged( bool b ); void signalPriorityChanged( int i ); void signalShowMenu( const QPoint & ); void signalNotFound(); void signalWrapAround(); - + void showDetails( const ToDoEvent & ); protected: void keyPressEvent( QKeyEvent *e ); private: void updateVisible(); void viewportPaintEvent( QPaintEvent * ); void internalAddEntries( QList<ToDoEvent> &list); inline void insertIntoTable( ToDoEvent *todo, int row ); void updateJournal( const ToDoEvent &todo, journal_action action); void mergeJournal(); void journalFreeReplaceEntry( const ToDoEvent &todo, int row ); void journalFreeRemoveEntry( int row ); inline void realignTable( int row ); void loadFile( const QString &strFile); private slots: void slotClicked( int row, int col, int button, const QPoint &pos ); void slotPressed( int row, int col, int button, const QPoint &pos ); void slotCheckPriority(int row, int col ); void slotCurrentChanged(int row, int col ); void slotDoFind( const QString &findString, bool caseSensetive, bool backwards, int category ); void slotShowMenu(); void rowHeightChanged( int row ); void slotCheckDay(); // check the day private: friend class TodoWindow; QMap<CheckItem*, ToDoEvent *> todoList; QStringList categoryList; bool showComp; |