-rw-r--r-- | korganizer/kolistview.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp index 3d4acb7..f8bfc8b 100644 --- a/korganizer/kolistview.cpp +++ b/korganizer/kolistview.cpp | |||
@@ -1,209 +1,211 @@ | |||
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 | #include <qregexp.h> |
36 | 36 | ||
37 | #include <klocale.h> | 37 | #include <klocale.h> |
38 | #include <kdebug.h> | 38 | #include <kdebug.h> |
39 | #include <kiconloader.h> | 39 | #include <kiconloader.h> |
40 | #include <kglobal.h> | 40 | #include <kglobal.h> |
41 | 41 | ||
42 | #include <libkdepim/kpimglobalprefs.h> | 42 | #include <libkdepim/kpimglobalprefs.h> |
43 | #include <libkcal/calendar.h> | 43 | #include <libkcal/calendar.h> |
44 | #include <libkcal/calendarlocal.h> | 44 | #include <libkcal/calendarlocal.h> |
45 | #include <libkcal/icalformat.h> | 45 | #include <libkcal/icalformat.h> |
46 | #include <libkcal/vcalformat.h> | 46 | #include <libkcal/vcalformat.h> |
47 | #include <libkcal/recurrence.h> | 47 | #include <libkcal/recurrence.h> |
48 | #include <libkcal/filestorage.h> | 48 | #include <libkcal/filestorage.h> |
49 | #include <libkdepim/categoryselectdialog.h> | 49 | #include <libkdepim/categoryselectdialog.h> |
50 | #ifndef DESKTOP_VERSION | 50 | #ifndef DESKTOP_VERSION |
51 | #include <qpe/qpeapplication.h> | 51 | #include <qpe/qpeapplication.h> |
52 | #else | 52 | #else |
53 | #include <qapplication.h> | 53 | #include <qapplication.h> |
54 | #endif | 54 | #endif |
55 | 55 | ||
56 | #ifndef KORG_NOPRINTER | 56 | #ifndef KORG_NOPRINTER |
57 | #include "calprinter.h" | 57 | #include "calprinter.h" |
58 | #endif | 58 | #endif |
59 | #include "koglobals.h" | 59 | #include "koglobals.h" |
60 | #include "koprefs.h" | 60 | #include "koprefs.h" |
61 | #include "kfiledialog.h" | 61 | #include "kfiledialog.h" |
62 | 62 | ||
63 | #include "kolistview.h" | 63 | #include "kolistview.h" |
64 | 64 | ||
65 | ListItemVisitor::ListItemVisitor(KOListViewItem *item, QDate date ) | 65 | ListItemVisitor::ListItemVisitor(KOListViewItem *item, QDate date ) |
66 | { | 66 | { |
67 | mItem = item; | 67 | mItem = item; |
68 | mDate = date; | 68 | mDate = date; |
69 | } | 69 | } |
70 | 70 | ||
71 | ListItemVisitor::~ListItemVisitor() | 71 | ListItemVisitor::~ListItemVisitor() |
72 | { | 72 | { |
73 | } | 73 | } |
74 | 74 | ||
75 | bool ListItemVisitor::visit(Event *e) | 75 | bool ListItemVisitor::visit(Event *e) |
76 | { | 76 | { |
77 | 77 | ||
78 | bool ok = false; | 78 | bool ok = false; |
79 | QString start, end; | 79 | QString start, end; |
80 | QDate ds, de; | ||
80 | if ( e->doesRecur() ) { | 81 | if ( e->doesRecur() ) { |
81 | QDate d = e->getNextOccurence( QDateTime( mDate, QTime(0,0,0)), &ok ).date(); | 82 | ds = e->getNextOccurence( QDateTime( mDate, QTime(0,0,0)), &ok ).date(); |
82 | if ( ok ) { | 83 | if ( ok ) { |
83 | int days = e->dtStart().date().daysTo(e->dtEnd().date() ); | 84 | int days = e->dtStart().date().daysTo(e->dtEnd().date() ); |
84 | start = KGlobal::locale()->formatDate(d,true); | 85 | start = KGlobal::locale()->formatDate(ds,true); |
85 | end = KGlobal::locale()->formatDate(d.addDays( days),true); | 86 | de = ds.addDays( days); |
87 | end = KGlobal::locale()->formatDate(de,true); | ||
86 | } | 88 | } |
87 | 89 | ||
88 | } | 90 | } |
89 | if ( ! ok ) { | 91 | if ( ! ok ) { |
90 | start =e->dtStartDateStr(); | 92 | start =e->dtStartDateStr(); |
91 | end = e->dtEndDateStr(); | 93 | end = e->dtEndDateStr(); |
94 | ds = e->dtStart().date(); | ||
95 | de = e->dtEnd().date(); | ||
92 | } | 96 | } |
93 | mItem->setText(0,e->summary()); | 97 | mItem->setText(0,e->summary()); |
94 | mItem->setText(1,start); | 98 | mItem->setText(1,start); |
95 | mItem->setText(2,e->dtStartTimeStr()); | 99 | mItem->setText(2,e->dtStartTimeStr()); |
96 | mItem->setText(3,end); | 100 | mItem->setText(3,end); |
97 | mItem->setText(4,e->dtEndTimeStr()); | 101 | mItem->setText(4,e->dtEndTimeStr()); |
98 | mItem->setText(5,e->isAlarmEnabled() ? i18n("Yes") : i18n("No")); | 102 | mItem->setText(5,e->isAlarmEnabled() ? i18n("Yes") : i18n("No")); |
99 | mItem->setText(6, e->recurrence()->recurrenceText()); | 103 | mItem->setText(6, e->recurrence()->recurrenceText()); |
100 | mItem->setText(7,"---"); | 104 | mItem->setText(7,"---"); |
101 | mItem->setText(8,"---"); | 105 | mItem->setText(8,"---"); |
102 | mItem->setText(9, e->cancelled() ? i18n("Yes") : i18n("No")); | 106 | mItem->setText(9, e->cancelled() ? i18n("Yes") : i18n("No")); |
103 | mItem->setText(10,e->categoriesStr()); | 107 | mItem->setText(10,e->categoriesStr()); |
104 | 108 | ||
105 | QString key; | 109 | QString key; |
106 | QDate d = e->dtStart().date(); | ||
107 | QTime t = e->doesFloat() ? QTime(0,0) : e->dtStart().time(); | 110 | QTime t = e->doesFloat() ? QTime(0,0) : e->dtStart().time(); |
108 | 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",ds.year(),ds.month(),ds.day(),t.hour(),t.minute()); |
109 | mItem->setSortKey(1,key); | 112 | mItem->setSortKey(1,key); |
110 | 113 | ||
111 | d = e->dtEnd().date(); | ||
112 | t = e->doesFloat() ? QTime(0,0) : e->dtEnd().time(); | 114 | t = e->doesFloat() ? QTime(0,0) : e->dtEnd().time(); |
113 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),t.hour(),t.minute()); | 115 | key.sprintf("%04d%02d%02d%02d%02d",de.year(),de.month(),de.day(),t.hour(),t.minute()); |
114 | mItem->setSortKey(3,key); | 116 | mItem->setSortKey(3,key); |
115 | 117 | ||
116 | return true; | 118 | return true; |
117 | } | 119 | } |
118 | 120 | ||
119 | bool ListItemVisitor::visit(Todo *t) | 121 | bool ListItemVisitor::visit(Todo *t) |
120 | { | 122 | { |
121 | mItem->setText(0,i18n("To-Do: %1").arg(t->summary())); | 123 | mItem->setText(0,i18n("To-Do: %1").arg(t->summary())); |
122 | if (t->hasStartDate()) { | 124 | if (t->hasStartDate()) { |
123 | mItem->setText(1,t->dtStartDateStr()); | 125 | mItem->setText(1,t->dtStartDateStr()); |
124 | if (t->doesFloat()) { | 126 | if (t->doesFloat()) { |
125 | mItem->setText(2,"---"); | 127 | mItem->setText(2,"---"); |
126 | } else { | 128 | } else { |
127 | mItem->setText(2,t->dtStartTimeStr()); | 129 | mItem->setText(2,t->dtStartTimeStr()); |
128 | } | 130 | } |
129 | } else { | 131 | } else { |
130 | mItem->setText(1,"---"); | 132 | mItem->setText(1,"---"); |
131 | mItem->setText(2,"---"); | 133 | mItem->setText(2,"---"); |
132 | } | 134 | } |
133 | mItem->setText(3,"---"); | 135 | mItem->setText(3,"---"); |
134 | mItem->setText(4,"---"); | 136 | mItem->setText(4,"---"); |
135 | mItem->setText(5,"---"); | 137 | mItem->setText(5,"---"); |
136 | mItem->setText(6,"---"); | 138 | mItem->setText(6,"---"); |
137 | if (t->hasDueDate()) { | 139 | if (t->hasDueDate()) { |
138 | mItem->setText(7,t->dtDueDateStr()); | 140 | mItem->setText(7,t->dtDueDateStr()); |
139 | if (t->doesFloat()) { | 141 | if (t->doesFloat()) { |
140 | mItem->setText(8,"---"); | 142 | mItem->setText(8,"---"); |
141 | } else { | 143 | } else { |
142 | mItem->setText(8,t->dtDueTimeStr()); | 144 | mItem->setText(8,t->dtDueTimeStr()); |
143 | } | 145 | } |
144 | } else { | 146 | } else { |
145 | mItem->setText(7,"---"); | 147 | mItem->setText(7,"---"); |
146 | mItem->setText(8,"---"); | 148 | mItem->setText(8,"---"); |
147 | } | 149 | } |
148 | mItem->setText(9, t->cancelled() ? i18n("Yes") : i18n("No")); | 150 | mItem->setText(9, t->cancelled() ? i18n("Yes") : i18n("No")); |
149 | mItem->setText(10,t->categoriesStr()); | 151 | mItem->setText(10,t->categoriesStr()); |
150 | 152 | ||
151 | QString key; | 153 | QString key; |
152 | QDate d; | 154 | QDate d; |
153 | if (t->hasDueDate()) { | 155 | if (t->hasDueDate()) { |
154 | d = t->dtDue().date(); | 156 | d = t->dtDue().date(); |
155 | QTime tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time(); | 157 | QTime tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time(); |
156 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); | 158 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); |
157 | mItem->setSortKey(7,key); | 159 | mItem->setSortKey(7,key); |
158 | } | 160 | } |
159 | if ( t->hasStartDate() ) { | 161 | if ( t->hasStartDate() ) { |
160 | d = t->dtStart().date(); | 162 | d = t->dtStart().date(); |
161 | QTime tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time(); | 163 | QTime tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time(); |
162 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); | 164 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); |
163 | mItem->setSortKey(1,key); | 165 | mItem->setSortKey(1,key); |
164 | } | 166 | } |
165 | return true; | 167 | return true; |
166 | } | 168 | } |
167 | 169 | ||
168 | bool ListItemVisitor::visit(Journal * j) | 170 | bool ListItemVisitor::visit(Journal * j) |
169 | { | 171 | { |
170 | QString des = j->description().left(50); | 172 | QString des = j->description().left(50); |
171 | des = des.simplifyWhiteSpace (); | 173 | des = des.simplifyWhiteSpace (); |
172 | des.replace (QRegExp ("\\n"),"" ); | 174 | des.replace (QRegExp ("\\n"),"" ); |
173 | des.replace (QRegExp ("\\r"),"" ); | 175 | des.replace (QRegExp ("\\r"),"" ); |
174 | mItem->setText(0,i18n("Journal")+": "+des.left(25)); | 176 | mItem->setText(0,i18n("Journal")+": "+des.left(25)); |
175 | mItem->setText(1,j->dtStartDateStr()); | 177 | mItem->setText(1,j->dtStartDateStr()); |
176 | mItem->setText(2,"---"); | 178 | mItem->setText(2,"---"); |
177 | mItem->setText(3,"---"); | 179 | mItem->setText(3,"---"); |
178 | mItem->setText(4,"---"); | 180 | mItem->setText(4,"---"); |
179 | mItem->setText(5,"---"); | 181 | mItem->setText(5,"---"); |
180 | mItem->setText(6,"---"); | 182 | mItem->setText(6,"---"); |
181 | mItem->setText(7,j->dtStartDateStr()); | 183 | mItem->setText(7,j->dtStartDateStr()); |
182 | mItem->setText(8,"---"); | 184 | mItem->setText(8,"---"); |
183 | mItem->setText(9,"---"); | 185 | mItem->setText(9,"---"); |
184 | mItem->setText(10,i18n("Last Modified: ")+ KGlobal::locale()->formatDateTime( j->lastModified() , true) ); | 186 | mItem->setText(10,i18n("Last Modified: ")+ KGlobal::locale()->formatDateTime( j->lastModified() , true) ); |
185 | 187 | ||
186 | QString key; | 188 | QString key; |
187 | QDate d = j->dtStart().date(); | 189 | QDate d = j->dtStart().date(); |
188 | key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); | 190 | key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); |
189 | mItem->setSortKey(1,key); | 191 | mItem->setSortKey(1,key); |
190 | mItem->setSortKey(7,key); | 192 | mItem->setSortKey(7,key); |
191 | 193 | ||
192 | return true; | 194 | return true; |
193 | } | 195 | } |
194 | 196 | ||
195 | KOListView::KOListView(Calendar *calendar, QWidget *parent, | 197 | KOListView::KOListView(Calendar *calendar, QWidget *parent, |
196 | const char *name) | 198 | const char *name) |
197 | : KOEventView(calendar, parent, name) | 199 | : KOEventView(calendar, parent, name) |
198 | { | 200 | { |
199 | mActiveItem = 0; | 201 | mActiveItem = 0; |
200 | mListView = new KOListViewListView(this); | 202 | mListView = new KOListViewListView(this); |
201 | mListView->addColumn(i18n("Summary")); | 203 | mListView->addColumn(i18n("Summary")); |
202 | mListView->addColumn(i18n("Start Date")); | 204 | mListView->addColumn(i18n("Start Date")); |
203 | mListView->addColumn(i18n("Start Time")); | 205 | mListView->addColumn(i18n("Start Time")); |
204 | mListView->addColumn(i18n("End Date")); | 206 | mListView->addColumn(i18n("End Date")); |
205 | mListView->addColumn(i18n("End Time")); | 207 | mListView->addColumn(i18n("End Time")); |
206 | mListView->addColumn(i18n("Alarm")); // alarm set? | 208 | mListView->addColumn(i18n("Alarm")); // alarm set? |
207 | mListView->addColumn(i18n("Recurs")); // recurs? | 209 | mListView->addColumn(i18n("Recurs")); // recurs? |
208 | mListView->addColumn(i18n("Due Date")); | 210 | mListView->addColumn(i18n("Due Date")); |
209 | mListView->addColumn(i18n("Due Time")); | 211 | mListView->addColumn(i18n("Due Time")); |