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