-rw-r--r-- | korganizer/kolistview.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp index 9a3ba73..bafd349 100644 --- a/korganizer/kolistview.cpp +++ b/korganizer/kolistview.cpp | |||
@@ -1,273 +1,279 @@ | |||
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 <qregexp.h> | ||
35 | 36 | ||
36 | #include <klocale.h> | 37 | #include <klocale.h> |
37 | #include <kdebug.h> | 38 | #include <kdebug.h> |
38 | #include <kiconloader.h> | 39 | #include <kiconloader.h> |
39 | #include <kglobal.h> | 40 | #include <kglobal.h> |
40 | 41 | ||
41 | #include <libkcal/calendar.h> | 42 | #include <libkcal/calendar.h> |
42 | #include <libkcal/calendarlocal.h> | 43 | #include <libkcal/calendarlocal.h> |
43 | #include <libkcal/icalformat.h> | 44 | #include <libkcal/icalformat.h> |
44 | #include <libkcal/vcalformat.h> | 45 | #include <libkcal/vcalformat.h> |
45 | #include <libkcal/recurrence.h> | 46 | #include <libkcal/recurrence.h> |
46 | #include <libkcal/filestorage.h> | 47 | #include <libkcal/filestorage.h> |
47 | #include <libkdepim/categoryselectdialog.h> | 48 | #include <libkdepim/categoryselectdialog.h> |
48 | #ifndef DESKTOP_VERSION | 49 | #ifndef DESKTOP_VERSION |
49 | #include <qpe/qpeapplication.h> | 50 | #include <qpe/qpeapplication.h> |
50 | #else | 51 | #else |
51 | #include <qapplication.h> | 52 | #include <qapplication.h> |
52 | #endif | 53 | #endif |
53 | 54 | ||
54 | #ifndef KORG_NOPRINTER | 55 | #ifndef KORG_NOPRINTER |
55 | #include "calprinter.h" | 56 | #include "calprinter.h" |
56 | #endif | 57 | #endif |
57 | #include "koglobals.h" | 58 | #include "koglobals.h" |
58 | #include "koprefs.h" | 59 | #include "koprefs.h" |
59 | #include "kfiledialog.h" | 60 | #include "kfiledialog.h" |
60 | 61 | ||
61 | #include "kolistview.h" | 62 | #include "kolistview.h" |
62 | 63 | ||
63 | ListItemVisitor::ListItemVisitor(KOListViewItem *item, QDate date ) | 64 | ListItemVisitor::ListItemVisitor(KOListViewItem *item, QDate date ) |
64 | { | 65 | { |
65 | mItem = item; | 66 | mItem = item; |
66 | mDate = date; | 67 | mDate = date; |
67 | } | 68 | } |
68 | 69 | ||
69 | ListItemVisitor::~ListItemVisitor() | 70 | ListItemVisitor::~ListItemVisitor() |
70 | { | 71 | { |
71 | } | 72 | } |
72 | 73 | ||
73 | bool ListItemVisitor::visit(Event *e) | 74 | bool ListItemVisitor::visit(Event *e) |
74 | { | 75 | { |
75 | 76 | ||
76 | bool ok = false; | 77 | bool ok = false; |
77 | QString start, end; | 78 | QString start, end; |
78 | if ( e->doesRecur() ) { | 79 | if ( e->doesRecur() ) { |
79 | QDate d = e->getNextOccurence( QDateTime( mDate, QTime(0,0,0)), &ok ).date(); | 80 | QDate d = e->getNextOccurence( QDateTime( mDate, QTime(0,0,0)), &ok ).date(); |
80 | if ( ok ) { | 81 | if ( ok ) { |
81 | int days = e->dtStart().date().daysTo(e->dtEnd().date() ); | 82 | int days = e->dtStart().date().daysTo(e->dtEnd().date() ); |
82 | start = KGlobal::locale()->formatDate(d,true); | 83 | start = KGlobal::locale()->formatDate(d,true); |
83 | end = KGlobal::locale()->formatDate(d.addDays( days),true); | 84 | end = KGlobal::locale()->formatDate(d.addDays( days),true); |
84 | } | 85 | } |
85 | 86 | ||
86 | } | 87 | } |
87 | if ( ! ok ) { | 88 | if ( ! ok ) { |
88 | start =e->dtStartDateStr(); | 89 | start =e->dtStartDateStr(); |
89 | end = e->dtEndDateStr(); | 90 | end = e->dtEndDateStr(); |
90 | } | 91 | } |
91 | mItem->setText(0,e->summary()); | 92 | mItem->setText(0,e->summary()); |
92 | mItem->setText(1,start); | 93 | mItem->setText(1,start); |
93 | mItem->setText(2,e->dtStartTimeStr()); | 94 | mItem->setText(2,e->dtStartTimeStr()); |
94 | mItem->setText(3,end); | 95 | mItem->setText(3,end); |
95 | mItem->setText(4,e->dtEndTimeStr()); | 96 | mItem->setText(4,e->dtEndTimeStr()); |
96 | mItem->setText(5,e->isAlarmEnabled() ? i18n("Yes") : i18n("No")); | 97 | mItem->setText(5,e->isAlarmEnabled() ? i18n("Yes") : i18n("No")); |
97 | mItem->setText(6, e->recurrence()->recurrenceText()); | 98 | mItem->setText(6, e->recurrence()->recurrenceText()); |
98 | mItem->setText(7,"---"); | 99 | mItem->setText(7,"---"); |
99 | mItem->setText(8,"---"); | 100 | mItem->setText(8,"---"); |
100 | mItem->setText(9, e->cancelled() ? i18n("Yes") : i18n("No")); | 101 | mItem->setText(9, e->cancelled() ? i18n("Yes") : i18n("No")); |
101 | mItem->setText(10,e->categoriesStr()); | 102 | mItem->setText(10,e->categoriesStr()); |
102 | 103 | ||
103 | QString key; | 104 | QString key; |
104 | QDate d = e->dtStart().date(); | 105 | QDate d = e->dtStart().date(); |
105 | QTime t = e->doesFloat() ? QTime(0,0) : e->dtStart().time(); | 106 | QTime t = e->doesFloat() ? QTime(0,0) : e->dtStart().time(); |
106 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),t.hour(),t.minute()); | 107 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),t.hour(),t.minute()); |
107 | mItem->setSortKey(1,key); | 108 | mItem->setSortKey(1,key); |
108 | 109 | ||
109 | d = e->dtEnd().date(); | 110 | d = e->dtEnd().date(); |
110 | t = e->doesFloat() ? QTime(0,0) : e->dtEnd().time(); | 111 | t = e->doesFloat() ? QTime(0,0) : e->dtEnd().time(); |
111 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),t.hour(),t.minute()); | 112 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),t.hour(),t.minute()); |
112 | mItem->setSortKey(3,key); | 113 | mItem->setSortKey(3,key); |
113 | 114 | ||
114 | return true; | 115 | return true; |
115 | } | 116 | } |
116 | 117 | ||
117 | bool ListItemVisitor::visit(Todo *t) | 118 | bool ListItemVisitor::visit(Todo *t) |
118 | { | 119 | { |
119 | mItem->setText(0,i18n("To-Do: %1").arg(t->summary())); | 120 | mItem->setText(0,i18n("To-Do: %1").arg(t->summary())); |
120 | if (t->hasStartDate()) { | 121 | if (t->hasStartDate()) { |
121 | mItem->setText(1,t->dtStartDateStr()); | 122 | mItem->setText(1,t->dtStartDateStr()); |
122 | if (t->doesFloat()) { | 123 | if (t->doesFloat()) { |
123 | mItem->setText(2,"---"); | 124 | mItem->setText(2,"---"); |
124 | } else { | 125 | } else { |
125 | mItem->setText(2,t->dtStartTimeStr()); | 126 | mItem->setText(2,t->dtStartTimeStr()); |
126 | } | 127 | } |
127 | } else { | 128 | } else { |
128 | mItem->setText(1,"---"); | 129 | mItem->setText(1,"---"); |
129 | mItem->setText(2,"---"); | 130 | mItem->setText(2,"---"); |
130 | } | 131 | } |
131 | mItem->setText(3,"---"); | 132 | mItem->setText(3,"---"); |
132 | mItem->setText(4,"---"); | 133 | mItem->setText(4,"---"); |
133 | mItem->setText(5,"---"); | 134 | mItem->setText(5,"---"); |
134 | mItem->setText(6,"---"); | 135 | mItem->setText(6,"---"); |
135 | if (t->hasDueDate()) { | 136 | if (t->hasDueDate()) { |
136 | mItem->setText(7,t->dtDueDateStr()); | 137 | mItem->setText(7,t->dtDueDateStr()); |
137 | if (t->doesFloat()) { | 138 | if (t->doesFloat()) { |
138 | mItem->setText(8,"---"); | 139 | mItem->setText(8,"---"); |
139 | } else { | 140 | } else { |
140 | mItem->setText(8,t->dtDueTimeStr()); | 141 | mItem->setText(8,t->dtDueTimeStr()); |
141 | } | 142 | } |
142 | } else { | 143 | } else { |
143 | mItem->setText(7,"---"); | 144 | mItem->setText(7,"---"); |
144 | mItem->setText(8,"---"); | 145 | mItem->setText(8,"---"); |
145 | } | 146 | } |
146 | mItem->setText(9, t->cancelled() ? i18n("Yes") : i18n("No")); | 147 | mItem->setText(9, t->cancelled() ? i18n("Yes") : i18n("No")); |
147 | mItem->setText(10,t->categoriesStr()); | 148 | mItem->setText(10,t->categoriesStr()); |
148 | 149 | ||
149 | QString key; | 150 | QString key; |
150 | QDate d; | 151 | QDate d; |
151 | if (t->hasDueDate()) { | 152 | if (t->hasDueDate()) { |
152 | d = t->dtDue().date(); | 153 | d = t->dtDue().date(); |
153 | QTime tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time(); | 154 | QTime tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time(); |
154 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); | 155 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); |
155 | mItem->setSortKey(7,key); | 156 | mItem->setSortKey(7,key); |
156 | } | 157 | } |
157 | if ( t->hasStartDate() ) { | 158 | if ( t->hasStartDate() ) { |
158 | d = t->dtStart().date(); | 159 | d = t->dtStart().date(); |
159 | QTime tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time(); | 160 | QTime tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time(); |
160 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); | 161 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); |
161 | mItem->setSortKey(1,key); | 162 | mItem->setSortKey(1,key); |
162 | } | 163 | } |
163 | return true; | 164 | return true; |
164 | } | 165 | } |
165 | 166 | ||
166 | bool ListItemVisitor::visit(Journal * j) | 167 | bool ListItemVisitor::visit(Journal * j) |
167 | { | 168 | { |
168 | mItem->setText(0,i18n("Journal")); | 169 | QString des = j->description().left(50); |
170 | des = des.simplifyWhiteSpace (); | ||
171 | des.replace (QRegExp ("\\n"),"" ); | ||
172 | des.replace (QRegExp ("\\r"),"" ); | ||
173 | mItem->setText(0,i18n("Journal")+": "+des.left(25)); | ||
169 | mItem->setText(1,j->dtStartDateStr()); | 174 | mItem->setText(1,j->dtStartDateStr()); |
170 | mItem->setText(2,"---"); | 175 | mItem->setText(2,"---"); |
171 | mItem->setText(3,"---"); | 176 | mItem->setText(3,"---"); |
172 | mItem->setText(4,"---"); | 177 | mItem->setText(4,"---"); |
173 | mItem->setText(5,"---"); | 178 | mItem->setText(5,"---"); |
174 | mItem->setText(6,"---"); | 179 | mItem->setText(6,"---"); |
175 | mItem->setText(7,j->dtStartDateStr()); | 180 | mItem->setText(7,j->dtStartDateStr()); |
176 | mItem->setText(8,"---"); | 181 | mItem->setText(8,"---"); |
177 | mItem->setText(9,"---"); | 182 | mItem->setText(9,"---"); |
183 | mItem->setText(10,i18n("Last Modified: ")+ KGlobal::locale()->formatDateTime( j->lastModified() , true) ); | ||
178 | 184 | ||
179 | QString key; | 185 | QString key; |
180 | QDate d = j->dtStart().date(); | 186 | QDate d = j->dtStart().date(); |
181 | key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); | 187 | key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); |
182 | mItem->setSortKey(1,key); | 188 | mItem->setSortKey(1,key); |
183 | mItem->setSortKey(7,key); | 189 | mItem->setSortKey(7,key); |
184 | 190 | ||
185 | return true; | 191 | return true; |
186 | } | 192 | } |
187 | 193 | ||
188 | KOListView::KOListView(Calendar *calendar, QWidget *parent, | 194 | KOListView::KOListView(Calendar *calendar, QWidget *parent, |
189 | const char *name) | 195 | const char *name) |
190 | : KOEventView(calendar, parent, name) | 196 | : KOEventView(calendar, parent, name) |
191 | { | 197 | { |
192 | mActiveItem = 0; | 198 | mActiveItem = 0; |
193 | mListView = new KOListViewListView(this); | 199 | mListView = new KOListViewListView(this); |
194 | mListView->addColumn(i18n("Summary")); | 200 | mListView->addColumn(i18n("Summary")); |
195 | mListView->addColumn(i18n("Start Date")); | 201 | mListView->addColumn(i18n("Start Date")); |
196 | mListView->addColumn(i18n("Start Time")); | 202 | mListView->addColumn(i18n("Start Time")); |
197 | mListView->addColumn(i18n("End Date")); | 203 | mListView->addColumn(i18n("End Date")); |
198 | mListView->addColumn(i18n("End Time")); | 204 | mListView->addColumn(i18n("End Time")); |
199 | mListView->addColumn(i18n("Alarm")); // alarm set? | 205 | mListView->addColumn(i18n("Alarm")); // alarm set? |
200 | mListView->addColumn(i18n("Recurs")); // recurs? | 206 | mListView->addColumn(i18n("Recurs")); // recurs? |
201 | mListView->addColumn(i18n("Due Date")); | 207 | mListView->addColumn(i18n("Due Date")); |
202 | mListView->addColumn(i18n("Due Time")); | 208 | mListView->addColumn(i18n("Due Time")); |
203 | mListView->addColumn(i18n("Cancelled")); | 209 | mListView->addColumn(i18n("Cancelled")); |
204 | mListView->addColumn(i18n("Categories")); | 210 | mListView->addColumn(i18n("Categories")); |
205 | 211 | ||
206 | mListView->setColumnAlignment(0,AlignLeft); | 212 | mListView->setColumnAlignment(0,AlignLeft); |
207 | mListView->setColumnAlignment(1,AlignLeft); | 213 | mListView->setColumnAlignment(1,AlignLeft); |
208 | mListView->setColumnAlignment(2,AlignHCenter); | 214 | mListView->setColumnAlignment(2,AlignHCenter); |
209 | mListView->setColumnAlignment(3,AlignLeft); | 215 | mListView->setColumnAlignment(3,AlignLeft); |
210 | mListView->setColumnAlignment(4,AlignHCenter); | 216 | mListView->setColumnAlignment(4,AlignHCenter); |
211 | mListView->setColumnAlignment(5,AlignLeft); | 217 | mListView->setColumnAlignment(5,AlignLeft); |
212 | mListView->setColumnAlignment(6,AlignLeft); | 218 | mListView->setColumnAlignment(6,AlignLeft); |
213 | mListView->setColumnAlignment(7,AlignLeft); | 219 | mListView->setColumnAlignment(7,AlignLeft); |
214 | mListView->setColumnAlignment(8,AlignLeft); | 220 | mListView->setColumnAlignment(8,AlignLeft); |
215 | mListView->setColumnAlignment(9,AlignLeft); | 221 | mListView->setColumnAlignment(9,AlignLeft); |
216 | mListView->setColumnAlignment(10,AlignLeft); | 222 | mListView->setColumnAlignment(10,AlignLeft); |
217 | 223 | ||
218 | int iii = 0; | 224 | int iii = 0; |
219 | for ( iii = 0; iii< 10 ; ++iii ) | 225 | for ( iii = 0; iii< 10 ; ++iii ) |
220 | mListView->setColumnWidthMode( iii, QListView::Manual ); | 226 | mListView->setColumnWidthMode( iii, QListView::Manual ); |
221 | 227 | ||
222 | QBoxLayout *layoutTop = new QVBoxLayout(this); | 228 | QBoxLayout *layoutTop = new QVBoxLayout(this); |
223 | layoutTop->addWidget(mListView); | 229 | layoutTop->addWidget(mListView); |
224 | mListView->setFont ( KOPrefs::instance()->mListViewFont ); | 230 | mListView->setFont ( KOPrefs::instance()->mListViewFont ); |
225 | mPopupMenu = eventPopup(); | 231 | mPopupMenu = eventPopup(); |
226 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 232 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
227 | i18n("Select all"),this, | 233 | i18n("Select all"),this, |
228 | SLOT(allSelection()),true); | 234 | SLOT(allSelection()),true); |
229 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 235 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
230 | i18n("Deselect All"),this, | 236 | i18n("Deselect All"),this, |
231 | SLOT(clearSelection()),true); | 237 | SLOT(clearSelection()),true); |
232 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 238 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
233 | i18n("Delete all selected"),this, | 239 | i18n("Delete all selected"),this, |
234 | SLOT(deleteAll()),true); | 240 | SLOT(deleteAll()),true); |
235 | mPopupMenu->insertSeparator(); | 241 | mPopupMenu->insertSeparator(); |
236 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 242 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
237 | i18n("Save selected to file..."),this, | 243 | i18n("Save selected to file..."),this, |
238 | SLOT(saveToFile()),true); | 244 | SLOT(saveToFile()),true); |
239 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 245 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
240 | i18n("Save Journal/Description..."),this, | 246 | i18n("Save Journal/Description..."),this, |
241 | SLOT(saveDescriptionToFile()),true); | 247 | SLOT(saveDescriptionToFile()),true); |
242 | mPopupMenu->insertSeparator(); | 248 | mPopupMenu->insertSeparator(); |
243 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 249 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
244 | i18n("Add Categ. to selected..."),this, | 250 | i18n("Add Categ. to selected..."),this, |
245 | SLOT(addCat()),true); | 251 | SLOT(addCat()),true); |
246 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 252 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
247 | i18n("Set Categ. for selected..."),this, | 253 | i18n("Set Categ. for selected..."),this, |
248 | SLOT(setCat()),true); | 254 | SLOT(setCat()),true); |
249 | mPopupMenu->insertSeparator(); | 255 | mPopupMenu->insertSeparator(); |
250 | 256 | ||
251 | 257 | ||
252 | #ifndef DESKTOP_VERSION | 258 | #ifndef DESKTOP_VERSION |
253 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 259 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
254 | i18n("Beam selected via IR"),this, | 260 | i18n("Beam selected via IR"),this, |
255 | SLOT(beamSelected()),true); | 261 | SLOT(beamSelected()),true); |
256 | #endif | 262 | #endif |
257 | /* | 263 | /* |
258 | mPopupMenu = new QPopupMenu; | 264 | mPopupMenu = new QPopupMenu; |
259 | mPopupMenu->insertItem(i18n("Edit Event"), this, | 265 | mPopupMenu->insertItem(i18n("Edit Event"), this, |
260 | SLOT (editEvent())); | 266 | SLOT (editEvent())); |
261 | mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this, | 267 | mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this, |
262 | SLOT (deleteEvent())); | 268 | SLOT (deleteEvent())); |
263 | mPopupMenu->insertSeparator(); | 269 | mPopupMenu->insertSeparator(); |
264 | mPopupMenu->insertItem(i18n("Show Dates"), this, | 270 | mPopupMenu->insertItem(i18n("Show Dates"), this, |
265 | SLOT(showDates())); | 271 | SLOT(showDates())); |
266 | mPopupMenu->insertItem(i18n("Hide Dates"), this, | 272 | mPopupMenu->insertItem(i18n("Hide Dates"), this, |
267 | SLOT(hideDates())); | 273 | SLOT(hideDates())); |
268 | */ | 274 | */ |
269 | QObject::connect(mListView,SIGNAL( newEvent()), | 275 | QObject::connect(mListView,SIGNAL( newEvent()), |
270 | this,SIGNAL(signalNewEvent())); | 276 | this,SIGNAL(signalNewEvent())); |
271 | QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)), | 277 | QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)), |
272 | this,SLOT(defaultItemAction(QListViewItem *))); | 278 | this,SLOT(defaultItemAction(QListViewItem *))); |
273 | QObject::connect(mListView,SIGNAL(rightButtonClicked ( QListViewItem *, | 279 | QObject::connect(mListView,SIGNAL(rightButtonClicked ( QListViewItem *, |
@@ -596,197 +602,202 @@ void KOListView::deleteAll() | |||
596 | 602 | ||
597 | } | 603 | } |
598 | int KOListView::maxDatesHint() | 604 | int KOListView::maxDatesHint() |
599 | { | 605 | { |
600 | return 0; | 606 | return 0; |
601 | } | 607 | } |
602 | 608 | ||
603 | int KOListView::currentDateCount() | 609 | int KOListView::currentDateCount() |
604 | { | 610 | { |
605 | return 0; | 611 | return 0; |
606 | } | 612 | } |
607 | 613 | ||
608 | QPtrList<Incidence> KOListView::selectedIncidences() | 614 | QPtrList<Incidence> KOListView::selectedIncidences() |
609 | { | 615 | { |
610 | QPtrList<Incidence> eventList; | 616 | QPtrList<Incidence> eventList; |
611 | QListViewItem *item = mListView->firstChild (); | 617 | QListViewItem *item = mListView->firstChild (); |
612 | while ( item ) { | 618 | while ( item ) { |
613 | if ( item->isSelected() ) { | 619 | if ( item->isSelected() ) { |
614 | eventList.append(((KOListViewItem *)item)->data()); | 620 | eventList.append(((KOListViewItem *)item)->data()); |
615 | } | 621 | } |
616 | 622 | ||
617 | item = item->nextSibling(); | 623 | item = item->nextSibling(); |
618 | } | 624 | } |
619 | 625 | ||
620 | // // QListViewItem *item = mListView->selectedItem(); | 626 | // // QListViewItem *item = mListView->selectedItem(); |
621 | //if (item) eventList.append(((KOListViewItem *)item)->data()); | 627 | //if (item) eventList.append(((KOListViewItem *)item)->data()); |
622 | 628 | ||
623 | return eventList; | 629 | return eventList; |
624 | } | 630 | } |
625 | 631 | ||
626 | DateList KOListView::selectedDates() | 632 | DateList KOListView::selectedDates() |
627 | { | 633 | { |
628 | DateList eventList; | 634 | DateList eventList; |
629 | return eventList; | 635 | return eventList; |
630 | } | 636 | } |
631 | 637 | ||
632 | void KOListView::showDates(bool show) | 638 | void KOListView::showDates(bool show) |
633 | { | 639 | { |
634 | // Shouldn't we set it to a value greater 0? When showDates is called with | 640 | // Shouldn't we set it to a value greater 0? When showDates is called with |
635 | // show == true at first, then the columnwidths are set to zero. | 641 | // show == true at first, then the columnwidths are set to zero. |
636 | static int oldColWidth1 = 0; | 642 | static int oldColWidth1 = 0; |
637 | static int oldColWidth3 = 0; | 643 | static int oldColWidth3 = 0; |
638 | 644 | ||
639 | if (!show) { | 645 | if (!show) { |
640 | oldColWidth1 = mListView->columnWidth(1); | 646 | oldColWidth1 = mListView->columnWidth(1); |
641 | oldColWidth3 = mListView->columnWidth(3); | 647 | oldColWidth3 = mListView->columnWidth(3); |
642 | mListView->setColumnWidth(1, 0); | 648 | mListView->setColumnWidth(1, 0); |
643 | mListView->setColumnWidth(3, 0); | 649 | mListView->setColumnWidth(3, 0); |
644 | } else { | 650 | } else { |
645 | mListView->setColumnWidth(1, oldColWidth1); | 651 | mListView->setColumnWidth(1, oldColWidth1); |
646 | mListView->setColumnWidth(3, oldColWidth3); | 652 | mListView->setColumnWidth(3, oldColWidth3); |
647 | } | 653 | } |
648 | mListView->repaint(); | 654 | mListView->repaint(); |
649 | } | 655 | } |
650 | 656 | ||
651 | void KOListView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 657 | void KOListView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
652 | const QDate &td) | 658 | const QDate &td) |
653 | { | 659 | { |
654 | #ifndef KORG_NOPRINTER | 660 | #ifndef KORG_NOPRINTER |
655 | calPrinter->preview(CalPrinter::Day, fd, td); | 661 | calPrinter->preview(CalPrinter::Day, fd, td); |
656 | #endif | 662 | #endif |
657 | } | 663 | } |
658 | 664 | ||
659 | void KOListView::showDates() | 665 | void KOListView::showDates() |
660 | { | 666 | { |
661 | showDates(true); | 667 | showDates(true); |
662 | } | 668 | } |
663 | 669 | ||
664 | void KOListView::hideDates() | 670 | void KOListView::hideDates() |
665 | { | 671 | { |
666 | showDates(false); | 672 | showDates(false); |
667 | } | 673 | } |
668 | 674 | ||
669 | void KOListView::updateView() | 675 | void KOListView::updateView() |
670 | { | 676 | { |
671 | mListView->setFocus(); | 677 | mListView->setFocus(); |
672 | if ( mListView->firstChild () ) | 678 | if ( mListView->firstChild () ) |
673 | mListView->setCurrentItem( mListView->firstChild () ); | 679 | mListView->setCurrentItem( mListView->firstChild () ); |
674 | } | 680 | } |
675 | void KOListView::updateConfig() | 681 | void KOListView::updateConfig() |
676 | { | 682 | { |
677 | 683 | ||
678 | mListView->setFont ( KOPrefs::instance()->mListViewFont ); | 684 | mListView->setFont ( KOPrefs::instance()->mListViewFont ); |
679 | updateView(); | 685 | updateView(); |
680 | 686 | ||
681 | } | 687 | } |
682 | void KOListView::setStartDate(const QDate &start) | 688 | void KOListView::setStartDate(const QDate &start) |
683 | { | 689 | { |
684 | mStartDate = start; | 690 | mStartDate = start; |
685 | } | 691 | } |
686 | 692 | ||
687 | void KOListView::showDates(const QDate &start, const QDate &end) | 693 | void KOListView::showDates(const QDate &start, const QDate &end) |
688 | { | 694 | { |
689 | clear(); | 695 | clear(); |
690 | mStartDate = start; | 696 | mStartDate = start; |
691 | QDate date = start; | 697 | QDate date = start; |
698 | QPtrList<Journal> j_list; | ||
692 | while( date <= end ) { | 699 | while( date <= end ) { |
693 | addEvents(calendar()->events(date)); | 700 | addEvents(calendar()->events(date)); |
694 | addTodos(calendar()->todos(date)); | 701 | addTodos(calendar()->todos(date)); |
702 | Journal* jo = calendar()->journal(date); | ||
703 | if ( jo ) | ||
704 | j_list.append( jo ); | ||
695 | date = date.addDays( 1 ); | 705 | date = date.addDays( 1 ); |
696 | } | 706 | } |
707 | addJournals(j_list); | ||
697 | emit incidenceSelected( 0 ); | 708 | emit incidenceSelected( 0 ); |
698 | updateView(); | 709 | updateView(); |
699 | 710 | ||
700 | } | 711 | } |
701 | 712 | ||
702 | void KOListView::addEvents(QPtrList<Event> eventList) | 713 | void KOListView::addEvents(QPtrList<Event> eventList) |
703 | { | 714 | { |
704 | Event *ev; | 715 | Event *ev; |
705 | for(ev = eventList.first(); ev; ev = eventList.next()) { | 716 | for(ev = eventList.first(); ev; ev = eventList.next()) { |
706 | addIncidence(ev); | 717 | addIncidence(ev); |
707 | } | 718 | } |
708 | if ( !mListView->currentItem() ){ | 719 | if ( !mListView->currentItem() ){ |
709 | updateView(); | 720 | updateView(); |
710 | } | 721 | } |
711 | } | 722 | } |
712 | 723 | ||
713 | void KOListView::addTodos(QPtrList<Todo> eventList) | 724 | void KOListView::addTodos(QPtrList<Todo> eventList) |
714 | { | 725 | { |
715 | Todo *ev; | 726 | Todo *ev; |
716 | for(ev = eventList.first(); ev; ev = eventList.next()) { | 727 | for(ev = eventList.first(); ev; ev = eventList.next()) { |
717 | addIncidence(ev); | 728 | addIncidence(ev); |
718 | } | 729 | } |
719 | if ( !mListView->currentItem() ){ | 730 | if ( !mListView->currentItem() ){ |
720 | updateView(); | 731 | updateView(); |
721 | } | 732 | } |
722 | } | 733 | } |
723 | void KOListView::addJournals(QPtrList<Journal> eventList) | 734 | void KOListView::addJournals(QPtrList<Journal> eventList) |
724 | { | 735 | { |
725 | Journal *ev; | 736 | Journal *ev; |
726 | for(ev = eventList.first(); ev; ev = eventList.next()) { | 737 | for(ev = eventList.first(); ev; ev = eventList.next()) { |
727 | addIncidence(ev); | 738 | addIncidence(ev); |
728 | } | 739 | } |
729 | if ( !mListView->currentItem() ){ | 740 | if ( !mListView->currentItem() ){ |
730 | updateView(); | 741 | updateView(); |
731 | } | 742 | } |
732 | } | 743 | } |
733 | 744 | ||
734 | void KOListView::addIncidence(Incidence *incidence) | 745 | void KOListView::addIncidence(Incidence *incidence) |
735 | { | 746 | { |
736 | if ( mUidDict.find( incidence->uid() ) ) return; | 747 | if ( mUidDict.find( incidence->uid() ) ) return; |
737 | 748 | ||
738 | // mListView->setFont ( KOPrefs::instance()->mListViewFont ); | 749 | // mListView->setFont ( KOPrefs::instance()->mListViewFont ); |
739 | mUidDict.insert( incidence->uid(), incidence ); | 750 | mUidDict.insert( incidence->uid(), incidence ); |
740 | 751 | ||
741 | KOListViewItem *item = new KOListViewItem( incidence, mListView ); | 752 | KOListViewItem *item = new KOListViewItem( incidence, mListView ); |
742 | ListItemVisitor v(item, mStartDate ); | 753 | ListItemVisitor v(item, mStartDate ); |
743 | if (incidence->accept(v)) return; | 754 | if (incidence->accept(v)) return; |
744 | else delete item; | 755 | else delete item; |
745 | //qDebug("delete item "); | 756 | //qDebug("delete item "); |
746 | } | 757 | } |
747 | 758 | ||
748 | void KOListView::showEvents(QPtrList<Event> eventList) | 759 | void KOListView::showEvents(QPtrList<Event> eventList) |
749 | { | 760 | { |
750 | clear(); | 761 | clear(); |
751 | 762 | ||
752 | addEvents(eventList); | 763 | addEvents(eventList); |
753 | 764 | ||
754 | // After new creation of list view no events are selected. | 765 | // After new creation of list view no events are selected. |
755 | emit incidenceSelected( 0 ); | 766 | emit incidenceSelected( 0 ); |
756 | } | 767 | } |
757 | int KOListView::count() | 768 | int KOListView::count() |
758 | { | 769 | { |
759 | return mListView->childCount(); | 770 | return mListView->childCount(); |
760 | } | 771 | } |
761 | 772 | ||
762 | void KOListView::changeEventDisplay(Event *event, int action) | 773 | void KOListView::changeEventDisplay(Event *event, int action) |
763 | { | 774 | { |
764 | KOListViewItem *item; | 775 | KOListViewItem *item; |
765 | 776 | ||
766 | switch(action) { | 777 | switch(action) { |
767 | case KOGlobals::EVENTADDED: | 778 | case KOGlobals::EVENTADDED: |
768 | addIncidence( event ); | 779 | addIncidence( event ); |
769 | break; | 780 | break; |
770 | case KOGlobals::EVENTEDITED: | 781 | case KOGlobals::EVENTEDITED: |
771 | item = getItemForEvent(event); | 782 | item = getItemForEvent(event); |
772 | if (item) { | 783 | if (item) { |
773 | mUidDict.remove( event->uid() ); | 784 | mUidDict.remove( event->uid() ); |
774 | delete item; | 785 | delete item; |
775 | addIncidence( event ); | 786 | addIncidence( event ); |
776 | } | 787 | } |
777 | break; | 788 | break; |
778 | case KOGlobals::EVENTDELETED: | 789 | case KOGlobals::EVENTDELETED: |
779 | item = getItemForEvent(event); | 790 | item = getItemForEvent(event); |
780 | if (item) { | 791 | if (item) { |
781 | mUidDict.remove( event->uid() ); | 792 | mUidDict.remove( event->uid() ); |
782 | delete item; | 793 | delete item; |
783 | } | 794 | } |
784 | break; | 795 | break; |
785 | default: | 796 | default: |
786 | ; | 797 | ; |
787 | } | 798 | } |
788 | } | 799 | } |
789 | 800 | ||
790 | KOListViewItem *KOListView::getItemForEvent(Event *event) | 801 | KOListViewItem *KOListView::getItemForEvent(Event *event) |
791 | { | 802 | { |
792 | KOListViewItem *item = (KOListViewItem *)mListView->firstChild(); | 803 | KOListViewItem *item = (KOListViewItem *)mListView->firstChild(); |