-rw-r--r-- | core/pim/todo/tableitems.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/core/pim/todo/tableitems.cpp b/core/pim/todo/tableitems.cpp index a636de6..216b740 100644 --- a/core/pim/todo/tableitems.cpp +++ b/core/pim/todo/tableitems.cpp | |||
@@ -1,80 +1,82 @@ | |||
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 <> | 3 | .=l. Copyright (c) 2002 <> |
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 "tableview.h" | 28 | #include "tableview.h" |
29 | 29 | ||
30 | #include "tableitems.h" | 30 | #include "tableitems.h" |
31 | #include <string.h> | 31 | #include <string.h> |
32 | 32 | ||
33 | #include <qobject.h> | ||
34 | |||
33 | using namespace Todo; | 35 | using namespace Todo; |
34 | 36 | ||
35 | CheckItem::CheckItem( QTable* t, | 37 | CheckItem::CheckItem( QTable* t, |
36 | const QString& sortKey, | 38 | const QString& sortKey, |
37 | int uid, | 39 | int uid, |
38 | const QArray<int>& lis) | 40 | const QArray<int>& lis) |
39 | : OCheckItem(t, sortKey), m_uid(uid ), m_cat( lis ) | 41 | : OCheckItem(t, sortKey), m_uid(uid ), m_cat( lis ) |
40 | { | 42 | { |
41 | } | 43 | } |
42 | CheckItem::~CheckItem() { | 44 | CheckItem::~CheckItem() { |
43 | } | 45 | } |
44 | void CheckItem::setChecked( bool b ) { | 46 | void CheckItem::setChecked( bool b ) { |
45 | OCheckItem::setChecked(b); | 47 | OCheckItem::setChecked(b); |
46 | } | 48 | } |
47 | void CheckItem::toggle() { | 49 | void CheckItem::toggle() { |
48 | TableView* view = static_cast<TableView*>( table() ); | 50 | TableView* view = static_cast<TableView*>( table() ); |
49 | OTodo ev = view->find( view->current() ); | 51 | OTodo ev = view->find( view->current() ); |
50 | ev.setCompleted(!isChecked() ); | 52 | ev.setCompleted(!isChecked() ); |
51 | //view->updateFromTable( ev ); | 53 | //view->updateFromTable( ev ); |
52 | 54 | ||
53 | OCheckItem::toggle(); | 55 | OCheckItem::toggle(); |
54 | table()->updateCell( row(), col() ); | 56 | table()->updateCell( row(), col() ); |
55 | } | 57 | } |
56 | int CheckItem::uid() const { | 58 | int CheckItem::uid() const { |
57 | return m_uid; | 59 | return m_uid; |
58 | } | 60 | } |
59 | QArray<int> CheckItem::cats() { | 61 | QArray<int> CheckItem::cats() { |
60 | return m_cat; | 62 | return m_cat; |
61 | } | 63 | } |
62 | 64 | ||
63 | /* ComboItem */ | 65 | /* ComboItem */ |
64 | ComboItem::ComboItem( QTable* t, EditType et ) | 66 | ComboItem::ComboItem( QTable* t, EditType et ) |
65 | : QTableItem( t, et, "3" ), m_cb(0) | 67 | : QTableItem( t, et, "3" ), m_cb(0) |
66 | { | 68 | { |
67 | setReplaceable( FALSE ); | 69 | setReplaceable( FALSE ); |
68 | } | 70 | } |
69 | ComboItem::~ComboItem() { | 71 | ComboItem::~ComboItem() { |
70 | 72 | ||
71 | } | 73 | } |
72 | QWidget* ComboItem::createEditor()const { | 74 | QWidget* ComboItem::createEditor()const { |
73 | qWarning( "create editor"); | 75 | qWarning( "create editor"); |
74 | QString txt = text(); | 76 | QString txt = text(); |
75 | 77 | ||
76 | ( (ComboItem*)this)-> m_cb = new QComboBox( table()->viewport() ); | 78 | ( (ComboItem*)this)-> m_cb = new QComboBox( table()->viewport() ); |
77 | 79 | ||
78 | m_cb->insertItem( "1" ); | 80 | m_cb->insertItem( "1" ); |
79 | m_cb->insertItem( "2" ); | 81 | m_cb->insertItem( "2" ); |
80 | m_cb->insertItem( "3" ); | 82 | m_cb->insertItem( "3" ); |
@@ -110,72 +112,72 @@ QString ComboItem::text()const { | |||
110 | } | 112 | } |
111 | 113 | ||
112 | /* TodoTextItem */ | 114 | /* TodoTextItem */ |
113 | TodoTextItem::~TodoTextItem() { | 115 | TodoTextItem::~TodoTextItem() { |
114 | 116 | ||
115 | } | 117 | } |
116 | TodoTextItem::TodoTextItem( QTable* t, | 118 | TodoTextItem::TodoTextItem( QTable* t, |
117 | const QString& string ) | 119 | const QString& string ) |
118 | : QTableItem( t, QTableItem::Never, string ) | 120 | : QTableItem( t, QTableItem::Never, string ) |
119 | {} | 121 | {} |
120 | 122 | ||
121 | /* DueTextItem */ | 123 | /* DueTextItem */ |
122 | DueTextItem::DueTextItem( QTable* t, const OTodo& ev) | 124 | DueTextItem::DueTextItem( QTable* t, const OTodo& ev) |
123 | : QTableItem(t, Never, QString::null ) | 125 | : QTableItem(t, Never, QString::null ) |
124 | { | 126 | { |
125 | setToDoEvent( ev ); | 127 | setToDoEvent( ev ); |
126 | } | 128 | } |
127 | DueTextItem::~DueTextItem() { | 129 | DueTextItem::~DueTextItem() { |
128 | 130 | ||
129 | } | 131 | } |
130 | QString DueTextItem::key() const { | 132 | QString DueTextItem::key() const { |
131 | QString key; | 133 | QString key; |
132 | 134 | ||
133 | if( m_hasDate ){ | 135 | if( m_hasDate ){ |
134 | if(m_off == 0 ){ | 136 | if(m_off == 0 ){ |
135 | key.append("b"); | 137 | key.append("b"); |
136 | }else if( m_off > 0 ){ | 138 | }else if( m_off > 0 ){ |
137 | key.append("c"); | 139 | key.append("c"); |
138 | }else if( m_off < 0 ){ | 140 | }else if( m_off < 0 ){ |
139 | key.append("a"); | 141 | key.append("a"); |
140 | } | 142 | } |
141 | key.append(QString::number(m_off ) ); | 143 | key.append(QString::number(m_off ) ); |
142 | }else{ | 144 | }else{ |
143 | key.append("d"); | 145 | key.append("d"); |
144 | } | 146 | } |
145 | return key; | 147 | return key; |
146 | } | 148 | } |
147 | void DueTextItem::setCompleted( bool comp ) { | 149 | void DueTextItem::setCompleted( bool comp ) { |
148 | m_completed = comp; | 150 | m_completed = comp; |
149 | table()->updateCell( row(), col() ); | 151 | table()->updateCell( row(), col() ); |
150 | } | 152 | } |
151 | void DueTextItem::setToDoEvent( const OTodo& ev ) { | 153 | void DueTextItem::setToDoEvent( const OTodo& ev ) { |
152 | m_hasDate = ev.hasDueDate(); | 154 | m_hasDate = ev.hasDueDate(); |
153 | m_completed = ev.isCompleted(); | 155 | m_completed = ev.isCompleted(); |
154 | 156 | ||
155 | if( ev.hasDueDate() ){ | 157 | if( ev.hasDueDate() ){ |
156 | QDate today = QDate::currentDate(); | 158 | QDate today = QDate::currentDate(); |
157 | m_off = today.daysTo(ev.dueDate() ); | 159 | m_off = today.daysTo(ev.dueDate() ); |
158 | setText( tr( "%1 day(s)" ).arg( QString::number(m_off) ) ); | 160 | setText( QObject::tr( "%1 day(s)" ).arg( QString::number(m_off) ) ); |
159 | }else{ | 161 | }else{ |
160 | setText("n.d." ); | 162 | setText("n.d." ); |
161 | m_off = 0; | 163 | m_off = 0; |
162 | } | 164 | } |
163 | } | 165 | } |
164 | void DueTextItem::paint( QPainter* p, const QColorGroup &cg, | 166 | void DueTextItem::paint( QPainter* p, const QColorGroup &cg, |
165 | const QRect& cr, bool selected ) { | 167 | const QRect& cr, bool selected ) { |
166 | QColorGroup cg2(cg); | 168 | QColorGroup cg2(cg); |
167 | 169 | ||
168 | QColor text = cg.text(); | 170 | QColor text = cg.text(); |
169 | if( m_hasDate && !m_completed ){ | 171 | if( m_hasDate && !m_completed ){ |
170 | if( m_off < 0 ){ | 172 | if( m_off < 0 ){ |
171 | cg2.setColor(QColorGroup::Text, QColor(red ) ); | 173 | cg2.setColor(QColorGroup::Text, QColor(red ) ); |
172 | }else if( m_off == 0 ){ | 174 | }else if( m_off == 0 ){ |
173 | cg2.setColor(QColorGroup::Text, QColor(yellow) ); // orange isn't predefined | 175 | cg2.setColor(QColorGroup::Text, QColor(yellow) ); // orange isn't predefined |
174 | }else if( m_off > 0){ | 176 | }else if( m_off > 0){ |
175 | cg2.setColor(QColorGroup::Text, QColor(green ) ); | 177 | cg2.setColor(QColorGroup::Text, QColor(green ) ); |
176 | } | 178 | } |
177 | } | 179 | } |
178 | QTableItem::paint(p, cg2, cr, selected ); | 180 | QTableItem::paint(p, cg2, cr, selected ); |
179 | /* restore default color */ | 181 | /* restore default color */ |
180 | cg2.setColor(QColorGroup::Text, text ); | 182 | cg2.setColor(QColorGroup::Text, text ); |
181 | } | 183 | } |