-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,497 +1,499 @@ | |||
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")); |
210 | mListView->addColumn(i18n("Cancelled")); | 212 | mListView->addColumn(i18n("Cancelled")); |
211 | mListView->addColumn(i18n("Categories")); | 213 | mListView->addColumn(i18n("Categories")); |
212 | 214 | ||
213 | mListView->setColumnAlignment(0,AlignLeft); | 215 | mListView->setColumnAlignment(0,AlignLeft); |
214 | mListView->setColumnAlignment(1,AlignLeft); | 216 | mListView->setColumnAlignment(1,AlignLeft); |
215 | mListView->setColumnAlignment(2,AlignHCenter); | 217 | mListView->setColumnAlignment(2,AlignHCenter); |
216 | mListView->setColumnAlignment(3,AlignLeft); | 218 | mListView->setColumnAlignment(3,AlignLeft); |
217 | mListView->setColumnAlignment(4,AlignHCenter); | 219 | mListView->setColumnAlignment(4,AlignHCenter); |
218 | mListView->setColumnAlignment(5,AlignLeft); | 220 | mListView->setColumnAlignment(5,AlignLeft); |
219 | mListView->setColumnAlignment(6,AlignLeft); | 221 | mListView->setColumnAlignment(6,AlignLeft); |
220 | mListView->setColumnAlignment(7,AlignLeft); | 222 | mListView->setColumnAlignment(7,AlignLeft); |
221 | mListView->setColumnAlignment(8,AlignLeft); | 223 | mListView->setColumnAlignment(8,AlignLeft); |
222 | mListView->setColumnAlignment(9,AlignLeft); | 224 | mListView->setColumnAlignment(9,AlignLeft); |
223 | mListView->setColumnAlignment(10,AlignLeft); | 225 | mListView->setColumnAlignment(10,AlignLeft); |
224 | 226 | ||
225 | int iii = 0; | 227 | int iii = 0; |
226 | for ( iii = 0; iii< 10 ; ++iii ) | 228 | for ( iii = 0; iii< 10 ; ++iii ) |
227 | mListView->setColumnWidthMode( iii, QListView::Manual ); | 229 | mListView->setColumnWidthMode( iii, QListView::Manual ); |
228 | 230 | ||
229 | QBoxLayout *layoutTop = new QVBoxLayout(this); | 231 | QBoxLayout *layoutTop = new QVBoxLayout(this); |
230 | layoutTop->addWidget(mListView); | 232 | layoutTop->addWidget(mListView); |
231 | mListView->setFont ( KOPrefs::instance()->mListViewFont ); | 233 | mListView->setFont ( KOPrefs::instance()->mListViewFont ); |
232 | mPopupMenu = eventPopup(); | 234 | mPopupMenu = eventPopup(); |
233 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 235 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
234 | i18n("Select all"),this, | 236 | i18n("Select all"),this, |
235 | SLOT(allSelection()),true); | 237 | SLOT(allSelection()),true); |
236 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 238 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
237 | i18n("Deselect All"),this, | 239 | i18n("Deselect All"),this, |
238 | SLOT(clearSelection()),true); | 240 | SLOT(clearSelection()),true); |
239 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 241 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
240 | i18n("Delete all selected"),this, | 242 | i18n("Delete all selected"),this, |
241 | SLOT(deleteAll()),true); | 243 | SLOT(deleteAll()),true); |
242 | mPopupMenu->insertSeparator(); | 244 | mPopupMenu->insertSeparator(); |
243 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 245 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
244 | i18n("Save selected to file..."),this, | 246 | i18n("Save selected to file..."),this, |
245 | SLOT(saveToFile()),true); | 247 | SLOT(saveToFile()),true); |
246 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 248 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
247 | i18n("Save Journal/Description..."),this, | 249 | i18n("Save Journal/Description..."),this, |
248 | SLOT(saveDescriptionToFile()),true); | 250 | SLOT(saveDescriptionToFile()),true); |
249 | mPopupMenu->insertSeparator(); | 251 | mPopupMenu->insertSeparator(); |
250 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 252 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
251 | i18n("Add Categ. to selected..."),this, | 253 | i18n("Add Categ. to selected..."),this, |
252 | SLOT(addCat()),true); | 254 | SLOT(addCat()),true); |
253 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 255 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
254 | i18n("Set Categ. for selected..."),this, | 256 | i18n("Set Categ. for selected..."),this, |
255 | SLOT(setCat()),true); | 257 | SLOT(setCat()),true); |
256 | mPopupMenu->insertSeparator(); | 258 | mPopupMenu->insertSeparator(); |
257 | 259 | ||
258 | 260 | ||
259 | #ifndef DESKTOP_VERSION | 261 | #ifndef DESKTOP_VERSION |
260 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 262 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
261 | i18n("Beam selected via IR"),this, | 263 | i18n("Beam selected via IR"),this, |
262 | SLOT(beamSelected()),true); | 264 | SLOT(beamSelected()),true); |
263 | #endif | 265 | #endif |
264 | /* | 266 | /* |
265 | mPopupMenu = new QPopupMenu; | 267 | mPopupMenu = new QPopupMenu; |
266 | mPopupMenu->insertItem(i18n("Edit Event"), this, | 268 | mPopupMenu->insertItem(i18n("Edit Event"), this, |
267 | SLOT (editEvent())); | 269 | SLOT (editEvent())); |
268 | mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this, | 270 | mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this, |
269 | SLOT (deleteEvent())); | 271 | SLOT (deleteEvent())); |
270 | mPopupMenu->insertSeparator(); | 272 | mPopupMenu->insertSeparator(); |
271 | mPopupMenu->insertItem(i18n("Show Dates"), this, | 273 | mPopupMenu->insertItem(i18n("Show Dates"), this, |
272 | SLOT(showDates())); | 274 | SLOT(showDates())); |
273 | mPopupMenu->insertItem(i18n("Hide Dates"), this, | 275 | mPopupMenu->insertItem(i18n("Hide Dates"), this, |
274 | SLOT(hideDates())); | 276 | SLOT(hideDates())); |
275 | */ | 277 | */ |
276 | QObject::connect(mListView,SIGNAL( newEvent()), | 278 | QObject::connect(mListView,SIGNAL( newEvent()), |
277 | this,SIGNAL(signalNewEvent())); | 279 | this,SIGNAL(signalNewEvent())); |
278 | QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)), | 280 | QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)), |
279 | this,SLOT(defaultItemAction(QListViewItem *))); | 281 | this,SLOT(defaultItemAction(QListViewItem *))); |
280 | QObject::connect(mListView,SIGNAL(rightButtonClicked ( QListViewItem *, | 282 | QObject::connect(mListView,SIGNAL(rightButtonClicked ( QListViewItem *, |
281 | const QPoint &, int )), | 283 | const QPoint &, int )), |
282 | this,SLOT(popupMenu(QListViewItem *,const QPoint &,int))); | 284 | this,SLOT(popupMenu(QListViewItem *,const QPoint &,int))); |
283 | QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)), | 285 | QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)), |
284 | SLOT(processSelectionChange(QListViewItem *))); | 286 | SLOT(processSelectionChange(QListViewItem *))); |
285 | QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)), | 287 | QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)), |
286 | SIGNAL(showIncidenceSignal(Incidence *)) ); | 288 | SIGNAL(showIncidenceSignal(Incidence *)) ); |
287 | 289 | ||
288 | readSettings(KOGlobals::config(),"KOListView Layout"); | 290 | readSettings(KOGlobals::config(),"KOListView Layout"); |
289 | } | 291 | } |
290 | 292 | ||
291 | KOListView::~KOListView() | 293 | KOListView::~KOListView() |
292 | { | 294 | { |
293 | delete mPopupMenu; | 295 | delete mPopupMenu; |
294 | } | 296 | } |
295 | 297 | ||
296 | void KOListView::updateList() | 298 | void KOListView::updateList() |
297 | { | 299 | { |
298 | // qDebug(" KOListView::updateList() "); | 300 | // qDebug(" KOListView::updateList() "); |
299 | 301 | ||
300 | } | 302 | } |
301 | 303 | ||
302 | void KOListView::addCat( ) | 304 | void KOListView::addCat( ) |
303 | { | 305 | { |
304 | setCategories( false ); | 306 | setCategories( false ); |
305 | } | 307 | } |
306 | void KOListView::setCat() | 308 | void KOListView::setCat() |
307 | { | 309 | { |
308 | setCategories( true ); | 310 | setCategories( true ); |
309 | } | 311 | } |
310 | void KOListView::setCategories( bool removeOld ) | 312 | void KOListView::setCategories( bool removeOld ) |
311 | { | 313 | { |
312 | 314 | ||
313 | KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); | 315 | KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); |
314 | if (! csd->exec()) { | 316 | if (! csd->exec()) { |
315 | delete csd; | 317 | delete csd; |
316 | return; | 318 | return; |
317 | } | 319 | } |
318 | QStringList catList = csd->selectedCategories(); | 320 | QStringList catList = csd->selectedCategories(); |
319 | delete csd; | 321 | delete csd; |
320 | // if ( catList.count() == 0 ) | 322 | // if ( catList.count() == 0 ) |
321 | // return; | 323 | // return; |
322 | catList.sort(); | 324 | catList.sort(); |
323 | QString categoriesStr = catList.join(","); | 325 | QString categoriesStr = catList.join(","); |
324 | int i; | 326 | int i; |
325 | QStringList itemList; | 327 | QStringList itemList; |
326 | QPtrList<KOListViewItem> sel ; | 328 | QPtrList<KOListViewItem> sel ; |
327 | QListViewItem *qitem = mListView->firstChild (); | 329 | QListViewItem *qitem = mListView->firstChild (); |
328 | while ( qitem ) { | 330 | while ( qitem ) { |
329 | if ( qitem->isSelected() ) { | 331 | if ( qitem->isSelected() ) { |
330 | sel.append(((KOListViewItem *)qitem)); | 332 | sel.append(((KOListViewItem *)qitem)); |
331 | } | 333 | } |
332 | qitem = qitem->nextSibling(); | 334 | qitem = qitem->nextSibling(); |
333 | } | 335 | } |
334 | KOListViewItem * item, *temp; | 336 | KOListViewItem * item, *temp; |
335 | item = sel.first(); | 337 | item = sel.first(); |
336 | Incidence* inc; | 338 | Incidence* inc; |
337 | while ( item ) { | 339 | while ( item ) { |
338 | inc = item->data(); | 340 | inc = item->data(); |
339 | if ( removeOld ) { | 341 | if ( removeOld ) { |
340 | inc->setCategories( categoriesStr ); | 342 | inc->setCategories( categoriesStr ); |
341 | } else { | 343 | } else { |
342 | itemList = QStringList::split (",", inc->categoriesStr() ); | 344 | itemList = QStringList::split (",", inc->categoriesStr() ); |
343 | for( i = 0; i< catList.count(); ++i ) { | 345 | for( i = 0; i< catList.count(); ++i ) { |
344 | if ( !itemList.contains (catList[i])) | 346 | if ( !itemList.contains (catList[i])) |
345 | itemList.append( catList[i] ); | 347 | itemList.append( catList[i] ); |
346 | } | 348 | } |
347 | itemList.sort(); | 349 | itemList.sort(); |
348 | inc->setCategories( itemList.join(",") ); | 350 | inc->setCategories( itemList.join(",") ); |
349 | } | 351 | } |
350 | temp = item; | 352 | temp = item; |
351 | item = sel.next(); | 353 | item = sel.next(); |
352 | mUidDict.remove( inc->uid() ); | 354 | mUidDict.remove( inc->uid() ); |
353 | delete temp;; | 355 | delete temp;; |
354 | addIncidence( inc ); | 356 | addIncidence( inc ); |
355 | } | 357 | } |
356 | } | 358 | } |
357 | 359 | ||
358 | void KOListView::beamSelected() | 360 | void KOListView::beamSelected() |
359 | { | 361 | { |
360 | int icount = 0; | 362 | int icount = 0; |
361 | QPtrList<Incidence> delSel ; | 363 | QPtrList<Incidence> delSel ; |
362 | QListViewItem *item = mListView->firstChild (); | 364 | QListViewItem *item = mListView->firstChild (); |
363 | while ( item ) { | 365 | while ( item ) { |
364 | if ( item->isSelected() ) { | 366 | if ( item->isSelected() ) { |
365 | delSel.append(((KOListViewItem *)item)->data()); | 367 | delSel.append(((KOListViewItem *)item)->data()); |
366 | ++icount; | 368 | ++icount; |
367 | } | 369 | } |
368 | 370 | ||
369 | item = item->nextSibling(); | 371 | item = item->nextSibling(); |
370 | } | 372 | } |
371 | if ( icount ) { | 373 | if ( icount ) { |
372 | emit beamIncidenceList( delSel ); | 374 | emit beamIncidenceList( delSel ); |
373 | return; | 375 | return; |
374 | QString fn ; | 376 | QString fn ; |
375 | fn = QDir::homeDirPath()+"/kopitempbeamfile.vcs"; | 377 | fn = QDir::homeDirPath()+"/kopitempbeamfile.vcs"; |
376 | QString mes; | 378 | QString mes; |
377 | bool createbup = true; | 379 | bool createbup = true; |
378 | if ( createbup ) { | 380 | if ( createbup ) { |
379 | QString description = "\n"; | 381 | QString description = "\n"; |
380 | CalendarLocal* cal = new CalendarLocal(); | 382 | CalendarLocal* cal = new CalendarLocal(); |
381 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 383 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
382 | Incidence *incidence = delSel.first(); | 384 | Incidence *incidence = delSel.first(); |
383 | while ( incidence ) { | 385 | while ( incidence ) { |
384 | Incidence *in = incidence->clone(); | 386 | Incidence *in = incidence->clone(); |
385 | description += in->summary() + "\n"; | 387 | description += in->summary() + "\n"; |
386 | cal->addIncidence( in ); | 388 | cal->addIncidence( in ); |
387 | incidence = delSel.next(); | 389 | incidence = delSel.next(); |
388 | } | 390 | } |
389 | FileStorage storage( cal, fn, new VCalFormat ); | 391 | FileStorage storage( cal, fn, new VCalFormat ); |
390 | storage.save(); | 392 | storage.save(); |
391 | delete cal; | 393 | delete cal; |
392 | mes = i18n("KO/Pi: Ready for beaming"); | 394 | mes = i18n("KO/Pi: Ready for beaming"); |
393 | topLevelWidget()->setCaption(mes); | 395 | topLevelWidget()->setCaption(mes); |
394 | 396 | ||
395 | #ifndef DESKTOP_VERSION | 397 | #ifndef DESKTOP_VERSION |
396 | Ir *ir = new Ir( this ); | 398 | Ir *ir = new Ir( this ); |
397 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 399 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
398 | ir->send( fn, description, "text/x-vCalendar" ); | 400 | ir->send( fn, description, "text/x-vCalendar" ); |
399 | #endif | 401 | #endif |
400 | } | 402 | } |
401 | } | 403 | } |
402 | } | 404 | } |
403 | void KOListView::beamDone( Ir *ir ) | 405 | void KOListView::beamDone( Ir *ir ) |
404 | { | 406 | { |
405 | #ifndef DESKTOP_VERSION | 407 | #ifndef DESKTOP_VERSION |
406 | delete ir; | 408 | delete ir; |
407 | #endif | 409 | #endif |
408 | topLevelWidget()->setCaption(i18n("KO/Pi:Beaming done")); | 410 | topLevelWidget()->setCaption(i18n("KO/Pi:Beaming done")); |
409 | } | 411 | } |
410 | 412 | ||
411 | void KOListView::saveDescriptionToFile() | 413 | void KOListView::saveDescriptionToFile() |
412 | { | 414 | { |
413 | 415 | ||
414 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 416 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
415 | i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."), | 417 | i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."), |
416 | i18n("Continue"), i18n("Cancel"), 0, | 418 | i18n("Continue"), i18n("Cancel"), 0, |
417 | 0, 1 ); | 419 | 0, 1 ); |
418 | if ( result != 0 ) { | 420 | if ( result != 0 ) { |
419 | return; | 421 | return; |
420 | } | 422 | } |
421 | int icount = 0; | 423 | int icount = 0; |
422 | QPtrList<Incidence> delSel ; | 424 | QPtrList<Incidence> delSel ; |
423 | QListViewItem *item = mListView->firstChild (); | 425 | QListViewItem *item = mListView->firstChild (); |
424 | while ( item ) { | 426 | while ( item ) { |
425 | if ( item->isSelected() ) { | 427 | if ( item->isSelected() ) { |
426 | delSel.append(((KOListViewItem *)item)->data()); | 428 | delSel.append(((KOListViewItem *)item)->data()); |
427 | ++icount; | 429 | ++icount; |
428 | } | 430 | } |
429 | 431 | ||
430 | item = item->nextSibling(); | 432 | item = item->nextSibling(); |
431 | } | 433 | } |
432 | if ( icount ) { | 434 | if ( icount ) { |
433 | QString fn = KOPrefs::instance()->mLastSaveFile; | 435 | QString fn = KOPrefs::instance()->mLastSaveFile; |
434 | fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); | 436 | fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); |
435 | 437 | ||
436 | if ( fn == "" ) | 438 | if ( fn == "" ) |
437 | return; | 439 | return; |
438 | QFileInfo info; | 440 | QFileInfo info; |
439 | info.setFile( fn ); | 441 | info.setFile( fn ); |
440 | QString mes; | 442 | QString mes; |
441 | bool createbup = true; | 443 | bool createbup = true; |
442 | if ( info. exists() ) { | 444 | if ( info. exists() ) { |
443 | mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); | 445 | mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); |
444 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 446 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
445 | i18n("Overwrite!"), i18n("Cancel"), 0, | 447 | i18n("Overwrite!"), i18n("Cancel"), 0, |
446 | 0, 1 ); | 448 | 0, 1 ); |
447 | if ( result != 0 ) { | 449 | if ( result != 0 ) { |
448 | createbup = false; | 450 | createbup = false; |
449 | } | 451 | } |
450 | } | 452 | } |
451 | if ( createbup ) { | 453 | if ( createbup ) { |
452 | QString text = i18n("KO/Pi Description/Journal save file.\nSave date: ") + | 454 | QString text = i18n("KO/Pi Description/Journal save file.\nSave date: ") + |
453 | KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), false); | 455 | KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), false); |
454 | Incidence *incidence = delSel.first(); | 456 | Incidence *incidence = delSel.first(); |
455 | icount = 0; | 457 | icount = 0; |
456 | while ( incidence ) { | 458 | while ( incidence ) { |
457 | if ( incidence->type() == "Journal" ) { | 459 | if ( incidence->type() == "Journal" ) { |
458 | text += "\n************************************\n"; | 460 | text += "\n************************************\n"; |
459 | text += i18n("Journal from: ") +incidence->dtStartDateStr( false ); | 461 | text += i18n("Journal from: ") +incidence->dtStartDateStr( false ); |
460 | text +="\n" + i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); | 462 | text +="\n" + i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); |
461 | text +="\n" + i18n("Description: ") + "\n"+ incidence->description(); | 463 | text +="\n" + i18n("Description: ") + "\n"+ incidence->description(); |
462 | ++icount; | 464 | ++icount; |
463 | 465 | ||
464 | } else { | 466 | } else { |
465 | if ( !incidence->description().isEmpty() ) { | 467 | if ( !incidence->description().isEmpty() ) { |
466 | text += "\n************************************\n"; | 468 | text += "\n************************************\n"; |
467 | if ( incidence->type() == "Todo" ) | 469 | if ( incidence->type() == "Todo" ) |
468 | text += i18n("To-Do: "); | 470 | text += i18n("To-Do: "); |
469 | text += incidence->summary(); | 471 | text += incidence->summary(); |
470 | if ( incidence->hasStartDate() ) | 472 | if ( incidence->hasStartDate() ) |
471 | text +="\n"+ i18n("Start Date: ") + incidence->dtStartStr( false ); | 473 | text +="\n"+ i18n("Start Date: ") + incidence->dtStartStr( false ); |
472 | text +="\n"+ i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); | 474 | text +="\n"+ i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); |
473 | if ( !incidence->location().isEmpty() ) | 475 | if ( !incidence->location().isEmpty() ) |
474 | text += "\n" +i18n("Location: ") + incidence->location(); | 476 | text += "\n" +i18n("Location: ") + incidence->location(); |
475 | text += "\n" + i18n("Description: ") + "\n" + incidence->description(); | 477 | text += "\n" + i18n("Description: ") + "\n" + incidence->description(); |
476 | ++icount; | 478 | ++icount; |
477 | 479 | ||
478 | } | 480 | } |
479 | } | 481 | } |
480 | incidence = delSel.next(); | 482 | incidence = delSel.next(); |
481 | } | 483 | } |
482 | QFile file( fn ); | 484 | QFile file( fn ); |
483 | if (!file.open( IO_WriteOnly ) ) { | 485 | if (!file.open( IO_WriteOnly ) ) { |
484 | topLevelWidget()->setCaption(i18n("File open error - nothing saved!") ); | 486 | topLevelWidget()->setCaption(i18n("File open error - nothing saved!") ); |
485 | return; | 487 | return; |
486 | } | 488 | } |
487 | QTextStream ts( &file ); | 489 | QTextStream ts( &file ); |
488 | ts << text; | 490 | ts << text; |
489 | file.close(); | 491 | file.close(); |
490 | //qDebug("%s ", text.latin1()); | 492 | //qDebug("%s ", text.latin1()); |
491 | mes = i18n("KO/Pi:Saved %1 descriptions/journals").arg(icount ); | 493 | mes = i18n("KO/Pi:Saved %1 descriptions/journals").arg(icount ); |
492 | KOPrefs::instance()->mLastSaveFile = fn; | 494 | KOPrefs::instance()->mLastSaveFile = fn; |
493 | topLevelWidget()->setCaption(mes); | 495 | topLevelWidget()->setCaption(mes); |
494 | } | 496 | } |
495 | } | 497 | } |
496 | } | 498 | } |
497 | void KOListView::saveToFile() | 499 | void KOListView::saveToFile() |