-rw-r--r-- | core/pim/todo/mainwindow.cpp | 9 | ||||
-rw-r--r-- | core/pim/todo/mainwindow.h | 2 | ||||
-rw-r--r-- | core/pim/todo/tableview.cpp | 21 | ||||
-rw-r--r-- | core/pim/todo/tableview.h | 1 | ||||
-rw-r--r-- | core/pim/todo/textviewshow.cpp | 17 | ||||
-rw-r--r-- | core/pim/todo/textviewshow.h | 5 | ||||
-rw-r--r-- | core/pim/todo/todoshow.cpp | 9 | ||||
-rw-r--r-- | core/pim/todo/todoshow.h | 7 |
8 files changed, 58 insertions, 13 deletions
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp index c90166b..d328558 100644 --- a/core/pim/todo/mainwindow.cpp +++ b/core/pim/todo/mainwindow.cpp @@ -77,29 +77,29 @@ MainWindow::MainWindow( QWidget* parent, 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() ) ); @@ -242,25 +242,25 @@ void MainWindow::initViews() { 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); + m_curShow = new TextViewShow(this, this); m_stack->addWidget( m_curShow->widget() , m_counter++ ); } MainWindow::~MainWindow() { delete templateManager(); } void MainWindow::connectBase( ViewBase* ) { // once templates and signals mix we'll use it again } QPopupMenu* MainWindow::contextMenu( int , bool recur ) { QPopupMenu* menu = new QPopupMenu(); m_editAction->addTo( menu ); @@ -804,12 +804,15 @@ void MainWindow::add( const OPimRecord& rec) { const OTodo& todo = static_cast<const OTodo&>(rec); m_todoMgr.add(todo ); currentView()->addEvent( todo ); // I'm afraid we must call this every time now, otherwise // spend expensive time comparing all these strings... // but only call if we changed something -zecke populateCategories(); } +void MainWindow::slotReturnFromView() { + raiseCurrentView(); +} diff --git a/core/pim/todo/mainwindow.h b/core/pim/todo/mainwindow.h index d756d64..f880505 100644 --- a/core/pim/todo/mainwindow.h +++ b/core/pim/todo/mainwindow.h @@ -51,24 +51,25 @@ 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: MainWindow( QWidget *parent = 0, const char* name = 0 ); ~MainWindow(); /** return a context menu for an OTodo */ QPopupMenu* contextMenu(int uid, bool doesRecur = FALSE ); QPopupMenu* options(); QPopupMenu* edit(); QToolBar* toolbar(); @@ -174,24 +175,25 @@ private slots: void slotShowDeadLine( bool ); void slotShowCompleted( bool ); void slotShowQuickTask( bool ); void setDocument( const QString& ); void slotBeam(); void beamDone( Ir* ); void slotShowDetails(); void slotShowDue( bool ); + void slotReturnFromView(); // for TodoShow... /* reimplementation from opimmainwindow */ protected slots: void flush(); void reload(); int create(); bool remove( int uid ); void beam(int uid, int transport = IrDa ); void show( int uid ); void edit( int uid ); void add( const OPimRecord& ); }; }; diff --git a/core/pim/todo/tableview.cpp b/core/pim/todo/tableview.cpp index 61d1edd..cec8b5e 100644 --- a/core/pim/todo/tableview.cpp +++ b/core/pim/todo/tableview.cpp @@ -50,52 +50,52 @@ namespace { static const int RowHeight = 20; } void TableView::initConfig() { Config config( "todo" ); config.setGroup( "Options" ); m_completeStrokeWidth = config.readNumEntry( "CompleteStrokeWidth", 8 ); } TableView::TableView( MainWindow* window, QWidget* wid ) : QTable( wid ), TodoView( window ) { - + // 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) ) ); @@ -359,25 +359,25 @@ void TableView::paintCell(QPainter* p, int row, int col, const QRect& cr, bool int marg = ( cr.width() - BoxSize ) / 2; int x = 0; int y = ( cr.height() - BoxSize ) / 2; switch(col) { case 0: // completed field { //p->setPen( QPen( cg.text() ) ); //p->drawRect( x + marg, y, BoxSize, BoxSize ); //p->drawRect( x + marg+1, y+1, BoxSize-2, BoxSize-2 ); if ( task.isCompleted() ) { p->drawPixmap( x + marg, y, m_pic_completed ); - } + } } break; case 1: // priority field { p->drawPixmap( x + marg, y, m_pic_priority[ task.priority() - 1 ] ); } break; case 2: // description field { QString text = task.summary().isEmpty() ? task.description().left(20) : task.summary(); @@ -460,25 +460,25 @@ void TableView::setCellContentFromEditor(int row, int col ) { } } void TableView::slotPriority() { setCellContentFromEditor( currentRow(), currentColumn() ); } /* * We'll use the TimerEvent to read ahead or to keep the cahce always * filled enough. * We will try to read ahead 4 items in both ways * up and down. On odd or even we will currentRow()+-4 or +-9 * */ -void TableView::timerEvent( QTimerEvent* ev ) { +void TableView::timerEvent( QTimerEvent* ) { // qWarning("sorted %d", sorted().count() ); if (sorted().count() == 0 ) return; int row = currentRow(); if ( m_row ) { int ro = row-4; if (ro < 0 ) ro = 0; sorted()[ro]; ro = row+4; sorted()[ro]; @@ -521,12 +521,23 @@ void TableView::contentsMouseReleaseEvent( QMouseEvent* e) { qWarning("colNew: %d colOld: %d", colNew, colOld ); if ( row == rowAt( e->y() ) && row != -1 && colOld != colNew ) { TodoView::complete( sorted()[row] ); return; } QTable::contentsMouseReleaseEvent( e ); } void TableView::contentsMouseMoveEvent( QMouseEvent* e ) { m_menuTimer->stop(); QTable::contentsMouseMoveEvent( e ); } +void TableView::keyPressEvent( QKeyEvent* event) { + switch( event->key() ) { + case Qt::Key_F33: + case Qt::Key_Enter: + case Qt::Key_Return: + showTodo( sorted().uidAt( currentRow() ) ); + break; + default: + QTable::keyPressEvent( event ); + } +} diff --git a/core/pim/todo/tableview.h b/core/pim/todo/tableview.h index 2b6ea2b..689c496 100644 --- a/core/pim/todo/tableview.h +++ b/core/pim/todo/tableview.h @@ -76,24 +76,25 @@ namespace Todo { private: /* reimplented for internal reasons */ void viewportPaintEvent( QPaintEvent* ); QTimer *m_menuTimer; bool m_enablePaint:1; QString m_oleCat; bool m_first : 1; QPixmap m_pic_completed; QPixmap m_pic_priority[ 5 ]; protected: + void keyPressEvent( QKeyEvent* ); void contentsMouseReleaseEvent( QMouseEvent* ); void contentsMouseMoveEvent( QMouseEvent* ); void timerEvent( QTimerEvent* e ); QWidget* createEditor(int row, int col, bool initFromCell )const; void setCellContentFromEditor( int row, int col ); private slots: void slotShowMenu(); void slotClicked(int, int, int, const QPoint& ); void slotPressed(int, int, int, const QPoint& ); diff --git a/core/pim/todo/textviewshow.cpp b/core/pim/todo/textviewshow.cpp index 24c8c0e..fe8a9c8 100644 --- a/core/pim/todo/textviewshow.cpp +++ b/core/pim/todo/textviewshow.cpp @@ -1,19 +1,32 @@ +#include "mainwindow.h" #include "textviewshow.h" using namespace Todo; -TextViewShow::TextViewShow( QWidget* parent) - : QTextView( parent ), TodoShow() { +TextViewShow::TextViewShow( QWidget* parent, MainWindow* win) + : QTextView( parent ), TodoShow(win) { } TextViewShow::~TextViewShow() { } QString TextViewShow::type()const { return QString::fromLatin1("TextViewShow"); } void TextViewShow::slotShow( const OTodo& ev ) { setText( ev.toRichText() ); } QWidget* TextViewShow::widget() { return this; } +void TextViewShow::keyPressEvent( QKeyEvent* event ) { + switch( event->key() ) { + case Qt::Key_F33: + case Qt::Key_Enter: + case Qt::Key_Return: + escapeView(); + break; + default: + QTextView::keyPressEvent( event ); + break; + } +} diff --git a/core/pim/todo/textviewshow.h b/core/pim/todo/textviewshow.h index f58026b..498de81 100644 --- a/core/pim/todo/textviewshow.h +++ b/core/pim/todo/textviewshow.h @@ -1,17 +1,20 @@ #include <qtextview.h> #include "todoshow.h" namespace Todo { class TextViewShow : public QTextView, public TodoShow { public: - TextViewShow( QWidget* parent ); + TextViewShow( QWidget* parent, MainWindow* ); ~TextViewShow(); QString type()const; void slotShow( const OTodo& ev ); QWidget* widget(); + protected: + void keyPressEvent( QKeyEvent* ); + }; }; diff --git a/core/pim/todo/todoshow.cpp b/core/pim/todo/todoshow.cpp index c84a08f..4dbc9aa 100644 --- a/core/pim/todo/todoshow.cpp +++ b/core/pim/todo/todoshow.cpp @@ -1,9 +1,16 @@ + +#include "mainwindow.h" #include "todoshow.h" using namespace Todo; -TodoShow::TodoShow() { +TodoShow::TodoShow(MainWindow* win) { + m_win = win; } TodoShow::~TodoShow() { } +void TodoShow::escapeView() { + if (m_win ) + m_win->slotReturnFromView(); +} diff --git a/core/pim/todo/todoshow.h b/core/pim/todo/todoshow.h index 198e9ae..7267b13 100644 --- a/core/pim/todo/todoshow.h +++ b/core/pim/todo/todoshow.h @@ -25,29 +25,34 @@ Boston, MA 02111-1307, USA. */ #ifndef TODO_TODO_SHOW_H #define TODO_TODO_SHOW_H #include <qstring.h> #include <qwidget.h> #include <opie/otodo.h> namespace Todo { + class MainWindow; /** * TodoShow is the baseclass of * of all TodoShows. * The first implementation is a QTextView * implementation showing the Todo as richtext */ class TodoShow { public: - TodoShow(); + TodoShow( MainWindow* win); virtual ~TodoShow(); virtual QString type()const = 0; virtual void slotShow( const OTodo& ev ) = 0; virtual QWidget* widget() = 0; + protected: + void escapeView(); + private: + MainWindow *m_win; }; }; #endif |