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