author | zautrix <zautrix> | 2005-08-19 12:08:05 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-08-19 12:08:05 (UTC) |
commit | 9014049779be6cfec02d73e19596439f0f4f9bed (patch) (unidiff) | |
tree | 3983282e83183cc15dd615ba4ac5a800da21efe0 /korganizer | |
parent | 81891a49afc2f7cd89db4e2770c3b7831644428d (diff) | |
download | kdepimpi-9014049779be6cfec02d73e19596439f0f4f9bed.zip kdepimpi-9014049779be6cfec02d73e19596439f0f4f9bed.tar.gz kdepimpi-9014049779be6cfec02d73e19596439f0f4f9bed.tar.bz2 |
list sort fix
-rw-r--r-- | korganizer/kolistview.cpp | 21 | ||||
-rw-r--r-- | korganizer/kotodoviewitem.cpp | 14 |
2 files changed, 11 insertions, 24 deletions
diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp index b236c2d..4fc1194 100644 --- a/korganizer/kolistview.cpp +++ b/korganizer/kolistview.cpp | |||
@@ -1,643 +1,636 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 1999 Preston Brown | 3 | Copyright (c) 1999 Preston Brown |
4 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This program is free software; you can redistribute it and/or modify | 6 | This program is free software; you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by | 7 | it under the terms of the GNU General Public License as published by |
8 | the Free Software Foundation; either version 2 of the License, or | 8 | the Free Software Foundation; either version 2 of the License, or |
9 | (at your option) any later version. | 9 | (at your option) any later version. |
10 | 10 | ||
11 | This program is distributed in the hope that it will be useful, | 11 | This program is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | GNU General Public License for more details. | 14 | GNU General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU General Public License | 16 | You should have received a copy of the GNU General Public License |
17 | along with this program; if not, write to the Free Software | 17 | along with this program; if not, write to the Free Software |
18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
19 | 19 | ||
20 | As a special exception, permission is given to link this program | 20 | As a special exception, permission is given to link this program |
21 | with any edition of Qt, and distribute the resulting executable, | 21 | with any edition of Qt, and distribute the resulting executable, |
22 | without including the source code for Qt in the source distribution. | 22 | without including the source code for Qt in the source distribution. |
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include <qlistview.h> | 25 | #include <qlistview.h> |
26 | #include <qlayout.h> | 26 | #include <qlayout.h> |
27 | #include <qlabel.h> | 27 | #include <qlabel.h> |
28 | #include <qpopupmenu.h> | 28 | #include <qpopupmenu.h> |
29 | #include <qprogressbar.h> | 29 | #include <qprogressbar.h> |
30 | #include <qfileinfo.h> | 30 | #include <qfileinfo.h> |
31 | #include <qmessagebox.h> | 31 | #include <qmessagebox.h> |
32 | #include <qdialog.h> | 32 | #include <qdialog.h> |
33 | #include <qtextstream.h> | 33 | #include <qtextstream.h> |
34 | #include <qdir.h> | 34 | #include <qdir.h> |
35 | #include <qwhatsthis.h> | 35 | #include <qwhatsthis.h> |
36 | #include <qregexp.h> | 36 | #include <qregexp.h> |
37 | #include <qpainter.h> | 37 | #include <qpainter.h> |
38 | #include <qpaintdevicemetrics.h> | 38 | #include <qpaintdevicemetrics.h> |
39 | 39 | ||
40 | #include <klocale.h> | 40 | #include <klocale.h> |
41 | #include <kdebug.h> | 41 | #include <kdebug.h> |
42 | #include <kiconloader.h> | 42 | #include <kiconloader.h> |
43 | #include <kglobal.h> | 43 | #include <kglobal.h> |
44 | 44 | ||
45 | #include <libkdepim/kpimglobalprefs.h> | 45 | #include <libkdepim/kpimglobalprefs.h> |
46 | #include <libkcal/calendar.h> | 46 | #include <libkcal/calendar.h> |
47 | #include <libkcal/calendarlocal.h> | 47 | #include <libkcal/calendarlocal.h> |
48 | #include <libkcal/icalformat.h> | 48 | #include <libkcal/icalformat.h> |
49 | #include <libkcal/vcalformat.h> | 49 | #include <libkcal/vcalformat.h> |
50 | #include <libkcal/recurrence.h> | 50 | #include <libkcal/recurrence.h> |
51 | #include <libkcal/filestorage.h> | 51 | #include <libkcal/filestorage.h> |
52 | #include <libkdepim/categoryselectdialog.h> | 52 | #include <libkdepim/categoryselectdialog.h> |
53 | #include <libkcal/kincidenceformatter.h> | 53 | #include <libkcal/kincidenceformatter.h> |
54 | #ifndef DESKTOP_VERSION | 54 | #ifndef DESKTOP_VERSION |
55 | #include <qpe/qpeapplication.h> | 55 | #include <qpe/qpeapplication.h> |
56 | #else | 56 | #else |
57 | #include <qapplication.h> | 57 | #include <qapplication.h> |
58 | #endif | 58 | #endif |
59 | 59 | ||
60 | #ifndef KORG_NOPRINTER | 60 | #ifndef KORG_NOPRINTER |
61 | #include "calprinter.h" | 61 | #include "calprinter.h" |
62 | #endif | 62 | #endif |
63 | #include "koglobals.h" | 63 | #include "koglobals.h" |
64 | #include "koprefs.h" | 64 | #include "koprefs.h" |
65 | #include "kfiledialog.h" | 65 | #include "kfiledialog.h" |
66 | 66 | ||
67 | #include "kolistview.h" | 67 | #include "kolistview.h" |
68 | #include "koeventviewer.h" | 68 | #include "koeventviewer.h" |
69 | 69 | ||
70 | extern QPixmap* sgListViewCompletedPix[6]; | 70 | extern QPixmap* sgListViewCompletedPix[6]; |
71 | extern QPixmap* sgListViewJournalPix; | 71 | extern QPixmap* sgListViewJournalPix; |
72 | 72 | ||
73 | class KOListViewWhatsThis :public QWhatsThis | 73 | class KOListViewWhatsThis :public QWhatsThis |
74 | { | 74 | { |
75 | public: | 75 | public: |
76 | KOListViewWhatsThis( QWidget *wid, KOListView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { }; | 76 | KOListViewWhatsThis( QWidget *wid, KOListView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { }; |
77 | 77 | ||
78 | protected: | 78 | protected: |
79 | virtual QString text( const QPoint& p) | 79 | virtual QString text( const QPoint& p) |
80 | { | 80 | { |
81 | return _view->getWhatsThisText(p) ; | 81 | return _view->getWhatsThisText(p) ; |
82 | } | 82 | } |
83 | private: | 83 | private: |
84 | QWidget* _wid; | 84 | QWidget* _wid; |
85 | KOListView * _view; | 85 | KOListView * _view; |
86 | }; | 86 | }; |
87 | 87 | ||
88 | 88 | ||
89 | ListItemVisitor::ListItemVisitor(KOListViewItem *item, QDate date ) | 89 | ListItemVisitor::ListItemVisitor(KOListViewItem *item, QDate date ) |
90 | { | 90 | { |
91 | mItem = item; | 91 | mItem = item; |
92 | mDate = date; | 92 | mDate = date; |
93 | } | 93 | } |
94 | 94 | ||
95 | ListItemVisitor::~ListItemVisitor() | 95 | ListItemVisitor::~ListItemVisitor() |
96 | { | 96 | { |
97 | } | 97 | } |
98 | 98 | ||
99 | bool ListItemVisitor::visit(Event *e) | 99 | bool ListItemVisitor::visit(Event *e) |
100 | { | 100 | { |
101 | bool ok = false; | 101 | bool ok = false; |
102 | QString start, end; | 102 | QString start, end; |
103 | QDate ds, de; | 103 | QDate ds, de; |
104 | if ( e->doesRecur() ) { | 104 | if ( e->doesRecur() ) { |
105 | ds = e->getNextOccurence( QDateTime( mDate, QTime(0,0,0)), &ok ).date(); | 105 | ds = e->getNextOccurence( QDateTime( mDate, QTime(0,0,0)), &ok ).date(); |
106 | if ( ok ) { | 106 | if ( ok ) { |
107 | int days = e->dtStart().date().daysTo(e->dtEnd().date() ); | 107 | int days = e->dtStart().date().daysTo(e->dtEnd().date() ); |
108 | start = KGlobal::locale()->formatDate(ds,true); | 108 | start = KGlobal::locale()->formatDate(ds,true); |
109 | de = ds.addDays( days); | 109 | de = ds.addDays( days); |
110 | end = KGlobal::locale()->formatDate(de,true); | 110 | end = KGlobal::locale()->formatDate(de,true); |
111 | } | 111 | } |
112 | 112 | ||
113 | } | 113 | } |
114 | if ( ! ok ) { | 114 | if ( ! ok ) { |
115 | start =e->dtStartDateStr(); | 115 | start =e->dtStartDateStr(); |
116 | end = e->dtEndDateStr(); | 116 | end = e->dtEndDateStr(); |
117 | ds = e->dtStart().date(); | 117 | ds = e->dtStart().date(); |
118 | de = e->dtEnd().date(); | 118 | de = e->dtEnd().date(); |
119 | } | 119 | } |
120 | mItem->setText(0,e->summary()); | 120 | mItem->setText(0,e->summary()); |
121 | mItem->setText(1,start); | 121 | mItem->setText(1,start); |
122 | if ( e->doesFloat() ) | 122 | if ( e->doesFloat() ) |
123 | mItem->setText(2,"---"); | 123 | mItem->setText(2,"---"); |
124 | else | 124 | else |
125 | mItem->setText(2,e->dtStartTimeStr()); | 125 | mItem->setText(2,e->dtStartTimeStr()); |
126 | mItem->setText(3,end); | 126 | mItem->setText(3,end); |
127 | if ( e->doesFloat() ) | 127 | if ( e->doesFloat() ) |
128 | mItem->setText(4,"---"); | 128 | mItem->setText(4,"---"); |
129 | else | 129 | else |
130 | mItem->setText(4,e->dtEndTimeStr()); | 130 | mItem->setText(4,e->dtEndTimeStr()); |
131 | mItem->setText(5, e->durationText()); | 131 | mItem->setText(5, e->durationText()); |
132 | if ( e->isAlarmEnabled() ) { | 132 | if ( e->isAlarmEnabled() ) { |
133 | mItem->setText(6,e->alarms().first()->offsetText() ); | 133 | mItem->setText(6,e->alarms().first()->offsetText() ); |
134 | } else { | 134 | } else { |
135 | mItem->setText(6, i18n("No")); | 135 | mItem->setText(6, i18n("No")); |
136 | } | 136 | } |
137 | mItem->setText(7, e->recurrenceText()); | 137 | mItem->setText(7, e->recurrenceText()); |
138 | if( ! e->doesRecur() ) | 138 | if( ! e->doesRecur() ) |
139 | mItem->setSortKey( 7, "-" ); | 139 | mItem->setSortKey( 7, "-" ); |
140 | mItem->setText(8, e->cancelled() ? i18n("Yes") : i18n("No")); | 140 | mItem->setText(8, e->cancelled() ? i18n("Yes") : i18n("No")); |
141 | mItem->setText(9,e->categoriesStr()); | 141 | mItem->setText(9,e->categoriesStr()); |
142 | mItem->setText(10, KOPrefs::instance()->calName( e->calID() )); | 142 | mItem->setText(10, KOPrefs::instance()->calName( e->calID() )); |
143 | mItem->setText(11, KGlobal::locale()->formatDateTime( e->lastModified(), true, true )); | 143 | mItem->setText(11, KGlobal::locale()->formatDateTime( e->lastModified(), true, true )); |
144 | mItem->setSortKey(11,e->lastModifiedSortKey()); | ||
144 | 145 | ||
145 | QString key; | 146 | QString key; |
146 | QDate d = e->lastModified().date(); | 147 | QTime t; |
147 | QTime t = e->lastModified().time(); | ||
148 | key.sprintf("%04d%02d%02d%02d%02d%02d",d.year(),d.month(),d.day(),t.hour(),t.minute(),t.second() ); | ||
149 | mItem->setSortKey(12,key); | ||
150 | t = e->doesFloat() ? QTime(0,0) : e->dtStart().time(); | 148 | t = e->doesFloat() ? QTime(0,0) : e->dtStart().time(); |
151 | key.sprintf("%04d%02d%02d%02d%02d",ds.year(),ds.month(),ds.day(),t.hour(),t.minute()); | 149 | key.sprintf("%04d%02d%02d%02d%02d",ds.year(),ds.month(),ds.day(),t.hour(),t.minute()); |
152 | mItem->setSortKey(1,key); | 150 | mItem->setSortKey(1,key); |
153 | 151 | ||
154 | t = e->doesFloat() ? QTime(0,0) : e->dtEnd().time(); | 152 | t = e->doesFloat() ? QTime(0,0) : e->dtEnd().time(); |
155 | key.sprintf("%04d%02d%02d%02d%02d",de.year(),de.month(),de.day(),t.hour(),t.minute()); | 153 | key.sprintf("%04d%02d%02d%02d%02d",de.year(),de.month(),de.day(),t.hour(),t.minute()); |
156 | mItem->setSortKey(3,key); | 154 | mItem->setSortKey(3,key); |
157 | return true; | 155 | return true; |
158 | } | 156 | } |
159 | 157 | ||
160 | bool ListItemVisitor::visit(Todo *t) | 158 | bool ListItemVisitor::visit(Todo *t) |
161 | { | 159 | { |
162 | mItem->setText(0,t->summary()); | 160 | mItem->setText(0,t->summary()); |
163 | if ( t->isCompleted() ) { | 161 | if ( t->isCompleted() ) { |
164 | mItem->setSortKey(0,"99"+ t->summary().left(10)); | 162 | mItem->setSortKey(0,"99"+ t->summary().left(10)); |
165 | } else | 163 | } else |
166 | mItem->setSortKey(0,QString::number( t->percentComplete()+1 )+ t->summary().left(10)); | 164 | mItem->setSortKey(0,QString::number( t->percentComplete()+1 )+ t->summary().left(10)); |
167 | mItem->setPixmap( 0, *(sgListViewCompletedPix[t->percentComplete()/20])); | 165 | mItem->setPixmap( 0, *(sgListViewCompletedPix[t->percentComplete()/20])); |
168 | if (t->hasStartDate()) { | 166 | if (t->hasStartDate()) { |
169 | mItem->setText(1,t->dtStartDateStr()); | 167 | mItem->setText(1,t->dtStartDateStr()); |
170 | if (t->doesFloat()) { | 168 | if (t->doesFloat()) { |
171 | mItem->setText(2,"---"); | 169 | mItem->setText(2,"---"); |
172 | } else { | 170 | } else { |
173 | mItem->setText(2,t->dtStartTimeStr()); | 171 | mItem->setText(2,t->dtStartTimeStr()); |
174 | } | 172 | } |
175 | } else { | 173 | } else { |
176 | mItem->setText(1,"---"); | 174 | mItem->setText(1,"---"); |
177 | mItem->setText(2,"---"); | 175 | mItem->setText(2,"---"); |
178 | } | 176 | } |
179 | if ( t->isAlarmEnabled() ) { | 177 | if ( t->isAlarmEnabled() ) { |
180 | mItem->setText(6,t->alarms().first()->offsetText() ); | 178 | mItem->setText(6,t->alarms().first()->offsetText() ); |
181 | } else { | 179 | } else { |
182 | mItem->setText(6, i18n("No")); | 180 | mItem->setText(6, i18n("No")); |
183 | } | 181 | } |
184 | mItem->setText(7, t->recurrenceText()); | 182 | mItem->setText(7, t->recurrenceText()); |
185 | if( ! t->doesRecur() ) | 183 | if( ! t->doesRecur() ) |
186 | mItem->setSortKey( 7, "-" ); | 184 | mItem->setSortKey( 7, "-" ); |
187 | if (t->hasDueDate()) { | 185 | if (t->hasDueDate()) { |
188 | mItem->setText(3,t->dtDueDateStr()); | 186 | mItem->setText(3,t->dtDueDateStr()); |
189 | if (t->doesFloat()) { | 187 | if (t->doesFloat()) { |
190 | mItem->setText(4,"---"); | 188 | mItem->setText(4,"---"); |
191 | } else { | 189 | } else { |
192 | mItem->setText(4,t->dtDueTimeStr()); | 190 | mItem->setText(4,t->dtDueTimeStr()); |
193 | } | 191 | } |
194 | } else { | 192 | } else { |
195 | mItem->setText(3,"---"); | 193 | mItem->setText(3,"---"); |
196 | mItem->setText(4,"---"); | 194 | mItem->setText(4,"---"); |
197 | } | 195 | } |
198 | mItem->setText(5, t->durationText()); | 196 | mItem->setText(5, t->durationText()); |
199 | mItem->setText(8, t->cancelled() ? i18n("Yes") : i18n("No")); | 197 | mItem->setText(8, t->cancelled() ? i18n("Yes") : i18n("No")); |
200 | mItem->setText(9,t->categoriesStr()); | 198 | mItem->setText(9,t->categoriesStr()); |
201 | mItem->setText(10, KOPrefs::instance()->calName( t->calID() )); | 199 | mItem->setText(10, KOPrefs::instance()->calName( t->calID() )); |
202 | mItem->setText(11, KGlobal::locale()->formatDateTime( t->lastModified(), true, true )); | 200 | mItem->setText(11, KGlobal::locale()->formatDateTime( t->lastModified(), true, true )); |
201 | mItem->setSortKey(11,t->lastModifiedSortKey()); | ||
203 | QString key; | 202 | QString key; |
204 | QDate d = t->lastModified().date(); | 203 | QDate d; |
205 | QTime tm = t->lastModified().time(); | 204 | QTime tm; |
206 | key.sprintf("%04d%02d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute(),tm.second() ); | ||
207 | mItem->setSortKey(11,key); | ||
208 | if (t->hasDueDate()) { | 205 | if (t->hasDueDate()) { |
209 | d = t->dtDue().date(); | 206 | d = t->dtDue().date(); |
210 | tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time(); | 207 | tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time(); |
211 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); | 208 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); |
212 | mItem->setSortKey(3,key); | 209 | mItem->setSortKey(3,key); |
213 | } | 210 | } |
214 | if ( t->hasStartDate() ) { | 211 | if ( t->hasStartDate() ) { |
215 | d = t->dtStart().date(); | 212 | d = t->dtStart().date(); |
216 | tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time(); | 213 | tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time(); |
217 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); | 214 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); |
218 | mItem->setSortKey(1,key); | 215 | mItem->setSortKey(1,key); |
219 | } | 216 | } |
220 | return true; | 217 | return true; |
221 | } | 218 | } |
222 | 219 | ||
223 | bool ListItemVisitor::visit(Journal * j) | 220 | bool ListItemVisitor::visit(Journal * j) |
224 | { | 221 | { |
225 | 222 | ||
226 | QString des; | 223 | QString des; |
227 | mItem->setPixmap( 0, *sgListViewJournalPix); | 224 | mItem->setPixmap( 0, *sgListViewJournalPix); |
228 | if ( !j->summary().isEmpty() ) { | 225 | if ( !j->summary().isEmpty() ) { |
229 | des = j->summary(); | 226 | des = j->summary(); |
230 | } else { | 227 | } else { |
231 | des = j->description().left(30); | 228 | des = j->description().left(30); |
232 | des = des.simplifyWhiteSpace (); | 229 | des = des.simplifyWhiteSpace (); |
233 | des.replace (QRegExp ("\\n"),"" ); | 230 | des.replace (QRegExp ("\\n"),"" ); |
234 | des.replace (QRegExp ("\\r"),"" ); | 231 | des.replace (QRegExp ("\\r"),"" ); |
235 | } | 232 | } |
236 | mItem->setText(0,des.left(25)); | 233 | mItem->setText(0,des.left(25)); |
237 | mItem->setSortKey(0,"0"+ des.left(25)); | 234 | mItem->setSortKey(0,"0"+ des.left(25)); |
238 | mItem->setText(1,j->dtStartDateStr()); | 235 | mItem->setText(1,j->dtStartDateStr()); |
239 | mItem->setText(2,"---"); | 236 | mItem->setText(2,"---"); |
240 | mItem->setText(3,"---"); | 237 | mItem->setText(3,"---"); |
241 | mItem->setText(4,"---"); | 238 | mItem->setText(4,"---"); |
242 | mItem->setText(5,"---"); | 239 | mItem->setText(5,"---"); |
243 | mItem->setText(6,"---"); | 240 | mItem->setText(6,"---"); |
244 | mItem->setText(7,"---"); | 241 | mItem->setText(7,"---"); |
245 | mItem->setText(8,"---"); | 242 | mItem->setText(8,"---"); |
246 | mItem->setText(9,j->categoriesStr()); | 243 | mItem->setText(9,j->categoriesStr()); |
247 | mItem->setText(10, KOPrefs::instance()->calName( j->calID() )); | 244 | mItem->setText(10, KOPrefs::instance()->calName( j->calID() )); |
248 | mItem->setText(11, KGlobal::locale()->formatDateTime( j->lastModified(), true, true )); | 245 | mItem->setText(11, KGlobal::locale()->formatDateTime( j->lastModified(), true, true )); |
246 | mItem->setSortKey(11,j->lastModifiedSortKey()); | ||
249 | 247 | ||
250 | QString key; | 248 | QString key; |
251 | QDate d = j->lastModified().date(); | 249 | QDate d; |
252 | QTime tm = j->lastModified().time(); | ||
253 | key.sprintf("%04d%02d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute(),tm.second() ); | ||
254 | mItem->setSortKey(12,key); | ||
255 | d = j->dtStart().date(); | 250 | d = j->dtStart().date(); |
256 | key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); | 251 | key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); |
257 | mItem->setSortKey(1,key); | 252 | mItem->setSortKey(1,key); |
258 | mItem->setSortKey(7,key); | ||
259 | |||
260 | return true; | 253 | return true; |
261 | } | 254 | } |
262 | 255 | ||
263 | KOListView::KOListView(Calendar *calendar, QWidget *parent, | 256 | KOListView::KOListView(Calendar *calendar, QWidget *parent, |
264 | const char *name) | 257 | const char *name) |
265 | : KOEventView(calendar, parent, name) | 258 | : KOEventView(calendar, parent, name) |
266 | { | 259 | { |
267 | 260 | ||
268 | mActiveItem = 0; | 261 | mActiveItem = 0; |
269 | mForceShowCompletedTodos = false; | 262 | mForceShowCompletedTodos = false; |
270 | mListView = new KOListViewListView(this); | 263 | mListView = new KOListViewListView(this); |
271 | mListView->addColumn(i18n("Summary")); | 264 | mListView->addColumn(i18n("Summary")); |
272 | mListView->addColumn(i18n("Start Date")); | 265 | mListView->addColumn(i18n("Start Date")); |
273 | mListView->addColumn(i18n("Start Time")); | 266 | mListView->addColumn(i18n("Start Time")); |
274 | mListView->addColumn(i18n("End/Due Date")); | 267 | mListView->addColumn(i18n("End/Due Date")); |
275 | mListView->addColumn(i18n("End/Due Time")); | 268 | mListView->addColumn(i18n("End/Due Time")); |
276 | mListView->addColumn(i18n("Duration")); | 269 | mListView->addColumn(i18n("Duration")); |
277 | mListView->addColumn(i18n("Alarm")); // alarm set? | 270 | mListView->addColumn(i18n("Alarm")); // alarm set? |
278 | mListView->addColumn(i18n("Recurs")); // recurs? | 271 | mListView->addColumn(i18n("Recurs")); // recurs? |
279 | mListView->addColumn(i18n("Cancelled")); | 272 | mListView->addColumn(i18n("Cancelled")); |
280 | mListView->addColumn(i18n("Categories")); | 273 | mListView->addColumn(i18n("Categories")); |
281 | mListView->addColumn(i18n("Calendar")); | 274 | mListView->addColumn(i18n("Calendar")); |
282 | mListView->addColumn(i18n("Last Modified")); | 275 | mListView->addColumn(i18n("Last Modified")); |
283 | 276 | ||
284 | mListView->setColumnAlignment(0,AlignLeft); | 277 | mListView->setColumnAlignment(0,AlignLeft); |
285 | mListView->setColumnAlignment(1,AlignLeft); | 278 | mListView->setColumnAlignment(1,AlignLeft); |
286 | mListView->setColumnAlignment(2,AlignHCenter); | 279 | mListView->setColumnAlignment(2,AlignHCenter); |
287 | mListView->setColumnAlignment(3,AlignLeft); | 280 | mListView->setColumnAlignment(3,AlignLeft); |
288 | mListView->setColumnAlignment(4,AlignHCenter); | 281 | mListView->setColumnAlignment(4,AlignHCenter); |
289 | mListView->setColumnAlignment(5,AlignLeft); | 282 | mListView->setColumnAlignment(5,AlignLeft); |
290 | mListView->setColumnAlignment(6,AlignLeft); | 283 | mListView->setColumnAlignment(6,AlignLeft); |
291 | mListView->setColumnAlignment(7,AlignLeft); | 284 | mListView->setColumnAlignment(7,AlignLeft); |
292 | mListView->setColumnAlignment(8,AlignLeft); | 285 | mListView->setColumnAlignment(8,AlignLeft); |
293 | mListView->setColumnAlignment(9,AlignLeft); | 286 | mListView->setColumnAlignment(9,AlignLeft); |
294 | mListView->setColumnAlignment(10,AlignLeft); | 287 | mListView->setColumnAlignment(10,AlignLeft); |
295 | mListView->setColumnAlignment(11,AlignLeft); | 288 | mListView->setColumnAlignment(11,AlignLeft); |
296 | mKOListViewWhatsThis = new KOListViewWhatsThis(mListView->viewport(),this); | 289 | mKOListViewWhatsThis = new KOListViewWhatsThis(mListView->viewport(),this); |
297 | 290 | ||
298 | int iii = 0; | 291 | int iii = 0; |
299 | for ( iii = 0; iii< 12 ; ++iii ) | 292 | for ( iii = 0; iii< 12 ; ++iii ) |
300 | mListView->setColumnWidthMode( iii, QListView::Manual ); | 293 | mListView->setColumnWidthMode( iii, QListView::Manual ); |
301 | 294 | ||
302 | QBoxLayout *layoutTop = new QVBoxLayout(this); | 295 | QBoxLayout *layoutTop = new QVBoxLayout(this); |
303 | layoutTop->addWidget(mListView); | 296 | layoutTop->addWidget(mListView); |
304 | mListView->setFont ( KOPrefs::instance()->mListViewFont ); | 297 | mListView->setFont ( KOPrefs::instance()->mListViewFont ); |
305 | mPopupMenu = eventPopup(); | 298 | mPopupMenu = eventPopup(); |
306 | QPopupMenu* selPopup = new QPopupMenu ( this ); | 299 | QPopupMenu* selPopup = new QPopupMenu ( this ); |
307 | mPopupMenu->insertSeparator(); | 300 | mPopupMenu->insertSeparator(); |
308 | 301 | ||
309 | selPopup->insertItem(i18n("All"),this, | 302 | selPopup->insertItem(i18n("All"),this, |
310 | SLOT(allSelection())); | 303 | SLOT(allSelection())); |
311 | selPopup->insertItem(i18n("None"),this, | 304 | selPopup->insertItem(i18n("None"),this, |
312 | SLOT(clearSelection())); | 305 | SLOT(clearSelection())); |
313 | selPopup->insertItem(i18n("Delete selected..."),this, | 306 | selPopup->insertItem(i18n("Delete selected..."),this, |
314 | SLOT(deleteAll())); | 307 | SLOT(deleteAll())); |
315 | mPopupMenu->insertItem(i18n("Selection"), selPopup ); | 308 | mPopupMenu->insertItem(i18n("Selection"), selPopup ); |
316 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 309 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
317 | i18n("Hide all selected"),this, | 310 | i18n("Hide all selected"),this, |
318 | SLOT(hideAll()),true); | 311 | SLOT(hideAll()),true); |
319 | 312 | ||
320 | selPopup->insertSeparator(); | 313 | selPopup->insertSeparator(); |
321 | QPopupMenu * exportPO = new QPopupMenu ( this ); | 314 | QPopupMenu * exportPO = new QPopupMenu ( this ); |
322 | selPopup->insertItem( i18n("Export"), exportPO ); | 315 | selPopup->insertItem( i18n("Export"), exportPO ); |
323 | #ifdef DESKTOP_VERSION | 316 | #ifdef DESKTOP_VERSION |
324 | mPopupMenu->insertSeparator(); | 317 | mPopupMenu->insertSeparator(); |
325 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 318 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
326 | i18n("Print complete list..."),this, | 319 | i18n("Print complete list..."),this, |
327 | SLOT(printList()),true); | 320 | SLOT(printList()),true); |
328 | #endif | 321 | #endif |
329 | mCalPopup = new QPopupMenu ( this ); | 322 | mCalPopup = new QPopupMenu ( this ); |
330 | selPopup->insertItem( i18n("Set Calendar"), mCalPopup ); | 323 | selPopup->insertItem( i18n("Set Calendar"), mCalPopup ); |
331 | 324 | ||
332 | selPopup->insertItem(i18n("Set categories")+"...",this, | 325 | selPopup->insertItem(i18n("Set categories")+"...",this, |
333 | SLOT(setCat()) ); | 326 | SLOT(setCat()) ); |
334 | selPopup->insertItem( i18n("Set alarm..."),this, | 327 | selPopup->insertItem( i18n("Set alarm..."),this, |
335 | SLOT(setAlarm())); | 328 | SLOT(setAlarm())); |
336 | #if 0 | 329 | #if 0 |
337 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 330 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
338 | i18n("Set categories")+"...",this, | 331 | i18n("Set categories")+"...",this, |
339 | SLOT(setCat()),true); | 332 | SLOT(setCat()),true); |
340 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 333 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
341 | i18n("Set alarm..."),this, | 334 | i18n("Set alarm..."),this, |
342 | SLOT(setAlarm()),true); | 335 | SLOT(setAlarm()),true); |
343 | #endif | 336 | #endif |
344 | QObject::connect(mCalPopup,SIGNAL(aboutToShow()),this, | 337 | QObject::connect(mCalPopup,SIGNAL(aboutToShow()),this, |
345 | SLOT( populateCalPopup() )); | 338 | SLOT( populateCalPopup() )); |
346 | QObject::connect(mCalPopup,SIGNAL(activated( int )),this, | 339 | QObject::connect(mCalPopup,SIGNAL(activated( int )),this, |
347 | SLOT( setCalendar( int ) )); | 340 | SLOT( setCalendar( int ) )); |
348 | QObject::connect(mPopupMenu,SIGNAL(categoryChanged( Incidence * )),this, | 341 | QObject::connect(mPopupMenu,SIGNAL(categoryChanged( Incidence * )),this, |
349 | SLOT( catChanged( Incidence * ) )); | 342 | SLOT( catChanged( Incidence * ) )); |
350 | exportPO->insertItem( i18n("As iCal (ics) file..."),this, | 343 | exportPO->insertItem( i18n("As iCal (ics) file..."),this, |
351 | SLOT(saveToFile())); | 344 | SLOT(saveToFile())); |
352 | exportPO->insertItem( i18n("As vCal (vcs) file..."),this, | 345 | exportPO->insertItem( i18n("As vCal (vcs) file..."),this, |
353 | SLOT(saveToFileVCS())); | 346 | SLOT(saveToFileVCS())); |
354 | exportPO->insertItem( i18n("Journal/Details..."),this, | 347 | exportPO->insertItem( i18n("Journal/Details..."),this, |
355 | SLOT(saveDescriptionToFile())); | 348 | SLOT(saveDescriptionToFile())); |
356 | // mPopupMenu->insertSeparator(); | 349 | // mPopupMenu->insertSeparator(); |
357 | // mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 350 | // mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
358 | // i18n("Add Categ. to selected..."),this, | 351 | // i18n("Add Categ. to selected..."),this, |
359 | // SLOT(addCat()),true); | 352 | // SLOT(addCat()),true); |
360 | //mPopupMenu->insertSeparator(); | 353 | //mPopupMenu->insertSeparator(); |
361 | #ifndef DESKTOP_VERSION | 354 | #ifndef DESKTOP_VERSION |
362 | selPopup->insertSeparator(); | 355 | selPopup->insertSeparator(); |
363 | selPopup->insertItem( i18n("Beam via IR..."),this, | 356 | selPopup->insertItem( i18n("Beam via IR..."),this, |
364 | SLOT(beamSelected())); | 357 | SLOT(beamSelected())); |
365 | #if 0 | 358 | #if 0 |
366 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 359 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
367 | i18n("Beam via IR"),this, | 360 | i18n("Beam via IR"),this, |
368 | SLOT(beamSelected()),true); | 361 | SLOT(beamSelected()),true); |
369 | #endif | 362 | #endif |
370 | #endif | 363 | #endif |
371 | /* | 364 | /* |
372 | mPopupMenu = new QPopupMenu; | 365 | mPopupMenu = new QPopupMenu; |
373 | mPopupMenu->insertItem(i18n("Edit Event"), this, | 366 | mPopupMenu->insertItem(i18n("Edit Event"), this, |
374 | SLOT (editEvent())); | 367 | SLOT (editEvent())); |
375 | mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this, | 368 | mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this, |
376 | SLOT (deleteEvent())); | 369 | SLOT (deleteEvent())); |
377 | mPopupMenu->insertSeparator(); | 370 | mPopupMenu->insertSeparator(); |
378 | mPopupMenu->insertItem(i18n("Show Dates"), this, | 371 | mPopupMenu->insertItem(i18n("Show Dates"), this, |
379 | SLOT(showDates())); | 372 | SLOT(showDates())); |
380 | mPopupMenu->insertItem(i18n("Hide Dates"), this, | 373 | mPopupMenu->insertItem(i18n("Hide Dates"), this, |
381 | SLOT(hideDates())); | 374 | SLOT(hideDates())); |
382 | */ | 375 | */ |
383 | QObject::connect(mListView,SIGNAL( newEvent()), | 376 | QObject::connect(mListView,SIGNAL( newEvent()), |
384 | this,SIGNAL(signalNewEvent())); | 377 | this,SIGNAL(signalNewEvent())); |
385 | QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)), | 378 | QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)), |
386 | this,SLOT(defaultItemAction(QListViewItem *))); | 379 | this,SLOT(defaultItemAction(QListViewItem *))); |
387 | QObject::connect(mListView,SIGNAL(rightButtonPressed( QListViewItem *, | 380 | QObject::connect(mListView,SIGNAL(rightButtonPressed( QListViewItem *, |
388 | const QPoint &, int )), | 381 | const QPoint &, int )), |
389 | this,SLOT(popupMenu(QListViewItem *,const QPoint &,int))); | 382 | this,SLOT(popupMenu(QListViewItem *,const QPoint &,int))); |
390 | QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)), | 383 | QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)), |
391 | SLOT(processSelectionChange(QListViewItem *))); | 384 | SLOT(processSelectionChange(QListViewItem *))); |
392 | QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)), | 385 | QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)), |
393 | SIGNAL(showIncidenceSignal(Incidence *)) ); | 386 | SIGNAL(showIncidenceSignal(Incidence *)) ); |
394 | 387 | ||
395 | readSettings(KOGlobals::config(),"KOListView Layout"); | 388 | readSettings(KOGlobals::config(),"KOListView Layout"); |
396 | } | 389 | } |
397 | 390 | ||
398 | KOListView::~KOListView() | 391 | KOListView::~KOListView() |
399 | { | 392 | { |
400 | delete mPopupMenu; | 393 | delete mPopupMenu; |
401 | #if QT_VERSION >= 0x030000 | 394 | #if QT_VERSION >= 0x030000 |
402 | 395 | ||
403 | #else | 396 | #else |
404 | delete mKOListViewWhatsThis; | 397 | delete mKOListViewWhatsThis; |
405 | #endif | 398 | #endif |
406 | } | 399 | } |
407 | 400 | ||
408 | void KOListView::catChanged( Incidence* inc) | 401 | void KOListView::catChanged( Incidence* inc) |
409 | { | 402 | { |
410 | KOListViewItem* item = getItemForEvent(inc); | 403 | KOListViewItem* item = getItemForEvent(inc); |
411 | if (item) { | 404 | if (item) { |
412 | ListItemVisitor v(item, mStartDate ); | 405 | ListItemVisitor v(item, mStartDate ); |
413 | inc->accept(v); | 406 | inc->accept(v); |
414 | } | 407 | } |
415 | } | 408 | } |
416 | QString KOListView::getWhatsThisText(QPoint p) | 409 | QString KOListView::getWhatsThisText(QPoint p) |
417 | { | 410 | { |
418 | KOListViewItem* item = ( KOListViewItem* ) mListView->itemAt( p ); | 411 | KOListViewItem* item = ( KOListViewItem* ) mListView->itemAt( p ); |
419 | if ( item ) | 412 | if ( item ) |
420 | return KIncidenceFormatter::instance()->getFormattedText( item->data(), | 413 | return KIncidenceFormatter::instance()->getFormattedText( item->data(), |
421 | KOPrefs::instance()->mWTshowDetails, | 414 | KOPrefs::instance()->mWTshowDetails, |
422 | KOPrefs::instance()->mWTshowCreated, | 415 | KOPrefs::instance()->mWTshowCreated, |
423 | KOPrefs::instance()->mWTshowChanged); | 416 | KOPrefs::instance()->mWTshowChanged); |
424 | return i18n("That is the list view" ); | 417 | return i18n("That is the list view" ); |
425 | 418 | ||
426 | } | 419 | } |
427 | 420 | ||
428 | void KOListView::setCalendar( int c ) | 421 | void KOListView::setCalendar( int c ) |
429 | { | 422 | { |
430 | int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"), | 423 | int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"), |
431 | i18n("This adds the selected\nitems to the calendar\n%1\nand removes them from\ntheir current calendar!").arg( KOPrefs::instance()->calName( c ) ), | 424 | i18n("This adds the selected\nitems to the calendar\n%1\nand removes them from\ntheir current calendar!").arg( KOPrefs::instance()->calName( c ) ), |
432 | i18n("Continue"), i18n("Cancel"), 0, | 425 | i18n("Continue"), i18n("Cancel"), 0, |
433 | 0, 1 ); | 426 | 0, 1 ); |
434 | if ( result != 0 ) { | 427 | if ( result != 0 ) { |
435 | return; | 428 | return; |
436 | } | 429 | } |
437 | 430 | ||
438 | QPtrList<Incidence> delSel = getSelectedIncidences() ; | 431 | QPtrList<Incidence> delSel = getSelectedIncidences() ; |
439 | int icount = delSel.count(); | 432 | int icount = delSel.count(); |
440 | if ( icount ) { | 433 | if ( icount ) { |
441 | Incidence *incidence = delSel.first(); | 434 | Incidence *incidence = delSel.first(); |
442 | while ( incidence ) { | 435 | while ( incidence ) { |
443 | incidence->setCalID( c ); | 436 | incidence->setCalID( c ); |
444 | KOListViewItem * item = getItemForEvent( incidence ); | 437 | KOListViewItem * item = getItemForEvent( incidence ); |
445 | if ( item ) { | 438 | if ( item ) { |
446 | ListItemVisitor v(item, mStartDate ); | 439 | ListItemVisitor v(item, mStartDate ); |
447 | incidence->accept(v); | 440 | incidence->accept(v); |
448 | } | 441 | } |
449 | incidence = delSel.next(); | 442 | incidence = delSel.next(); |
450 | } | 443 | } |
451 | } | 444 | } |
452 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 445 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
453 | KopiCalendarFile * cal = calendars.first(); | 446 | KopiCalendarFile * cal = calendars.first(); |
454 | while ( cal ) { | 447 | while ( cal ) { |
455 | mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); | 448 | mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); |
456 | mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); | 449 | mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); |
457 | mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); | 450 | mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); |
458 | if ( cal->isStandard ) | 451 | if ( cal->isStandard ) |
459 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 452 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
460 | cal = calendars.next(); | 453 | cal = calendars.next(); |
461 | } | 454 | } |
462 | mCalendar->setSyncEventsReadOnly(); | 455 | mCalendar->setSyncEventsReadOnly(); |
463 | mCalendar->reInitAlarmSettings(); | 456 | mCalendar->reInitAlarmSettings(); |
464 | 457 | ||
465 | } | 458 | } |
466 | void KOListView::populateCalPopup() | 459 | void KOListView::populateCalPopup() |
467 | { | 460 | { |
468 | mCalPopup->clear(); | 461 | mCalPopup->clear(); |
469 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); | 462 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); |
470 | while ( kkf ) { | 463 | while ( kkf ) { |
471 | int index = mCalPopup->insertItem( kkf->mName+"...", kkf->mCalNumber); | 464 | int index = mCalPopup->insertItem( kkf->mName+"...", kkf->mCalNumber); |
472 | if ( kkf->mErrorOnLoad || kkf->isReadOnly ) | 465 | if ( kkf->mErrorOnLoad || kkf->isReadOnly ) |
473 | mCalPopup->setItemEnabled( index, false ); | 466 | mCalPopup->setItemEnabled( index, false ); |
474 | kkf = KOPrefs::instance()->mCalendars.next(); | 467 | kkf = KOPrefs::instance()->mCalendars.next(); |
475 | } | 468 | } |
476 | } | 469 | } |
477 | void KOListView::updateList() | 470 | void KOListView::updateList() |
478 | { | 471 | { |
479 | // qDebug(" KOListView::updateList() "); | 472 | // qDebug(" KOListView::updateList() "); |
480 | 473 | ||
481 | } | 474 | } |
482 | 475 | ||
483 | void KOListView::clearList() | 476 | void KOListView::clearList() |
484 | { | 477 | { |
485 | clear (); | 478 | clear (); |
486 | } | 479 | } |
487 | 480 | ||
488 | void KOListView::setCat() | 481 | void KOListView::setCat() |
489 | { | 482 | { |
490 | 483 | ||
491 | bool set = true; | 484 | bool set = true; |
492 | int result = KMessageBox::warningYesNoCancel(this, | 485 | int result = KMessageBox::warningYesNoCancel(this, |
493 | i18n("Do you want to <b>add</b> categories to the selected items or <b>reset</b> the list (i.e. remove current categories)?"), | 486 | i18n("Do you want to <b>add</b> categories to the selected items or <b>reset</b> the list (i.e. remove current categories)?"), |
494 | i18n("Set categories"), | 487 | i18n("Set categories"), |
495 | i18n("Add"), | 488 | i18n("Add"), |
496 | i18n("Reset")); | 489 | i18n("Reset")); |
497 | if (result == KMessageBox::Cancel) return; | 490 | if (result == KMessageBox::Cancel) return; |
498 | if (result == KMessageBox::Yes) set = false; | 491 | if (result == KMessageBox::Yes) set = false; |
499 | setCategories( set ); | 492 | setCategories( set ); |
500 | } | 493 | } |
501 | 494 | ||
502 | void KOListView::setAlarm() | 495 | void KOListView::setAlarm() |
503 | { | 496 | { |
504 | KOAlarmPrefs kap( this); | 497 | KOAlarmPrefs kap( this); |
505 | if ( !kap.exec() ) | 498 | if ( !kap.exec() ) |
506 | return; | 499 | return; |
507 | QPtrList<Incidence> delSel = getSelectedIncidences( true, true, false, true ); // no journals, only due todos | 500 | QPtrList<Incidence> delSel = getSelectedIncidences( true, true, false, true ); // no journals, only due todos |
508 | Incidence* inc = delSel.first(); | 501 | Incidence* inc = delSel.first(); |
509 | int count = 0; | 502 | int count = 0; |
510 | while ( inc ) { | 503 | while ( inc ) { |
511 | ++count; | 504 | ++count; |
512 | if (kap.mAlarmButton->isChecked()) { | 505 | if (kap.mAlarmButton->isChecked()) { |
513 | if (inc->alarms().count() == 0) | 506 | if (inc->alarms().count() == 0) |
514 | inc->newAlarm(); | 507 | inc->newAlarm(); |
515 | Alarm *alarm = inc->alarms().first(); | 508 | Alarm *alarm = inc->alarms().first(); |
516 | alarm->setEnabled(true); | 509 | alarm->setEnabled(true); |
517 | int j = kap.mAlarmTimeEdit->value()* -60; | 510 | int j = kap.mAlarmTimeEdit->value()* -60; |
518 | if (kap.mAlarmIncrCombo->currentItem() == 1) | 511 | if (kap.mAlarmIncrCombo->currentItem() == 1) |
519 | j = j * 60; | 512 | j = j * 60; |
520 | else if (kap.mAlarmIncrCombo->currentItem() == 2) | 513 | else if (kap.mAlarmIncrCombo->currentItem() == 2) |
521 | j = j * (60 * 24); | 514 | j = j * (60 * 24); |
522 | alarm->setStartOffset( j ); | 515 | alarm->setStartOffset( j ); |
523 | 516 | ||
524 | if (!kap.mAlarmProgram.isEmpty() && kap.mAlarmProgramButton->isOn()) { | 517 | if (!kap.mAlarmProgram.isEmpty() && kap.mAlarmProgramButton->isOn()) { |
525 | alarm->setProcedureAlarm(kap.mAlarmProgram); | 518 | alarm->setProcedureAlarm(kap.mAlarmProgram); |
526 | } | 519 | } |
527 | else if (!kap.mAlarmSound.isEmpty() && kap.mAlarmSoundButton->isOn()) | 520 | else if (!kap.mAlarmSound.isEmpty() && kap.mAlarmSoundButton->isOn()) |
528 | alarm->setAudioAlarm(kap.mAlarmSound); | 521 | alarm->setAudioAlarm(kap.mAlarmSound); |
529 | else | 522 | else |
530 | alarm->setType(Alarm::Invalid); | 523 | alarm->setType(Alarm::Invalid); |
531 | } else { | 524 | } else { |
532 | QPtrList<Alarm> alarms = inc->alarms(); | 525 | QPtrList<Alarm> alarms = inc->alarms(); |
533 | Alarm *alarm; | 526 | Alarm *alarm; |
534 | for (alarm = alarms.first(); alarm; alarm = alarms.next() ) { | 527 | for (alarm = alarms.first(); alarm; alarm = alarms.next() ) { |
535 | alarm->setEnabled(false); | 528 | alarm->setEnabled(false); |
536 | alarm->setType(Alarm::Invalid); | 529 | alarm->setType(Alarm::Invalid); |
537 | } | 530 | } |
538 | } | 531 | } |
539 | KOListViewItem* item = getItemForEvent(inc); | 532 | KOListViewItem* item = getItemForEvent(inc); |
540 | if (item) { | 533 | if (item) { |
541 | ListItemVisitor v(item, mStartDate ); | 534 | ListItemVisitor v(item, mStartDate ); |
542 | inc->accept(v); | 535 | inc->accept(v); |
543 | } | 536 | } |
544 | inc = delSel.next(); | 537 | inc = delSel.next(); |
545 | } | 538 | } |
546 | topLevelWidget()->setCaption( i18n("Changed alarm for %1 items").arg( count ) ); | 539 | topLevelWidget()->setCaption( i18n("Changed alarm for %1 items").arg( count ) ); |
547 | qDebug("KO: Set alarm for %d items", count); | 540 | qDebug("KO: Set alarm for %d items", count); |
548 | calendar()->reInitAlarmSettings(); | 541 | calendar()->reInitAlarmSettings(); |
549 | QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); | 542 | QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); |
550 | } | 543 | } |
551 | void KOListView::setCategories( bool removeOld ) | 544 | void KOListView::setCategories( bool removeOld ) |
552 | { | 545 | { |
553 | 546 | ||
554 | KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); | 547 | KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); |
555 | csd->setColorEnabled(); | 548 | csd->setColorEnabled(); |
556 | if (! csd->exec()) { | 549 | if (! csd->exec()) { |
557 | delete csd; | 550 | delete csd; |
558 | return; | 551 | return; |
559 | } | 552 | } |
560 | QStringList catList = csd->selectedCategories(); | 553 | QStringList catList = csd->selectedCategories(); |
561 | delete csd; | 554 | delete csd; |
562 | QPtrList<Incidence> delSel = getSelectedIncidences(); // all inc allowed; | 555 | QPtrList<Incidence> delSel = getSelectedIncidences(); // all inc allowed; |
563 | Incidence* inc = delSel.first(); | 556 | Incidence* inc = delSel.first(); |
564 | while ( inc ) { | 557 | while ( inc ) { |
565 | if ( removeOld ) { | 558 | if ( removeOld ) { |
566 | inc->setCategories( catList, false ); | 559 | inc->setCategories( catList, false ); |
567 | } else { | 560 | } else { |
568 | inc->addCategories( catList, false ); | 561 | inc->addCategories( catList, false ); |
569 | } | 562 | } |
570 | KOListViewItem* item = getItemForEvent(inc); | 563 | KOListViewItem* item = getItemForEvent(inc); |
571 | if (item) { | 564 | if (item) { |
572 | ListItemVisitor v(item, mStartDate ); | 565 | ListItemVisitor v(item, mStartDate ); |
573 | inc->accept(v); | 566 | inc->accept(v); |
574 | } | 567 | } |
575 | inc = delSel.next(); | 568 | inc = delSel.next(); |
576 | } | 569 | } |
577 | QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); | 570 | QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); |
578 | } | 571 | } |
579 | 572 | ||
580 | void KOListView::beamSelected() | 573 | void KOListView::beamSelected() |
581 | { | 574 | { |
582 | QPtrList<Incidence> delSel = getSelectedIncidences() ; | 575 | QPtrList<Incidence> delSel = getSelectedIncidences() ; |
583 | if ( delSel.count() ) | 576 | if ( delSel.count() ) |
584 | emit beamIncidenceList( delSel ); | 577 | emit beamIncidenceList( delSel ); |
585 | } | 578 | } |
586 | 579 | ||
587 | void KOListView::saveDescriptionToFile() | 580 | void KOListView::saveDescriptionToFile() |
588 | { | 581 | { |
589 | 582 | ||
590 | int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"), | 583 | int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"), |
591 | i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."), | 584 | i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."), |
592 | i18n("Continue"), i18n("Cancel"), 0, | 585 | i18n("Continue"), i18n("Cancel"), 0, |
593 | 0, 1 ); | 586 | 0, 1 ); |
594 | if ( result != 0 ) { | 587 | if ( result != 0 ) { |
595 | return; | 588 | return; |
596 | } | 589 | } |
597 | QPtrList<Incidence> delSel = getSelectedIncidences() ; | 590 | QPtrList<Incidence> delSel = getSelectedIncidences() ; |
598 | int icount = delSel.count(); | 591 | int icount = delSel.count(); |
599 | if ( icount ) { | 592 | if ( icount ) { |
600 | QString fn = KOPrefs::instance()->mLastSaveFile; | 593 | QString fn = KOPrefs::instance()->mLastSaveFile; |
601 | fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); | 594 | fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); |
602 | 595 | ||
603 | if ( fn == "" ) | 596 | if ( fn == "" ) |
604 | return; | 597 | return; |
605 | QFileInfo info; | 598 | QFileInfo info; |
606 | info.setFile( fn ); | 599 | info.setFile( fn ); |
607 | QString mes; | 600 | QString mes; |
608 | bool createbup = true; | 601 | bool createbup = true; |
609 | if ( info. exists() ) { | 602 | if ( info. exists() ) { |
610 | mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); | 603 | mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); |
611 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 604 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
612 | i18n("Overwrite!"), i18n("Cancel"), 0, | 605 | i18n("Overwrite!"), i18n("Cancel"), 0, |
613 | 0, 1 ); | 606 | 0, 1 ); |
614 | if ( result != 0 ) { | 607 | if ( result != 0 ) { |
615 | createbup = false; | 608 | createbup = false; |
616 | } | 609 | } |
617 | } | 610 | } |
618 | if ( createbup ) { | 611 | if ( createbup ) { |
619 | QString text = i18n("KO/Pi Description/Journal save file.\nSave date: ") + | 612 | QString text = i18n("KO/Pi Description/Journal save file.\nSave date: ") + |
620 | KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), false); | 613 | KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), false); |
621 | Incidence *incidence = delSel.first(); | 614 | Incidence *incidence = delSel.first(); |
622 | icount = 0; | 615 | icount = 0; |
623 | while ( incidence ) { | 616 | while ( incidence ) { |
624 | if ( incidence->typeID() == journalID ) { | 617 | if ( incidence->typeID() == journalID ) { |
625 | text += "\n************************************\n"; | 618 | text += "\n************************************\n"; |
626 | if ( !incidence->summary().isEmpty() ) | 619 | if ( !incidence->summary().isEmpty() ) |
627 | text += i18n("Journal: %1 from ").arg( incidence->summary() ) +incidence->dtStartDateStr( false ); | 620 | text += i18n("Journal: %1 from ").arg( incidence->summary() ) +incidence->dtStartDateStr( false ); |
628 | else | 621 | else |
629 | text += i18n("Journal from: ") +incidence->dtStartDateStr( false ); | 622 | text += i18n("Journal from: ") +incidence->dtStartDateStr( false ); |
630 | if ( !incidence->location().isEmpty() ) | 623 | if ( !incidence->location().isEmpty() ) |
631 | text +="\n(" + i18n("Location: ") + incidence->location()+ ")"; | 624 | text +="\n(" + i18n("Location: ") + incidence->location()+ ")"; |
632 | text +="\n" + i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); | 625 | text +="\n" + i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); |
633 | text +="\n" + i18n("Description: ") + "\n"+ incidence->description(); | 626 | text +="\n" + i18n("Description: ") + "\n"+ incidence->description(); |
634 | ++icount; | 627 | ++icount; |
635 | 628 | ||
636 | } else { | 629 | } else { |
637 | if ( !incidence->description().isEmpty() ) { | 630 | if ( !incidence->description().isEmpty() ) { |
638 | text += "\n************************************\n"; | 631 | text += "\n************************************\n"; |
639 | if ( incidence->typeID() == todoID ) | 632 | if ( incidence->typeID() == todoID ) |
640 | text += i18n("To-Do: "); | 633 | text += i18n("To-Do: "); |
641 | text += incidence->summary(); | 634 | text += incidence->summary(); |
642 | if ( !incidence->location().isEmpty() ) | 635 | if ( !incidence->location().isEmpty() ) |
643 | text +="\n(" + i18n("Location: ") + incidence->location()+ ")"; | 636 | text +="\n(" + i18n("Location: ") + incidence->location()+ ")"; |
diff --git a/korganizer/kotodoviewitem.cpp b/korganizer/kotodoviewitem.cpp index bdef94c..848e9e7 100644 --- a/korganizer/kotodoviewitem.cpp +++ b/korganizer/kotodoviewitem.cpp | |||
@@ -1,558 +1,552 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include <klocale.h> | 20 | #include <klocale.h> |
21 | #include <kdebug.h> | 21 | #include <kdebug.h> |
22 | #include <qapp.h> | 22 | #include <qapp.h> |
23 | #include <kglobal.h> | 23 | #include <kglobal.h> |
24 | 24 | ||
25 | #include <kiconloader.h> | 25 | #include <kiconloader.h> |
26 | #include "kotodoviewitem.h" | 26 | #include "kotodoviewitem.h" |
27 | #include "kotodoview.h" | 27 | #include "kotodoview.h" |
28 | #include "koprefs.h" | 28 | #include "koprefs.h" |
29 | 29 | ||
30 | KOTodoViewItem::KOTodoViewItem( QListView *parent, Todo *todo, KOTodoView *kotodo) | 30 | KOTodoViewItem::KOTodoViewItem( QListView *parent, Todo *todo, KOTodoView *kotodo) |
31 | : QCheckListItem( parent , "", CheckBox ), mTodo( todo ), mTodoView( kotodo ) | 31 | : QCheckListItem( parent , "", CheckBox ), mTodo( todo ), mTodoView( kotodo ) |
32 | { | 32 | { |
33 | construct(); | 33 | construct(); |
34 | } | 34 | } |
35 | 35 | ||
36 | KOTodoViewItem::KOTodoViewItem( KOTodoViewItem *parent, Todo *todo, KOTodoView *kotodo ) | 36 | KOTodoViewItem::KOTodoViewItem( KOTodoViewItem *parent, Todo *todo, KOTodoView *kotodo ) |
37 | : QCheckListItem( parent, "", CheckBox ), mTodo( todo ), mTodoView( kotodo ) | 37 | : QCheckListItem( parent, "", CheckBox ), mTodo( todo ), mTodoView( kotodo ) |
38 | { | 38 | { |
39 | construct(); | 39 | construct(); |
40 | } | 40 | } |
41 | 41 | ||
42 | QString KOTodoViewItem::key(int column,bool) const | 42 | QString KOTodoViewItem::key(int column,bool) const |
43 | { | 43 | { |
44 | QMap<int,QString>::ConstIterator it = mKeyMap.find(column); | 44 | QMap<int,QString>::ConstIterator it = mKeyMap.find(column); |
45 | if (it == mKeyMap.end()) { | 45 | if (it == mKeyMap.end()) { |
46 | return text(column).lower(); | 46 | return text(column).lower(); |
47 | } else { | 47 | } else { |
48 | return *it; | 48 | return *it; |
49 | } | 49 | } |
50 | } | 50 | } |
51 | 51 | ||
52 | void KOTodoViewItem:: setup() | 52 | void KOTodoViewItem:: setup() |
53 | { | 53 | { |
54 | 54 | ||
55 | int h = 20; | 55 | int h = 20; |
56 | if ( listView () ) { | 56 | if ( listView () ) { |
57 | QFontMetrics fm ( listView ()->font () ); | 57 | QFontMetrics fm ( listView ()->font () ); |
58 | h = fm.height(); | 58 | h = fm.height(); |
59 | } | 59 | } |
60 | setHeight( h ); | 60 | setHeight( h ); |
61 | 61 | ||
62 | } | 62 | } |
63 | void KOTodoViewItem::setSortKey(int column,const QString &key) | 63 | void KOTodoViewItem::setSortKey(int column,const QString &key) |
64 | { | 64 | { |
65 | mKeyMap.insert(column,key); | 65 | mKeyMap.insert(column,key); |
66 | } | 66 | } |
67 | 67 | ||
68 | #if QT_VERSION >= 0x030000 | 68 | #if QT_VERSION >= 0x030000 |
69 | void KOTodoViewItem::paintBranches(QPainter *p,const QColorGroup & cg,int w, | 69 | void KOTodoViewItem::paintBranches(QPainter *p,const QColorGroup & cg,int w, |
70 | int y,int h) | 70 | int y,int h) |
71 | { | 71 | { |
72 | QListViewItem::paintBranches(p,cg,w,y,h); | 72 | QListViewItem::paintBranches(p,cg,w,y,h); |
73 | } | 73 | } |
74 | #else | 74 | #else |
75 | #endif | 75 | #endif |
76 | 76 | ||
77 | void KOTodoViewItem::construct() | 77 | void KOTodoViewItem::construct() |
78 | { | 78 | { |
79 | // qDebug("KOTodoViewItem::construct() "); | 79 | // qDebug("KOTodoViewItem::construct() "); |
80 | m_init = true; | 80 | m_init = true; |
81 | QString keyd = "=="; | 81 | QString keyd = "=="; |
82 | QString keyt = "=="; | 82 | QString keyt = "=="; |
83 | QString skeyd = "=="; | 83 | QString skeyd = "=="; |
84 | QString skeyt = "=="; | 84 | QString skeyt = "=="; |
85 | 85 | ||
86 | setOn(mTodo->isCompleted()); | 86 | setOn(mTodo->isCompleted()); |
87 | setText(0,mTodo->summary()); | 87 | setText(0,mTodo->summary()); |
88 | setText(1,QString::number(mTodo->priority())); | 88 | setText(1,QString::number(mTodo->priority())); |
89 | setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete()))); | 89 | setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete()))); |
90 | if (mTodo->percentComplete()<100) { | 90 | if (mTodo->percentComplete()<100) { |
91 | if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); | 91 | if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); |
92 | else setSortKey(2,QString::number(mTodo->percentComplete())); | 92 | else setSortKey(2,QString::number(mTodo->percentComplete())); |
93 | } | 93 | } |
94 | else { | 94 | else { |
95 | if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); | 95 | if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); |
96 | else setSortKey(2,QString::number(99)); | 96 | else setSortKey(2,QString::number(99)); |
97 | } | 97 | } |
98 | if (mTodo->hasDueDate()) { | 98 | if (mTodo->hasDueDate()) { |
99 | setText(3, mTodo->dtDueDateStr()); | 99 | setText(3, mTodo->dtDueDateStr()); |
100 | QDate d = mTodo->dtDue().date(); | 100 | QDate d = mTodo->dtDue().date(); |
101 | keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); | 101 | keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); |
102 | // setSortKey(3,keyd); | 102 | // setSortKey(3,keyd); |
103 | if (mTodo->doesFloat()) { | 103 | if (mTodo->doesFloat()) { |
104 | setText(4,""); | 104 | setText(4,""); |
105 | } | 105 | } |
106 | else { | 106 | else { |
107 | setText(4,mTodo->dtDueTimeStr()); | 107 | setText(4,mTodo->dtDueTimeStr()); |
108 | QTime t = mTodo->dtDue().time(); | 108 | QTime t = mTodo->dtDue().time(); |
109 | keyt.sprintf("%02d%02d",t.hour(),t.minute()); | 109 | keyt.sprintf("%02d%02d",t.hour(),t.minute()); |
110 | //setSortKey(4,keyt); | 110 | //setSortKey(4,keyt); |
111 | } | 111 | } |
112 | } else { | 112 | } else { |
113 | setText(3,""); | 113 | setText(3,""); |
114 | setText(4,""); | 114 | setText(4,""); |
115 | } | 115 | } |
116 | setSortKey(3,keyd); | 116 | setSortKey(3,keyd); |
117 | setSortKey(4,keyt); | 117 | setSortKey(4,keyt); |
118 | 118 | ||
119 | if (mTodo->isCompleted()) setSortKey(1,"6" + QString::number(mTodo->priority())+keyd+keyt); | 119 | if (mTodo->isCompleted()) setSortKey(1,"6" + QString::number(mTodo->priority())+keyd+keyt); |
120 | else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt); | 120 | else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt); |
121 | 121 | ||
122 | |||
123 | |||
124 | keyd = ""; | 122 | keyd = ""; |
125 | keyt = ""; | 123 | keyt = ""; |
126 | 124 | ||
127 | if (mTodo->isRunning() ) { | 125 | if (mTodo->isRunning() ) { |
128 | QDate d = mTodo->runStart().date(); | 126 | QDate d = mTodo->runStart().date(); |
129 | QTime t = mTodo->runStart().time(); | 127 | QTime t = mTodo->runStart().time(); |
130 | skeyt.sprintf("%02d%02d",t.hour(),t.minute()); | 128 | skeyt.sprintf("%02d%02d",t.hour(),t.minute()); |
131 | skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); | 129 | skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); |
132 | keyd = KGlobal::locale()->formatDate( d , true); | 130 | keyd = KGlobal::locale()->formatDate( d , true); |
133 | keyt = KGlobal::locale()->formatTime( t ); | 131 | keyt = KGlobal::locale()->formatTime( t ); |
134 | 132 | ||
135 | } else { | 133 | } else { |
136 | 134 | ||
137 | if (mTodo->hasStartDate()) { | 135 | if (mTodo->hasStartDate()) { |
138 | keyd = mTodo->dtStartDateStr(); | 136 | keyd = mTodo->dtStartDateStr(); |
139 | QDate d = mTodo->dtStart().date(); | 137 | QDate d = mTodo->dtStart().date(); |
140 | skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); | 138 | skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); |
141 | 139 | ||
142 | if ( !mTodo->doesFloat()) { | 140 | if ( !mTodo->doesFloat()) { |
143 | keyt = mTodo->dtStartTimeStr(); | 141 | keyt = mTodo->dtStartTimeStr(); |
144 | QTime t = mTodo->dtStart().time(); | 142 | QTime t = mTodo->dtStart().time(); |
145 | skeyt.sprintf("%02d%02d",t.hour(),t.minute()); | 143 | skeyt.sprintf("%02d%02d",t.hour(),t.minute()); |
146 | 144 | ||
147 | } | 145 | } |
148 | 146 | ||
149 | } | 147 | } |
150 | } | 148 | } |
151 | setText(5,keyd); | 149 | setText(5,keyd); |
152 | setText(6,keyt); | 150 | setText(6,keyt); |
153 | setSortKey(5,skeyd); | 151 | setSortKey(5,skeyd); |
154 | setSortKey(6,skeyt); | 152 | setSortKey(6,skeyt); |
155 | 153 | ||
156 | //setText(7,mTodo->cancelled() ? i18n("Yes") : i18n("No")); | 154 | //setText(7,mTodo->cancelled() ? i18n("Yes") : i18n("No")); |
157 | setText(7,mTodo->categoriesStr()); | 155 | setText(7,mTodo->categoriesStr()); |
158 | setText(8,KOPrefs::instance()->calName( mTodo->calID())); | 156 | setText(8,KOPrefs::instance()->calName( mTodo->calID())); |
159 | setText(9, KGlobal::locale()->formatDateTime( mTodo->lastModified(), true, true )); | 157 | setText(9, KGlobal::locale()->formatDateTime( mTodo->lastModified(), true, true )); |
160 | setText(10, KGlobal::locale()->formatDateTime( mTodo->created(), true, true )); | 158 | setText(10, KGlobal::locale()->formatDateTime( mTodo->created(), true, true )); |
161 | setText(11, KGlobal::locale()->formatDateTime( mTodo->lastModifiedSub(), true, true )); | 159 | setText(11, KGlobal::locale()->formatDateTime( mTodo->lastModifiedSub(), true, true )); |
162 | QString key; | 160 | QString key; |
163 | QDate d = mTodo->lastModified().date(); | 161 | QDate d; |
164 | QTime t = mTodo->lastModified().time(); | 162 | QTime t; |
165 | key.sprintf("%04d%02d%02d%02d%02d%02d",d.year(),d.month(),d.day(),t.hour(),t.minute(),t.second() ); | 163 | setSortKey(9,mTodo->lastModifiedSortKey()); |
166 | setSortKey(9,key); | ||
167 | d = mTodo->created().date(); | 164 | d = mTodo->created().date(); |
168 | t = mTodo->created().time(); | 165 | t = mTodo->created().time(); |
169 | key.sprintf("%04d%02d%02d%02d%02d%02d",d.year(),d.month(),d.day(),t.hour(),t.minute(),t.second() ); | 166 | key.sprintf("%04d%02d%02d%02d%02d%02d",d.year(),d.month(),d.day(),t.hour(),t.minute(),t.second() ); |
170 | setSortKey(10,key); | 167 | setSortKey(10,key); |
171 | d = mTodo->lastModifiedSub().date(); | 168 | setSortKey(11,mTodo->lastModifiedSubSortKey()); |
172 | t = mTodo->lastModifiedSub().time(); | ||
173 | key.sprintf("%04d%02d%02d%02d%02d%02d",d.year(),d.month(),d.day(),t.hour(),t.minute(),t.second() ); | ||
174 | setSortKey(11,key); | ||
175 | 169 | ||
176 | #if 0 | 170 | #if 0 |
177 | // Find sort id in description. It's the text behind the last '#' character | 171 | // Find sort id in description. It's the text behind the last '#' character |
178 | // found in the description. White spaces are removed from beginning and end | 172 | // found in the description. White spaces are removed from beginning and end |
179 | // of sort id. | 173 | // of sort id. |
180 | int pos = mTodo->description().findRev('#'); | 174 | int pos = mTodo->description().findRev('#'); |
181 | if (pos < 0) { | 175 | if (pos < 0) { |
182 | setText(6,""); | 176 | setText(6,""); |
183 | } else { | 177 | } else { |
184 | QString str = mTodo->description().mid(pos+1); | 178 | QString str = mTodo->description().mid(pos+1); |
185 | str.stripWhiteSpace(); | 179 | str.stripWhiteSpace(); |
186 | setText(6,str); | 180 | setText(6,str); |
187 | } | 181 | } |
188 | #endif | 182 | #endif |
189 | 183 | ||
190 | m_known = false; | 184 | m_known = false; |
191 | m_init = false; | 185 | m_init = false; |
192 | 186 | ||
193 | setMyPixmap(); | 187 | setMyPixmap(); |
194 | 188 | ||
195 | } | 189 | } |
196 | void KOTodoViewItem::setMyPixmap() | 190 | void KOTodoViewItem::setMyPixmap() |
197 | { | 191 | { |
198 | int size = 5; | 192 | int size = 5; |
199 | QPixmap pixi = QPixmap( 1, 1 ); | 193 | QPixmap pixi = QPixmap( 1, 1 ); |
200 | // if ( !mTodo->isCompleted() && mTodo->hasDueDate() && mTodo->dtDue() < QDateTime::currentDateTime() ) { | 194 | // if ( !mTodo->isCompleted() && mTodo->hasDueDate() && mTodo->dtDue() < QDateTime::currentDateTime() ) { |
201 | // pixi = SmallIcon("redcross16"); | 195 | // pixi = SmallIcon("redcross16"); |
202 | // } else { | 196 | // } else { |
203 | QPainter p; | 197 | QPainter p; |
204 | 198 | ||
205 | int pixSize = 0; | 199 | int pixSize = 0; |
206 | QPixmap pPix = QPixmap( size, size ); | 200 | QPixmap pPix = QPixmap( size, size ); |
207 | if ( mTodo->description().length() > 0 ) { | 201 | if ( mTodo->description().length() > 0 ) { |
208 | pixi.resize(size, pixSize+size); | 202 | pixi.resize(size, pixSize+size); |
209 | pPix.fill( Qt::darkGreen ); | 203 | pPix.fill( Qt::darkGreen ); |
210 | p.begin( &pixi ); | 204 | p.begin( &pixi ); |
211 | p. drawPixmap ( 0, pixSize, pPix); | 205 | p. drawPixmap ( 0, pixSize, pPix); |
212 | p.end(); | 206 | p.end(); |
213 | pixSize += size; | 207 | pixSize += size; |
214 | } | 208 | } |
215 | if ( mTodo->isAlarmEnabled() && mTodo->alarmEnabled()) { | 209 | if ( mTodo->isAlarmEnabled() && mTodo->alarmEnabled()) { |
216 | pixi.resize(size, pixSize+size); | 210 | pixi.resize(size, pixSize+size); |
217 | pPix.fill( Qt::red ); | 211 | pPix.fill( Qt::red ); |
218 | p.begin( &pixi ); | 212 | p.begin( &pixi ); |
219 | p. drawPixmap ( 0, pixSize, pPix); | 213 | p. drawPixmap ( 0, pixSize, pPix); |
220 | p.end(); | 214 | p.end(); |
221 | pixSize += size; | 215 | pixSize += size; |
222 | } | 216 | } |
223 | if ( mTodo->doesRecur() ) { | 217 | if ( mTodo->doesRecur() ) { |
224 | pixi.resize(size, pixSize+size); | 218 | pixi.resize(size, pixSize+size); |
225 | pPix.fill( Qt::blue ); | 219 | pPix.fill( Qt::blue ); |
226 | p.begin( &pixi ); | 220 | p.begin( &pixi ); |
227 | p. drawPixmap ( 0, pixSize, pPix); | 221 | p. drawPixmap ( 0, pixSize, pPix); |
228 | p.end(); | 222 | p.end(); |
229 | pixSize += size; | 223 | pixSize += size; |
230 | } | 224 | } |
231 | // } | 225 | // } |
232 | if ( pixi.width() > 1 ) { | 226 | if ( pixi.width() > 1 ) { |
233 | setPixmap ( 0,pixi ) ; | 227 | setPixmap ( 0,pixi ) ; |
234 | } else { | 228 | } else { |
235 | setPixmap ( 0,QPixmap() ) ; | 229 | setPixmap ( 0,QPixmap() ) ; |
236 | } | 230 | } |
237 | } | 231 | } |
238 | void KOTodoViewItem::stateChange(bool state) | 232 | void KOTodoViewItem::stateChange(bool state) |
239 | { | 233 | { |
240 | // qDebug("KOTodoViewItem::stateChange %d ", state); | 234 | // qDebug("KOTodoViewItem::stateChange %d ", state); |
241 | // do not change setting on startup | 235 | // do not change setting on startup |
242 | if ( m_init ) return; | 236 | if ( m_init ) return; |
243 | if (isOn()!=state) { | 237 | if (isOn()!=state) { |
244 | setOn(state); | 238 | setOn(state); |
245 | //qDebug("SETON "); | 239 | //qDebug("SETON "); |
246 | return; | 240 | return; |
247 | } | 241 | } |
248 | if ( mTodo->isCompleted() == state ) { | 242 | if ( mTodo->isCompleted() == state ) { |
249 | //qDebug("STATECHANGE:nothing to do "); | 243 | //qDebug("STATECHANGE:nothing to do "); |
250 | return; | 244 | return; |
251 | } | 245 | } |
252 | QString keyd = "=="; | 246 | QString keyd = "=="; |
253 | QString keyt = "=="; | 247 | QString keyt = "=="; |
254 | //qDebug("KOTodoViewItem::stateChange %s ", text(0).latin1()); | 248 | //qDebug("KOTodoViewItem::stateChange %s ", text(0).latin1()); |
255 | if ( mTodo->doesRecur() ){ | 249 | if ( mTodo->doesRecur() ){ |
256 | QDateTime start = mTodo->dtStart(); | 250 | QDateTime start = mTodo->dtStart(); |
257 | mTodo->setCompleted(state); | 251 | mTodo->setCompleted(state); |
258 | if ( start != mTodo->dtStart() ) { | 252 | if ( start != mTodo->dtStart() ) { |
259 | if ( state && !mTodo->isCompleted() ) { | 253 | if ( state && !mTodo->isCompleted() ) { |
260 | setOn( false ); | 254 | setOn( false ); |
261 | state = false; | 255 | state = false; |
262 | } | 256 | } |
263 | } | 257 | } |
264 | } else | 258 | } else |
265 | mTodo->setCompleted(state); | 259 | mTodo->setCompleted(state); |
266 | 260 | ||
267 | if (state) mTodo->setCompleted(QDateTime::currentDateTime()); | 261 | if (state) mTodo->setCompleted(QDateTime::currentDateTime()); |
268 | 262 | ||
269 | if (mTodo->hasDueDate()) { | 263 | if (mTodo->hasDueDate()) { |
270 | setText(3, mTodo->dtDueDateStr()); | 264 | setText(3, mTodo->dtDueDateStr()); |
271 | QDate d = mTodo->dtDue().date(); | 265 | QDate d = mTodo->dtDue().date(); |
272 | keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); | 266 | keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); |
273 | setSortKey(3,keyd); | 267 | setSortKey(3,keyd); |
274 | if (mTodo->doesFloat()) { | 268 | if (mTodo->doesFloat()) { |
275 | setText(4,""); | 269 | setText(4,""); |
276 | } | 270 | } |
277 | else { | 271 | else { |
278 | setText(4,mTodo->dtDueTimeStr()); | 272 | setText(4,mTodo->dtDueTimeStr()); |
279 | QTime t = mTodo->dtDue().time(); | 273 | QTime t = mTodo->dtDue().time(); |
280 | keyt.sprintf("%02d%02d",t.hour(),t.minute()); | 274 | keyt.sprintf("%02d%02d",t.hour(),t.minute()); |
281 | setSortKey(4,keyt); | 275 | setSortKey(4,keyt); |
282 | } | 276 | } |
283 | } | 277 | } |
284 | if (mTodo->hasStartDate()) { | 278 | if (mTodo->hasStartDate()) { |
285 | QString skeyt = "=="; | 279 | QString skeyt = "=="; |
286 | QString skeyd = "=="; | 280 | QString skeyd = "=="; |
287 | setText(5, mTodo->dtStartDateStr()); | 281 | setText(5, mTodo->dtStartDateStr()); |
288 | QDate d = mTodo->dtStart().date(); | 282 | QDate d = mTodo->dtStart().date(); |
289 | skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); | 283 | skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); |
290 | 284 | ||
291 | if (mTodo->doesFloat()) { | 285 | if (mTodo->doesFloat()) { |
292 | setText(6,""); | 286 | setText(6,""); |
293 | } | 287 | } |
294 | else { | 288 | else { |
295 | setText(6,mTodo->dtStartTimeStr()); | 289 | setText(6,mTodo->dtStartTimeStr()); |
296 | QTime t = mTodo->dtStart().time(); | 290 | QTime t = mTodo->dtStart().time(); |
297 | skeyt.sprintf("%02d%02d",t.hour(),t.minute()); | 291 | skeyt.sprintf("%02d%02d",t.hour(),t.minute()); |
298 | 292 | ||
299 | } | 293 | } |
300 | setSortKey(5,skeyd); | 294 | setSortKey(5,skeyd); |
301 | setSortKey(6,skeyt); | 295 | setSortKey(6,skeyt); |
302 | } | 296 | } |
303 | if (mTodo->isCompleted()) setSortKey(1,QString::number(9)+keyd+keyt); | 297 | if (mTodo->isCompleted()) setSortKey(1,QString::number(9)+keyd+keyt); |
304 | else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt); | 298 | else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt); |
305 | 299 | ||
306 | setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete()))); | 300 | setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete()))); |
307 | if (mTodo->percentComplete()<100) { | 301 | if (mTodo->percentComplete()<100) { |
308 | if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); | 302 | if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); |
309 | else setSortKey(2,QString::number(mTodo->percentComplete())); | 303 | else setSortKey(2,QString::number(mTodo->percentComplete())); |
310 | } | 304 | } |
311 | else { | 305 | else { |
312 | if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); | 306 | if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); |
313 | else setSortKey(2,QString::number(99)); | 307 | else setSortKey(2,QString::number(99)); |
314 | } | 308 | } |
315 | if ( state ) { | 309 | if ( state ) { |
316 | QListViewItem * myChild = firstChild(); | 310 | QListViewItem * myChild = firstChild(); |
317 | KOTodoViewItem *item; | 311 | KOTodoViewItem *item; |
318 | while( myChild ) { | 312 | while( myChild ) { |
319 | //qDebug("stateCH "); | 313 | //qDebug("stateCH "); |
320 | item = static_cast<KOTodoViewItem*>(myChild); | 314 | item = static_cast<KOTodoViewItem*>(myChild); |
321 | item->stateChange(state); | 315 | item->stateChange(state); |
322 | myChild = myChild->nextSibling(); | 316 | myChild = myChild->nextSibling(); |
323 | } | 317 | } |
324 | } else { | 318 | } else { |
325 | QListViewItem * myChild = parent(); | 319 | QListViewItem * myChild = parent(); |
326 | if ( myChild ) | 320 | if ( myChild ) |
327 | (static_cast<KOTodoViewItem*>(myChild))->stateChange(state); | 321 | (static_cast<KOTodoViewItem*>(myChild))->stateChange(state); |
328 | } | 322 | } |
329 | mTodoView->modified(true); | 323 | mTodoView->modified(true); |
330 | setMyPixmap(); | 324 | setMyPixmap(); |
331 | mTodoView->setTodoModified( mTodo ); | 325 | mTodoView->setTodoModified( mTodo ); |
332 | } | 326 | } |
333 | 327 | ||
334 | bool KOTodoViewItem::isAlternate() | 328 | bool KOTodoViewItem::isAlternate() |
335 | { | 329 | { |
336 | #if 0 | 330 | #if 0 |
337 | //if ( m_known ) return m_odd; | 331 | //if ( m_known ) return m_odd; |
338 | //qDebug("test "); | 332 | //qDebug("test "); |
339 | KOTodoViewItem *item = static_cast<KOTodoViewItem *>(itemAbove()); | 333 | KOTodoViewItem *item = static_cast<KOTodoViewItem *>(itemAbove()); |
340 | if ( item ) { | 334 | if ( item ) { |
341 | m_known = item->m_known; | 335 | m_known = item->m_known; |
342 | if ( m_known ) { | 336 | if ( m_known ) { |
343 | m_odd = !item->m_odd ; | 337 | m_odd = !item->m_odd ; |
344 | return m_odd; | 338 | return m_odd; |
345 | } | 339 | } |
346 | } else { | 340 | } else { |
347 | item = static_cast<KOTodoViewItem *>(itemBelow()); | 341 | item = static_cast<KOTodoViewItem *>(itemBelow()); |
348 | if ( item ) { | 342 | if ( item ) { |
349 | m_known = item->m_known; | 343 | m_known = item->m_known; |
350 | if ( m_known ) { | 344 | if ( m_known ) { |
351 | m_odd = !item->m_odd ; | 345 | m_odd = !item->m_odd ; |
352 | return m_odd; | 346 | return m_odd; |
353 | } | 347 | } |
354 | } | 348 | } |
355 | } | 349 | } |
356 | KOTodoListView *lv = static_cast<KOTodoListView *>(listView()); | 350 | KOTodoListView *lv = static_cast<KOTodoListView *>(listView()); |
357 | item = static_cast<KOTodoViewItem *>(lv->firstChild()); | 351 | item = static_cast<KOTodoViewItem *>(lv->firstChild()); |
358 | bool previous = true; | 352 | bool previous = true; |
359 | qDebug("WHILE "); | 353 | qDebug("WHILE "); |
360 | while ( item ) { | 354 | while ( item ) { |
361 | item->m_odd = !previous; | 355 | item->m_odd = !previous; |
362 | item->m_known = true; | 356 | item->m_known = true; |
363 | previous = !previous; | 357 | previous = !previous; |
364 | item = static_cast<KOTodoViewItem *>(item->itemBelow()); | 358 | item = static_cast<KOTodoViewItem *>(item->itemBelow()); |
365 | } | 359 | } |
366 | return m_odd; | 360 | return m_odd; |
367 | 361 | ||
368 | #else | 362 | #else |
369 | 363 | ||
370 | //KOTodoListView *lv = static_cast<KOTodoListView *>(listView()); | 364 | //KOTodoListView *lv = static_cast<KOTodoListView *>(listView()); |
371 | //if (lv && lv->alternateBackground().isValid()) | 365 | //if (lv && lv->alternateBackground().isValid()) |
372 | { | 366 | { |
373 | KOTodoViewItem *above = static_cast<KOTodoViewItem *>(itemAbove()); | 367 | KOTodoViewItem *above = static_cast<KOTodoViewItem *>(itemAbove()); |
374 | m_known = above ? above->m_known : true; | 368 | m_known = above ? above->m_known : true; |
375 | if (m_known) | 369 | if (m_known) |
376 | { | 370 | { |
377 | m_odd = above ? !above->m_odd : false; | 371 | m_odd = above ? !above->m_odd : false; |
378 | } | 372 | } |
379 | else | 373 | else |
380 | { | 374 | { |
381 | KOTodoViewItem *item; | 375 | KOTodoViewItem *item; |
382 | bool previous = true; | 376 | bool previous = true; |
383 | if (QListViewItem::parent()) | 377 | if (QListViewItem::parent()) |
384 | { | 378 | { |
385 | item = static_cast<KOTodoViewItem *>(QListViewItem::parent()); | 379 | item = static_cast<KOTodoViewItem *>(QListViewItem::parent()); |
386 | if (item) | 380 | if (item) |
387 | previous = item->m_odd; | 381 | previous = item->m_odd; |
388 | item = static_cast<KOTodoViewItem *>(QListViewItem::parent()->firstChild()); | 382 | item = static_cast<KOTodoViewItem *>(QListViewItem::parent()->firstChild()); |
389 | } | 383 | } |
390 | else | 384 | else |
391 | { | 385 | { |
392 | KOTodoListView *lv = static_cast<KOTodoListView *>(listView()); | 386 | KOTodoListView *lv = static_cast<KOTodoListView *>(listView()); |
393 | item = static_cast<KOTodoViewItem *>(lv->firstChild()); | 387 | item = static_cast<KOTodoViewItem *>(lv->firstChild()); |
394 | } | 388 | } |
395 | 389 | ||
396 | while(item) | 390 | while(item) |
397 | { | 391 | { |
398 | item->m_odd = previous = !previous; | 392 | item->m_odd = previous = !previous; |
399 | item->m_known = true; | 393 | item->m_known = true; |
400 | item = static_cast<KOTodoViewItem *>(item->nextSibling()); | 394 | item = static_cast<KOTodoViewItem *>(item->nextSibling()); |
401 | } | 395 | } |
402 | } | 396 | } |
403 | return m_odd; | 397 | return m_odd; |
404 | } | 398 | } |
405 | return false; | 399 | return false; |
406 | #endif | 400 | #endif |
407 | } | 401 | } |
408 | 402 | ||
409 | void KOTodoViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment) | 403 | void KOTodoViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment) |
410 | { | 404 | { |
411 | QColorGroup _cg = cg; | 405 | QColorGroup _cg = cg; |
412 | QColorGroup::ColorRole role; | 406 | QColorGroup::ColorRole role; |
413 | if ( KOPrefs::instance()->mTodoViewUsesForegroundColor && !mTodo->isRunning()) | 407 | if ( KOPrefs::instance()->mTodoViewUsesForegroundColor && !mTodo->isRunning()) |
414 | role = QColorGroup::Text; | 408 | role = QColorGroup::Text; |
415 | else | 409 | else |
416 | role = QColorGroup::Base; | 410 | role = QColorGroup::Base; |
417 | //#ifndef KORG_NOLVALTERNATION | 411 | //#ifndef KORG_NOLVALTERNATION |
418 | if (isAlternate()) | 412 | if (isAlternate()) |
419 | _cg.setColor(QColorGroup::Base, static_cast< KOTodoListView* >(listView())->alternateBackground()); | 413 | _cg.setColor(QColorGroup::Base, static_cast< KOTodoListView* >(listView())->alternateBackground()); |
420 | bool setColor = KOPrefs::instance()->mTodoViewUsesCatColors; | 414 | bool setColor = KOPrefs::instance()->mTodoViewUsesCatColors; |
421 | QColor colorToSet; | 415 | QColor colorToSet; |
422 | if ( column == 0 && mTodo->calID() > 1 ) { | 416 | if ( column == 0 && mTodo->calID() > 1 ) { |
423 | setColor = true; | 417 | setColor = true; |
424 | colorToSet = KOPrefs::instance()->defaultColor( mTodo->calID() ); | 418 | colorToSet = KOPrefs::instance()->defaultColor( mTodo->calID() ); |
425 | } else if ( setColor ) { | 419 | } else if ( setColor ) { |
426 | QStringList categories = mTodo->categories(); | 420 | QStringList categories = mTodo->categories(); |
427 | QString cat = categories.first(); | 421 | QString cat = categories.first(); |
428 | if ( !cat.isEmpty()) { | 422 | if ( !cat.isEmpty()) { |
429 | colorToSet = *(KOPrefs::instance()->categoryColor(cat) ); | 423 | colorToSet = *(KOPrefs::instance()->categoryColor(cat) ); |
430 | } else | 424 | } else |
431 | setColor = false; | 425 | setColor = false; |
432 | } | 426 | } |
433 | bool openMode = !isOpen(); | 427 | bool openMode = !isOpen(); |
434 | // maybe we are in flat-display-mode | 428 | // maybe we are in flat-display-mode |
435 | if ( !firstChild() ) | 429 | if ( !firstChild() ) |
436 | openMode = false; | 430 | openMode = false; |
437 | bool colorRunning = mTodo->isRunning(); | 431 | bool colorRunning = mTodo->isRunning(); |
438 | if ( ! colorRunning && openMode ) | 432 | if ( ! colorRunning && openMode ) |
439 | colorRunning = mTodo->hasRunningSub(); | 433 | colorRunning = mTodo->hasRunningSub(); |
440 | if ( colorRunning ) { | 434 | if ( colorRunning ) { |
441 | setColor = true; | 435 | setColor = true; |
442 | colorToSet = KOPrefs::instance()->mTodoRunColor; | 436 | colorToSet = KOPrefs::instance()->mTodoRunColor; |
443 | } else { | 437 | } else { |
444 | int odue = mTodo->hasDueSubTodo( openMode ); | 438 | int odue = mTodo->hasDueSubTodo( openMode ); |
445 | if (odue == 2) { | 439 | if (odue == 2) { |
446 | colorToSet = KOPrefs::instance()->mTodoOverdueColor; | 440 | colorToSet = KOPrefs::instance()->mTodoOverdueColor; |
447 | setColor = true; | 441 | setColor = true; |
448 | } else if ( odue == 1 ) { | 442 | } else if ( odue == 1 ) { |
449 | colorToSet = KOPrefs::instance()->mTodoDueTodayColor; | 443 | colorToSet = KOPrefs::instance()->mTodoDueTodayColor; |
450 | setColor = true; | 444 | setColor = true; |
451 | } | 445 | } |
452 | } | 446 | } |
453 | 447 | ||
454 | 448 | ||
455 | if ( setColor ) { | 449 | if ( setColor ) { |
456 | _cg.setColor(role,colorToSet ); | 450 | _cg.setColor(role,colorToSet ); |
457 | if ( role == QColorGroup::Base) { | 451 | if ( role == QColorGroup::Base) { |
458 | int rgb = colorToSet.red(); | 452 | int rgb = colorToSet.red(); |
459 | rgb += colorToSet.blue()/2; | 453 | rgb += colorToSet.blue()/2; |
460 | rgb += colorToSet.green(); | 454 | rgb += colorToSet.green(); |
461 | if ( rgb < 200 ) | 455 | if ( rgb < 200 ) |
462 | _cg.setColor(QColorGroup::Text,Qt::white ); | 456 | _cg.setColor(QColorGroup::Text,Qt::white ); |
463 | } | 457 | } |
464 | } | 458 | } |
465 | //#endif | 459 | //#endif |
466 | if ( column > 0 ){ | 460 | if ( column > 0 ){ |
467 | if ( column == 2 && !KOPrefs::instance()->mTodoViewShowsPercentage ) { | 461 | if ( column == 2 && !KOPrefs::instance()->mTodoViewShowsPercentage ) { |
468 | p->save(); | 462 | p->save(); |
469 | int progress = (int)(( (width-6)*mTodo->percentComplete())/100.0 + 0.5); | 463 | int progress = (int)(( (width-6)*mTodo->percentComplete())/100.0 + 0.5); |
470 | 464 | ||
471 | p->fillRect( 0, 0, width, height(), _cg.base() ); // background | 465 | p->fillRect( 0, 0, width, height(), _cg.base() ); // background |
472 | // p->setPen(Qt::black ); //border | 466 | // p->setPen(Qt::black ); //border |
473 | // p->setBrush( KOPrefs::instance()->mHighlightColorKGlobalSettings::baseColor() ); //filling | 467 | // p->setBrush( KOPrefs::instance()->mHighlightColorKGlobalSettings::baseColor() ); //filling |
474 | QColor fc = KOPrefs::instance()->mHighlightColor; | 468 | QColor fc = KOPrefs::instance()->mHighlightColor; |
475 | if ( mTodo->percentComplete() == 100 ) | 469 | if ( mTodo->percentComplete() == 100 ) |
476 | fc = darkGreen; | 470 | fc = darkGreen; |
477 | p->drawRect( 2, 2, width-4, height()-4); | 471 | p->drawRect( 2, 2, width-4, height()-4); |
478 | p->fillRect( 3, 3, progress, height()-6, | 472 | p->fillRect( 3, 3, progress, height()-6, |
479 | fc ); | 473 | fc ); |
480 | p->restore(); | 474 | p->restore(); |
481 | } else { | 475 | } else { |
482 | QCheckListItem::paintCell(p, _cg, column, width, alignment); | 476 | QCheckListItem::paintCell(p, _cg, column, width, alignment); |
483 | } | 477 | } |
484 | return; | 478 | return; |
485 | } | 479 | } |
486 | 480 | ||
487 | int align = alignment; | 481 | int align = alignment; |
488 | 482 | ||
489 | if ( !p ) | 483 | if ( !p ) |
490 | return; | 484 | return; |
491 | 485 | ||
492 | p->fillRect( 0, 0, width, height(), _cg.brush( QColorGroup::Base ) ); | 486 | p->fillRect( 0, 0, width, height(), _cg.brush( QColorGroup::Base ) ); |
493 | 487 | ||
494 | QListView *lv = listView(); | 488 | QListView *lv = listView(); |
495 | if ( !lv ) | 489 | if ( !lv ) |
496 | return; | 490 | return; |
497 | int marg = 2;//lv->itemMargin(); | 491 | int marg = 2;//lv->itemMargin(); |
498 | int r = 0; | 492 | int r = 0; |
499 | QCheckListItem::Type myType = QCheckListItem::CheckBox; | 493 | QCheckListItem::Type myType = QCheckListItem::CheckBox; |
500 | int BoxSize = 20; | 494 | int BoxSize = 20; |
501 | int boxOffset = 2; | 495 | int boxOffset = 2; |
502 | int xOffset = 2; | 496 | int xOffset = 2; |
503 | if (qApp->desktop()->width() < 300 ) { | 497 | if (qApp->desktop()->width() < 300 ) { |
504 | BoxSize = 14; | 498 | BoxSize = 14; |
505 | boxOffset = -1; | 499 | boxOffset = -1; |
506 | xOffset = 1; | 500 | xOffset = 1; |
507 | // marg = 0; | 501 | // marg = 0; |
508 | } | 502 | } |
509 | if ( height() < BoxSize ) { | 503 | if ( height() < BoxSize ) { |
510 | boxOffset = boxOffset - ((BoxSize - height())/2) ; | 504 | boxOffset = boxOffset - ((BoxSize - height())/2) ; |
511 | // qDebug("boxOffset %d height %d", boxOffset, height() ); | 505 | // qDebug("boxOffset %d height %d", boxOffset, height() ); |
512 | BoxSize = height(); | 506 | BoxSize = height(); |
513 | 507 | ||
514 | } | 508 | } |
515 | //bool winStyle = lv->style() == WindowsStyle; | 509 | //bool winStyle = lv->style() == WindowsStyle; |
516 | 510 | ||
517 | int lineStart = 5; | 511 | int lineStart = 5; |
518 | if ( myType == Controller ) { | 512 | if ( myType == Controller ) { |
519 | if ( !pixmap( 0 ) ) | 513 | if ( !pixmap( 0 ) ) |
520 | r += BoxSize + 4; | 514 | r += BoxSize + 4; |
521 | } else { | 515 | } else { |
522 | ASSERT( lv ); //### | 516 | ASSERT( lv ); //### |
523 | //QFontMetrics fm( lv->font() ); | 517 | //QFontMetrics fm( lv->font() ); |
524 | //int d = fm.height(); | 518 | //int d = fm.height(); |
525 | int x = 0; | 519 | int x = 0; |
526 | int y = (height() - BoxSize) / 2; | 520 | int y = (height() - BoxSize) / 2; |
527 | //p->setPen( QPen( _cg.text(), winStyle ? 2 : 1 ) ); | 521 | //p->setPen( QPen( _cg.text(), winStyle ? 2 : 1 ) ); |
528 | if ( myType == CheckBox ) { | 522 | if ( myType == CheckBox ) { |
529 | if ( isEnabled() ) | 523 | if ( isEnabled() ) |
530 | p->setPen( QPen( _cg.text(), 1 ) ); | 524 | p->setPen( QPen( _cg.text(), 1 ) ); |
531 | else | 525 | else |
532 | p->setPen( QPen( listView()->palette().color( QPalette::Disabled, QColorGroup::Text ), 1 ) ); | 526 | p->setPen( QPen( listView()->palette().color( QPalette::Disabled, QColorGroup::Text ), 1 ) ); |
533 | p->drawRect( x+marg, y+2, BoxSize-4, BoxSize-4 ); | 527 | p->drawRect( x+marg, y+2, BoxSize-4, BoxSize-4 ); |
534 | lineStart = x+marg; | 528 | lineStart = x+marg; |
535 | ///////////////////// | 529 | ///////////////////// |
536 | x++; | 530 | x++; |
537 | y++; | 531 | y++; |
538 | if ( isOn() ) { | 532 | if ( isOn() ) { |
539 | QPointArray a( 7*2 ); | 533 | QPointArray a( 7*2 ); |
540 | int i, xx, yy; | 534 | int i, xx, yy; |
541 | xx = x+xOffset+marg+(boxOffset/2); | 535 | xx = x+xOffset+marg+(boxOffset/2); |
542 | yy = y+5+boxOffset; | 536 | yy = y+5+boxOffset; |
543 | for ( i=0; i<3; i++ ) { | 537 | for ( i=0; i<3; i++ ) { |
544 | a.setPoint( 2*i, xx, yy ); | 538 | a.setPoint( 2*i, xx, yy ); |
545 | a.setPoint( 2*i+1, xx, yy+2 ); | 539 | a.setPoint( 2*i+1, xx, yy+2 ); |
546 | // qDebug(" "); | 540 | // qDebug(" "); |
547 | xx++; yy++; | 541 | xx++; yy++; |
548 | } | 542 | } |
549 | yy -= 2; | 543 | yy -= 2; |
550 | for ( i=3; i<7; i++ ) { | 544 | for ( i=3; i<7; i++ ) { |
551 | a.setPoint( 2*i, xx, yy ); | 545 | a.setPoint( 2*i, xx, yy ); |
552 | a.setPoint( 2*i+1, xx, yy+2 ); | 546 | a.setPoint( 2*i+1, xx, yy+2 ); |
553 | xx++; yy--; | 547 | xx++; yy--; |
554 | } | 548 | } |
555 | p->setPen( darkGreen ); | 549 | p->setPen( darkGreen ); |
556 | p->drawLineSegments( a ); | 550 | p->drawLineSegments( a ); |
557 | } | 551 | } |
558 | //////////////////////// | 552 | //////////////////////// |