-rw-r--r-- | core/pim/todo/tableitems.cpp | 183 |
1 files changed, 0 insertions, 183 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 | |||
35 | using namespace Todo; | ||
36 | |||
37 | CheckItem::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 | } | ||
44 | CheckItem::~CheckItem() { | ||
45 | } | ||
46 | void CheckItem::setChecked( bool b ) { | ||
47 | OCheckItem::setChecked(b); | ||
48 | } | ||
49 | void 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 | } | ||
58 | int CheckItem::uid() const { | ||
59 | return m_uid; | ||
60 | } | ||
61 | QArray<int> CheckItem::cats() { | ||
62 | return m_cat; | ||
63 | } | ||
64 | |||
65 | /* ComboItem */ | ||
66 | ComboItem::ComboItem( QTable* t, EditType et ) | ||
67 | : QTableItem( t, et, "3" ), m_cb(0) | ||
68 | { | ||
69 | setReplaceable( FALSE ); | ||
70 | } | ||
71 | ComboItem::~ComboItem() { | ||
72 | |||
73 | } | ||
74 | QWidget* 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 | } | ||
89 | void 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 | } | ||
101 | void ComboItem::setText( const QString& s ) { | ||
102 | if ( m_cb ) | ||
103 | m_cb->setCurrentItem( s.toInt()-1 ); | ||
104 | |||
105 | QTableItem::setText( s ); | ||
106 | } | ||
107 | QString ComboItem::text()const { | ||
108 | if ( m_cb) | ||
109 | return m_cb->currentText(); | ||
110 | |||
111 | return QTableItem::text(); | ||
112 | } | ||
113 | |||
114 | /* TodoTextItem */ | ||
115 | TodoTextItem::~TodoTextItem() { | ||
116 | |||
117 | } | ||
118 | TodoTextItem::TodoTextItem( QTable* t, | ||
119 | const QString& string ) | ||
120 | : QTableItem( t, QTableItem::Never, string ) | ||
121 | {} | ||
122 | |||
123 | /* DueTextItem */ | ||
124 | DueTextItem::DueTextItem( QTable* t, const OTodo& ev) | ||
125 | : QTableItem(t, Never, QString::null ) | ||
126 | { | ||
127 | setToDoEvent( ev ); | ||
128 | } | ||
129 | DueTextItem::~DueTextItem() { | ||
130 | |||
131 | } | ||
132 | QString 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 | } | ||
149 | void DueTextItem::setCompleted( bool comp ) { | ||
150 | m_completed = comp; | ||
151 | table()->updateCell( row(), col() ); | ||
152 | } | ||
153 | void 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 | } | ||
166 | void 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 | } | ||