-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 | |||
@@ -81,21 +81,21 @@ MainWindow::MainWindow( QWidget* parent, | |||
81 | populateTemplates(); | 81 | populateTemplates(); |
82 | raiseCurrentView(); | 82 | raiseCurrentView(); |
83 | QTimer::singleShot(0, this, SLOT(populateCategories() ) ); | 83 | QTimer::singleShot(0, this, SLOT(populateCategories() ) ); |
84 | } | 84 | } |
85 | void MainWindow::initTemplate() { | 85 | void MainWindow::initTemplate() { |
86 | m_curTempEd = new TemplateEditor( this, templateManager() ); | 86 | m_curTempEd = new TemplateEditor( this, templateManager() ); |
87 | } | 87 | } |
88 | void MainWindow::initActions() { | 88 | void MainWindow::initActions() { |
89 | 89 | ||
90 | // Data menu | 90 | // Data menu |
91 | m_edit->insertItem(QWidget::tr("New from template"), m_template, | 91 | m_edit->insertItem(QWidget::tr("New from template"), m_template, |
92 | -1, 0 ); | 92 | -1, 0 ); |
93 | 93 | ||
94 | QAction* a = new QAction( QWidget::tr("New Task" ), Resource::loadPixmap( "new" ), | 94 | QAction* a = new QAction( QWidget::tr("New Task" ), Resource::loadPixmap( "new" ), |
95 | QString::null, 0, this, 0 ); | 95 | QString::null, 0, this, 0 ); |
96 | connect(a, SIGNAL( activated() ), | 96 | connect(a, SIGNAL( activated() ), |
97 | this, SLOT( slotNew() ) ); | 97 | this, SLOT( slotNew() ) ); |
98 | a->setWhatsThis( QWidget::tr( "Click here to create a new task." ) ); | 98 | a->setWhatsThis( QWidget::tr( "Click here to create a new task." ) ); |
99 | a->addTo(m_tool ); | 99 | a->addTo(m_tool ); |
100 | a->addTo(m_edit ); | 100 | a->addTo(m_edit ); |
101 | 101 | ||
@@ -246,17 +246,17 @@ void MainWindow::initViews() { | |||
246 | * the View menu | 246 | * the View menu |
247 | * and subdirs for multiple views | 247 | * and subdirs for multiple views |
248 | */ | 248 | */ |
249 | } | 249 | } |
250 | void MainWindow::initEditor() { | 250 | void MainWindow::initEditor() { |
251 | m_curEdit = new Editor(); | 251 | m_curEdit = new Editor(); |
252 | } | 252 | } |
253 | void MainWindow::initShow() { | 253 | void MainWindow::initShow() { |
254 | m_curShow = new TextViewShow(this); | 254 | m_curShow = new TextViewShow(this, this); |
255 | m_stack->addWidget( m_curShow->widget() , m_counter++ ); | 255 | m_stack->addWidget( m_curShow->widget() , m_counter++ ); |
256 | } | 256 | } |
257 | MainWindow::~MainWindow() { | 257 | MainWindow::~MainWindow() { |
258 | delete templateManager(); | 258 | delete templateManager(); |
259 | } | 259 | } |
260 | void MainWindow::connectBase( ViewBase* ) { | 260 | void MainWindow::connectBase( ViewBase* ) { |
261 | // once templates and signals mix we'll use it again | 261 | // once templates and signals mix we'll use it again |
262 | } | 262 | } |
@@ -808,8 +808,11 @@ void MainWindow::add( const OPimRecord& rec) { | |||
808 | currentView()->addEvent( todo ); | 808 | currentView()->addEvent( todo ); |
809 | 809 | ||
810 | 810 | ||
811 | // I'm afraid we must call this every time now, otherwise | 811 | // I'm afraid we must call this every time now, otherwise |
812 | // spend expensive time comparing all these strings... | 812 | // spend expensive time comparing all these strings... |
813 | // but only call if we changed something -zecke | 813 | // but only call if we changed something -zecke |
814 | populateCategories(); | 814 | populateCategories(); |
815 | } | 815 | } |
816 | void MainWindow::slotReturnFromView() { | ||
817 | raiseCurrentView(); | ||
818 | } | ||
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 | |||
@@ -55,16 +55,17 @@ namespace Todo { | |||
55 | class Editor; | 55 | class Editor; |
56 | class TodoShow; | 56 | class TodoShow; |
57 | class TemplateEditor; | 57 | class TemplateEditor; |
58 | struct QuickEditBase; | 58 | struct QuickEditBase; |
59 | 59 | ||
60 | class MainWindow : public OPimMainWindow { | 60 | class MainWindow : public OPimMainWindow { |
61 | Q_OBJECT | 61 | Q_OBJECT |
62 | friend class TodoView; // avoid QObject here.... | 62 | friend class TodoView; // avoid QObject here.... |
63 | friend class TodoShow; // avoid QObject | ||
63 | public: | 64 | public: |
64 | MainWindow( QWidget *parent = 0, | 65 | MainWindow( QWidget *parent = 0, |
65 | const char* name = 0 ); | 66 | const char* name = 0 ); |
66 | ~MainWindow(); | 67 | ~MainWindow(); |
67 | 68 | ||
68 | /** return a context menu for an OTodo */ | 69 | /** return a context menu for an OTodo */ |
69 | QPopupMenu* contextMenu(int uid, bool doesRecur = FALSE ); | 70 | QPopupMenu* contextMenu(int uid, bool doesRecur = FALSE ); |
70 | QPopupMenu* options(); | 71 | QPopupMenu* options(); |
@@ -178,16 +179,17 @@ private slots: | |||
178 | 179 | ||
179 | void setDocument( const QString& ); | 180 | void setDocument( const QString& ); |
180 | 181 | ||
181 | 182 | ||
182 | void slotBeam(); | 183 | void slotBeam(); |
183 | void beamDone( Ir* ); | 184 | void beamDone( Ir* ); |
184 | void slotShowDetails(); | 185 | void slotShowDetails(); |
185 | void slotShowDue( bool ); | 186 | void slotShowDue( bool ); |
187 | void slotReturnFromView(); // for TodoShow... | ||
186 | /* reimplementation from opimmainwindow */ | 188 | /* reimplementation from opimmainwindow */ |
187 | protected slots: | 189 | protected slots: |
188 | void flush(); | 190 | void flush(); |
189 | void reload(); | 191 | void reload(); |
190 | int create(); | 192 | int create(); |
191 | bool remove( int uid ); | 193 | bool remove( int uid ); |
192 | void beam(int uid, int transport = IrDa ); | 194 | void beam(int uid, int transport = IrDa ); |
193 | void show( int uid ); | 195 | void show( int uid ); |
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 | |||
@@ -54,17 +54,17 @@ namespace { | |||
54 | void TableView::initConfig() { | 54 | void TableView::initConfig() { |
55 | Config config( "todo" ); | 55 | Config config( "todo" ); |
56 | config.setGroup( "Options" ); | 56 | config.setGroup( "Options" ); |
57 | m_completeStrokeWidth = config.readNumEntry( "CompleteStrokeWidth", 8 ); | 57 | m_completeStrokeWidth = config.readNumEntry( "CompleteStrokeWidth", 8 ); |
58 | } | 58 | } |
59 | 59 | ||
60 | TableView::TableView( MainWindow* window, QWidget* wid ) | 60 | TableView::TableView( MainWindow* window, QWidget* wid ) |
61 | : QTable( wid ), TodoView( window ) { | 61 | : QTable( wid ), TodoView( window ) { |
62 | 62 | ||
63 | // Load icons | 63 | // Load icons |
64 | // TODO - probably should be done globally somewhere else, | 64 | // TODO - probably should be done globally somewhere else, |
65 | // see also quickeditimpl.cpp/h, taskeditoroverview.cpp/h | 65 | // see also quickeditimpl.cpp/h, taskeditoroverview.cpp/h |
66 | m_pic_completed = Resource::loadPixmap( "todo/completed" ); | 66 | m_pic_completed = Resource::loadPixmap( "todo/completed" ); |
67 | QString namestr; | 67 | QString namestr; |
68 | for ( unsigned int i = 1; i < 6; i++ ) { | 68 | for ( unsigned int i = 1; i < 6; i++ ) { |
69 | namestr = "todo/priority"; | 69 | namestr = "todo/priority"; |
70 | namestr.append( QString::number( i ) ); | 70 | namestr.append( QString::number( i ) ); |
@@ -78,20 +78,20 @@ TableView::TableView( MainWindow* window, QWidget* wid ) | |||
78 | setNumCols(4); | 78 | setNumCols(4); |
79 | 79 | ||
80 | horizontalHeader()->setLabel( 0, QWidget::tr("C.") ); | 80 | horizontalHeader()->setLabel( 0, QWidget::tr("C.") ); |
81 | horizontalHeader()->setLabel( 1, QWidget::tr("Priority") ); | 81 | horizontalHeader()->setLabel( 1, QWidget::tr("Priority") ); |
82 | horizontalHeader()->setLabel( 2, QWidget::tr("Description" ) ); | 82 | horizontalHeader()->setLabel( 2, QWidget::tr("Description" ) ); |
83 | horizontalHeader()->setLabel( 3, QWidget::tr("Deadline") ); | 83 | horizontalHeader()->setLabel( 3, QWidget::tr("Deadline") ); |
84 | 84 | ||
85 | setShowDeadline( todoWindow()->showDeadline() ); | 85 | setShowDeadline( todoWindow()->showDeadline() ); |
86 | 86 | ||
87 | setSorting( TRUE ); | 87 | setSorting( TRUE ); |
88 | setSelectionMode( NoSelection ); | 88 | setSelectionMode( NoSelection ); |
89 | 89 | ||
90 | setLeftMargin( 0 ); | 90 | setLeftMargin( 0 ); |
91 | verticalHeader()->hide(); | 91 | verticalHeader()->hide(); |
92 | 92 | ||
93 | connect((QTable*)this, SIGNAL( clicked( int, int, int, const QPoint& ) ), | 93 | connect((QTable*)this, SIGNAL( clicked( int, int, int, const QPoint& ) ), |
94 | this, SLOT( slotClicked(int, int, int, const QPoint& ) ) ); | 94 | this, SLOT( slotClicked(int, int, int, const QPoint& ) ) ); |
95 | connect((QTable*)this, SIGNAL( pressed( int, int, int, const QPoint& ) ), | 95 | connect((QTable*)this, SIGNAL( pressed( int, int, int, const QPoint& ) ), |
96 | this, SLOT( slotPressed(int, int, int, const QPoint& ) ) ); | 96 | this, SLOT( slotPressed(int, int, int, const QPoint& ) ) ); |
97 | connect((QTable*)this, SIGNAL(valueChanged(int, int) ), | 97 | connect((QTable*)this, SIGNAL(valueChanged(int, int) ), |
@@ -363,17 +363,17 @@ void TableView::paintCell(QPainter* p, int row, int col, const QRect& cr, bool | |||
363 | switch(col) { | 363 | switch(col) { |
364 | case 0: // completed field | 364 | case 0: // completed field |
365 | { | 365 | { |
366 | //p->setPen( QPen( cg.text() ) ); | 366 | //p->setPen( QPen( cg.text() ) ); |
367 | //p->drawRect( x + marg, y, BoxSize, BoxSize ); | 367 | //p->drawRect( x + marg, y, BoxSize, BoxSize ); |
368 | //p->drawRect( x + marg+1, y+1, BoxSize-2, BoxSize-2 ); | 368 | //p->drawRect( x + marg+1, y+1, BoxSize-2, BoxSize-2 ); |
369 | if ( task.isCompleted() ) { | 369 | if ( task.isCompleted() ) { |
370 | p->drawPixmap( x + marg, y, m_pic_completed ); | 370 | p->drawPixmap( x + marg, y, m_pic_completed ); |
371 | } | 371 | } |
372 | } | 372 | } |
373 | break; | 373 | break; |
374 | case 1: // priority field | 374 | case 1: // priority field |
375 | { | 375 | { |
376 | p->drawPixmap( x + marg, y, m_pic_priority[ task.priority() - 1 ] ); | 376 | p->drawPixmap( x + marg, y, m_pic_priority[ task.priority() - 1 ] ); |
377 | } | 377 | } |
378 | break; | 378 | break; |
379 | case 2: // description field | 379 | case 2: // description field |
@@ -464,17 +464,17 @@ void TableView::slotPriority() { | |||
464 | } | 464 | } |
465 | /* | 465 | /* |
466 | * We'll use the TimerEvent to read ahead or to keep the cahce always | 466 | * We'll use the TimerEvent to read ahead or to keep the cahce always |
467 | * filled enough. | 467 | * filled enough. |
468 | * We will try to read ahead 4 items in both ways | 468 | * We will try to read ahead 4 items in both ways |
469 | * up and down. On odd or even we will currentRow()+-4 or +-9 | 469 | * up and down. On odd or even we will currentRow()+-4 or +-9 |
470 | * | 470 | * |
471 | */ | 471 | */ |
472 | void TableView::timerEvent( QTimerEvent* ev ) { | 472 | void TableView::timerEvent( QTimerEvent* ) { |
473 | // qWarning("sorted %d", sorted().count() ); | 473 | // qWarning("sorted %d", sorted().count() ); |
474 | if (sorted().count() == 0 ) | 474 | if (sorted().count() == 0 ) |
475 | return; | 475 | return; |
476 | 476 | ||
477 | int row = currentRow(); | 477 | int row = currentRow(); |
478 | if ( m_row ) { | 478 | if ( m_row ) { |
479 | int ro = row-4; | 479 | int ro = row-4; |
480 | if (ro < 0 ) ro = 0; | 480 | if (ro < 0 ) ro = 0; |
@@ -525,8 +525,19 @@ void TableView::contentsMouseReleaseEvent( QMouseEvent* e) { | |||
525 | return; | 525 | return; |
526 | } | 526 | } |
527 | QTable::contentsMouseReleaseEvent( e ); | 527 | QTable::contentsMouseReleaseEvent( e ); |
528 | } | 528 | } |
529 | void TableView::contentsMouseMoveEvent( QMouseEvent* e ) { | 529 | void TableView::contentsMouseMoveEvent( QMouseEvent* e ) { |
530 | m_menuTimer->stop(); | 530 | m_menuTimer->stop(); |
531 | QTable::contentsMouseMoveEvent( e ); | 531 | QTable::contentsMouseMoveEvent( e ); |
532 | } | 532 | } |
533 | void TableView::keyPressEvent( QKeyEvent* event) { | ||
534 | switch( event->key() ) { | ||
535 | case Qt::Key_F33: | ||
536 | case Qt::Key_Enter: | ||
537 | case Qt::Key_Return: | ||
538 | showTodo( sorted().uidAt( currentRow() ) ); | ||
539 | break; | ||
540 | default: | ||
541 | QTable::keyPressEvent( event ); | ||
542 | } | ||
543 | } | ||
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 | |||
@@ -80,16 +80,17 @@ namespace Todo { | |||
80 | bool m_enablePaint:1; | 80 | bool m_enablePaint:1; |
81 | QString m_oleCat; | 81 | QString m_oleCat; |
82 | bool m_first : 1; | 82 | bool m_first : 1; |
83 | 83 | ||
84 | QPixmap m_pic_completed; | 84 | QPixmap m_pic_completed; |
85 | QPixmap m_pic_priority[ 5 ]; | 85 | QPixmap m_pic_priority[ 5 ]; |
86 | 86 | ||
87 | protected: | 87 | protected: |
88 | void keyPressEvent( QKeyEvent* ); | ||
88 | void contentsMouseReleaseEvent( QMouseEvent* ); | 89 | void contentsMouseReleaseEvent( QMouseEvent* ); |
89 | void contentsMouseMoveEvent( QMouseEvent* ); | 90 | void contentsMouseMoveEvent( QMouseEvent* ); |
90 | void timerEvent( QTimerEvent* e ); | 91 | void timerEvent( QTimerEvent* e ); |
91 | QWidget* createEditor(int row, int col, bool initFromCell )const; | 92 | QWidget* createEditor(int row, int col, bool initFromCell )const; |
92 | void setCellContentFromEditor( int row, int col ); | 93 | void setCellContentFromEditor( int row, int col ); |
93 | 94 | ||
94 | private slots: | 95 | private slots: |
95 | void slotShowMenu(); | 96 | void slotShowMenu(); |
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 @@ | |||
1 | #include "mainwindow.h" | ||
1 | #include "textviewshow.h" | 2 | #include "textviewshow.h" |
2 | 3 | ||
3 | using namespace Todo; | 4 | using namespace Todo; |
4 | 5 | ||
5 | TextViewShow::TextViewShow( QWidget* parent) | 6 | TextViewShow::TextViewShow( QWidget* parent, MainWindow* win) |
6 | : QTextView( parent ), TodoShow() { | 7 | : QTextView( parent ), TodoShow(win) { |
7 | 8 | ||
8 | } | 9 | } |
9 | TextViewShow::~TextViewShow() { | 10 | TextViewShow::~TextViewShow() { |
10 | } | 11 | } |
11 | QString TextViewShow::type()const { | 12 | QString TextViewShow::type()const { |
12 | return QString::fromLatin1("TextViewShow"); | 13 | return QString::fromLatin1("TextViewShow"); |
13 | } | 14 | } |
14 | void TextViewShow::slotShow( const OTodo& ev ) { | 15 | void TextViewShow::slotShow( const OTodo& ev ) { |
15 | setText( ev.toRichText() ); | 16 | setText( ev.toRichText() ); |
16 | } | 17 | } |
17 | QWidget* TextViewShow::widget() { | 18 | QWidget* TextViewShow::widget() { |
18 | return this; | 19 | return this; |
19 | } | 20 | } |
21 | void TextViewShow::keyPressEvent( QKeyEvent* event ) { | ||
22 | switch( event->key() ) { | ||
23 | case Qt::Key_F33: | ||
24 | case Qt::Key_Enter: | ||
25 | case Qt::Key_Return: | ||
26 | escapeView(); | ||
27 | break; | ||
28 | default: | ||
29 | QTextView::keyPressEvent( event ); | ||
30 | break; | ||
31 | } | ||
32 | } | ||
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 @@ | |||
1 | #include <qtextview.h> | 1 | #include <qtextview.h> |
2 | 2 | ||
3 | #include "todoshow.h" | 3 | #include "todoshow.h" |
4 | 4 | ||
5 | namespace Todo { | 5 | namespace Todo { |
6 | 6 | ||
7 | class TextViewShow : public QTextView, public TodoShow { | 7 | class TextViewShow : public QTextView, public TodoShow { |
8 | public: | 8 | public: |
9 | TextViewShow( QWidget* parent ); | 9 | TextViewShow( QWidget* parent, MainWindow* ); |
10 | ~TextViewShow(); | 10 | ~TextViewShow(); |
11 | 11 | ||
12 | QString type()const; | 12 | QString type()const; |
13 | void slotShow( const OTodo& ev ); | 13 | void slotShow( const OTodo& ev ); |
14 | QWidget* widget(); | 14 | QWidget* widget(); |
15 | 15 | ||
16 | protected: | ||
17 | void keyPressEvent( QKeyEvent* ); | ||
18 | |||
16 | }; | 19 | }; |
17 | }; | 20 | }; |
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 @@ | |||
1 | |||
2 | #include "mainwindow.h" | ||
1 | #include "todoshow.h" | 3 | #include "todoshow.h" |
2 | 4 | ||
3 | using namespace Todo; | 5 | using namespace Todo; |
4 | 6 | ||
5 | TodoShow::TodoShow() { | 7 | TodoShow::TodoShow(MainWindow* win) { |
8 | m_win = win; | ||
6 | } | 9 | } |
7 | TodoShow::~TodoShow() { | 10 | TodoShow::~TodoShow() { |
8 | } | 11 | } |
12 | void TodoShow::escapeView() { | ||
13 | if (m_win ) | ||
14 | m_win->slotReturnFromView(); | ||
15 | } | ||
9 | 16 | ||
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 | |||
@@ -29,25 +29,30 @@ | |||
29 | #define TODO_TODO_SHOW_H | 29 | #define TODO_TODO_SHOW_H |
30 | 30 | ||
31 | #include <qstring.h> | 31 | #include <qstring.h> |
32 | #include <qwidget.h> | 32 | #include <qwidget.h> |
33 | 33 | ||
34 | #include <opie/otodo.h> | 34 | #include <opie/otodo.h> |
35 | 35 | ||
36 | namespace Todo { | 36 | namespace Todo { |
37 | class MainWindow; | ||
37 | /** | 38 | /** |
38 | * TodoShow is the baseclass of | 39 | * TodoShow is the baseclass of |
39 | * of all TodoShows. | 40 | * of all TodoShows. |
40 | * The first implementation is a QTextView | 41 | * The first implementation is a QTextView |
41 | * implementation showing the Todo as richtext | 42 | * implementation showing the Todo as richtext |
42 | */ | 43 | */ |
43 | class TodoShow { | 44 | class TodoShow { |
44 | public: | 45 | public: |
45 | TodoShow(); | 46 | TodoShow( MainWindow* win); |
46 | virtual ~TodoShow(); | 47 | virtual ~TodoShow(); |
47 | virtual QString type()const = 0; | 48 | virtual QString type()const = 0; |
48 | virtual void slotShow( const OTodo& ev ) = 0; | 49 | virtual void slotShow( const OTodo& ev ) = 0; |
49 | virtual QWidget* widget() = 0; | 50 | virtual QWidget* widget() = 0; |
51 | protected: | ||
52 | void escapeView(); | ||
53 | private: | ||
54 | MainWindow *m_win; | ||
50 | }; | 55 | }; |
51 | }; | 56 | }; |
52 | 57 | ||
53 | #endif | 58 | #endif |