summaryrefslogtreecommitdiff
path: root/core/pim/todo/tableview.cpp
Unidiff
Diffstat (limited to 'core/pim/todo/tableview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/todo/tableview.cpp88
1 files changed, 34 insertions, 54 deletions
diff --git a/core/pim/todo/tableview.cpp b/core/pim/todo/tableview.cpp
index 221faca..c64ad46 100644
--- a/core/pim/todo/tableview.cpp
+++ b/core/pim/todo/tableview.cpp
@@ -1,28 +1,28 @@
1/* 1/*
2               =. This file is part of the OPIE Project 2 =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 <zecke> 3 .=l. Copyright (c) 2002 <zecke>
4           .>+-= 4 .>+-=
5 _;:,     .>    :=|. This program is free software; you can 5_;:, .> :=|. This program is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under 6.> <`_, > . <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU General Public 7:`=1 )Y*s>-.-- : the terms of the GNU General Public
8.="- .-=="i,     .._ License as published by the Free Software 8.="- .-=="i, .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License, 9- . .-<_> .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version. 10 ._= =} : or (at your option) any later version.
11    .%`+i>       _;_. 11 .%`+i> _;_.
12    .i_,=:_.      -<s. This program is distributed in the hope that 12 .i_,=:_. -<s. This program is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 13 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of 14 : .. .:, . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 15 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 16 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more 17..}^=.= = ; Library General Public License for more
18++=   -.     .`     .: details. 18++= -. .` .: details.
19 :     =  ...= . :.=- 19: = ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU 20-. .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = Library General Public License along with 21 -_. . . )=. = Library General Public License along with
22    --        :-=` this library; see the file COPYING.LIB. 22 -- :-=` this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation, 23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330, 24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28#include <stdlib.h> 28#include <stdlib.h>
@@ -30,17 +30,17 @@
30#include <cctype> 30#include <cctype>
31 31
32#include <opie2/odebug.h> 32#include <opie2/odebug.h>
33#include <opie2/opimrecurrence.h> 33#include <opie2/opimrecurrence.h>
34 34
35#include <qpe/config.h> 35#include <qpe/config.h>
36#include <qpe/qpeapplication.h>
36#include <qpe/resource.h> 37#include <qpe/resource.h>
37 38
38#include <qcombobox.h> 39#include <qcombobox.h>
39#include <qlineedit.h> 40#include <qlineedit.h>
40#include <qtimer.h>
41#include <qpopupmenu.h> 41#include <qpopupmenu.h>
42 42
43#include "mainwindow.h" 43#include "mainwindow.h"
44//#include "tableitems.h" 44//#include "tableitems.h"
45#include "tableview.h" 45#include "tableview.h"
46 46
@@ -114,25 +114,20 @@ TableView::TableView( MainWindow* window, QWidget* wid )
114 setSorting( TRUE ); 114 setSorting( TRUE );
115 setSelectionMode( NoSelection ); 115 setSelectionMode( NoSelection );
116 116
117 setLeftMargin( 0 ); 117 setLeftMargin( 0 );
118 verticalHeader()->hide(); 118 verticalHeader()->hide();
119 119
120 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
120 connect((QTable*)this, SIGNAL( clicked(int,int,int,const QPoint&) ), 121 connect((QTable*)this, SIGNAL( clicked(int,int,int,const QPoint&) ),
121 this, SLOT( slotClicked(int,int,int,const QPoint&) ) ); 122 this, SLOT( slotClicked(int,int,int,const QPoint&) ) );
122 connect((QTable*)this, SIGNAL( pressed(int,int,int,const QPoint&) ),
123 this, SLOT( slotPressed(int,int,int,const QPoint&) ) );
124 connect((QTable*)this, SIGNAL(valueChanged(int,int) ), 123 connect((QTable*)this, SIGNAL(valueChanged(int,int) ),
125 this, SLOT( slotValueChanged(int,int) ) ); 124 this, SLOT( slotValueChanged(int,int) ) );
126 connect((QTable*)this, SIGNAL(currentChanged(int,int) ), 125 connect((QTable*)this, SIGNAL(currentChanged(int,int) ),
127 this, SLOT( slotCurrentChanged(int,int) ) ); 126 this, SLOT( slotCurrentChanged(int,int) ) );
128 127
129 m_menuTimer = new QTimer( this );
130 connect( m_menuTimer, SIGNAL(timeout()),
131 this, SLOT(slotShowMenu()) );
132
133 /* now let's init the config */ 128 /* now let's init the config */
134 initConfig(); 129 initConfig();
135 130
136 131
137 m_enablePaint = true; 132 m_enablePaint = true;
138 setUpdatesEnabled( true ); 133 setUpdatesEnabled( true );
@@ -154,17 +149,12 @@ void TableView::newDay() {
154TableView::~TableView() { 149TableView::~TableView() {
155 Config config( "todo" ); 150 Config config( "todo" );
156 config.setGroup( "Options" ); 151 config.setGroup( "Options" );
157 for (int i = 0; i < numCols(); i++ ) 152 for (int i = 0; i < numCols(); i++ )
158 config.writeEntry("Width"+QString::number(i), columnWidth(i) ); 153 config.writeEntry("Width"+QString::number(i), columnWidth(i) );
159} 154}
160void TableView::slotShowMenu() {
161 QPopupMenu *menu = todoWindow()->contextMenu( current(), sorted()[currentRow()].recurrence().doesRecur() );
162 menu->exec(QCursor::pos() );
163 delete menu;
164}
165QString TableView::type() const { 155QString TableView::type() const {
166 return QString::fromLatin1( tr("Table View") ); 156 return QString::fromLatin1( tr("Table View") );
167} 157}
168int TableView::current() { 158int TableView::current() {
169 if (numRows() == 0 ) return 0; 159 if (numRows() == 0 ) return 0;
170 int uid = sorted().uidAt(currentRow() ); 160 int uid = sorted().uidAt(currentRow() );
@@ -277,16 +267,15 @@ void TableView::setShowDeadline( bool b ) {
277 } 267 }
278 setColumnWidth( 2, col2width ); 268 setColumnWidth( 2, col2width );
279} 269}
280void TableView::setShowCategory( const QString& str) { 270void TableView::setShowCategory( const QString& str) {
281 if ( str != m_oleCat || m_first ) 271 if ( str != m_oleCat || m_first )
282 updateView(); 272 updateView();
283 273
284 m_oleCat = str; 274 m_oleCat = str;
285 m_first = false; 275 m_first = false;
286
287} 276}
288void TableView::clear() { 277void TableView::clear() {
289 setNumRows(0); 278 setNumRows(0);
290} 279}
291void TableView::slotClicked(int row, int col, int, 280void TableView::slotClicked(int row, int col, int,
292 const QPoint& point) { 281 const QPoint& point) {
@@ -323,38 +312,23 @@ void TableView::slotClicked(int row, int col, int,
323 QWidget* wid = beginEdit( row, col, FALSE ); 312 QWidget* wid = beginEdit( row, col, FALSE );
324 m_editorWidget.setCellWidget( wid, row, col ); 313 m_editorWidget.setCellWidget( wid, row, col );
325 } 314 }
326 break; 315 break;
327 316
328 case 2: { 317 case 2: {
329 m_menuTimer->stop();
330 showTodo( ui ); 318 showTodo( ui );
331 break; 319 break;
332 } 320 }
333 case 3: { 321 case 3: {
334 m_menuTimer->stop();
335 TodoView::edit( ui ); 322 TodoView::edit( ui );
336 break; 323 break;
337 } 324 }
338 } 325 }
339 326
340 327
341} 328}
342void TableView::slotPressed(int row, int col, int,
343 const QPoint& point) {
344
345 m_prevP = point;
346 /* TextColumn column */
347 if ( col == 2 && cellGeometry( row, col ).contains( point ) )
348 m_menuTimer->start( 750, TRUE );
349}
350void TableView::slotValueChanged( int, int ) {
351}
352void TableView::slotCurrentChanged(int, int ) {
353 m_menuTimer->stop();
354}
355QWidget* TableView::widget() { 329QWidget* TableView::widget() {
356 return this; 330 return this;
357} 331}
358/* 332/*
359 * We need to overwrite sortColumn 333 * We need to overwrite sortColumn
360 * because we want to sort whole row 334 * because we want to sort whole row
@@ -576,26 +550,32 @@ void TableView::timerEvent( QTimerEvent* ) {
576 * REASON: QTable is doing auto scrolling which leads to a move 550 * REASON: QTable is doing auto scrolling which leads to a move
577 * in the x coordinate and this way it's able to pass the 551 * in the x coordinate and this way it's able to pass the
578 * m_completeStrokeWidth criteria 552 * m_completeStrokeWidth criteria
579 * WORKAROUND: strike through needs to strike through the same 553 * WORKAROUND: strike through needs to strike through the same
580 * row and two columns! 554 * row and two columns!
581 */ 555 */
582void TableView::contentsMouseReleaseEvent( QMouseEvent* e) { 556void TableView::contentsMouseReleaseEvent( QMouseEvent *e ) {
583 int row = rowAt(m_prevP.y()); 557 int row = rowAt(m_prevP.y());
584 int colOld = columnAt(m_prevP.x() ); 558 int colOld = columnAt(m_prevP.x() );
585 int colNew = columnAt(e->x() ); 559 int colNew = columnAt(e->x() );
586 if ( row == rowAt( e->y() ) && row != -1 && 560 if ( row == rowAt( e->y() ) && row != -1 &&
587 colOld != colNew ) { 561 colOld != colNew ) {
588 TodoView::complete( sorted()[row] ); 562 TodoView::complete( sorted()[row] );
589 return; 563 return;
590 } 564 }
591 QTable::contentsMouseReleaseEvent( e ); 565 QTable::contentsMouseReleaseEvent( e );
592} 566}
593void TableView::contentsMouseMoveEvent( QMouseEvent* e ) { 567void TableView::contentsMousePressEvent( QMouseEvent *e ) {
594 m_menuTimer->stop(); 568 if ( e->button() == RightButton ) {
595 QTable::contentsMouseMoveEvent( e ); 569 QPopupMenu *menu = todoWindow()->contextMenu( current(), sorted()[currentRow()].recurrence().doesRecur() );
570 menu->exec( QCursor::pos() );
571 }
572 else {
573 m_prevP = e->pos();
574 QTable::contentsMousePressEvent( e );
575 }
596} 576}
597void TableView::keyPressEvent( QKeyEvent* event) { 577void TableView::keyPressEvent( QKeyEvent* event) {
598 if ( m_editorWidget.cellWidget() ) { 578 if ( m_editorWidget.cellWidget() ) {
599// setCellContentFromEditor(m_editorWidget.cellRow(), m_editorWidget.cellCol() ); 579// setCellContentFromEditor(m_editorWidget.cellRow(), m_editorWidget.cellCol() );
600 endEdit(m_editorWidget.cellRow(), m_editorWidget.cellCol(), 580 endEdit(m_editorWidget.cellRow(), m_editorWidget.cellCol(),
601 true, true ); 581 true, true );