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