summaryrefslogtreecommitdiff
path: root/core/pim/todo/tableview.cpp
Side-by-side diff
Diffstat (limited to 'core/pim/todo/tableview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/todo/tableview.cpp55
1 files changed, 29 insertions, 26 deletions
diff --git a/core/pim/todo/tableview.cpp b/core/pim/todo/tableview.cpp
index c64ad46..3e88974 100644
--- a/core/pim/todo/tableview.cpp
+++ b/core/pim/todo/tableview.cpp
@@ -1,146 +1,149 @@
/*
- =. This file is part of the OPIE Project
- .=l. Copyright (c) 2002 <zecke>
- .>+-=
-_;:, .> :=|. This program is free software; you can
-.> <`_, > . <= redistribute it and/or modify it under
-:`=1 )Y*s>-.-- : the terms of the GNU General Public
-.="- .-=="i, .._ License as published by the Free Software
-- . .-<_> .<> Foundation; either version 2 of the License,
- ._= =} : or (at your option) any later version.
- .%`+i> _;_.
- .i_,=:_. -<s. This program is distributed in the hope that
- + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
- : .. .:, . . . without even the implied warranty of
- =_ + =;=|` 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.
+                 This file is part of the Opie Project
+
+ Copyright (C) Opie Team <opie-devel@handhelds.org>
+ =.
+ .=l.
+           .>+-=
+ _;:,     .>    :=|. This program is free software; you can
+.> <`_,   >  .   <= redistribute it and/or modify it under
+:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
+.="- .-=="i,     .._ License as published by the Free Software
+ - .   .-<_>     .<> Foundation; either version 2 of the License,
+     ._= =}       : or (at your option) any later version.
+    .%`+i>       _;_.
+    .i_,=:_.      -<s. This program is distributed in the hope that
+     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
+ : ..    .:,     . . . without even the implied warranty of
+    =_        +     =;=|` 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.
-
*/
+
#include <stdlib.h>
#include <cmath>
#include <cctype>
#include <opie2/odebug.h>
#include <opie2/opimrecurrence.h>
+#include <opie2/oresource.h>
#include <qpe/config.h>
#include <qpe/qpeapplication.h>
-#include <qpe/resource.h>
#include <qcombobox.h>
#include <qlineedit.h>
#include <qpopupmenu.h>
#include "mainwindow.h"
//#include "tableitems.h"
#include "tableview.h"
using namespace Todo;
namespace {
static const int BoxSize = 14;
static const int RowHeight = 20;
}
TableView::EditorWidget::EditorWidget() : m_wid(0l), m_row(-1), m_col(-1) {
}
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" );
+ m_pic_completed = Opie::Core::OResource::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 );
+ m_pic_priority[ i - 1 ] = Opie::Core::OResource::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("Summary" ) );
horizontalHeader()->setLabel( 3, QWidget::tr("Deadline") );
setShowDeadline( todoWindow()->showDeadline() );
setSorting( TRUE );
setSelectionMode( NoSelection );
setLeftMargin( 0 );
verticalHeader()->hide();
QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
connect((QTable*)this, SIGNAL( clicked(int,int,int,const QPoint&) ),
this, SLOT( slotClicked(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) ) );
/* now let's init the config */
initConfig();
m_enablePaint = true;
setUpdatesEnabled( true );
viewport()->setUpdatesEnabled( true );
viewport()->update();
setSortOrder( Opie::OPimTodoAccess::Completed );
setAscending( TRUE );
m_first = true;
}
/* a new day has started
* update the day
*/
void TableView::newDay() {
clear();
@@ -225,97 +228,97 @@ void TableView::setTodo( int, const OPimTodo&) {
void TableView::addEvent( const OPimTodo&) {
/* fix problems of not showing the 'Haken' */
updateView();
}
/*
* find the event
* and then replace the complete row
*/
void TableView::replaceEvent( const OPimTodo& ev) {
addEvent( ev );
}
/*
* re aligning table can be slow too
* FIXME: look what performs better
* either this or the old align table
*/
void TableView::removeEvent( int ) {
updateView();
}
void TableView::setShowCompleted( bool ) {
updateView();
}
void TableView::setShowDeadline( bool b ) {
if ( b )
showColumn( 3 );
else
hideColumn( 3 );
// Try to intelligently size columns
// TODO - would use width() below, but doesn't have valid value at time of c'tor
int col2width = 238;
int width = m_pic_completed.width();
setColumnWidth( 0, width );
col2width -= width;
width = fontMetrics().boundingRect( horizontalHeader()->label( 1 ) ).width() + 8;
setColumnWidth( 1, width );
col2width -= width;
if ( b ) {
width = fontMetrics().boundingRect( horizontalHeader()->label( 3 ) ).width() + 8;
setColumnWidth( 3, width );
col2width -= width;
}
setColumnWidth( 2, col2width );
}
void TableView::setShowCategory( const QString& str) {
if ( str != m_oleCat || m_first )
updateView();
-
+
m_oleCat = str;
m_first = false;
}
void TableView::clear() {
setNumRows(0);
}
void TableView::slotClicked(int row, int col, int,
const QPoint& point) {
if ( m_editorWidget.cellWidget() ) {
//setCellContentFromEditor(m_editorWidget.cellRow(), m_editorWidget.cellCol() );
endEdit(m_editorWidget.cellRow(), m_editorWidget.cellCol(),
true, true );
m_editorWidget.releaseCellWidget();
}
if ( !cellGeometry(row, col ).contains(point ) )
return;
int ui= sorted().uidAt( row );
switch( col ) {
case 0:{
int x = point.x() -columnPos( col );
int y = point.y() -rowPos( row );
int w = columnWidth( col );
int h = rowHeight( row );
if ( x >= ( w - BoxSize ) / 2 &&
x <= ( w - BoxSize ) / 2 + BoxSize &&
y >= ( h - BoxSize ) / 2 &&
y <= ( h - BoxSize ) / 2 + BoxSize ) {
TodoView::complete(sorted()[row] );
}
}
break;
// Priority emit a double click...
case 1:{
QWidget* wid = beginEdit( row, col, FALSE );
m_editorWidget.setCellWidget( wid, row, col );
}
break;
case 2: {
showTodo( ui );
break;
}
case 3: {