-rw-r--r-- | korganizer/kolistview.cpp | 1 |
1 files changed, 0 insertions, 1 deletions
diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp index b6061d0..9a3ba73 100644 --- a/korganizer/kolistview.cpp +++ b/korganizer/kolistview.cpp | |||
@@ -1,254 +1,253 @@ | |||
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 | 35 | ||
36 | #include <klocale.h> | 36 | #include <klocale.h> |
37 | #include <kdebug.h> | 37 | #include <kdebug.h> |
38 | #include <kiconloader.h> | 38 | #include <kiconloader.h> |
39 | #include <kglobal.h> | 39 | #include <kglobal.h> |
40 | 40 | ||
41 | #include <libkcal/calendar.h> | 41 | #include <libkcal/calendar.h> |
42 | #include <libkcal/calendarlocal.h> | 42 | #include <libkcal/calendarlocal.h> |
43 | #include <libkcal/icalformat.h> | 43 | #include <libkcal/icalformat.h> |
44 | #include <libkcal/vcalformat.h> | 44 | #include <libkcal/vcalformat.h> |
45 | #include <libkcal/recurrence.h> | 45 | #include <libkcal/recurrence.h> |
46 | #include <libkcal/filestorage.h> | 46 | #include <libkcal/filestorage.h> |
47 | #include <libkdepim/categoryselectdialog.h> | 47 | #include <libkdepim/categoryselectdialog.h> |
48 | #ifndef DESKTOP_VERSION | 48 | #ifndef DESKTOP_VERSION |
49 | #include <qpe/qpeapplication.h> | 49 | #include <qpe/qpeapplication.h> |
50 | #else | 50 | #else |
51 | #include <qapplication.h> | 51 | #include <qapplication.h> |
52 | #endif | 52 | #endif |
53 | 53 | ||
54 | #ifndef KORG_NOPRINTER | 54 | #ifndef KORG_NOPRINTER |
55 | #include "calprinter.h" | 55 | #include "calprinter.h" |
56 | #endif | 56 | #endif |
57 | #include "koglobals.h" | 57 | #include "koglobals.h" |
58 | #include "koprefs.h" | 58 | #include "koprefs.h" |
59 | #include "kfiledialog.h" | 59 | #include "kfiledialog.h" |
60 | 60 | ||
61 | #include "kolistview.h" | 61 | #include "kolistview.h" |
62 | #include "kolistview.moc" | ||
63 | 62 | ||
64 | ListItemVisitor::ListItemVisitor(KOListViewItem *item, QDate date ) | 63 | ListItemVisitor::ListItemVisitor(KOListViewItem *item, QDate date ) |
65 | { | 64 | { |
66 | mItem = item; | 65 | mItem = item; |
67 | mDate = date; | 66 | mDate = date; |
68 | } | 67 | } |
69 | 68 | ||
70 | ListItemVisitor::~ListItemVisitor() | 69 | ListItemVisitor::~ListItemVisitor() |
71 | { | 70 | { |
72 | } | 71 | } |
73 | 72 | ||
74 | bool ListItemVisitor::visit(Event *e) | 73 | bool ListItemVisitor::visit(Event *e) |
75 | { | 74 | { |
76 | 75 | ||
77 | bool ok = false; | 76 | bool ok = false; |
78 | QString start, end; | 77 | QString start, end; |
79 | if ( e->doesRecur() ) { | 78 | if ( e->doesRecur() ) { |
80 | QDate d = e->getNextOccurence( QDateTime( mDate, QTime(0,0,0)), &ok ).date(); | 79 | QDate d = e->getNextOccurence( QDateTime( mDate, QTime(0,0,0)), &ok ).date(); |
81 | if ( ok ) { | 80 | if ( ok ) { |
82 | int days = e->dtStart().date().daysTo(e->dtEnd().date() ); | 81 | int days = e->dtStart().date().daysTo(e->dtEnd().date() ); |
83 | start = KGlobal::locale()->formatDate(d,true); | 82 | start = KGlobal::locale()->formatDate(d,true); |
84 | end = KGlobal::locale()->formatDate(d.addDays( days),true); | 83 | end = KGlobal::locale()->formatDate(d.addDays( days),true); |
85 | } | 84 | } |
86 | 85 | ||
87 | } | 86 | } |
88 | if ( ! ok ) { | 87 | if ( ! ok ) { |
89 | start =e->dtStartDateStr(); | 88 | start =e->dtStartDateStr(); |
90 | end = e->dtEndDateStr(); | 89 | end = e->dtEndDateStr(); |
91 | } | 90 | } |
92 | mItem->setText(0,e->summary()); | 91 | mItem->setText(0,e->summary()); |
93 | mItem->setText(1,start); | 92 | mItem->setText(1,start); |
94 | mItem->setText(2,e->dtStartTimeStr()); | 93 | mItem->setText(2,e->dtStartTimeStr()); |
95 | mItem->setText(3,end); | 94 | mItem->setText(3,end); |
96 | mItem->setText(4,e->dtEndTimeStr()); | 95 | mItem->setText(4,e->dtEndTimeStr()); |
97 | mItem->setText(5,e->isAlarmEnabled() ? i18n("Yes") : i18n("No")); | 96 | mItem->setText(5,e->isAlarmEnabled() ? i18n("Yes") : i18n("No")); |
98 | mItem->setText(6, e->recurrence()->recurrenceText()); | 97 | mItem->setText(6, e->recurrence()->recurrenceText()); |
99 | mItem->setText(7,"---"); | 98 | mItem->setText(7,"---"); |
100 | mItem->setText(8,"---"); | 99 | mItem->setText(8,"---"); |
101 | mItem->setText(9, e->cancelled() ? i18n("Yes") : i18n("No")); | 100 | mItem->setText(9, e->cancelled() ? i18n("Yes") : i18n("No")); |
102 | mItem->setText(10,e->categoriesStr()); | 101 | mItem->setText(10,e->categoriesStr()); |
103 | 102 | ||
104 | QString key; | 103 | QString key; |
105 | QDate d = e->dtStart().date(); | 104 | QDate d = e->dtStart().date(); |
106 | QTime t = e->doesFloat() ? QTime(0,0) : e->dtStart().time(); | 105 | QTime t = e->doesFloat() ? QTime(0,0) : e->dtStart().time(); |
107 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),t.hour(),t.minute()); | 106 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),t.hour(),t.minute()); |
108 | mItem->setSortKey(1,key); | 107 | mItem->setSortKey(1,key); |
109 | 108 | ||
110 | d = e->dtEnd().date(); | 109 | d = e->dtEnd().date(); |
111 | t = e->doesFloat() ? QTime(0,0) : e->dtEnd().time(); | 110 | t = e->doesFloat() ? QTime(0,0) : e->dtEnd().time(); |
112 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),t.hour(),t.minute()); | 111 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),t.hour(),t.minute()); |
113 | mItem->setSortKey(3,key); | 112 | mItem->setSortKey(3,key); |
114 | 113 | ||
115 | return true; | 114 | return true; |
116 | } | 115 | } |
117 | 116 | ||
118 | bool ListItemVisitor::visit(Todo *t) | 117 | bool ListItemVisitor::visit(Todo *t) |
119 | { | 118 | { |
120 | mItem->setText(0,i18n("To-Do: %1").arg(t->summary())); | 119 | mItem->setText(0,i18n("To-Do: %1").arg(t->summary())); |
121 | if (t->hasStartDate()) { | 120 | if (t->hasStartDate()) { |
122 | mItem->setText(1,t->dtStartDateStr()); | 121 | mItem->setText(1,t->dtStartDateStr()); |
123 | if (t->doesFloat()) { | 122 | if (t->doesFloat()) { |
124 | mItem->setText(2,"---"); | 123 | mItem->setText(2,"---"); |
125 | } else { | 124 | } else { |
126 | mItem->setText(2,t->dtStartTimeStr()); | 125 | mItem->setText(2,t->dtStartTimeStr()); |
127 | } | 126 | } |
128 | } else { | 127 | } else { |
129 | mItem->setText(1,"---"); | 128 | mItem->setText(1,"---"); |
130 | mItem->setText(2,"---"); | 129 | mItem->setText(2,"---"); |
131 | } | 130 | } |
132 | mItem->setText(3,"---"); | 131 | mItem->setText(3,"---"); |
133 | mItem->setText(4,"---"); | 132 | mItem->setText(4,"---"); |
134 | mItem->setText(5,"---"); | 133 | mItem->setText(5,"---"); |
135 | mItem->setText(6,"---"); | 134 | mItem->setText(6,"---"); |
136 | if (t->hasDueDate()) { | 135 | if (t->hasDueDate()) { |
137 | mItem->setText(7,t->dtDueDateStr()); | 136 | mItem->setText(7,t->dtDueDateStr()); |
138 | if (t->doesFloat()) { | 137 | if (t->doesFloat()) { |
139 | mItem->setText(8,"---"); | 138 | mItem->setText(8,"---"); |
140 | } else { | 139 | } else { |
141 | mItem->setText(8,t->dtDueTimeStr()); | 140 | mItem->setText(8,t->dtDueTimeStr()); |
142 | } | 141 | } |
143 | } else { | 142 | } else { |
144 | mItem->setText(7,"---"); | 143 | mItem->setText(7,"---"); |
145 | mItem->setText(8,"---"); | 144 | mItem->setText(8,"---"); |
146 | } | 145 | } |
147 | mItem->setText(9, t->cancelled() ? i18n("Yes") : i18n("No")); | 146 | mItem->setText(9, t->cancelled() ? i18n("Yes") : i18n("No")); |
148 | mItem->setText(10,t->categoriesStr()); | 147 | mItem->setText(10,t->categoriesStr()); |
149 | 148 | ||
150 | QString key; | 149 | QString key; |
151 | QDate d; | 150 | QDate d; |
152 | if (t->hasDueDate()) { | 151 | if (t->hasDueDate()) { |
153 | d = t->dtDue().date(); | 152 | d = t->dtDue().date(); |
154 | QTime tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time(); | 153 | QTime tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time(); |
155 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); | 154 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); |
156 | mItem->setSortKey(7,key); | 155 | mItem->setSortKey(7,key); |
157 | } | 156 | } |
158 | if ( t->hasStartDate() ) { | 157 | if ( t->hasStartDate() ) { |
159 | d = t->dtStart().date(); | 158 | d = t->dtStart().date(); |
160 | QTime tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time(); | 159 | QTime tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time(); |
161 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); | 160 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); |
162 | mItem->setSortKey(1,key); | 161 | mItem->setSortKey(1,key); |
163 | } | 162 | } |
164 | return true; | 163 | return true; |
165 | } | 164 | } |
166 | 165 | ||
167 | bool ListItemVisitor::visit(Journal * j) | 166 | bool ListItemVisitor::visit(Journal * j) |
168 | { | 167 | { |
169 | mItem->setText(0,i18n("Journal")); | 168 | mItem->setText(0,i18n("Journal")); |
170 | mItem->setText(1,j->dtStartDateStr()); | 169 | mItem->setText(1,j->dtStartDateStr()); |
171 | mItem->setText(2,"---"); | 170 | mItem->setText(2,"---"); |
172 | mItem->setText(3,"---"); | 171 | mItem->setText(3,"---"); |
173 | mItem->setText(4,"---"); | 172 | mItem->setText(4,"---"); |
174 | mItem->setText(5,"---"); | 173 | mItem->setText(5,"---"); |
175 | mItem->setText(6,"---"); | 174 | mItem->setText(6,"---"); |
176 | mItem->setText(7,j->dtStartDateStr()); | 175 | mItem->setText(7,j->dtStartDateStr()); |
177 | mItem->setText(8,"---"); | 176 | mItem->setText(8,"---"); |
178 | mItem->setText(9,"---"); | 177 | mItem->setText(9,"---"); |
179 | 178 | ||
180 | QString key; | 179 | QString key; |
181 | QDate d = j->dtStart().date(); | 180 | QDate d = j->dtStart().date(); |
182 | key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); | 181 | key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); |
183 | mItem->setSortKey(1,key); | 182 | mItem->setSortKey(1,key); |
184 | mItem->setSortKey(7,key); | 183 | mItem->setSortKey(7,key); |
185 | 184 | ||
186 | return true; | 185 | return true; |
187 | } | 186 | } |
188 | 187 | ||
189 | KOListView::KOListView(Calendar *calendar, QWidget *parent, | 188 | KOListView::KOListView(Calendar *calendar, QWidget *parent, |
190 | const char *name) | 189 | const char *name) |
191 | : KOEventView(calendar, parent, name) | 190 | : KOEventView(calendar, parent, name) |
192 | { | 191 | { |
193 | mActiveItem = 0; | 192 | mActiveItem = 0; |
194 | mListView = new KOListViewListView(this); | 193 | mListView = new KOListViewListView(this); |
195 | mListView->addColumn(i18n("Summary")); | 194 | mListView->addColumn(i18n("Summary")); |
196 | mListView->addColumn(i18n("Start Date")); | 195 | mListView->addColumn(i18n("Start Date")); |
197 | mListView->addColumn(i18n("Start Time")); | 196 | mListView->addColumn(i18n("Start Time")); |
198 | mListView->addColumn(i18n("End Date")); | 197 | mListView->addColumn(i18n("End Date")); |
199 | mListView->addColumn(i18n("End Time")); | 198 | mListView->addColumn(i18n("End Time")); |
200 | mListView->addColumn(i18n("Alarm")); // alarm set? | 199 | mListView->addColumn(i18n("Alarm")); // alarm set? |
201 | mListView->addColumn(i18n("Recurs")); // recurs? | 200 | mListView->addColumn(i18n("Recurs")); // recurs? |
202 | mListView->addColumn(i18n("Due Date")); | 201 | mListView->addColumn(i18n("Due Date")); |
203 | mListView->addColumn(i18n("Due Time")); | 202 | mListView->addColumn(i18n("Due Time")); |
204 | mListView->addColumn(i18n("Cancelled")); | 203 | mListView->addColumn(i18n("Cancelled")); |
205 | mListView->addColumn(i18n("Categories")); | 204 | mListView->addColumn(i18n("Categories")); |
206 | 205 | ||
207 | mListView->setColumnAlignment(0,AlignLeft); | 206 | mListView->setColumnAlignment(0,AlignLeft); |
208 | mListView->setColumnAlignment(1,AlignLeft); | 207 | mListView->setColumnAlignment(1,AlignLeft); |
209 | mListView->setColumnAlignment(2,AlignHCenter); | 208 | mListView->setColumnAlignment(2,AlignHCenter); |
210 | mListView->setColumnAlignment(3,AlignLeft); | 209 | mListView->setColumnAlignment(3,AlignLeft); |
211 | mListView->setColumnAlignment(4,AlignHCenter); | 210 | mListView->setColumnAlignment(4,AlignHCenter); |
212 | mListView->setColumnAlignment(5,AlignLeft); | 211 | mListView->setColumnAlignment(5,AlignLeft); |
213 | mListView->setColumnAlignment(6,AlignLeft); | 212 | mListView->setColumnAlignment(6,AlignLeft); |
214 | mListView->setColumnAlignment(7,AlignLeft); | 213 | mListView->setColumnAlignment(7,AlignLeft); |
215 | mListView->setColumnAlignment(8,AlignLeft); | 214 | mListView->setColumnAlignment(8,AlignLeft); |
216 | mListView->setColumnAlignment(9,AlignLeft); | 215 | mListView->setColumnAlignment(9,AlignLeft); |
217 | mListView->setColumnAlignment(10,AlignLeft); | 216 | mListView->setColumnAlignment(10,AlignLeft); |
218 | 217 | ||
219 | int iii = 0; | 218 | int iii = 0; |
220 | for ( iii = 0; iii< 10 ; ++iii ) | 219 | for ( iii = 0; iii< 10 ; ++iii ) |
221 | mListView->setColumnWidthMode( iii, QListView::Manual ); | 220 | mListView->setColumnWidthMode( iii, QListView::Manual ); |
222 | 221 | ||
223 | QBoxLayout *layoutTop = new QVBoxLayout(this); | 222 | QBoxLayout *layoutTop = new QVBoxLayout(this); |
224 | layoutTop->addWidget(mListView); | 223 | layoutTop->addWidget(mListView); |
225 | mListView->setFont ( KOPrefs::instance()->mListViewFont ); | 224 | mListView->setFont ( KOPrefs::instance()->mListViewFont ); |
226 | mPopupMenu = eventPopup(); | 225 | mPopupMenu = eventPopup(); |
227 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 226 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
228 | i18n("Select all"),this, | 227 | i18n("Select all"),this, |
229 | SLOT(allSelection()),true); | 228 | SLOT(allSelection()),true); |
230 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 229 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
231 | i18n("Deselect All"),this, | 230 | i18n("Deselect All"),this, |
232 | SLOT(clearSelection()),true); | 231 | SLOT(clearSelection()),true); |
233 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 232 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
234 | i18n("Delete all selected"),this, | 233 | i18n("Delete all selected"),this, |
235 | SLOT(deleteAll()),true); | 234 | SLOT(deleteAll()),true); |
236 | mPopupMenu->insertSeparator(); | 235 | mPopupMenu->insertSeparator(); |
237 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 236 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
238 | i18n("Save selected to file..."),this, | 237 | i18n("Save selected to file..."),this, |
239 | SLOT(saveToFile()),true); | 238 | SLOT(saveToFile()),true); |
240 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 239 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
241 | i18n("Save Journal/Description..."),this, | 240 | i18n("Save Journal/Description..."),this, |
242 | SLOT(saveDescriptionToFile()),true); | 241 | SLOT(saveDescriptionToFile()),true); |
243 | mPopupMenu->insertSeparator(); | 242 | mPopupMenu->insertSeparator(); |
244 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 243 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
245 | i18n("Add Categ. to selected..."),this, | 244 | i18n("Add Categ. to selected..."),this, |
246 | SLOT(addCat()),true); | 245 | SLOT(addCat()),true); |
247 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 246 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
248 | i18n("Set Categ. for selected..."),this, | 247 | i18n("Set Categ. for selected..."),this, |
249 | SLOT(setCat()),true); | 248 | SLOT(setCat()),true); |
250 | mPopupMenu->insertSeparator(); | 249 | mPopupMenu->insertSeparator(); |
251 | 250 | ||
252 | 251 | ||
253 | #ifndef DESKTOP_VERSION | 252 | #ifndef DESKTOP_VERSION |
254 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 253 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |