author | zautrix <zautrix> | 2005-06-09 08:27:24 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-06-09 08:27:24 (UTC) |
commit | 12b4828ddfa8ac2fabbaf7c8841b8d68d16a0262 (patch) (unidiff) | |
tree | ac59de32cdf3ae5b8430b9039232f596a8a6a063 | |
parent | b0eb8251185b7c9d664af23da94480c7fcfcf8be (diff) | |
download | kdepimpi-12b4828ddfa8ac2fabbaf7c8841b8d68d16a0262.zip kdepimpi-12b4828ddfa8ac2fabbaf7c8841b8d68d16a0262.tar.gz kdepimpi-12b4828ddfa8ac2fabbaf7c8841b8d68d16a0262.tar.bz2 |
select lisz view fixes
-rw-r--r-- | korganizer/kolistview.cpp | 108 | ||||
-rw-r--r-- | korganizer/kolistview.h | 1 |
2 files changed, 51 insertions, 58 deletions
diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp index 5797d1b..1f3b4c6 100644 --- a/korganizer/kolistview.cpp +++ b/korganizer/kolistview.cpp | |||
@@ -1,1398 +1,1390 @@ | |||
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 | 70 | ||
71 | 71 | ||
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 | if ( e->isAlarmEnabled() ) { | 131 | if ( e->isAlarmEnabled() ) { |
132 | mItem->setText(5,e->alarms().first()->offsetText() ); | 132 | mItem->setText(5,e->alarms().first()->offsetText() ); |
133 | } else { | 133 | } else { |
134 | mItem->setText(5, i18n("No")); | 134 | mItem->setText(5, i18n("No")); |
135 | } | 135 | } |
136 | mItem->setText(6, e->recurrence()->recurrenceText()); | 136 | mItem->setText(6, e->recurrence()->recurrenceText()); |
137 | if( ! e->doesRecur() ) | 137 | if( ! e->doesRecur() ) |
138 | mItem->setSortKey( 6, "-" ); | 138 | mItem->setSortKey( 6, "-" ); |
139 | mItem->setText(7,"---"); | 139 | mItem->setText(7,"---"); |
140 | mItem->setText(8,"---"); | 140 | mItem->setText(8,"---"); |
141 | mItem->setText(9, e->cancelled() ? i18n("Yes") : i18n("No")); | 141 | mItem->setText(9, e->cancelled() ? i18n("Yes") : i18n("No")); |
142 | mItem->setText(10,e->categoriesStr()); | 142 | mItem->setText(10,e->categoriesStr()); |
143 | 143 | ||
144 | QString key; | 144 | QString key; |
145 | QTime t = e->doesFloat() ? QTime(0,0) : e->dtStart().time(); | 145 | QTime t = e->doesFloat() ? QTime(0,0) : e->dtStart().time(); |
146 | 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()); |
147 | mItem->setSortKey(1,key); | 147 | mItem->setSortKey(1,key); |
148 | 148 | ||
149 | t = e->doesFloat() ? QTime(0,0) : e->dtEnd().time(); | 149 | t = e->doesFloat() ? QTime(0,0) : e->dtEnd().time(); |
150 | 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()); |
151 | mItem->setSortKey(3,key); | 151 | mItem->setSortKey(3,key); |
152 | return true; | 152 | return true; |
153 | } | 153 | } |
154 | 154 | ||
155 | bool ListItemVisitor::visit(Todo *t) | 155 | bool ListItemVisitor::visit(Todo *t) |
156 | { | 156 | { |
157 | mItem->setText(0,i18n("Todo: %1").arg(t->summary())); | 157 | mItem->setText(0,i18n("Todo: %1").arg(t->summary())); |
158 | if (t->hasStartDate()) { | 158 | if (t->hasStartDate()) { |
159 | mItem->setText(1,t->dtStartDateStr()); | 159 | mItem->setText(1,t->dtStartDateStr()); |
160 | if (t->doesFloat()) { | 160 | if (t->doesFloat()) { |
161 | mItem->setText(2,"---"); | 161 | mItem->setText(2,"---"); |
162 | } else { | 162 | } else { |
163 | mItem->setText(2,t->dtStartTimeStr()); | 163 | mItem->setText(2,t->dtStartTimeStr()); |
164 | } | 164 | } |
165 | } else { | 165 | } else { |
166 | mItem->setText(1,"---"); | 166 | mItem->setText(1,"---"); |
167 | mItem->setText(2,"---"); | 167 | mItem->setText(2,"---"); |
168 | } | 168 | } |
169 | mItem->setText(3,"---"); | 169 | mItem->setText(3,"---"); |
170 | mItem->setText(4,"---"); | 170 | mItem->setText(4,"---"); |
171 | if ( t->isAlarmEnabled() ) { | 171 | if ( t->isAlarmEnabled() ) { |
172 | mItem->setText(5,t->alarms().first()->offsetText() ); | 172 | mItem->setText(5,t->alarms().first()->offsetText() ); |
173 | } else { | 173 | } else { |
174 | mItem->setText(5, i18n("No")); | 174 | mItem->setText(5, i18n("No")); |
175 | } | 175 | } |
176 | mItem->setText(6, t->recurrence()->recurrenceText()); | 176 | mItem->setText(6, t->recurrence()->recurrenceText()); |
177 | if( ! t->doesRecur() ) | 177 | if( ! t->doesRecur() ) |
178 | mItem->setSortKey( 6, "-" ); | 178 | mItem->setSortKey( 6, "-" ); |
179 | if (t->hasDueDate()) { | 179 | if (t->hasDueDate()) { |
180 | mItem->setText(7,t->dtDueDateStr()); | 180 | mItem->setText(7,t->dtDueDateStr()); |
181 | if (t->doesFloat()) { | 181 | if (t->doesFloat()) { |
182 | mItem->setText(8,"---"); | 182 | mItem->setText(8,"---"); |
183 | } else { | 183 | } else { |
184 | mItem->setText(8,t->dtDueTimeStr()); | 184 | mItem->setText(8,t->dtDueTimeStr()); |
185 | } | 185 | } |
186 | } else { | 186 | } else { |
187 | mItem->setText(7,"---"); | 187 | mItem->setText(7,"---"); |
188 | mItem->setText(8,"---"); | 188 | mItem->setText(8,"---"); |
189 | } | 189 | } |
190 | mItem->setText(9, t->cancelled() ? i18n("Yes") : i18n("No")); | 190 | mItem->setText(9, t->cancelled() ? i18n("Yes") : i18n("No")); |
191 | mItem->setText(10,t->categoriesStr()); | 191 | mItem->setText(10,t->categoriesStr()); |
192 | 192 | ||
193 | QString key; | 193 | QString key; |
194 | QDate d; | 194 | QDate d; |
195 | if (t->hasDueDate()) { | 195 | if (t->hasDueDate()) { |
196 | d = t->dtDue().date(); | 196 | d = t->dtDue().date(); |
197 | QTime tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time(); | 197 | QTime tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time(); |
198 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); | 198 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); |
199 | mItem->setSortKey(7,key); | 199 | mItem->setSortKey(7,key); |
200 | } | 200 | } |
201 | if ( t->hasStartDate() ) { | 201 | if ( t->hasStartDate() ) { |
202 | d = t->dtStart().date(); | 202 | d = t->dtStart().date(); |
203 | QTime tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time(); | 203 | QTime tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time(); |
204 | 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()); |
205 | mItem->setSortKey(1,key); | 205 | mItem->setSortKey(1,key); |
206 | } | 206 | } |
207 | return true; | 207 | return true; |
208 | } | 208 | } |
209 | 209 | ||
210 | bool ListItemVisitor::visit(Journal * j) | 210 | bool ListItemVisitor::visit(Journal * j) |
211 | { | 211 | { |
212 | QString des = j->description().left(30); | 212 | QString des = j->description().left(30); |
213 | des = des.simplifyWhiteSpace (); | 213 | des = des.simplifyWhiteSpace (); |
214 | des.replace (QRegExp ("\\n"),"" ); | 214 | des.replace (QRegExp ("\\n"),"" ); |
215 | des.replace (QRegExp ("\\r"),"" ); | 215 | des.replace (QRegExp ("\\r"),"" ); |
216 | mItem->setText(0,i18n("Journal: ")+des.left(25)); | 216 | mItem->setText(0,i18n("Journal: ")+des.left(25)); |
217 | mItem->setText(1,j->dtStartDateStr()); | 217 | mItem->setText(1,j->dtStartDateStr()); |
218 | mItem->setText(2,"---"); | 218 | mItem->setText(2,"---"); |
219 | mItem->setText(3,"---"); | 219 | mItem->setText(3,"---"); |
220 | mItem->setText(4,"---"); | 220 | mItem->setText(4,"---"); |
221 | mItem->setText(5,"---"); | 221 | mItem->setText(5,"---"); |
222 | mItem->setText(6,"---"); | 222 | mItem->setText(6,"---"); |
223 | mItem->setText(7,j->dtStartDateStr()); | 223 | mItem->setText(7,j->dtStartDateStr()); |
224 | mItem->setText(8,"---"); | 224 | mItem->setText(8,"---"); |
225 | mItem->setText(9,"---"); | 225 | mItem->setText(9,"---"); |
226 | mItem->setText(10,i18n("Last Modified: ")+ KGlobal::locale()->formatDateTime( j->lastModified() , true) ); | 226 | mItem->setText(10,i18n("Last Modified: ")+ KGlobal::locale()->formatDateTime( j->lastModified() , true) ); |
227 | 227 | ||
228 | QString key; | 228 | QString key; |
229 | QDate d = j->dtStart().date(); | 229 | QDate d = j->dtStart().date(); |
230 | key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); | 230 | key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); |
231 | mItem->setSortKey(1,key); | 231 | mItem->setSortKey(1,key); |
232 | mItem->setSortKey(7,key); | 232 | mItem->setSortKey(7,key); |
233 | 233 | ||
234 | return true; | 234 | return true; |
235 | } | 235 | } |
236 | 236 | ||
237 | KOListView::KOListView(Calendar *calendar, QWidget *parent, | 237 | KOListView::KOListView(Calendar *calendar, QWidget *parent, |
238 | const char *name) | 238 | const char *name) |
239 | : KOEventView(calendar, parent, name) | 239 | : KOEventView(calendar, parent, name) |
240 | { | 240 | { |
241 | mActiveItem = 0; | 241 | mActiveItem = 0; |
242 | mListView = new KOListViewListView(this); | 242 | mListView = new KOListViewListView(this); |
243 | mListView->addColumn(i18n("Summary")); | 243 | mListView->addColumn(i18n("Summary")); |
244 | mListView->addColumn(i18n("Start Date")); | 244 | mListView->addColumn(i18n("Start Date")); |
245 | mListView->addColumn(i18n("Start Time")); | 245 | mListView->addColumn(i18n("Start Time")); |
246 | mListView->addColumn(i18n("End Date")); | 246 | mListView->addColumn(i18n("End Date")); |
247 | mListView->addColumn(i18n("End Time")); | 247 | mListView->addColumn(i18n("End Time")); |
248 | mListView->addColumn(i18n("Alarm")); // alarm set? | 248 | mListView->addColumn(i18n("Alarm")); // alarm set? |
249 | mListView->addColumn(i18n("Recurs")); // recurs? | 249 | mListView->addColumn(i18n("Recurs")); // recurs? |
250 | mListView->addColumn(i18n("Due Date")); | 250 | mListView->addColumn(i18n("Due Date")); |
251 | mListView->addColumn(i18n("Due Time")); | 251 | mListView->addColumn(i18n("Due Time")); |
252 | mListView->addColumn(i18n("Cancelled")); | 252 | mListView->addColumn(i18n("Cancelled")); |
253 | mListView->addColumn(i18n("Categories")); | 253 | mListView->addColumn(i18n("Categories")); |
254 | 254 | ||
255 | mListView->setColumnAlignment(0,AlignLeft); | 255 | mListView->setColumnAlignment(0,AlignLeft); |
256 | mListView->setColumnAlignment(1,AlignLeft); | 256 | mListView->setColumnAlignment(1,AlignLeft); |
257 | mListView->setColumnAlignment(2,AlignHCenter); | 257 | mListView->setColumnAlignment(2,AlignHCenter); |
258 | mListView->setColumnAlignment(3,AlignLeft); | 258 | mListView->setColumnAlignment(3,AlignLeft); |
259 | mListView->setColumnAlignment(4,AlignHCenter); | 259 | mListView->setColumnAlignment(4,AlignHCenter); |
260 | mListView->setColumnAlignment(5,AlignLeft); | 260 | mListView->setColumnAlignment(5,AlignLeft); |
261 | mListView->setColumnAlignment(6,AlignLeft); | 261 | mListView->setColumnAlignment(6,AlignLeft); |
262 | mListView->setColumnAlignment(7,AlignLeft); | 262 | mListView->setColumnAlignment(7,AlignLeft); |
263 | mListView->setColumnAlignment(8,AlignLeft); | 263 | mListView->setColumnAlignment(8,AlignLeft); |
264 | mListView->setColumnAlignment(9,AlignLeft); | 264 | mListView->setColumnAlignment(9,AlignLeft); |
265 | mListView->setColumnAlignment(10,AlignLeft); | 265 | mListView->setColumnAlignment(10,AlignLeft); |
266 | mListView->setColumnWidthMode(10, QListView::Manual); | 266 | mListView->setColumnWidthMode(10, QListView::Manual); |
267 | mKOListViewWhatsThis = new KOListViewWhatsThis(mListView->viewport(),this); | 267 | mKOListViewWhatsThis = new KOListViewWhatsThis(mListView->viewport(),this); |
268 | 268 | ||
269 | int iii = 0; | 269 | int iii = 0; |
270 | for ( iii = 0; iii< 10 ; ++iii ) | 270 | for ( iii = 0; iii< 10 ; ++iii ) |
271 | mListView->setColumnWidthMode( iii, QListView::Manual ); | 271 | mListView->setColumnWidthMode( iii, QListView::Manual ); |
272 | 272 | ||
273 | QBoxLayout *layoutTop = new QVBoxLayout(this); | 273 | QBoxLayout *layoutTop = new QVBoxLayout(this); |
274 | layoutTop->addWidget(mListView); | 274 | layoutTop->addWidget(mListView); |
275 | mListView->setFont ( KOPrefs::instance()->mListViewFont ); | 275 | mListView->setFont ( KOPrefs::instance()->mListViewFont ); |
276 | mPopupMenu = eventPopup(); | 276 | mPopupMenu = eventPopup(); |
277 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 277 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
278 | i18n("Select all"),this, | 278 | i18n("Select all"),this, |
279 | SLOT(allSelection()),true); | 279 | SLOT(allSelection()),true); |
280 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 280 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
281 | i18n("Deselect all"),this, | 281 | i18n("Deselect all"),this, |
282 | SLOT(clearSelection()),true); | 282 | SLOT(clearSelection()),true); |
283 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 283 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
284 | i18n("Delete all selected"),this, | 284 | i18n("Delete all selected"),this, |
285 | SLOT(deleteAll()),true); | 285 | SLOT(deleteAll()),true); |
286 | 286 | ||
287 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 287 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
288 | i18n("Hide all selected"),this, | 288 | i18n("Hide all selected"),this, |
289 | SLOT(hideAll()),true); | 289 | SLOT(hideAll()),true); |
290 | 290 | ||
291 | mPopupMenu->insertSeparator(); | 291 | mPopupMenu->insertSeparator(); |
292 | #ifdef DESKTOP_VERSION | 292 | #ifdef DESKTOP_VERSION |
293 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 293 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
294 | i18n("Print complete list"),this, | 294 | i18n("Print complete list"),this, |
295 | SLOT(printList()),true); | 295 | SLOT(printList()),true); |
296 | mPopupMenu->insertSeparator(); | 296 | mPopupMenu->insertSeparator(); |
297 | #endif | 297 | #endif |
298 | QPopupMenu * exportPO = new QPopupMenu ( this ); | 298 | QPopupMenu * exportPO = new QPopupMenu ( this ); |
299 | mPopupMenu->insertItem( i18n("Export selected"), exportPO ); | 299 | mPopupMenu->insertItem( i18n("Export selected"), exportPO ); |
300 | exportPO->insertItem( i18n("As iCal (ics) file..."),this, | 300 | exportPO->insertItem( i18n("As iCal (ics) file..."),this, |
301 | SLOT(saveToFile())); | 301 | SLOT(saveToFile())); |
302 | exportPO->insertItem( i18n("As vCal (vcs) file..."),this, | 302 | exportPO->insertItem( i18n("As vCal (vcs) file..."),this, |
303 | SLOT(saveToFileVCS())); | 303 | SLOT(saveToFileVCS())); |
304 | exportPO->insertItem( i18n("Journal/Details..."),this, | 304 | exportPO->insertItem( i18n("Journal/Details..."),this, |
305 | SLOT(saveDescriptionToFile())); | 305 | SLOT(saveDescriptionToFile())); |
306 | // mPopupMenu->insertSeparator(); | 306 | // mPopupMenu->insertSeparator(); |
307 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 307 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
308 | i18n("Add Categ. to selected..."),this, | 308 | i18n("Add Categ. to selected..."),this, |
309 | SLOT(addCat()),true); | 309 | SLOT(addCat()),true); |
310 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 310 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
311 | i18n("Set Categ. for selected..."),this, | 311 | i18n("Set Categ. for selected..."),this, |
312 | SLOT(setCat()),true); | 312 | SLOT(setCat()),true); |
313 | //mPopupMenu->insertSeparator(); | 313 | //mPopupMenu->insertSeparator(); |
314 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 314 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
315 | i18n("Set alarm for selected..."),this, | 315 | i18n("Set alarm for selected..."),this, |
316 | SLOT(setAlarm()),true); | 316 | SLOT(setAlarm()),true); |
317 | 317 | ||
318 | 318 | ||
319 | #ifndef DESKTOP_VERSION | 319 | #ifndef DESKTOP_VERSION |
320 | mPopupMenu->insertSeparator(); | 320 | mPopupMenu->insertSeparator(); |
321 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 321 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
322 | i18n("Beam selected via IR"),this, | 322 | i18n("Beam selected via IR"),this, |
323 | SLOT(beamSelected()),true); | 323 | SLOT(beamSelected()),true); |
324 | #endif | 324 | #endif |
325 | /* | 325 | /* |
326 | mPopupMenu = new QPopupMenu; | 326 | mPopupMenu = new QPopupMenu; |
327 | mPopupMenu->insertItem(i18n("Edit Event"), this, | 327 | mPopupMenu->insertItem(i18n("Edit Event"), this, |
328 | SLOT (editEvent())); | 328 | SLOT (editEvent())); |
329 | mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this, | 329 | mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this, |
330 | SLOT (deleteEvent())); | 330 | SLOT (deleteEvent())); |
331 | mPopupMenu->insertSeparator(); | 331 | mPopupMenu->insertSeparator(); |
332 | mPopupMenu->insertItem(i18n("Show Dates"), this, | 332 | mPopupMenu->insertItem(i18n("Show Dates"), this, |
333 | SLOT(showDates())); | 333 | SLOT(showDates())); |
334 | mPopupMenu->insertItem(i18n("Hide Dates"), this, | 334 | mPopupMenu->insertItem(i18n("Hide Dates"), this, |
335 | SLOT(hideDates())); | 335 | SLOT(hideDates())); |
336 | */ | 336 | */ |
337 | QObject::connect(mListView,SIGNAL( newEvent()), | 337 | QObject::connect(mListView,SIGNAL( newEvent()), |
338 | this,SIGNAL(signalNewEvent())); | 338 | this,SIGNAL(signalNewEvent())); |
339 | QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)), | 339 | QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)), |
340 | this,SLOT(defaultItemAction(QListViewItem *))); | 340 | this,SLOT(defaultItemAction(QListViewItem *))); |
341 | QObject::connect(mListView,SIGNAL(rightButtonPressed( QListViewItem *, | 341 | QObject::connect(mListView,SIGNAL(rightButtonPressed( QListViewItem *, |
342 | const QPoint &, int )), | 342 | const QPoint &, int )), |
343 | this,SLOT(popupMenu(QListViewItem *,const QPoint &,int))); | 343 | this,SLOT(popupMenu(QListViewItem *,const QPoint &,int))); |
344 | QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)), | 344 | QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)), |
345 | SLOT(processSelectionChange(QListViewItem *))); | 345 | SLOT(processSelectionChange(QListViewItem *))); |
346 | QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)), | 346 | QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)), |
347 | SIGNAL(showIncidenceSignal(Incidence *)) ); | 347 | SIGNAL(showIncidenceSignal(Incidence *)) ); |
348 | 348 | ||
349 | readSettings(KOGlobals::config(),"KOListView Layout"); | 349 | readSettings(KOGlobals::config(),"KOListView Layout"); |
350 | } | 350 | } |
351 | 351 | ||
352 | KOListView::~KOListView() | 352 | KOListView::~KOListView() |
353 | { | 353 | { |
354 | delete mPopupMenu; | 354 | delete mPopupMenu; |
355 | #if QT_VERSION >= 0x030000 | 355 | #if QT_VERSION >= 0x030000 |
356 | 356 | ||
357 | #else | 357 | #else |
358 | delete mKOListViewWhatsThis; | 358 | delete mKOListViewWhatsThis; |
359 | #endif | 359 | #endif |
360 | } | 360 | } |
361 | 361 | ||
362 | QString KOListView::getWhatsThisText(QPoint p) | 362 | QString KOListView::getWhatsThisText(QPoint p) |
363 | { | 363 | { |
364 | KOListViewItem* item = ( KOListViewItem* ) mListView->itemAt( p ); | 364 | KOListViewItem* item = ( KOListViewItem* ) mListView->itemAt( p ); |
365 | if ( item ) | 365 | if ( item ) |
366 | return KIncidenceFormatter::instance()->getFormattedText( item->data(), | 366 | return KIncidenceFormatter::instance()->getFormattedText( item->data(), |
367 | KOPrefs::instance()->mWTshowDetails, | 367 | KOPrefs::instance()->mWTshowDetails, |
368 | KOPrefs::instance()->mWTshowCreated, | 368 | KOPrefs::instance()->mWTshowCreated, |
369 | KOPrefs::instance()->mWTshowChanged); | 369 | KOPrefs::instance()->mWTshowChanged); |
370 | return i18n("That is the list view" ); | 370 | return i18n("That is the list view" ); |
371 | 371 | ||
372 | } | 372 | } |
373 | 373 | ||
374 | void KOListView::updateList() | 374 | void KOListView::updateList() |
375 | { | 375 | { |
376 | // qDebug(" KOListView::updateList() "); | 376 | // qDebug(" KOListView::updateList() "); |
377 | 377 | ||
378 | } | 378 | } |
379 | 379 | ||
380 | void KOListView::clearList() | 380 | void KOListView::clearList() |
381 | { | 381 | { |
382 | clear (); | 382 | clear (); |
383 | } | 383 | } |
384 | void KOListView::addCat( ) | 384 | void KOListView::addCat( ) |
385 | { | 385 | { |
386 | setCategories( false ); | 386 | setCategories( false ); |
387 | } | 387 | } |
388 | void KOListView::setCat() | 388 | void KOListView::setCat() |
389 | { | 389 | { |
390 | setCategories( true ); | 390 | setCategories( true ); |
391 | } | 391 | } |
392 | |||
392 | void KOListView::setAlarm() | 393 | void KOListView::setAlarm() |
393 | { | 394 | { |
394 | KOAlarmPrefs kap( this); | 395 | KOAlarmPrefs kap( this); |
395 | if ( !kap.exec() ) | 396 | if ( !kap.exec() ) |
396 | return; | 397 | return; |
397 | QStringList itemList; | 398 | QStringList itemList; |
398 | QPtrList<KOListViewItem> sel ; | 399 | QPtrList<KOListViewItem> sel ; |
399 | QListViewItem *qitem = mListView->firstChild (); | 400 | QListViewItem *qitem = mListView->firstChild (); |
400 | while ( qitem ) { | 401 | while ( qitem ) { |
401 | if ( qitem->isSelected() ) { | 402 | if ( qitem->isSelected() ) { |
402 | Incidence* inc = ((KOListViewItem *) qitem)->data(); | 403 | Incidence* inc = ((KOListViewItem *) qitem)->data(); |
403 | if ( inc->typeID() != journalID ) { | 404 | if ( inc->typeID() != journalID ) { |
404 | if ( inc->typeID() == todoID ) { | 405 | if ( inc->typeID() == todoID ) { |
405 | if ( ((Todo*)inc)->hasDueDate() ) | 406 | if ( ((Todo*)inc)->hasDueDate() ) |
406 | sel.append(((KOListViewItem *)qitem)); | 407 | sel.append(((KOListViewItem *)qitem)); |
407 | } else | 408 | } else |
408 | sel.append(((KOListViewItem *)qitem)); | 409 | sel.append(((KOListViewItem *)qitem)); |
409 | } | 410 | } |
410 | } | 411 | } |
411 | qitem = qitem->nextSibling(); | 412 | qitem = qitem->nextSibling(); |
412 | } | 413 | } |
413 | int count = 0; | 414 | int count = 0; |
414 | KOListViewItem * item, *temp; | 415 | KOListViewItem * item, *temp; |
415 | item = sel.first(); | 416 | item = sel.first(); |
416 | Incidence* inc; | 417 | Incidence* inc; |
417 | while ( item ) { | 418 | while ( item ) { |
418 | inc = item->data(); | 419 | inc = item->data(); |
419 | ++count; | 420 | ++count; |
420 | if (kap.mAlarmButton->isChecked()) { | 421 | if (kap.mAlarmButton->isChecked()) { |
421 | if (inc->alarms().count() == 0) | 422 | if (inc->alarms().count() == 0) |
422 | inc->newAlarm(); | 423 | inc->newAlarm(); |
423 | QPtrList<Alarm> alarms = inc->alarms(); | 424 | QPtrList<Alarm> alarms = inc->alarms(); |
424 | Alarm *alarm; | 425 | Alarm *alarm; |
425 | for (alarm = alarms.first(); alarm; alarm = alarms.next() ) { | 426 | for (alarm = alarms.first(); alarm; alarm = alarms.next() ) { |
426 | alarm->setEnabled(true); | 427 | alarm->setEnabled(true); |
427 | int j = kap.mAlarmTimeEdit->value()* -60; | 428 | int j = kap.mAlarmTimeEdit->value()* -60; |
428 | if (kap.mAlarmIncrCombo->currentItem() == 1) | 429 | if (kap.mAlarmIncrCombo->currentItem() == 1) |
429 | j = j * 60; | 430 | j = j * 60; |
430 | else if (kap.mAlarmIncrCombo->currentItem() == 2) | 431 | else if (kap.mAlarmIncrCombo->currentItem() == 2) |
431 | j = j * (60 * 24); | 432 | j = j * (60 * 24); |
432 | alarm->setStartOffset( j ); | 433 | alarm->setStartOffset( j ); |
433 | 434 | ||
434 | if (!kap.mAlarmProgram.isEmpty() && kap.mAlarmProgramButton->isOn()) { | 435 | if (!kap.mAlarmProgram.isEmpty() && kap.mAlarmProgramButton->isOn()) { |
435 | alarm->setProcedureAlarm(kap.mAlarmProgram); | 436 | alarm->setProcedureAlarm(kap.mAlarmProgram); |
436 | } | 437 | } |
437 | else if (!kap.mAlarmSound.isEmpty() && kap.mAlarmSoundButton->isOn()) | 438 | else if (!kap.mAlarmSound.isEmpty() && kap.mAlarmSoundButton->isOn()) |
438 | alarm->setAudioAlarm(kap.mAlarmSound); | 439 | alarm->setAudioAlarm(kap.mAlarmSound); |
439 | else | 440 | else |
440 | alarm->setType(Alarm::Invalid); | 441 | alarm->setType(Alarm::Invalid); |
441 | //alarm->setAudioAlarm("default"); | 442 | //alarm->setAudioAlarm("default"); |
442 | // TODO: Deal with multiple alarms | 443 | // TODO: Deal with multiple alarms |
443 | break; // For now, stop after the first alarm | 444 | break; // For now, stop after the first alarm |
444 | } | 445 | } |
445 | } else { | 446 | } else { |
446 | Alarm* alarm = inc->alarms().first(); | 447 | Alarm* alarm = inc->alarms().first(); |
447 | if ( alarm ) { | 448 | if ( alarm ) { |
448 | alarm->setEnabled(false); | 449 | alarm->setEnabled(false); |
449 | alarm->setType(Alarm::Invalid); | 450 | alarm->setType(Alarm::Invalid); |
450 | } | 451 | } |
451 | } | 452 | } |
452 | ListItemVisitor v(item, mStartDate ); | 453 | ListItemVisitor v(item, mStartDate ); |
453 | inc->accept(v); | 454 | inc->accept(v); |
454 | item = sel.next(); | 455 | item = sel.next(); |
455 | } | 456 | } |
456 | topLevelWidget()->setCaption( i18n("Changed alarm for %1 items").arg( count ) ); | 457 | topLevelWidget()->setCaption( i18n("Changed alarm for %1 items").arg( count ) ); |
457 | qDebug("KO: Set alarm for %d items", count); | 458 | qDebug("KO: Set alarm for %d items", count); |
458 | calendar()->reInitAlarmSettings(); | 459 | calendar()->reInitAlarmSettings(); |
459 | QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); | 460 | QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); |
460 | } | 461 | } |
461 | void KOListView::setCategories( bool removeOld ) | 462 | void KOListView::setCategories( bool removeOld ) |
462 | { | 463 | { |
463 | 464 | ||
464 | KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); | 465 | KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); |
465 | csd->setColorEnabled(); | 466 | csd->setColorEnabled(); |
466 | if (! csd->exec()) { | 467 | if (! csd->exec()) { |
467 | delete csd; | 468 | delete csd; |
468 | return; | 469 | return; |
469 | } | 470 | } |
470 | QStringList catList = csd->selectedCategories(); | 471 | QStringList catList = csd->selectedCategories(); |
471 | delete csd; | 472 | delete csd; |
472 | // if ( catList.count() == 0 ) | 473 | // if ( catList.count() == 0 ) |
473 | // return; | 474 | // return; |
474 | //catList.sort(); | 475 | //catList.sort(); |
475 | QString categoriesStr = catList.join(","); | 476 | QString categoriesStr = catList.join(","); |
476 | int i; | 477 | int i; |
477 | QStringList itemList; | 478 | QStringList itemList; |
478 | QPtrList<KOListViewItem> sel ; | 479 | QPtrList<KOListViewItem> sel ; |
479 | QListViewItem *qitem = mListView->firstChild (); | 480 | QListViewItem *qitem = mListView->firstChild (); |
480 | while ( qitem ) { | 481 | while ( qitem ) { |
481 | if ( qitem->isSelected() ) { | 482 | if ( qitem->isSelected() ) { |
482 | sel.append(((KOListViewItem *)qitem)); | 483 | sel.append(((KOListViewItem *)qitem)); |
483 | } | 484 | } |
484 | qitem = qitem->nextSibling(); | 485 | qitem = qitem->nextSibling(); |
485 | } | 486 | } |
486 | KOListViewItem * item, *temp; | 487 | KOListViewItem * item, *temp; |
487 | item = sel.first(); | 488 | item = sel.first(); |
488 | if( item ) { | 489 | if( item ) { |
489 | Incidence* inc = item->data() ; | 490 | Incidence* inc = item->data() ; |
490 | bool setSub = false; | 491 | bool setSub = false; |
491 | if( inc->typeID() == todoID && sel.count() == 1 && inc->relations().count() > 0 ) { | 492 | if( inc->typeID() == todoID && sel.count() == 1 && inc->relations().count() > 0 ) { |
492 | int result = KMessageBox::warningYesNoCancel(this, | 493 | int result = KMessageBox::warningYesNoCancel(this, |
493 | i18n("The todo\n%1\nhas subtodos!\nDo you want to set\nthe categories for\nall subtodos as well?").arg( inc->summary().left ( 25 ) ), | 494 | i18n("The todo\n%1\nhas subtodos!\nDo you want to set\nthe categories for\nall subtodos as well?").arg( inc->summary().left ( 25 ) ), |
494 | i18n("Todo has subtodos"), | 495 | i18n("Todo has subtodos"), |
495 | i18n("Yes"), | 496 | i18n("Yes"), |
496 | i18n("No")); | 497 | i18n("No")); |
497 | if (result == KMessageBox::Cancel) item = 0; | 498 | if (result == KMessageBox::Cancel) item = 0; |
498 | if (result == KMessageBox::Yes) setSub = true; | 499 | if (result == KMessageBox::Yes) setSub = true; |
499 | } | 500 | } |
500 | while ( item ) { | 501 | while ( item ) { |
501 | inc = item->data(); | 502 | inc = item->data(); |
502 | if ( removeOld ) { | 503 | if ( removeOld ) { |
503 | inc->setCategories( catList, setSub ); | 504 | inc->setCategories( catList, setSub ); |
504 | } else { | 505 | } else { |
505 | inc->addCategories( catList, setSub ); | 506 | inc->addCategories( catList, setSub ); |
506 | } | 507 | } |
507 | ListItemVisitor v(item, mStartDate ); | 508 | ListItemVisitor v(item, mStartDate ); |
508 | inc->accept(v); | 509 | inc->accept(v); |
509 | item = sel.next(); | 510 | item = sel.next(); |
510 | } | 511 | } |
511 | } | 512 | } |
512 | QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); | 513 | QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); |
513 | } | 514 | } |
514 | 515 | ||
515 | void KOListView::beamSelected() | 516 | void KOListView::beamSelected() |
516 | { | 517 | { |
517 | int icount = 0; | 518 | QPtrList<Incidence> delSel = getSelectedIncidences() ; |
518 | QPtrList<Incidence> delSel ; | 519 | int icount = delSel.count(); |
519 | QListViewItem *item = mListView->firstChild (); | ||
520 | while ( item ) { | ||
521 | if ( item->isSelected() ) { | ||
522 | delSel.append(((KOListViewItem *)item)->data()); | ||
523 | ++icount; | ||
524 | } | ||
525 | |||
526 | item = item->nextSibling(); | ||
527 | } | ||
528 | if ( icount ) { | 520 | if ( icount ) { |
529 | emit beamIncidenceList( delSel ); | 521 | emit beamIncidenceList( delSel ); |
530 | return; | 522 | return; |
531 | QString fn ; | 523 | QString fn ; |
532 | fn = QDir::homeDirPath()+"/kopitempbeamfile.vcs"; | 524 | fn = QDir::homeDirPath()+"/kopitempbeamfile.vcs"; |
533 | QString mes; | 525 | QString mes; |
534 | bool createbup = true; | 526 | bool createbup = true; |
535 | if ( createbup ) { | 527 | if ( createbup ) { |
536 | QString description = "\n"; | 528 | QString description = "\n"; |
537 | CalendarLocal* cal = new CalendarLocal(); | 529 | CalendarLocal* cal = new CalendarLocal(); |
538 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 530 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
539 | Incidence *incidence = delSel.first(); | 531 | Incidence *incidence = delSel.first(); |
540 | while ( incidence ) { | 532 | while ( incidence ) { |
541 | Incidence *in = incidence->clone(); | 533 | Incidence *in = incidence->clone(); |
542 | description += in->summary() + "\n"; | 534 | description += in->summary() + "\n"; |
543 | cal->addIncidence( in ); | 535 | cal->addIncidence( in ); |
544 | incidence = delSel.next(); | 536 | incidence = delSel.next(); |
545 | } | 537 | } |
546 | FileStorage storage( cal, fn, new VCalFormat ); | 538 | FileStorage storage( cal, fn, new VCalFormat ); |
547 | storage.save(); | 539 | storage.save(); |
548 | delete cal; | 540 | delete cal; |
549 | mes = i18n("KO/Pi: Ready for beaming"); | 541 | mes = i18n("KO/Pi: Ready for beaming"); |
550 | topLevelWidget()->setCaption(mes); | 542 | topLevelWidget()->setCaption(mes); |
551 | 543 | ||
552 | #ifndef DESKTOP_VERSION | 544 | #ifndef DESKTOP_VERSION |
553 | Ir *ir = new Ir( this ); | 545 | Ir *ir = new Ir( this ); |
554 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 546 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
555 | ir->send( fn, description, "text/x-vCalendar" ); | 547 | ir->send( fn, description, "text/x-vCalendar" ); |
556 | #endif | 548 | #endif |
557 | } | 549 | } |
558 | } | 550 | } |
559 | } | 551 | } |
560 | void KOListView::beamDone( Ir *ir ) | 552 | void KOListView::beamDone( Ir *ir ) |
561 | { | 553 | { |
562 | #ifndef DESKTOP_VERSION | 554 | #ifndef DESKTOP_VERSION |
563 | delete ir; | 555 | delete ir; |
564 | #endif | 556 | #endif |
565 | topLevelWidget()->setCaption(i18n("KO/Pi:Beaming done")); | 557 | topLevelWidget()->setCaption(i18n("KO/Pi:Beaming done")); |
566 | } | 558 | } |
567 | 559 | ||
568 | void KOListView::saveDescriptionToFile() | 560 | void KOListView::saveDescriptionToFile() |
569 | { | 561 | { |
570 | 562 | ||
571 | int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"), | 563 | int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"), |
572 | i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."), | 564 | i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."), |
573 | i18n("Continue"), i18n("Cancel"), 0, | 565 | i18n("Continue"), i18n("Cancel"), 0, |
574 | 0, 1 ); | 566 | 0, 1 ); |
575 | if ( result != 0 ) { | 567 | if ( result != 0 ) { |
576 | return; | 568 | return; |
577 | } | 569 | } |
578 | int icount = 0; | 570 | QPtrList<Incidence> delSel = getSelectedIncidences() ; |
579 | QPtrList<Incidence> delSel ; | 571 | int icount = delSel.count(); |
580 | QListViewItem *item = mListView->firstChild (); | ||
581 | while ( item ) { | ||
582 | if ( item->isSelected() ) { | ||
583 | delSel.append(((KOListViewItem *)item)->data()); | ||
584 | ++icount; | ||
585 | } | ||
586 | |||
587 | item = item->nextSibling(); | ||
588 | } | ||
589 | if ( icount ) { | 572 | if ( icount ) { |
590 | QString fn = KOPrefs::instance()->mLastSaveFile; | 573 | QString fn = KOPrefs::instance()->mLastSaveFile; |
591 | fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); | 574 | fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); |
592 | 575 | ||
593 | if ( fn == "" ) | 576 | if ( fn == "" ) |
594 | return; | 577 | return; |
595 | QFileInfo info; | 578 | QFileInfo info; |
596 | info.setFile( fn ); | 579 | info.setFile( fn ); |
597 | QString mes; | 580 | QString mes; |
598 | bool createbup = true; | 581 | bool createbup = true; |
599 | if ( info. exists() ) { | 582 | if ( info. exists() ) { |
600 | mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); | 583 | mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); |
601 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 584 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
602 | i18n("Overwrite!"), i18n("Cancel"), 0, | 585 | i18n("Overwrite!"), i18n("Cancel"), 0, |
603 | 0, 1 ); | 586 | 0, 1 ); |
604 | if ( result != 0 ) { | 587 | if ( result != 0 ) { |
605 | createbup = false; | 588 | createbup = false; |
606 | } | 589 | } |
607 | } | 590 | } |
608 | if ( createbup ) { | 591 | if ( createbup ) { |
609 | QString text = i18n("KO/Pi Description/Journal save file.\nSave date: ") + | 592 | QString text = i18n("KO/Pi Description/Journal save file.\nSave date: ") + |
610 | KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), false); | 593 | KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), false); |
611 | Incidence *incidence = delSel.first(); | 594 | Incidence *incidence = delSel.first(); |
612 | icount = 0; | 595 | icount = 0; |
613 | while ( incidence ) { | 596 | while ( incidence ) { |
614 | if ( incidence->typeID() == journalID ) { | 597 | if ( incidence->typeID() == journalID ) { |
615 | text += "\n************************************\n"; | 598 | text += "\n************************************\n"; |
616 | text += i18n("Journal from: ") +incidence->dtStartDateStr( false ); | 599 | text += i18n("Journal from: ") +incidence->dtStartDateStr( false ); |
617 | text +="\n" + i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); | 600 | text +="\n" + i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); |
618 | text +="\n" + i18n("Description: ") + "\n"+ incidence->description(); | 601 | text +="\n" + i18n("Description: ") + "\n"+ incidence->description(); |
619 | ++icount; | 602 | ++icount; |
620 | 603 | ||
621 | } else { | 604 | } else { |
622 | if ( !incidence->description().isEmpty() ) { | 605 | if ( !incidence->description().isEmpty() ) { |
623 | text += "\n************************************\n"; | 606 | text += "\n************************************\n"; |
624 | if ( incidence->typeID() == todoID ) | 607 | if ( incidence->typeID() == todoID ) |
625 | text += i18n("To-Do: "); | 608 | text += i18n("To-Do: "); |
626 | text += incidence->summary(); | 609 | text += incidence->summary(); |
627 | if ( incidence->hasStartDate() ) | 610 | if ( incidence->hasStartDate() ) |
628 | text +="\n"+ i18n("Start Date: ") + incidence->dtStartStr( false ); | 611 | text +="\n"+ i18n("Start Date: ") + incidence->dtStartStr( false ); |
629 | text +="\n"+ i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); | 612 | text +="\n"+ i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); |
630 | if ( !incidence->location().isEmpty() ) | 613 | if ( !incidence->location().isEmpty() ) |
631 | text += "\n" +i18n("Location: ") + incidence->location(); | 614 | text += "\n" +i18n("Location: ") + incidence->location(); |
632 | text += "\n" + i18n("Description: ") + "\n" + incidence->description(); | 615 | text += "\n" + i18n("Description: ") + "\n" + incidence->description(); |
633 | ++icount; | 616 | ++icount; |
634 | 617 | ||
635 | } | 618 | } |
636 | } | 619 | } |
637 | incidence = delSel.next(); | 620 | incidence = delSel.next(); |
638 | } | 621 | } |
639 | QFile file( fn ); | 622 | QFile file( fn ); |
640 | if (!file.open( IO_WriteOnly ) ) { | 623 | if (!file.open( IO_WriteOnly ) ) { |
641 | topLevelWidget()->setCaption(i18n("File open error - nothing saved!") ); | 624 | topLevelWidget()->setCaption(i18n("File open error - nothing saved!") ); |
642 | return; | 625 | return; |
643 | } | 626 | } |
644 | QTextStream ts( &file ); | 627 | QTextStream ts( &file ); |
645 | ts << text; | 628 | ts << text; |
646 | file.close(); | 629 | file.close(); |
647 | //qDebug("%s ", text.latin1()); | 630 | //qDebug("%s ", text.latin1()); |
648 | mes = i18n("KO/Pi:Saved %1 descriptions/journals").arg(icount ); | 631 | mes = i18n("KO/Pi:Saved %1 descriptions/journals").arg(icount ); |
649 | KOPrefs::instance()->mLastSaveFile = fn; | 632 | KOPrefs::instance()->mLastSaveFile = fn; |
650 | topLevelWidget()->setCaption(mes); | 633 | topLevelWidget()->setCaption(mes); |
651 | } | 634 | } |
652 | } | 635 | } |
653 | } | 636 | } |
654 | void KOListView::saveToFileVCS() | 637 | void KOListView::saveToFileVCS() |
655 | { | 638 | { |
656 | writeToFile( false ); | 639 | writeToFile( false ); |
657 | } | 640 | } |
658 | void KOListView::saveToFile() | 641 | void KOListView::saveToFile() |
659 | { | 642 | { |
660 | writeToFile( true ); | 643 | writeToFile( true ); |
661 | } | 644 | } |
662 | void KOListView::writeToFile( bool iCal ) | 645 | QPtrList<Incidence> KOListView::getSelectedIncidences( bool includeEvents, bool includeTodos, bool includeJournals, bool onlyDueTodos ) |
663 | { | 646 | { |
664 | |||
665 | int icount = 0; | ||
666 | QPtrList<Incidence> delSel ; | 647 | QPtrList<Incidence> delSel ; |
667 | QListViewItem *item = mListView->firstChild (); | ||
668 | bool journal = iCal; // warn only for vCal | ||
669 | bool addSubTodos = false; | 648 | bool addSubTodos = false; |
670 | bool askSubTodos = true; | 649 | bool askSubTodos = true; |
650 | QListViewItem *item = mListView->firstChild (); | ||
671 | while ( item ) { | 651 | while ( item ) { |
672 | if ( item->isSelected() ) { | 652 | if ( item->isSelected() ) { |
673 | if ( !journal ) | ||
674 | if ( ((KOListViewItem *)item)->data()->typeID() == journalID ) | ||
675 | journal = true; | ||
676 | Incidence* inc = ((KOListViewItem *)item)->data(); | 653 | Incidence* inc = ((KOListViewItem *)item)->data(); |
677 | if ( addSubTodos ) { | 654 | if ( ( addSubTodos && delSel.findRef( inc ) == -1) || !addSubTodos ) { |
678 | if ( delSel.findRef( inc ) == -1 ) | 655 | if ( (inc->typeID() == todoID && includeTodos) || |
679 | delSel.append( inc ); | 656 | (inc->typeID() == eventID && includeEvents) || |
680 | } else | 657 | (inc->typeID() == journalID && includeJournals) ) { |
681 | delSel.append(inc); | 658 | if ( inc->typeID() == todoID && onlyDueTodos ) { |
659 | if ( ((Todo*)inc)->hasDueDate() ) | ||
660 | delSel.append( inc ); | ||
661 | } else | ||
662 | delSel.append( inc ); | ||
663 | |||
664 | } | ||
665 | } | ||
682 | if ( inc->typeID() == todoID ) { | 666 | if ( inc->typeID() == todoID ) { |
683 | Todo * todo = (Todo*) inc; | 667 | Todo * todo = (Todo*) inc; |
684 | if ( todo->relations().count() ) { | 668 | if ( todo->relations().count() ) { |
685 | if ( askSubTodos ) { | 669 | if ( askSubTodos ) { |
686 | int result = KMessageBox::warningYesNoCancel(this, | 670 | int result = KMessageBox::warningYesNoCancel(this, |
687 | i18n("A selected todo has subtodos!\nDo you want to export\nall subtodos of all\nselected todos as well?"), | 671 | i18n("One (or more) selected\ntodo has subtodos!\nDo you want to select\nall subtodos of all\nselected todos as well?"), |
688 | i18n("Todo has subtodos"), | 672 | i18n("Todo has subtodos"), |
689 | i18n("Yes"), | 673 | i18n("Yes"), |
690 | i18n("No")); | 674 | i18n("No")); |
691 | if ( result == KMessageBox::Cancel ) { | 675 | if ( result == KMessageBox::Cancel ) { |
692 | return; | 676 | delSel.clear(); |
677 | return delSel; | ||
693 | } | 678 | } |
694 | if (result == KMessageBox::Yes) | 679 | if (result == KMessageBox::Yes) |
695 | addSubTodos = true; | 680 | addSubTodos = true; |
696 | askSubTodos = false; | 681 | askSubTodos = false; |
697 | } | 682 | } |
698 | if ( addSubTodos ) { | 683 | if ( addSubTodos ) { |
699 | inc->addRelationsToList( &delSel ); | 684 | inc->addRelationsToList( &delSel ); |
700 | } | 685 | } |
701 | } | 686 | } |
702 | } | 687 | } |
703 | ++icount; | ||
704 | } | 688 | } |
705 | item = item->nextSibling(); | 689 | item = item->nextSibling(); |
706 | } | 690 | } |
707 | if ( !iCal && journal ) { | 691 | return delSel; |
708 | int result = KMessageBox::warningContinueCancel(this, | 692 | } |
709 | i18n("The journal entries can not be\nexported to a vCalendar file."), | 693 | |
710 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), | 694 | void KOListView::writeToFile( bool iCal ) |
711 | true); | 695 | { |
712 | if (result != KMessageBox::Continue) return; | 696 | QPtrList<Incidence> delSel = getSelectedIncidences(); // all inc allowed; |
697 | if ( !iCal ) { | ||
698 | bool journal = false; | ||
699 | Incidence *incidence = delSel.first(); | ||
700 | while ( incidence ) { | ||
701 | if ( incidence->typeID() == journalID ) { | ||
702 | journal = true; | ||
703 | break; | ||
704 | } | ||
705 | incidence = delSel.next(); | ||
706 | } | ||
707 | if ( journal ) { | ||
708 | int result = KMessageBox::warningContinueCancel(this, | ||
709 | i18n("The journal entries can not be\nexported to a vCalendar file."), | ||
710 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), | ||
711 | true); | ||
712 | if (result != KMessageBox::Continue) return; | ||
713 | } | ||
713 | } | 714 | } |
714 | if ( icount ) { | 715 | if ( delSel.count() ) { |
715 | QString fn = KOPrefs::instance()->mLastSaveFile; | 716 | QString fn = KOPrefs::instance()->mLastSaveFile; |
716 | QString extension; | 717 | QString extension; |
717 | if ( iCal ) { | 718 | if ( iCal ) { |
718 | if ( fn.right( 4 ).lower() == ".vcs" ) { | 719 | if ( fn.right( 4 ).lower() == ".vcs" ) { |
719 | fn = fn.left( fn.length() -3) + "ics"; | 720 | fn = fn.left( fn.length() -3) + "ics"; |
720 | } | 721 | } |
721 | } else { | 722 | } else { |
722 | if ( fn.right( 4 ).lower() == ".ics" ) { | 723 | if ( fn.right( 4 ).lower() == ".ics" ) { |
723 | fn = fn.left( fn.length() -3) + "vcs"; | 724 | fn = fn.left( fn.length() -3) + "vcs"; |
724 | } | 725 | } |
725 | } | 726 | } |
726 | fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); | 727 | fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); |
727 | 728 | ||
728 | if ( fn == "" ) | 729 | if ( fn == "" ) |
729 | return; | 730 | return; |
730 | QFileInfo info; | 731 | QFileInfo info; |
731 | info.setFile( fn ); | 732 | info.setFile( fn ); |
732 | QString mes; | 733 | QString mes; |
733 | bool createbup = true; | 734 | bool createbup = true; |
734 | if ( info. exists() ) { | 735 | if ( info. exists() ) { |
735 | mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); | 736 | mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); |
736 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 737 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
737 | i18n("Overwrite!"), i18n("Cancel"), 0, | 738 | i18n("Overwrite!"), i18n("Cancel"), 0, |
738 | 0, 1 ); | 739 | 0, 1 ); |
739 | if ( result != 0 ) { | 740 | if ( result != 0 ) { |
740 | createbup = false; | 741 | createbup = false; |
741 | } | 742 | } |
742 | } | 743 | } |
743 | if ( createbup ) { | 744 | if ( createbup ) { |
744 | CalendarLocal cal; | 745 | CalendarLocal cal; |
745 | cal.setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 746 | cal.setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
746 | Incidence *incidence = delSel.first(); | 747 | Incidence *incidence = delSel.first(); |
747 | while ( incidence ) { | 748 | while ( incidence ) { |
748 | cal.addIncidence( incidence->clone() ); | 749 | cal.addIncidence( incidence->clone() ); |
749 | incidence = delSel.next(); | 750 | incidence = delSel.next(); |
750 | } | 751 | } |
751 | if ( iCal ) { | 752 | if ( iCal ) { |
752 | ICalFormat format; | 753 | ICalFormat format; |
753 | format.save( &cal, fn ); | 754 | format.save( &cal, fn ); |
754 | } else { | 755 | } else { |
755 | 756 | ||
756 | VCalFormat format; | 757 | VCalFormat format; |
757 | format.save( &cal, fn ); | 758 | format.save( &cal, fn ); |
758 | } | 759 | } |
759 | mes = i18n("KO/Pi:Saved %1").arg(fn ); | 760 | mes = i18n("KO/Pi:Saved %1").arg(fn ); |
760 | KOPrefs::instance()->mLastSaveFile = fn; | 761 | KOPrefs::instance()->mLastSaveFile = fn; |
761 | topLevelWidget()->setCaption(mes); | 762 | topLevelWidget()->setCaption(mes); |
762 | } | 763 | } |
763 | } | 764 | } |
764 | QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); | 765 | QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); |
765 | } | 766 | } |
766 | void KOListView::hideAll() | 767 | void KOListView::hideAll() |
767 | { | 768 | { |
768 | QPtrList<QListViewItem> delSel ; | 769 | QPtrList<QListViewItem> delSel ; |
769 | QListViewItem *item = mListView->firstChild (); | 770 | QListViewItem *item = mListView->firstChild (); |
770 | while ( item ) { | 771 | while ( item ) { |
771 | if ( item->isSelected() ) { | 772 | if ( item->isSelected() ) { |
772 | delSel.append(item); | 773 | delSel.append(item); |
773 | } | 774 | } |
774 | item = item->nextSibling(); | 775 | item = item->nextSibling(); |
775 | } | 776 | } |
776 | item = delSel.first() ; | 777 | item = delSel.first() ; |
777 | while ( item ) { | 778 | while ( item ) { |
778 | QListViewItem * del = item; | 779 | QListViewItem * del = item; |
779 | item = delSel.next(); | 780 | item = delSel.next(); |
780 | delete del; | 781 | delete del; |
781 | } | 782 | } |
782 | } | 783 | } |
783 | void KOListView::printList() | 784 | void KOListView::printList() |
784 | { | 785 | { |
785 | mListView->printList(); | 786 | mListView->printList(); |
786 | } | 787 | } |
787 | void KOListView::deleteAll() | 788 | void KOListView::deleteAll() |
788 | { | 789 | { |
789 | int icount = 0; | 790 | QPtrList<Incidence> delSel = getSelectedIncidences(); // all inc allowed;; |
790 | QPtrList<Incidence> delSel ; | 791 | if ( delSel.count() ) { |
791 | QListViewItem *item = mListView->firstChild (); | 792 | int icount = delSel.count(); |
792 | while ( item ) { | ||
793 | if ( item->isSelected() ) { | ||
794 | delSel.append(((KOListViewItem *)item)->data()); | ||
795 | ++icount; | ||
796 | } | ||
797 | |||
798 | item = item->nextSibling(); | ||
799 | } | ||
800 | if ( icount ) { | ||
801 | Incidence *incidence = delSel.first(); | 793 | Incidence *incidence = delSel.first(); |
802 | Incidence *toDelete; | 794 | Incidence *toDelete; |
803 | KOPrefs *p = KOPrefs::instance(); | 795 | KOPrefs *p = KOPrefs::instance(); |
804 | bool confirm = p->mConfirm; | 796 | bool confirm = p->mConfirm; |
805 | QString mess; | 797 | QString mess; |
806 | mess = mess.sprintf( i18n("You have %d item(s) selected.\n"), icount ); | 798 | mess = mess.sprintf( i18n("You have %d item(s) selected.\n"), icount ); |
807 | if ( KMessageBox::Continue == KMessageBox::warningContinueCancel(this, mess + i18n("All selected items will be\npermanently deleted.\n(Deleting items will take\nsome time on a PDA)\n"), i18n("KO/Pi Confirmation"),i18n("Delete")) ) { | 799 | if ( KMessageBox::Continue == KMessageBox::warningContinueCancel(this, mess + i18n("All selected items will be\npermanently deleted.\n(Deleting items will take\nsome time on a PDA)\n"), i18n("KO/Pi Confirmation"),i18n("Delete")) ) { |
808 | p->mConfirm = false; | 800 | p->mConfirm = false; |
809 | int delCounter = 0; | 801 | int delCounter = 0; |
810 | QDialog dia ( this, "p-dialog", true ); | 802 | QDialog dia ( this, "p-dialog", true ); |
811 | QLabel lab (i18n("Close dialog to abort deletion!"), &dia ); | 803 | QLabel lab (i18n("Close dialog to abort deletion!"), &dia ); |
812 | QVBoxLayout lay( &dia ); | 804 | QVBoxLayout lay( &dia ); |
813 | lay.setMargin(7); | 805 | lay.setMargin(7); |
814 | lay.setSpacing(7); | 806 | lay.setSpacing(7); |
815 | lay.addWidget( &lab); | 807 | lay.addWidget( &lab); |
816 | QProgressBar bar( icount, &dia ); | 808 | QProgressBar bar( icount, &dia ); |
817 | lay.addWidget( &bar); | 809 | lay.addWidget( &bar); |
818 | int w = 220; | 810 | int w = 220; |
819 | int h = 50; | 811 | int h = 50; |
820 | int dw = QApplication::desktop()->width(); | 812 | int dw = QApplication::desktop()->width(); |
821 | int dh = QApplication::desktop()->height(); | 813 | int dh = QApplication::desktop()->height(); |
822 | dia.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 814 | dia.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
823 | //dia.resize( 240,50 ); | 815 | //dia.resize( 240,50 ); |
824 | dia.show(); | 816 | dia.show(); |
825 | 817 | ||
826 | while ( incidence ) { | 818 | while ( incidence ) { |
827 | bar.setProgress( delCounter ); | 819 | bar.setProgress( delCounter ); |
828 | mess = mess.sprintf( i18n("Deleting item %d ..."), ++delCounter ); | 820 | mess = mess.sprintf( i18n("Deleting item %d ..."), ++delCounter ); |
829 | dia.setCaption( mess ); | 821 | dia.setCaption( mess ); |
830 | qApp->processEvents(); | 822 | qApp->processEvents(); |
831 | toDelete = (incidence); | 823 | toDelete = (incidence); |
832 | incidence = delSel.next(); | 824 | incidence = delSel.next(); |
833 | emit deleteIncidenceSignal(toDelete ); | 825 | emit deleteIncidenceSignal(toDelete ); |
834 | if ( dia.result() != 0 ) | 826 | if ( dia.result() != 0 ) |
835 | break; | 827 | break; |
836 | 828 | ||
837 | } | 829 | } |
838 | mess = mess.sprintf( i18n("%d items remaining in list."), count() ); | 830 | mess = mess.sprintf( i18n("%d items remaining in list."), count() ); |
839 | topLevelWidget ()->setCaption( mess ); | 831 | topLevelWidget ()->setCaption( mess ); |
840 | p->mConfirm = confirm; | 832 | p->mConfirm = confirm; |
841 | } | 833 | } |
842 | } | 834 | } |
843 | 835 | ||
844 | 836 | ||
845 | } | 837 | } |
846 | int KOListView::maxDatesHint() | 838 | int KOListView::maxDatesHint() |
847 | { | 839 | { |
848 | return 0; | 840 | return 0; |
849 | } | 841 | } |
850 | 842 | ||
851 | int KOListView::currentDateCount() | 843 | int KOListView::currentDateCount() |
852 | { | 844 | { |
853 | return 0; | 845 | return 0; |
854 | } | 846 | } |
855 | 847 | ||
856 | QPtrList<Incidence> KOListView::selectedIncidences() | 848 | QPtrList<Incidence> KOListView::selectedIncidences() |
857 | { | 849 | { |
858 | QPtrList<Incidence> eventList; | 850 | QPtrList<Incidence> eventList; |
859 | QListViewItem *item = mListView->firstChild (); | 851 | QListViewItem *item = mListView->firstChild (); |
860 | while ( item ) { | 852 | while ( item ) { |
861 | if ( item->isSelected() ) { | 853 | if ( item->isSelected() ) { |
862 | eventList.append(((KOListViewItem *)item)->data()); | 854 | eventList.append(((KOListViewItem *)item)->data()); |
863 | } | 855 | } |
864 | 856 | ||
865 | item = item->nextSibling(); | 857 | item = item->nextSibling(); |
866 | } | 858 | } |
867 | 859 | ||
868 | // // QListViewItem *item = mListView->selectedItem(); | 860 | // // QListViewItem *item = mListView->selectedItem(); |
869 | //if (item) eventList.append(((KOListViewItem *)item)->data()); | 861 | //if (item) eventList.append(((KOListViewItem *)item)->data()); |
870 | 862 | ||
871 | return eventList; | 863 | return eventList; |
872 | } | 864 | } |
873 | 865 | ||
874 | DateList KOListView::selectedDates() | 866 | DateList KOListView::selectedDates() |
875 | { | 867 | { |
876 | DateList eventList; | 868 | DateList eventList; |
877 | return eventList; | 869 | return eventList; |
878 | } | 870 | } |
879 | 871 | ||
880 | void KOListView::showDates(bool show) | 872 | void KOListView::showDates(bool show) |
881 | { | 873 | { |
882 | // Shouldn't we set it to a value greater 0? When showDates is called with | 874 | // Shouldn't we set it to a value greater 0? When showDates is called with |
883 | // show == true at first, then the columnwidths are set to zero. | 875 | // show == true at first, then the columnwidths are set to zero. |
884 | static int oldColWidth1 = 0; | 876 | static int oldColWidth1 = 0; |
885 | static int oldColWidth3 = 0; | 877 | static int oldColWidth3 = 0; |
886 | 878 | ||
887 | if (!show) { | 879 | if (!show) { |
888 | oldColWidth1 = mListView->columnWidth(1); | 880 | oldColWidth1 = mListView->columnWidth(1); |
889 | oldColWidth3 = mListView->columnWidth(3); | 881 | oldColWidth3 = mListView->columnWidth(3); |
890 | mListView->setColumnWidth(1, 0); | 882 | mListView->setColumnWidth(1, 0); |
891 | mListView->setColumnWidth(3, 0); | 883 | mListView->setColumnWidth(3, 0); |
892 | } else { | 884 | } else { |
893 | mListView->setColumnWidth(1, oldColWidth1); | 885 | mListView->setColumnWidth(1, oldColWidth1); |
894 | mListView->setColumnWidth(3, oldColWidth3); | 886 | mListView->setColumnWidth(3, oldColWidth3); |
895 | } | 887 | } |
896 | mListView->repaint(); | 888 | mListView->repaint(); |
897 | } | 889 | } |
898 | 890 | ||
899 | void KOListView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 891 | void KOListView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
900 | const QDate &td) | 892 | const QDate &td) |
901 | { | 893 | { |
902 | #ifndef KORG_NOPRINTER | 894 | #ifndef KORG_NOPRINTER |
903 | calPrinter->preview(CalPrinter::Day, fd, td); | 895 | calPrinter->preview(CalPrinter::Day, fd, td); |
904 | #endif | 896 | #endif |
905 | } | 897 | } |
906 | 898 | ||
907 | void KOListView::showDates() | 899 | void KOListView::showDates() |
908 | { | 900 | { |
909 | showDates(true); | 901 | showDates(true); |
910 | } | 902 | } |
911 | 903 | ||
912 | void KOListView::hideDates() | 904 | void KOListView::hideDates() |
913 | { | 905 | { |
914 | showDates(false); | 906 | showDates(false); |
915 | } | 907 | } |
916 | 908 | ||
917 | void KOListView::resetFocus() | 909 | void KOListView::resetFocus() |
918 | { | 910 | { |
919 | topLevelWidget()->setActiveWindow(); | 911 | topLevelWidget()->setActiveWindow(); |
920 | topLevelWidget()->raise(); | 912 | topLevelWidget()->raise(); |
921 | mListView->setFocus(); | 913 | mListView->setFocus(); |
922 | } | 914 | } |
923 | void KOListView::updateView() | 915 | void KOListView::updateView() |
924 | { | 916 | { |
925 | mListView->setFocus(); | 917 | mListView->setFocus(); |
926 | if ( mListView->firstChild () ) | 918 | if ( mListView->firstChild () ) |
927 | mListView->setCurrentItem( mListView->firstChild () ); | 919 | mListView->setCurrentItem( mListView->firstChild () ); |
928 | } | 920 | } |
929 | void KOListView::updateConfig() | 921 | void KOListView::updateConfig() |
930 | { | 922 | { |
931 | 923 | ||
932 | mListView->setFont ( KOPrefs::instance()->mListViewFont ); | 924 | mListView->setFont ( KOPrefs::instance()->mListViewFont ); |
933 | updateView(); | 925 | updateView(); |
934 | 926 | ||
935 | } | 927 | } |
936 | void KOListView::setStartDate(const QDate &start) | 928 | void KOListView::setStartDate(const QDate &start) |
937 | { | 929 | { |
938 | mStartDate = start; | 930 | mStartDate = start; |
939 | } | 931 | } |
940 | 932 | ||
941 | void KOListView::showDates(const QDate &start, const QDate &end) | 933 | void KOListView::showDates(const QDate &start, const QDate &end) |
942 | { | 934 | { |
943 | clear(); | 935 | clear(); |
944 | mStartDate = start; | 936 | mStartDate = start; |
945 | QDate date = start; | 937 | QDate date = start; |
946 | QPtrList<Journal> j_list; | 938 | QPtrList<Journal> j_list; |
947 | while( date <= end ) { | 939 | while( date <= end ) { |
948 | addEvents(calendar()->events(date)); | 940 | addEvents(calendar()->events(date)); |
949 | addTodos(calendar()->todos(date)); | 941 | addTodos(calendar()->todos(date)); |
950 | Journal* jo = calendar()->journal(date); | 942 | Journal* jo = calendar()->journal(date); |
951 | if ( jo ) | 943 | if ( jo ) |
952 | j_list.append( jo ); | 944 | j_list.append( jo ); |
953 | date = date.addDays( 1 ); | 945 | date = date.addDays( 1 ); |
954 | } | 946 | } |
955 | addJournals(j_list); | 947 | addJournals(j_list); |
956 | emit incidenceSelected( 0 ); | 948 | emit incidenceSelected( 0 ); |
957 | updateView(); | 949 | updateView(); |
958 | 950 | ||
959 | } | 951 | } |
960 | 952 | ||
961 | void KOListView::addEvents(QPtrList<Event> eventList) | 953 | void KOListView::addEvents(QPtrList<Event> eventList) |
962 | { | 954 | { |
963 | 955 | ||
964 | Event *ev; | 956 | Event *ev; |
965 | for(ev = eventList.first(); ev; ev = eventList.next()) { | 957 | for(ev = eventList.first(); ev; ev = eventList.next()) { |
966 | addIncidence(ev); | 958 | addIncidence(ev); |
967 | } | 959 | } |
968 | if ( !mListView->currentItem() ){ | 960 | if ( !mListView->currentItem() ){ |
969 | updateView(); | 961 | updateView(); |
970 | } | 962 | } |
971 | } | 963 | } |
972 | 964 | ||
973 | void KOListView::addTodos(QPtrList<Todo> eventList) | 965 | void KOListView::addTodos(QPtrList<Todo> eventList) |
974 | { | 966 | { |
975 | Todo *ev; | 967 | Todo *ev; |
976 | for(ev = eventList.first(); ev; ev = eventList.next()) { | 968 | for(ev = eventList.first(); ev; ev = eventList.next()) { |
977 | addIncidence(ev); | 969 | addIncidence(ev); |
978 | } | 970 | } |
979 | if ( !mListView->currentItem() ){ | 971 | if ( !mListView->currentItem() ){ |
980 | updateView(); | 972 | updateView(); |
981 | } | 973 | } |
982 | } | 974 | } |
983 | void KOListView::addJournals(QPtrList<Journal> eventList) | 975 | void KOListView::addJournals(QPtrList<Journal> eventList) |
984 | { | 976 | { |
985 | Journal *ev; | 977 | Journal *ev; |
986 | for(ev = eventList.first(); ev; ev = eventList.next()) { | 978 | for(ev = eventList.first(); ev; ev = eventList.next()) { |
987 | addIncidence(ev); | 979 | addIncidence(ev); |
988 | } | 980 | } |
989 | if ( !mListView->currentItem() ){ | 981 | if ( !mListView->currentItem() ){ |
990 | updateView(); | 982 | updateView(); |
991 | } | 983 | } |
992 | } | 984 | } |
993 | 985 | ||
994 | void KOListView::addIncidence(Incidence *incidence) | 986 | void KOListView::addIncidence(Incidence *incidence) |
995 | { | 987 | { |
996 | if ( mUidDict.find( incidence->uid() ) ) return; | 988 | if ( mUidDict.find( incidence->uid() ) ) return; |
997 | 989 | ||
998 | // mListView->setFont ( KOPrefs::instance()->mListViewFont ); | 990 | // mListView->setFont ( KOPrefs::instance()->mListViewFont ); |
999 | mUidDict.insert( incidence->uid(), incidence ); | 991 | mUidDict.insert( incidence->uid(), incidence ); |
1000 | KOListViewItem *item = new KOListViewItem( incidence, mListView ); | 992 | KOListViewItem *item = new KOListViewItem( incidence, mListView ); |
1001 | ListItemVisitor v(item, mStartDate ); | 993 | ListItemVisitor v(item, mStartDate ); |
1002 | if (incidence->accept(v)) { | 994 | if (incidence->accept(v)) { |
1003 | return; | 995 | return; |
1004 | } | 996 | } |
1005 | else delete item; | 997 | else delete item; |
1006 | } | 998 | } |
1007 | 999 | ||
1008 | void KOListView::showEvents(QPtrList<Event> eventList) | 1000 | void KOListView::showEvents(QPtrList<Event> eventList) |
1009 | { | 1001 | { |
1010 | clear(); | 1002 | clear(); |
1011 | 1003 | ||
1012 | addEvents(eventList); | 1004 | addEvents(eventList); |
1013 | 1005 | ||
1014 | // After new creation of list view no events are selected. | 1006 | // After new creation of list view no events are selected. |
1015 | emit incidenceSelected( 0 ); | 1007 | emit incidenceSelected( 0 ); |
1016 | } | 1008 | } |
1017 | int KOListView::count() | 1009 | int KOListView::count() |
1018 | { | 1010 | { |
1019 | return mListView->childCount(); | 1011 | return mListView->childCount(); |
1020 | } | 1012 | } |
1021 | 1013 | ||
1022 | void KOListView::changeEventDisplay(Event *event, int action) | 1014 | void KOListView::changeEventDisplay(Event *event, int action) |
1023 | { | 1015 | { |
1024 | KOListViewItem *item; | 1016 | KOListViewItem *item; |
1025 | 1017 | ||
1026 | switch(action) { | 1018 | switch(action) { |
1027 | case KOGlobals::EVENTADDED: | 1019 | case KOGlobals::EVENTADDED: |
1028 | addIncidence( event ); | 1020 | addIncidence( event ); |
1029 | break; | 1021 | break; |
1030 | case KOGlobals::EVENTEDITED: | 1022 | case KOGlobals::EVENTEDITED: |
1031 | item = getItemForEvent(event); | 1023 | item = getItemForEvent(event); |
1032 | if (item) { | 1024 | if (item) { |
1033 | mUidDict.remove( event->uid() ); | 1025 | mUidDict.remove( event->uid() ); |
1034 | delete item; | 1026 | delete item; |
1035 | addIncidence( event ); | 1027 | addIncidence( event ); |
1036 | } | 1028 | } |
1037 | break; | 1029 | break; |
1038 | case KOGlobals::EVENTDELETED: | 1030 | case KOGlobals::EVENTDELETED: |
1039 | item = getItemForEvent(event); | 1031 | item = getItemForEvent(event); |
1040 | if (item) { | 1032 | if (item) { |
1041 | mUidDict.remove( event->uid() ); | 1033 | mUidDict.remove( event->uid() ); |
1042 | delete item; | 1034 | delete item; |
1043 | } | 1035 | } |
1044 | break; | 1036 | break; |
1045 | default: | 1037 | default: |
1046 | ; | 1038 | ; |
1047 | } | 1039 | } |
1048 | } | 1040 | } |
1049 | 1041 | ||
1050 | KOListViewItem *KOListView::getItemForEvent(Event *event) | 1042 | KOListViewItem *KOListView::getItemForEvent(Event *event) |
1051 | { | 1043 | { |
1052 | KOListViewItem *item = (KOListViewItem *)mListView->firstChild(); | 1044 | KOListViewItem *item = (KOListViewItem *)mListView->firstChild(); |
1053 | while (item) { | 1045 | while (item) { |
1054 | if (item->data() == event) return item; | 1046 | if (item->data() == event) return item; |
1055 | item = (KOListViewItem *)item->nextSibling(); | 1047 | item = (KOListViewItem *)item->nextSibling(); |
1056 | } | 1048 | } |
1057 | return 0; | 1049 | return 0; |
1058 | } | 1050 | } |
1059 | 1051 | ||
1060 | void KOListView::defaultItemAction(QListViewItem *i) | 1052 | void KOListView::defaultItemAction(QListViewItem *i) |
1061 | { | 1053 | { |
1062 | KOListViewItem *item = static_cast<KOListViewItem *>( i ); | 1054 | KOListViewItem *item = static_cast<KOListViewItem *>( i ); |
1063 | if ( item ) defaultAction( item->data() ); | 1055 | if ( item ) defaultAction( item->data() ); |
1064 | 1056 | ||
1065 | } | 1057 | } |
1066 | 1058 | ||
1067 | void KOListView::popupMenu(QListViewItem *item,const QPoint &,int) | 1059 | void KOListView::popupMenu(QListViewItem *item,const QPoint &,int) |
1068 | { | 1060 | { |
1069 | mActiveItem = (KOListViewItem *)item; | 1061 | mActiveItem = (KOListViewItem *)item; |
1070 | if (mActiveItem) { | 1062 | if (mActiveItem) { |
1071 | Incidence *incidence = mActiveItem->data(); | 1063 | Incidence *incidence = mActiveItem->data(); |
1072 | mPopupMenu->enableDefault( !mListView->hasMultiSelection( item ) ); | 1064 | mPopupMenu->enableDefault( !mListView->hasMultiSelection( item ) ); |
1073 | mPopupMenu->showIncidencePopup(incidence); | 1065 | mPopupMenu->showIncidencePopup(incidence); |
1074 | 1066 | ||
1075 | /* | 1067 | /* |
1076 | if ( incidence && incidence->type() == "Event" ) { | 1068 | if ( incidence && incidence->type() == "Event" ) { |
1077 | Event *event = static_cast<Event *>( incidence ); | 1069 | Event *event = static_cast<Event *>( incidence ); |
1078 | mPopupMenu->showEventPopup(event); | 1070 | mPopupMenu->showEventPopup(event); |
1079 | } | 1071 | } |
1080 | */ | 1072 | */ |
1081 | } | 1073 | } |
1082 | } | 1074 | } |
1083 | 1075 | ||
1084 | void KOListView::readSettings(KConfig *config, QString setting) | 1076 | void KOListView::readSettings(KConfig *config, QString setting) |
1085 | { | 1077 | { |
1086 | // qDebug("KOListView::readSettings "); | 1078 | // qDebug("KOListView::readSettings "); |
1087 | mListView->restoreLayout(config,setting); | 1079 | mListView->restoreLayout(config,setting); |
1088 | } | 1080 | } |
1089 | 1081 | ||
1090 | void KOListView::writeSettings(KConfig *config, QString setting) | 1082 | void KOListView::writeSettings(KConfig *config, QString setting) |
1091 | { | 1083 | { |
1092 | // qDebug("KOListView::writeSettings "); | 1084 | // qDebug("KOListView::writeSettings "); |
1093 | mListView->saveLayout(config, setting); | 1085 | mListView->saveLayout(config, setting); |
1094 | } | 1086 | } |
1095 | 1087 | ||
1096 | void KOListView::processSelectionChange(QListViewItem *) | 1088 | void KOListView::processSelectionChange(QListViewItem *) |
1097 | { | 1089 | { |
1098 | 1090 | ||
1099 | KOListViewItem *item = | 1091 | KOListViewItem *item = |
1100 | static_cast<KOListViewItem *>( mListView->currentItem() ); | 1092 | static_cast<KOListViewItem *>( mListView->currentItem() ); |
1101 | 1093 | ||
1102 | if ( !item ) { | 1094 | if ( !item ) { |
1103 | emit incidenceSelected( 0 ); | 1095 | emit incidenceSelected( 0 ); |
1104 | } else { | 1096 | } else { |
1105 | emit incidenceSelected( item->data() ); | 1097 | emit incidenceSelected( item->data() ); |
1106 | } | 1098 | } |
1107 | } | 1099 | } |
1108 | 1100 | ||
1109 | void KOListView::clearSelection() | 1101 | void KOListView::clearSelection() |
1110 | { | 1102 | { |
1111 | mListView->selectAll( false ); | 1103 | mListView->selectAll( false ); |
1112 | } | 1104 | } |
1113 | void KOListView::allSelection() | 1105 | void KOListView::allSelection() |
1114 | { | 1106 | { |
1115 | mListView->selectAll( true ); | 1107 | mListView->selectAll( true ); |
1116 | } | 1108 | } |
1117 | 1109 | ||
1118 | void KOListView::clear() | 1110 | void KOListView::clear() |
1119 | { | 1111 | { |
1120 | mListView->clear(); | 1112 | mListView->clear(); |
1121 | mUidDict.clear(); | 1113 | mUidDict.clear(); |
1122 | } | 1114 | } |
1123 | 1115 | ||
1124 | Incidence* KOListView::currentItem() | 1116 | Incidence* KOListView::currentItem() |
1125 | { | 1117 | { |
1126 | if ( mListView->currentItem() ) | 1118 | if ( mListView->currentItem() ) |
1127 | return ((KOListViewItem*) mListView->currentItem())->data(); | 1119 | return ((KOListViewItem*) mListView->currentItem())->data(); |
1128 | return 0; | 1120 | return 0; |
1129 | } | 1121 | } |
1130 | void KOListView::keyPressEvent ( QKeyEvent *e) | 1122 | void KOListView::keyPressEvent ( QKeyEvent *e) |
1131 | { | 1123 | { |
1132 | 1124 | ||
1133 | if ( e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace ) { | 1125 | if ( e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace ) { |
1134 | deleteAll(); | 1126 | deleteAll(); |
1135 | return; | 1127 | return; |
1136 | } | 1128 | } |
1137 | 1129 | ||
1138 | e->ignore(); | 1130 | e->ignore(); |
1139 | } | 1131 | } |
1140 | void KOListViewListView::keyPressEvent ( QKeyEvent *e) | 1132 | void KOListViewListView::keyPressEvent ( QKeyEvent *e) |
1141 | { | 1133 | { |
1142 | 1134 | ||
1143 | switch ( e->key() ) { | 1135 | switch ( e->key() ) { |
1144 | case Qt::Key_Down: | 1136 | case Qt::Key_Down: |
1145 | if ( e->state() == ShiftButton ) { | 1137 | if ( e->state() == ShiftButton ) { |
1146 | QListViewItem* cn = currentItem(); | 1138 | QListViewItem* cn = currentItem(); |
1147 | if ( !cn ) | 1139 | if ( !cn ) |
1148 | cn = firstChild(); | 1140 | cn = firstChild(); |
1149 | if ( !cn ) | 1141 | if ( !cn ) |
1150 | return; | 1142 | return; |
1151 | while ( cn->nextSibling() ) | 1143 | while ( cn->nextSibling() ) |
1152 | cn = cn->nextSibling(); | 1144 | cn = cn->nextSibling(); |
1153 | setCurrentItem ( cn ); | 1145 | setCurrentItem ( cn ); |
1154 | ensureItemVisible ( cn ); | 1146 | ensureItemVisible ( cn ); |
1155 | 1147 | ||
1156 | e->accept(); | 1148 | e->accept(); |
1157 | return; | 1149 | return; |
1158 | } | 1150 | } |
1159 | if ( e->state() == ControlButton ) { | 1151 | if ( e->state() == ControlButton ) { |
1160 | int count = childCount (); | 1152 | int count = childCount (); |
1161 | int jump = count / 5; | 1153 | int jump = count / 5; |
1162 | QListViewItem* cn; | 1154 | QListViewItem* cn; |
1163 | cn = currentItem(); | 1155 | cn = currentItem(); |
1164 | if ( ! cn ) | 1156 | if ( ! cn ) |
1165 | return; | 1157 | return; |
1166 | if ( jump == 0 ) | 1158 | if ( jump == 0 ) |
1167 | jump = 1; | 1159 | jump = 1; |
1168 | while ( jump && cn->nextSibling() ) { | 1160 | while ( jump && cn->nextSibling() ) { |
1169 | cn = cn->nextSibling(); | 1161 | cn = cn->nextSibling(); |
1170 | --jump; | 1162 | --jump; |
1171 | } | 1163 | } |
1172 | setCurrentItem ( cn ); | 1164 | setCurrentItem ( cn ); |
1173 | ensureItemVisible ( cn ); | 1165 | ensureItemVisible ( cn ); |
1174 | 1166 | ||
1175 | } else | 1167 | } else |
1176 | QListView::keyPressEvent ( e ) ; | 1168 | QListView::keyPressEvent ( e ) ; |
1177 | e->accept(); | 1169 | e->accept(); |
1178 | break; | 1170 | break; |
1179 | 1171 | ||
1180 | case Qt::Key_Up: | 1172 | case Qt::Key_Up: |
1181 | if ( e->state() == ShiftButton ) { | 1173 | if ( e->state() == ShiftButton ) { |
1182 | QListViewItem* cn = firstChild(); | 1174 | QListViewItem* cn = firstChild(); |
1183 | if ( cn ) { | 1175 | if ( cn ) { |
1184 | setCurrentItem ( cn ); | 1176 | setCurrentItem ( cn ); |
1185 | ensureItemVisible ( cn ); | 1177 | ensureItemVisible ( cn ); |
1186 | } | 1178 | } |
1187 | e->accept(); | 1179 | e->accept(); |
1188 | return; | 1180 | return; |
1189 | } | 1181 | } |
1190 | if ( e->state() == ControlButton ) { | 1182 | if ( e->state() == ControlButton ) { |
1191 | int count = childCount (); | 1183 | int count = childCount (); |
1192 | int jump = count / 5; | 1184 | int jump = count / 5; |
1193 | QListViewItem* cn; | 1185 | QListViewItem* cn; |
1194 | cn = currentItem(); | 1186 | cn = currentItem(); |
1195 | if ( ! cn ) | 1187 | if ( ! cn ) |
1196 | return; | 1188 | return; |
1197 | if ( jump == 0 ) | 1189 | if ( jump == 0 ) |
1198 | jump = 1; | 1190 | jump = 1; |
1199 | while ( jump && cn->itemAbove ()) { | 1191 | while ( jump && cn->itemAbove ()) { |
1200 | cn = cn->itemAbove (); | 1192 | cn = cn->itemAbove (); |
1201 | --jump; | 1193 | --jump; |
1202 | } | 1194 | } |
1203 | setCurrentItem ( cn ); | 1195 | setCurrentItem ( cn ); |
1204 | ensureItemVisible ( cn ); | 1196 | ensureItemVisible ( cn ); |
1205 | } else | 1197 | } else |
1206 | QListView::keyPressEvent ( e ) ; | 1198 | QListView::keyPressEvent ( e ) ; |
1207 | e->accept(); | 1199 | e->accept(); |
1208 | break; | 1200 | break; |
1209 | case Qt::Key_I: { | 1201 | case Qt::Key_I: { |
1210 | QListViewItem* cn; | 1202 | QListViewItem* cn; |
1211 | cn = currentItem(); | 1203 | cn = currentItem(); |
1212 | if ( cn ) { | 1204 | if ( cn ) { |
1213 | KOListViewItem* ci = (KOListViewItem*)( cn ); | 1205 | KOListViewItem* ci = (KOListViewItem*)( cn ); |
1214 | if ( ci ){ | 1206 | if ( ci ){ |
1215 | //emit showIncidence( ci->data()); | 1207 | //emit showIncidence( ci->data()); |
1216 | cn = cn->nextSibling(); | 1208 | cn = cn->nextSibling(); |
1217 | if ( cn ) { | 1209 | if ( cn ) { |
1218 | setCurrentItem ( cn ); | 1210 | setCurrentItem ( cn ); |
1219 | ensureItemVisible ( cn ); | 1211 | ensureItemVisible ( cn ); |
1220 | } | 1212 | } |
1221 | emit showIncidence( ci->data()); | 1213 | emit showIncidence( ci->data()); |
1222 | } | 1214 | } |
1223 | } | 1215 | } |
1224 | e->accept(); | 1216 | e->accept(); |
1225 | } | 1217 | } |
1226 | break; | 1218 | break; |
1227 | case Qt::Key_Return: | 1219 | case Qt::Key_Return: |
1228 | case Qt::Key_Enter: | 1220 | case Qt::Key_Enter: |
1229 | { | 1221 | { |
1230 | QListViewItem* cn; | 1222 | QListViewItem* cn; |
1231 | cn = currentItem(); | 1223 | cn = currentItem(); |
1232 | if ( cn ) { | 1224 | if ( cn ) { |
1233 | KOListViewItem* ci = (KOListViewItem*)( cn ); | 1225 | KOListViewItem* ci = (KOListViewItem*)( cn ); |
1234 | if ( ci ){ | 1226 | if ( ci ){ |
1235 | if ( e->state() == ShiftButton ) | 1227 | if ( e->state() == ShiftButton ) |
1236 | ci->setSelected( false ); | 1228 | ci->setSelected( false ); |
1237 | else | 1229 | else |
1238 | ci->setSelected( true ); | 1230 | ci->setSelected( true ); |
1239 | cn = cn->nextSibling(); | 1231 | cn = cn->nextSibling(); |
1240 | if ( cn ) { | 1232 | if ( cn ) { |
1241 | setCurrentItem ( cn ); | 1233 | setCurrentItem ( cn ); |
1242 | ensureItemVisible ( cn ); | 1234 | ensureItemVisible ( cn ); |
1243 | } | 1235 | } |
1244 | } | 1236 | } |
1245 | } | 1237 | } |
1246 | e->accept(); | 1238 | e->accept(); |
1247 | } | 1239 | } |
1248 | break; | 1240 | break; |
1249 | default: | 1241 | default: |
1250 | e->ignore(); | 1242 | e->ignore(); |
1251 | } | 1243 | } |
1252 | } | 1244 | } |
1253 | KOListViewListView::KOListViewListView(KOListView * lv ) | 1245 | KOListViewListView::KOListViewListView(KOListView * lv ) |
1254 | : KListView( lv, "kolistlistview", false ) | 1246 | : KListView( lv, "kolistlistview", false ) |
1255 | { | 1247 | { |
1256 | mYMousePos = 0; | 1248 | mYMousePos = 0; |
1257 | mPopupTimer = new QTimer(this); | 1249 | mPopupTimer = new QTimer(this); |
1258 | connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); | 1250 | connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); |
1259 | #ifndef DESKTOP_VERSION | 1251 | #ifndef DESKTOP_VERSION |
1260 | //QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); | 1252 | //QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); |
1261 | #endif | 1253 | #endif |
1262 | setSelectionMode( QListView::Multi ); | 1254 | setSelectionMode( QListView::Multi ); |
1263 | setMultiSelection( true); | 1255 | setMultiSelection( true); |
1264 | } | 1256 | } |
1265 | bool KOListViewListView::hasMultiSelection(QListViewItem* item) | 1257 | bool KOListViewListView::hasMultiSelection(QListViewItem* item) |
1266 | { | 1258 | { |
1267 | int selCount = 0; | 1259 | int selCount = 0; |
1268 | QListViewItem *qitem = firstChild (); | 1260 | QListViewItem *qitem = firstChild (); |
1269 | while ( qitem ) { | 1261 | while ( qitem ) { |
1270 | if ( qitem->isSelected() && item != qitem ) | 1262 | if ( qitem->isSelected() && item != qitem ) |
1271 | return true; | 1263 | return true; |
1272 | qitem = qitem->nextSibling(); | 1264 | qitem = qitem->nextSibling(); |
1273 | } | 1265 | } |
1274 | return false; | 1266 | return false; |
1275 | } | 1267 | } |
1276 | void KOListViewListView::contentsMouseDoubleClickEvent(QMouseEvent *e) | 1268 | void KOListViewListView::contentsMouseDoubleClickEvent(QMouseEvent *e) |
1277 | { | 1269 | { |
1278 | if (!e) return; | 1270 | if (!e) return; |
1279 | QPoint vp = contentsToViewport(e->pos()); | 1271 | QPoint vp = contentsToViewport(e->pos()); |
1280 | QListViewItem *item = itemAt(vp); | 1272 | QListViewItem *item = itemAt(vp); |
1281 | if (!item) { | 1273 | if (!item) { |
1282 | emit newEvent(); | 1274 | emit newEvent(); |
1283 | return; | 1275 | return; |
1284 | } | 1276 | } |
1285 | KListView::contentsMouseDoubleClickEvent(e); | 1277 | KListView::contentsMouseDoubleClickEvent(e); |
1286 | } | 1278 | } |
1287 | #if 0 | 1279 | #if 0 |
1288 | void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) | 1280 | void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) |
1289 | { | 1281 | { |
1290 | //qDebug("contentsMousePressEvent++++ "); | 1282 | //qDebug("contentsMousePressEvent++++ "); |
1291 | KListView::contentsMousePressEvent( e ); | 1283 | KListView::contentsMousePressEvent( e ); |
1292 | if ( e->button() == RightButton ) { | 1284 | if ( e->button() == RightButton ) { |
1293 | QListViewItem* ci = currentItem(); | 1285 | QListViewItem* ci = currentItem(); |
1294 | clearSelection () ; | 1286 | clearSelection () ; |
1295 | if ( ci ) | 1287 | if ( ci ) |
1296 | ci->setSelected( true ); | 1288 | ci->setSelected( true ); |
1297 | } | 1289 | } |
1298 | } | 1290 | } |
1299 | void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) | 1291 | void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) |
1300 | { | 1292 | { |
1301 | KListView::contentsMouseReleaseEvent(e); | 1293 | KListView::contentsMouseReleaseEvent(e); |
1302 | } | 1294 | } |
1303 | void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) | 1295 | void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) |
1304 | { | 1296 | { |
1305 | KListView::contentsMouseMoveEvent(e); | 1297 | KListView::contentsMouseMoveEvent(e); |
1306 | } | 1298 | } |
1307 | #endif | 1299 | #endif |
1308 | void KOListViewListView::popupMenu() | 1300 | void KOListViewListView::popupMenu() |
1309 | { | 1301 | { |
1310 | mPopupTimer->stop(); | 1302 | mPopupTimer->stop(); |
1311 | QMouseEvent* e = new QMouseEvent( QEvent::MouseButtonPress, mEventPos ,mEventGlobalPos, RightButton , RightButton ); | 1303 | QMouseEvent* e = new QMouseEvent( QEvent::MouseButtonPress, mEventPos ,mEventGlobalPos, RightButton , RightButton ); |
1312 | QApplication::postEvent( this->viewport(), e ); | 1304 | QApplication::postEvent( this->viewport(), e ); |
1313 | 1305 | ||
1314 | } | 1306 | } |
1315 | void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) | 1307 | void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) |
1316 | { | 1308 | { |
1317 | //qDebug("contentsMousePressEvent++++ %d %d", e->pos().y(), e->globalPos().y()); | 1309 | //qDebug("contentsMousePressEvent++++ %d %d", e->pos().y(), e->globalPos().y()); |
1318 | mYMousePos = mapToGlobal( (e->pos())).y(); | 1310 | mYMousePos = mapToGlobal( (e->pos())).y(); |
1319 | if ( e->button() == LeftButton ) { | 1311 | if ( e->button() == LeftButton ) { |
1320 | mPopupTimer->start( 600 ); | 1312 | mPopupTimer->start( 600 ); |
1321 | mEventPos = contentsToViewport(e->pos()); | 1313 | mEventPos = contentsToViewport(e->pos()); |
1322 | mEventGlobalPos = e->globalPos(); | 1314 | mEventGlobalPos = e->globalPos(); |
1323 | } | 1315 | } |
1324 | KListView::contentsMousePressEvent( e ); | 1316 | KListView::contentsMousePressEvent( e ); |
1325 | if ( e->button() == RightButton ) { | 1317 | if ( e->button() == RightButton ) { |
1326 | QListViewItem* ci = currentItem(); | 1318 | QListViewItem* ci = currentItem(); |
1327 | //clearSelection(); | 1319 | //clearSelection(); |
1328 | if ( ci ) | 1320 | if ( ci ) |
1329 | ci->setSelected( true ); | 1321 | ci->setSelected( true ); |
1330 | } | 1322 | } |
1331 | } | 1323 | } |
1332 | void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) | 1324 | void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) |
1333 | { | 1325 | { |
1334 | mPopupTimer->stop(); | 1326 | mPopupTimer->stop(); |
1335 | KListView::contentsMouseReleaseEvent(e); | 1327 | KListView::contentsMouseReleaseEvent(e); |
1336 | } | 1328 | } |
1337 | void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) | 1329 | void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) |
1338 | { | 1330 | { |
1339 | // qDebug("contentsMouseMoveEv....... "); | 1331 | // qDebug("contentsMouseMoveEv....... "); |
1340 | // qDebug("start: %d current %d ",mYMousePos , mapToGlobal( (e->pos())).y() ); | 1332 | // qDebug("start: %d current %d ",mYMousePos , mapToGlobal( (e->pos())).y() ); |
1341 | int diff = mYMousePos - mapToGlobal( (e->pos())).y(); | 1333 | int diff = mYMousePos - mapToGlobal( (e->pos())).y(); |
1342 | if ( diff < 0 ) diff = -diff; | 1334 | if ( diff < 0 ) diff = -diff; |
1343 | if ( diff > 15 ) | 1335 | if ( diff > 15 ) |
1344 | mPopupTimer->stop(); | 1336 | mPopupTimer->stop(); |
1345 | else { | 1337 | else { |
1346 | mEventPos = contentsToViewport(e->pos()); | 1338 | mEventPos = contentsToViewport(e->pos()); |
1347 | mEventGlobalPos = e->globalPos(); | 1339 | mEventGlobalPos = e->globalPos(); |
1348 | } | 1340 | } |
1349 | KListView::contentsMouseMoveEvent(e); | 1341 | KListView::contentsMouseMoveEvent(e); |
1350 | } | 1342 | } |
1351 | 1343 | ||
1352 | #define protected public | 1344 | #define protected public |
1353 | #include <qheader.h> | 1345 | #include <qheader.h> |
1354 | #undef protected | 1346 | #undef protected |
1355 | void KOListViewListView::printList() | 1347 | void KOListViewListView::printList() |
1356 | { | 1348 | { |
1357 | #ifdef DESKTOP_VERSION | 1349 | #ifdef DESKTOP_VERSION |
1358 | KOPrintPrefs pp ( this ); | 1350 | KOPrintPrefs pp ( this ); |
1359 | if (!pp.exec() ) | 1351 | if (!pp.exec() ) |
1360 | return; | 1352 | return; |
1361 | int scaleval = pp.printMode() ; | 1353 | int scaleval = pp.printMode() ; |
1362 | 1354 | ||
1363 | QPrinter printer; | 1355 | QPrinter printer; |
1364 | if (!printer.setup() ) | 1356 | if (!printer.setup() ) |
1365 | return; | 1357 | return; |
1366 | clearSelection (); | 1358 | clearSelection (); |
1367 | QPainter p; | 1359 | QPainter p; |
1368 | p.begin ( &printer ); | 1360 | p.begin ( &printer ); |
1369 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); | 1361 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); |
1370 | float dx, dy; | 1362 | float dx, dy; |
1371 | int wid = (m.width() * 9)/10; | 1363 | int wid = (m.width() * 9)/10; |
1372 | dx = (float) wid/(float)contentsWidth (); | 1364 | dx = (float) wid/(float)contentsWidth (); |
1373 | dy = (float)(m.height()) / (float)contentsHeight (); | 1365 | dy = (float)(m.height()) / (float)contentsHeight (); |
1374 | float scale; | 1366 | float scale; |
1375 | // scale to fit the width or height of the paper | 1367 | // scale to fit the width or height of the paper |
1376 | if ( dx < dy ) | 1368 | if ( dx < dy ) |
1377 | scale = dx; | 1369 | scale = dx; |
1378 | else | 1370 | else |
1379 | scale = dy; | 1371 | scale = dy; |
1380 | 1372 | ||
1381 | p.translate( m.width()/10,m.width()/10 ); | 1373 | p.translate( m.width()/10,m.width()/10 ); |
1382 | if ( scaleval == 2 || scaleval == 1 && scale < 1.0 ) { | 1374 | if ( scaleval == 2 || scaleval == 1 && scale < 1.0 ) { |
1383 | p.scale( scale, scale ); | 1375 | p.scale( scale, scale ); |
1384 | } | 1376 | } |
1385 | 1377 | ||
1386 | int cou = header()->count(); | 1378 | int cou = header()->count(); |
1387 | int iii; | 1379 | int iii; |
1388 | QRect rect ( 0,0,0, header()->height()); | 1380 | QRect rect ( 0,0,0, header()->height()); |
1389 | for ( iii = 0; iii < cou; ++iii ) { | 1381 | for ( iii = 0; iii < cou; ++iii ) { |
1390 | rect.setLeft ( header()->sectionPos( iii ) ); | 1382 | rect.setLeft ( header()->sectionPos( iii ) ); |
1391 | rect.setRight ( header()->sectionPos( iii ) + header()->sectionSize (iii)); | 1383 | rect.setRight ( header()->sectionPos( iii ) + header()->sectionSize (iii)); |
1392 | header()->paintSection ( & p, header()->mapToIndex (iii), rect ); | 1384 | header()->paintSection ( & p, header()->mapToIndex (iii), rect ); |
1393 | } | 1385 | } |
1394 | p.translate( 0, header()->height()); | 1386 | p.translate( 0, header()->height()); |
1395 | drawContentsOffset ( &p, 0,0, 0,0, contentsWidth (), contentsHeight () ); | 1387 | drawContentsOffset ( &p, 0,0, 0,0, contentsWidth (), contentsHeight () ); |
1396 | p.end(); | 1388 | p.end(); |
1397 | #endif | 1389 | #endif |
1398 | } | 1390 | } |
diff --git a/korganizer/kolistview.h b/korganizer/kolistview.h index c25592d..9da5497 100644 --- a/korganizer/kolistview.h +++ b/korganizer/kolistview.h | |||
@@ -1,317 +1,318 @@ | |||
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 | #ifndef _KOLISTVIEW_H | 24 | #ifndef _KOLISTVIEW_H |
25 | #define _KOLISTVIEW_H | 25 | #define _KOLISTVIEW_H |
26 | 26 | ||
27 | #include <qlistview.h> | 27 | #include <qlistview.h> |
28 | #include <qmap.h> | 28 | #include <qmap.h> |
29 | #include <qdict.h> | 29 | #include <qdict.h> |
30 | 30 | ||
31 | #include <klistview.h> | 31 | #include <klistview.h> |
32 | 32 | ||
33 | #ifndef DESKTOP_VERSION | 33 | #ifndef DESKTOP_VERSION |
34 | #include <qtopia/ir.h> | 34 | #include <qtopia/ir.h> |
35 | #else | 35 | #else |
36 | #define Ir char | 36 | #define Ir char |
37 | #endif | 37 | #endif |
38 | #include <libkcal/incidence.h> | 38 | #include <libkcal/incidence.h> |
39 | 39 | ||
40 | #include "koeventview.h" | 40 | #include "koeventview.h" |
41 | #include "customlistviewitem.h" | 41 | #include "customlistviewitem.h" |
42 | 42 | ||
43 | using namespace KCal; | 43 | using namespace KCal; |
44 | 44 | ||
45 | class KOListViewWhatsThis; | 45 | class KOListViewWhatsThis; |
46 | 46 | ||
47 | #include <qpushbutton.h> | 47 | #include <qpushbutton.h> |
48 | #include <qlayout.h> | 48 | #include <qlayout.h> |
49 | #include <qdialog.h> | 49 | #include <qdialog.h> |
50 | #include <qtimer.h> | 50 | #include <qtimer.h> |
51 | #include <qcombobox.h> | 51 | #include <qcombobox.h> |
52 | #include <qspinbox.h> | 52 | #include <qspinbox.h> |
53 | #include <qtooltip.h> | 53 | #include <qtooltip.h> |
54 | #include <qcheckbox.h> | 54 | #include <qcheckbox.h> |
55 | #include <qhbox.h> | 55 | #include <qhbox.h> |
56 | #include <qlabel.h> | 56 | #include <qlabel.h> |
57 | #include <kiconloader.h> | 57 | #include <kiconloader.h> |
58 | #include "kfiledialog.h" | 58 | #include "kfiledialog.h" |
59 | #include "koprefs.h" | 59 | #include "koprefs.h" |
60 | class KOAlarmPrefs : public QDialog | 60 | class KOAlarmPrefs : public QDialog |
61 | { | 61 | { |
62 | Q_OBJECT | 62 | Q_OBJECT |
63 | public: | 63 | public: |
64 | KOAlarmPrefs( QWidget *par=0, const char *name=0 ) : | 64 | KOAlarmPrefs( QWidget *par=0, const char *name=0 ) : |
65 | QDialog( par, name, true ) | 65 | QDialog( par, name, true ) |
66 | { | 66 | { |
67 | setCaption( i18n("Alarm Options") ); | 67 | setCaption( i18n("Alarm Options") ); |
68 | QVBoxLayout* alarmLayout = new QVBoxLayout( this ); | 68 | QVBoxLayout* alarmLayout = new QVBoxLayout( this ); |
69 | alarmLayout->setSpacing( 3 ); | 69 | alarmLayout->setSpacing( 3 ); |
70 | alarmLayout->setMargin( 3 ); | 70 | alarmLayout->setMargin( 3 ); |
71 | QWidget *parent = this; | 71 | QWidget *parent = this; |
72 | mAlarmButton = new QCheckBox(i18n("Set reminder ON with offset to:"),parent); | 72 | mAlarmButton = new QCheckBox(i18n("Set reminder ON with offset to:"),parent); |
73 | alarmLayout->addWidget(mAlarmButton); | 73 | alarmLayout->addWidget(mAlarmButton); |
74 | mAlarmTimeEdit = new QSpinBox ( 0, 9999, 1, parent, "mAlarmTimeEdit " ) ; | 74 | mAlarmTimeEdit = new QSpinBox ( 0, 9999, 1, parent, "mAlarmTimeEdit " ) ; |
75 | mAlarmTimeEdit->setValue( 15 ); | 75 | mAlarmTimeEdit->setValue( 15 ); |
76 | alarmLayout->addWidget(mAlarmTimeEdit); | 76 | alarmLayout->addWidget(mAlarmTimeEdit); |
77 | mAlarmIncrCombo = new QComboBox(false, parent); | 77 | mAlarmIncrCombo = new QComboBox(false, parent); |
78 | mAlarmIncrCombo->insertItem(i18n("minute(s)")); | 78 | mAlarmIncrCombo->insertItem(i18n("minute(s)")); |
79 | mAlarmIncrCombo->insertItem(i18n("hour(s)")); | 79 | mAlarmIncrCombo->insertItem(i18n("hour(s)")); |
80 | mAlarmIncrCombo->insertItem(i18n("day(s)")); | 80 | mAlarmIncrCombo->insertItem(i18n("day(s)")); |
81 | alarmLayout->addWidget(mAlarmIncrCombo); | 81 | alarmLayout->addWidget(mAlarmIncrCombo); |
82 | QHBox * hb = new QHBox ( parent ); | 82 | QHBox * hb = new QHBox ( parent ); |
83 | alarmLayout->addWidget(hb); | 83 | alarmLayout->addWidget(hb); |
84 | mAlarmSoundButton = new QPushButton(hb); | 84 | mAlarmSoundButton = new QPushButton(hb); |
85 | mAlarmSoundButton->setPixmap(SmallIcon("playsound")); | 85 | mAlarmSoundButton->setPixmap(SmallIcon("playsound")); |
86 | mAlarmSoundButton->setToggleButton(true); | 86 | mAlarmSoundButton->setToggleButton(true); |
87 | connect(mAlarmSoundButton, SIGNAL(clicked()), SLOT(pickAlarmSound())); | 87 | connect(mAlarmSoundButton, SIGNAL(clicked()), SLOT(pickAlarmSound())); |
88 | mAlarmProgramButton = new QPushButton(hb); | 88 | mAlarmProgramButton = new QPushButton(hb); |
89 | mAlarmProgramButton->setPixmap(SmallIcon("run")); | 89 | mAlarmProgramButton->setPixmap(SmallIcon("run")); |
90 | mAlarmProgramButton->setToggleButton(true); | 90 | mAlarmProgramButton->setToggleButton(true); |
91 | connect(mAlarmProgramButton, SIGNAL(clicked()), SLOT(pickAlarmProgram())); | 91 | connect(mAlarmProgramButton, SIGNAL(clicked()), SLOT(pickAlarmProgram())); |
92 | mAlarmSoundButton->setMaximumWidth( mAlarmSoundButton->sizeHint().width() + 4 ); | 92 | mAlarmSoundButton->setMaximumWidth( mAlarmSoundButton->sizeHint().width() + 4 ); |
93 | mAlarmProgramButton->setMaximumWidth(mAlarmProgramButton->sizeHint().width() + 4 ); | 93 | mAlarmProgramButton->setMaximumWidth(mAlarmProgramButton->sizeHint().width() + 4 ); |
94 | mAlarmLabel = new QLabel( this ); | 94 | mAlarmLabel = new QLabel( this ); |
95 | alarmLayout->addWidget( mAlarmLabel ); | 95 | alarmLayout->addWidget( mAlarmLabel ); |
96 | mAlarmLabel->setText( "..."+KOPrefs::instance()->mDefaultAlarmFile.right( 30 ) ); | 96 | mAlarmLabel->setText( "..."+KOPrefs::instance()->mDefaultAlarmFile.right( 30 ) ); |
97 | mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; | 97 | mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; |
98 | mAlarmSoundButton->setOn( true ); | 98 | mAlarmSoundButton->setOn( true ); |
99 | QPushButton * ok = new QPushButton( i18n("Set Alarm!"), this ); | 99 | QPushButton * ok = new QPushButton( i18n("Set Alarm!"), this ); |
100 | alarmLayout->addWidget( ok ); | 100 | alarmLayout->addWidget( ok ); |
101 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 101 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
102 | alarmLayout->addWidget( cancel ); | 102 | alarmLayout->addWidget( cancel ); |
103 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 103 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
104 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 104 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
105 | resize( 200, 200 ); | 105 | resize( 200, 200 ); |
106 | 106 | ||
107 | } | 107 | } |
108 | 108 | ||
109 | 109 | ||
110 | 110 | ||
111 | QString mAlarmSound, mAlarmProgram ; | 111 | QString mAlarmSound, mAlarmProgram ; |
112 | QCheckBox* mAlarmButton; | 112 | QCheckBox* mAlarmButton; |
113 | QSpinBox* mAlarmTimeEdit; | 113 | QSpinBox* mAlarmTimeEdit; |
114 | QLabel* mAlarmLabel; | 114 | QLabel* mAlarmLabel; |
115 | QComboBox* mAlarmIncrCombo ; | 115 | QComboBox* mAlarmIncrCombo ; |
116 | QPushButton* mAlarmSoundButton ,*mAlarmProgramButton; | 116 | QPushButton* mAlarmSoundButton ,*mAlarmProgramButton; |
117 | private slots: | 117 | private slots: |
118 | 118 | ||
119 | void pickAlarmSound() | 119 | void pickAlarmSound() |
120 | { | 120 | { |
121 | //QString prefix = mAlarmSound; | 121 | //QString prefix = mAlarmSound; |
122 | if (!mAlarmSoundButton->isOn()) { | 122 | if (!mAlarmSoundButton->isOn()) { |
123 | //mAlarmSound = ""; | 123 | //mAlarmSound = ""; |
124 | QToolTip::remove(mAlarmSoundButton); | 124 | QToolTip::remove(mAlarmSoundButton); |
125 | QToolTip::add(mAlarmSoundButton, i18n("No sound set")); | 125 | QToolTip::add(mAlarmSoundButton, i18n("No sound set")); |
126 | mAlarmProgramButton->setOn(true); | 126 | mAlarmProgramButton->setOn(true); |
127 | mAlarmSoundButton->setOn(false); | 127 | mAlarmSoundButton->setOn(false); |
128 | } else { | 128 | } else { |
129 | QString fileName(KFileDialog::getOpenFileName(mAlarmSound, | 129 | QString fileName(KFileDialog::getOpenFileName(mAlarmSound, |
130 | i18n("*.wav|Wav Files"), 0)); | 130 | i18n("*.wav|Wav Files"), 0)); |
131 | if (!fileName.isEmpty()) { | 131 | if (!fileName.isEmpty()) { |
132 | mAlarmSound = fileName; | 132 | mAlarmSound = fileName; |
133 | mAlarmLabel->setText( "..."+fileName.right( 30 ) ); | 133 | mAlarmLabel->setText( "..."+fileName.right( 30 ) ); |
134 | QToolTip::remove(mAlarmSoundButton); | 134 | QToolTip::remove(mAlarmSoundButton); |
135 | QString dispStr = i18n("Playing '%1'").arg(fileName); | 135 | QString dispStr = i18n("Playing '%1'").arg(fileName); |
136 | QToolTip::add(mAlarmSoundButton, dispStr); | 136 | QToolTip::add(mAlarmSoundButton, dispStr); |
137 | mAlarmProgramButton->setOn(false); | 137 | mAlarmProgramButton->setOn(false); |
138 | mAlarmSoundButton->setOn(true); | 138 | mAlarmSoundButton->setOn(true); |
139 | } else { | 139 | } else { |
140 | mAlarmProgramButton->setOn(true); | 140 | mAlarmProgramButton->setOn(true); |
141 | mAlarmSoundButton->setOn(false); | 141 | mAlarmSoundButton->setOn(false); |
142 | 142 | ||
143 | } | 143 | } |
144 | } | 144 | } |
145 | }; | 145 | }; |
146 | 146 | ||
147 | void pickAlarmProgram() | 147 | void pickAlarmProgram() |
148 | { | 148 | { |
149 | if (!mAlarmProgramButton->isOn()) { | 149 | if (!mAlarmProgramButton->isOn()) { |
150 | //mAlarmProgram = ""; | 150 | //mAlarmProgram = ""; |
151 | QToolTip::remove(mAlarmProgramButton); | 151 | QToolTip::remove(mAlarmProgramButton); |
152 | QToolTip::add(mAlarmProgramButton, i18n("No program set")); | 152 | QToolTip::add(mAlarmProgramButton, i18n("No program set")); |
153 | mAlarmProgramButton->setOn(false); | 153 | mAlarmProgramButton->setOn(false); |
154 | mAlarmSoundButton->setOn(true); | 154 | mAlarmSoundButton->setOn(true); |
155 | } else { | 155 | } else { |
156 | QString fileName(KFileDialog::getOpenFileName(mAlarmProgram,i18n("Procedure Alarm.: ") , 0)); | 156 | QString fileName(KFileDialog::getOpenFileName(mAlarmProgram,i18n("Procedure Alarm.: ") , 0)); |
157 | if (!fileName.isEmpty()) { | 157 | if (!fileName.isEmpty()) { |
158 | mAlarmProgram = fileName; | 158 | mAlarmProgram = fileName; |
159 | mAlarmLabel->setText( "..."+fileName.right( 30 ) ); | 159 | mAlarmLabel->setText( "..."+fileName.right( 30 ) ); |
160 | QToolTip::remove(mAlarmProgramButton); | 160 | QToolTip::remove(mAlarmProgramButton); |
161 | QString dispStr = i18n("Running '%1'").arg(fileName); | 161 | QString dispStr = i18n("Running '%1'").arg(fileName); |
162 | QToolTip::add(mAlarmProgramButton, dispStr); | 162 | QToolTip::add(mAlarmProgramButton, dispStr); |
163 | mAlarmSoundButton->setOn(false); | 163 | mAlarmSoundButton->setOn(false); |
164 | mAlarmProgramButton->setOn(true); | 164 | mAlarmProgramButton->setOn(true); |
165 | } else { | 165 | } else { |
166 | mAlarmProgramButton->setOn(false); | 166 | mAlarmProgramButton->setOn(false); |
167 | mAlarmSoundButton->setOn(true); | 167 | mAlarmSoundButton->setOn(true); |
168 | } | 168 | } |
169 | } | 169 | } |
170 | }; | 170 | }; |
171 | 171 | ||
172 | }; | 172 | }; |
173 | 173 | ||
174 | 174 | ||
175 | 175 | ||
176 | 176 | ||
177 | 177 | ||
178 | 178 | ||
179 | 179 | ||
180 | typedef CustomListViewItem<Incidence *> KOListViewItem; | 180 | typedef CustomListViewItem<Incidence *> KOListViewItem; |
181 | 181 | ||
182 | /** | 182 | /** |
183 | This class provides the initialisation of a KOListViewItem for calendar | 183 | This class provides the initialisation of a KOListViewItem for calendar |
184 | components using the Incidence::Visitor. | 184 | components using the Incidence::Visitor. |
185 | */ | 185 | */ |
186 | class ListItemVisitor : public Incidence::Visitor | 186 | class ListItemVisitor : public Incidence::Visitor |
187 | { | 187 | { |
188 | public: | 188 | public: |
189 | ListItemVisitor(KOListViewItem *, QDate d); | 189 | ListItemVisitor(KOListViewItem *, QDate d); |
190 | ~ListItemVisitor(); | 190 | ~ListItemVisitor(); |
191 | 191 | ||
192 | bool visit(Event *); | 192 | bool visit(Event *); |
193 | bool visit(Todo *); | 193 | bool visit(Todo *); |
194 | bool visit(Journal *); | 194 | bool visit(Journal *); |
195 | 195 | ||
196 | private: | 196 | private: |
197 | KOListViewItem *mItem; | 197 | KOListViewItem *mItem; |
198 | QDate mDate; | 198 | QDate mDate; |
199 | }; | 199 | }; |
200 | 200 | ||
201 | /** | 201 | /** |
202 | This class provides a multi-column list view of events. It can | 202 | This class provides a multi-column list view of events. It can |
203 | display events from one particular day or several days, it doesn't | 203 | display events from one particular day or several days, it doesn't |
204 | matter. To use a view that only handles one day at a time, use | 204 | matter. To use a view that only handles one day at a time, use |
205 | KODayListView. | 205 | KODayListView. |
206 | 206 | ||
207 | @short multi-column list view of various events. | 207 | @short multi-column list view of various events. |
208 | @author Preston Brown <pbrown@kde.org> | 208 | @author Preston Brown <pbrown@kde.org> |
209 | @see KOBaseView, KODayListView | 209 | @see KOBaseView, KODayListView |
210 | */ | 210 | */ |
211 | class KOListView; | 211 | class KOListView; |
212 | 212 | ||
213 | class KOListViewListView : public KListView | 213 | class KOListViewListView : public KListView |
214 | { | 214 | { |
215 | Q_OBJECT | 215 | Q_OBJECT |
216 | public: | 216 | public: |
217 | KOListViewListView(KOListView * lv ); | 217 | KOListViewListView(KOListView * lv ); |
218 | bool hasMultiSelection(QListViewItem*); | 218 | bool hasMultiSelection(QListViewItem*); |
219 | void printList(); | 219 | void printList(); |
220 | signals: | 220 | signals: |
221 | void newEvent(); | 221 | void newEvent(); |
222 | void showIncidence( Incidence* ); | 222 | void showIncidence( Incidence* ); |
223 | public slots: | 223 | public slots: |
224 | void popupMenu(); | 224 | void popupMenu(); |
225 | private: | 225 | private: |
226 | QPoint mEventPos; | 226 | QPoint mEventPos; |
227 | QPoint mEventGlobalPos; | 227 | QPoint mEventGlobalPos; |
228 | QTimer* mPopupTimer; | 228 | QTimer* mPopupTimer; |
229 | int mYMousePos; | 229 | int mYMousePos; |
230 | void keyPressEvent ( QKeyEvent * ) ; | 230 | void keyPressEvent ( QKeyEvent * ) ; |
231 | void contentsMouseDoubleClickEvent(QMouseEvent *e); | 231 | void contentsMouseDoubleClickEvent(QMouseEvent *e); |
232 | void contentsMousePressEvent(QMouseEvent *e); | 232 | void contentsMousePressEvent(QMouseEvent *e); |
233 | void contentsMouseReleaseEvent(QMouseEvent *e); | 233 | void contentsMouseReleaseEvent(QMouseEvent *e); |
234 | void contentsMouseMoveEvent(QMouseEvent *e); | 234 | void contentsMouseMoveEvent(QMouseEvent *e); |
235 | bool mMouseDown; | 235 | bool mMouseDown; |
236 | }; | 236 | }; |
237 | 237 | ||
238 | class KOListView : public KOEventView | 238 | class KOListView : public KOEventView |
239 | { | 239 | { |
240 | Q_OBJECT | 240 | Q_OBJECT |
241 | public: | 241 | public: |
242 | KOListView(Calendar *calendar, QWidget *parent = 0, | 242 | KOListView(Calendar *calendar, QWidget *parent = 0, |
243 | const char *name = 0); | 243 | const char *name = 0); |
244 | ~KOListView(); | 244 | ~KOListView(); |
245 | 245 | ||
246 | virtual int maxDatesHint(); | 246 | virtual int maxDatesHint(); |
247 | virtual int currentDateCount(); | 247 | virtual int currentDateCount(); |
248 | virtual QPtrList<Incidence> selectedIncidences(); | 248 | virtual QPtrList<Incidence> selectedIncidences(); |
249 | virtual DateList selectedDates(); | 249 | virtual DateList selectedDates(); |
250 | 250 | ||
251 | void showDates(bool show); | 251 | void showDates(bool show); |
252 | Incidence* currentItem(); | 252 | Incidence* currentItem(); |
253 | void addTodos(QPtrList<Todo> eventList); | 253 | void addTodos(QPtrList<Todo> eventList); |
254 | void addJournals(QPtrList<Journal> eventList); | 254 | void addJournals(QPtrList<Journal> eventList); |
255 | virtual void printPreview(CalPrinter *calPrinter, | 255 | virtual void printPreview(CalPrinter *calPrinter, |
256 | const QDate &, const QDate &); | 256 | const QDate &, const QDate &); |
257 | 257 | ||
258 | void readSettings(KConfig *config, QString setting = "KOListView Layout"); | 258 | void readSettings(KConfig *config, QString setting = "KOListView Layout"); |
259 | void writeSettings(KConfig *config, QString setting = "KOListView Layout"); | 259 | void writeSettings(KConfig *config, QString setting = "KOListView Layout"); |
260 | void updateList(); | 260 | void updateList(); |
261 | void clearList(); | 261 | void clearList(); |
262 | void setStartDate(const QDate &start); | 262 | void setStartDate(const QDate &start); |
263 | int count(); | 263 | int count(); |
264 | QString getWhatsThisText(QPoint p); | 264 | QString getWhatsThisText(QPoint p); |
265 | QPtrList<Incidence> KOListView::getSelectedIncidences( bool includeEvents = true, bool includeTodos = true , bool includeJournals = true, bool onlyDueTodos = false ); | ||
265 | signals: | 266 | signals: |
266 | void signalNewEvent(); | 267 | void signalNewEvent(); |
267 | void beamIncidenceList(QPtrList<Incidence>); | 268 | void beamIncidenceList(QPtrList<Incidence>); |
268 | 269 | ||
269 | public slots: | 270 | public slots: |
270 | void hideAll(); | 271 | void hideAll(); |
271 | void printList(); | 272 | void printList(); |
272 | void resetFocus(); | 273 | void resetFocus(); |
273 | virtual void updateView(); | 274 | virtual void updateView(); |
274 | virtual void showDates(const QDate &start, const QDate &end); | 275 | virtual void showDates(const QDate &start, const QDate &end); |
275 | virtual void showEvents(QPtrList<Event> eventList); | 276 | virtual void showEvents(QPtrList<Event> eventList); |
276 | void clearSelection(); | 277 | void clearSelection(); |
277 | void allSelection(); | 278 | void allSelection(); |
278 | 279 | ||
279 | void clear(); | 280 | void clear(); |
280 | void beamDone( Ir *ir ); | 281 | void beamDone( Ir *ir ); |
281 | void showDates(); | 282 | void showDates(); |
282 | void hideDates(); | 283 | void hideDates(); |
283 | void deleteAll(); | 284 | void deleteAll(); |
284 | void saveToFile(); | 285 | void saveToFile(); |
285 | void saveToFileVCS(); | 286 | void saveToFileVCS(); |
286 | void saveDescriptionToFile(); | 287 | void saveDescriptionToFile(); |
287 | void beamSelected(); | 288 | void beamSelected(); |
288 | void updateConfig(); | 289 | void updateConfig(); |
289 | void addCat(); | 290 | void addCat(); |
290 | void setCat(); | 291 | void setCat(); |
291 | void setAlarm(); | 292 | void setAlarm(); |
292 | void setCategories( bool removeOld ); | 293 | void setCategories( bool removeOld ); |
293 | void changeEventDisplay(Event *, int); | 294 | void changeEventDisplay(Event *, int); |
294 | 295 | ||
295 | void defaultItemAction(QListViewItem *item); | 296 | void defaultItemAction(QListViewItem *item); |
296 | void popupMenu(QListViewItem *item,const QPoint &,int); | 297 | void popupMenu(QListViewItem *item,const QPoint &,int); |
297 | 298 | ||
298 | protected slots: | 299 | protected slots: |
299 | void processSelectionChange(QListViewItem *); | 300 | void processSelectionChange(QListViewItem *); |
300 | 301 | ||
301 | protected: | 302 | protected: |
302 | void writeToFile( bool iCal ); | 303 | void writeToFile( bool iCal ); |
303 | void addEvents(QPtrList<Event> eventList); | 304 | void addEvents(QPtrList<Event> eventList); |
304 | void addIncidence(Incidence *); | 305 | void addIncidence(Incidence *); |
305 | KOListViewItem *getItemForEvent(Event *event); | 306 | KOListViewItem *getItemForEvent(Event *event); |
306 | 307 | ||
307 | private: | 308 | private: |
308 | KOListViewWhatsThis *mKOListViewWhatsThis; | 309 | KOListViewWhatsThis *mKOListViewWhatsThis; |
309 | KOListViewListView *mListView; | 310 | KOListViewListView *mListView; |
310 | KOEventPopupMenu *mPopupMenu; | 311 | KOEventPopupMenu *mPopupMenu; |
311 | KOListViewItem *mActiveItem; | 312 | KOListViewItem *mActiveItem; |
312 | QDict<Incidence> mUidDict; | 313 | QDict<Incidence> mUidDict; |
313 | QDate mStartDate; | 314 | QDate mStartDate; |
314 | void keyPressEvent ( QKeyEvent * ) ; | 315 | void keyPressEvent ( QKeyEvent * ) ; |
315 | }; | 316 | }; |
316 | 317 | ||
317 | #endif | 318 | #endif |