-rw-r--r-- | korganizer/kolistview.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp index c705c73..0b2f9a4 100644 --- a/korganizer/kolistview.cpp +++ b/korganizer/kolistview.cpp | |||
@@ -1,432 +1,440 @@ | |||
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]; | ||
71 | |||
70 | class KOListViewWhatsThis :public QWhatsThis | 72 | class KOListViewWhatsThis :public QWhatsThis |
71 | { | 73 | { |
72 | public: | 74 | public: |
73 | KOListViewWhatsThis( QWidget *wid, KOListView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { }; | 75 | KOListViewWhatsThis( QWidget *wid, KOListView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { }; |
74 | 76 | ||
75 | protected: | 77 | protected: |
76 | virtual QString text( const QPoint& p) | 78 | virtual QString text( const QPoint& p) |
77 | { | 79 | { |
78 | return _view->getWhatsThisText(p) ; | 80 | return _view->getWhatsThisText(p) ; |
79 | } | 81 | } |
80 | private: | 82 | private: |
81 | QWidget* _wid; | 83 | QWidget* _wid; |
82 | KOListView * _view; | 84 | KOListView * _view; |
83 | }; | 85 | }; |
84 | 86 | ||
85 | 87 | ||
86 | ListItemVisitor::ListItemVisitor(KOListViewItem *item, QDate date ) | 88 | ListItemVisitor::ListItemVisitor(KOListViewItem *item, QDate date ) |
87 | { | 89 | { |
88 | mItem = item; | 90 | mItem = item; |
89 | mDate = date; | 91 | mDate = date; |
90 | } | 92 | } |
91 | 93 | ||
92 | ListItemVisitor::~ListItemVisitor() | 94 | ListItemVisitor::~ListItemVisitor() |
93 | { | 95 | { |
94 | } | 96 | } |
95 | 97 | ||
96 | bool ListItemVisitor::visit(Event *e) | 98 | bool ListItemVisitor::visit(Event *e) |
97 | { | 99 | { |
98 | bool ok = false; | 100 | bool ok = false; |
99 | QString start, end; | 101 | QString start, end; |
100 | QDate ds, de; | 102 | QDate ds, de; |
101 | if ( e->doesRecur() ) { | 103 | if ( e->doesRecur() ) { |
102 | ds = e->getNextOccurence( QDateTime( mDate, QTime(0,0,0)), &ok ).date(); | 104 | ds = e->getNextOccurence( QDateTime( mDate, QTime(0,0,0)), &ok ).date(); |
103 | if ( ok ) { | 105 | if ( ok ) { |
104 | int days = e->dtStart().date().daysTo(e->dtEnd().date() ); | 106 | int days = e->dtStart().date().daysTo(e->dtEnd().date() ); |
105 | start = KGlobal::locale()->formatDate(ds,true); | 107 | start = KGlobal::locale()->formatDate(ds,true); |
106 | de = ds.addDays( days); | 108 | de = ds.addDays( days); |
107 | end = KGlobal::locale()->formatDate(de,true); | 109 | end = KGlobal::locale()->formatDate(de,true); |
108 | } | 110 | } |
109 | 111 | ||
110 | } | 112 | } |
111 | if ( ! ok ) { | 113 | if ( ! ok ) { |
112 | start =e->dtStartDateStr(); | 114 | start =e->dtStartDateStr(); |
113 | end = e->dtEndDateStr(); | 115 | end = e->dtEndDateStr(); |
114 | ds = e->dtStart().date(); | 116 | ds = e->dtStart().date(); |
115 | de = e->dtEnd().date(); | 117 | de = e->dtEnd().date(); |
116 | } | 118 | } |
117 | mItem->setText(0,e->summary()); | 119 | mItem->setText(0,e->summary()); |
118 | mItem->setText(1,start); | 120 | mItem->setText(1,start); |
119 | if ( e->doesFloat() ) | 121 | if ( e->doesFloat() ) |
120 | mItem->setText(2,"---"); | 122 | mItem->setText(2,"---"); |
121 | else | 123 | else |
122 | mItem->setText(2,e->dtStartTimeStr()); | 124 | mItem->setText(2,e->dtStartTimeStr()); |
123 | mItem->setText(3,end); | 125 | mItem->setText(3,end); |
124 | if ( e->doesFloat() ) | 126 | if ( e->doesFloat() ) |
125 | mItem->setText(4,"---"); | 127 | mItem->setText(4,"---"); |
126 | else | 128 | else |
127 | mItem->setText(4,e->dtEndTimeStr()); | 129 | mItem->setText(4,e->dtEndTimeStr()); |
128 | if ( e->isAlarmEnabled() ) { | 130 | if ( e->isAlarmEnabled() ) { |
129 | mItem->setText(5,e->alarms().first()->offsetText() ); | 131 | mItem->setText(5,e->alarms().first()->offsetText() ); |
130 | } else { | 132 | } else { |
131 | mItem->setText(5, i18n("No")); | 133 | mItem->setText(5, i18n("No")); |
132 | } | 134 | } |
133 | mItem->setText(6, e->recurrence()->recurrenceText()); | 135 | mItem->setText(6, e->recurrence()->recurrenceText()); |
134 | if( ! e->doesRecur() ) | 136 | if( ! e->doesRecur() ) |
135 | mItem->setSortKey( 6, "-" ); | 137 | mItem->setSortKey( 6, "-" ); |
136 | mItem->setText(7,"---"); | 138 | mItem->setText(7,"---"); |
137 | mItem->setText(8,"---"); | 139 | mItem->setText(8,"---"); |
138 | mItem->setText(9, e->cancelled() ? i18n("Yes") : i18n("No")); | 140 | mItem->setText(9, e->cancelled() ? i18n("Yes") : i18n("No")); |
139 | mItem->setText(10,e->categoriesStr()); | 141 | mItem->setText(10,e->categoriesStr()); |
140 | mItem->setText(11, KOPrefs::instance()->calName( e->calID() )); | 142 | mItem->setText(11, KOPrefs::instance()->calName( e->calID() )); |
141 | 143 | ||
142 | QString key; | 144 | QString key; |
143 | QTime t = e->doesFloat() ? QTime(0,0) : e->dtStart().time(); | 145 | QTime t = e->doesFloat() ? QTime(0,0) : e->dtStart().time(); |
144 | key.sprintf("%04d%02d%02d%02d%02d",ds.year(),ds.month(),ds.day(),t.hour(),t.minute()); | 146 | key.sprintf("%04d%02d%02d%02d%02d",ds.year(),ds.month(),ds.day(),t.hour(),t.minute()); |
145 | mItem->setSortKey(1,key); | 147 | mItem->setSortKey(1,key); |
146 | 148 | ||
147 | t = e->doesFloat() ? QTime(0,0) : e->dtEnd().time(); | 149 | t = e->doesFloat() ? QTime(0,0) : e->dtEnd().time(); |
148 | key.sprintf("%04d%02d%02d%02d%02d",de.year(),de.month(),de.day(),t.hour(),t.minute()); | 150 | key.sprintf("%04d%02d%02d%02d%02d",de.year(),de.month(),de.day(),t.hour(),t.minute()); |
149 | mItem->setSortKey(3,key); | 151 | mItem->setSortKey(3,key); |
150 | return true; | 152 | return true; |
151 | } | 153 | } |
152 | 154 | ||
153 | bool ListItemVisitor::visit(Todo *t) | 155 | bool ListItemVisitor::visit(Todo *t) |
154 | { | 156 | { |
155 | mItem->setText(0,i18n("Todo: %1").arg(t->summary())); | 157 | mItem->setText(0,t->summary()); |
158 | if ( t->isCompleted() ) { | ||
159 | mItem->setSortKey(0,"99"+ t->summary().left(10)); | ||
160 | } else | ||
161 | mItem->setSortKey(0,QString::number( t->percentComplete() )+ t->summary().left(10)); | ||
162 | mItem->setPixmap( 0, *(sgListViewCompletedPix[t->percentComplete()/20])); | ||
156 | if (t->hasStartDate()) { | 163 | if (t->hasStartDate()) { |
157 | mItem->setText(1,t->dtStartDateStr()); | 164 | mItem->setText(1,t->dtStartDateStr()); |
158 | if (t->doesFloat()) { | 165 | if (t->doesFloat()) { |
159 | mItem->setText(2,"---"); | 166 | mItem->setText(2,"---"); |
160 | } else { | 167 | } else { |
161 | mItem->setText(2,t->dtStartTimeStr()); | 168 | mItem->setText(2,t->dtStartTimeStr()); |
162 | } | 169 | } |
163 | } else { | 170 | } else { |
164 | mItem->setText(1,"---"); | 171 | mItem->setText(1,"---"); |
165 | mItem->setText(2,"---"); | 172 | mItem->setText(2,"---"); |
166 | } | 173 | } |
167 | mItem->setText(3,"---"); | 174 | mItem->setText(3,"---"); |
168 | mItem->setText(4,"---"); | 175 | mItem->setText(4,"---"); |
169 | if ( t->isAlarmEnabled() ) { | 176 | if ( t->isAlarmEnabled() ) { |
170 | mItem->setText(5,t->alarms().first()->offsetText() ); | 177 | mItem->setText(5,t->alarms().first()->offsetText() ); |
171 | } else { | 178 | } else { |
172 | mItem->setText(5, i18n("No")); | 179 | mItem->setText(5, i18n("No")); |
173 | } | 180 | } |
174 | mItem->setText(6, t->recurrence()->recurrenceText()); | 181 | mItem->setText(6, t->recurrence()->recurrenceText()); |
175 | if( ! t->doesRecur() ) | 182 | if( ! t->doesRecur() ) |
176 | mItem->setSortKey( 6, "-" ); | 183 | mItem->setSortKey( 6, "-" ); |
177 | if (t->hasDueDate()) { | 184 | if (t->hasDueDate()) { |
178 | mItem->setText(7,t->dtDueDateStr()); | 185 | mItem->setText(7,t->dtDueDateStr()); |
179 | if (t->doesFloat()) { | 186 | if (t->doesFloat()) { |
180 | mItem->setText(8,"---"); | 187 | mItem->setText(8,"---"); |
181 | } else { | 188 | } else { |
182 | mItem->setText(8,t->dtDueTimeStr()); | 189 | mItem->setText(8,t->dtDueTimeStr()); |
183 | } | 190 | } |
184 | } else { | 191 | } else { |
185 | mItem->setText(7,"---"); | 192 | mItem->setText(7,"---"); |
186 | mItem->setText(8,"---"); | 193 | mItem->setText(8,"---"); |
187 | } | 194 | } |
188 | mItem->setText(9, t->cancelled() ? i18n("Yes") : i18n("No")); | 195 | mItem->setText(9, t->cancelled() ? i18n("Yes") : i18n("No")); |
189 | mItem->setText(10,t->categoriesStr()); | 196 | mItem->setText(10,t->categoriesStr()); |
190 | mItem->setText(11, KOPrefs::instance()->calName( t->calID() )); | 197 | mItem->setText(11, KOPrefs::instance()->calName( t->calID() )); |
191 | 198 | ||
192 | QString key; | 199 | QString key; |
193 | QDate d; | 200 | QDate d; |
194 | if (t->hasDueDate()) { | 201 | if (t->hasDueDate()) { |
195 | d = t->dtDue().date(); | 202 | d = t->dtDue().date(); |
196 | QTime tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time(); | 203 | QTime tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time(); |
197 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); | 204 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); |
198 | mItem->setSortKey(7,key); | 205 | mItem->setSortKey(7,key); |
199 | } | 206 | } |
200 | if ( t->hasStartDate() ) { | 207 | if ( t->hasStartDate() ) { |
201 | d = t->dtStart().date(); | 208 | d = t->dtStart().date(); |
202 | QTime tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time(); | 209 | QTime tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time(); |
203 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); | 210 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); |
204 | mItem->setSortKey(1,key); | 211 | mItem->setSortKey(1,key); |
205 | } | 212 | } |
206 | return true; | 213 | return true; |
207 | } | 214 | } |
208 | 215 | ||
209 | bool ListItemVisitor::visit(Journal * j) | 216 | bool ListItemVisitor::visit(Journal * j) |
210 | { | 217 | { |
211 | QString des = j->description().left(30); | 218 | QString des = j->description().left(30); |
212 | des = des.simplifyWhiteSpace (); | 219 | des = des.simplifyWhiteSpace (); |
213 | des.replace (QRegExp ("\\n"),"" ); | 220 | des.replace (QRegExp ("\\n"),"" ); |
214 | des.replace (QRegExp ("\\r"),"" ); | 221 | des.replace (QRegExp ("\\r"),"" ); |
215 | mItem->setText(0,i18n("Journal: ")+des.left(25)); | 222 | mItem->setText(0,i18n("Journal: ")+des.left(25)); |
216 | mItem->setText(1,j->dtStartDateStr()); | 223 | mItem->setText(1,j->dtStartDateStr()); |
217 | mItem->setText(2,"---"); | 224 | mItem->setText(2,"---"); |
218 | mItem->setText(3,"---"); | 225 | mItem->setText(3,"---"); |
219 | mItem->setText(4,"---"); | 226 | mItem->setText(4,"---"); |
220 | mItem->setText(5,"---"); | 227 | mItem->setText(5,"---"); |
221 | mItem->setText(6,"---"); | 228 | mItem->setText(6,"---"); |
222 | mItem->setText(7,j->dtStartDateStr()); | 229 | mItem->setText(7,j->dtStartDateStr()); |
223 | mItem->setText(8,"---"); | 230 | mItem->setText(8,"---"); |
224 | mItem->setText(9,"---"); | 231 | mItem->setText(9,"---"); |
225 | mItem->setText(10,i18n("Last Modified: ")+ KGlobal::locale()->formatDateTime( j->lastModified() , true) ); | 232 | mItem->setText(10,i18n("Last Modified: ")+ KGlobal::locale()->formatDateTime( j->lastModified() , true) ); |
226 | mItem->setText(11, KOPrefs::instance()->calName( j->calID() )); | 233 | mItem->setText(11, KOPrefs::instance()->calName( j->calID() )); |
227 | 234 | ||
228 | QString key; | 235 | QString key; |
229 | QDate d = j->dtStart().date(); | 236 | QDate d = j->dtStart().date(); |
230 | key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); | 237 | key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); |
231 | mItem->setSortKey(1,key); | 238 | mItem->setSortKey(1,key); |
232 | mItem->setSortKey(7,key); | 239 | mItem->setSortKey(7,key); |
233 | 240 | ||
234 | return true; | 241 | return true; |
235 | } | 242 | } |
236 | 243 | ||
237 | KOListView::KOListView(Calendar *calendar, QWidget *parent, | 244 | KOListView::KOListView(Calendar *calendar, QWidget *parent, |
238 | const char *name) | 245 | const char *name) |
239 | : KOEventView(calendar, parent, name) | 246 | : KOEventView(calendar, parent, name) |
240 | { | 247 | { |
248 | |||
241 | mActiveItem = 0; | 249 | mActiveItem = 0; |
242 | mListView = new KOListViewListView(this); | 250 | mListView = new KOListViewListView(this); |
243 | mListView->addColumn(i18n("Summary")); | 251 | mListView->addColumn(i18n("Summary")); |
244 | mListView->addColumn(i18n("Start Date")); | 252 | mListView->addColumn(i18n("Start Date")); |
245 | mListView->addColumn(i18n("Start Time")); | 253 | mListView->addColumn(i18n("Start Time")); |
246 | mListView->addColumn(i18n("End Date")); | 254 | mListView->addColumn(i18n("End Date")); |
247 | mListView->addColumn(i18n("End Time")); | 255 | mListView->addColumn(i18n("End Time")); |
248 | mListView->addColumn(i18n("Alarm")); // alarm set? | 256 | mListView->addColumn(i18n("Alarm")); // alarm set? |
249 | mListView->addColumn(i18n("Recurs")); // recurs? | 257 | mListView->addColumn(i18n("Recurs")); // recurs? |
250 | mListView->addColumn(i18n("Due Date")); | 258 | mListView->addColumn(i18n("Due Date")); |
251 | mListView->addColumn(i18n("Due Time")); | 259 | mListView->addColumn(i18n("Due Time")); |
252 | mListView->addColumn(i18n("Cancelled")); | 260 | mListView->addColumn(i18n("Cancelled")); |
253 | mListView->addColumn(i18n("Categories")); | 261 | mListView->addColumn(i18n("Categories")); |
254 | mListView->addColumn(i18n("Calendar")); | 262 | mListView->addColumn(i18n("Calendar")); |
255 | 263 | ||
256 | mListView->setColumnAlignment(0,AlignLeft); | 264 | mListView->setColumnAlignment(0,AlignLeft); |
257 | mListView->setColumnAlignment(1,AlignLeft); | 265 | mListView->setColumnAlignment(1,AlignLeft); |
258 | mListView->setColumnAlignment(2,AlignHCenter); | 266 | mListView->setColumnAlignment(2,AlignHCenter); |
259 | mListView->setColumnAlignment(3,AlignLeft); | 267 | mListView->setColumnAlignment(3,AlignLeft); |
260 | mListView->setColumnAlignment(4,AlignHCenter); | 268 | mListView->setColumnAlignment(4,AlignHCenter); |
261 | mListView->setColumnAlignment(5,AlignLeft); | 269 | mListView->setColumnAlignment(5,AlignLeft); |
262 | mListView->setColumnAlignment(6,AlignLeft); | 270 | mListView->setColumnAlignment(6,AlignLeft); |
263 | mListView->setColumnAlignment(7,AlignLeft); | 271 | mListView->setColumnAlignment(7,AlignLeft); |
264 | mListView->setColumnAlignment(8,AlignLeft); | 272 | mListView->setColumnAlignment(8,AlignLeft); |
265 | mListView->setColumnAlignment(9,AlignLeft); | 273 | mListView->setColumnAlignment(9,AlignLeft); |
266 | mListView->setColumnAlignment(10,AlignLeft); | 274 | mListView->setColumnAlignment(10,AlignLeft); |
267 | mListView->setColumnAlignment(11,AlignLeft); | 275 | mListView->setColumnAlignment(11,AlignLeft); |
268 | mKOListViewWhatsThis = new KOListViewWhatsThis(mListView->viewport(),this); | 276 | mKOListViewWhatsThis = new KOListViewWhatsThis(mListView->viewport(),this); |
269 | 277 | ||
270 | int iii = 0; | 278 | int iii = 0; |
271 | for ( iii = 0; iii< 12 ; ++iii ) | 279 | for ( iii = 0; iii< 12 ; ++iii ) |
272 | mListView->setColumnWidthMode( iii, QListView::Manual ); | 280 | mListView->setColumnWidthMode( iii, QListView::Manual ); |
273 | 281 | ||
274 | QBoxLayout *layoutTop = new QVBoxLayout(this); | 282 | QBoxLayout *layoutTop = new QVBoxLayout(this); |
275 | layoutTop->addWidget(mListView); | 283 | layoutTop->addWidget(mListView); |
276 | mListView->setFont ( KOPrefs::instance()->mListViewFont ); | 284 | mListView->setFont ( KOPrefs::instance()->mListViewFont ); |
277 | mPopupMenu = eventPopup(); | 285 | mPopupMenu = eventPopup(); |
278 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 286 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
279 | i18n("Select all"),this, | 287 | i18n("Select all"),this, |
280 | SLOT(allSelection()),true); | 288 | SLOT(allSelection()),true); |
281 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 289 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
282 | i18n("Deselect all"),this, | 290 | i18n("Deselect all"),this, |
283 | SLOT(clearSelection()),true); | 291 | SLOT(clearSelection()),true); |
284 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 292 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
285 | i18n("Delete all selected"),this, | 293 | i18n("Delete all selected"),this, |
286 | SLOT(deleteAll()),true); | 294 | SLOT(deleteAll()),true); |
287 | 295 | ||
288 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 296 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
289 | i18n("Hide all selected"),this, | 297 | i18n("Hide all selected"),this, |
290 | SLOT(hideAll()),true); | 298 | SLOT(hideAll()),true); |
291 | 299 | ||
292 | mPopupMenu->insertSeparator(); | 300 | mPopupMenu->insertSeparator(); |
293 | #ifdef DESKTOP_VERSION | 301 | #ifdef DESKTOP_VERSION |
294 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 302 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
295 | i18n("Print complete list"),this, | 303 | i18n("Print complete list"),this, |
296 | SLOT(printList()),true); | 304 | SLOT(printList()),true); |
297 | mPopupMenu->insertSeparator(); | 305 | mPopupMenu->insertSeparator(); |
298 | #endif | 306 | #endif |
299 | mCalPopup = new QPopupMenu ( this ); | 307 | mCalPopup = new QPopupMenu ( this ); |
300 | mPopupMenu->insertItem( i18n("Set Calendar"), mCalPopup ); | 308 | mPopupMenu->insertItem( i18n("Set Calendar"), mCalPopup ); |
301 | 309 | ||
302 | QObject::connect(mCalPopup,SIGNAL(aboutToShow()),this, | 310 | QObject::connect(mCalPopup,SIGNAL(aboutToShow()),this, |
303 | SLOT( populateCalPopup() )); | 311 | SLOT( populateCalPopup() )); |
304 | QObject::connect(mCalPopup,SIGNAL(activated( int )),this, | 312 | QObject::connect(mCalPopup,SIGNAL(activated( int )),this, |
305 | SLOT( setCalendar( int ) )); | 313 | SLOT( setCalendar( int ) )); |
306 | QPopupMenu * exportPO = new QPopupMenu ( this ); | 314 | QPopupMenu * exportPO = new QPopupMenu ( this ); |
307 | mPopupMenu->insertItem( i18n("Export selected"), exportPO ); | 315 | mPopupMenu->insertItem( i18n("Export selected"), exportPO ); |
308 | exportPO->insertItem( i18n("As iCal (ics) file..."),this, | 316 | exportPO->insertItem( i18n("As iCal (ics) file..."),this, |
309 | SLOT(saveToFile())); | 317 | SLOT(saveToFile())); |
310 | exportPO->insertItem( i18n("As vCal (vcs) file..."),this, | 318 | exportPO->insertItem( i18n("As vCal (vcs) file..."),this, |
311 | SLOT(saveToFileVCS())); | 319 | SLOT(saveToFileVCS())); |
312 | exportPO->insertItem( i18n("Journal/Details..."),this, | 320 | exportPO->insertItem( i18n("Journal/Details..."),this, |
313 | SLOT(saveDescriptionToFile())); | 321 | SLOT(saveDescriptionToFile())); |
314 | // mPopupMenu->insertSeparator(); | 322 | // mPopupMenu->insertSeparator(); |
315 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 323 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
316 | i18n("Add Categ. to selected..."),this, | 324 | i18n("Add Categ. to selected..."),this, |
317 | SLOT(addCat()),true); | 325 | SLOT(addCat()),true); |
318 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 326 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
319 | i18n("Set Categ. for selected..."),this, | 327 | i18n("Set Categ. for selected..."),this, |
320 | SLOT(setCat()),true); | 328 | SLOT(setCat()),true); |
321 | //mPopupMenu->insertSeparator(); | 329 | //mPopupMenu->insertSeparator(); |
322 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 330 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
323 | i18n("Set alarm for selected..."),this, | 331 | i18n("Set alarm for selected..."),this, |
324 | SLOT(setAlarm()),true); | 332 | SLOT(setAlarm()),true); |
325 | 333 | ||
326 | 334 | ||
327 | 335 | ||
328 | #ifndef DESKTOP_VERSION | 336 | #ifndef DESKTOP_VERSION |
329 | mPopupMenu->insertSeparator(); | 337 | mPopupMenu->insertSeparator(); |
330 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 338 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
331 | i18n("Beam selected via IR"),this, | 339 | i18n("Beam selected via IR"),this, |
332 | SLOT(beamSelected()),true); | 340 | SLOT(beamSelected()),true); |
333 | #endif | 341 | #endif |
334 | /* | 342 | /* |
335 | mPopupMenu = new QPopupMenu; | 343 | mPopupMenu = new QPopupMenu; |
336 | mPopupMenu->insertItem(i18n("Edit Event"), this, | 344 | mPopupMenu->insertItem(i18n("Edit Event"), this, |
337 | SLOT (editEvent())); | 345 | SLOT (editEvent())); |
338 | mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this, | 346 | mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this, |
339 | SLOT (deleteEvent())); | 347 | SLOT (deleteEvent())); |
340 | mPopupMenu->insertSeparator(); | 348 | mPopupMenu->insertSeparator(); |
341 | mPopupMenu->insertItem(i18n("Show Dates"), this, | 349 | mPopupMenu->insertItem(i18n("Show Dates"), this, |
342 | SLOT(showDates())); | 350 | SLOT(showDates())); |
343 | mPopupMenu->insertItem(i18n("Hide Dates"), this, | 351 | mPopupMenu->insertItem(i18n("Hide Dates"), this, |
344 | SLOT(hideDates())); | 352 | SLOT(hideDates())); |
345 | */ | 353 | */ |
346 | QObject::connect(mListView,SIGNAL( newEvent()), | 354 | QObject::connect(mListView,SIGNAL( newEvent()), |
347 | this,SIGNAL(signalNewEvent())); | 355 | this,SIGNAL(signalNewEvent())); |
348 | QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)), | 356 | QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)), |
349 | this,SLOT(defaultItemAction(QListViewItem *))); | 357 | this,SLOT(defaultItemAction(QListViewItem *))); |
350 | QObject::connect(mListView,SIGNAL(rightButtonPressed( QListViewItem *, | 358 | QObject::connect(mListView,SIGNAL(rightButtonPressed( QListViewItem *, |
351 | const QPoint &, int )), | 359 | const QPoint &, int )), |
352 | this,SLOT(popupMenu(QListViewItem *,const QPoint &,int))); | 360 | this,SLOT(popupMenu(QListViewItem *,const QPoint &,int))); |
353 | QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)), | 361 | QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)), |
354 | SLOT(processSelectionChange(QListViewItem *))); | 362 | SLOT(processSelectionChange(QListViewItem *))); |
355 | QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)), | 363 | QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)), |
356 | SIGNAL(showIncidenceSignal(Incidence *)) ); | 364 | SIGNAL(showIncidenceSignal(Incidence *)) ); |
357 | 365 | ||
358 | readSettings(KOGlobals::config(),"KOListView Layout"); | 366 | readSettings(KOGlobals::config(),"KOListView Layout"); |
359 | } | 367 | } |
360 | 368 | ||
361 | KOListView::~KOListView() | 369 | KOListView::~KOListView() |
362 | { | 370 | { |
363 | delete mPopupMenu; | 371 | delete mPopupMenu; |
364 | #if QT_VERSION >= 0x030000 | 372 | #if QT_VERSION >= 0x030000 |
365 | 373 | ||
366 | #else | 374 | #else |
367 | delete mKOListViewWhatsThis; | 375 | delete mKOListViewWhatsThis; |
368 | #endif | 376 | #endif |
369 | } | 377 | } |
370 | 378 | ||
371 | QString KOListView::getWhatsThisText(QPoint p) | 379 | QString KOListView::getWhatsThisText(QPoint p) |
372 | { | 380 | { |
373 | KOListViewItem* item = ( KOListViewItem* ) mListView->itemAt( p ); | 381 | KOListViewItem* item = ( KOListViewItem* ) mListView->itemAt( p ); |
374 | if ( item ) | 382 | if ( item ) |
375 | return KIncidenceFormatter::instance()->getFormattedText( item->data(), | 383 | return KIncidenceFormatter::instance()->getFormattedText( item->data(), |
376 | KOPrefs::instance()->mWTshowDetails, | 384 | KOPrefs::instance()->mWTshowDetails, |
377 | KOPrefs::instance()->mWTshowCreated, | 385 | KOPrefs::instance()->mWTshowCreated, |
378 | KOPrefs::instance()->mWTshowChanged); | 386 | KOPrefs::instance()->mWTshowChanged); |
379 | return i18n("That is the list view" ); | 387 | return i18n("That is the list view" ); |
380 | 388 | ||
381 | } | 389 | } |
382 | 390 | ||
383 | void KOListView::setCalendar( int c ) | 391 | void KOListView::setCalendar( int c ) |
384 | { | 392 | { |
385 | int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"), | 393 | int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"), |
386 | i18n("This adds the selected\nitems to the calendar\n%1\nand removes them from\ntheir current calendar!").arg( KOPrefs::instance()->calName( c ) ), | 394 | i18n("This adds the selected\nitems to the calendar\n%1\nand removes them from\ntheir current calendar!").arg( KOPrefs::instance()->calName( c ) ), |
387 | i18n("Continue"), i18n("Cancel"), 0, | 395 | i18n("Continue"), i18n("Cancel"), 0, |
388 | 0, 1 ); | 396 | 0, 1 ); |
389 | if ( result != 0 ) { | 397 | if ( result != 0 ) { |
390 | return; | 398 | return; |
391 | } | 399 | } |
392 | 400 | ||
393 | QPtrList<Incidence> delSel = getSelectedIncidences() ; | 401 | QPtrList<Incidence> delSel = getSelectedIncidences() ; |
394 | int icount = delSel.count(); | 402 | int icount = delSel.count(); |
395 | if ( icount ) { | 403 | if ( icount ) { |
396 | Incidence *incidence = delSel.first(); | 404 | Incidence *incidence = delSel.first(); |
397 | while ( incidence ) { | 405 | while ( incidence ) { |
398 | incidence->setCalID( c ); | 406 | incidence->setCalID( c ); |
399 | KOListViewItem * item = getItemForEvent( incidence ); | 407 | KOListViewItem * item = getItemForEvent( incidence ); |
400 | if ( item ) { | 408 | if ( item ) { |
401 | ListItemVisitor v(item, mStartDate ); | 409 | ListItemVisitor v(item, mStartDate ); |
402 | incidence->accept(v); | 410 | incidence->accept(v); |
403 | } | 411 | } |
404 | incidence = delSel.next(); | 412 | incidence = delSel.next(); |
405 | } | 413 | } |
406 | } | 414 | } |
407 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 415 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
408 | KopiCalendarFile * cal = calendars.first(); | 416 | KopiCalendarFile * cal = calendars.first(); |
409 | while ( cal ) { | 417 | while ( cal ) { |
410 | mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); | 418 | mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); |
411 | mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); | 419 | mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); |
412 | mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); | 420 | mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); |
413 | if ( cal->isStandard ) | 421 | if ( cal->isStandard ) |
414 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 422 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
415 | cal = calendars.next(); | 423 | cal = calendars.next(); |
416 | } | 424 | } |
417 | mCalendar->setSyncEventsReadOnly(); | 425 | mCalendar->setSyncEventsReadOnly(); |
418 | mCalendar->reInitAlarmSettings(); | 426 | mCalendar->reInitAlarmSettings(); |
419 | 427 | ||
420 | } | 428 | } |
421 | void KOListView::populateCalPopup() | 429 | void KOListView::populateCalPopup() |
422 | { | 430 | { |
423 | mCalPopup->clear(); | 431 | mCalPopup->clear(); |
424 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); | 432 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); |
425 | while ( kkf ) { | 433 | while ( kkf ) { |
426 | mCalPopup->insertItem( kkf->mName, kkf->mCalNumber); | 434 | mCalPopup->insertItem( kkf->mName, kkf->mCalNumber); |
427 | kkf = KOPrefs::instance()->mCalendars.next(); | 435 | kkf = KOPrefs::instance()->mCalendars.next(); |
428 | } | 436 | } |
429 | } | 437 | } |
430 | void KOListView::updateList() | 438 | void KOListView::updateList() |
431 | { | 439 | { |
432 | // qDebug(" KOListView::updateList() "); | 440 | // qDebug(" KOListView::updateList() "); |