summaryrefslogtreecommitdiff
authorzecke <zecke>2002-12-17 19:34:07 (UTC)
committer zecke <zecke>2002-12-17 19:34:07 (UTC)
commit98f90f6ed89986485a1413c4325411e30f4c0693 (patch) (unidiff)
treeaa5c949e65b2c89e2fa6d11ca42e442808c0c2a2
parent813e3ff4978cc480fcb971411211df9a07375743 (diff)
downloadopie-98f90f6ed89986485a1413c4325411e30f4c0693.zip
opie-98f90f6ed89986485a1413c4325411e30f4c0693.tar.gz
opie-98f90f6ed89986485a1413c4325411e30f4c0693.tar.bz2
say good bye to the nice and educational
QTableItems. :(
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/todo/tableitems.cpp183
-rw-r--r--core/pim/todo/tableitems.h124
2 files changed, 0 insertions, 307 deletions
diff --git a/core/pim/todo/tableitems.cpp b/core/pim/todo/tableitems.cpp
deleted file mode 100644
index 216b740..0000000
--- a/core/pim/todo/tableitems.cpp
+++ b/dev/null
@@ -1,183 +0,0 @@
1/*
2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 <>
4           .>+-=
5 _;:,     .>    :=|. This program is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU General Public
8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This program is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more
18++=   -.     .`     .: details.
19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = Library General Public License along with
22    --        :-=` this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA.
26
27*/
28#include "tableview.h"
29
30#include "tableitems.h"
31#include <string.h>
32
33#include <qobject.h>
34
35using namespace Todo;
36
37CheckItem::CheckItem( QTable* t,
38 const QString& sortKey,
39 int uid,
40 const QArray<int>& lis)
41 : OCheckItem(t, sortKey), m_uid(uid ), m_cat( lis )
42{
43}
44CheckItem::~CheckItem() {
45}
46void CheckItem::setChecked( bool b ) {
47 OCheckItem::setChecked(b);
48}
49void CheckItem::toggle() {
50 TableView* view = static_cast<TableView*>( table() );
51 OTodo ev = view->find( view->current() );
52 ev.setCompleted(!isChecked() );
53 //view->updateFromTable( ev );
54
55 OCheckItem::toggle();
56 table()->updateCell( row(), col() );
57}
58int CheckItem::uid() const {
59 return m_uid;
60}
61QArray<int> CheckItem::cats() {
62 return m_cat;
63}
64
65/* ComboItem */
66ComboItem::ComboItem( QTable* t, EditType et )
67 : QTableItem( t, et, "3" ), m_cb(0)
68{
69 setReplaceable( FALSE );
70}
71ComboItem::~ComboItem() {
72
73}
74QWidget* ComboItem::createEditor()const {
75 qWarning( "create editor");
76 QString txt = text();
77
78 ( (ComboItem*)this)-> m_cb = new QComboBox( table()->viewport() );
79
80 m_cb->insertItem( "1" );
81 m_cb->insertItem( "2" );
82 m_cb->insertItem( "3" );
83 m_cb->insertItem( "4" );
84 m_cb->insertItem( "5" );
85 m_cb->setCurrentItem( txt.toInt() - 1 );
86
87 return m_cb;
88}
89void ComboItem::setContentFromEditor( QWidget* w) {
90 TableView* view = static_cast<TableView*>( table() );
91 OTodo ev = view->find( view->current() );
92
93 if ( w->inherits( "QComboBox" ) )
94 setText( ( (QComboBox*)w )->currentText() );
95 else
96 QTableItem::setContentFromEditor( w );
97
98 ev.setPriority( text().toInt() );
99 //view->updateFromTable( ev );
100}
101void ComboItem::setText( const QString& s ) {
102 if ( m_cb )
103 m_cb->setCurrentItem( s.toInt()-1 );
104
105 QTableItem::setText( s );
106}
107QString ComboItem::text()const {
108 if ( m_cb)
109 return m_cb->currentText();
110
111 return QTableItem::text();
112}
113
114/* TodoTextItem */
115TodoTextItem::~TodoTextItem() {
116
117}
118TodoTextItem::TodoTextItem( QTable* t,
119 const QString& string )
120 : QTableItem( t, QTableItem::Never, string )
121{}
122
123/* DueTextItem */
124DueTextItem::DueTextItem( QTable* t, const OTodo& ev)
125 : QTableItem(t, Never, QString::null )
126{
127 setToDoEvent( ev );
128}
129DueTextItem::~DueTextItem() {
130
131}
132QString DueTextItem::key() const {
133 QString key;
134
135 if( m_hasDate ){
136 if(m_off == 0 ){
137 key.append("b");
138 }else if( m_off > 0 ){
139 key.append("c");
140 }else if( m_off < 0 ){
141 key.append("a");
142 }
143 key.append(QString::number(m_off ) );
144 }else{
145 key.append("d");
146 }
147 return key;
148}
149void DueTextItem::setCompleted( bool comp ) {
150 m_completed = comp;
151 table()->updateCell( row(), col() );
152}
153void DueTextItem::setToDoEvent( const OTodo& ev ) {
154 m_hasDate = ev.hasDueDate();
155 m_completed = ev.isCompleted();
156
157 if( ev.hasDueDate() ){
158 QDate today = QDate::currentDate();
159 m_off = today.daysTo(ev.dueDate() );
160 setText( QObject::tr( "%1 day(s)" ).arg( QString::number(m_off) ) );
161 }else{
162 setText("n.d." );
163 m_off = 0;
164 }
165}
166void DueTextItem::paint( QPainter* p, const QColorGroup &cg,
167 const QRect& cr, bool selected ) {
168 QColorGroup cg2(cg);
169
170 QColor text = cg.text();
171 if( m_hasDate && !m_completed ){
172 if( m_off < 0 ){
173 cg2.setColor(QColorGroup::Text, QColor(red ) );
174 }else if( m_off == 0 ){
175 cg2.setColor(QColorGroup::Text, QColor(yellow) ); // orange isn't predefined
176 }else if( m_off > 0){
177 cg2.setColor(QColorGroup::Text, QColor(green ) );
178 }
179 }
180 QTableItem::paint(p, cg2, cr, selected );
181 /* restore default color */
182 cg2.setColor(QColorGroup::Text, text );
183}
diff --git a/core/pim/todo/tableitems.h b/core/pim/todo/tableitems.h
deleted file mode 100644
index 33ae814..0000000
--- a/core/pim/todo/tableitems.h
+++ b/dev/null
@@ -1,124 +0,0 @@
1/*
2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 <>
4           .>+-=
5 _;:,     .>    :=|. This program is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU General Public
8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This program is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more
18++=   -.     .`     .: details.
19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = Library General Public License along with
22    --        :-=` this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA.
26
27*/
28
29#ifndef OPIE_TODO_TABLE_ITEMS_H
30#define OPIE_TODO_TABLE_ITEMS_H
31
32#include <qarray.h>
33#include <qguardedptr.h>
34#include <qcombobox.h>
35#include <qtable.h>
36
37#include <qpe/stringutil.h>
38
39#include <opie/ocheckitem.h>
40#include <opie/otodo.h>
41
42
43namespace Todo {
44
45 /**
46 * We need to reimplement OCheckItem here
47 * we need to update on change
48 * You can check a checkItem
49 */
50 class CheckItem : public OCheckItem {
51 public:
52 CheckItem( QTable* t, const QString& sortKey,
53 int uid,
54 const QArray<int>& );
55 ~CheckItem();
56 virtual void setChecked( bool b );
57 virtual void toggle();
58 int uid()const;
59 QArray<int> cats();
60 private:
61 int m_uid;
62 QArray<int> m_cat;
63 };
64
65 /**
66 * creates a QComboBox if neccessary
67 * to edit inline
68 */
69 class ComboItem : public QTableItem {
70 public:
71 ComboItem( QTable* t, EditType et );
72 ~ComboItem();
73 QWidget* createEditor()const;
74 void setContentFromEditor( QWidget* w );
75 void setText( const QString& s );
76 int alignment() const;
77
78 QString text()const;
79
80 private:
81 QGuardedPtr<QComboBox> m_cb;
82 };
83
84 /* implement inline */
85 inline int ComboItem::alignment()const {
86 return Qt::AlignCenter;
87 }
88
89 /**
90 * TodoTextItem builds a better specialised
91 * sortkey
92 */
93 class TodoTextItem : public QTableItem {
94 public:
95 TodoTextItem( QTable* t, const QString& str );
96 ~TodoTextItem();
97 QString key()const;
98 };
99
100
101 inline QString TodoTextItem::key() const {
102 return Qtopia::buildSortKey( text() );
103 }
104
105 class DueTextItem : public QTableItem {
106 public:
107 DueTextItem( QTable* t, const OTodo& );
108 ~DueTextItem();
109
110 QString key()const;
111 void setToDoEvent( const OTodo& ev );
112 void setCompleted( bool comp );
113 void paint( QPainter *p, const QColorGroup &cg,
114 const QRect& cr, bool selected );
115 private:
116 int m_off;
117 bool m_hasDate:1;
118 bool m_completed:1;
119 };
120
121
122};
123
124#endif