-rw-r--r-- | kaddressbook/views/contactlistview.cpp | 4 | ||||
-rw-r--r-- | kmicromail/koprefs.cpp | 12 | ||||
-rw-r--r-- | kmicromail/koprefs.h | 2 | ||||
-rw-r--r-- | korganizer/calendarview.cpp | 12 | ||||
-rw-r--r-- | korganizer/kolistview.cpp | 5 | ||||
-rw-r--r-- | korganizer/koprefs.cpp | 15 | ||||
-rw-r--r-- | korganizer/koprefs.h | 9 | ||||
-rw-r--r-- | libkdepim/kpimglobalprefs.cpp | 2 | ||||
-rw-r--r-- | microkde/kdecore/klocale.cpp | 50 |
9 files changed, 42 insertions, 69 deletions
diff --git a/kaddressbook/views/contactlistview.cpp b/kaddressbook/views/contactlistview.cpp index 5fb4163..ad43970 100644 --- a/kaddressbook/views/contactlistview.cpp +++ b/kaddressbook/views/contactlistview.cpp | |||
@@ -1,373 +1,373 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressBook. | 2 | This file is part of KAddressBook. |
3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> | 3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <qheader.h> | 24 | #include <qheader.h> |
25 | #include <qiconset.h> | 25 | #include <qiconset.h> |
26 | #include <qimage.h> | 26 | #include <qimage.h> |
27 | #include <qdragobject.h> | 27 | #include <qdragobject.h> |
28 | #include <qcombobox.h> | 28 | #include <qcombobox.h> |
29 | #include <qpainter.h> | 29 | #include <qpainter.h> |
30 | #include <qbrush.h> | 30 | #include <qbrush.h> |
31 | #include <qevent.h> | 31 | #include <qevent.h> |
32 | 32 | ||
33 | #include <klocale.h> | 33 | #include <klocale.h> |
34 | #include <kglobalsettings.h> | 34 | #include <kglobalsettings.h> |
35 | #include <kiconloader.h> | 35 | #include <kiconloader.h> |
36 | #include <kdebug.h> | 36 | #include <kdebug.h> |
37 | #include <kconfig.h> | 37 | #include <kconfig.h> |
38 | #include <kapplication.h> | 38 | #include <kapplication.h> |
39 | #include <kurl.h> | 39 | #include <kurl.h> |
40 | 40 | ||
41 | #include "kaddressbooktableview.h" | 41 | #include "kaddressbooktableview.h" |
42 | 42 | ||
43 | #include "contactlistview.h" | 43 | #include "contactlistview.h" |
44 | 44 | ||
45 | ///////////////////////////////// | 45 | ///////////////////////////////// |
46 | // DynamicTip Methods | 46 | // DynamicTip Methods |
47 | 47 | ||
48 | DynamicTip::DynamicTip( ContactListView *parent) | 48 | DynamicTip::DynamicTip( ContactListView *parent) |
49 | : QToolTip( parent ) | 49 | : QToolTip( parent ) |
50 | { | 50 | { |
51 | } | 51 | } |
52 | 52 | ||
53 | void DynamicTip::maybeTip( const QPoint &pos ) | 53 | void DynamicTip::maybeTip( const QPoint &pos ) |
54 | { | 54 | { |
55 | static bool ishidden = true; | 55 | static bool ishidden = true; |
56 | if (!parentWidget()->inherits( "ContactListView" )) | 56 | if (!parentWidget()->inherits( "ContactListView" )) |
57 | return; | 57 | return; |
58 | 58 | ||
59 | ContactListView *plv = (ContactListView*)parentWidget(); | 59 | ContactListView *plv = (ContactListView*)parentWidget(); |
60 | if (!plv->tooltips()) | 60 | if (!plv->tooltips()) |
61 | return; | 61 | return; |
62 | 62 | ||
63 | QPoint posVp = plv->viewport()->pos(); | 63 | QPoint posVp = plv->viewport()->pos(); |
64 | 64 | ||
65 | QListViewItem *lvi = plv->itemAt( pos - posVp ); | 65 | QListViewItem *lvi = plv->itemAt( pos - posVp ); |
66 | if (!lvi) | 66 | if (!lvi) |
67 | return; | 67 | return; |
68 | 68 | ||
69 | #ifndef KAB_EMBEDDED | 69 | #ifndef KAB_EMBEDDED |
70 | ContactListViewItem *plvi = dynamic_cast< ContactListViewItem* >(lvi); | 70 | ContactListViewItem *plvi = dynamic_cast< ContactListViewItem* >(lvi); |
71 | #else //KAB_EMBEDDED | 71 | #else //KAB_EMBEDDED |
72 | ContactListViewItem *plvi = (ContactListViewItem*)(lvi); | 72 | ContactListViewItem *plvi = (ContactListViewItem*)(lvi); |
73 | #endif //KAB_EMBEDDED | 73 | #endif //KAB_EMBEDDED |
74 | 74 | ||
75 | if (!plvi) | 75 | if (!plvi) |
76 | return; | 76 | return; |
77 | 77 | ||
78 | if (ishidden) { | 78 | if (ishidden) { |
79 | QString s; | 79 | QString s; |
80 | QRect r = plv->itemRect( lvi ); | 80 | QRect r = plv->itemRect( lvi ); |
81 | r.moveBy( posVp.x(), posVp.y() ); | 81 | r.moveBy( posVp.x(), posVp.y() ); |
82 | 82 | ||
83 | //kdDebug() << "Tip rec: " << r.x() << "," << r.y() << "," << r.width() | 83 | //kdDebug() << "Tip rec: " << r.x() << "," << r.y() << "," << r.width() |
84 | // << "," << r.height() << endl; | 84 | // << "," << r.height() << endl; |
85 | 85 | ||
86 | KABC::Addressee a = plvi->addressee(); | 86 | KABC::Addressee a = plvi->addressee(); |
87 | if (a.isEmpty()) | 87 | if (a.isEmpty()) |
88 | return; | 88 | return; |
89 | 89 | ||
90 | s += i18n("label: value", "%1: %2").arg(a.formattedNameLabel()) | 90 | s += i18n("label: value", "%1: %2").arg(a.formattedNameLabel()) |
91 | .arg(a.formattedName()); | 91 | .arg(a.formattedName()); |
92 | 92 | ||
93 | s += '\n'; | 93 | s += '\n'; |
94 | s += i18n("label: value", "%1: %2").arg(a.organizationLabel()) | 94 | s += i18n("label: value", "%1: %2").arg(a.organizationLabel()) |
95 | .arg(a.organization()); | 95 | .arg(a.organization()); |
96 | 96 | ||
97 | QString notes = a.note().stripWhiteSpace(); | 97 | QString notes = a.note().stripWhiteSpace(); |
98 | if ( !notes.isEmpty() ) { | 98 | if ( !notes.isEmpty() ) { |
99 | notes += '\n'; | 99 | notes += '\n'; |
100 | s += '\n' + i18n("label: value", "%1: \n").arg(a.noteLabel()); | 100 | s += '\n' + i18n("label: value", "%1: \n").arg(a.noteLabel()); |
101 | QFontMetrics fm( font() ); | 101 | QFontMetrics fm( font() ); |
102 | 102 | ||
103 | // Begin word wrap code based on QMultiLineEdit code | 103 | // Begin word wrap code based on QMultiLineEdit code |
104 | int i = 0; | 104 | int i = 0; |
105 | bool doBreak = false; | 105 | bool doBreak = false; |
106 | int linew = 0; | 106 | int linew = 0; |
107 | int lastSpace = -1; | 107 | int lastSpace = -1; |
108 | int a = 0; | 108 | int a = 0; |
109 | int lastw = 0; | 109 | int lastw = 0; |
110 | 110 | ||
111 | while ( i < int(notes.length()) ) { | 111 | while ( i < int(notes.length()) ) { |
112 | doBreak = FALSE; | 112 | doBreak = FALSE; |
113 | if ( notes[i] != '\n' ) | 113 | if ( notes[i] != '\n' ) |
114 | linew += fm.width( notes[i] ); | 114 | linew += fm.width( notes[i] ); |
115 | 115 | ||
116 | if ( lastSpace >= a && notes[i] != '\n' ) | 116 | if ( lastSpace >= a && notes[i] != '\n' ) |
117 | if (linew >= parentWidget()->width()) { | 117 | if (linew >= parentWidget()->width()) { |
118 | doBreak = TRUE; | 118 | doBreak = TRUE; |
119 | if ( lastSpace > a ) { | 119 | if ( lastSpace > a ) { |
120 | i = lastSpace; | 120 | i = lastSpace; |
121 | linew = lastw; | 121 | linew = lastw; |
122 | } | 122 | } |
123 | else | 123 | else |
124 | i = QMAX( a, i-1 ); | 124 | i = QMAX( a, i-1 ); |
125 | } | 125 | } |
126 | 126 | ||
127 | if ( notes[i] == '\n' || doBreak ) { | 127 | if ( notes[i] == '\n' || doBreak ) { |
128 | s += notes.mid( a, i - a + (doBreak?1:0) ) +"\n"; | 128 | s += notes.mid( a, i - a + (doBreak?1:0) ) +"\n"; |
129 | 129 | ||
130 | a = i + 1; | 130 | a = i + 1; |
131 | lastSpace = a; | 131 | lastSpace = a; |
132 | linew = 0; | 132 | linew = 0; |
133 | } | 133 | } |
134 | 134 | ||
135 | if ( notes[i].isSpace() ) { | 135 | if ( notes[i].isSpace() ) { |
136 | lastSpace = i; | 136 | lastSpace = i; |
137 | lastw = linew; | 137 | lastw = linew; |
138 | } | 138 | } |
139 | 139 | ||
140 | if ( lastSpace <= a ) { | 140 | if ( lastSpace <= a ) { |
141 | lastw = linew; | 141 | lastw = linew; |
142 | } | 142 | } |
143 | 143 | ||
144 | ++i; | 144 | ++i; |
145 | } | 145 | } |
146 | } | 146 | } |
147 | 147 | ||
148 | tip( r, s ); | 148 | tip( r, s ); |
149 | } | 149 | } |
150 | else | 150 | else |
151 | hide(); | 151 | hide(); |
152 | ishidden = !ishidden; | 152 | ishidden = !ishidden; |
153 | 153 | ||
154 | } | 154 | } |
155 | 155 | ||
156 | /////////////////////////// | 156 | /////////////////////////// |
157 | // ContactListViewItem Methods | 157 | // ContactListViewItem Methods |
158 | 158 | ||
159 | ContactListViewItem::ContactListViewItem(const KABC::Addressee &a, | 159 | ContactListViewItem::ContactListViewItem(const KABC::Addressee &a, |
160 | ContactListView *parent, | 160 | ContactListView *parent, |
161 | KABC::AddressBook *doc, | 161 | KABC::AddressBook *doc, |
162 | const KABC::Field::List &fields ) | 162 | const KABC::Field::List &fields ) |
163 | : KListViewItem(parent), mAddressee(a), mFields( fields ), | 163 | : KListViewItem(parent), mAddressee(a), mFields( fields ), |
164 | parentListView( parent ), mDocument(doc) | 164 | parentListView( parent ), mDocument(doc) |
165 | { | 165 | { |
166 | refresh(); | 166 | refresh(); |
167 | } | 167 | } |
168 | 168 | ||
169 | QString ContactListViewItem::key(int column, bool ascending) const | 169 | QString ContactListViewItem::key(int column, bool ascending) const |
170 | { | 170 | { |
171 | #ifndef DESKTOP_VERSION | 171 | #ifndef DESKTOP_VERSION |
172 | int lan = KGlobal::locale()->language(); | 172 | int lan = KGlobal::locale()->language(); |
173 | //qDebug("language %d ", lan); | 173 | //qDebug("language %d ", lan); |
174 | if ( lan == 1 ) { //GERMAN | 174 | if ( lan == 1 ) { //GERMAN |
175 | QString ret = QListViewItem::key(column, ascending).utf8(); | 175 | QString ret = QListViewItem::key(column, ascending).lower().utf8(); |
176 | int start = -1; | 176 | int start = -1; |
177 | while ( (start = ret.find( 'ä', start+1)) > 0 ) { | 177 | while ( (start = ret.find( 'ä', start+1)) > 0 ) { |
178 | ret.at(start-1) = 'a'; | 178 | ret.at(start-1) = 'a'; |
179 | } | 179 | } |
180 | start = -1; | 180 | start = -1; |
181 | while ( (start = ret.find( 'ö', start+1)) > 0 ) { | 181 | while ( (start = ret.find( 'ö', start+1)) > 0 ) { |
182 | ret.at(start-1) = 'o'; | 182 | ret.at(start-1) = 'o'; |
183 | } | 183 | } |
184 | start = -1; | 184 | start = -1; |
185 | while ( (start = ret.find( 'ü', start+1)) > 0 ) { | 185 | while ( (start = ret.find( 'ü', start+1)) > 0 ) { |
186 | ret.at(start-1) = 'o'; | 186 | ret.at(start-1) = 'o'; |
187 | } | 187 | } |
188 | start = -1; | 188 | start = -1; |
189 | while ( (start = ret.find( 'ß', start+1)) > 0 ) { | 189 | while ( (start = ret.find( 'ß', start+1)) > 0 ) { |
190 | ret.at(start-1) = 's'; | 190 | ret.at(start-1) = 's'; |
191 | } | 191 | } |
192 | //qDebug("conv string %s ", ret.latin1()); | 192 | qDebug("conv string %s ", ret.latin1()); |
193 | 193 | ||
194 | return ret; | 194 | return ret; |
195 | 195 | ||
196 | } | 196 | } |
197 | else | 197 | else |
198 | #endif | 198 | #endif |
199 | return QListViewItem::key(column, ascending).lower(); | 199 | return QListViewItem::key(column, ascending).lower(); |
200 | } | 200 | } |
201 | 201 | ||
202 | void ContactListViewItem::paintCell(QPainter * p, | 202 | void ContactListViewItem::paintCell(QPainter * p, |
203 | const QColorGroup & cg, | 203 | const QColorGroup & cg, |
204 | int column, | 204 | int column, |
205 | int width, | 205 | int width, |
206 | int align) | 206 | int align) |
207 | { | 207 | { |
208 | KListViewItem::paintCell(p, cg, column, width, align); | 208 | KListViewItem::paintCell(p, cg, column, width, align); |
209 | 209 | ||
210 | if ( !p ) | 210 | if ( !p ) |
211 | return; | 211 | return; |
212 | 212 | ||
213 | if (parentListView->singleLine()) { | 213 | if (parentListView->singleLine()) { |
214 | p->setPen( parentListView->alternateColor() ); | 214 | p->setPen( parentListView->alternateColor() ); |
215 | p->drawLine( 0, height() - 1, width, height() - 1 ); | 215 | p->drawLine( 0, height() - 1, width, height() - 1 ); |
216 | } | 216 | } |
217 | } | 217 | } |
218 | 218 | ||
219 | 219 | ||
220 | ContactListView *ContactListViewItem::parent() | 220 | ContactListView *ContactListViewItem::parent() |
221 | { | 221 | { |
222 | return parentListView; | 222 | return parentListView; |
223 | } | 223 | } |
224 | 224 | ||
225 | 225 | ||
226 | void ContactListViewItem::refresh() | 226 | void ContactListViewItem::refresh() |
227 | { | 227 | { |
228 | // Update our addressee, since it may have changed else were | 228 | // Update our addressee, since it may have changed else were |
229 | mAddressee = mDocument->findByUid(mAddressee.uid()); | 229 | mAddressee = mDocument->findByUid(mAddressee.uid()); |
230 | if (mAddressee.isEmpty()) | 230 | if (mAddressee.isEmpty()) |
231 | return; | 231 | return; |
232 | 232 | ||
233 | int i = 0; | 233 | int i = 0; |
234 | KABC::Field::List::ConstIterator it; | 234 | KABC::Field::List::ConstIterator it; |
235 | for( it = mFields.begin(); it != mFields.end(); ++it ) { | 235 | for( it = mFields.begin(); it != mFields.end(); ++it ) { |
236 | setText( i++, (*it)->value( mAddressee ) ); | 236 | setText( i++, (*it)->value( mAddressee ) ); |
237 | } | 237 | } |
238 | } | 238 | } |
239 | 239 | ||
240 | /////////////////////////////// | 240 | /////////////////////////////// |
241 | // ContactListView | 241 | // ContactListView |
242 | 242 | ||
243 | ContactListView::ContactListView(KAddressBookTableView *view, | 243 | ContactListView::ContactListView(KAddressBookTableView *view, |
244 | KABC::AddressBook* /* doc */, | 244 | KABC::AddressBook* /* doc */, |
245 | QWidget *parent, | 245 | QWidget *parent, |
246 | const char *name ) | 246 | const char *name ) |
247 | : KListView( parent, name ), | 247 | : KListView( parent, name ), |
248 | pabWidget( view ), | 248 | pabWidget( view ), |
249 | oldColumn( 0 ) | 249 | oldColumn( 0 ) |
250 | { | 250 | { |
251 | mABackground = true; | 251 | mABackground = true; |
252 | mSingleLine = false; | 252 | mSingleLine = false; |
253 | mToolTips = true; | 253 | mToolTips = true; |
254 | #ifndef KAB_EMBEDDED | 254 | #ifndef KAB_EMBEDDED |
255 | mAlternateColor = KGlobalSettings::alternateBackgroundColor(); | 255 | mAlternateColor = KGlobalSettings::alternateBackgroundColor(); |
256 | #else //KAB_EMBEDDED | 256 | #else //KAB_EMBEDDED |
257 | mAlternateColor = QColor(240, 240, 240); | 257 | mAlternateColor = QColor(240, 240, 240); |
258 | #endif //KAB_EMBEDDED | 258 | #endif //KAB_EMBEDDED |
259 | 259 | ||
260 | setAlternateBackgroundEnabled(mABackground); | 260 | setAlternateBackgroundEnabled(mABackground); |
261 | setAcceptDrops( true ); | 261 | setAcceptDrops( true ); |
262 | viewport()->setAcceptDrops( true ); | 262 | viewport()->setAcceptDrops( true ); |
263 | setAllColumnsShowFocus( true ); | 263 | setAllColumnsShowFocus( true ); |
264 | setShowSortIndicator(true); | 264 | setShowSortIndicator(true); |
265 | 265 | ||
266 | setSelectionModeExt( KListView::Extended ); | 266 | setSelectionModeExt( KListView::Extended ); |
267 | setDropVisualizer(false); | 267 | setDropVisualizer(false); |
268 | // setFrameStyle(QFrame::NoFrame); | 268 | // setFrameStyle(QFrame::NoFrame); |
269 | //setLineWidth ( 0 ); | 269 | //setLineWidth ( 0 ); |
270 | //setMidLineWidth ( 0 ); | 270 | //setMidLineWidth ( 0 ); |
271 | //setMargin ( 0 ); | 271 | //setMargin ( 0 ); |
272 | #ifndef KAB_EMBEDDED | 272 | #ifndef KAB_EMBEDDED |
273 | connect(this, SIGNAL(dropped(QDropEvent*)), | 273 | connect(this, SIGNAL(dropped(QDropEvent*)), |
274 | this, SLOT(itemDropped(QDropEvent*))); | 274 | this, SLOT(itemDropped(QDropEvent*))); |
275 | #endif //KAB_EMBEDDED | 275 | #endif //KAB_EMBEDDED |
276 | 276 | ||
277 | 277 | ||
278 | new DynamicTip( this ); | 278 | new DynamicTip( this ); |
279 | } | 279 | } |
280 | 280 | ||
281 | void ContactListView::setAlternateColor(const QColor &m_AlternateColor) | 281 | void ContactListView::setAlternateColor(const QColor &m_AlternateColor) |
282 | { | 282 | { |
283 | mAlternateColor = m_AlternateColor; | 283 | mAlternateColor = m_AlternateColor; |
284 | } | 284 | } |
285 | 285 | ||
286 | void ContactListView::paintEmptyArea( QPainter * p, const QRect & rect ) | 286 | void ContactListView::paintEmptyArea( QPainter * p, const QRect & rect ) |
287 | { | 287 | { |
288 | QBrush b = palette().brush(QPalette::Active, QColorGroup::Base); | 288 | QBrush b = palette().brush(QPalette::Active, QColorGroup::Base); |
289 | 289 | ||
290 | // Get the brush, which will have the background pixmap if there is one. | 290 | // Get the brush, which will have the background pixmap if there is one. |
291 | if (b.pixmap()) | 291 | if (b.pixmap()) |
292 | { | 292 | { |
293 | p->drawTiledPixmap( rect.left(), rect.top(), rect.width(), rect.height(), | 293 | p->drawTiledPixmap( rect.left(), rect.top(), rect.width(), rect.height(), |
294 | *(b.pixmap()), | 294 | *(b.pixmap()), |
295 | rect.left() + contentsX(), | 295 | rect.left() + contentsX(), |
296 | rect.top() + contentsY() ); | 296 | rect.top() + contentsY() ); |
297 | } | 297 | } |
298 | 298 | ||
299 | else | 299 | else |
300 | { | 300 | { |
301 | // Do a normal paint | 301 | // Do a normal paint |
302 | KListView::paintEmptyArea(p, rect); | 302 | KListView::paintEmptyArea(p, rect); |
303 | } | 303 | } |
304 | } | 304 | } |
305 | 305 | ||
306 | void ContactListView::contentsMousePressEvent(QMouseEvent* e) | 306 | void ContactListView::contentsMousePressEvent(QMouseEvent* e) |
307 | { | 307 | { |
308 | presspos = e->pos(); | 308 | presspos = e->pos(); |
309 | KListView::contentsMousePressEvent(e); | 309 | KListView::contentsMousePressEvent(e); |
310 | } | 310 | } |
311 | 311 | ||
312 | 312 | ||
313 | // To initiate a drag operation | 313 | // To initiate a drag operation |
314 | void ContactListView::contentsMouseMoveEvent( QMouseEvent *e ) | 314 | void ContactListView::contentsMouseMoveEvent( QMouseEvent *e ) |
315 | { | 315 | { |
316 | if ((e->state() & LeftButton) && (e->pos() - presspos).manhattanLength() > 4 ) { | 316 | if ((e->state() & LeftButton) && (e->pos() - presspos).manhattanLength() > 4 ) { |
317 | emit startAddresseeDrag(); | 317 | emit startAddresseeDrag(); |
318 | } | 318 | } |
319 | else | 319 | else |
320 | KListView::contentsMouseMoveEvent( e ); | 320 | KListView::contentsMouseMoveEvent( e ); |
321 | } | 321 | } |
322 | 322 | ||
323 | bool ContactListView::acceptDrag(QDropEvent *e) const | 323 | bool ContactListView::acceptDrag(QDropEvent *e) const |
324 | { | 324 | { |
325 | #ifndef KAB_EMBEDDED | 325 | #ifndef KAB_EMBEDDED |
326 | return QTextDrag::canDecode(e); | 326 | return QTextDrag::canDecode(e); |
327 | #else //KAB_EMBEDDED | 327 | #else //KAB_EMBEDDED |
328 | qDebug("ContactListView::acceptDrag has to be fixed"); | 328 | qDebug("ContactListView::acceptDrag has to be fixed"); |
329 | return false; | 329 | return false; |
330 | #endif //KAB_EMBEDDED | 330 | #endif //KAB_EMBEDDED |
331 | } | 331 | } |
332 | 332 | ||
333 | void ContactListView::itemDropped(QDropEvent *e) | 333 | void ContactListView::itemDropped(QDropEvent *e) |
334 | { | 334 | { |
335 | contentsDropEvent(e); | 335 | contentsDropEvent(e); |
336 | } | 336 | } |
337 | 337 | ||
338 | void ContactListView::contentsDropEvent( QDropEvent *e ) | 338 | void ContactListView::contentsDropEvent( QDropEvent *e ) |
339 | { | 339 | { |
340 | emit addresseeDropped(e); | 340 | emit addresseeDropped(e); |
341 | } | 341 | } |
342 | 342 | ||
343 | void ContactListView::setAlternateBackgroundEnabled(bool enabled) | 343 | void ContactListView::setAlternateBackgroundEnabled(bool enabled) |
344 | { | 344 | { |
345 | mABackground = enabled; | 345 | mABackground = enabled; |
346 | 346 | ||
347 | if (mABackground) | 347 | if (mABackground) |
348 | { | 348 | { |
349 | setAlternateBackground(mAlternateColor); | 349 | setAlternateBackground(mAlternateColor); |
350 | } | 350 | } |
351 | else | 351 | else |
352 | { | 352 | { |
353 | setAlternateBackground(QColor()); | 353 | setAlternateBackground(QColor()); |
354 | } | 354 | } |
355 | } | 355 | } |
356 | 356 | ||
357 | void ContactListView::setBackgroundPixmap(const QString &filename) | 357 | void ContactListView::setBackgroundPixmap(const QString &filename) |
358 | { | 358 | { |
359 | if (filename.isEmpty()) | 359 | if (filename.isEmpty()) |
360 | { | 360 | { |
361 | unsetPalette(); | 361 | unsetPalette(); |
362 | } | 362 | } |
363 | else | 363 | else |
364 | { | 364 | { |
365 | qDebug("ContactListView::setBackgroundPixmap has to be verified"); | 365 | qDebug("ContactListView::setBackgroundPixmap has to be verified"); |
366 | //US setPaletteBackgroundPixmap(QPixmap(filename)); | 366 | //US setPaletteBackgroundPixmap(QPixmap(filename)); |
367 | KListView::setBackgroundPixmap((const QPixmap&)QPixmap(filename)); | 367 | KListView::setBackgroundPixmap((const QPixmap&)QPixmap(filename)); |
368 | } | 368 | } |
369 | 369 | ||
370 | } | 370 | } |
371 | #ifndef KAB_EMBEDDED | 371 | #ifndef KAB_EMBEDDED |
372 | #include "contactlistview.moc" | 372 | #include "contactlistview.moc" |
373 | #endif //KAB_EMBEDDED | 373 | #endif //KAB_EMBEDDED |
diff --git a/kmicromail/koprefs.cpp b/kmicromail/koprefs.cpp index c0200ff..8143b6f 100644 --- a/kmicromail/koprefs.cpp +++ b/kmicromail/koprefs.cpp | |||
@@ -1,128 +1,122 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <time.h> | 24 | #include <time.h> |
25 | #ifndef _WIN32_ | 25 | #ifndef _WIN32_ |
26 | #include <unistd.h> | 26 | #include <unistd.h> |
27 | #endif | 27 | #endif |
28 | #include <qdir.h> | 28 | #include <qdir.h> |
29 | #include <qtextstream.h> | 29 | #include <qtextstream.h> |
30 | #include <qtextcodec.h> | 30 | #include <qtextcodec.h> |
31 | #include <qstring.h> | 31 | #include <qstring.h> |
32 | #include <qregexp.h> | 32 | #include <qregexp.h> |
33 | #include <qfont.h> | 33 | #include <qfont.h> |
34 | #include <qcolor.h> | 34 | #include <qcolor.h> |
35 | #include <qstringlist.h> | 35 | #include <qstringlist.h> |
36 | #include <stdlib.h> | 36 | #include <stdlib.h> |
37 | 37 | ||
38 | #include <kglobal.h> | 38 | #include <kglobal.h> |
39 | #include <kconfig.h> | 39 | #include <kconfig.h> |
40 | #include <klocale.h> | 40 | #include <klocale.h> |
41 | #include <kdebug.h> | 41 | #include <kdebug.h> |
42 | #include <kemailsettings.h> | 42 | #include <kemailsettings.h> |
43 | #include <kstaticdeleter.h> | 43 | #include <kstaticdeleter.h> |
44 | 44 | ||
45 | #include "koprefs.h" | 45 | #include "koprefs.h" |
46 | #include "mainwindow.h" | 46 | #include "mainwindow.h" |
47 | 47 | ||
48 | 48 | ||
49 | KOPrefs *KOPrefs::mInstance = 0; | 49 | KOPrefs *KOPrefs::mInstance = 0; |
50 | static KStaticDeleter<KOPrefs> insd; | 50 | static KStaticDeleter<KOPrefs> insd; |
51 | 51 | ||
52 | KOPrefs::KOPrefs() : | 52 | KOPrefs::KOPrefs() : |
53 | KPimPrefs("kopiemailrc") | 53 | KPimPrefs("kopiemailrc") |
54 | { | 54 | { |
55 | mAppFont = QFont("helvetica",12); | 55 | mAppFont = QFont("helvetica",12); |
56 | mComposeFont = QFont("helvetica",12); | 56 | mComposeFont = QFont("helvetica",12); |
57 | mReadFont = QFont("helvetica",12); | 57 | mReadFont = QFont("helvetica",12); |
58 | 58 | ||
59 | KPrefs::setCurrentGroup("General"); | 59 | KPrefs::setCurrentGroup("General"); |
60 | addItemString("SenderName",&mName,i18n ("Please set at") ); | 60 | addItemString("SenderName",&mName,i18n ("Please set at") ); |
61 | addItemString("SenderEmail",&mEmail,i18n ("Settings@General TAB") ); | 61 | addItemString("SenderEmail",&mEmail,i18n ("Settings@General TAB") ); |
62 | addItemBool("ViewMailAsHtml",&mViewAsHtml,false); | 62 | addItemBool("ViewMailAsHtml",&mViewAsHtml,false); |
63 | addItemBool("SendMailLater",&mSendLater,true); | 63 | addItemBool("SendMailLater",&mSendLater,true); |
64 | addItemBool("UseKapi",&mUseKapi,false); | 64 | addItemBool("UseKapi",&mUseKapi,false); |
65 | 65 | ||
66 | KPrefs::setCurrentGroup("Fonts"); | 66 | KPrefs::setCurrentGroup("Fonts"); |
67 | addItemFont("Application Font",&mAppFont); | 67 | addItemFont("Application Font",&mAppFont); |
68 | addItemFont("Compose Font",&mComposeFont); | 68 | addItemFont("Compose Font",&mComposeFont); |
69 | addItemFont("Read Font",&mReadFont); | 69 | addItemFont("Read Font",&mReadFont); |
70 | 70 | fillMailDefaults(); | |
71 | 71 | ||
72 | } | 72 | } |
73 | 73 | ||
74 | 74 | ||
75 | KOPrefs::~KOPrefs() | 75 | KOPrefs::~KOPrefs() |
76 | { | 76 | { |
77 | if (mInstance == this) | 77 | if (mInstance == this) |
78 | mInstance = insd.setObject(0); | 78 | mInstance = insd.setObject(0); |
79 | 79 | ||
80 | } | 80 | } |
81 | 81 | ||
82 | 82 | ||
83 | KOPrefs *KOPrefs::instance() | 83 | KOPrefs *KOPrefs::instance() |
84 | { | 84 | { |
85 | if (!mInstance) { | 85 | if (!mInstance) { |
86 | mInstance = insd.setObject(new KOPrefs()); | 86 | mInstance = insd.setObject(new KOPrefs()); |
87 | mInstance->readConfig(); | 87 | mInstance->readConfig(); |
88 | } | 88 | } |
89 | 89 | ||
90 | return mInstance; | 90 | return mInstance; |
91 | } | 91 | } |
92 | 92 | ||
93 | void KOPrefs::usrSetDefaults() | 93 | void KOPrefs::usrSetDefaults() |
94 | { | 94 | { |
95 | 95 | ||
96 | } | 96 | } |
97 | 97 | ||
98 | void KOPrefs::fillMailDefaults() | 98 | void KOPrefs::fillMailDefaults() |
99 | { | 99 | { |
100 | if (mName.isEmpty()) mName = i18n("Anonymous"); | 100 | if (mName.isEmpty()) mName = i18n ("Please set at"); |
101 | if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere"); | 101 | if (mEmail.isEmpty()) mEmail = i18n ("Settings@General TAB"); |
102 | } | 102 | } |
103 | 103 | ||
104 | void KOPrefs::setTimeZoneIdDefault() | ||
105 | { | ||
106 | mTimeZoneId = i18n("+01:00 Europe/Oslo(CET)"); | ||
107 | } | ||
108 | |||
109 | |||
110 | void KOPrefs::usrReadConfig() | 104 | void KOPrefs::usrReadConfig() |
111 | { | 105 | { |
112 | 106 | ||
113 | KPimPrefs::usrReadConfig(); | 107 | KPimPrefs::usrReadConfig(); |
114 | } | 108 | } |
115 | 109 | ||
116 | 110 | ||
117 | void KOPrefs::usrWriteConfig() | 111 | void KOPrefs::usrWriteConfig() |
118 | { | 112 | { |
119 | 113 | ||
120 | KPimPrefs::usrWriteConfig(); | 114 | KPimPrefs::usrWriteConfig(); |
121 | } | 115 | } |
122 | 116 | ||
123 | 117 | ||
124 | 118 | ||
125 | KConfig* KOPrefs::getConfig() | 119 | KConfig* KOPrefs::getConfig() |
126 | { | 120 | { |
127 | return config(); | 121 | return config(); |
128 | } | 122 | } |
diff --git a/kmicromail/koprefs.h b/kmicromail/koprefs.h index c42d787..a47642b 100644 --- a/kmicromail/koprefs.h +++ b/kmicromail/koprefs.h | |||
@@ -1,81 +1,79 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | #ifndef KOPREFS_H | 23 | #ifndef KOPREFS_H |
24 | #define KOPREFS_H | 24 | #define KOPREFS_H |
25 | 25 | ||
26 | #include <qdict.h> | 26 | #include <qdict.h> |
27 | 27 | ||
28 | #include <libkdepim/kpimprefs.h> | 28 | #include <libkdepim/kpimprefs.h> |
29 | 29 | ||
30 | class KConfig; | 30 | class KConfig; |
31 | class QFont; | 31 | class QFont; |
32 | class QColor; | 32 | class QColor; |
33 | class QStringList; | 33 | class QStringList; |
34 | 34 | ||
35 | class KOPrefs : public KPimPrefs | 35 | class KOPrefs : public KPimPrefs |
36 | { | 36 | { |
37 | public: | 37 | public: |
38 | virtual ~KOPrefs(); | 38 | virtual ~KOPrefs(); |
39 | 39 | ||
40 | /** Get instance of KOPrefs. It is made sure that there is only one | 40 | /** Get instance of KOPrefs. It is made sure that there is only one |
41 | instance. */ | 41 | instance. */ |
42 | static KOPrefs *instance(); | 42 | static KOPrefs *instance(); |
43 | 43 | ||
44 | /** Set preferences to default values */ | 44 | /** Set preferences to default values */ |
45 | void usrSetDefaults(); | 45 | void usrSetDefaults(); |
46 | 46 | ||
47 | /** Read preferences from config file */ | 47 | /** Read preferences from config file */ |
48 | void usrReadConfig(); | 48 | void usrReadConfig(); |
49 | 49 | ||
50 | /** Write preferences to config file */ | 50 | /** Write preferences to config file */ |
51 | void usrWriteConfig(); | 51 | void usrWriteConfig(); |
52 | void setCategoryDefaults(){;}; | 52 | void setCategoryDefaults(){;}; |
53 | 53 | ||
54 | protected: | 54 | protected: |
55 | void setTimeZoneIdDefault(); | ||
56 | 55 | ||
57 | /** Fill empty mail fields with default values. */ | 56 | /** Fill empty mail fields with default values. */ |
58 | void fillMailDefaults(); | 57 | void fillMailDefaults(); |
59 | 58 | ||
60 | private: | 59 | private: |
61 | /** Constructor disabled for public. Use instance() to create a KOPrefs | 60 | /** Constructor disabled for public. Use instance() to create a KOPrefs |
62 | object. */ | 61 | object. */ |
63 | KOPrefs(); | 62 | KOPrefs(); |
64 | 63 | ||
65 | static KOPrefs *mInstance; | 64 | static KOPrefs *mInstance; |
66 | QDict<QString> *mLocaleDict; | 65 | QDict<QString> *mLocaleDict; |
67 | public: | 66 | public: |
68 | // preferences data | 67 | // preferences data |
69 | KConfig* getConfig(); | 68 | KConfig* getConfig(); |
70 | QFont mAppFont; | 69 | QFont mAppFont; |
71 | QFont mComposeFont; | 70 | QFont mComposeFont; |
72 | QFont mReadFont; | 71 | QFont mReadFont; |
73 | QFont mTimeZoneId; | ||
74 | QString mName; | 72 | QString mName; |
75 | QString mEmail; | 73 | QString mEmail; |
76 | bool mSendLater, mViewAsHtml, mUseKapi; | 74 | bool mSendLater, mViewAsHtml, mUseKapi; |
77 | private: | 75 | private: |
78 | 76 | ||
79 | }; | 77 | }; |
80 | 78 | ||
81 | #endif | 79 | #endif |
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 0306e07..e64d83a 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -434,2658 +434,2658 @@ void CalendarView::init() | |||
434 | 434 | ||
435 | 435 | ||
436 | 436 | ||
437 | 437 | ||
438 | 438 | ||
439 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), | 439 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), |
440 | SLOT(checkClipboard())); | 440 | SLOT(checkClipboard())); |
441 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), | 441 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), |
442 | SLOT( processTodoListSelection( Incidence * ) ) ); | 442 | SLOT( processTodoListSelection( Incidence * ) ) ); |
443 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); | 443 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); |
444 | 444 | ||
445 | // kdDebug() << "CalendarView::CalendarView() done" << endl; | 445 | // kdDebug() << "CalendarView::CalendarView() done" << endl; |
446 | 446 | ||
447 | mDateFrame = new QVBox(0,0,WType_Popup); | 447 | mDateFrame = new QVBox(0,0,WType_Popup); |
448 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 448 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
449 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); | 449 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); |
450 | mDateFrame->setLineWidth(3); | 450 | mDateFrame->setLineWidth(3); |
451 | mDateFrame->hide(); | 451 | mDateFrame->hide(); |
452 | mDateFrame->setCaption( i18n( "Pick a date to display")); | 452 | mDateFrame->setCaption( i18n( "Pick a date to display")); |
453 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); | 453 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); |
454 | 454 | ||
455 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); | 455 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); |
456 | 456 | ||
457 | mEventEditor = mDialogManager->getEventEditor(); | 457 | mEventEditor = mDialogManager->getEventEditor(); |
458 | mTodoEditor = mDialogManager->getTodoEditor(); | 458 | mTodoEditor = mDialogManager->getTodoEditor(); |
459 | 459 | ||
460 | mFlagEditDescription = false; | 460 | mFlagEditDescription = false; |
461 | 461 | ||
462 | mSuspendTimer = new QTimer( this ); | 462 | mSuspendTimer = new QTimer( this ); |
463 | mAlarmTimer = new QTimer( this ); | 463 | mAlarmTimer = new QTimer( this ); |
464 | mRecheckAlarmTimer = new QTimer( this ); | 464 | mRecheckAlarmTimer = new QTimer( this ); |
465 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); | 465 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); |
466 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); | 466 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); |
467 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); | 467 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); |
468 | mAlarmDialog = new AlarmDialog( this ); | 468 | mAlarmDialog = new AlarmDialog( this ); |
469 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); | 469 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); |
470 | mAlarmDialog->setServerNotification( false ); | 470 | mAlarmDialog->setServerNotification( false ); |
471 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); | 471 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); |
472 | 472 | ||
473 | 473 | ||
474 | #ifndef DESKTOP_VERSION | 474 | #ifndef DESKTOP_VERSION |
475 | //US listen for arriving address resultsets | 475 | //US listen for arriving address resultsets |
476 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), | 476 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), |
477 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); | 477 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); |
478 | #endif | 478 | #endif |
479 | 479 | ||
480 | } | 480 | } |
481 | 481 | ||
482 | 482 | ||
483 | CalendarView::~CalendarView() | 483 | CalendarView::~CalendarView() |
484 | { | 484 | { |
485 | // kdDebug() << "~CalendarView()" << endl; | 485 | // kdDebug() << "~CalendarView()" << endl; |
486 | //qDebug("CalendarView::~CalendarView() "); | 486 | //qDebug("CalendarView::~CalendarView() "); |
487 | delete mDialogManager; | 487 | delete mDialogManager; |
488 | delete mViewManager; | 488 | delete mViewManager; |
489 | delete mStorage; | 489 | delete mStorage; |
490 | delete mDateFrame ; | 490 | delete mDateFrame ; |
491 | delete beamDialog; | 491 | delete beamDialog; |
492 | //kdDebug() << "~CalendarView() done" << endl; | 492 | //kdDebug() << "~CalendarView() done" << endl; |
493 | } | 493 | } |
494 | void CalendarView::timerAlarm() | 494 | void CalendarView::timerAlarm() |
495 | { | 495 | { |
496 | //qDebug("CalendarView::timerAlarm() "); | 496 | //qDebug("CalendarView::timerAlarm() "); |
497 | computeAlarm(mAlarmNotification ); | 497 | computeAlarm(mAlarmNotification ); |
498 | } | 498 | } |
499 | 499 | ||
500 | void CalendarView::suspendAlarm() | 500 | void CalendarView::suspendAlarm() |
501 | { | 501 | { |
502 | //qDebug(" CalendarView::suspendAlarm() "); | 502 | //qDebug(" CalendarView::suspendAlarm() "); |
503 | computeAlarm(mSuspendAlarmNotification ); | 503 | computeAlarm(mSuspendAlarmNotification ); |
504 | 504 | ||
505 | } | 505 | } |
506 | 506 | ||
507 | void CalendarView::startAlarm( QString mess , QString filename) | 507 | void CalendarView::startAlarm( QString mess , QString filename) |
508 | { | 508 | { |
509 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); | 509 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); |
510 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); | 510 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); |
511 | 511 | ||
512 | } | 512 | } |
513 | 513 | ||
514 | void CalendarView::checkNextTimerAlarm() | 514 | void CalendarView::checkNextTimerAlarm() |
515 | { | 515 | { |
516 | mCalendar->checkAlarmForIncidence( 0, true ); | 516 | mCalendar->checkAlarmForIncidence( 0, true ); |
517 | } | 517 | } |
518 | 518 | ||
519 | void CalendarView::computeAlarm( QString msg ) | 519 | void CalendarView::computeAlarm( QString msg ) |
520 | { | 520 | { |
521 | 521 | ||
522 | QString mess = msg; | 522 | QString mess = msg; |
523 | QString mAlarmMessage = mess.mid( 9 ); | 523 | QString mAlarmMessage = mess.mid( 9 ); |
524 | QString filename = MainWindow::resourcePath(); | 524 | QString filename = MainWindow::resourcePath(); |
525 | filename += "koalarm.wav"; | 525 | filename += "koalarm.wav"; |
526 | QString tempfilename; | 526 | QString tempfilename; |
527 | if ( mess.left( 13 ) == "suspend_alarm") { | 527 | if ( mess.left( 13 ) == "suspend_alarm") { |
528 | bool error = false; | 528 | bool error = false; |
529 | int len = mess.mid( 13 ).find("+++"); | 529 | int len = mess.mid( 13 ).find("+++"); |
530 | if ( len < 2 ) | 530 | if ( len < 2 ) |
531 | error = true; | 531 | error = true; |
532 | else { | 532 | else { |
533 | tempfilename = mess.mid( 13, len ); | 533 | tempfilename = mess.mid( 13, len ); |
534 | if ( !QFile::exists( tempfilename ) ) | 534 | if ( !QFile::exists( tempfilename ) ) |
535 | error = true; | 535 | error = true; |
536 | } | 536 | } |
537 | if ( ! error ) { | 537 | if ( ! error ) { |
538 | filename = tempfilename; | 538 | filename = tempfilename; |
539 | } | 539 | } |
540 | mAlarmMessage = mess.mid( 13+len+3 ); | 540 | mAlarmMessage = mess.mid( 13+len+3 ); |
541 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 541 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
542 | startAlarm( mAlarmMessage, filename); | 542 | startAlarm( mAlarmMessage, filename); |
543 | return; | 543 | return; |
544 | } | 544 | } |
545 | if ( mess.left( 11 ) == "timer_alarm") { | 545 | if ( mess.left( 11 ) == "timer_alarm") { |
546 | //mTimerTime = 0; | 546 | //mTimerTime = 0; |
547 | startAlarm( mess.mid( 11 ), filename ); | 547 | startAlarm( mess.mid( 11 ), filename ); |
548 | return; | 548 | return; |
549 | } | 549 | } |
550 | if ( mess.left( 10 ) == "proc_alarm") { | 550 | if ( mess.left( 10 ) == "proc_alarm") { |
551 | bool error = false; | 551 | bool error = false; |
552 | int len = mess.mid( 10 ).find("+++"); | 552 | int len = mess.mid( 10 ).find("+++"); |
553 | if ( len < 2 ) | 553 | if ( len < 2 ) |
554 | error = true; | 554 | error = true; |
555 | else { | 555 | else { |
556 | tempfilename = mess.mid( 10, len ); | 556 | tempfilename = mess.mid( 10, len ); |
557 | if ( !QFile::exists( tempfilename ) ) | 557 | if ( !QFile::exists( tempfilename ) ) |
558 | error = true; | 558 | error = true; |
559 | } | 559 | } |
560 | if ( error ) { | 560 | if ( error ) { |
561 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | 561 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; |
562 | mAlarmMessage += mess.mid( 10+len+3+9 ); | 562 | mAlarmMessage += mess.mid( 10+len+3+9 ); |
563 | } else { | 563 | } else { |
564 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 564 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
565 | //qDebug("-----system command %s ",tempfilename.latin1() ); | 565 | //qDebug("-----system command %s ",tempfilename.latin1() ); |
566 | #ifndef _WIN32_ | 566 | #ifndef _WIN32_ |
567 | if ( vfork () == 0 ) { | 567 | if ( vfork () == 0 ) { |
568 | execl ( tempfilename.latin1(), 0 ); | 568 | execl ( tempfilename.latin1(), 0 ); |
569 | return; | 569 | return; |
570 | } | 570 | } |
571 | #else | 571 | #else |
572 | QProcess* p = new QProcess(); | 572 | QProcess* p = new QProcess(); |
573 | p->addArgument( tempfilename.latin1() ); | 573 | p->addArgument( tempfilename.latin1() ); |
574 | p->start(); | 574 | p->start(); |
575 | return; | 575 | return; |
576 | #endif | 576 | #endif |
577 | 577 | ||
578 | return; | 578 | return; |
579 | } | 579 | } |
580 | 580 | ||
581 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 581 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
582 | } | 582 | } |
583 | if ( mess.left( 11 ) == "audio_alarm") { | 583 | if ( mess.left( 11 ) == "audio_alarm") { |
584 | bool error = false; | 584 | bool error = false; |
585 | int len = mess.mid( 11 ).find("+++"); | 585 | int len = mess.mid( 11 ).find("+++"); |
586 | if ( len < 2 ) | 586 | if ( len < 2 ) |
587 | error = true; | 587 | error = true; |
588 | else { | 588 | else { |
589 | tempfilename = mess.mid( 11, len ); | 589 | tempfilename = mess.mid( 11, len ); |
590 | if ( !QFile::exists( tempfilename ) ) | 590 | if ( !QFile::exists( tempfilename ) ) |
591 | error = true; | 591 | error = true; |
592 | } | 592 | } |
593 | if ( ! error ) { | 593 | if ( ! error ) { |
594 | filename = tempfilename; | 594 | filename = tempfilename; |
595 | } | 595 | } |
596 | mAlarmMessage = mess.mid( 11+len+3+9 ); | 596 | mAlarmMessage = mess.mid( 11+len+3+9 ); |
597 | //qDebug("audio file command %s ",tempfilename.latin1() ); | 597 | //qDebug("audio file command %s ",tempfilename.latin1() ); |
598 | } | 598 | } |
599 | if ( mess.left( 9 ) == "cal_alarm") { | 599 | if ( mess.left( 9 ) == "cal_alarm") { |
600 | mAlarmMessage = mess.mid( 9 ) ; | 600 | mAlarmMessage = mess.mid( 9 ) ; |
601 | } | 601 | } |
602 | 602 | ||
603 | startAlarm( mAlarmMessage, filename ); | 603 | startAlarm( mAlarmMessage, filename ); |
604 | 604 | ||
605 | 605 | ||
606 | } | 606 | } |
607 | 607 | ||
608 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) | 608 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) |
609 | { | 609 | { |
610 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 610 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
611 | 611 | ||
612 | mSuspendAlarmNotification = noti; | 612 | mSuspendAlarmNotification = noti; |
613 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; | 613 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; |
614 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); | 614 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); |
615 | mSuspendTimer->start( ms , true ); | 615 | mSuspendTimer->start( ms , true ); |
616 | 616 | ||
617 | } | 617 | } |
618 | 618 | ||
619 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) | 619 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) |
620 | { | 620 | { |
621 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 621 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
622 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 622 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
623 | #ifndef DESKTOP_VERSION | 623 | #ifndef DESKTOP_VERSION |
624 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); | 624 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); |
625 | #endif | 625 | #endif |
626 | return; | 626 | return; |
627 | } | 627 | } |
628 | int maxSec; | 628 | int maxSec; |
629 | //maxSec = 5; //testing only | 629 | //maxSec = 5; //testing only |
630 | maxSec = 86400+3600; // one day+1hour | 630 | maxSec = 86400+3600; // one day+1hour |
631 | mAlarmNotification = noti; | 631 | mAlarmNotification = noti; |
632 | int sec = QDateTime::currentDateTime().secsTo( qdt ); | 632 | int sec = QDateTime::currentDateTime().secsTo( qdt ); |
633 | if ( sec > maxSec ) { | 633 | if ( sec > maxSec ) { |
634 | mRecheckAlarmTimer->start( maxSec * 1000 ); | 634 | mRecheckAlarmTimer->start( maxSec * 1000 ); |
635 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); | 635 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); |
636 | return; | 636 | return; |
637 | } else { | 637 | } else { |
638 | mRecheckAlarmTimer->stop(); | 638 | mRecheckAlarmTimer->stop(); |
639 | } | 639 | } |
640 | //qDebug("Alarm timer started with secs: %d ", sec); | 640 | //qDebug("Alarm timer started with secs: %d ", sec); |
641 | mAlarmTimer->start( sec *1000 , true ); | 641 | mAlarmTimer->start( sec *1000 , true ); |
642 | 642 | ||
643 | } | 643 | } |
644 | // called by mRecheckAlarmTimer to get next alarm | 644 | // called by mRecheckAlarmTimer to get next alarm |
645 | // we need this, because a QTimer has only a max range of 25 days | 645 | // we need this, because a QTimer has only a max range of 25 days |
646 | void CalendarView::recheckTimerAlarm() | 646 | void CalendarView::recheckTimerAlarm() |
647 | { | 647 | { |
648 | mAlarmTimer->stop(); | 648 | mAlarmTimer->stop(); |
649 | mRecheckAlarmTimer->stop(); | 649 | mRecheckAlarmTimer->stop(); |
650 | mCalendar->checkAlarmForIncidence( 0, true ); | 650 | mCalendar->checkAlarmForIncidence( 0, true ); |
651 | } | 651 | } |
652 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) | 652 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) |
653 | { | 653 | { |
654 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 654 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
655 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 655 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
656 | #ifndef DESKTOP_VERSION | 656 | #ifndef DESKTOP_VERSION |
657 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); | 657 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); |
658 | #endif | 658 | #endif |
659 | return; | 659 | return; |
660 | } | 660 | } |
661 | mAlarmTimer->stop(); | 661 | mAlarmTimer->stop(); |
662 | } | 662 | } |
663 | void CalendarView::selectWeekNum ( int num ) | 663 | void CalendarView::selectWeekNum ( int num ) |
664 | { | 664 | { |
665 | dateNavigator()->selectWeek( num ); | 665 | dateNavigator()->selectWeek( num ); |
666 | mViewManager->showWeekView(); | 666 | mViewManager->showWeekView(); |
667 | } | 667 | } |
668 | KOViewManager *CalendarView::viewManager() | 668 | KOViewManager *CalendarView::viewManager() |
669 | { | 669 | { |
670 | return mViewManager; | 670 | return mViewManager; |
671 | } | 671 | } |
672 | 672 | ||
673 | KODialogManager *CalendarView::dialogManager() | 673 | KODialogManager *CalendarView::dialogManager() |
674 | { | 674 | { |
675 | return mDialogManager; | 675 | return mDialogManager; |
676 | } | 676 | } |
677 | 677 | ||
678 | QDate CalendarView::startDate() | 678 | QDate CalendarView::startDate() |
679 | { | 679 | { |
680 | DateList dates = mNavigator->selectedDates(); | 680 | DateList dates = mNavigator->selectedDates(); |
681 | 681 | ||
682 | return dates.first(); | 682 | return dates.first(); |
683 | } | 683 | } |
684 | 684 | ||
685 | QDate CalendarView::endDate() | 685 | QDate CalendarView::endDate() |
686 | { | 686 | { |
687 | DateList dates = mNavigator->selectedDates(); | 687 | DateList dates = mNavigator->selectedDates(); |
688 | 688 | ||
689 | return dates.last(); | 689 | return dates.last(); |
690 | } | 690 | } |
691 | 691 | ||
692 | 692 | ||
693 | void CalendarView::createPrinter() | 693 | void CalendarView::createPrinter() |
694 | { | 694 | { |
695 | #ifndef KORG_NOPRINTER | 695 | #ifndef KORG_NOPRINTER |
696 | if (!mCalPrinter) { | 696 | if (!mCalPrinter) { |
697 | mCalPrinter = new CalPrinter(this, mCalendar); | 697 | mCalPrinter = new CalPrinter(this, mCalendar); |
698 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); | 698 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); |
699 | } | 699 | } |
700 | #endif | 700 | #endif |
701 | } | 701 | } |
702 | 702 | ||
703 | 703 | ||
704 | //KOPrefs::instance()->mWriteBackFile | 704 | //KOPrefs::instance()->mWriteBackFile |
705 | //KOPrefs::instance()->mWriteBackExistingOnly | 705 | //KOPrefs::instance()->mWriteBackExistingOnly |
706 | 706 | ||
707 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); | 707 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); |
708 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); | 708 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); |
709 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); | 709 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); |
710 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); | 710 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); |
711 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); | 711 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); |
712 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); | 712 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); |
713 | 713 | ||
714 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) | 714 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) |
715 | { | 715 | { |
716 | 716 | ||
717 | // 0 equal | 717 | // 0 equal |
718 | // 1 take local | 718 | // 1 take local |
719 | // 2 take remote | 719 | // 2 take remote |
720 | // 3 cancel | 720 | // 3 cancel |
721 | QDateTime lastSync = mLastCalendarSync; | 721 | QDateTime lastSync = mLastCalendarSync; |
722 | QDateTime localMod = local->lastModified(); | 722 | QDateTime localMod = local->lastModified(); |
723 | QDateTime remoteMod = remote->lastModified(); | 723 | QDateTime remoteMod = remote->lastModified(); |
724 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 724 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
725 | bool remCh, locCh; | 725 | bool remCh, locCh; |
726 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 726 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
727 | //if ( remCh ) | 727 | //if ( remCh ) |
728 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 728 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
729 | locCh = ( localMod > mLastCalendarSync ); | 729 | locCh = ( localMod > mLastCalendarSync ); |
730 | if ( !remCh && ! locCh ) { | 730 | if ( !remCh && ! locCh ) { |
731 | //qDebug("both not changed "); | 731 | //qDebug("both not changed "); |
732 | lastSync = localMod.addDays(1); | 732 | lastSync = localMod.addDays(1); |
733 | if ( mode <= SYNC_PREF_ASK ) | 733 | if ( mode <= SYNC_PREF_ASK ) |
734 | return 0; | 734 | return 0; |
735 | } else { | 735 | } else { |
736 | if ( locCh ) { | 736 | if ( locCh ) { |
737 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); | 737 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); |
738 | lastSync = localMod.addDays( -1 ); | 738 | lastSync = localMod.addDays( -1 ); |
739 | if ( !remCh ) | 739 | if ( !remCh ) |
740 | remoteMod = ( lastSync.addDays( -1 ) ); | 740 | remoteMod = ( lastSync.addDays( -1 ) ); |
741 | } else { | 741 | } else { |
742 | //qDebug(" not loc changed "); | 742 | //qDebug(" not loc changed "); |
743 | lastSync = localMod.addDays( 1 ); | 743 | lastSync = localMod.addDays( 1 ); |
744 | if ( remCh ) | 744 | if ( remCh ) |
745 | remoteMod =( lastSync.addDays( 1 ) ); | 745 | remoteMod =( lastSync.addDays( 1 ) ); |
746 | 746 | ||
747 | } | 747 | } |
748 | } | 748 | } |
749 | full = true; | 749 | full = true; |
750 | if ( mode < SYNC_PREF_ASK ) | 750 | if ( mode < SYNC_PREF_ASK ) |
751 | mode = SYNC_PREF_ASK; | 751 | mode = SYNC_PREF_ASK; |
752 | } else { | 752 | } else { |
753 | if ( localMod == remoteMod ) | 753 | if ( localMod == remoteMod ) |
754 | // if ( local->revision() == remote->revision() ) | 754 | // if ( local->revision() == remote->revision() ) |
755 | return 0; | 755 | return 0; |
756 | 756 | ||
757 | } | 757 | } |
758 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 758 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
759 | 759 | ||
760 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); | 760 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); |
761 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); | 761 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); |
762 | //full = true; //debug only | 762 | //full = true; //debug only |
763 | if ( full ) { | 763 | if ( full ) { |
764 | bool equ = false; | 764 | bool equ = false; |
765 | if ( local->type() == "Event" ) { | 765 | if ( local->type() == "Event" ) { |
766 | equ = (*((Event*) local) == *((Event*) remote)); | 766 | equ = (*((Event*) local) == *((Event*) remote)); |
767 | } | 767 | } |
768 | else if ( local->type() =="Todo" ) | 768 | else if ( local->type() =="Todo" ) |
769 | equ = (*((Todo*) local) == (*(Todo*) remote)); | 769 | equ = (*((Todo*) local) == (*(Todo*) remote)); |
770 | else if ( local->type() =="Journal" ) | 770 | else if ( local->type() =="Journal" ) |
771 | equ = (*((Journal*) local) == *((Journal*) remote)); | 771 | equ = (*((Journal*) local) == *((Journal*) remote)); |
772 | if ( equ ) { | 772 | if ( equ ) { |
773 | //qDebug("equal "); | 773 | //qDebug("equal "); |
774 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 774 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
775 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 775 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
776 | } | 776 | } |
777 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 777 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
778 | return 0; | 778 | return 0; |
779 | 779 | ||
780 | }//else //debug only | 780 | }//else //debug only |
781 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 781 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
782 | } | 782 | } |
783 | int result; | 783 | int result; |
784 | bool localIsNew; | 784 | bool localIsNew; |
785 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); | 785 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); |
786 | 786 | ||
787 | if ( full && mode < SYNC_PREF_NEWEST ) | 787 | if ( full && mode < SYNC_PREF_NEWEST ) |
788 | mode = SYNC_PREF_ASK; | 788 | mode = SYNC_PREF_ASK; |
789 | 789 | ||
790 | switch( mode ) { | 790 | switch( mode ) { |
791 | case SYNC_PREF_LOCAL: | 791 | case SYNC_PREF_LOCAL: |
792 | if ( lastSync > remoteMod ) | 792 | if ( lastSync > remoteMod ) |
793 | return 1; | 793 | return 1; |
794 | if ( lastSync > localMod ) | 794 | if ( lastSync > localMod ) |
795 | return 2; | 795 | return 2; |
796 | return 1; | 796 | return 1; |
797 | break; | 797 | break; |
798 | case SYNC_PREF_REMOTE: | 798 | case SYNC_PREF_REMOTE: |
799 | if ( lastSync > remoteMod ) | 799 | if ( lastSync > remoteMod ) |
800 | return 1; | 800 | return 1; |
801 | if ( lastSync > localMod ) | 801 | if ( lastSync > localMod ) |
802 | return 2; | 802 | return 2; |
803 | return 2; | 803 | return 2; |
804 | break; | 804 | break; |
805 | case SYNC_PREF_NEWEST: | 805 | case SYNC_PREF_NEWEST: |
806 | if ( localMod > remoteMod ) | 806 | if ( localMod > remoteMod ) |
807 | return 1; | 807 | return 1; |
808 | else | 808 | else |
809 | return 2; | 809 | return 2; |
810 | break; | 810 | break; |
811 | case SYNC_PREF_ASK: | 811 | case SYNC_PREF_ASK: |
812 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 812 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
813 | if ( lastSync > remoteMod ) | 813 | if ( lastSync > remoteMod ) |
814 | return 1; | 814 | return 1; |
815 | if ( lastSync > localMod ) | 815 | if ( lastSync > localMod ) |
816 | return 2; | 816 | return 2; |
817 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 817 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
818 | localIsNew = localMod >= remoteMod; | 818 | localIsNew = localMod >= remoteMod; |
819 | if ( localIsNew ) | 819 | if ( localIsNew ) |
820 | getEventViewerDialog()->setColorMode( 1 ); | 820 | getEventViewerDialog()->setColorMode( 1 ); |
821 | else | 821 | else |
822 | getEventViewerDialog()->setColorMode( 2 ); | 822 | getEventViewerDialog()->setColorMode( 2 ); |
823 | getEventViewerDialog()->setIncidence(local); | 823 | getEventViewerDialog()->setIncidence(local); |
824 | if ( localIsNew ) | 824 | if ( localIsNew ) |
825 | getEventViewerDialog()->setColorMode( 2 ); | 825 | getEventViewerDialog()->setColorMode( 2 ); |
826 | else | 826 | else |
827 | getEventViewerDialog()->setColorMode( 1 ); | 827 | getEventViewerDialog()->setColorMode( 1 ); |
828 | getEventViewerDialog()->addIncidence(remote); | 828 | getEventViewerDialog()->addIncidence(remote); |
829 | getEventViewerDialog()->setColorMode( 0 ); | 829 | getEventViewerDialog()->setColorMode( 0 ); |
830 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 830 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
831 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 831 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
832 | getEventViewerDialog()->showMe(); | 832 | getEventViewerDialog()->showMe(); |
833 | result = getEventViewerDialog()->executeS( localIsNew ); | 833 | result = getEventViewerDialog()->executeS( localIsNew ); |
834 | return result; | 834 | return result; |
835 | 835 | ||
836 | break; | 836 | break; |
837 | case SYNC_PREF_FORCE_LOCAL: | 837 | case SYNC_PREF_FORCE_LOCAL: |
838 | return 1; | 838 | return 1; |
839 | break; | 839 | break; |
840 | case SYNC_PREF_FORCE_REMOTE: | 840 | case SYNC_PREF_FORCE_REMOTE: |
841 | return 2; | 841 | return 2; |
842 | break; | 842 | break; |
843 | 843 | ||
844 | default: | 844 | default: |
845 | // SYNC_PREF_TAKE_BOTH not implemented | 845 | // SYNC_PREF_TAKE_BOTH not implemented |
846 | break; | 846 | break; |
847 | } | 847 | } |
848 | return 0; | 848 | return 0; |
849 | } | 849 | } |
850 | Event* CalendarView::getLastSyncEvent() | 850 | Event* CalendarView::getLastSyncEvent() |
851 | { | 851 | { |
852 | Event* lse; | 852 | Event* lse; |
853 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 853 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
854 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); | 854 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
855 | if (!lse) { | 855 | if (!lse) { |
856 | lse = new Event(); | 856 | lse = new Event(); |
857 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 857 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
858 | QString sum = ""; | 858 | QString sum = ""; |
859 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 859 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
860 | sum = "E: "; | 860 | sum = "E: "; |
861 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); | 861 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); |
862 | lse->setDtStart( mLastCalendarSync ); | 862 | lse->setDtStart( mLastCalendarSync ); |
863 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 863 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
864 | lse->setCategories( i18n("SyncEvent") ); | 864 | lse->setCategories( i18n("SyncEvent") ); |
865 | lse->setReadOnly( true ); | 865 | lse->setReadOnly( true ); |
866 | mCalendar->addEvent( lse ); | 866 | mCalendar->addEvent( lse ); |
867 | } | 867 | } |
868 | 868 | ||
869 | return lse; | 869 | return lse; |
870 | 870 | ||
871 | } | 871 | } |
872 | 872 | ||
873 | // we check, if the to delete event has a id for a profile | 873 | // we check, if the to delete event has a id for a profile |
874 | // if yes, we set this id in the profile to delete | 874 | // if yes, we set this id in the profile to delete |
875 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) | 875 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) |
876 | { | 876 | { |
877 | if ( lastSync.count() == 0 ) { | 877 | if ( lastSync.count() == 0 ) { |
878 | //qDebug(" lastSync.count() == 0"); | 878 | //qDebug(" lastSync.count() == 0"); |
879 | return; | 879 | return; |
880 | } | 880 | } |
881 | if ( toDelete->type() == "Journal" ) | 881 | if ( toDelete->type() == "Journal" ) |
882 | return; | 882 | return; |
883 | 883 | ||
884 | Event* eve = lastSync.first(); | 884 | Event* eve = lastSync.first(); |
885 | 885 | ||
886 | while ( eve ) { | 886 | while ( eve ) { |
887 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 887 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
888 | if ( !id.isEmpty() ) { | 888 | if ( !id.isEmpty() ) { |
889 | QString des = eve->description(); | 889 | QString des = eve->description(); |
890 | QString pref = "e"; | 890 | QString pref = "e"; |
891 | if ( toDelete->type() == "Todo" ) | 891 | if ( toDelete->type() == "Todo" ) |
892 | pref = "t"; | 892 | pref = "t"; |
893 | des += pref+ id + ","; | 893 | des += pref+ id + ","; |
894 | eve->setReadOnly( false ); | 894 | eve->setReadOnly( false ); |
895 | eve->setDescription( des ); | 895 | eve->setDescription( des ); |
896 | //qDebug("setdes %s ", des.latin1()); | 896 | //qDebug("setdes %s ", des.latin1()); |
897 | eve->setReadOnly( true ); | 897 | eve->setReadOnly( true ); |
898 | } | 898 | } |
899 | eve = lastSync.next(); | 899 | eve = lastSync.next(); |
900 | } | 900 | } |
901 | 901 | ||
902 | } | 902 | } |
903 | void CalendarView::checkExternalId( Incidence * inc ) | 903 | void CalendarView::checkExternalId( Incidence * inc ) |
904 | { | 904 | { |
905 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 905 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
906 | checkExternSyncEvent( lastSync, inc ); | 906 | checkExternSyncEvent( lastSync, inc ); |
907 | 907 | ||
908 | } | 908 | } |
909 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 909 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
910 | { | 910 | { |
911 | bool syncOK = true; | 911 | bool syncOK = true; |
912 | int addedEvent = 0; | 912 | int addedEvent = 0; |
913 | int addedEventR = 0; | 913 | int addedEventR = 0; |
914 | int deletedEventR = 0; | 914 | int deletedEventR = 0; |
915 | int deletedEventL = 0; | 915 | int deletedEventL = 0; |
916 | int changedLocal = 0; | 916 | int changedLocal = 0; |
917 | int changedRemote = 0; | 917 | int changedRemote = 0; |
918 | //QPtrList<Event> el = local->rawEvents(); | 918 | //QPtrList<Event> el = local->rawEvents(); |
919 | Event* eventR; | 919 | Event* eventR; |
920 | QString uid; | 920 | QString uid; |
921 | int take; | 921 | int take; |
922 | Event* eventL; | 922 | Event* eventL; |
923 | Event* eventRSync; | 923 | Event* eventRSync; |
924 | Event* eventLSync; | 924 | Event* eventLSync; |
925 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 925 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
926 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 926 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
927 | bool fullDateRange = false; | 927 | bool fullDateRange = false; |
928 | local->resetTempSyncStat(); | 928 | local->resetTempSyncStat(); |
929 | if ( mSyncKDE ) | 929 | if ( mSyncKDE ) |
930 | remote->resetPilotStat(1); | 930 | remote->resetPilotStat(1); |
931 | mLastCalendarSync = QDateTime::currentDateTime(); | 931 | mLastCalendarSync = QDateTime::currentDateTime(); |
932 | QDateTime modifiedCalendar = mLastCalendarSync;; | 932 | QDateTime modifiedCalendar = mLastCalendarSync;; |
933 | eventLSync = getLastSyncEvent(); | 933 | eventLSync = getLastSyncEvent(); |
934 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 934 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
935 | if ( eventR ) { | 935 | if ( eventR ) { |
936 | eventRSync = (Event*) eventR->clone(); | 936 | eventRSync = (Event*) eventR->clone(); |
937 | remote->deleteEvent(eventR ); | 937 | remote->deleteEvent(eventR ); |
938 | 938 | ||
939 | } else { | 939 | } else { |
940 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncKDE) { | 940 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncKDE) { |
941 | eventRSync = (Event*)eventLSync->clone(); | 941 | eventRSync = (Event*)eventLSync->clone(); |
942 | } else { | 942 | } else { |
943 | fullDateRange = true; | 943 | fullDateRange = true; |
944 | eventRSync = new Event(); | 944 | eventRSync = new Event(); |
945 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 945 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
946 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 946 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
947 | eventRSync->setDtStart( mLastCalendarSync ); | 947 | eventRSync->setDtStart( mLastCalendarSync ); |
948 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 948 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
949 | eventRSync->setCategories( i18n("SyncEvent") ); | 949 | eventRSync->setCategories( i18n("SyncEvent") ); |
950 | } | 950 | } |
951 | } | 951 | } |
952 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 952 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
953 | fullDateRange = true; | 953 | fullDateRange = true; |
954 | 954 | ||
955 | if ( ! fullDateRange ) { | 955 | if ( ! fullDateRange ) { |
956 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 956 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
957 | 957 | ||
958 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 958 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
959 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 959 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
960 | fullDateRange = true; | 960 | fullDateRange = true; |
961 | } | 961 | } |
962 | } | 962 | } |
963 | if ( fullDateRange && !mSyncKDE ) | 963 | if ( fullDateRange && !mSyncKDE ) |
964 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 964 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
965 | else | 965 | else |
966 | mLastCalendarSync = eventLSync->dtStart(); | 966 | mLastCalendarSync = eventLSync->dtStart(); |
967 | // for resyncing if own file has changed | 967 | // for resyncing if own file has changed |
968 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 968 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
969 | mLastCalendarSync = loadedFileVersion; | 969 | mLastCalendarSync = loadedFileVersion; |
970 | //qDebug("setting mLastCalendarSync "); | 970 | //qDebug("setting mLastCalendarSync "); |
971 | } | 971 | } |
972 | //qDebug("*************************** "); | 972 | //qDebug("*************************** "); |
973 | qDebug("mLastCalendarSync %s full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); | 973 | qDebug("mLastCalendarSync %s full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); |
974 | QPtrList<Incidence> er = remote->rawIncidences(); | 974 | QPtrList<Incidence> er = remote->rawIncidences(); |
975 | Incidence* inR = er.first(); | 975 | Incidence* inR = er.first(); |
976 | Incidence* inL; | 976 | Incidence* inL; |
977 | QProgressBar bar( er.count(),0 ); | 977 | QProgressBar bar( er.count(),0 ); |
978 | bar.setCaption (i18n("Syncing - close to abort!") ); | 978 | bar.setCaption (i18n("Syncing - close to abort!") ); |
979 | 979 | ||
980 | int w = 300; | 980 | int w = 300; |
981 | if ( QApplication::desktop()->width() < 320 ) | 981 | if ( QApplication::desktop()->width() < 320 ) |
982 | w = 220; | 982 | w = 220; |
983 | int h = bar.sizeHint().height() ; | 983 | int h = bar.sizeHint().height() ; |
984 | int dw = QApplication::desktop()->width(); | 984 | int dw = QApplication::desktop()->width(); |
985 | int dh = QApplication::desktop()->height(); | 985 | int dh = QApplication::desktop()->height(); |
986 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 986 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
987 | bar.show(); | 987 | bar.show(); |
988 | int modulo = (er.count()/10)+1; | 988 | int modulo = (er.count()/10)+1; |
989 | int incCounter = 0; | 989 | int incCounter = 0; |
990 | while ( inR ) { | 990 | while ( inR ) { |
991 | if ( ! bar.isVisible() ) | 991 | if ( ! bar.isVisible() ) |
992 | return false; | 992 | return false; |
993 | if ( incCounter % modulo == 0 ) | 993 | if ( incCounter % modulo == 0 ) |
994 | bar.setProgress( incCounter ); | 994 | bar.setProgress( incCounter ); |
995 | ++incCounter; | 995 | ++incCounter; |
996 | uid = inR->uid(); | 996 | uid = inR->uid(); |
997 | bool skipIncidence = false; | 997 | bool skipIncidence = false; |
998 | if ( uid.left(15) == QString("last-syncEvent-") ) | 998 | if ( uid.left(15) == QString("last-syncEvent-") ) |
999 | skipIncidence = true; | 999 | skipIncidence = true; |
1000 | QString idS; | 1000 | QString idS; |
1001 | qApp->processEvents(); | 1001 | qApp->processEvents(); |
1002 | if ( !skipIncidence ) { | 1002 | if ( !skipIncidence ) { |
1003 | inL = local->incidence( uid ); | 1003 | inL = local->incidence( uid ); |
1004 | if ( inL ) { // maybe conflict - same uid in both calendars | 1004 | if ( inL ) { // maybe conflict - same uid in both calendars |
1005 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1005 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1006 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1006 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1007 | if ( take == 3 ) | 1007 | if ( take == 3 ) |
1008 | return false; | 1008 | return false; |
1009 | if ( take == 1 ) {// take local | 1009 | if ( take == 1 ) {// take local |
1010 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 1010 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
1011 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1011 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1012 | else | 1012 | else |
1013 | idS = inR->IDStr(); | 1013 | idS = inR->IDStr(); |
1014 | remote->deleteIncidence( inR ); | 1014 | remote->deleteIncidence( inR ); |
1015 | inR = inL->clone(); | 1015 | inR = inL->clone(); |
1016 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1016 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1017 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1017 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1018 | inR->setIDStr( idS ); | 1018 | inR->setIDStr( idS ); |
1019 | remote->addIncidence( inR ); | 1019 | remote->addIncidence( inR ); |
1020 | if ( mSyncKDE ) | 1020 | if ( mSyncKDE ) |
1021 | inR->setPilotId( 2 ); | 1021 | inR->setPilotId( 2 ); |
1022 | ++changedRemote; | 1022 | ++changedRemote; |
1023 | } else { | 1023 | } else { |
1024 | idS = inL->IDStr(); | 1024 | idS = inL->IDStr(); |
1025 | int pid = inL->pilotId(); | 1025 | int pid = inL->pilotId(); |
1026 | local->deleteIncidence( inL ); | 1026 | local->deleteIncidence( inL ); |
1027 | inL = inR->clone(); | 1027 | inL = inR->clone(); |
1028 | if ( mSyncKDE ) | 1028 | if ( mSyncKDE ) |
1029 | inL->setPilotId( pid ); | 1029 | inL->setPilotId( pid ); |
1030 | inL->setIDStr( idS ); | 1030 | inL->setIDStr( idS ); |
1031 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1031 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1032 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1032 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1033 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1033 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1034 | } | 1034 | } |
1035 | local->addIncidence( inL ); | 1035 | local->addIncidence( inL ); |
1036 | ++changedLocal; | 1036 | ++changedLocal; |
1037 | } | 1037 | } |
1038 | } | 1038 | } |
1039 | } else { // no conflict | 1039 | } else { // no conflict |
1040 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1040 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1041 | QString des = eventLSync->description(); | 1041 | QString des = eventLSync->description(); |
1042 | QString pref = "e"; | 1042 | QString pref = "e"; |
1043 | if ( inR->type() == "Todo" ) | 1043 | if ( inR->type() == "Todo" ) |
1044 | pref = "t"; | 1044 | pref = "t"; |
1045 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1045 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1046 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1046 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1047 | //remote->deleteIncidence( inR ); | 1047 | //remote->deleteIncidence( inR ); |
1048 | ++deletedEventR; | 1048 | ++deletedEventR; |
1049 | } else { | 1049 | } else { |
1050 | inR->setLastModified( modifiedCalendar ); | 1050 | inR->setLastModified( modifiedCalendar ); |
1051 | inL = inR->clone(); | 1051 | inL = inR->clone(); |
1052 | local->addIncidence( inL ); | 1052 | local->addIncidence( inL ); |
1053 | ++addedEvent; | 1053 | ++addedEvent; |
1054 | } | 1054 | } |
1055 | } else { | 1055 | } else { |
1056 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1056 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1057 | inR->setLastModified( modifiedCalendar ); | 1057 | inR->setLastModified( modifiedCalendar ); |
1058 | local->addIncidence( inR->clone() ); | 1058 | local->addIncidence( inR->clone() ); |
1059 | ++addedEvent; | 1059 | ++addedEvent; |
1060 | } else { | 1060 | } else { |
1061 | checkExternSyncEvent(eventRSyncSharp, inR); | 1061 | checkExternSyncEvent(eventRSyncSharp, inR); |
1062 | remote->deleteIncidence( inR ); | 1062 | remote->deleteIncidence( inR ); |
1063 | ++deletedEventR; | 1063 | ++deletedEventR; |
1064 | } | 1064 | } |
1065 | } | 1065 | } |
1066 | } | 1066 | } |
1067 | } | 1067 | } |
1068 | inR = er.next(); | 1068 | inR = er.next(); |
1069 | } | 1069 | } |
1070 | QPtrList<Incidence> el = local->rawIncidences(); | 1070 | QPtrList<Incidence> el = local->rawIncidences(); |
1071 | inL = el.first(); | 1071 | inL = el.first(); |
1072 | modulo = (el.count()/10)+1; | 1072 | modulo = (el.count()/10)+1; |
1073 | bar.setCaption (i18n("Add / remove events") ); | 1073 | bar.setCaption (i18n("Add / remove events") ); |
1074 | bar.setTotalSteps ( el.count() ) ; | 1074 | bar.setTotalSteps ( el.count() ) ; |
1075 | bar.show(); | 1075 | bar.show(); |
1076 | incCounter = 0; | 1076 | incCounter = 0; |
1077 | 1077 | ||
1078 | while ( inL ) { | 1078 | while ( inL ) { |
1079 | 1079 | ||
1080 | qApp->processEvents(); | 1080 | qApp->processEvents(); |
1081 | if ( ! bar.isVisible() ) | 1081 | if ( ! bar.isVisible() ) |
1082 | return false; | 1082 | return false; |
1083 | if ( incCounter % modulo == 0 ) | 1083 | if ( incCounter % modulo == 0 ) |
1084 | bar.setProgress( incCounter ); | 1084 | bar.setProgress( incCounter ); |
1085 | ++incCounter; | 1085 | ++incCounter; |
1086 | uid = inL->uid(); | 1086 | uid = inL->uid(); |
1087 | bool skipIncidence = false; | 1087 | bool skipIncidence = false; |
1088 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1088 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1089 | skipIncidence = true; | 1089 | skipIncidence = true; |
1090 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) | 1090 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) |
1091 | skipIncidence = true; | 1091 | skipIncidence = true; |
1092 | if ( !skipIncidence ) { | 1092 | if ( !skipIncidence ) { |
1093 | inR = remote->incidence( uid ); | 1093 | inR = remote->incidence( uid ); |
1094 | if ( ! inR ) { | 1094 | if ( ! inR ) { |
1095 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1095 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1096 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1096 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1097 | checkExternSyncEvent(eventLSyncSharp, inL); | 1097 | checkExternSyncEvent(eventLSyncSharp, inL); |
1098 | local->deleteIncidence( inL ); | 1098 | local->deleteIncidence( inL ); |
1099 | ++deletedEventL; | 1099 | ++deletedEventL; |
1100 | } else { | 1100 | } else { |
1101 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1101 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1102 | inL->removeID(mCurrentSyncDevice ); | 1102 | inL->removeID(mCurrentSyncDevice ); |
1103 | ++addedEventR; | 1103 | ++addedEventR; |
1104 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1104 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1105 | inL->setLastModified( modifiedCalendar ); | 1105 | inL->setLastModified( modifiedCalendar ); |
1106 | inR = inL->clone(); | 1106 | inR = inL->clone(); |
1107 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1107 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1108 | remote->addIncidence( inR ); | 1108 | remote->addIncidence( inR ); |
1109 | } | 1109 | } |
1110 | } | 1110 | } |
1111 | } else { | 1111 | } else { |
1112 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1112 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1113 | checkExternSyncEvent(eventLSyncSharp, inL); | 1113 | checkExternSyncEvent(eventLSyncSharp, inL); |
1114 | local->deleteIncidence( inL ); | 1114 | local->deleteIncidence( inL ); |
1115 | ++deletedEventL; | 1115 | ++deletedEventL; |
1116 | } else { | 1116 | } else { |
1117 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1117 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1118 | ++addedEventR; | 1118 | ++addedEventR; |
1119 | inL->setLastModified( modifiedCalendar ); | 1119 | inL->setLastModified( modifiedCalendar ); |
1120 | remote->addIncidence( inL->clone() ); | 1120 | remote->addIncidence( inL->clone() ); |
1121 | } | 1121 | } |
1122 | } | 1122 | } |
1123 | } | 1123 | } |
1124 | } | 1124 | } |
1125 | } | 1125 | } |
1126 | inL = el.next(); | 1126 | inL = el.next(); |
1127 | } | 1127 | } |
1128 | int delFut = 0; | 1128 | int delFut = 0; |
1129 | int remRem = 0; | 1129 | int remRem = 0; |
1130 | if ( mSyncManager->mWriteBackInFuture ) { | 1130 | if ( mSyncManager->mWriteBackInFuture ) { |
1131 | er = remote->rawIncidences(); | 1131 | er = remote->rawIncidences(); |
1132 | remRem = er.count(); | 1132 | remRem = er.count(); |
1133 | inR = er.first(); | 1133 | inR = er.first(); |
1134 | QDateTime dt; | 1134 | QDateTime dt; |
1135 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); | 1135 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); |
1136 | QDateTime end = cur.addDays( (mSyncManager->mWriteBackInFuture +1 ) *7 ); | 1136 | QDateTime end = cur.addDays( (mSyncManager->mWriteBackInFuture +1 ) *7 ); |
1137 | while ( inR ) { | 1137 | while ( inR ) { |
1138 | if ( inR->type() == "Todo" ) { | 1138 | if ( inR->type() == "Todo" ) { |
1139 | Todo * t = (Todo*)inR; | 1139 | Todo * t = (Todo*)inR; |
1140 | if ( t->hasDueDate() ) | 1140 | if ( t->hasDueDate() ) |
1141 | dt = t->dtDue(); | 1141 | dt = t->dtDue(); |
1142 | else | 1142 | else |
1143 | dt = cur.addSecs( 62 ); | 1143 | dt = cur.addSecs( 62 ); |
1144 | } | 1144 | } |
1145 | else if (inR->type() == "Event" ) { | 1145 | else if (inR->type() == "Event" ) { |
1146 | bool ok; | 1146 | bool ok; |
1147 | dt = inR->getNextOccurence( cur, &ok ); | 1147 | dt = inR->getNextOccurence( cur, &ok ); |
1148 | if ( !ok ) | 1148 | if ( !ok ) |
1149 | dt = cur.addSecs( -62 ); | 1149 | dt = cur.addSecs( -62 ); |
1150 | } | 1150 | } |
1151 | else | 1151 | else |
1152 | dt = inR->dtStart(); | 1152 | dt = inR->dtStart(); |
1153 | if ( dt < cur || dt > end ) { | 1153 | if ( dt < cur || dt > end ) { |
1154 | remote->deleteIncidence( inR ); | 1154 | remote->deleteIncidence( inR ); |
1155 | ++delFut; | 1155 | ++delFut; |
1156 | } | 1156 | } |
1157 | inR = er.next(); | 1157 | inR = er.next(); |
1158 | } | 1158 | } |
1159 | } | 1159 | } |
1160 | bar.hide(); | 1160 | bar.hide(); |
1161 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1161 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1162 | eventLSync->setReadOnly( false ); | 1162 | eventLSync->setReadOnly( false ); |
1163 | eventLSync->setDtStart( mLastCalendarSync ); | 1163 | eventLSync->setDtStart( mLastCalendarSync ); |
1164 | eventRSync->setDtStart( mLastCalendarSync ); | 1164 | eventRSync->setDtStart( mLastCalendarSync ); |
1165 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1165 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1166 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1166 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1167 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1167 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1168 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1168 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1169 | eventLSync->setReadOnly( true ); | 1169 | eventLSync->setReadOnly( true ); |
1170 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncKDE) // kde is abnormal... | 1170 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncKDE) // kde is abnormal... |
1171 | remote->addEvent( eventRSync ); | 1171 | remote->addEvent( eventRSync ); |
1172 | else | 1172 | else |
1173 | delete eventRSync; | 1173 | delete eventRSync; |
1174 | QString mes; | 1174 | QString mes; |
1175 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR ); | 1175 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR ); |
1176 | QString delmess; | 1176 | QString delmess; |
1177 | if ( delFut ) { | 1177 | if ( delFut ) { |
1178 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInFuture, remRem-delFut); | 1178 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInFuture, remRem-delFut); |
1179 | mes += delmess; | 1179 | mes += delmess; |
1180 | } | 1180 | } |
1181 | if ( mSyncManager->mShowSyncSummary ) { | 1181 | if ( mSyncManager->mShowSyncSummary ) { |
1182 | KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); | 1182 | KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); |
1183 | } | 1183 | } |
1184 | qDebug( mes ); | 1184 | qDebug( mes ); |
1185 | mCalendar->checkAlarmForIncidence( 0, true ); | 1185 | mCalendar->checkAlarmForIncidence( 0, true ); |
1186 | return syncOK; | 1186 | return syncOK; |
1187 | } | 1187 | } |
1188 | 1188 | ||
1189 | void CalendarView::setSyncDevice( QString s ) | 1189 | void CalendarView::setSyncDevice( QString s ) |
1190 | { | 1190 | { |
1191 | mCurrentSyncDevice= s; | 1191 | mCurrentSyncDevice= s; |
1192 | } | 1192 | } |
1193 | void CalendarView::setSyncName( QString s ) | 1193 | void CalendarView::setSyncName( QString s ) |
1194 | { | 1194 | { |
1195 | mCurrentSyncName= s; | 1195 | mCurrentSyncName= s; |
1196 | } | 1196 | } |
1197 | bool CalendarView::syncCalendar(QString filename, int mode) | 1197 | bool CalendarView::syncCalendar(QString filename, int mode) |
1198 | { | 1198 | { |
1199 | //qDebug("syncCalendar %s ", filename.latin1()); | 1199 | //qDebug("syncCalendar %s ", filename.latin1()); |
1200 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1200 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1201 | CalendarLocal* calendar = new CalendarLocal(); | 1201 | CalendarLocal* calendar = new CalendarLocal(); |
1202 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 1202 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1203 | FileStorage* storage = new FileStorage( calendar ); | 1203 | FileStorage* storage = new FileStorage( calendar ); |
1204 | bool syncOK = false; | 1204 | bool syncOK = false; |
1205 | storage->setFileName( filename ); | 1205 | storage->setFileName( filename ); |
1206 | // qDebug("loading ... "); | 1206 | // qDebug("loading ... "); |
1207 | if ( storage->load() ) { | 1207 | if ( storage->load() ) { |
1208 | getEventViewerDialog()->setSyncMode( true ); | 1208 | getEventViewerDialog()->setSyncMode( true ); |
1209 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1209 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1210 | getEventViewerDialog()->setSyncMode( false ); | 1210 | getEventViewerDialog()->setSyncMode( false ); |
1211 | if ( syncOK ) { | 1211 | if ( syncOK ) { |
1212 | if ( mSyncManager->mWriteBackFile ) | 1212 | if ( mSyncManager->mWriteBackFile ) |
1213 | { | 1213 | { |
1214 | storage->setSaveFormat( new ICalFormat() ); | 1214 | storage->setSaveFormat( new ICalFormat() ); |
1215 | storage->save(); | 1215 | storage->save(); |
1216 | } | 1216 | } |
1217 | } | 1217 | } |
1218 | setModified( true ); | 1218 | setModified( true ); |
1219 | } | 1219 | } |
1220 | delete storage; | 1220 | delete storage; |
1221 | delete calendar; | 1221 | delete calendar; |
1222 | if ( syncOK ) | 1222 | if ( syncOK ) |
1223 | updateView(); | 1223 | updateView(); |
1224 | return syncOK; | 1224 | return syncOK; |
1225 | } | 1225 | } |
1226 | 1226 | ||
1227 | void CalendarView::syncExternal( int mode ) | 1227 | void CalendarView::syncExternal( int mode ) |
1228 | { | 1228 | { |
1229 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 1229 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
1230 | 1230 | ||
1231 | qApp->processEvents(); | 1231 | qApp->processEvents(); |
1232 | CalendarLocal* calendar = new CalendarLocal(); | 1232 | CalendarLocal* calendar = new CalendarLocal(); |
1233 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 1233 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1234 | bool syncOK = false; | 1234 | bool syncOK = false; |
1235 | bool loadSuccess = false; | 1235 | bool loadSuccess = false; |
1236 | PhoneFormat* phoneFormat = 0; | 1236 | PhoneFormat* phoneFormat = 0; |
1237 | emit tempDisableBR(true); | 1237 | emit tempDisableBR(true); |
1238 | #ifndef DESKTOP_VERSION | 1238 | #ifndef DESKTOP_VERSION |
1239 | SharpFormat* sharpFormat = 0; | 1239 | SharpFormat* sharpFormat = 0; |
1240 | if ( mode == 0 ) { // sharp | 1240 | if ( mode == 0 ) { // sharp |
1241 | sharpFormat = new SharpFormat () ; | 1241 | sharpFormat = new SharpFormat () ; |
1242 | loadSuccess = sharpFormat->load( calendar, mCalendar ); | 1242 | loadSuccess = sharpFormat->load( calendar, mCalendar ); |
1243 | 1243 | ||
1244 | } else | 1244 | } else |
1245 | #endif | 1245 | #endif |
1246 | if ( mode == 1 ) { // phone | 1246 | if ( mode == 1 ) { // phone |
1247 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, | 1247 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, |
1248 | mSyncManager->mPhoneDevice, | 1248 | mSyncManager->mPhoneDevice, |
1249 | mSyncManager->mPhoneConnection, | 1249 | mSyncManager->mPhoneConnection, |
1250 | mSyncManager->mPhoneModel); | 1250 | mSyncManager->mPhoneModel); |
1251 | loadSuccess = phoneFormat->load( calendar,mCalendar); | 1251 | loadSuccess = phoneFormat->load( calendar,mCalendar); |
1252 | 1252 | ||
1253 | } else { | 1253 | } else { |
1254 | emit tempDisableBR(false); | 1254 | emit tempDisableBR(false); |
1255 | return; | 1255 | return; |
1256 | } | 1256 | } |
1257 | if ( loadSuccess ) { | 1257 | if ( loadSuccess ) { |
1258 | getEventViewerDialog()->setSyncMode( true ); | 1258 | getEventViewerDialog()->setSyncMode( true ); |
1259 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1259 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1260 | getEventViewerDialog()->setSyncMode( false ); | 1260 | getEventViewerDialog()->setSyncMode( false ); |
1261 | qApp->processEvents(); | 1261 | qApp->processEvents(); |
1262 | if ( syncOK ) { | 1262 | if ( syncOK ) { |
1263 | if ( mSyncManager->mWriteBackFile ) | 1263 | if ( mSyncManager->mWriteBackFile ) |
1264 | { | 1264 | { |
1265 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); | 1265 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); |
1266 | Incidence* inc = iL.first(); | 1266 | Incidence* inc = iL.first(); |
1267 | if ( phoneFormat ) { | 1267 | if ( phoneFormat ) { |
1268 | while ( inc ) { | 1268 | while ( inc ) { |
1269 | inc->removeID(mCurrentSyncDevice); | 1269 | inc->removeID(mCurrentSyncDevice); |
1270 | inc = iL.next(); | 1270 | inc = iL.next(); |
1271 | } | 1271 | } |
1272 | } | 1272 | } |
1273 | #ifndef DESKTOP_VERSION | 1273 | #ifndef DESKTOP_VERSION |
1274 | if ( sharpFormat ) | 1274 | if ( sharpFormat ) |
1275 | sharpFormat->save(calendar); | 1275 | sharpFormat->save(calendar); |
1276 | #endif | 1276 | #endif |
1277 | if ( phoneFormat ) | 1277 | if ( phoneFormat ) |
1278 | phoneFormat->save(calendar); | 1278 | phoneFormat->save(calendar); |
1279 | iL = calendar->rawIncidences(); | 1279 | iL = calendar->rawIncidences(); |
1280 | inc = iL.first(); | 1280 | inc = iL.first(); |
1281 | Incidence* loc; | 1281 | Incidence* loc; |
1282 | while ( inc ) { | 1282 | while ( inc ) { |
1283 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { | 1283 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { |
1284 | loc = mCalendar->incidence(inc->uid() ); | 1284 | loc = mCalendar->incidence(inc->uid() ); |
1285 | if ( loc ) { | 1285 | if ( loc ) { |
1286 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); | 1286 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); |
1287 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); | 1287 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); |
1288 | } | 1288 | } |
1289 | } | 1289 | } |
1290 | inc = iL.next(); | 1290 | inc = iL.next(); |
1291 | } | 1291 | } |
1292 | Incidence* lse = getLastSyncEvent(); | 1292 | Incidence* lse = getLastSyncEvent(); |
1293 | if ( lse ) { | 1293 | if ( lse ) { |
1294 | lse->setReadOnly( false ); | 1294 | lse->setReadOnly( false ); |
1295 | lse->setDescription( "" ); | 1295 | lse->setDescription( "" ); |
1296 | lse->setReadOnly( true ); | 1296 | lse->setReadOnly( true ); |
1297 | } | 1297 | } |
1298 | } | 1298 | } |
1299 | } | 1299 | } |
1300 | setModified( true ); | 1300 | setModified( true ); |
1301 | } else { | 1301 | } else { |
1302 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; | 1302 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; |
1303 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), | 1303 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), |
1304 | question, i18n("Ok")) ; | 1304 | question, i18n("Ok")) ; |
1305 | 1305 | ||
1306 | } | 1306 | } |
1307 | delete calendar; | 1307 | delete calendar; |
1308 | updateView(); | 1308 | updateView(); |
1309 | emit tempDisableBR(false); | 1309 | emit tempDisableBR(false); |
1310 | return ;//syncOK; | 1310 | return ;//syncOK; |
1311 | 1311 | ||
1312 | } | 1312 | } |
1313 | 1313 | ||
1314 | bool CalendarView::importBday() | 1314 | bool CalendarView::importBday() |
1315 | { | 1315 | { |
1316 | #ifndef KORG_NOKABC | 1316 | #ifndef KORG_NOKABC |
1317 | 1317 | ||
1318 | #ifdef DESKTOP_VERSION | 1318 | #ifdef DESKTOP_VERSION |
1319 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 1319 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
1320 | KABC::AddressBook::Iterator it; | 1320 | KABC::AddressBook::Iterator it; |
1321 | int count = 0; | 1321 | int count = 0; |
1322 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1322 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1323 | ++count; | 1323 | ++count; |
1324 | } | 1324 | } |
1325 | QProgressBar bar(count,0 ); | 1325 | QProgressBar bar(count,0 ); |
1326 | int w = 300; | 1326 | int w = 300; |
1327 | if ( QApplication::desktop()->width() < 320 ) | 1327 | if ( QApplication::desktop()->width() < 320 ) |
1328 | w = 220; | 1328 | w = 220; |
1329 | int h = bar.sizeHint().height() ; | 1329 | int h = bar.sizeHint().height() ; |
1330 | int dw = QApplication::desktop()->width(); | 1330 | int dw = QApplication::desktop()->width(); |
1331 | int dh = QApplication::desktop()->height(); | 1331 | int dh = QApplication::desktop()->height(); |
1332 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1332 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1333 | bar.show(); | 1333 | bar.show(); |
1334 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); | 1334 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); |
1335 | qApp->processEvents(); | 1335 | qApp->processEvents(); |
1336 | count = 0; | 1336 | count = 0; |
1337 | int addCount = 0; | 1337 | int addCount = 0; |
1338 | KCal::Attendee* a = 0; | 1338 | KCal::Attendee* a = 0; |
1339 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1339 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1340 | if ( ! bar.isVisible() ) | 1340 | if ( ! bar.isVisible() ) |
1341 | return false; | 1341 | return false; |
1342 | bar.setProgress( count++ ); | 1342 | bar.setProgress( count++ ); |
1343 | qApp->processEvents(); | 1343 | qApp->processEvents(); |
1344 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); | 1344 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); |
1345 | if ( (*it).birthday().date().isValid() ){ | 1345 | if ( (*it).birthday().date().isValid() ){ |
1346 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1346 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1347 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) | 1347 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) |
1348 | ++addCount; | 1348 | ++addCount; |
1349 | } | 1349 | } |
1350 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); | 1350 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); |
1351 | if ( anni.isValid() ){ | 1351 | if ( anni.isValid() ){ |
1352 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1352 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1353 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) | 1353 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) |
1354 | ++addCount; | 1354 | ++addCount; |
1355 | } | 1355 | } |
1356 | } | 1356 | } |
1357 | updateView(); | 1357 | updateView(); |
1358 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1358 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1359 | #else //DESKTOP_VERSION | 1359 | #else //DESKTOP_VERSION |
1360 | 1360 | ||
1361 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 1361 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
1362 | // the result should now arrive through method insertBirthdays | 1362 | // the result should now arrive through method insertBirthdays |
1363 | 1363 | ||
1364 | #endif //DESKTOP_VERSION | 1364 | #endif //DESKTOP_VERSION |
1365 | 1365 | ||
1366 | #endif //KORG_NOKABC | 1366 | #endif //KORG_NOKABC |
1367 | 1367 | ||
1368 | 1368 | ||
1369 | return true; | 1369 | return true; |
1370 | } | 1370 | } |
1371 | 1371 | ||
1372 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI | 1372 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI |
1373 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, | 1373 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, |
1374 | const QStringList& anniversaryList, const QStringList& realNameList, | 1374 | const QStringList& anniversaryList, const QStringList& realNameList, |
1375 | const QStringList& emailList, const QStringList& assembledNameList, | 1375 | const QStringList& emailList, const QStringList& assembledNameList, |
1376 | const QStringList& uidList) | 1376 | const QStringList& uidList) |
1377 | { | 1377 | { |
1378 | qDebug("CalendarView::insertBirthdays"); | 1378 | qDebug("CalendarView::insertBirthdays"); |
1379 | if (uid == this->name()) | 1379 | if (uid == this->name()) |
1380 | { | 1380 | { |
1381 | int count = birthdayList.count(); | 1381 | int count = birthdayList.count(); |
1382 | int addCount = 0; | 1382 | int addCount = 0; |
1383 | KCal::Attendee* a = 0; | 1383 | KCal::Attendee* a = 0; |
1384 | 1384 | ||
1385 | qDebug("CalView 1 %i", count); | 1385 | qDebug("CalView 1 %i", count); |
1386 | 1386 | ||
1387 | QProgressBar bar(count,0 ); | 1387 | QProgressBar bar(count,0 ); |
1388 | int w = 300; | 1388 | int w = 300; |
1389 | if ( QApplication::desktop()->width() < 320 ) | 1389 | if ( QApplication::desktop()->width() < 320 ) |
1390 | w = 220; | 1390 | w = 220; |
1391 | int h = bar.sizeHint().height() ; | 1391 | int h = bar.sizeHint().height() ; |
1392 | int dw = QApplication::desktop()->width(); | 1392 | int dw = QApplication::desktop()->width(); |
1393 | int dh = QApplication::desktop()->height(); | 1393 | int dh = QApplication::desktop()->height(); |
1394 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1394 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1395 | bar.show(); | 1395 | bar.show(); |
1396 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); | 1396 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); |
1397 | qApp->processEvents(); | 1397 | qApp->processEvents(); |
1398 | 1398 | ||
1399 | QDate birthday; | 1399 | QDate birthday; |
1400 | QDate anniversary; | 1400 | QDate anniversary; |
1401 | QString realName; | 1401 | QString realName; |
1402 | QString email; | 1402 | QString email; |
1403 | QString assembledName; | 1403 | QString assembledName; |
1404 | QString uid; | 1404 | QString uid; |
1405 | bool ok = true; | 1405 | bool ok = true; |
1406 | for ( int i = 0; i < count; i++) | 1406 | for ( int i = 0; i < count; i++) |
1407 | { | 1407 | { |
1408 | if ( ! bar.isVisible() ) | 1408 | if ( ! bar.isVisible() ) |
1409 | return; | 1409 | return; |
1410 | bar.setProgress( i ); | 1410 | bar.setProgress( i ); |
1411 | qApp->processEvents(); | 1411 | qApp->processEvents(); |
1412 | 1412 | ||
1413 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); | 1413 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); |
1414 | if (!ok) { | 1414 | if (!ok) { |
1415 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); | 1415 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); |
1416 | } | 1416 | } |
1417 | 1417 | ||
1418 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); | 1418 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); |
1419 | if (!ok) { | 1419 | if (!ok) { |
1420 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); | 1420 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); |
1421 | } | 1421 | } |
1422 | realName = realNameList[i]; | 1422 | realName = realNameList[i]; |
1423 | email = emailList[i]; | 1423 | email = emailList[i]; |
1424 | assembledName = assembledNameList[i]; | 1424 | assembledName = assembledNameList[i]; |
1425 | uid = uidList[i]; | 1425 | uid = uidList[i]; |
1426 | //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); | 1426 | //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); |
1427 | 1427 | ||
1428 | if ( birthday.isValid() ){ | 1428 | if ( birthday.isValid() ){ |
1429 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1429 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1430 | KCal::Attendee::ReqParticipant,uid) ; | 1430 | KCal::Attendee::ReqParticipant,uid) ; |
1431 | if ( addAnniversary( birthday, assembledName, a, true ) ) | 1431 | if ( addAnniversary( birthday, assembledName, a, true ) ) |
1432 | ++addCount; | 1432 | ++addCount; |
1433 | } | 1433 | } |
1434 | 1434 | ||
1435 | if ( anniversary.isValid() ){ | 1435 | if ( anniversary.isValid() ){ |
1436 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1436 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1437 | KCal::Attendee::ReqParticipant,uid) ; | 1437 | KCal::Attendee::ReqParticipant,uid) ; |
1438 | if ( addAnniversary( anniversary, assembledName, a, false ) ) | 1438 | if ( addAnniversary( anniversary, assembledName, a, false ) ) |
1439 | ++addCount; | 1439 | ++addCount; |
1440 | } | 1440 | } |
1441 | } | 1441 | } |
1442 | 1442 | ||
1443 | updateView(); | 1443 | updateView(); |
1444 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1444 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1445 | 1445 | ||
1446 | } | 1446 | } |
1447 | 1447 | ||
1448 | } | 1448 | } |
1449 | 1449 | ||
1450 | 1450 | ||
1451 | 1451 | ||
1452 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) | 1452 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) |
1453 | { | 1453 | { |
1454 | //qDebug("addAnni "); | 1454 | //qDebug("addAnni "); |
1455 | Event * ev = new Event(); | 1455 | Event * ev = new Event(); |
1456 | if ( a ) { | 1456 | if ( a ) { |
1457 | ev->addAttendee( a ); | 1457 | ev->addAttendee( a ); |
1458 | } | 1458 | } |
1459 | QString kind; | 1459 | QString kind; |
1460 | if ( birthday ) | 1460 | if ( birthday ) |
1461 | kind = i18n( "Birthday" ); | 1461 | kind = i18n( "Birthday" ); |
1462 | else | 1462 | else |
1463 | kind = i18n( "Anniversary" ); | 1463 | kind = i18n( "Anniversary" ); |
1464 | ev->setSummary( name + " - " + kind ); | 1464 | ev->setSummary( name + " - " + kind ); |
1465 | ev->setOrganizer( "nobody@nowhere" ); | 1465 | ev->setOrganizer( "nobody@nowhere" ); |
1466 | ev->setCategories( kind ); | 1466 | ev->setCategories( kind ); |
1467 | ev->setDtStart( QDateTime(date) ); | 1467 | ev->setDtStart( QDateTime(date) ); |
1468 | ev->setDtEnd( QDateTime(date) ); | 1468 | ev->setDtEnd( QDateTime(date) ); |
1469 | ev->setFloats( true ); | 1469 | ev->setFloats( true ); |
1470 | Recurrence * rec = ev->recurrence(); | 1470 | Recurrence * rec = ev->recurrence(); |
1471 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); | 1471 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); |
1472 | rec->addYearlyNum( date.month() ); | 1472 | rec->addYearlyNum( date.month() ); |
1473 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { | 1473 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { |
1474 | delete ev; | 1474 | delete ev; |
1475 | return false; | 1475 | return false; |
1476 | } | 1476 | } |
1477 | return true; | 1477 | return true; |
1478 | 1478 | ||
1479 | } | 1479 | } |
1480 | bool CalendarView::importQtopia( const QString &categories, | 1480 | bool CalendarView::importQtopia( const QString &categories, |
1481 | const QString &datebook, | 1481 | const QString &datebook, |
1482 | const QString &todolist ) | 1482 | const QString &todolist ) |
1483 | { | 1483 | { |
1484 | 1484 | ||
1485 | QtopiaFormat qtopiaFormat; | 1485 | QtopiaFormat qtopiaFormat; |
1486 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1486 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1487 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); | 1487 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); |
1488 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); | 1488 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); |
1489 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); | 1489 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); |
1490 | 1490 | ||
1491 | updateView(); | 1491 | updateView(); |
1492 | return true; | 1492 | return true; |
1493 | 1493 | ||
1494 | #if 0 | 1494 | #if 0 |
1495 | mGlobalSyncMode = SYNC_MODE_QTOPIA; | 1495 | mGlobalSyncMode = SYNC_MODE_QTOPIA; |
1496 | mCurrentSyncDevice = "qtopia-XML"; | 1496 | mCurrentSyncDevice = "qtopia-XML"; |
1497 | if ( mSyncManager->mAskForPreferences ) | 1497 | if ( mSyncManager->mAskForPreferences ) |
1498 | edit_sync_options(); | 1498 | edit_sync_options(); |
1499 | qApp->processEvents(); | 1499 | qApp->processEvents(); |
1500 | CalendarLocal* calendar = new CalendarLocal(); | 1500 | CalendarLocal* calendar = new CalendarLocal(); |
1501 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 1501 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1502 | bool syncOK = false; | 1502 | bool syncOK = false; |
1503 | QtopiaFormat qtopiaFormat; | 1503 | QtopiaFormat qtopiaFormat; |
1504 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1504 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1505 | bool loadOk = true; | 1505 | bool loadOk = true; |
1506 | if ( !categories.isEmpty() ) | 1506 | if ( !categories.isEmpty() ) |
1507 | loadOk = qtopiaFormat.load( calendar, categories ); | 1507 | loadOk = qtopiaFormat.load( calendar, categories ); |
1508 | if ( loadOk && !datebook.isEmpty() ) | 1508 | if ( loadOk && !datebook.isEmpty() ) |
1509 | loadOk = qtopiaFormat.load( calendar, datebook ); | 1509 | loadOk = qtopiaFormat.load( calendar, datebook ); |
1510 | if ( loadOk && !todolist.isEmpty() ) | 1510 | if ( loadOk && !todolist.isEmpty() ) |
1511 | loadOk = qtopiaFormat.load( calendar, todolist ); | 1511 | loadOk = qtopiaFormat.load( calendar, todolist ); |
1512 | 1512 | ||
1513 | if ( loadOk ) { | 1513 | if ( loadOk ) { |
1514 | getEventViewerDialog()->setSyncMode( true ); | 1514 | getEventViewerDialog()->setSyncMode( true ); |
1515 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1515 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1516 | getEventViewerDialog()->setSyncMode( false ); | 1516 | getEventViewerDialog()->setSyncMode( false ); |
1517 | qApp->processEvents(); | 1517 | qApp->processEvents(); |
1518 | if ( syncOK ) { | 1518 | if ( syncOK ) { |
1519 | if ( mSyncManager->mWriteBackFile ) | 1519 | if ( mSyncManager->mWriteBackFile ) |
1520 | { | 1520 | { |
1521 | // write back XML file | 1521 | // write back XML file |
1522 | 1522 | ||
1523 | } | 1523 | } |
1524 | setModified( true ); | 1524 | setModified( true ); |
1525 | } | 1525 | } |
1526 | } else { | 1526 | } else { |
1527 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; | 1527 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; |
1528 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), | 1528 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), |
1529 | question, i18n("Ok")) ; | 1529 | question, i18n("Ok")) ; |
1530 | } | 1530 | } |
1531 | delete calendar; | 1531 | delete calendar; |
1532 | updateView(); | 1532 | updateView(); |
1533 | return syncOK; | 1533 | return syncOK; |
1534 | 1534 | ||
1535 | 1535 | ||
1536 | #endif | 1536 | #endif |
1537 | 1537 | ||
1538 | } | 1538 | } |
1539 | 1539 | ||
1540 | void CalendarView::setSyncEventsReadOnly() | 1540 | void CalendarView::setSyncEventsReadOnly() |
1541 | { | 1541 | { |
1542 | Event * ev; | 1542 | Event * ev; |
1543 | QPtrList<Event> eL = mCalendar->rawEvents(); | 1543 | QPtrList<Event> eL = mCalendar->rawEvents(); |
1544 | ev = eL.first(); | 1544 | ev = eL.first(); |
1545 | while ( ev ) { | 1545 | while ( ev ) { |
1546 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) | 1546 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) |
1547 | ev->setReadOnly( true ); | 1547 | ev->setReadOnly( true ); |
1548 | ev = eL.next(); | 1548 | ev = eL.next(); |
1549 | } | 1549 | } |
1550 | } | 1550 | } |
1551 | bool CalendarView::openCalendar(QString filename, bool merge) | 1551 | bool CalendarView::openCalendar(QString filename, bool merge) |
1552 | { | 1552 | { |
1553 | 1553 | ||
1554 | if (filename.isEmpty()) { | 1554 | if (filename.isEmpty()) { |
1555 | return false; | 1555 | return false; |
1556 | } | 1556 | } |
1557 | 1557 | ||
1558 | if (!QFile::exists(filename)) { | 1558 | if (!QFile::exists(filename)) { |
1559 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); | 1559 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); |
1560 | return false; | 1560 | return false; |
1561 | } | 1561 | } |
1562 | 1562 | ||
1563 | globalFlagBlockAgenda = 1; | 1563 | globalFlagBlockAgenda = 1; |
1564 | if (!merge) mCalendar->close(); | 1564 | if (!merge) mCalendar->close(); |
1565 | 1565 | ||
1566 | mStorage->setFileName( filename ); | 1566 | mStorage->setFileName( filename ); |
1567 | 1567 | ||
1568 | if ( mStorage->load() ) { | 1568 | if ( mStorage->load() ) { |
1569 | if ( merge ) ;//setModified( true ); | 1569 | if ( merge ) ;//setModified( true ); |
1570 | else { | 1570 | else { |
1571 | //setModified( true ); | 1571 | //setModified( true ); |
1572 | mViewManager->setDocumentId( filename ); | 1572 | mViewManager->setDocumentId( filename ); |
1573 | mDialogManager->setDocumentId( filename ); | 1573 | mDialogManager->setDocumentId( filename ); |
1574 | mTodoList->setDocumentId( filename ); | 1574 | mTodoList->setDocumentId( filename ); |
1575 | } | 1575 | } |
1576 | globalFlagBlockAgenda = 2; | 1576 | globalFlagBlockAgenda = 2; |
1577 | // if ( getLastSyncEvent() ) | 1577 | // if ( getLastSyncEvent() ) |
1578 | // getLastSyncEvent()->setReadOnly( true ); | 1578 | // getLastSyncEvent()->setReadOnly( true ); |
1579 | mCalendar->reInitAlarmSettings(); | 1579 | mCalendar->reInitAlarmSettings(); |
1580 | setSyncEventsReadOnly(); | 1580 | setSyncEventsReadOnly(); |
1581 | updateUnmanagedViews(); | 1581 | updateUnmanagedViews(); |
1582 | updateView(); | 1582 | updateView(); |
1583 | if ( filename != MainWindow::defaultFileName() ) { | 1583 | if ( filename != MainWindow::defaultFileName() ) { |
1584 | saveCalendar( MainWindow::defaultFileName() ); | 1584 | saveCalendar( MainWindow::defaultFileName() ); |
1585 | } else { | 1585 | } else { |
1586 | QFileInfo finf ( MainWindow::defaultFileName()); | 1586 | QFileInfo finf ( MainWindow::defaultFileName()); |
1587 | if ( finf.exists() ) { | 1587 | if ( finf.exists() ) { |
1588 | setLoadedFileVersion( finf.lastModified () ); | 1588 | setLoadedFileVersion( finf.lastModified () ); |
1589 | } | 1589 | } |
1590 | } | 1590 | } |
1591 | return true; | 1591 | return true; |
1592 | } else { | 1592 | } else { |
1593 | // while failing to load, the calendar object could | 1593 | // while failing to load, the calendar object could |
1594 | // have become partially populated. Clear it out. | 1594 | // have become partially populated. Clear it out. |
1595 | if ( !merge ) { | 1595 | if ( !merge ) { |
1596 | mCalendar->close(); | 1596 | mCalendar->close(); |
1597 | mViewManager->setDocumentId( filename ); | 1597 | mViewManager->setDocumentId( filename ); |
1598 | mDialogManager->setDocumentId( filename ); | 1598 | mDialogManager->setDocumentId( filename ); |
1599 | mTodoList->setDocumentId( filename ); | 1599 | mTodoList->setDocumentId( filename ); |
1600 | } | 1600 | } |
1601 | 1601 | ||
1602 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); | 1602 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); |
1603 | 1603 | ||
1604 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); | 1604 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); |
1605 | globalFlagBlockAgenda = 2; | 1605 | globalFlagBlockAgenda = 2; |
1606 | mCalendar->reInitAlarmSettings(); | 1606 | mCalendar->reInitAlarmSettings(); |
1607 | setSyncEventsReadOnly(); | 1607 | setSyncEventsReadOnly(); |
1608 | updateUnmanagedViews(); | 1608 | updateUnmanagedViews(); |
1609 | updateView(); | 1609 | updateView(); |
1610 | } | 1610 | } |
1611 | return false; | 1611 | return false; |
1612 | } | 1612 | } |
1613 | void CalendarView::showOpenError() | 1613 | void CalendarView::showOpenError() |
1614 | { | 1614 | { |
1615 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); | 1615 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); |
1616 | } | 1616 | } |
1617 | void CalendarView::setLoadedFileVersion(QDateTime dt) | 1617 | void CalendarView::setLoadedFileVersion(QDateTime dt) |
1618 | { | 1618 | { |
1619 | loadedFileVersion = dt; | 1619 | loadedFileVersion = dt; |
1620 | } | 1620 | } |
1621 | bool CalendarView::checkFileChanged(QString fn) | 1621 | bool CalendarView::checkFileChanged(QString fn) |
1622 | { | 1622 | { |
1623 | QFileInfo finf ( fn ); | 1623 | QFileInfo finf ( fn ); |
1624 | if ( !finf.exists() ) | 1624 | if ( !finf.exists() ) |
1625 | return true; | 1625 | return true; |
1626 | QDateTime dt = finf.lastModified (); | 1626 | QDateTime dt = finf.lastModified (); |
1627 | if ( dt <= loadedFileVersion ) | 1627 | if ( dt <= loadedFileVersion ) |
1628 | return false; | 1628 | return false; |
1629 | return true; | 1629 | return true; |
1630 | 1630 | ||
1631 | } | 1631 | } |
1632 | void CalendarView::watchSavedFile() | 1632 | void CalendarView::watchSavedFile() |
1633 | { | 1633 | { |
1634 | QFileInfo finf ( MainWindow::defaultFileName()); | 1634 | QFileInfo finf ( MainWindow::defaultFileName()); |
1635 | if ( !finf.exists() ) | 1635 | if ( !finf.exists() ) |
1636 | return; | 1636 | return; |
1637 | QDateTime dt = finf.lastModified (); | 1637 | QDateTime dt = finf.lastModified (); |
1638 | if ( dt < loadedFileVersion ) { | 1638 | if ( dt < loadedFileVersion ) { |
1639 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); | 1639 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); |
1640 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); | 1640 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); |
1641 | return; | 1641 | return; |
1642 | } | 1642 | } |
1643 | loadedFileVersion = dt; | 1643 | loadedFileVersion = dt; |
1644 | } | 1644 | } |
1645 | 1645 | ||
1646 | bool CalendarView::checkFileVersion(QString fn) | 1646 | bool CalendarView::checkFileVersion(QString fn) |
1647 | { | 1647 | { |
1648 | QFileInfo finf ( fn ); | 1648 | QFileInfo finf ( fn ); |
1649 | if ( !finf.exists() ) | 1649 | if ( !finf.exists() ) |
1650 | return true; | 1650 | return true; |
1651 | QDateTime dt = finf.lastModified (); | 1651 | QDateTime dt = finf.lastModified (); |
1652 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); | 1652 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); |
1653 | //qDebug("file on disk version %s",dt.toString().latin1()); | 1653 | //qDebug("file on disk version %s",dt.toString().latin1()); |
1654 | if ( dt <= loadedFileVersion ) | 1654 | if ( dt <= loadedFileVersion ) |
1655 | return true; | 1655 | return true; |
1656 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , | 1656 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , |
1657 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 1657 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
1658 | i18n("Sync+save")); | 1658 | i18n("Sync+save")); |
1659 | 1659 | ||
1660 | if ( km == KMessageBox::Cancel ) | 1660 | if ( km == KMessageBox::Cancel ) |
1661 | return false; | 1661 | return false; |
1662 | if ( km == KMessageBox::Yes ) | 1662 | if ( km == KMessageBox::Yes ) |
1663 | return true; | 1663 | return true; |
1664 | 1664 | ||
1665 | setSyncDevice("deleteaftersync" ); | 1665 | setSyncDevice("deleteaftersync" ); |
1666 | mSyncManager->mAskForPreferences = true; | 1666 | mSyncManager->mAskForPreferences = true; |
1667 | mSyncManager->mSyncAlgoPrefs = 3; | 1667 | mSyncManager->mSyncAlgoPrefs = 3; |
1668 | mSyncManager->mWriteBackFile = false; | 1668 | mSyncManager->mWriteBackFile = false; |
1669 | mSyncManager->mWriteBackExistingOnly = false; | 1669 | mSyncManager->mWriteBackExistingOnly = false; |
1670 | mSyncManager->mShowSyncSummary = false; | 1670 | mSyncManager->mShowSyncSummary = false; |
1671 | syncCalendar( fn, 3 ); | 1671 | syncCalendar( fn, 3 ); |
1672 | Event * e = getLastSyncEvent(); | 1672 | Event * e = getLastSyncEvent(); |
1673 | mCalendar->deleteEvent ( e ); | 1673 | mCalendar->deleteEvent ( e ); |
1674 | updateView(); | 1674 | updateView(); |
1675 | return true; | 1675 | return true; |
1676 | } | 1676 | } |
1677 | 1677 | ||
1678 | bool CalendarView::saveCalendar( QString filename ) | 1678 | bool CalendarView::saveCalendar( QString filename ) |
1679 | { | 1679 | { |
1680 | 1680 | ||
1681 | // Store back all unsaved data into calendar object | 1681 | // Store back all unsaved data into calendar object |
1682 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 1682 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
1683 | if ( mViewManager->currentView() ) | 1683 | if ( mViewManager->currentView() ) |
1684 | mViewManager->currentView()->flushView(); | 1684 | mViewManager->currentView()->flushView(); |
1685 | 1685 | ||
1686 | 1686 | ||
1687 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); | 1687 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); |
1688 | mStorage->setSaveFormat( new ICalFormat() ); | 1688 | mStorage->setSaveFormat( new ICalFormat() ); |
1689 | mStorage->setFileName( filename ); | 1689 | mStorage->setFileName( filename ); |
1690 | bool success; | 1690 | bool success; |
1691 | success = mStorage->save(); | 1691 | success = mStorage->save(); |
1692 | if ( !success ) { | 1692 | if ( !success ) { |
1693 | return false; | 1693 | return false; |
1694 | } | 1694 | } |
1695 | if ( filename == MainWindow::defaultFileName() ) { | 1695 | if ( filename == MainWindow::defaultFileName() ) { |
1696 | setLoadedFileVersion( lfv ); | 1696 | setLoadedFileVersion( lfv ); |
1697 | watchSavedFile(); | 1697 | watchSavedFile(); |
1698 | } | 1698 | } |
1699 | return true; | 1699 | return true; |
1700 | } | 1700 | } |
1701 | 1701 | ||
1702 | void CalendarView::closeCalendar() | 1702 | void CalendarView::closeCalendar() |
1703 | { | 1703 | { |
1704 | 1704 | ||
1705 | // child windows no longer valid | 1705 | // child windows no longer valid |
1706 | emit closingDown(); | 1706 | emit closingDown(); |
1707 | 1707 | ||
1708 | mCalendar->close(); | 1708 | mCalendar->close(); |
1709 | setModified(false); | 1709 | setModified(false); |
1710 | updateView(); | 1710 | updateView(); |
1711 | } | 1711 | } |
1712 | 1712 | ||
1713 | void CalendarView::archiveCalendar() | 1713 | void CalendarView::archiveCalendar() |
1714 | { | 1714 | { |
1715 | mDialogManager->showArchiveDialog(); | 1715 | mDialogManager->showArchiveDialog(); |
1716 | } | 1716 | } |
1717 | 1717 | ||
1718 | 1718 | ||
1719 | void CalendarView::readSettings() | 1719 | void CalendarView::readSettings() |
1720 | { | 1720 | { |
1721 | 1721 | ||
1722 | 1722 | ||
1723 | // mViewManager->showAgendaView(); | 1723 | // mViewManager->showAgendaView(); |
1724 | QString str; | 1724 | QString str; |
1725 | //qDebug("CalendarView::readSettings() "); | 1725 | //qDebug("CalendarView::readSettings() "); |
1726 | // read settings from the KConfig, supplying reasonable | 1726 | // read settings from the KConfig, supplying reasonable |
1727 | // defaults where none are to be found | 1727 | // defaults where none are to be found |
1728 | KConfig *config = KOGlobals::config(); | 1728 | KConfig *config = KOGlobals::config(); |
1729 | #ifndef KORG_NOSPLITTER | 1729 | #ifndef KORG_NOSPLITTER |
1730 | config->setGroup("KOrganizer Geometry"); | 1730 | config->setGroup("KOrganizer Geometry"); |
1731 | 1731 | ||
1732 | QValueList<int> sizes = config->readIntListEntry("Separator1"); | 1732 | QValueList<int> sizes = config->readIntListEntry("Separator1"); |
1733 | if (sizes.count() != 2) { | 1733 | if (sizes.count() != 2) { |
1734 | sizes << mDateNavigator->minimumSizeHint().width(); | 1734 | sizes << mDateNavigator->minimumSizeHint().width(); |
1735 | sizes << 300; | 1735 | sizes << 300; |
1736 | } | 1736 | } |
1737 | mPanner->setSizes(sizes); | 1737 | mPanner->setSizes(sizes); |
1738 | 1738 | ||
1739 | sizes = config->readIntListEntry("Separator2"); | 1739 | sizes = config->readIntListEntry("Separator2"); |
1740 | if ( ( mResourceView && sizes.count() == 4 ) || | 1740 | if ( ( mResourceView && sizes.count() == 4 ) || |
1741 | ( !mResourceView && sizes.count() == 3 ) ) { | 1741 | ( !mResourceView && sizes.count() == 3 ) ) { |
1742 | mLeftSplitter->setSizes(sizes); | 1742 | mLeftSplitter->setSizes(sizes); |
1743 | } | 1743 | } |
1744 | #endif | 1744 | #endif |
1745 | globalFlagBlockAgenda = 1; | 1745 | globalFlagBlockAgenda = 1; |
1746 | mViewManager->showAgendaView(); | 1746 | mViewManager->showAgendaView(); |
1747 | //mViewManager->readSettings( config ); | 1747 | //mViewManager->readSettings( config ); |
1748 | mTodoList->restoreLayout(config,QString("Todo Layout")); | 1748 | mTodoList->restoreLayout(config,QString("Todo Layout")); |
1749 | readFilterSettings(config); | 1749 | readFilterSettings(config); |
1750 | config->setGroup( "Views" ); | 1750 | config->setGroup( "Views" ); |
1751 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 1751 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
1752 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); | 1752 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); |
1753 | else if ( dateCount == 7 ) mNavigator->selectWeek(); | 1753 | else if ( dateCount == 7 ) mNavigator->selectWeek(); |
1754 | else mNavigator->selectDates( dateCount ); | 1754 | else mNavigator->selectDates( dateCount ); |
1755 | // mViewManager->readSettings( config ); | 1755 | // mViewManager->readSettings( config ); |
1756 | updateConfig(); | 1756 | updateConfig(); |
1757 | globalFlagBlockAgenda = 2; | 1757 | globalFlagBlockAgenda = 2; |
1758 | mViewManager->readSettings( config ); | 1758 | mViewManager->readSettings( config ); |
1759 | #ifdef DESKTOP_VERSION | 1759 | #ifdef DESKTOP_VERSION |
1760 | config->setGroup("WidgetLayout"); | 1760 | config->setGroup("WidgetLayout"); |
1761 | QStringList list; | 1761 | QStringList list; |
1762 | list = config->readListEntry("MainLayout"); | 1762 | list = config->readListEntry("MainLayout"); |
1763 | int x,y,w,h; | 1763 | int x,y,w,h; |
1764 | if ( ! list.isEmpty() ) { | 1764 | if ( ! list.isEmpty() ) { |
1765 | x = list[0].toInt(); | 1765 | x = list[0].toInt(); |
1766 | y = list[1].toInt(); | 1766 | y = list[1].toInt(); |
1767 | w = list[2].toInt(); | 1767 | w = list[2].toInt(); |
1768 | h = list[3].toInt(); | 1768 | h = list[3].toInt(); |
1769 | topLevelWidget()->setGeometry(x,y,w,h); | 1769 | topLevelWidget()->setGeometry(x,y,w,h); |
1770 | 1770 | ||
1771 | } else { | 1771 | } else { |
1772 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); | 1772 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); |
1773 | } | 1773 | } |
1774 | list = config->readListEntry("EditEventLayout"); | 1774 | list = config->readListEntry("EditEventLayout"); |
1775 | if ( ! list.isEmpty() ) { | 1775 | if ( ! list.isEmpty() ) { |
1776 | x = list[0].toInt(); | 1776 | x = list[0].toInt(); |
1777 | y = list[1].toInt(); | 1777 | y = list[1].toInt(); |
1778 | w = list[2].toInt(); | 1778 | w = list[2].toInt(); |
1779 | h = list[3].toInt(); | 1779 | h = list[3].toInt(); |
1780 | mEventEditor->setGeometry(x,y,w,h); | 1780 | mEventEditor->setGeometry(x,y,w,h); |
1781 | 1781 | ||
1782 | } | 1782 | } |
1783 | list = config->readListEntry("EditTodoLayout"); | 1783 | list = config->readListEntry("EditTodoLayout"); |
1784 | if ( ! list.isEmpty() ) { | 1784 | if ( ! list.isEmpty() ) { |
1785 | x = list[0].toInt(); | 1785 | x = list[0].toInt(); |
1786 | y = list[1].toInt(); | 1786 | y = list[1].toInt(); |
1787 | w = list[2].toInt(); | 1787 | w = list[2].toInt(); |
1788 | h = list[3].toInt(); | 1788 | h = list[3].toInt(); |
1789 | mTodoEditor->setGeometry(x,y,w,h); | 1789 | mTodoEditor->setGeometry(x,y,w,h); |
1790 | 1790 | ||
1791 | } | 1791 | } |
1792 | list = config->readListEntry("ViewerLayout"); | 1792 | list = config->readListEntry("ViewerLayout"); |
1793 | if ( ! list.isEmpty() ) { | 1793 | if ( ! list.isEmpty() ) { |
1794 | x = list[0].toInt(); | 1794 | x = list[0].toInt(); |
1795 | y = list[1].toInt(); | 1795 | y = list[1].toInt(); |
1796 | w = list[2].toInt(); | 1796 | w = list[2].toInt(); |
1797 | h = list[3].toInt(); | 1797 | h = list[3].toInt(); |
1798 | getEventViewerDialog()->setGeometry(x,y,w,h); | 1798 | getEventViewerDialog()->setGeometry(x,y,w,h); |
1799 | } | 1799 | } |
1800 | #endif | 1800 | #endif |
1801 | 1801 | ||
1802 | } | 1802 | } |
1803 | 1803 | ||
1804 | 1804 | ||
1805 | void CalendarView::writeSettings() | 1805 | void CalendarView::writeSettings() |
1806 | { | 1806 | { |
1807 | // kdDebug() << "CalendarView::writeSettings" << endl; | 1807 | // kdDebug() << "CalendarView::writeSettings" << endl; |
1808 | 1808 | ||
1809 | KConfig *config = KOGlobals::config(); | 1809 | KConfig *config = KOGlobals::config(); |
1810 | 1810 | ||
1811 | #ifndef KORG_NOSPLITTER | 1811 | #ifndef KORG_NOSPLITTER |
1812 | config->setGroup("KOrganizer Geometry"); | 1812 | config->setGroup("KOrganizer Geometry"); |
1813 | 1813 | ||
1814 | QValueList<int> list = mPanner->sizes(); | 1814 | QValueList<int> list = mPanner->sizes(); |
1815 | config->writeEntry("Separator1",list); | 1815 | config->writeEntry("Separator1",list); |
1816 | 1816 | ||
1817 | list = mLeftSplitter->sizes(); | 1817 | list = mLeftSplitter->sizes(); |
1818 | config->writeEntry("Separator2",list); | 1818 | config->writeEntry("Separator2",list); |
1819 | #endif | 1819 | #endif |
1820 | 1820 | ||
1821 | mViewManager->writeSettings( config ); | 1821 | mViewManager->writeSettings( config ); |
1822 | mTodoList->saveLayout(config,QString("Todo Layout")); | 1822 | mTodoList->saveLayout(config,QString("Todo Layout")); |
1823 | mDialogManager->writeSettings( config ); | 1823 | mDialogManager->writeSettings( config ); |
1824 | //KOPrefs::instance()->usrWriteConfig(); | 1824 | //KOPrefs::instance()->usrWriteConfig(); |
1825 | KOPrefs::instance()->writeConfig(); | 1825 | KOPrefs::instance()->writeConfig(); |
1826 | 1826 | ||
1827 | writeFilterSettings(config); | 1827 | writeFilterSettings(config); |
1828 | 1828 | ||
1829 | config->setGroup( "Views" ); | 1829 | config->setGroup( "Views" ); |
1830 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); | 1830 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); |
1831 | 1831 | ||
1832 | #ifdef DESKTOP_VERSION | 1832 | #ifdef DESKTOP_VERSION |
1833 | config->setGroup("WidgetLayout"); | 1833 | config->setGroup("WidgetLayout"); |
1834 | QStringList list ;//= config->readListEntry("MainLayout"); | 1834 | QStringList list ;//= config->readListEntry("MainLayout"); |
1835 | int x,y,w,h; | 1835 | int x,y,w,h; |
1836 | QWidget* wid; | 1836 | QWidget* wid; |
1837 | wid = topLevelWidget(); | 1837 | wid = topLevelWidget(); |
1838 | x = wid->geometry().x(); | 1838 | x = wid->geometry().x(); |
1839 | y = wid->geometry().y(); | 1839 | y = wid->geometry().y(); |
1840 | w = wid->width(); | 1840 | w = wid->width(); |
1841 | h = wid->height(); | 1841 | h = wid->height(); |
1842 | list.clear(); | 1842 | list.clear(); |
1843 | list << QString::number( x ); | 1843 | list << QString::number( x ); |
1844 | list << QString::number( y ); | 1844 | list << QString::number( y ); |
1845 | list << QString::number( w ); | 1845 | list << QString::number( w ); |
1846 | list << QString::number( h ); | 1846 | list << QString::number( h ); |
1847 | config->writeEntry("MainLayout",list ); | 1847 | config->writeEntry("MainLayout",list ); |
1848 | 1848 | ||
1849 | wid = mEventEditor; | 1849 | wid = mEventEditor; |
1850 | x = wid->geometry().x(); | 1850 | x = wid->geometry().x(); |
1851 | y = wid->geometry().y(); | 1851 | y = wid->geometry().y(); |
1852 | w = wid->width(); | 1852 | w = wid->width(); |
1853 | h = wid->height(); | 1853 | h = wid->height(); |
1854 | list.clear(); | 1854 | list.clear(); |
1855 | list << QString::number( x ); | 1855 | list << QString::number( x ); |
1856 | list << QString::number( y ); | 1856 | list << QString::number( y ); |
1857 | list << QString::number( w ); | 1857 | list << QString::number( w ); |
1858 | list << QString::number( h ); | 1858 | list << QString::number( h ); |
1859 | config->writeEntry("EditEventLayout",list ); | 1859 | config->writeEntry("EditEventLayout",list ); |
1860 | 1860 | ||
1861 | wid = mTodoEditor; | 1861 | wid = mTodoEditor; |
1862 | x = wid->geometry().x(); | 1862 | x = wid->geometry().x(); |
1863 | y = wid->geometry().y(); | 1863 | y = wid->geometry().y(); |
1864 | w = wid->width(); | 1864 | w = wid->width(); |
1865 | h = wid->height(); | 1865 | h = wid->height(); |
1866 | list.clear(); | 1866 | list.clear(); |
1867 | list << QString::number( x ); | 1867 | list << QString::number( x ); |
1868 | list << QString::number( y ); | 1868 | list << QString::number( y ); |
1869 | list << QString::number( w ); | 1869 | list << QString::number( w ); |
1870 | list << QString::number( h ); | 1870 | list << QString::number( h ); |
1871 | config->writeEntry("EditTodoLayout",list ); | 1871 | config->writeEntry("EditTodoLayout",list ); |
1872 | wid = getEventViewerDialog(); | 1872 | wid = getEventViewerDialog(); |
1873 | x = wid->geometry().x(); | 1873 | x = wid->geometry().x(); |
1874 | y = wid->geometry().y(); | 1874 | y = wid->geometry().y(); |
1875 | w = wid->width(); | 1875 | w = wid->width(); |
1876 | h = wid->height(); | 1876 | h = wid->height(); |
1877 | list.clear(); | 1877 | list.clear(); |
1878 | list << QString::number( x ); | 1878 | list << QString::number( x ); |
1879 | list << QString::number( y ); | 1879 | list << QString::number( y ); |
1880 | list << QString::number( w ); | 1880 | list << QString::number( w ); |
1881 | list << QString::number( h ); | 1881 | list << QString::number( h ); |
1882 | config->writeEntry("ViewerLayout",list ); | 1882 | config->writeEntry("ViewerLayout",list ); |
1883 | wid = mDialogManager->getSearchDialog(); | 1883 | wid = mDialogManager->getSearchDialog(); |
1884 | if ( wid ) { | 1884 | if ( wid ) { |
1885 | x = wid->geometry().x(); | 1885 | x = wid->geometry().x(); |
1886 | y = wid->geometry().y(); | 1886 | y = wid->geometry().y(); |
1887 | w = wid->width(); | 1887 | w = wid->width(); |
1888 | h = wid->height(); | 1888 | h = wid->height(); |
1889 | list.clear(); | 1889 | list.clear(); |
1890 | list << QString::number( x ); | 1890 | list << QString::number( x ); |
1891 | list << QString::number( y ); | 1891 | list << QString::number( y ); |
1892 | list << QString::number( w ); | 1892 | list << QString::number( w ); |
1893 | list << QString::number( h ); | 1893 | list << QString::number( h ); |
1894 | config->writeEntry("SearchLayout",list ); | 1894 | config->writeEntry("SearchLayout",list ); |
1895 | } | 1895 | } |
1896 | #endif | 1896 | #endif |
1897 | 1897 | ||
1898 | 1898 | ||
1899 | config->sync(); | 1899 | config->sync(); |
1900 | } | 1900 | } |
1901 | 1901 | ||
1902 | void CalendarView::readFilterSettings(KConfig *config) | 1902 | void CalendarView::readFilterSettings(KConfig *config) |
1903 | { | 1903 | { |
1904 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; | 1904 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; |
1905 | 1905 | ||
1906 | mFilters.clear(); | 1906 | mFilters.clear(); |
1907 | 1907 | ||
1908 | config->setGroup("General"); | 1908 | config->setGroup("General"); |
1909 | QStringList filterList = config->readListEntry("CalendarFilters"); | 1909 | QStringList filterList = config->readListEntry("CalendarFilters"); |
1910 | 1910 | ||
1911 | QStringList::ConstIterator it = filterList.begin(); | 1911 | QStringList::ConstIterator it = filterList.begin(); |
1912 | QStringList::ConstIterator end = filterList.end(); | 1912 | QStringList::ConstIterator end = filterList.end(); |
1913 | while(it != end) { | 1913 | while(it != end) { |
1914 | // kdDebug() << " filter: " << (*it) << endl; | 1914 | // kdDebug() << " filter: " << (*it) << endl; |
1915 | 1915 | ||
1916 | CalFilter *filter; | 1916 | CalFilter *filter; |
1917 | filter = new CalFilter(*it); | 1917 | filter = new CalFilter(*it); |
1918 | config->setGroup("Filter_" + (*it)); | 1918 | config->setGroup("Filter_" + (*it)); |
1919 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); | 1919 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); |
1920 | filter->setCriteria(config->readNumEntry("Criteria",0)); | 1920 | filter->setCriteria(config->readNumEntry("Criteria",0)); |
1921 | filter->setCategoryList(config->readListEntry("CategoryList")); | 1921 | filter->setCategoryList(config->readListEntry("CategoryList")); |
1922 | mFilters.append(filter); | 1922 | mFilters.append(filter); |
1923 | 1923 | ||
1924 | ++it; | 1924 | ++it; |
1925 | } | 1925 | } |
1926 | 1926 | ||
1927 | if (mFilters.count() == 0) { | 1927 | if (mFilters.count() == 0) { |
1928 | CalFilter *filter = new CalFilter(i18n("Default")); | 1928 | CalFilter *filter = new CalFilter(i18n("Default")); |
1929 | mFilters.append(filter); | 1929 | mFilters.append(filter); |
1930 | } | 1930 | } |
1931 | mFilterView->updateFilters(); | 1931 | mFilterView->updateFilters(); |
1932 | config->setGroup("FilterView"); | 1932 | config->setGroup("FilterView"); |
1933 | 1933 | ||
1934 | mFilterView->blockSignals(true); | 1934 | mFilterView->blockSignals(true); |
1935 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); | 1935 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); |
1936 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); | 1936 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); |
1937 | mFilterView->blockSignals(false); | 1937 | mFilterView->blockSignals(false); |
1938 | // We do it manually to avoid it being done twice by the above calls | 1938 | // We do it manually to avoid it being done twice by the above calls |
1939 | updateFilter(); | 1939 | updateFilter(); |
1940 | } | 1940 | } |
1941 | 1941 | ||
1942 | void CalendarView::writeFilterSettings(KConfig *config) | 1942 | void CalendarView::writeFilterSettings(KConfig *config) |
1943 | { | 1943 | { |
1944 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; | 1944 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; |
1945 | 1945 | ||
1946 | QStringList filterList; | 1946 | QStringList filterList; |
1947 | 1947 | ||
1948 | CalFilter *filter = mFilters.first(); | 1948 | CalFilter *filter = mFilters.first(); |
1949 | while(filter) { | 1949 | while(filter) { |
1950 | // kdDebug() << " fn: " << filter->name() << endl; | 1950 | // kdDebug() << " fn: " << filter->name() << endl; |
1951 | filterList << filter->name(); | 1951 | filterList << filter->name(); |
1952 | config->setGroup("Filter_" + filter->name()); | 1952 | config->setGroup("Filter_" + filter->name()); |
1953 | config->writeEntry("Criteria",filter->criteria()); | 1953 | config->writeEntry("Criteria",filter->criteria()); |
1954 | config->writeEntry("CategoryList",filter->categoryList()); | 1954 | config->writeEntry("CategoryList",filter->categoryList()); |
1955 | filter = mFilters.next(); | 1955 | filter = mFilters.next(); |
1956 | } | 1956 | } |
1957 | config->setGroup("General"); | 1957 | config->setGroup("General"); |
1958 | config->writeEntry("CalendarFilters",filterList); | 1958 | config->writeEntry("CalendarFilters",filterList); |
1959 | 1959 | ||
1960 | config->setGroup("FilterView"); | 1960 | config->setGroup("FilterView"); |
1961 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); | 1961 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); |
1962 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); | 1962 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); |
1963 | } | 1963 | } |
1964 | 1964 | ||
1965 | 1965 | ||
1966 | void CalendarView::goToday() | 1966 | void CalendarView::goToday() |
1967 | { | 1967 | { |
1968 | mNavigator->selectToday(); | 1968 | mNavigator->selectToday(); |
1969 | } | 1969 | } |
1970 | 1970 | ||
1971 | void CalendarView::goNext() | 1971 | void CalendarView::goNext() |
1972 | { | 1972 | { |
1973 | mNavigator->selectNext(); | 1973 | mNavigator->selectNext(); |
1974 | } | 1974 | } |
1975 | 1975 | ||
1976 | void CalendarView::goPrevious() | 1976 | void CalendarView::goPrevious() |
1977 | { | 1977 | { |
1978 | mNavigator->selectPrevious(); | 1978 | mNavigator->selectPrevious(); |
1979 | } | 1979 | } |
1980 | void CalendarView::goNextMonth() | 1980 | void CalendarView::goNextMonth() |
1981 | { | 1981 | { |
1982 | mNavigator->selectNextMonth(); | 1982 | mNavigator->selectNextMonth(); |
1983 | } | 1983 | } |
1984 | 1984 | ||
1985 | void CalendarView::goPreviousMonth() | 1985 | void CalendarView::goPreviousMonth() |
1986 | { | 1986 | { |
1987 | mNavigator->selectPreviousMonth(); | 1987 | mNavigator->selectPreviousMonth(); |
1988 | } | 1988 | } |
1989 | void CalendarView::writeLocale() | 1989 | void CalendarView::writeLocale() |
1990 | { | 1990 | { |
1991 | //KPimGlobalPrefs::instance()->setGlobalConfig(); | 1991 | //KPimGlobalPrefs::instance()->setGlobalConfig(); |
1992 | #if 0 | 1992 | #if 0 |
1993 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); | 1993 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); |
1994 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); | 1994 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); |
1995 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); | 1995 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); |
1996 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); | 1996 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); |
1997 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; | 1997 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; |
1998 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); | 1998 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); |
1999 | dummy = KOPrefs::instance()->mUserDateFormatShort; | 1999 | dummy = KOPrefs::instance()->mUserDateFormatShort; |
2000 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); | 2000 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); |
2001 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, | 2001 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, |
2002 | KOPrefs::instance()->mDaylightsavingStart, | 2002 | KOPrefs::instance()->mDaylightsavingStart, |
2003 | KOPrefs::instance()->mDaylightsavingEnd ); | 2003 | KOPrefs::instance()->mDaylightsavingEnd ); |
2004 | KGlobal::locale()->setTimezone( KOPrefs::instance()->mTimeZoneId ); | 2004 | KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); |
2005 | #endif | 2005 | #endif |
2006 | } | 2006 | } |
2007 | void CalendarView::updateConfig() | 2007 | void CalendarView::updateConfig() |
2008 | { | 2008 | { |
2009 | writeLocale(); | 2009 | writeLocale(); |
2010 | if ( KOPrefs::instance()->mUseAppColors ) | 2010 | if ( KOPrefs::instance()->mUseAppColors ) |
2011 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 2011 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
2012 | emit configChanged(); | 2012 | emit configChanged(); |
2013 | mTodoList->updateConfig(); | 2013 | mTodoList->updateConfig(); |
2014 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); | 2014 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); |
2015 | mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 2015 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2016 | // To make the "fill window" configurations work | 2016 | // To make the "fill window" configurations work |
2017 | //mViewManager->raiseCurrentView(); | 2017 | //mViewManager->raiseCurrentView(); |
2018 | } | 2018 | } |
2019 | 2019 | ||
2020 | 2020 | ||
2021 | void CalendarView::eventChanged(Event *event) | 2021 | void CalendarView::eventChanged(Event *event) |
2022 | { | 2022 | { |
2023 | changeEventDisplay(event,KOGlobals::EVENTEDITED); | 2023 | changeEventDisplay(event,KOGlobals::EVENTEDITED); |
2024 | //updateUnmanagedViews(); | 2024 | //updateUnmanagedViews(); |
2025 | } | 2025 | } |
2026 | 2026 | ||
2027 | void CalendarView::eventAdded(Event *event) | 2027 | void CalendarView::eventAdded(Event *event) |
2028 | { | 2028 | { |
2029 | changeEventDisplay(event,KOGlobals::EVENTADDED); | 2029 | changeEventDisplay(event,KOGlobals::EVENTADDED); |
2030 | } | 2030 | } |
2031 | 2031 | ||
2032 | void CalendarView::eventToBeDeleted(Event *) | 2032 | void CalendarView::eventToBeDeleted(Event *) |
2033 | { | 2033 | { |
2034 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; | 2034 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; |
2035 | } | 2035 | } |
2036 | 2036 | ||
2037 | void CalendarView::eventDeleted() | 2037 | void CalendarView::eventDeleted() |
2038 | { | 2038 | { |
2039 | changeEventDisplay(0,KOGlobals::EVENTDELETED); | 2039 | changeEventDisplay(0,KOGlobals::EVENTDELETED); |
2040 | } | 2040 | } |
2041 | void CalendarView::changeTodoDisplay(Todo *which, int action) | 2041 | void CalendarView::changeTodoDisplay(Todo *which, int action) |
2042 | { | 2042 | { |
2043 | changeIncidenceDisplay((Incidence *)which, action); | 2043 | changeIncidenceDisplay((Incidence *)which, action); |
2044 | mDateNavigator->updateView(); //LR | 2044 | mDateNavigator->updateView(); //LR |
2045 | //mDialogManager->updateSearchDialog(); | 2045 | //mDialogManager->updateSearchDialog(); |
2046 | 2046 | ||
2047 | if (which) { | 2047 | if (which) { |
2048 | mViewManager->updateWNview(); | 2048 | mViewManager->updateWNview(); |
2049 | //mTodoList->updateView(); | 2049 | //mTodoList->updateView(); |
2050 | } | 2050 | } |
2051 | 2051 | ||
2052 | } | 2052 | } |
2053 | 2053 | ||
2054 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) | 2054 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) |
2055 | { | 2055 | { |
2056 | updateUnmanagedViews(); | 2056 | updateUnmanagedViews(); |
2057 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); | 2057 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); |
2058 | if ( action == KOGlobals::EVENTDELETED ) { //delete | 2058 | if ( action == KOGlobals::EVENTDELETED ) { //delete |
2059 | mCalendar->checkAlarmForIncidence( 0, true ); | 2059 | mCalendar->checkAlarmForIncidence( 0, true ); |
2060 | if ( mEventViewerDialog ) | 2060 | if ( mEventViewerDialog ) |
2061 | mEventViewerDialog->hide(); | 2061 | mEventViewerDialog->hide(); |
2062 | } | 2062 | } |
2063 | else | 2063 | else |
2064 | mCalendar->checkAlarmForIncidence( which , false ); | 2064 | mCalendar->checkAlarmForIncidence( which , false ); |
2065 | } | 2065 | } |
2066 | 2066 | ||
2067 | // most of the changeEventDisplays() right now just call the view's | 2067 | // most of the changeEventDisplays() right now just call the view's |
2068 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. | 2068 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. |
2069 | void CalendarView::changeEventDisplay(Event *which, int action) | 2069 | void CalendarView::changeEventDisplay(Event *which, int action) |
2070 | { | 2070 | { |
2071 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; | 2071 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; |
2072 | changeIncidenceDisplay((Incidence *)which, action); | 2072 | changeIncidenceDisplay((Incidence *)which, action); |
2073 | mDateNavigator->updateView(); | 2073 | mDateNavigator->updateView(); |
2074 | //mDialogManager->updateSearchDialog(); | 2074 | //mDialogManager->updateSearchDialog(); |
2075 | 2075 | ||
2076 | if (which) { | 2076 | if (which) { |
2077 | // If there is an event view visible update the display | 2077 | // If there is an event view visible update the display |
2078 | mViewManager->currentView()->changeEventDisplay(which,action); | 2078 | mViewManager->currentView()->changeEventDisplay(which,action); |
2079 | // TODO: check, if update needed | 2079 | // TODO: check, if update needed |
2080 | // if (which->getTodoStatus()) { | 2080 | // if (which->getTodoStatus()) { |
2081 | mTodoList->updateView(); | 2081 | mTodoList->updateView(); |
2082 | // } | 2082 | // } |
2083 | } else { | 2083 | } else { |
2084 | mViewManager->currentView()->updateView(); | 2084 | mViewManager->currentView()->updateView(); |
2085 | } | 2085 | } |
2086 | } | 2086 | } |
2087 | 2087 | ||
2088 | 2088 | ||
2089 | void CalendarView::updateTodoViews() | 2089 | void CalendarView::updateTodoViews() |
2090 | { | 2090 | { |
2091 | 2091 | ||
2092 | mTodoList->updateView(); | 2092 | mTodoList->updateView(); |
2093 | mViewManager->currentView()->updateView(); | 2093 | mViewManager->currentView()->updateView(); |
2094 | 2094 | ||
2095 | } | 2095 | } |
2096 | 2096 | ||
2097 | 2097 | ||
2098 | void CalendarView::updateView(const QDate &start, const QDate &end) | 2098 | void CalendarView::updateView(const QDate &start, const QDate &end) |
2099 | { | 2099 | { |
2100 | mTodoList->updateView(); | 2100 | mTodoList->updateView(); |
2101 | mViewManager->updateView(start, end); | 2101 | mViewManager->updateView(start, end); |
2102 | //mDateNavigator->updateView(); | 2102 | //mDateNavigator->updateView(); |
2103 | } | 2103 | } |
2104 | 2104 | ||
2105 | void CalendarView::updateView() | 2105 | void CalendarView::updateView() |
2106 | { | 2106 | { |
2107 | DateList tmpList = mNavigator->selectedDates(); | 2107 | DateList tmpList = mNavigator->selectedDates(); |
2108 | 2108 | ||
2109 | // We assume that the navigator only selects consecutive days. | 2109 | // We assume that the navigator only selects consecutive days. |
2110 | updateView( tmpList.first(), tmpList.last() ); | 2110 | updateView( tmpList.first(), tmpList.last() ); |
2111 | } | 2111 | } |
2112 | 2112 | ||
2113 | void CalendarView::updateUnmanagedViews() | 2113 | void CalendarView::updateUnmanagedViews() |
2114 | { | 2114 | { |
2115 | mDateNavigator->updateDayMatrix(); | 2115 | mDateNavigator->updateDayMatrix(); |
2116 | } | 2116 | } |
2117 | 2117 | ||
2118 | int CalendarView::msgItemDelete() | 2118 | int CalendarView::msgItemDelete() |
2119 | { | 2119 | { |
2120 | return KMessageBox::warningContinueCancel(this, | 2120 | return KMessageBox::warningContinueCancel(this, |
2121 | i18n("This item will be\npermanently deleted."), | 2121 | i18n("This item will be\npermanently deleted."), |
2122 | i18n("KO/Pi Confirmation"),i18n("Delete")); | 2122 | i18n("KO/Pi Confirmation"),i18n("Delete")); |
2123 | } | 2123 | } |
2124 | 2124 | ||
2125 | 2125 | ||
2126 | void CalendarView::edit_cut() | 2126 | void CalendarView::edit_cut() |
2127 | { | 2127 | { |
2128 | Event *anEvent=0; | 2128 | Event *anEvent=0; |
2129 | 2129 | ||
2130 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2130 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2131 | 2131 | ||
2132 | if (mViewManager->currentView()->isEventView()) { | 2132 | if (mViewManager->currentView()->isEventView()) { |
2133 | if ( incidence && incidence->type() == "Event" ) { | 2133 | if ( incidence && incidence->type() == "Event" ) { |
2134 | anEvent = static_cast<Event *>(incidence); | 2134 | anEvent = static_cast<Event *>(incidence); |
2135 | } | 2135 | } |
2136 | } | 2136 | } |
2137 | 2137 | ||
2138 | if (!anEvent) { | 2138 | if (!anEvent) { |
2139 | KNotifyClient::beep(); | 2139 | KNotifyClient::beep(); |
2140 | return; | 2140 | return; |
2141 | } | 2141 | } |
2142 | DndFactory factory( mCalendar ); | 2142 | DndFactory factory( mCalendar ); |
2143 | factory.cutEvent(anEvent); | 2143 | factory.cutEvent(anEvent); |
2144 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2144 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2145 | } | 2145 | } |
2146 | 2146 | ||
2147 | void CalendarView::edit_copy() | 2147 | void CalendarView::edit_copy() |
2148 | { | 2148 | { |
2149 | Event *anEvent=0; | 2149 | Event *anEvent=0; |
2150 | 2150 | ||
2151 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2151 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2152 | 2152 | ||
2153 | if (mViewManager->currentView()->isEventView()) { | 2153 | if (mViewManager->currentView()->isEventView()) { |
2154 | if ( incidence && incidence->type() == "Event" ) { | 2154 | if ( incidence && incidence->type() == "Event" ) { |
2155 | anEvent = static_cast<Event *>(incidence); | 2155 | anEvent = static_cast<Event *>(incidence); |
2156 | } | 2156 | } |
2157 | } | 2157 | } |
2158 | 2158 | ||
2159 | if (!anEvent) { | 2159 | if (!anEvent) { |
2160 | KNotifyClient::beep(); | 2160 | KNotifyClient::beep(); |
2161 | return; | 2161 | return; |
2162 | } | 2162 | } |
2163 | DndFactory factory( mCalendar ); | 2163 | DndFactory factory( mCalendar ); |
2164 | factory.copyEvent(anEvent); | 2164 | factory.copyEvent(anEvent); |
2165 | } | 2165 | } |
2166 | 2166 | ||
2167 | void CalendarView::edit_paste() | 2167 | void CalendarView::edit_paste() |
2168 | { | 2168 | { |
2169 | QDate date = mNavigator->selectedDates().first(); | 2169 | QDate date = mNavigator->selectedDates().first(); |
2170 | 2170 | ||
2171 | DndFactory factory( mCalendar ); | 2171 | DndFactory factory( mCalendar ); |
2172 | Event *pastedEvent = factory.pasteEvent( date ); | 2172 | Event *pastedEvent = factory.pasteEvent( date ); |
2173 | 2173 | ||
2174 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); | 2174 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); |
2175 | } | 2175 | } |
2176 | 2176 | ||
2177 | void CalendarView::edit_options() | 2177 | void CalendarView::edit_options() |
2178 | { | 2178 | { |
2179 | mDialogManager->showOptionsDialog(); | 2179 | mDialogManager->showOptionsDialog(); |
2180 | //writeSettings(); | 2180 | //writeSettings(); |
2181 | } | 2181 | } |
2182 | 2182 | ||
2183 | void CalendarView::slotSelectPickerDate( QDate d) | 2183 | void CalendarView::slotSelectPickerDate( QDate d) |
2184 | { | 2184 | { |
2185 | mDateFrame->hide(); | 2185 | mDateFrame->hide(); |
2186 | if ( mDatePickerMode == 1 ) { | 2186 | if ( mDatePickerMode == 1 ) { |
2187 | mNavigator->slotDaySelect( d ); | 2187 | mNavigator->slotDaySelect( d ); |
2188 | } else if ( mDatePickerMode == 2 ) { | 2188 | } else if ( mDatePickerMode == 2 ) { |
2189 | if ( mMoveIncidence->type() == "Todo" ) { | 2189 | if ( mMoveIncidence->type() == "Todo" ) { |
2190 | Todo * to = (Todo *) mMoveIncidence; | 2190 | Todo * to = (Todo *) mMoveIncidence; |
2191 | QTime tim; | 2191 | QTime tim; |
2192 | if ( to->hasDueDate() ) | 2192 | if ( to->hasDueDate() ) |
2193 | tim = to->dtDue().time(); | 2193 | tim = to->dtDue().time(); |
2194 | else { | 2194 | else { |
2195 | tim = QTime ( 0,0,0 ); | 2195 | tim = QTime ( 0,0,0 ); |
2196 | to->setFloats( true ); | 2196 | to->setFloats( true ); |
2197 | to->setHasDueDate( true ); | 2197 | to->setHasDueDate( true ); |
2198 | } | 2198 | } |
2199 | QDateTime dt ( d,tim ); | 2199 | QDateTime dt ( d,tim ); |
2200 | to->setDtDue( dt ); | 2200 | to->setDtDue( dt ); |
2201 | todoChanged( to ); | 2201 | todoChanged( to ); |
2202 | } else { | 2202 | } else { |
2203 | QTime tim = mMoveIncidence->dtStart().time(); | 2203 | QTime tim = mMoveIncidence->dtStart().time(); |
2204 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); | 2204 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); |
2205 | QDateTime dt ( d,tim ); | 2205 | QDateTime dt ( d,tim ); |
2206 | mMoveIncidence->setDtStart( dt ); | 2206 | mMoveIncidence->setDtStart( dt ); |
2207 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); | 2207 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); |
2208 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); | 2208 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); |
2209 | } | 2209 | } |
2210 | 2210 | ||
2211 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); | 2211 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); |
2212 | } | 2212 | } |
2213 | } | 2213 | } |
2214 | 2214 | ||
2215 | void CalendarView::removeCategories() | 2215 | void CalendarView::removeCategories() |
2216 | { | 2216 | { |
2217 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2217 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2218 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2218 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2219 | QStringList catIncList; | 2219 | QStringList catIncList; |
2220 | QStringList newCatList; | 2220 | QStringList newCatList; |
2221 | Incidence* inc = incList.first(); | 2221 | Incidence* inc = incList.first(); |
2222 | int i; | 2222 | int i; |
2223 | int count = 0; | 2223 | int count = 0; |
2224 | while ( inc ) { | 2224 | while ( inc ) { |
2225 | newCatList.clear(); | 2225 | newCatList.clear(); |
2226 | catIncList = inc->categories() ; | 2226 | catIncList = inc->categories() ; |
2227 | for( i = 0; i< catIncList.count(); ++i ) { | 2227 | for( i = 0; i< catIncList.count(); ++i ) { |
2228 | if ( catList.contains (catIncList[i])) | 2228 | if ( catList.contains (catIncList[i])) |
2229 | newCatList.append( catIncList[i] ); | 2229 | newCatList.append( catIncList[i] ); |
2230 | } | 2230 | } |
2231 | newCatList.sort(); | 2231 | newCatList.sort(); |
2232 | inc->setCategories( newCatList.join(",") ); | 2232 | inc->setCategories( newCatList.join(",") ); |
2233 | inc = incList.next(); | 2233 | inc = incList.next(); |
2234 | } | 2234 | } |
2235 | } | 2235 | } |
2236 | 2236 | ||
2237 | int CalendarView::addCategories() | 2237 | int CalendarView::addCategories() |
2238 | { | 2238 | { |
2239 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2239 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2240 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2240 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2241 | QStringList catIncList; | 2241 | QStringList catIncList; |
2242 | Incidence* inc = incList.first(); | 2242 | Incidence* inc = incList.first(); |
2243 | int i; | 2243 | int i; |
2244 | int count = 0; | 2244 | int count = 0; |
2245 | while ( inc ) { | 2245 | while ( inc ) { |
2246 | catIncList = inc->categories() ; | 2246 | catIncList = inc->categories() ; |
2247 | for( i = 0; i< catIncList.count(); ++i ) { | 2247 | for( i = 0; i< catIncList.count(); ++i ) { |
2248 | if ( !catList.contains (catIncList[i])) { | 2248 | if ( !catList.contains (catIncList[i])) { |
2249 | catList.append( catIncList[i] ); | 2249 | catList.append( catIncList[i] ); |
2250 | //qDebug("add cat %s ", catIncList[i].latin1()); | 2250 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2251 | ++count; | 2251 | ++count; |
2252 | } | 2252 | } |
2253 | } | 2253 | } |
2254 | inc = incList.next(); | 2254 | inc = incList.next(); |
2255 | } | 2255 | } |
2256 | catList.sort(); | 2256 | catList.sort(); |
2257 | KOPrefs::instance()->mCustomCategories = catList; | 2257 | KOPrefs::instance()->mCustomCategories = catList; |
2258 | return count; | 2258 | return count; |
2259 | } | 2259 | } |
2260 | 2260 | ||
2261 | void CalendarView::manageCategories() | 2261 | void CalendarView::manageCategories() |
2262 | { | 2262 | { |
2263 | KOCatPrefs* cp = new KOCatPrefs(); | 2263 | KOCatPrefs* cp = new KOCatPrefs(); |
2264 | cp->show(); | 2264 | cp->show(); |
2265 | int w =cp->sizeHint().width() ; | 2265 | int w =cp->sizeHint().width() ; |
2266 | int h = cp->sizeHint().height() ; | 2266 | int h = cp->sizeHint().height() ; |
2267 | int dw = QApplication::desktop()->width(); | 2267 | int dw = QApplication::desktop()->width(); |
2268 | int dh = QApplication::desktop()->height(); | 2268 | int dh = QApplication::desktop()->height(); |
2269 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2269 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2270 | if ( !cp->exec() ) { | 2270 | if ( !cp->exec() ) { |
2271 | delete cp; | 2271 | delete cp; |
2272 | return; | 2272 | return; |
2273 | } | 2273 | } |
2274 | int count = 0; | 2274 | int count = 0; |
2275 | if ( cp->addCat() ) { | 2275 | if ( cp->addCat() ) { |
2276 | count = addCategories(); | 2276 | count = addCategories(); |
2277 | if ( count ) { | 2277 | if ( count ) { |
2278 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); | 2278 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); |
2279 | writeSettings(); | 2279 | writeSettings(); |
2280 | } | 2280 | } |
2281 | } else { | 2281 | } else { |
2282 | removeCategories(); | 2282 | removeCategories(); |
2283 | updateView(); | 2283 | updateView(); |
2284 | } | 2284 | } |
2285 | delete cp; | 2285 | delete cp; |
2286 | } | 2286 | } |
2287 | 2287 | ||
2288 | void CalendarView::beamIncidence(Incidence * Inc) | 2288 | void CalendarView::beamIncidence(Incidence * Inc) |
2289 | { | 2289 | { |
2290 | QPtrList<Incidence> delSel ; | 2290 | QPtrList<Incidence> delSel ; |
2291 | delSel.append(Inc); | 2291 | delSel.append(Inc); |
2292 | beamIncidenceList( delSel ); | 2292 | beamIncidenceList( delSel ); |
2293 | } | 2293 | } |
2294 | void CalendarView::beamCalendar() | 2294 | void CalendarView::beamCalendar() |
2295 | { | 2295 | { |
2296 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); | 2296 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); |
2297 | //qDebug("beamCalendar() "); | 2297 | //qDebug("beamCalendar() "); |
2298 | beamIncidenceList( delSel ); | 2298 | beamIncidenceList( delSel ); |
2299 | } | 2299 | } |
2300 | void CalendarView::beamFilteredCalendar() | 2300 | void CalendarView::beamFilteredCalendar() |
2301 | { | 2301 | { |
2302 | QPtrList<Incidence> delSel = mCalendar->incidences(); | 2302 | QPtrList<Incidence> delSel = mCalendar->incidences(); |
2303 | //qDebug("beamFilteredCalendar() "); | 2303 | //qDebug("beamFilteredCalendar() "); |
2304 | beamIncidenceList( delSel ); | 2304 | beamIncidenceList( delSel ); |
2305 | } | 2305 | } |
2306 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | 2306 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) |
2307 | { | 2307 | { |
2308 | if ( beamDialog->exec () == QDialog::Rejected ) | 2308 | if ( beamDialog->exec () == QDialog::Rejected ) |
2309 | return; | 2309 | return; |
2310 | #ifdef DESKTOP_VERSION | 2310 | #ifdef DESKTOP_VERSION |
2311 | QString fn = locateLocal( "tmp", "kopibeamfile" ); | 2311 | QString fn = locateLocal( "tmp", "kopibeamfile" ); |
2312 | #else | 2312 | #else |
2313 | QString fn = "/tmp/kopibeamfile"; | 2313 | QString fn = "/tmp/kopibeamfile"; |
2314 | #endif | 2314 | #endif |
2315 | QString mes; | 2315 | QString mes; |
2316 | bool createbup = true; | 2316 | bool createbup = true; |
2317 | if ( createbup ) { | 2317 | if ( createbup ) { |
2318 | QString description = "\n"; | 2318 | QString description = "\n"; |
2319 | CalendarLocal* cal = new CalendarLocal(); | 2319 | CalendarLocal* cal = new CalendarLocal(); |
2320 | if ( beamDialog->beamLocal() ) | 2320 | if ( beamDialog->beamLocal() ) |
2321 | cal->setLocalTime(); | 2321 | cal->setLocalTime(); |
2322 | else | 2322 | else |
2323 | cal->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 2323 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2324 | Incidence *incidence = delSel.first(); | 2324 | Incidence *incidence = delSel.first(); |
2325 | bool addText = false; | 2325 | bool addText = false; |
2326 | if ( delSel.count() < 10 ) | 2326 | if ( delSel.count() < 10 ) |
2327 | addText = true; | 2327 | addText = true; |
2328 | else { | 2328 | else { |
2329 | description.sprintf(i18n(" %d items?"),delSel.count() ); | 2329 | description.sprintf(i18n(" %d items?"),delSel.count() ); |
2330 | } | 2330 | } |
2331 | while ( incidence ) { | 2331 | while ( incidence ) { |
2332 | Incidence *in = incidence->clone(); | 2332 | Incidence *in = incidence->clone(); |
2333 | if ( ! in->summary().isEmpty() ) { | 2333 | if ( ! in->summary().isEmpty() ) { |
2334 | in->setDescription(""); | 2334 | in->setDescription(""); |
2335 | } else { | 2335 | } else { |
2336 | in->setSummary( in->description().left(20)); | 2336 | in->setSummary( in->description().left(20)); |
2337 | in->setDescription(""); | 2337 | in->setDescription(""); |
2338 | } | 2338 | } |
2339 | if ( addText ) | 2339 | if ( addText ) |
2340 | description += in->summary() + "\n"; | 2340 | description += in->summary() + "\n"; |
2341 | cal->addIncidence( in ); | 2341 | cal->addIncidence( in ); |
2342 | incidence = delSel.next(); | 2342 | incidence = delSel.next(); |
2343 | } | 2343 | } |
2344 | if ( beamDialog->beamVcal() ) { | 2344 | if ( beamDialog->beamVcal() ) { |
2345 | fn += ".vcs"; | 2345 | fn += ".vcs"; |
2346 | FileStorage storage( cal, fn, new VCalFormat ); | 2346 | FileStorage storage( cal, fn, new VCalFormat ); |
2347 | storage.save(); | 2347 | storage.save(); |
2348 | } else { | 2348 | } else { |
2349 | fn += ".ics"; | 2349 | fn += ".ics"; |
2350 | FileStorage storage( cal, fn, new ICalFormat( ) ); | 2350 | FileStorage storage( cal, fn, new ICalFormat( ) ); |
2351 | storage.save(); | 2351 | storage.save(); |
2352 | } | 2352 | } |
2353 | delete cal; | 2353 | delete cal; |
2354 | mes = i18n("KO/Pi: Ready for beaming"); | 2354 | mes = i18n("KO/Pi: Ready for beaming"); |
2355 | topLevelWidget()->setCaption(mes); | 2355 | topLevelWidget()->setCaption(mes); |
2356 | KApplication::convert2latin1( fn ); | 2356 | KApplication::convert2latin1( fn ); |
2357 | #ifndef DESKTOP_VERSION | 2357 | #ifndef DESKTOP_VERSION |
2358 | Ir *ir = new Ir( this ); | 2358 | Ir *ir = new Ir( this ); |
2359 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 2359 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
2360 | ir->send( fn, description, "text/x-vCalendar" ); | 2360 | ir->send( fn, description, "text/x-vCalendar" ); |
2361 | #endif | 2361 | #endif |
2362 | } | 2362 | } |
2363 | } | 2363 | } |
2364 | void CalendarView::beamDone( Ir *ir ) | 2364 | void CalendarView::beamDone( Ir *ir ) |
2365 | { | 2365 | { |
2366 | #ifndef DESKTOP_VERSION | 2366 | #ifndef DESKTOP_VERSION |
2367 | delete ir; | 2367 | delete ir; |
2368 | #endif | 2368 | #endif |
2369 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); | 2369 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); |
2370 | topLevelWidget()->raise(); | 2370 | topLevelWidget()->raise(); |
2371 | } | 2371 | } |
2372 | 2372 | ||
2373 | void CalendarView::moveIncidence(Incidence * inc ) | 2373 | void CalendarView::moveIncidence(Incidence * inc ) |
2374 | { | 2374 | { |
2375 | if ( !inc ) return; | 2375 | if ( !inc ) return; |
2376 | // qDebug("showDatePickerForIncidence( ) "); | 2376 | // qDebug("showDatePickerForIncidence( ) "); |
2377 | if ( mDateFrame->isVisible() ) | 2377 | if ( mDateFrame->isVisible() ) |
2378 | mDateFrame->hide(); | 2378 | mDateFrame->hide(); |
2379 | else { | 2379 | else { |
2380 | int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; | 2380 | int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; |
2381 | int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; | 2381 | int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; |
2382 | int dw = QApplication::desktop()->width(); | 2382 | int dw = QApplication::desktop()->width(); |
2383 | int dh = QApplication::desktop()->height(); | 2383 | int dh = QApplication::desktop()->height(); |
2384 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2384 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2385 | mDateFrame->show(); | 2385 | mDateFrame->show(); |
2386 | } | 2386 | } |
2387 | mDatePickerMode = 2; | 2387 | mDatePickerMode = 2; |
2388 | mMoveIncidence = inc ; | 2388 | mMoveIncidence = inc ; |
2389 | QDate da; | 2389 | QDate da; |
2390 | if ( mMoveIncidence->type() == "Todo" ) { | 2390 | if ( mMoveIncidence->type() == "Todo" ) { |
2391 | Todo * to = (Todo *) mMoveIncidence; | 2391 | Todo * to = (Todo *) mMoveIncidence; |
2392 | if ( to->hasDueDate() ) | 2392 | if ( to->hasDueDate() ) |
2393 | da = to->dtDue().date(); | 2393 | da = to->dtDue().date(); |
2394 | else | 2394 | else |
2395 | da = QDate::currentDate(); | 2395 | da = QDate::currentDate(); |
2396 | } else { | 2396 | } else { |
2397 | da = mMoveIncidence->dtStart().date(); | 2397 | da = mMoveIncidence->dtStart().date(); |
2398 | } | 2398 | } |
2399 | mDatePicker->setDate( da ); | 2399 | mDatePicker->setDate( da ); |
2400 | } | 2400 | } |
2401 | void CalendarView::showDatePicker( ) | 2401 | void CalendarView::showDatePicker( ) |
2402 | { | 2402 | { |
2403 | //qDebug("CalendarView::showDatePicker( ) "); | 2403 | //qDebug("CalendarView::showDatePicker( ) "); |
2404 | if ( mDateFrame->isVisible() ) | 2404 | if ( mDateFrame->isVisible() ) |
2405 | mDateFrame->hide(); | 2405 | mDateFrame->hide(); |
2406 | else { | 2406 | else { |
2407 | int w =mDatePicker->sizeHint().width() ; | 2407 | int w =mDatePicker->sizeHint().width() ; |
2408 | int h = mDatePicker->sizeHint().height() ; | 2408 | int h = mDatePicker->sizeHint().height() ; |
2409 | int dw = QApplication::desktop()->width(); | 2409 | int dw = QApplication::desktop()->width(); |
2410 | int dh = QApplication::desktop()->height(); | 2410 | int dh = QApplication::desktop()->height(); |
2411 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2411 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2412 | mDateFrame->show(); | 2412 | mDateFrame->show(); |
2413 | } | 2413 | } |
2414 | mDatePickerMode = 1; | 2414 | mDatePickerMode = 1; |
2415 | mDatePicker->setDate( mNavigator->selectedDates().first() ); | 2415 | mDatePicker->setDate( mNavigator->selectedDates().first() ); |
2416 | } | 2416 | } |
2417 | 2417 | ||
2418 | void CalendarView::showEventEditor() | 2418 | void CalendarView::showEventEditor() |
2419 | { | 2419 | { |
2420 | #ifdef DESKTOP_VERSION | 2420 | #ifdef DESKTOP_VERSION |
2421 | mEventEditor->show(); | 2421 | mEventEditor->show(); |
2422 | #else | 2422 | #else |
2423 | mEventEditor->showMaximized(); | 2423 | mEventEditor->showMaximized(); |
2424 | #endif | 2424 | #endif |
2425 | } | 2425 | } |
2426 | void CalendarView::showTodoEditor() | 2426 | void CalendarView::showTodoEditor() |
2427 | { | 2427 | { |
2428 | #ifdef DESKTOP_VERSION | 2428 | #ifdef DESKTOP_VERSION |
2429 | mTodoEditor->show(); | 2429 | mTodoEditor->show(); |
2430 | #else | 2430 | #else |
2431 | mTodoEditor->showMaximized(); | 2431 | mTodoEditor->showMaximized(); |
2432 | #endif | 2432 | #endif |
2433 | } | 2433 | } |
2434 | 2434 | ||
2435 | void CalendarView::cloneIncidence() | 2435 | void CalendarView::cloneIncidence() |
2436 | { | 2436 | { |
2437 | Incidence *incidence = currentSelection(); | 2437 | Incidence *incidence = currentSelection(); |
2438 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2438 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2439 | if ( incidence ) { | 2439 | if ( incidence ) { |
2440 | cloneIncidence(incidence); | 2440 | cloneIncidence(incidence); |
2441 | } | 2441 | } |
2442 | } | 2442 | } |
2443 | void CalendarView::moveIncidence() | 2443 | void CalendarView::moveIncidence() |
2444 | { | 2444 | { |
2445 | Incidence *incidence = currentSelection(); | 2445 | Incidence *incidence = currentSelection(); |
2446 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2446 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2447 | if ( incidence ) { | 2447 | if ( incidence ) { |
2448 | moveIncidence(incidence); | 2448 | moveIncidence(incidence); |
2449 | } | 2449 | } |
2450 | } | 2450 | } |
2451 | void CalendarView::beamIncidence() | 2451 | void CalendarView::beamIncidence() |
2452 | { | 2452 | { |
2453 | Incidence *incidence = currentSelection(); | 2453 | Incidence *incidence = currentSelection(); |
2454 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2454 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2455 | if ( incidence ) { | 2455 | if ( incidence ) { |
2456 | beamIncidence(incidence); | 2456 | beamIncidence(incidence); |
2457 | } | 2457 | } |
2458 | } | 2458 | } |
2459 | void CalendarView::toggleCancelIncidence() | 2459 | void CalendarView::toggleCancelIncidence() |
2460 | { | 2460 | { |
2461 | Incidence *incidence = currentSelection(); | 2461 | Incidence *incidence = currentSelection(); |
2462 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2462 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2463 | if ( incidence ) { | 2463 | if ( incidence ) { |
2464 | cancelIncidence(incidence); | 2464 | cancelIncidence(incidence); |
2465 | } | 2465 | } |
2466 | } | 2466 | } |
2467 | 2467 | ||
2468 | 2468 | ||
2469 | void CalendarView::cancelIncidence(Incidence * inc ) | 2469 | void CalendarView::cancelIncidence(Incidence * inc ) |
2470 | { | 2470 | { |
2471 | inc->setCancelled( ! inc->cancelled() ); | 2471 | inc->setCancelled( ! inc->cancelled() ); |
2472 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); | 2472 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); |
2473 | updateView(); | 2473 | updateView(); |
2474 | } | 2474 | } |
2475 | void CalendarView::cloneIncidence(Incidence * orgInc ) | 2475 | void CalendarView::cloneIncidence(Incidence * orgInc ) |
2476 | { | 2476 | { |
2477 | Incidence * newInc = orgInc->clone(); | 2477 | Incidence * newInc = orgInc->clone(); |
2478 | newInc->recreate(); | 2478 | newInc->recreate(); |
2479 | 2479 | ||
2480 | if ( newInc->type() == "Todo" ) { | 2480 | if ( newInc->type() == "Todo" ) { |
2481 | Todo* t = (Todo*) newInc; | 2481 | Todo* t = (Todo*) newInc; |
2482 | mTodoEditor->editTodo( t ); | 2482 | mTodoEditor->editTodo( t ); |
2483 | showTodoEditor(); | 2483 | showTodoEditor(); |
2484 | if ( mTodoEditor->exec() ) { | 2484 | if ( mTodoEditor->exec() ) { |
2485 | mCalendar->addTodo( t ); | 2485 | mCalendar->addTodo( t ); |
2486 | updateView(); | 2486 | updateView(); |
2487 | } else { | 2487 | } else { |
2488 | delete t; | 2488 | delete t; |
2489 | } | 2489 | } |
2490 | } | 2490 | } |
2491 | else { | 2491 | else { |
2492 | Event* e = (Event*) newInc; | 2492 | Event* e = (Event*) newInc; |
2493 | mEventEditor->editEvent( e ); | 2493 | mEventEditor->editEvent( e ); |
2494 | showEventEditor(); | 2494 | showEventEditor(); |
2495 | if ( mEventEditor->exec() ) { | 2495 | if ( mEventEditor->exec() ) { |
2496 | mCalendar->addEvent( e ); | 2496 | mCalendar->addEvent( e ); |
2497 | updateView(); | 2497 | updateView(); |
2498 | } else { | 2498 | } else { |
2499 | delete e; | 2499 | delete e; |
2500 | } | 2500 | } |
2501 | } | 2501 | } |
2502 | } | 2502 | } |
2503 | 2503 | ||
2504 | void CalendarView::newEvent() | 2504 | void CalendarView::newEvent() |
2505 | { | 2505 | { |
2506 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. | 2506 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. |
2507 | KOAgendaView *aView = mViewManager->agendaView(); | 2507 | KOAgendaView *aView = mViewManager->agendaView(); |
2508 | if (aView) { | 2508 | if (aView) { |
2509 | if (aView->selectionStart().isValid()) { | 2509 | if (aView->selectionStart().isValid()) { |
2510 | if (aView->selectedIsAllDay()) { | 2510 | if (aView->selectedIsAllDay()) { |
2511 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); | 2511 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); |
2512 | } else { | 2512 | } else { |
2513 | newEvent(aView->selectionStart(),aView->selectionEnd()); | 2513 | newEvent(aView->selectionStart(),aView->selectionEnd()); |
2514 | } | 2514 | } |
2515 | return; | 2515 | return; |
2516 | } | 2516 | } |
2517 | } | 2517 | } |
2518 | 2518 | ||
2519 | QDate date = mNavigator->selectedDates().first(); | 2519 | QDate date = mNavigator->selectedDates().first(); |
2520 | QDateTime current = QDateTime::currentDateTime(); | 2520 | QDateTime current = QDateTime::currentDateTime(); |
2521 | if ( date <= current.date() ) { | 2521 | if ( date <= current.date() ) { |
2522 | int hour = current.time().hour() +1; | 2522 | int hour = current.time().hour() +1; |
2523 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), | 2523 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), |
2524 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2524 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2525 | } else | 2525 | } else |
2526 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), | 2526 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), |
2527 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + | 2527 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + |
2528 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2528 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2529 | } | 2529 | } |
2530 | 2530 | ||
2531 | void CalendarView::newEvent(QDateTime fh) | 2531 | void CalendarView::newEvent(QDateTime fh) |
2532 | { | 2532 | { |
2533 | newEvent(fh, | 2533 | newEvent(fh, |
2534 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); | 2534 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); |
2535 | } | 2535 | } |
2536 | 2536 | ||
2537 | void CalendarView::newEvent(QDate dt) | 2537 | void CalendarView::newEvent(QDate dt) |
2538 | { | 2538 | { |
2539 | newEvent(QDateTime(dt, QTime(0,0,0)), | 2539 | newEvent(QDateTime(dt, QTime(0,0,0)), |
2540 | QDateTime(dt, QTime(0,0,0)), true); | 2540 | QDateTime(dt, QTime(0,0,0)), true); |
2541 | } | 2541 | } |
2542 | 2542 | ||
2543 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) | 2543 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) |
2544 | { | 2544 | { |
2545 | 2545 | ||
2546 | mEventEditor->newEvent(fromHint,toHint,allDay); | 2546 | mEventEditor->newEvent(fromHint,toHint,allDay); |
2547 | if ( mFilterView->filtersEnabled() ) { | 2547 | if ( mFilterView->filtersEnabled() ) { |
2548 | CalFilter *filter = mFilterView->selectedFilter(); | 2548 | CalFilter *filter = mFilterView->selectedFilter(); |
2549 | if (filter && filter->showCategories()) { | 2549 | if (filter && filter->showCategories()) { |
2550 | mEventEditor->setCategories(filter->categoryList().join(",") ); | 2550 | mEventEditor->setCategories(filter->categoryList().join(",") ); |
2551 | } | 2551 | } |
2552 | if ( filter ) | 2552 | if ( filter ) |
2553 | mEventEditor->setSecrecy( filter->getSecrecy() ); | 2553 | mEventEditor->setSecrecy( filter->getSecrecy() ); |
2554 | } | 2554 | } |
2555 | showEventEditor(); | 2555 | showEventEditor(); |
2556 | } | 2556 | } |
2557 | void CalendarView::todoAdded(Todo * t) | 2557 | void CalendarView::todoAdded(Todo * t) |
2558 | { | 2558 | { |
2559 | 2559 | ||
2560 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); | 2560 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); |
2561 | updateTodoViews(); | 2561 | updateTodoViews(); |
2562 | } | 2562 | } |
2563 | void CalendarView::todoChanged(Todo * t) | 2563 | void CalendarView::todoChanged(Todo * t) |
2564 | { | 2564 | { |
2565 | emit todoModified( t, 4 ); | 2565 | emit todoModified( t, 4 ); |
2566 | // updateTodoViews(); | 2566 | // updateTodoViews(); |
2567 | } | 2567 | } |
2568 | void CalendarView::todoToBeDeleted(Todo *) | 2568 | void CalendarView::todoToBeDeleted(Todo *) |
2569 | { | 2569 | { |
2570 | //qDebug("todoToBeDeleted(Todo *) "); | 2570 | //qDebug("todoToBeDeleted(Todo *) "); |
2571 | updateTodoViews(); | 2571 | updateTodoViews(); |
2572 | } | 2572 | } |
2573 | void CalendarView::todoDeleted() | 2573 | void CalendarView::todoDeleted() |
2574 | { | 2574 | { |
2575 | //qDebug(" todoDeleted()"); | 2575 | //qDebug(" todoDeleted()"); |
2576 | updateTodoViews(); | 2576 | updateTodoViews(); |
2577 | } | 2577 | } |
2578 | 2578 | ||
2579 | 2579 | ||
2580 | 2580 | ||
2581 | void CalendarView::newTodo() | 2581 | void CalendarView::newTodo() |
2582 | { | 2582 | { |
2583 | 2583 | ||
2584 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); | 2584 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); |
2585 | if ( mFilterView->filtersEnabled() ) { | 2585 | if ( mFilterView->filtersEnabled() ) { |
2586 | CalFilter *filter = mFilterView->selectedFilter(); | 2586 | CalFilter *filter = mFilterView->selectedFilter(); |
2587 | if (filter && filter->showCategories()) { | 2587 | if (filter && filter->showCategories()) { |
2588 | mTodoEditor->setCategories(filter->categoryList().join(",") ); | 2588 | mTodoEditor->setCategories(filter->categoryList().join(",") ); |
2589 | } | 2589 | } |
2590 | if ( filter ) | 2590 | if ( filter ) |
2591 | mTodoEditor->setSecrecy( filter->getSecrecy() ); | 2591 | mTodoEditor->setSecrecy( filter->getSecrecy() ); |
2592 | } | 2592 | } |
2593 | showTodoEditor(); | 2593 | showTodoEditor(); |
2594 | } | 2594 | } |
2595 | 2595 | ||
2596 | void CalendarView::newSubTodo() | 2596 | void CalendarView::newSubTodo() |
2597 | { | 2597 | { |
2598 | Todo *todo = selectedTodo(); | 2598 | Todo *todo = selectedTodo(); |
2599 | if ( todo ) newSubTodo( todo ); | 2599 | if ( todo ) newSubTodo( todo ); |
2600 | } | 2600 | } |
2601 | 2601 | ||
2602 | void CalendarView::newSubTodo(Todo *parentEvent) | 2602 | void CalendarView::newSubTodo(Todo *parentEvent) |
2603 | { | 2603 | { |
2604 | 2604 | ||
2605 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); | 2605 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); |
2606 | showTodoEditor(); | 2606 | showTodoEditor(); |
2607 | } | 2607 | } |
2608 | 2608 | ||
2609 | void CalendarView::newFloatingEvent() | 2609 | void CalendarView::newFloatingEvent() |
2610 | { | 2610 | { |
2611 | DateList tmpList = mNavigator->selectedDates(); | 2611 | DateList tmpList = mNavigator->selectedDates(); |
2612 | QDate date = tmpList.first(); | 2612 | QDate date = tmpList.first(); |
2613 | 2613 | ||
2614 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), | 2614 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), |
2615 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); | 2615 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); |
2616 | } | 2616 | } |
2617 | 2617 | ||
2618 | 2618 | ||
2619 | void CalendarView::editEvent( Event *event ) | 2619 | void CalendarView::editEvent( Event *event ) |
2620 | { | 2620 | { |
2621 | 2621 | ||
2622 | if ( !event ) return; | 2622 | if ( !event ) return; |
2623 | if ( event->isReadOnly() ) { | 2623 | if ( event->isReadOnly() ) { |
2624 | showEvent( event ); | 2624 | showEvent( event ); |
2625 | return; | 2625 | return; |
2626 | } | 2626 | } |
2627 | mEventEditor->editEvent( event , mFlagEditDescription); | 2627 | mEventEditor->editEvent( event , mFlagEditDescription); |
2628 | showEventEditor(); | 2628 | showEventEditor(); |
2629 | } | 2629 | } |
2630 | void CalendarView::editJournal( Journal *jour ) | 2630 | void CalendarView::editJournal( Journal *jour ) |
2631 | { | 2631 | { |
2632 | if ( !jour ) return; | 2632 | if ( !jour ) return; |
2633 | mDialogManager->hideSearchDialog(); | 2633 | mDialogManager->hideSearchDialog(); |
2634 | mViewManager->showJournalView(); | 2634 | mViewManager->showJournalView(); |
2635 | mNavigator->slotDaySelect( jour->dtStart().date() ); | 2635 | mNavigator->slotDaySelect( jour->dtStart().date() ); |
2636 | } | 2636 | } |
2637 | void CalendarView::editTodo( Todo *todo ) | 2637 | void CalendarView::editTodo( Todo *todo ) |
2638 | { | 2638 | { |
2639 | if ( !todo ) return; | 2639 | if ( !todo ) return; |
2640 | 2640 | ||
2641 | if ( todo->isReadOnly() ) { | 2641 | if ( todo->isReadOnly() ) { |
2642 | showTodo( todo ); | 2642 | showTodo( todo ); |
2643 | return; | 2643 | return; |
2644 | } | 2644 | } |
2645 | mTodoEditor->editTodo( todo ,mFlagEditDescription); | 2645 | mTodoEditor->editTodo( todo ,mFlagEditDescription); |
2646 | showTodoEditor(); | 2646 | showTodoEditor(); |
2647 | 2647 | ||
2648 | } | 2648 | } |
2649 | 2649 | ||
2650 | KOEventViewerDialog* CalendarView::getEventViewerDialog() | 2650 | KOEventViewerDialog* CalendarView::getEventViewerDialog() |
2651 | { | 2651 | { |
2652 | if ( !mEventViewerDialog ) { | 2652 | if ( !mEventViewerDialog ) { |
2653 | mEventViewerDialog = new KOEventViewerDialog(this); | 2653 | mEventViewerDialog = new KOEventViewerDialog(this); |
2654 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); | 2654 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); |
2655 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); | 2655 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); |
2656 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), | 2656 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), |
2657 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); | 2657 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); |
2658 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), | 2658 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), |
2659 | viewManager(), SLOT( showAgendaView( bool ) ) ); | 2659 | viewManager(), SLOT( showAgendaView( bool ) ) ); |
2660 | mEventViewerDialog->resize( 640, 480 ); | 2660 | mEventViewerDialog->resize( 640, 480 ); |
2661 | 2661 | ||
2662 | } | 2662 | } |
2663 | return mEventViewerDialog; | 2663 | return mEventViewerDialog; |
2664 | } | 2664 | } |
2665 | void CalendarView::showEvent(Event *event) | 2665 | void CalendarView::showEvent(Event *event) |
2666 | { | 2666 | { |
2667 | getEventViewerDialog()->setEvent(event); | 2667 | getEventViewerDialog()->setEvent(event); |
2668 | getEventViewerDialog()->showMe(); | 2668 | getEventViewerDialog()->showMe(); |
2669 | } | 2669 | } |
2670 | 2670 | ||
2671 | void CalendarView::showTodo(Todo *event) | 2671 | void CalendarView::showTodo(Todo *event) |
2672 | { | 2672 | { |
2673 | getEventViewerDialog()->setTodo(event); | 2673 | getEventViewerDialog()->setTodo(event); |
2674 | getEventViewerDialog()->showMe(); | 2674 | getEventViewerDialog()->showMe(); |
2675 | } | 2675 | } |
2676 | void CalendarView::showJournal( Journal *jour ) | 2676 | void CalendarView::showJournal( Journal *jour ) |
2677 | { | 2677 | { |
2678 | getEventViewerDialog()->setJournal(jour); | 2678 | getEventViewerDialog()->setJournal(jour); |
2679 | getEventViewerDialog()->showMe(); | 2679 | getEventViewerDialog()->showMe(); |
2680 | 2680 | ||
2681 | } | 2681 | } |
2682 | // void CalendarView::todoModified (Todo *event, int changed) | 2682 | // void CalendarView::todoModified (Todo *event, int changed) |
2683 | // { | 2683 | // { |
2684 | // // if (mDialogList.find (event) != mDialogList.end ()) { | 2684 | // // if (mDialogList.find (event) != mDialogList.end ()) { |
2685 | // // kdDebug() << "Todo modified and open" << endl; | 2685 | // // kdDebug() << "Todo modified and open" << endl; |
2686 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; | 2686 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; |
2687 | // // temp->modified (changed); | 2687 | // // temp->modified (changed); |
2688 | 2688 | ||
2689 | // // } | 2689 | // // } |
2690 | 2690 | ||
2691 | // mViewManager->updateView(); | 2691 | // mViewManager->updateView(); |
2692 | // } | 2692 | // } |
2693 | 2693 | ||
2694 | void CalendarView::appointment_show() | 2694 | void CalendarView::appointment_show() |
2695 | { | 2695 | { |
2696 | Event *anEvent = 0; | 2696 | Event *anEvent = 0; |
2697 | 2697 | ||
2698 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2698 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2699 | 2699 | ||
2700 | if (mViewManager->currentView()->isEventView()) { | 2700 | if (mViewManager->currentView()->isEventView()) { |
2701 | if ( incidence && incidence->type() == "Event" ) { | 2701 | if ( incidence && incidence->type() == "Event" ) { |
2702 | anEvent = static_cast<Event *>(incidence); | 2702 | anEvent = static_cast<Event *>(incidence); |
2703 | } | 2703 | } |
2704 | } | 2704 | } |
2705 | 2705 | ||
2706 | if (!anEvent) { | 2706 | if (!anEvent) { |
2707 | KNotifyClient::beep(); | 2707 | KNotifyClient::beep(); |
2708 | return; | 2708 | return; |
2709 | } | 2709 | } |
2710 | 2710 | ||
2711 | showEvent(anEvent); | 2711 | showEvent(anEvent); |
2712 | } | 2712 | } |
2713 | 2713 | ||
2714 | void CalendarView::appointment_edit() | 2714 | void CalendarView::appointment_edit() |
2715 | { | 2715 | { |
2716 | Event *anEvent = 0; | 2716 | Event *anEvent = 0; |
2717 | 2717 | ||
2718 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2718 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2719 | 2719 | ||
2720 | if (mViewManager->currentView()->isEventView()) { | 2720 | if (mViewManager->currentView()->isEventView()) { |
2721 | if ( incidence && incidence->type() == "Event" ) { | 2721 | if ( incidence && incidence->type() == "Event" ) { |
2722 | anEvent = static_cast<Event *>(incidence); | 2722 | anEvent = static_cast<Event *>(incidence); |
2723 | } | 2723 | } |
2724 | } | 2724 | } |
2725 | 2725 | ||
2726 | if (!anEvent) { | 2726 | if (!anEvent) { |
2727 | KNotifyClient::beep(); | 2727 | KNotifyClient::beep(); |
2728 | return; | 2728 | return; |
2729 | } | 2729 | } |
2730 | 2730 | ||
2731 | editEvent(anEvent); | 2731 | editEvent(anEvent); |
2732 | } | 2732 | } |
2733 | 2733 | ||
2734 | void CalendarView::appointment_delete() | 2734 | void CalendarView::appointment_delete() |
2735 | { | 2735 | { |
2736 | Event *anEvent = 0; | 2736 | Event *anEvent = 0; |
2737 | 2737 | ||
2738 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2738 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2739 | 2739 | ||
2740 | if (mViewManager->currentView()->isEventView()) { | 2740 | if (mViewManager->currentView()->isEventView()) { |
2741 | if ( incidence && incidence->type() == "Event" ) { | 2741 | if ( incidence && incidence->type() == "Event" ) { |
2742 | anEvent = static_cast<Event *>(incidence); | 2742 | anEvent = static_cast<Event *>(incidence); |
2743 | } | 2743 | } |
2744 | } | 2744 | } |
2745 | 2745 | ||
2746 | if (!anEvent) { | 2746 | if (!anEvent) { |
2747 | KNotifyClient::beep(); | 2747 | KNotifyClient::beep(); |
2748 | return; | 2748 | return; |
2749 | } | 2749 | } |
2750 | 2750 | ||
2751 | deleteEvent(anEvent); | 2751 | deleteEvent(anEvent); |
2752 | } | 2752 | } |
2753 | 2753 | ||
2754 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) | 2754 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) |
2755 | { | 2755 | { |
2756 | if (!sub) return; | 2756 | if (!sub) return; |
2757 | if (!parent) return; | 2757 | if (!parent) return; |
2758 | if ( sub->relatedTo() ) | 2758 | if ( sub->relatedTo() ) |
2759 | sub->relatedTo()->removeRelation(sub); | 2759 | sub->relatedTo()->removeRelation(sub); |
2760 | sub->setRelatedTo(parent); | 2760 | sub->setRelatedTo(parent); |
2761 | sub->setRelatedToUid(parent->uid()); | 2761 | sub->setRelatedToUid(parent->uid()); |
2762 | parent->addRelation(sub); | 2762 | parent->addRelation(sub); |
2763 | sub->updated(); | 2763 | sub->updated(); |
2764 | parent->updated(); | 2764 | parent->updated(); |
2765 | setModified(true); | 2765 | setModified(true); |
2766 | updateView(); | 2766 | updateView(); |
2767 | } | 2767 | } |
2768 | void CalendarView::todo_unsub(Todo *anTodo ) | 2768 | void CalendarView::todo_unsub(Todo *anTodo ) |
2769 | { | 2769 | { |
2770 | // Todo *anTodo = selectedTodo(); | 2770 | // Todo *anTodo = selectedTodo(); |
2771 | if (!anTodo) return; | 2771 | if (!anTodo) return; |
2772 | if (!anTodo->relatedTo()) return; | 2772 | if (!anTodo->relatedTo()) return; |
2773 | anTodo->relatedTo()->removeRelation(anTodo); | 2773 | anTodo->relatedTo()->removeRelation(anTodo); |
2774 | anTodo->setRelatedTo(0); | 2774 | anTodo->setRelatedTo(0); |
2775 | anTodo->updated(); | 2775 | anTodo->updated(); |
2776 | anTodo->setRelatedToUid(""); | 2776 | anTodo->setRelatedToUid(""); |
2777 | setModified(true); | 2777 | setModified(true); |
2778 | updateView(); | 2778 | updateView(); |
2779 | } | 2779 | } |
2780 | 2780 | ||
2781 | void CalendarView::deleteTodo(Todo *todo) | 2781 | void CalendarView::deleteTodo(Todo *todo) |
2782 | { | 2782 | { |
2783 | if (!todo) { | 2783 | if (!todo) { |
2784 | KNotifyClient::beep(); | 2784 | KNotifyClient::beep(); |
2785 | return; | 2785 | return; |
2786 | } | 2786 | } |
2787 | if (KOPrefs::instance()->mConfirm) { | 2787 | if (KOPrefs::instance()->mConfirm) { |
2788 | switch (msgItemDelete()) { | 2788 | switch (msgItemDelete()) { |
2789 | case KMessageBox::Continue: // OK | 2789 | case KMessageBox::Continue: // OK |
2790 | if (!todo->relations().isEmpty()) { | 2790 | if (!todo->relations().isEmpty()) { |
2791 | KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), | 2791 | KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), |
2792 | i18n("Delete To-Do")); | 2792 | i18n("Delete To-Do")); |
2793 | } else { | 2793 | } else { |
2794 | checkExternalId( todo ); | 2794 | checkExternalId( todo ); |
2795 | calendar()->deleteTodo(todo); | 2795 | calendar()->deleteTodo(todo); |
2796 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 2796 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
2797 | updateView(); | 2797 | updateView(); |
2798 | } | 2798 | } |
2799 | break; | 2799 | break; |
2800 | } // switch | 2800 | } // switch |
2801 | } else { | 2801 | } else { |
2802 | if (!todo->relations().isEmpty()) { | 2802 | if (!todo->relations().isEmpty()) { |
2803 | KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), | 2803 | KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), |
2804 | i18n("Delete To-Do")); | 2804 | i18n("Delete To-Do")); |
2805 | } else { | 2805 | } else { |
2806 | checkExternalId( todo ); | 2806 | checkExternalId( todo ); |
2807 | mCalendar->deleteTodo(todo); | 2807 | mCalendar->deleteTodo(todo); |
2808 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 2808 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
2809 | updateView(); | 2809 | updateView(); |
2810 | } | 2810 | } |
2811 | } | 2811 | } |
2812 | emit updateSearchDialog(); | 2812 | emit updateSearchDialog(); |
2813 | } | 2813 | } |
2814 | void CalendarView::deleteJournal(Journal *jour) | 2814 | void CalendarView::deleteJournal(Journal *jour) |
2815 | { | 2815 | { |
2816 | if (!jour) { | 2816 | if (!jour) { |
2817 | KNotifyClient::beep(); | 2817 | KNotifyClient::beep(); |
2818 | return; | 2818 | return; |
2819 | } | 2819 | } |
2820 | if (KOPrefs::instance()->mConfirm) { | 2820 | if (KOPrefs::instance()->mConfirm) { |
2821 | switch (msgItemDelete()) { | 2821 | switch (msgItemDelete()) { |
2822 | case KMessageBox::Continue: // OK | 2822 | case KMessageBox::Continue: // OK |
2823 | calendar()->deleteJournal(jour); | 2823 | calendar()->deleteJournal(jour); |
2824 | updateView(); | 2824 | updateView(); |
2825 | break; | 2825 | break; |
2826 | } // switch | 2826 | } // switch |
2827 | } else { | 2827 | } else { |
2828 | calendar()->deleteJournal(jour);; | 2828 | calendar()->deleteJournal(jour);; |
2829 | updateView(); | 2829 | updateView(); |
2830 | } | 2830 | } |
2831 | emit updateSearchDialog(); | 2831 | emit updateSearchDialog(); |
2832 | } | 2832 | } |
2833 | 2833 | ||
2834 | void CalendarView::deleteEvent(Event *anEvent) | 2834 | void CalendarView::deleteEvent(Event *anEvent) |
2835 | { | 2835 | { |
2836 | if (!anEvent) { | 2836 | if (!anEvent) { |
2837 | KNotifyClient::beep(); | 2837 | KNotifyClient::beep(); |
2838 | return; | 2838 | return; |
2839 | } | 2839 | } |
2840 | 2840 | ||
2841 | if (anEvent->recurrence()->doesRecur()) { | 2841 | if (anEvent->recurrence()->doesRecur()) { |
2842 | QDate itemDate = mViewManager->currentSelectionDate(); | 2842 | QDate itemDate = mViewManager->currentSelectionDate(); |
2843 | int km; | 2843 | int km; |
2844 | if (!itemDate.isValid()) { | 2844 | if (!itemDate.isValid()) { |
2845 | //kdDebug() << "Date Not Valid" << endl; | 2845 | //kdDebug() << "Date Not Valid" << endl; |
2846 | if (KOPrefs::instance()->mConfirm) { | 2846 | if (KOPrefs::instance()->mConfirm) { |
2847 | km = KMessageBox::warningContinueCancel(this,anEvent->summary() + | 2847 | km = KMessageBox::warningContinueCancel(this,anEvent->summary() + |
2848 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), | 2848 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), |
2849 | i18n("KO/Pi Confirmation"),i18n("Delete All")); | 2849 | i18n("KO/Pi Confirmation"),i18n("Delete All")); |
2850 | if ( km == KMessageBox::Continue ) | 2850 | if ( km == KMessageBox::Continue ) |
2851 | km = KMessageBox::No; // No = all below | 2851 | km = KMessageBox::No; // No = all below |
2852 | } else | 2852 | } else |
2853 | km = KMessageBox::No; | 2853 | km = KMessageBox::No; |
2854 | } else { | 2854 | } else { |
2855 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary() + | 2855 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary() + |
2856 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ | 2856 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ |
2857 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), | 2857 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), |
2858 | i18n("KO/Pi Confirmation"),i18n("Current"), | 2858 | i18n("KO/Pi Confirmation"),i18n("Current"), |
2859 | i18n("All")); | 2859 | i18n("All")); |
2860 | } | 2860 | } |
2861 | switch(km) { | 2861 | switch(km) { |
2862 | 2862 | ||
2863 | case KMessageBox::No: // Continue // all | 2863 | case KMessageBox::No: // Continue // all |
2864 | //qDebug("KMessageBox::No "); | 2864 | //qDebug("KMessageBox::No "); |
2865 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 2865 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
2866 | schedule(Scheduler::Cancel,anEvent); | 2866 | schedule(Scheduler::Cancel,anEvent); |
2867 | 2867 | ||
2868 | checkExternalId( anEvent); | 2868 | checkExternalId( anEvent); |
2869 | mCalendar->deleteEvent(anEvent); | 2869 | mCalendar->deleteEvent(anEvent); |
2870 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); | 2870 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); |
2871 | break; | 2871 | break; |
2872 | 2872 | ||
2873 | // Disabled because it does not work | 2873 | // Disabled because it does not work |
2874 | //#if 0 | 2874 | //#if 0 |
2875 | case KMessageBox::Yes: // just this one | 2875 | case KMessageBox::Yes: // just this one |
2876 | //QDate qd = mNavigator->selectedDates().first(); | 2876 | //QDate qd = mNavigator->selectedDates().first(); |
2877 | //if (!qd.isValid()) { | 2877 | //if (!qd.isValid()) { |
2878 | // kdDebug() << "no date selected, or invalid date" << endl; | 2878 | // kdDebug() << "no date selected, or invalid date" << endl; |
2879 | // KNotifyClient::beep(); | 2879 | // KNotifyClient::beep(); |
2880 | // return; | 2880 | // return; |
2881 | //} | 2881 | //} |
2882 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); | 2882 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); |
2883 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { | 2883 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { |
2884 | anEvent->addExDate(itemDate); | 2884 | anEvent->addExDate(itemDate); |
2885 | int duration = anEvent->recurrence()->duration(); | 2885 | int duration = anEvent->recurrence()->duration(); |
2886 | if ( duration > 0 ) { | 2886 | if ( duration > 0 ) { |
2887 | anEvent->recurrence()->setDuration( duration - 1 ); | 2887 | anEvent->recurrence()->setDuration( duration - 1 ); |
2888 | } | 2888 | } |
2889 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); | 2889 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); |
2890 | } | 2890 | } |
2891 | break; | 2891 | break; |
2892 | //#endif | 2892 | //#endif |
2893 | } // switch | 2893 | } // switch |
2894 | } else { | 2894 | } else { |
2895 | if (KOPrefs::instance()->mConfirm) { | 2895 | if (KOPrefs::instance()->mConfirm) { |
2896 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary() + | 2896 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary() + |
2897 | i18n("\nAre you sure you want\nto delete this event?"), | 2897 | i18n("\nAre you sure you want\nto delete this event?"), |
2898 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { | 2898 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { |
2899 | case KMessageBox::Continue: // OK | 2899 | case KMessageBox::Continue: // OK |
2900 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 2900 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
2901 | schedule(Scheduler::Cancel,anEvent); | 2901 | schedule(Scheduler::Cancel,anEvent); |
2902 | checkExternalId( anEvent); | 2902 | checkExternalId( anEvent); |
2903 | mCalendar->deleteEvent(anEvent); | 2903 | mCalendar->deleteEvent(anEvent); |
2904 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2904 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2905 | break; | 2905 | break; |
2906 | } // switch | 2906 | } // switch |
2907 | } else { | 2907 | } else { |
2908 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 2908 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
2909 | schedule(Scheduler::Cancel,anEvent); | 2909 | schedule(Scheduler::Cancel,anEvent); |
2910 | checkExternalId( anEvent); | 2910 | checkExternalId( anEvent); |
2911 | mCalendar->deleteEvent(anEvent); | 2911 | mCalendar->deleteEvent(anEvent); |
2912 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2912 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2913 | } | 2913 | } |
2914 | } // if-else | 2914 | } // if-else |
2915 | emit updateSearchDialog(); | 2915 | emit updateSearchDialog(); |
2916 | } | 2916 | } |
2917 | 2917 | ||
2918 | bool CalendarView::deleteEvent(const QString &uid) | 2918 | bool CalendarView::deleteEvent(const QString &uid) |
2919 | { | 2919 | { |
2920 | Event *ev = mCalendar->event(uid); | 2920 | Event *ev = mCalendar->event(uid); |
2921 | if (ev) { | 2921 | if (ev) { |
2922 | deleteEvent(ev); | 2922 | deleteEvent(ev); |
2923 | return true; | 2923 | return true; |
2924 | } else { | 2924 | } else { |
2925 | return false; | 2925 | return false; |
2926 | } | 2926 | } |
2927 | } | 2927 | } |
2928 | 2928 | ||
2929 | /*****************************************************************************/ | 2929 | /*****************************************************************************/ |
2930 | 2930 | ||
2931 | void CalendarView::action_mail() | 2931 | void CalendarView::action_mail() |
2932 | { | 2932 | { |
2933 | #ifndef KORG_NOMAIL | 2933 | #ifndef KORG_NOMAIL |
2934 | KOMailClient mailClient; | 2934 | KOMailClient mailClient; |
2935 | 2935 | ||
2936 | Incidence *incidence = currentSelection(); | 2936 | Incidence *incidence = currentSelection(); |
2937 | 2937 | ||
2938 | if (!incidence) { | 2938 | if (!incidence) { |
2939 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 2939 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
2940 | return; | 2940 | return; |
2941 | } | 2941 | } |
2942 | if(incidence->attendeeCount() == 0 ) { | 2942 | if(incidence->attendeeCount() == 0 ) { |
2943 | KMessageBox::sorry(this, | 2943 | KMessageBox::sorry(this, |
2944 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 2944 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
2945 | return; | 2945 | return; |
2946 | } | 2946 | } |
2947 | 2947 | ||
2948 | CalendarLocal cal_tmp; | 2948 | CalendarLocal cal_tmp; |
2949 | Event *event = 0; | 2949 | Event *event = 0; |
2950 | Event *ev = 0; | 2950 | Event *ev = 0; |
2951 | if ( incidence && incidence->type() == "Event" ) { | 2951 | if ( incidence && incidence->type() == "Event" ) { |
2952 | event = static_cast<Event *>(incidence); | 2952 | event = static_cast<Event *>(incidence); |
2953 | ev = new Event(*event); | 2953 | ev = new Event(*event); |
2954 | cal_tmp.addEvent(ev); | 2954 | cal_tmp.addEvent(ev); |
2955 | } | 2955 | } |
2956 | ICalFormat mForm(); | 2956 | ICalFormat mForm(); |
2957 | QString attachment = mForm.toString( &cal_tmp ); | 2957 | QString attachment = mForm.toString( &cal_tmp ); |
2958 | if (ev) delete(ev); | 2958 | if (ev) delete(ev); |
2959 | 2959 | ||
2960 | mailClient.mailAttendees(currentSelection(), attachment); | 2960 | mailClient.mailAttendees(currentSelection(), attachment); |
2961 | 2961 | ||
2962 | #endif | 2962 | #endif |
2963 | 2963 | ||
2964 | #if 0 | 2964 | #if 0 |
2965 | Event *anEvent = 0; | 2965 | Event *anEvent = 0; |
2966 | if (mViewManager->currentView()->isEventView()) { | 2966 | if (mViewManager->currentView()->isEventView()) { |
2967 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); | 2967 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); |
2968 | } | 2968 | } |
2969 | 2969 | ||
2970 | if (!anEvent) { | 2970 | if (!anEvent) { |
2971 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 2971 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
2972 | return; | 2972 | return; |
2973 | } | 2973 | } |
2974 | if(anEvent->attendeeCount() == 0 ) { | 2974 | if(anEvent->attendeeCount() == 0 ) { |
2975 | KMessageBox::sorry(this, | 2975 | KMessageBox::sorry(this, |
2976 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 2976 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
2977 | return; | 2977 | return; |
2978 | } | 2978 | } |
2979 | 2979 | ||
2980 | mailobject.emailEvent(anEvent); | 2980 | mailobject.emailEvent(anEvent); |
2981 | #endif | 2981 | #endif |
2982 | } | 2982 | } |
2983 | 2983 | ||
2984 | 2984 | ||
2985 | void CalendarView::schedule_publish(Incidence *incidence) | 2985 | void CalendarView::schedule_publish(Incidence *incidence) |
2986 | { | 2986 | { |
2987 | Event *event = 0; | 2987 | Event *event = 0; |
2988 | Todo *todo = 0; | 2988 | Todo *todo = 0; |
2989 | 2989 | ||
2990 | if (incidence == 0) { | 2990 | if (incidence == 0) { |
2991 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 2991 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
2992 | if (incidence == 0) { | 2992 | if (incidence == 0) { |
2993 | incidence = mTodoList->selectedIncidences().first(); | 2993 | incidence = mTodoList->selectedIncidences().first(); |
2994 | } | 2994 | } |
2995 | } | 2995 | } |
2996 | if ( incidence && incidence->type() == "Event" ) { | 2996 | if ( incidence && incidence->type() == "Event" ) { |
2997 | event = static_cast<Event *>(incidence); | 2997 | event = static_cast<Event *>(incidence); |
2998 | } else { | 2998 | } else { |
2999 | if ( incidence && incidence->type() == "Todo" ) { | 2999 | if ( incidence && incidence->type() == "Todo" ) { |
3000 | todo = static_cast<Todo *>(incidence); | 3000 | todo = static_cast<Todo *>(incidence); |
3001 | } | 3001 | } |
3002 | } | 3002 | } |
3003 | 3003 | ||
3004 | if (!event && !todo) { | 3004 | if (!event && !todo) { |
3005 | KMessageBox::sorry(this,i18n("No event selected.")); | 3005 | KMessageBox::sorry(this,i18n("No event selected.")); |
3006 | return; | 3006 | return; |
3007 | } | 3007 | } |
3008 | 3008 | ||
3009 | PublishDialog *publishdlg = new PublishDialog(); | 3009 | PublishDialog *publishdlg = new PublishDialog(); |
3010 | if (incidence->attendeeCount()>0) { | 3010 | if (incidence->attendeeCount()>0) { |
3011 | QPtrList<Attendee> attendees = incidence->attendees(); | 3011 | QPtrList<Attendee> attendees = incidence->attendees(); |
3012 | attendees.first(); | 3012 | attendees.first(); |
3013 | while ( attendees.current()!=0 ) { | 3013 | while ( attendees.current()!=0 ) { |
3014 | publishdlg->addAttendee(attendees.current()); | 3014 | publishdlg->addAttendee(attendees.current()); |
3015 | attendees.next(); | 3015 | attendees.next(); |
3016 | } | 3016 | } |
3017 | } | 3017 | } |
3018 | bool send = true; | 3018 | bool send = true; |
3019 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { | 3019 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { |
3020 | if ( publishdlg->exec() != QDialog::Accepted ) | 3020 | if ( publishdlg->exec() != QDialog::Accepted ) |
3021 | send = false; | 3021 | send = false; |
3022 | } | 3022 | } |
3023 | if ( send ) { | 3023 | if ( send ) { |
3024 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3024 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3025 | if ( event ) { | 3025 | if ( event ) { |
3026 | Event *ev = new Event(*event); | 3026 | Event *ev = new Event(*event); |
3027 | ev->registerObserver(0); | 3027 | ev->registerObserver(0); |
3028 | ev->clearAttendees(); | 3028 | ev->clearAttendees(); |
3029 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3029 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3030 | delete(ev); | 3030 | delete(ev); |
3031 | } | 3031 | } |
3032 | } else { | 3032 | } else { |
3033 | if ( todo ) { | 3033 | if ( todo ) { |
3034 | Todo *ev = new Todo(*todo); | 3034 | Todo *ev = new Todo(*todo); |
3035 | ev->registerObserver(0); | 3035 | ev->registerObserver(0); |
3036 | ev->clearAttendees(); | 3036 | ev->clearAttendees(); |
3037 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3037 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3038 | delete(ev); | 3038 | delete(ev); |
3039 | } | 3039 | } |
3040 | } | 3040 | } |
3041 | } | 3041 | } |
3042 | } | 3042 | } |
3043 | delete publishdlg; | 3043 | delete publishdlg; |
3044 | } | 3044 | } |
3045 | 3045 | ||
3046 | void CalendarView::schedule_request(Incidence *incidence) | 3046 | void CalendarView::schedule_request(Incidence *incidence) |
3047 | { | 3047 | { |
3048 | schedule(Scheduler::Request,incidence); | 3048 | schedule(Scheduler::Request,incidence); |
3049 | } | 3049 | } |
3050 | 3050 | ||
3051 | void CalendarView::schedule_refresh(Incidence *incidence) | 3051 | void CalendarView::schedule_refresh(Incidence *incidence) |
3052 | { | 3052 | { |
3053 | schedule(Scheduler::Refresh,incidence); | 3053 | schedule(Scheduler::Refresh,incidence); |
3054 | } | 3054 | } |
3055 | 3055 | ||
3056 | void CalendarView::schedule_cancel(Incidence *incidence) | 3056 | void CalendarView::schedule_cancel(Incidence *incidence) |
3057 | { | 3057 | { |
3058 | schedule(Scheduler::Cancel,incidence); | 3058 | schedule(Scheduler::Cancel,incidence); |
3059 | } | 3059 | } |
3060 | 3060 | ||
3061 | void CalendarView::schedule_add(Incidence *incidence) | 3061 | void CalendarView::schedule_add(Incidence *incidence) |
3062 | { | 3062 | { |
3063 | schedule(Scheduler::Add,incidence); | 3063 | schedule(Scheduler::Add,incidence); |
3064 | } | 3064 | } |
3065 | 3065 | ||
3066 | void CalendarView::schedule_reply(Incidence *incidence) | 3066 | void CalendarView::schedule_reply(Incidence *incidence) |
3067 | { | 3067 | { |
3068 | schedule(Scheduler::Reply,incidence); | 3068 | schedule(Scheduler::Reply,incidence); |
3069 | } | 3069 | } |
3070 | 3070 | ||
3071 | void CalendarView::schedule_counter(Incidence *incidence) | 3071 | void CalendarView::schedule_counter(Incidence *incidence) |
3072 | { | 3072 | { |
3073 | schedule(Scheduler::Counter,incidence); | 3073 | schedule(Scheduler::Counter,incidence); |
3074 | } | 3074 | } |
3075 | 3075 | ||
3076 | void CalendarView::schedule_declinecounter(Incidence *incidence) | 3076 | void CalendarView::schedule_declinecounter(Incidence *incidence) |
3077 | { | 3077 | { |
3078 | schedule(Scheduler::Declinecounter,incidence); | 3078 | schedule(Scheduler::Declinecounter,incidence); |
3079 | } | 3079 | } |
3080 | 3080 | ||
3081 | void CalendarView::schedule_publish_freebusy(int daysToPublish) | 3081 | void CalendarView::schedule_publish_freebusy(int daysToPublish) |
3082 | { | 3082 | { |
3083 | QDateTime start = QDateTime::currentDateTime(); | 3083 | QDateTime start = QDateTime::currentDateTime(); |
3084 | QDateTime end = start.addDays(daysToPublish); | 3084 | QDateTime end = start.addDays(daysToPublish); |
3085 | 3085 | ||
3086 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); | 3086 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); |
3087 | freebusy->setOrganizer(KOPrefs::instance()->email()); | 3087 | freebusy->setOrganizer(KOPrefs::instance()->email()); |
3088 | 3088 | ||
3089 | 3089 | ||
3090 | PublishDialog *publishdlg = new PublishDialog(); | 3090 | PublishDialog *publishdlg = new PublishDialog(); |
3091 | if ( publishdlg->exec() == QDialog::Accepted ) { | 3091 | if ( publishdlg->exec() == QDialog::Accepted ) { |
diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp index bafd349..d3aa650 100644 --- a/korganizer/kolistview.cpp +++ b/korganizer/kolistview.cpp | |||
@@ -1,1072 +1,1073 @@ | |||
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 <libkcal/calendar.h> | 43 | #include <libkcal/calendar.h> |
43 | #include <libkcal/calendarlocal.h> | 44 | #include <libkcal/calendarlocal.h> |
44 | #include <libkcal/icalformat.h> | 45 | #include <libkcal/icalformat.h> |
45 | #include <libkcal/vcalformat.h> | 46 | #include <libkcal/vcalformat.h> |
46 | #include <libkcal/recurrence.h> | 47 | #include <libkcal/recurrence.h> |
47 | #include <libkcal/filestorage.h> | 48 | #include <libkcal/filestorage.h> |
48 | #include <libkdepim/categoryselectdialog.h> | 49 | #include <libkdepim/categoryselectdialog.h> |
49 | #ifndef DESKTOP_VERSION | 50 | #ifndef DESKTOP_VERSION |
50 | #include <qpe/qpeapplication.h> | 51 | #include <qpe/qpeapplication.h> |
51 | #else | 52 | #else |
52 | #include <qapplication.h> | 53 | #include <qapplication.h> |
53 | #endif | 54 | #endif |
54 | 55 | ||
55 | #ifndef KORG_NOPRINTER | 56 | #ifndef KORG_NOPRINTER |
56 | #include "calprinter.h" | 57 | #include "calprinter.h" |
57 | #endif | 58 | #endif |
58 | #include "koglobals.h" | 59 | #include "koglobals.h" |
59 | #include "koprefs.h" | 60 | #include "koprefs.h" |
60 | #include "kfiledialog.h" | 61 | #include "kfiledialog.h" |
61 | 62 | ||
62 | #include "kolistview.h" | 63 | #include "kolistview.h" |
63 | 64 | ||
64 | ListItemVisitor::ListItemVisitor(KOListViewItem *item, QDate date ) | 65 | ListItemVisitor::ListItemVisitor(KOListViewItem *item, QDate date ) |
65 | { | 66 | { |
66 | mItem = item; | 67 | mItem = item; |
67 | mDate = date; | 68 | mDate = date; |
68 | } | 69 | } |
69 | 70 | ||
70 | ListItemVisitor::~ListItemVisitor() | 71 | ListItemVisitor::~ListItemVisitor() |
71 | { | 72 | { |
72 | } | 73 | } |
73 | 74 | ||
74 | bool ListItemVisitor::visit(Event *e) | 75 | bool ListItemVisitor::visit(Event *e) |
75 | { | 76 | { |
76 | 77 | ||
77 | bool ok = false; | 78 | bool ok = false; |
78 | QString start, end; | 79 | QString start, end; |
79 | if ( e->doesRecur() ) { | 80 | if ( e->doesRecur() ) { |
80 | QDate d = e->getNextOccurence( QDateTime( mDate, QTime(0,0,0)), &ok ).date(); | 81 | QDate d = e->getNextOccurence( QDateTime( mDate, QTime(0,0,0)), &ok ).date(); |
81 | if ( ok ) { | 82 | if ( ok ) { |
82 | int days = e->dtStart().date().daysTo(e->dtEnd().date() ); | 83 | int days = e->dtStart().date().daysTo(e->dtEnd().date() ); |
83 | start = KGlobal::locale()->formatDate(d,true); | 84 | start = KGlobal::locale()->formatDate(d,true); |
84 | end = KGlobal::locale()->formatDate(d.addDays( days),true); | 85 | end = KGlobal::locale()->formatDate(d.addDays( days),true); |
85 | } | 86 | } |
86 | 87 | ||
87 | } | 88 | } |
88 | if ( ! ok ) { | 89 | if ( ! ok ) { |
89 | start =e->dtStartDateStr(); | 90 | start =e->dtStartDateStr(); |
90 | end = e->dtEndDateStr(); | 91 | end = e->dtEndDateStr(); |
91 | } | 92 | } |
92 | mItem->setText(0,e->summary()); | 93 | mItem->setText(0,e->summary()); |
93 | mItem->setText(1,start); | 94 | mItem->setText(1,start); |
94 | mItem->setText(2,e->dtStartTimeStr()); | 95 | mItem->setText(2,e->dtStartTimeStr()); |
95 | mItem->setText(3,end); | 96 | mItem->setText(3,end); |
96 | mItem->setText(4,e->dtEndTimeStr()); | 97 | mItem->setText(4,e->dtEndTimeStr()); |
97 | mItem->setText(5,e->isAlarmEnabled() ? i18n("Yes") : i18n("No")); | 98 | mItem->setText(5,e->isAlarmEnabled() ? i18n("Yes") : i18n("No")); |
98 | mItem->setText(6, e->recurrence()->recurrenceText()); | 99 | mItem->setText(6, e->recurrence()->recurrenceText()); |
99 | mItem->setText(7,"---"); | 100 | mItem->setText(7,"---"); |
100 | mItem->setText(8,"---"); | 101 | mItem->setText(8,"---"); |
101 | mItem->setText(9, e->cancelled() ? i18n("Yes") : i18n("No")); | 102 | mItem->setText(9, e->cancelled() ? i18n("Yes") : i18n("No")); |
102 | mItem->setText(10,e->categoriesStr()); | 103 | mItem->setText(10,e->categoriesStr()); |
103 | 104 | ||
104 | QString key; | 105 | QString key; |
105 | QDate d = e->dtStart().date(); | 106 | QDate d = e->dtStart().date(); |
106 | QTime t = e->doesFloat() ? QTime(0,0) : e->dtStart().time(); | 107 | 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()); | 108 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),t.hour(),t.minute()); |
108 | mItem->setSortKey(1,key); | 109 | mItem->setSortKey(1,key); |
109 | 110 | ||
110 | d = e->dtEnd().date(); | 111 | d = e->dtEnd().date(); |
111 | t = e->doesFloat() ? QTime(0,0) : e->dtEnd().time(); | 112 | 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()); | 113 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),t.hour(),t.minute()); |
113 | mItem->setSortKey(3,key); | 114 | mItem->setSortKey(3,key); |
114 | 115 | ||
115 | return true; | 116 | return true; |
116 | } | 117 | } |
117 | 118 | ||
118 | bool ListItemVisitor::visit(Todo *t) | 119 | bool ListItemVisitor::visit(Todo *t) |
119 | { | 120 | { |
120 | mItem->setText(0,i18n("To-Do: %1").arg(t->summary())); | 121 | mItem->setText(0,i18n("To-Do: %1").arg(t->summary())); |
121 | if (t->hasStartDate()) { | 122 | if (t->hasStartDate()) { |
122 | mItem->setText(1,t->dtStartDateStr()); | 123 | mItem->setText(1,t->dtStartDateStr()); |
123 | if (t->doesFloat()) { | 124 | if (t->doesFloat()) { |
124 | mItem->setText(2,"---"); | 125 | mItem->setText(2,"---"); |
125 | } else { | 126 | } else { |
126 | mItem->setText(2,t->dtStartTimeStr()); | 127 | mItem->setText(2,t->dtStartTimeStr()); |
127 | } | 128 | } |
128 | } else { | 129 | } else { |
129 | mItem->setText(1,"---"); | 130 | mItem->setText(1,"---"); |
130 | mItem->setText(2,"---"); | 131 | mItem->setText(2,"---"); |
131 | } | 132 | } |
132 | mItem->setText(3,"---"); | 133 | mItem->setText(3,"---"); |
133 | mItem->setText(4,"---"); | 134 | mItem->setText(4,"---"); |
134 | mItem->setText(5,"---"); | 135 | mItem->setText(5,"---"); |
135 | mItem->setText(6,"---"); | 136 | mItem->setText(6,"---"); |
136 | if (t->hasDueDate()) { | 137 | if (t->hasDueDate()) { |
137 | mItem->setText(7,t->dtDueDateStr()); | 138 | mItem->setText(7,t->dtDueDateStr()); |
138 | if (t->doesFloat()) { | 139 | if (t->doesFloat()) { |
139 | mItem->setText(8,"---"); | 140 | mItem->setText(8,"---"); |
140 | } else { | 141 | } else { |
141 | mItem->setText(8,t->dtDueTimeStr()); | 142 | mItem->setText(8,t->dtDueTimeStr()); |
142 | } | 143 | } |
143 | } else { | 144 | } else { |
144 | mItem->setText(7,"---"); | 145 | mItem->setText(7,"---"); |
145 | mItem->setText(8,"---"); | 146 | mItem->setText(8,"---"); |
146 | } | 147 | } |
147 | mItem->setText(9, t->cancelled() ? i18n("Yes") : i18n("No")); | 148 | mItem->setText(9, t->cancelled() ? i18n("Yes") : i18n("No")); |
148 | mItem->setText(10,t->categoriesStr()); | 149 | mItem->setText(10,t->categoriesStr()); |
149 | 150 | ||
150 | QString key; | 151 | QString key; |
151 | QDate d; | 152 | QDate d; |
152 | if (t->hasDueDate()) { | 153 | if (t->hasDueDate()) { |
153 | d = t->dtDue().date(); | 154 | d = t->dtDue().date(); |
154 | QTime tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time(); | 155 | 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()); | 156 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); |
156 | mItem->setSortKey(7,key); | 157 | mItem->setSortKey(7,key); |
157 | } | 158 | } |
158 | if ( t->hasStartDate() ) { | 159 | if ( t->hasStartDate() ) { |
159 | d = t->dtStart().date(); | 160 | d = t->dtStart().date(); |
160 | QTime tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time(); | 161 | 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()); | 162 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); |
162 | mItem->setSortKey(1,key); | 163 | mItem->setSortKey(1,key); |
163 | } | 164 | } |
164 | return true; | 165 | return true; |
165 | } | 166 | } |
166 | 167 | ||
167 | bool ListItemVisitor::visit(Journal * j) | 168 | bool ListItemVisitor::visit(Journal * j) |
168 | { | 169 | { |
169 | QString des = j->description().left(50); | 170 | QString des = j->description().left(50); |
170 | des = des.simplifyWhiteSpace (); | 171 | des = des.simplifyWhiteSpace (); |
171 | des.replace (QRegExp ("\\n"),"" ); | 172 | des.replace (QRegExp ("\\n"),"" ); |
172 | des.replace (QRegExp ("\\r"),"" ); | 173 | des.replace (QRegExp ("\\r"),"" ); |
173 | mItem->setText(0,i18n("Journal")+": "+des.left(25)); | 174 | mItem->setText(0,i18n("Journal")+": "+des.left(25)); |
174 | mItem->setText(1,j->dtStartDateStr()); | 175 | mItem->setText(1,j->dtStartDateStr()); |
175 | mItem->setText(2,"---"); | 176 | mItem->setText(2,"---"); |
176 | mItem->setText(3,"---"); | 177 | mItem->setText(3,"---"); |
177 | mItem->setText(4,"---"); | 178 | mItem->setText(4,"---"); |
178 | mItem->setText(5,"---"); | 179 | mItem->setText(5,"---"); |
179 | mItem->setText(6,"---"); | 180 | mItem->setText(6,"---"); |
180 | mItem->setText(7,j->dtStartDateStr()); | 181 | mItem->setText(7,j->dtStartDateStr()); |
181 | mItem->setText(8,"---"); | 182 | mItem->setText(8,"---"); |
182 | mItem->setText(9,"---"); | 183 | mItem->setText(9,"---"); |
183 | mItem->setText(10,i18n("Last Modified: ")+ KGlobal::locale()->formatDateTime( j->lastModified() , true) ); | 184 | mItem->setText(10,i18n("Last Modified: ")+ KGlobal::locale()->formatDateTime( j->lastModified() , true) ); |
184 | 185 | ||
185 | QString key; | 186 | QString key; |
186 | QDate d = j->dtStart().date(); | 187 | QDate d = j->dtStart().date(); |
187 | key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); | 188 | key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); |
188 | mItem->setSortKey(1,key); | 189 | mItem->setSortKey(1,key); |
189 | mItem->setSortKey(7,key); | 190 | mItem->setSortKey(7,key); |
190 | 191 | ||
191 | return true; | 192 | return true; |
192 | } | 193 | } |
193 | 194 | ||
194 | KOListView::KOListView(Calendar *calendar, QWidget *parent, | 195 | KOListView::KOListView(Calendar *calendar, QWidget *parent, |
195 | const char *name) | 196 | const char *name) |
196 | : KOEventView(calendar, parent, name) | 197 | : KOEventView(calendar, parent, name) |
197 | { | 198 | { |
198 | mActiveItem = 0; | 199 | mActiveItem = 0; |
199 | mListView = new KOListViewListView(this); | 200 | mListView = new KOListViewListView(this); |
200 | mListView->addColumn(i18n("Summary")); | 201 | mListView->addColumn(i18n("Summary")); |
201 | mListView->addColumn(i18n("Start Date")); | 202 | mListView->addColumn(i18n("Start Date")); |
202 | mListView->addColumn(i18n("Start Time")); | 203 | mListView->addColumn(i18n("Start Time")); |
203 | mListView->addColumn(i18n("End Date")); | 204 | mListView->addColumn(i18n("End Date")); |
204 | mListView->addColumn(i18n("End Time")); | 205 | mListView->addColumn(i18n("End Time")); |
205 | mListView->addColumn(i18n("Alarm")); // alarm set? | 206 | mListView->addColumn(i18n("Alarm")); // alarm set? |
206 | mListView->addColumn(i18n("Recurs")); // recurs? | 207 | mListView->addColumn(i18n("Recurs")); // recurs? |
207 | mListView->addColumn(i18n("Due Date")); | 208 | mListView->addColumn(i18n("Due Date")); |
208 | mListView->addColumn(i18n("Due Time")); | 209 | mListView->addColumn(i18n("Due Time")); |
209 | mListView->addColumn(i18n("Cancelled")); | 210 | mListView->addColumn(i18n("Cancelled")); |
210 | mListView->addColumn(i18n("Categories")); | 211 | mListView->addColumn(i18n("Categories")); |
211 | 212 | ||
212 | mListView->setColumnAlignment(0,AlignLeft); | 213 | mListView->setColumnAlignment(0,AlignLeft); |
213 | mListView->setColumnAlignment(1,AlignLeft); | 214 | mListView->setColumnAlignment(1,AlignLeft); |
214 | mListView->setColumnAlignment(2,AlignHCenter); | 215 | mListView->setColumnAlignment(2,AlignHCenter); |
215 | mListView->setColumnAlignment(3,AlignLeft); | 216 | mListView->setColumnAlignment(3,AlignLeft); |
216 | mListView->setColumnAlignment(4,AlignHCenter); | 217 | mListView->setColumnAlignment(4,AlignHCenter); |
217 | mListView->setColumnAlignment(5,AlignLeft); | 218 | mListView->setColumnAlignment(5,AlignLeft); |
218 | mListView->setColumnAlignment(6,AlignLeft); | 219 | mListView->setColumnAlignment(6,AlignLeft); |
219 | mListView->setColumnAlignment(7,AlignLeft); | 220 | mListView->setColumnAlignment(7,AlignLeft); |
220 | mListView->setColumnAlignment(8,AlignLeft); | 221 | mListView->setColumnAlignment(8,AlignLeft); |
221 | mListView->setColumnAlignment(9,AlignLeft); | 222 | mListView->setColumnAlignment(9,AlignLeft); |
222 | mListView->setColumnAlignment(10,AlignLeft); | 223 | mListView->setColumnAlignment(10,AlignLeft); |
223 | 224 | ||
224 | int iii = 0; | 225 | int iii = 0; |
225 | for ( iii = 0; iii< 10 ; ++iii ) | 226 | for ( iii = 0; iii< 10 ; ++iii ) |
226 | mListView->setColumnWidthMode( iii, QListView::Manual ); | 227 | mListView->setColumnWidthMode( iii, QListView::Manual ); |
227 | 228 | ||
228 | QBoxLayout *layoutTop = new QVBoxLayout(this); | 229 | QBoxLayout *layoutTop = new QVBoxLayout(this); |
229 | layoutTop->addWidget(mListView); | 230 | layoutTop->addWidget(mListView); |
230 | mListView->setFont ( KOPrefs::instance()->mListViewFont ); | 231 | mListView->setFont ( KOPrefs::instance()->mListViewFont ); |
231 | mPopupMenu = eventPopup(); | 232 | mPopupMenu = eventPopup(); |
232 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 233 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
233 | i18n("Select all"),this, | 234 | i18n("Select all"),this, |
234 | SLOT(allSelection()),true); | 235 | SLOT(allSelection()),true); |
235 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 236 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
236 | i18n("Deselect All"),this, | 237 | i18n("Deselect All"),this, |
237 | SLOT(clearSelection()),true); | 238 | SLOT(clearSelection()),true); |
238 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 239 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
239 | i18n("Delete all selected"),this, | 240 | i18n("Delete all selected"),this, |
240 | SLOT(deleteAll()),true); | 241 | SLOT(deleteAll()),true); |
241 | mPopupMenu->insertSeparator(); | 242 | mPopupMenu->insertSeparator(); |
242 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 243 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
243 | i18n("Save selected to file..."),this, | 244 | i18n("Save selected to file..."),this, |
244 | SLOT(saveToFile()),true); | 245 | SLOT(saveToFile()),true); |
245 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 246 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
246 | i18n("Save Journal/Description..."),this, | 247 | i18n("Save Journal/Description..."),this, |
247 | SLOT(saveDescriptionToFile()),true); | 248 | SLOT(saveDescriptionToFile()),true); |
248 | mPopupMenu->insertSeparator(); | 249 | mPopupMenu->insertSeparator(); |
249 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 250 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
250 | i18n("Add Categ. to selected..."),this, | 251 | i18n("Add Categ. to selected..."),this, |
251 | SLOT(addCat()),true); | 252 | SLOT(addCat()),true); |
252 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 253 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
253 | i18n("Set Categ. for selected..."),this, | 254 | i18n("Set Categ. for selected..."),this, |
254 | SLOT(setCat()),true); | 255 | SLOT(setCat()),true); |
255 | mPopupMenu->insertSeparator(); | 256 | mPopupMenu->insertSeparator(); |
256 | 257 | ||
257 | 258 | ||
258 | #ifndef DESKTOP_VERSION | 259 | #ifndef DESKTOP_VERSION |
259 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 260 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
260 | i18n("Beam selected via IR"),this, | 261 | i18n("Beam selected via IR"),this, |
261 | SLOT(beamSelected()),true); | 262 | SLOT(beamSelected()),true); |
262 | #endif | 263 | #endif |
263 | /* | 264 | /* |
264 | mPopupMenu = new QPopupMenu; | 265 | mPopupMenu = new QPopupMenu; |
265 | mPopupMenu->insertItem(i18n("Edit Event"), this, | 266 | mPopupMenu->insertItem(i18n("Edit Event"), this, |
266 | SLOT (editEvent())); | 267 | SLOT (editEvent())); |
267 | mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this, | 268 | mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this, |
268 | SLOT (deleteEvent())); | 269 | SLOT (deleteEvent())); |
269 | mPopupMenu->insertSeparator(); | 270 | mPopupMenu->insertSeparator(); |
270 | mPopupMenu->insertItem(i18n("Show Dates"), this, | 271 | mPopupMenu->insertItem(i18n("Show Dates"), this, |
271 | SLOT(showDates())); | 272 | SLOT(showDates())); |
272 | mPopupMenu->insertItem(i18n("Hide Dates"), this, | 273 | mPopupMenu->insertItem(i18n("Hide Dates"), this, |
273 | SLOT(hideDates())); | 274 | SLOT(hideDates())); |
274 | */ | 275 | */ |
275 | QObject::connect(mListView,SIGNAL( newEvent()), | 276 | QObject::connect(mListView,SIGNAL( newEvent()), |
276 | this,SIGNAL(signalNewEvent())); | 277 | this,SIGNAL(signalNewEvent())); |
277 | QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)), | 278 | QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)), |
278 | this,SLOT(defaultItemAction(QListViewItem *))); | 279 | this,SLOT(defaultItemAction(QListViewItem *))); |
279 | QObject::connect(mListView,SIGNAL(rightButtonClicked ( QListViewItem *, | 280 | QObject::connect(mListView,SIGNAL(rightButtonClicked ( QListViewItem *, |
280 | const QPoint &, int )), | 281 | const QPoint &, int )), |
281 | this,SLOT(popupMenu(QListViewItem *,const QPoint &,int))); | 282 | this,SLOT(popupMenu(QListViewItem *,const QPoint &,int))); |
282 | QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)), | 283 | QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)), |
283 | SLOT(processSelectionChange(QListViewItem *))); | 284 | SLOT(processSelectionChange(QListViewItem *))); |
284 | QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)), | 285 | QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)), |
285 | SIGNAL(showIncidenceSignal(Incidence *)) ); | 286 | SIGNAL(showIncidenceSignal(Incidence *)) ); |
286 | 287 | ||
287 | readSettings(KOGlobals::config(),"KOListView Layout"); | 288 | readSettings(KOGlobals::config(),"KOListView Layout"); |
288 | } | 289 | } |
289 | 290 | ||
290 | KOListView::~KOListView() | 291 | KOListView::~KOListView() |
291 | { | 292 | { |
292 | delete mPopupMenu; | 293 | delete mPopupMenu; |
293 | } | 294 | } |
294 | 295 | ||
295 | void KOListView::updateList() | 296 | void KOListView::updateList() |
296 | { | 297 | { |
297 | // qDebug(" KOListView::updateList() "); | 298 | // qDebug(" KOListView::updateList() "); |
298 | 299 | ||
299 | } | 300 | } |
300 | 301 | ||
301 | void KOListView::addCat( ) | 302 | void KOListView::addCat( ) |
302 | { | 303 | { |
303 | setCategories( false ); | 304 | setCategories( false ); |
304 | } | 305 | } |
305 | void KOListView::setCat() | 306 | void KOListView::setCat() |
306 | { | 307 | { |
307 | setCategories( true ); | 308 | setCategories( true ); |
308 | } | 309 | } |
309 | void KOListView::setCategories( bool removeOld ) | 310 | void KOListView::setCategories( bool removeOld ) |
310 | { | 311 | { |
311 | 312 | ||
312 | KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); | 313 | KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); |
313 | if (! csd->exec()) { | 314 | if (! csd->exec()) { |
314 | delete csd; | 315 | delete csd; |
315 | return; | 316 | return; |
316 | } | 317 | } |
317 | QStringList catList = csd->selectedCategories(); | 318 | QStringList catList = csd->selectedCategories(); |
318 | delete csd; | 319 | delete csd; |
319 | // if ( catList.count() == 0 ) | 320 | // if ( catList.count() == 0 ) |
320 | // return; | 321 | // return; |
321 | catList.sort(); | 322 | catList.sort(); |
322 | QString categoriesStr = catList.join(","); | 323 | QString categoriesStr = catList.join(","); |
323 | int i; | 324 | int i; |
324 | QStringList itemList; | 325 | QStringList itemList; |
325 | QPtrList<KOListViewItem> sel ; | 326 | QPtrList<KOListViewItem> sel ; |
326 | QListViewItem *qitem = mListView->firstChild (); | 327 | QListViewItem *qitem = mListView->firstChild (); |
327 | while ( qitem ) { | 328 | while ( qitem ) { |
328 | if ( qitem->isSelected() ) { | 329 | if ( qitem->isSelected() ) { |
329 | sel.append(((KOListViewItem *)qitem)); | 330 | sel.append(((KOListViewItem *)qitem)); |
330 | } | 331 | } |
331 | qitem = qitem->nextSibling(); | 332 | qitem = qitem->nextSibling(); |
332 | } | 333 | } |
333 | KOListViewItem * item, *temp; | 334 | KOListViewItem * item, *temp; |
334 | item = sel.first(); | 335 | item = sel.first(); |
335 | Incidence* inc; | 336 | Incidence* inc; |
336 | while ( item ) { | 337 | while ( item ) { |
337 | inc = item->data(); | 338 | inc = item->data(); |
338 | if ( removeOld ) { | 339 | if ( removeOld ) { |
339 | inc->setCategories( categoriesStr ); | 340 | inc->setCategories( categoriesStr ); |
340 | } else { | 341 | } else { |
341 | itemList = QStringList::split (",", inc->categoriesStr() ); | 342 | itemList = QStringList::split (",", inc->categoriesStr() ); |
342 | for( i = 0; i< catList.count(); ++i ) { | 343 | for( i = 0; i< catList.count(); ++i ) { |
343 | if ( !itemList.contains (catList[i])) | 344 | if ( !itemList.contains (catList[i])) |
344 | itemList.append( catList[i] ); | 345 | itemList.append( catList[i] ); |
345 | } | 346 | } |
346 | itemList.sort(); | 347 | itemList.sort(); |
347 | inc->setCategories( itemList.join(",") ); | 348 | inc->setCategories( itemList.join(",") ); |
348 | } | 349 | } |
349 | temp = item; | 350 | temp = item; |
350 | item = sel.next(); | 351 | item = sel.next(); |
351 | mUidDict.remove( inc->uid() ); | 352 | mUidDict.remove( inc->uid() ); |
352 | delete temp;; | 353 | delete temp;; |
353 | addIncidence( inc ); | 354 | addIncidence( inc ); |
354 | } | 355 | } |
355 | } | 356 | } |
356 | 357 | ||
357 | void KOListView::beamSelected() | 358 | void KOListView::beamSelected() |
358 | { | 359 | { |
359 | int icount = 0; | 360 | int icount = 0; |
360 | QPtrList<Incidence> delSel ; | 361 | QPtrList<Incidence> delSel ; |
361 | QListViewItem *item = mListView->firstChild (); | 362 | QListViewItem *item = mListView->firstChild (); |
362 | while ( item ) { | 363 | while ( item ) { |
363 | if ( item->isSelected() ) { | 364 | if ( item->isSelected() ) { |
364 | delSel.append(((KOListViewItem *)item)->data()); | 365 | delSel.append(((KOListViewItem *)item)->data()); |
365 | ++icount; | 366 | ++icount; |
366 | } | 367 | } |
367 | 368 | ||
368 | item = item->nextSibling(); | 369 | item = item->nextSibling(); |
369 | } | 370 | } |
370 | if ( icount ) { | 371 | if ( icount ) { |
371 | emit beamIncidenceList( delSel ); | 372 | emit beamIncidenceList( delSel ); |
372 | return; | 373 | return; |
373 | QString fn ; | 374 | QString fn ; |
374 | fn = QDir::homeDirPath()+"/kopitempbeamfile.vcs"; | 375 | fn = QDir::homeDirPath()+"/kopitempbeamfile.vcs"; |
375 | QString mes; | 376 | QString mes; |
376 | bool createbup = true; | 377 | bool createbup = true; |
377 | if ( createbup ) { | 378 | if ( createbup ) { |
378 | QString description = "\n"; | 379 | QString description = "\n"; |
379 | CalendarLocal* cal = new CalendarLocal(); | 380 | CalendarLocal* cal = new CalendarLocal(); |
380 | cal->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 381 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
381 | Incidence *incidence = delSel.first(); | 382 | Incidence *incidence = delSel.first(); |
382 | while ( incidence ) { | 383 | while ( incidence ) { |
383 | Incidence *in = incidence->clone(); | 384 | Incidence *in = incidence->clone(); |
384 | description += in->summary() + "\n"; | 385 | description += in->summary() + "\n"; |
385 | cal->addIncidence( in ); | 386 | cal->addIncidence( in ); |
386 | incidence = delSel.next(); | 387 | incidence = delSel.next(); |
387 | } | 388 | } |
388 | FileStorage storage( cal, fn, new VCalFormat ); | 389 | FileStorage storage( cal, fn, new VCalFormat ); |
389 | storage.save(); | 390 | storage.save(); |
390 | delete cal; | 391 | delete cal; |
391 | mes = i18n("KO/Pi: Ready for beaming"); | 392 | mes = i18n("KO/Pi: Ready for beaming"); |
392 | topLevelWidget()->setCaption(mes); | 393 | topLevelWidget()->setCaption(mes); |
393 | 394 | ||
394 | #ifndef DESKTOP_VERSION | 395 | #ifndef DESKTOP_VERSION |
395 | Ir *ir = new Ir( this ); | 396 | Ir *ir = new Ir( this ); |
396 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 397 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
397 | ir->send( fn, description, "text/x-vCalendar" ); | 398 | ir->send( fn, description, "text/x-vCalendar" ); |
398 | #endif | 399 | #endif |
399 | } | 400 | } |
400 | } | 401 | } |
401 | } | 402 | } |
402 | void KOListView::beamDone( Ir *ir ) | 403 | void KOListView::beamDone( Ir *ir ) |
403 | { | 404 | { |
404 | #ifndef DESKTOP_VERSION | 405 | #ifndef DESKTOP_VERSION |
405 | delete ir; | 406 | delete ir; |
406 | #endif | 407 | #endif |
407 | topLevelWidget()->setCaption(i18n("KO/Pi:Beaming done")); | 408 | topLevelWidget()->setCaption(i18n("KO/Pi:Beaming done")); |
408 | } | 409 | } |
409 | 410 | ||
410 | void KOListView::saveDescriptionToFile() | 411 | void KOListView::saveDescriptionToFile() |
411 | { | 412 | { |
412 | 413 | ||
413 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 414 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
414 | i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."), | 415 | i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."), |
415 | i18n("Continue"), i18n("Cancel"), 0, | 416 | i18n("Continue"), i18n("Cancel"), 0, |
416 | 0, 1 ); | 417 | 0, 1 ); |
417 | if ( result != 0 ) { | 418 | if ( result != 0 ) { |
418 | return; | 419 | return; |
419 | } | 420 | } |
420 | int icount = 0; | 421 | int icount = 0; |
421 | QPtrList<Incidence> delSel ; | 422 | QPtrList<Incidence> delSel ; |
422 | QListViewItem *item = mListView->firstChild (); | 423 | QListViewItem *item = mListView->firstChild (); |
423 | while ( item ) { | 424 | while ( item ) { |
424 | if ( item->isSelected() ) { | 425 | if ( item->isSelected() ) { |
425 | delSel.append(((KOListViewItem *)item)->data()); | 426 | delSel.append(((KOListViewItem *)item)->data()); |
426 | ++icount; | 427 | ++icount; |
427 | } | 428 | } |
428 | 429 | ||
429 | item = item->nextSibling(); | 430 | item = item->nextSibling(); |
430 | } | 431 | } |
431 | if ( icount ) { | 432 | if ( icount ) { |
432 | QString fn = KOPrefs::instance()->mLastSaveFile; | 433 | QString fn = KOPrefs::instance()->mLastSaveFile; |
433 | fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); | 434 | fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); |
434 | 435 | ||
435 | if ( fn == "" ) | 436 | if ( fn == "" ) |
436 | return; | 437 | return; |
437 | QFileInfo info; | 438 | QFileInfo info; |
438 | info.setFile( fn ); | 439 | info.setFile( fn ); |
439 | QString mes; | 440 | QString mes; |
440 | bool createbup = true; | 441 | bool createbup = true; |
441 | if ( info. exists() ) { | 442 | if ( info. exists() ) { |
442 | mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); | 443 | mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); |
443 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 444 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
444 | i18n("Overwrite!"), i18n("Cancel"), 0, | 445 | i18n("Overwrite!"), i18n("Cancel"), 0, |
445 | 0, 1 ); | 446 | 0, 1 ); |
446 | if ( result != 0 ) { | 447 | if ( result != 0 ) { |
447 | createbup = false; | 448 | createbup = false; |
448 | } | 449 | } |
449 | } | 450 | } |
450 | if ( createbup ) { | 451 | if ( createbup ) { |
451 | QString text = i18n("KO/Pi Description/Journal save file.\nSave date: ") + | 452 | QString text = i18n("KO/Pi Description/Journal save file.\nSave date: ") + |
452 | KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), false); | 453 | KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), false); |
453 | Incidence *incidence = delSel.first(); | 454 | Incidence *incidence = delSel.first(); |
454 | icount = 0; | 455 | icount = 0; |
455 | while ( incidence ) { | 456 | while ( incidence ) { |
456 | if ( incidence->type() == "Journal" ) { | 457 | if ( incidence->type() == "Journal" ) { |
457 | text += "\n************************************\n"; | 458 | text += "\n************************************\n"; |
458 | text += i18n("Journal from: ") +incidence->dtStartDateStr( false ); | 459 | text += i18n("Journal from: ") +incidence->dtStartDateStr( false ); |
459 | text +="\n" + i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); | 460 | text +="\n" + i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); |
460 | text +="\n" + i18n("Description: ") + "\n"+ incidence->description(); | 461 | text +="\n" + i18n("Description: ") + "\n"+ incidence->description(); |
461 | ++icount; | 462 | ++icount; |
462 | 463 | ||
463 | } else { | 464 | } else { |
464 | if ( !incidence->description().isEmpty() ) { | 465 | if ( !incidence->description().isEmpty() ) { |
465 | text += "\n************************************\n"; | 466 | text += "\n************************************\n"; |
466 | if ( incidence->type() == "Todo" ) | 467 | if ( incidence->type() == "Todo" ) |
467 | text += i18n("To-Do: "); | 468 | text += i18n("To-Do: "); |
468 | text += incidence->summary(); | 469 | text += incidence->summary(); |
469 | if ( incidence->hasStartDate() ) | 470 | if ( incidence->hasStartDate() ) |
470 | text +="\n"+ i18n("Start Date: ") + incidence->dtStartStr( false ); | 471 | text +="\n"+ i18n("Start Date: ") + incidence->dtStartStr( false ); |
471 | text +="\n"+ i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); | 472 | text +="\n"+ i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); |
472 | if ( !incidence->location().isEmpty() ) | 473 | if ( !incidence->location().isEmpty() ) |
473 | text += "\n" +i18n("Location: ") + incidence->location(); | 474 | text += "\n" +i18n("Location: ") + incidence->location(); |
474 | text += "\n" + i18n("Description: ") + "\n" + incidence->description(); | 475 | text += "\n" + i18n("Description: ") + "\n" + incidence->description(); |
475 | ++icount; | 476 | ++icount; |
476 | 477 | ||
477 | } | 478 | } |
478 | } | 479 | } |
479 | incidence = delSel.next(); | 480 | incidence = delSel.next(); |
480 | } | 481 | } |
481 | QFile file( fn ); | 482 | QFile file( fn ); |
482 | if (!file.open( IO_WriteOnly ) ) { | 483 | if (!file.open( IO_WriteOnly ) ) { |
483 | topLevelWidget()->setCaption(i18n("File open error - nothing saved!") ); | 484 | topLevelWidget()->setCaption(i18n("File open error - nothing saved!") ); |
484 | return; | 485 | return; |
485 | } | 486 | } |
486 | QTextStream ts( &file ); | 487 | QTextStream ts( &file ); |
487 | ts << text; | 488 | ts << text; |
488 | file.close(); | 489 | file.close(); |
489 | //qDebug("%s ", text.latin1()); | 490 | //qDebug("%s ", text.latin1()); |
490 | mes = i18n("KO/Pi:Saved %1 descriptions/journals").arg(icount ); | 491 | mes = i18n("KO/Pi:Saved %1 descriptions/journals").arg(icount ); |
491 | KOPrefs::instance()->mLastSaveFile = fn; | 492 | KOPrefs::instance()->mLastSaveFile = fn; |
492 | topLevelWidget()->setCaption(mes); | 493 | topLevelWidget()->setCaption(mes); |
493 | } | 494 | } |
494 | } | 495 | } |
495 | } | 496 | } |
496 | void KOListView::saveToFile() | 497 | void KOListView::saveToFile() |
497 | { | 498 | { |
498 | 499 | ||
499 | int icount = 0; | 500 | int icount = 0; |
500 | QPtrList<Incidence> delSel ; | 501 | QPtrList<Incidence> delSel ; |
501 | QListViewItem *item = mListView->firstChild (); | 502 | QListViewItem *item = mListView->firstChild (); |
502 | while ( item ) { | 503 | while ( item ) { |
503 | if ( item->isSelected() ) { | 504 | if ( item->isSelected() ) { |
504 | delSel.append(((KOListViewItem *)item)->data()); | 505 | delSel.append(((KOListViewItem *)item)->data()); |
505 | ++icount; | 506 | ++icount; |
506 | } | 507 | } |
507 | 508 | ||
508 | item = item->nextSibling(); | 509 | item = item->nextSibling(); |
509 | } | 510 | } |
510 | if ( icount ) { | 511 | if ( icount ) { |
511 | QString fn = KOPrefs::instance()->mLastSaveFile; | 512 | QString fn = KOPrefs::instance()->mLastSaveFile; |
512 | fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); | 513 | fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); |
513 | 514 | ||
514 | if ( fn == "" ) | 515 | if ( fn == "" ) |
515 | return; | 516 | return; |
516 | QFileInfo info; | 517 | QFileInfo info; |
517 | info.setFile( fn ); | 518 | info.setFile( fn ); |
518 | QString mes; | 519 | QString mes; |
519 | bool createbup = true; | 520 | bool createbup = true; |
520 | if ( info. exists() ) { | 521 | if ( info. exists() ) { |
521 | mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); | 522 | mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); |
522 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 523 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
523 | i18n("Overwrite!"), i18n("Cancel"), 0, | 524 | i18n("Overwrite!"), i18n("Cancel"), 0, |
524 | 0, 1 ); | 525 | 0, 1 ); |
525 | if ( result != 0 ) { | 526 | if ( result != 0 ) { |
526 | createbup = false; | 527 | createbup = false; |
527 | } | 528 | } |
528 | } | 529 | } |
529 | if ( createbup ) { | 530 | if ( createbup ) { |
530 | CalendarLocal cal; | 531 | CalendarLocal cal; |
531 | cal.setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 532 | cal.setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
532 | Incidence *incidence = delSel.first(); | 533 | Incidence *incidence = delSel.first(); |
533 | while ( incidence ) { | 534 | while ( incidence ) { |
534 | cal.addIncidence( incidence->clone() ); | 535 | cal.addIncidence( incidence->clone() ); |
535 | incidence = delSel.next(); | 536 | incidence = delSel.next(); |
536 | } | 537 | } |
537 | ICalFormat format; | 538 | ICalFormat format; |
538 | format.save( &cal, fn ); | 539 | format.save( &cal, fn ); |
539 | mes = i18n("KO/Pi:Saved %1").arg(fn ); | 540 | mes = i18n("KO/Pi:Saved %1").arg(fn ); |
540 | KOPrefs::instance()->mLastSaveFile = fn; | 541 | KOPrefs::instance()->mLastSaveFile = fn; |
541 | topLevelWidget()->setCaption(mes); | 542 | topLevelWidget()->setCaption(mes); |
542 | } | 543 | } |
543 | } | 544 | } |
544 | } | 545 | } |
545 | void KOListView::deleteAll() | 546 | void KOListView::deleteAll() |
546 | { | 547 | { |
547 | int icount = 0; | 548 | int icount = 0; |
548 | QPtrList<Incidence> delSel ; | 549 | QPtrList<Incidence> delSel ; |
549 | QListViewItem *item = mListView->firstChild (); | 550 | QListViewItem *item = mListView->firstChild (); |
550 | while ( item ) { | 551 | while ( item ) { |
551 | if ( item->isSelected() ) { | 552 | if ( item->isSelected() ) { |
552 | delSel.append(((KOListViewItem *)item)->data()); | 553 | delSel.append(((KOListViewItem *)item)->data()); |
553 | ++icount; | 554 | ++icount; |
554 | } | 555 | } |
555 | 556 | ||
556 | item = item->nextSibling(); | 557 | item = item->nextSibling(); |
557 | } | 558 | } |
558 | if ( icount ) { | 559 | if ( icount ) { |
559 | Incidence *incidence = delSel.first(); | 560 | Incidence *incidence = delSel.first(); |
560 | Incidence *toDelete; | 561 | Incidence *toDelete; |
561 | KOPrefs *p = KOPrefs::instance(); | 562 | KOPrefs *p = KOPrefs::instance(); |
562 | bool confirm = p->mConfirm; | 563 | bool confirm = p->mConfirm; |
563 | QString mess; | 564 | QString mess; |
564 | mess = mess.sprintf( i18n("You have %d item(s) selected.\n"), icount ); | 565 | mess = mess.sprintf( i18n("You have %d item(s) selected.\n"), icount ); |
565 | if ( KMessageBox::Continue == KMessageBox::warningContinueCancel(this, mess + i18n("All selected items will be\npermanently deleted.\n(Deleting items will take\nsome time on a PDA)\n"), i18n("KO/Pi Confirmation"),i18n("Delete")) ) { | 566 | if ( KMessageBox::Continue == KMessageBox::warningContinueCancel(this, mess + i18n("All selected items will be\npermanently deleted.\n(Deleting items will take\nsome time on a PDA)\n"), i18n("KO/Pi Confirmation"),i18n("Delete")) ) { |
566 | p->mConfirm = false; | 567 | p->mConfirm = false; |
567 | int delCounter = 0; | 568 | int delCounter = 0; |
568 | QDialog dia ( this, "p-dialog", true ); | 569 | QDialog dia ( this, "p-dialog", true ); |
569 | QLabel lab (i18n("Close dialog to abort deletion!"), &dia ); | 570 | QLabel lab (i18n("Close dialog to abort deletion!"), &dia ); |
570 | QVBoxLayout lay( &dia ); | 571 | QVBoxLayout lay( &dia ); |
571 | lay.setMargin(7); | 572 | lay.setMargin(7); |
572 | lay.setSpacing(7); | 573 | lay.setSpacing(7); |
573 | lay.addWidget( &lab); | 574 | lay.addWidget( &lab); |
574 | QProgressBar bar( icount, &dia ); | 575 | QProgressBar bar( icount, &dia ); |
575 | lay.addWidget( &bar); | 576 | lay.addWidget( &bar); |
576 | int w = 220; | 577 | int w = 220; |
577 | int h = 50; | 578 | int h = 50; |
578 | int dw = QApplication::desktop()->width(); | 579 | int dw = QApplication::desktop()->width(); |
579 | int dh = QApplication::desktop()->height(); | 580 | int dh = QApplication::desktop()->height(); |
580 | dia.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 581 | dia.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
581 | //dia.resize( 240,50 ); | 582 | //dia.resize( 240,50 ); |
582 | dia.show(); | 583 | dia.show(); |
583 | 584 | ||
584 | while ( incidence ) { | 585 | while ( incidence ) { |
585 | bar.setProgress( delCounter ); | 586 | bar.setProgress( delCounter ); |
586 | mess = mess.sprintf( i18n("Deleting item %d ..."), ++delCounter ); | 587 | mess = mess.sprintf( i18n("Deleting item %d ..."), ++delCounter ); |
587 | dia.setCaption( mess ); | 588 | dia.setCaption( mess ); |
588 | qApp->processEvents(); | 589 | qApp->processEvents(); |
589 | toDelete = (incidence); | 590 | toDelete = (incidence); |
590 | incidence = delSel.next(); | 591 | incidence = delSel.next(); |
591 | emit deleteIncidenceSignal(toDelete ); | 592 | emit deleteIncidenceSignal(toDelete ); |
592 | if ( dia.result() != 0 ) | 593 | if ( dia.result() != 0 ) |
593 | break; | 594 | break; |
594 | 595 | ||
595 | } | 596 | } |
596 | mess = mess.sprintf( i18n("%d items remaining in list."), count() ); | 597 | mess = mess.sprintf( i18n("%d items remaining in list."), count() ); |
597 | topLevelWidget ()->setCaption( mess ); | 598 | topLevelWidget ()->setCaption( mess ); |
598 | p->mConfirm = confirm; | 599 | p->mConfirm = confirm; |
599 | } | 600 | } |
600 | } | 601 | } |
601 | 602 | ||
602 | 603 | ||
603 | } | 604 | } |
604 | int KOListView::maxDatesHint() | 605 | int KOListView::maxDatesHint() |
605 | { | 606 | { |
606 | return 0; | 607 | return 0; |
607 | } | 608 | } |
608 | 609 | ||
609 | int KOListView::currentDateCount() | 610 | int KOListView::currentDateCount() |
610 | { | 611 | { |
611 | return 0; | 612 | return 0; |
612 | } | 613 | } |
613 | 614 | ||
614 | QPtrList<Incidence> KOListView::selectedIncidences() | 615 | QPtrList<Incidence> KOListView::selectedIncidences() |
615 | { | 616 | { |
616 | QPtrList<Incidence> eventList; | 617 | QPtrList<Incidence> eventList; |
617 | QListViewItem *item = mListView->firstChild (); | 618 | QListViewItem *item = mListView->firstChild (); |
618 | while ( item ) { | 619 | while ( item ) { |
619 | if ( item->isSelected() ) { | 620 | if ( item->isSelected() ) { |
620 | eventList.append(((KOListViewItem *)item)->data()); | 621 | eventList.append(((KOListViewItem *)item)->data()); |
621 | } | 622 | } |
622 | 623 | ||
623 | item = item->nextSibling(); | 624 | item = item->nextSibling(); |
624 | } | 625 | } |
625 | 626 | ||
626 | // // QListViewItem *item = mListView->selectedItem(); | 627 | // // QListViewItem *item = mListView->selectedItem(); |
627 | //if (item) eventList.append(((KOListViewItem *)item)->data()); | 628 | //if (item) eventList.append(((KOListViewItem *)item)->data()); |
628 | 629 | ||
629 | return eventList; | 630 | return eventList; |
630 | } | 631 | } |
631 | 632 | ||
632 | DateList KOListView::selectedDates() | 633 | DateList KOListView::selectedDates() |
633 | { | 634 | { |
634 | DateList eventList; | 635 | DateList eventList; |
635 | return eventList; | 636 | return eventList; |
636 | } | 637 | } |
637 | 638 | ||
638 | void KOListView::showDates(bool show) | 639 | void KOListView::showDates(bool show) |
639 | { | 640 | { |
640 | // Shouldn't we set it to a value greater 0? When showDates is called with | 641 | // Shouldn't we set it to a value greater 0? When showDates is called with |
641 | // show == true at first, then the columnwidths are set to zero. | 642 | // show == true at first, then the columnwidths are set to zero. |
642 | static int oldColWidth1 = 0; | 643 | static int oldColWidth1 = 0; |
643 | static int oldColWidth3 = 0; | 644 | static int oldColWidth3 = 0; |
644 | 645 | ||
645 | if (!show) { | 646 | if (!show) { |
646 | oldColWidth1 = mListView->columnWidth(1); | 647 | oldColWidth1 = mListView->columnWidth(1); |
647 | oldColWidth3 = mListView->columnWidth(3); | 648 | oldColWidth3 = mListView->columnWidth(3); |
648 | mListView->setColumnWidth(1, 0); | 649 | mListView->setColumnWidth(1, 0); |
649 | mListView->setColumnWidth(3, 0); | 650 | mListView->setColumnWidth(3, 0); |
650 | } else { | 651 | } else { |
651 | mListView->setColumnWidth(1, oldColWidth1); | 652 | mListView->setColumnWidth(1, oldColWidth1); |
652 | mListView->setColumnWidth(3, oldColWidth3); | 653 | mListView->setColumnWidth(3, oldColWidth3); |
653 | } | 654 | } |
654 | mListView->repaint(); | 655 | mListView->repaint(); |
655 | } | 656 | } |
656 | 657 | ||
657 | void KOListView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 658 | void KOListView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
658 | const QDate &td) | 659 | const QDate &td) |
659 | { | 660 | { |
660 | #ifndef KORG_NOPRINTER | 661 | #ifndef KORG_NOPRINTER |
661 | calPrinter->preview(CalPrinter::Day, fd, td); | 662 | calPrinter->preview(CalPrinter::Day, fd, td); |
662 | #endif | 663 | #endif |
663 | } | 664 | } |
664 | 665 | ||
665 | void KOListView::showDates() | 666 | void KOListView::showDates() |
666 | { | 667 | { |
667 | showDates(true); | 668 | showDates(true); |
668 | } | 669 | } |
669 | 670 | ||
670 | void KOListView::hideDates() | 671 | void KOListView::hideDates() |
671 | { | 672 | { |
672 | showDates(false); | 673 | showDates(false); |
673 | } | 674 | } |
674 | 675 | ||
675 | void KOListView::updateView() | 676 | void KOListView::updateView() |
676 | { | 677 | { |
677 | mListView->setFocus(); | 678 | mListView->setFocus(); |
678 | if ( mListView->firstChild () ) | 679 | if ( mListView->firstChild () ) |
679 | mListView->setCurrentItem( mListView->firstChild () ); | 680 | mListView->setCurrentItem( mListView->firstChild () ); |
680 | } | 681 | } |
681 | void KOListView::updateConfig() | 682 | void KOListView::updateConfig() |
682 | { | 683 | { |
683 | 684 | ||
684 | mListView->setFont ( KOPrefs::instance()->mListViewFont ); | 685 | mListView->setFont ( KOPrefs::instance()->mListViewFont ); |
685 | updateView(); | 686 | updateView(); |
686 | 687 | ||
687 | } | 688 | } |
688 | void KOListView::setStartDate(const QDate &start) | 689 | void KOListView::setStartDate(const QDate &start) |
689 | { | 690 | { |
690 | mStartDate = start; | 691 | mStartDate = start; |
691 | } | 692 | } |
692 | 693 | ||
693 | void KOListView::showDates(const QDate &start, const QDate &end) | 694 | void KOListView::showDates(const QDate &start, const QDate &end) |
694 | { | 695 | { |
695 | clear(); | 696 | clear(); |
696 | mStartDate = start; | 697 | mStartDate = start; |
697 | QDate date = start; | 698 | QDate date = start; |
698 | QPtrList<Journal> j_list; | 699 | QPtrList<Journal> j_list; |
699 | while( date <= end ) { | 700 | while( date <= end ) { |
700 | addEvents(calendar()->events(date)); | 701 | addEvents(calendar()->events(date)); |
701 | addTodos(calendar()->todos(date)); | 702 | addTodos(calendar()->todos(date)); |
702 | Journal* jo = calendar()->journal(date); | 703 | Journal* jo = calendar()->journal(date); |
703 | if ( jo ) | 704 | if ( jo ) |
704 | j_list.append( jo ); | 705 | j_list.append( jo ); |
705 | date = date.addDays( 1 ); | 706 | date = date.addDays( 1 ); |
706 | } | 707 | } |
707 | addJournals(j_list); | 708 | addJournals(j_list); |
708 | emit incidenceSelected( 0 ); | 709 | emit incidenceSelected( 0 ); |
709 | updateView(); | 710 | updateView(); |
710 | 711 | ||
711 | } | 712 | } |
712 | 713 | ||
713 | void KOListView::addEvents(QPtrList<Event> eventList) | 714 | void KOListView::addEvents(QPtrList<Event> eventList) |
714 | { | 715 | { |
715 | Event *ev; | 716 | Event *ev; |
716 | for(ev = eventList.first(); ev; ev = eventList.next()) { | 717 | for(ev = eventList.first(); ev; ev = eventList.next()) { |
717 | addIncidence(ev); | 718 | addIncidence(ev); |
718 | } | 719 | } |
719 | if ( !mListView->currentItem() ){ | 720 | if ( !mListView->currentItem() ){ |
720 | updateView(); | 721 | updateView(); |
721 | } | 722 | } |
722 | } | 723 | } |
723 | 724 | ||
724 | void KOListView::addTodos(QPtrList<Todo> eventList) | 725 | void KOListView::addTodos(QPtrList<Todo> eventList) |
725 | { | 726 | { |
726 | Todo *ev; | 727 | Todo *ev; |
727 | for(ev = eventList.first(); ev; ev = eventList.next()) { | 728 | for(ev = eventList.first(); ev; ev = eventList.next()) { |
728 | addIncidence(ev); | 729 | addIncidence(ev); |
729 | } | 730 | } |
730 | if ( !mListView->currentItem() ){ | 731 | if ( !mListView->currentItem() ){ |
731 | updateView(); | 732 | updateView(); |
732 | } | 733 | } |
733 | } | 734 | } |
734 | void KOListView::addJournals(QPtrList<Journal> eventList) | 735 | void KOListView::addJournals(QPtrList<Journal> eventList) |
735 | { | 736 | { |
736 | Journal *ev; | 737 | Journal *ev; |
737 | for(ev = eventList.first(); ev; ev = eventList.next()) { | 738 | for(ev = eventList.first(); ev; ev = eventList.next()) { |
738 | addIncidence(ev); | 739 | addIncidence(ev); |
739 | } | 740 | } |
740 | if ( !mListView->currentItem() ){ | 741 | if ( !mListView->currentItem() ){ |
741 | updateView(); | 742 | updateView(); |
742 | } | 743 | } |
743 | } | 744 | } |
744 | 745 | ||
745 | void KOListView::addIncidence(Incidence *incidence) | 746 | void KOListView::addIncidence(Incidence *incidence) |
746 | { | 747 | { |
747 | if ( mUidDict.find( incidence->uid() ) ) return; | 748 | if ( mUidDict.find( incidence->uid() ) ) return; |
748 | 749 | ||
749 | // mListView->setFont ( KOPrefs::instance()->mListViewFont ); | 750 | // mListView->setFont ( KOPrefs::instance()->mListViewFont ); |
750 | mUidDict.insert( incidence->uid(), incidence ); | 751 | mUidDict.insert( incidence->uid(), incidence ); |
751 | 752 | ||
752 | KOListViewItem *item = new KOListViewItem( incidence, mListView ); | 753 | KOListViewItem *item = new KOListViewItem( incidence, mListView ); |
753 | ListItemVisitor v(item, mStartDate ); | 754 | ListItemVisitor v(item, mStartDate ); |
754 | if (incidence->accept(v)) return; | 755 | if (incidence->accept(v)) return; |
755 | else delete item; | 756 | else delete item; |
756 | //qDebug("delete item "); | 757 | //qDebug("delete item "); |
757 | } | 758 | } |
758 | 759 | ||
759 | void KOListView::showEvents(QPtrList<Event> eventList) | 760 | void KOListView::showEvents(QPtrList<Event> eventList) |
760 | { | 761 | { |
761 | clear(); | 762 | clear(); |
762 | 763 | ||
763 | addEvents(eventList); | 764 | addEvents(eventList); |
764 | 765 | ||
765 | // After new creation of list view no events are selected. | 766 | // After new creation of list view no events are selected. |
766 | emit incidenceSelected( 0 ); | 767 | emit incidenceSelected( 0 ); |
767 | } | 768 | } |
768 | int KOListView::count() | 769 | int KOListView::count() |
769 | { | 770 | { |
770 | return mListView->childCount(); | 771 | return mListView->childCount(); |
771 | } | 772 | } |
772 | 773 | ||
773 | void KOListView::changeEventDisplay(Event *event, int action) | 774 | void KOListView::changeEventDisplay(Event *event, int action) |
774 | { | 775 | { |
775 | KOListViewItem *item; | 776 | KOListViewItem *item; |
776 | 777 | ||
777 | switch(action) { | 778 | switch(action) { |
778 | case KOGlobals::EVENTADDED: | 779 | case KOGlobals::EVENTADDED: |
779 | addIncidence( event ); | 780 | addIncidence( event ); |
780 | break; | 781 | break; |
781 | case KOGlobals::EVENTEDITED: | 782 | case KOGlobals::EVENTEDITED: |
782 | item = getItemForEvent(event); | 783 | item = getItemForEvent(event); |
783 | if (item) { | 784 | if (item) { |
784 | mUidDict.remove( event->uid() ); | 785 | mUidDict.remove( event->uid() ); |
785 | delete item; | 786 | delete item; |
786 | addIncidence( event ); | 787 | addIncidence( event ); |
787 | } | 788 | } |
788 | break; | 789 | break; |
789 | case KOGlobals::EVENTDELETED: | 790 | case KOGlobals::EVENTDELETED: |
790 | item = getItemForEvent(event); | 791 | item = getItemForEvent(event); |
791 | if (item) { | 792 | if (item) { |
792 | mUidDict.remove( event->uid() ); | 793 | mUidDict.remove( event->uid() ); |
793 | delete item; | 794 | delete item; |
794 | } | 795 | } |
795 | break; | 796 | break; |
796 | default: | 797 | default: |
797 | ; | 798 | ; |
798 | } | 799 | } |
799 | } | 800 | } |
800 | 801 | ||
801 | KOListViewItem *KOListView::getItemForEvent(Event *event) | 802 | KOListViewItem *KOListView::getItemForEvent(Event *event) |
802 | { | 803 | { |
803 | KOListViewItem *item = (KOListViewItem *)mListView->firstChild(); | 804 | KOListViewItem *item = (KOListViewItem *)mListView->firstChild(); |
804 | while (item) { | 805 | while (item) { |
805 | if (item->data() == event) return item; | 806 | if (item->data() == event) return item; |
806 | item = (KOListViewItem *)item->nextSibling(); | 807 | item = (KOListViewItem *)item->nextSibling(); |
807 | } | 808 | } |
808 | return 0; | 809 | return 0; |
809 | } | 810 | } |
810 | 811 | ||
811 | void KOListView::defaultItemAction(QListViewItem *i) | 812 | void KOListView::defaultItemAction(QListViewItem *i) |
812 | { | 813 | { |
813 | KOListViewItem *item = static_cast<KOListViewItem *>( i ); | 814 | KOListViewItem *item = static_cast<KOListViewItem *>( i ); |
814 | if ( item ) defaultAction( item->data() ); | 815 | if ( item ) defaultAction( item->data() ); |
815 | 816 | ||
816 | } | 817 | } |
817 | 818 | ||
818 | void KOListView::popupMenu(QListViewItem *item,const QPoint &,int) | 819 | void KOListView::popupMenu(QListViewItem *item,const QPoint &,int) |
819 | { | 820 | { |
820 | mActiveItem = (KOListViewItem *)item; | 821 | mActiveItem = (KOListViewItem *)item; |
821 | if (mActiveItem) { | 822 | if (mActiveItem) { |
822 | Incidence *incidence = mActiveItem->data(); | 823 | Incidence *incidence = mActiveItem->data(); |
823 | mPopupMenu->showIncidencePopup(incidence); | 824 | mPopupMenu->showIncidencePopup(incidence); |
824 | 825 | ||
825 | /* | 826 | /* |
826 | if ( incidence && incidence->type() == "Event" ) { | 827 | if ( incidence && incidence->type() == "Event" ) { |
827 | Event *event = static_cast<Event *>( incidence ); | 828 | Event *event = static_cast<Event *>( incidence ); |
828 | mPopupMenu->showEventPopup(event); | 829 | mPopupMenu->showEventPopup(event); |
829 | } | 830 | } |
830 | */ | 831 | */ |
831 | } | 832 | } |
832 | } | 833 | } |
833 | 834 | ||
834 | void KOListView::readSettings(KConfig *config, QString setting) | 835 | void KOListView::readSettings(KConfig *config, QString setting) |
835 | { | 836 | { |
836 | // qDebug("KOListView::readSettings "); | 837 | // qDebug("KOListView::readSettings "); |
837 | mListView->restoreLayout(config,setting); | 838 | mListView->restoreLayout(config,setting); |
838 | } | 839 | } |
839 | 840 | ||
840 | void KOListView::writeSettings(KConfig *config, QString setting) | 841 | void KOListView::writeSettings(KConfig *config, QString setting) |
841 | { | 842 | { |
842 | // qDebug("KOListView::writeSettings "); | 843 | // qDebug("KOListView::writeSettings "); |
843 | mListView->saveLayout(config, setting); | 844 | mListView->saveLayout(config, setting); |
844 | } | 845 | } |
845 | 846 | ||
846 | void KOListView::processSelectionChange(QListViewItem *) | 847 | void KOListView::processSelectionChange(QListViewItem *) |
847 | { | 848 | { |
848 | 849 | ||
849 | KOListViewItem *item = | 850 | KOListViewItem *item = |
850 | static_cast<KOListViewItem *>( mListView->currentItem() ); | 851 | static_cast<KOListViewItem *>( mListView->currentItem() ); |
851 | 852 | ||
852 | if ( !item ) { | 853 | if ( !item ) { |
853 | emit incidenceSelected( 0 ); | 854 | emit incidenceSelected( 0 ); |
854 | } else { | 855 | } else { |
855 | emit incidenceSelected( item->data() ); | 856 | emit incidenceSelected( item->data() ); |
856 | } | 857 | } |
857 | } | 858 | } |
858 | 859 | ||
859 | void KOListView::clearSelection() | 860 | void KOListView::clearSelection() |
860 | { | 861 | { |
861 | mListView->selectAll( false ); | 862 | mListView->selectAll( false ); |
862 | } | 863 | } |
863 | void KOListView::allSelection() | 864 | void KOListView::allSelection() |
864 | { | 865 | { |
865 | mListView->selectAll( true ); | 866 | mListView->selectAll( true ); |
866 | } | 867 | } |
867 | 868 | ||
868 | void KOListView::clear() | 869 | void KOListView::clear() |
869 | { | 870 | { |
870 | mListView->clear(); | 871 | mListView->clear(); |
871 | mUidDict.clear(); | 872 | mUidDict.clear(); |
872 | } | 873 | } |
873 | 874 | ||
874 | Incidence* KOListView::currentItem() | 875 | Incidence* KOListView::currentItem() |
875 | { | 876 | { |
876 | if ( mListView->currentItem() ) | 877 | if ( mListView->currentItem() ) |
877 | return ((KOListViewItem*) mListView->currentItem())->data(); | 878 | return ((KOListViewItem*) mListView->currentItem())->data(); |
878 | return 0; | 879 | return 0; |
879 | } | 880 | } |
880 | void KOListView::keyPressEvent ( QKeyEvent *e) | 881 | void KOListView::keyPressEvent ( QKeyEvent *e) |
881 | { | 882 | { |
882 | 883 | ||
883 | if ( e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace ) { | 884 | if ( e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace ) { |
884 | deleteAll(); | 885 | deleteAll(); |
885 | return; | 886 | return; |
886 | } | 887 | } |
887 | 888 | ||
888 | e->ignore(); | 889 | e->ignore(); |
889 | } | 890 | } |
890 | void KOListViewListView::keyPressEvent ( QKeyEvent *e) | 891 | void KOListViewListView::keyPressEvent ( QKeyEvent *e) |
891 | { | 892 | { |
892 | 893 | ||
893 | switch ( e->key() ) { | 894 | switch ( e->key() ) { |
894 | case Qt::Key_Down: | 895 | case Qt::Key_Down: |
895 | if ( e->state() == ShiftButton ) { | 896 | if ( e->state() == ShiftButton ) { |
896 | QListViewItem* cn = currentItem(); | 897 | QListViewItem* cn = currentItem(); |
897 | if ( !cn ) | 898 | if ( !cn ) |
898 | cn = firstChild(); | 899 | cn = firstChild(); |
899 | if ( !cn ) | 900 | if ( !cn ) |
900 | return; | 901 | return; |
901 | while ( cn->nextSibling() ) | 902 | while ( cn->nextSibling() ) |
902 | cn = cn->nextSibling(); | 903 | cn = cn->nextSibling(); |
903 | setCurrentItem ( cn ); | 904 | setCurrentItem ( cn ); |
904 | ensureItemVisible ( cn ); | 905 | ensureItemVisible ( cn ); |
905 | 906 | ||
906 | e->accept(); | 907 | e->accept(); |
907 | return; | 908 | return; |
908 | } | 909 | } |
909 | if ( e->state() == ControlButton ) { | 910 | if ( e->state() == ControlButton ) { |
910 | int count = childCount (); | 911 | int count = childCount (); |
911 | int jump = count / 5; | 912 | int jump = count / 5; |
912 | QListViewItem* cn; | 913 | QListViewItem* cn; |
913 | cn = currentItem(); | 914 | cn = currentItem(); |
914 | if ( ! cn ) | 915 | if ( ! cn ) |
915 | return; | 916 | return; |
916 | if ( jump == 0 ) | 917 | if ( jump == 0 ) |
917 | jump = 1; | 918 | jump = 1; |
918 | while ( jump && cn->nextSibling() ) { | 919 | while ( jump && cn->nextSibling() ) { |
919 | cn = cn->nextSibling(); | 920 | cn = cn->nextSibling(); |
920 | --jump; | 921 | --jump; |
921 | } | 922 | } |
922 | setCurrentItem ( cn ); | 923 | setCurrentItem ( cn ); |
923 | ensureItemVisible ( cn ); | 924 | ensureItemVisible ( cn ); |
924 | 925 | ||
925 | } else | 926 | } else |
926 | QListView::keyPressEvent ( e ) ; | 927 | QListView::keyPressEvent ( e ) ; |
927 | e->accept(); | 928 | e->accept(); |
928 | break; | 929 | break; |
929 | 930 | ||
930 | case Qt::Key_Up: | 931 | case Qt::Key_Up: |
931 | if ( e->state() == ShiftButton ) { | 932 | if ( e->state() == ShiftButton ) { |
932 | QListViewItem* cn = firstChild(); | 933 | QListViewItem* cn = firstChild(); |
933 | if ( cn ) { | 934 | if ( cn ) { |
934 | setCurrentItem ( cn ); | 935 | setCurrentItem ( cn ); |
935 | ensureItemVisible ( cn ); | 936 | ensureItemVisible ( cn ); |
936 | } | 937 | } |
937 | e->accept(); | 938 | e->accept(); |
938 | return; | 939 | return; |
939 | } | 940 | } |
940 | if ( e->state() == ControlButton ) { | 941 | if ( e->state() == ControlButton ) { |
941 | int count = childCount (); | 942 | int count = childCount (); |
942 | int jump = count / 5; | 943 | int jump = count / 5; |
943 | QListViewItem* cn; | 944 | QListViewItem* cn; |
944 | cn = currentItem(); | 945 | cn = currentItem(); |
945 | if ( ! cn ) | 946 | if ( ! cn ) |
946 | return; | 947 | return; |
947 | if ( jump == 0 ) | 948 | if ( jump == 0 ) |
948 | jump = 1; | 949 | jump = 1; |
949 | while ( jump && cn->itemAbove ()) { | 950 | while ( jump && cn->itemAbove ()) { |
950 | cn = cn->itemAbove (); | 951 | cn = cn->itemAbove (); |
951 | --jump; | 952 | --jump; |
952 | } | 953 | } |
953 | setCurrentItem ( cn ); | 954 | setCurrentItem ( cn ); |
954 | ensureItemVisible ( cn ); | 955 | ensureItemVisible ( cn ); |
955 | } else | 956 | } else |
956 | QListView::keyPressEvent ( e ) ; | 957 | QListView::keyPressEvent ( e ) ; |
957 | e->accept(); | 958 | e->accept(); |
958 | break; | 959 | break; |
959 | case Qt::Key_I: { | 960 | case Qt::Key_I: { |
960 | QListViewItem* cn; | 961 | QListViewItem* cn; |
961 | cn = currentItem(); | 962 | cn = currentItem(); |
962 | if ( cn ) { | 963 | if ( cn ) { |
963 | KOListViewItem* ci = (KOListViewItem*)( cn ); | 964 | KOListViewItem* ci = (KOListViewItem*)( cn ); |
964 | if ( ci ){ | 965 | if ( ci ){ |
965 | emit showIncidence( ci->data()); | 966 | emit showIncidence( ci->data()); |
966 | cn = cn->nextSibling(); | 967 | cn = cn->nextSibling(); |
967 | if ( cn ) { | 968 | if ( cn ) { |
968 | setCurrentItem ( cn ); | 969 | setCurrentItem ( cn ); |
969 | ensureItemVisible ( cn ); | 970 | ensureItemVisible ( cn ); |
970 | } | 971 | } |
971 | } | 972 | } |
972 | } | 973 | } |
973 | e->accept(); | 974 | e->accept(); |
974 | } | 975 | } |
975 | break; | 976 | break; |
976 | case Qt::Key_Return: | 977 | case Qt::Key_Return: |
977 | case Qt::Key_Enter: | 978 | case Qt::Key_Enter: |
978 | { | 979 | { |
979 | QListViewItem* cn; | 980 | QListViewItem* cn; |
980 | cn = currentItem(); | 981 | cn = currentItem(); |
981 | if ( cn ) { | 982 | if ( cn ) { |
982 | KOListViewItem* ci = (KOListViewItem*)( cn ); | 983 | KOListViewItem* ci = (KOListViewItem*)( cn ); |
983 | if ( ci ){ | 984 | if ( ci ){ |
984 | if ( e->state() == ShiftButton ) | 985 | if ( e->state() == ShiftButton ) |
985 | ci->setSelected( false ); | 986 | ci->setSelected( false ); |
986 | else | 987 | else |
987 | ci->setSelected( true ); | 988 | ci->setSelected( true ); |
988 | cn = cn->nextSibling(); | 989 | cn = cn->nextSibling(); |
989 | if ( cn ) { | 990 | if ( cn ) { |
990 | setCurrentItem ( cn ); | 991 | setCurrentItem ( cn ); |
991 | ensureItemVisible ( cn ); | 992 | ensureItemVisible ( cn ); |
992 | } | 993 | } |
993 | } | 994 | } |
994 | } | 995 | } |
995 | e->accept(); | 996 | e->accept(); |
996 | } | 997 | } |
997 | break; | 998 | break; |
998 | default: | 999 | default: |
999 | e->ignore(); | 1000 | e->ignore(); |
1000 | } | 1001 | } |
1001 | } | 1002 | } |
1002 | KOListViewListView::KOListViewListView(KOListView * lv ) | 1003 | KOListViewListView::KOListViewListView(KOListView * lv ) |
1003 | : KListView( lv ) | 1004 | : KListView( lv ) |
1004 | { | 1005 | { |
1005 | #ifndef DESKTOP_VERSION | 1006 | #ifndef DESKTOP_VERSION |
1006 | QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); | 1007 | QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); |
1007 | #endif | 1008 | #endif |
1008 | setSelectionMode( QListView::Multi ); | 1009 | setSelectionMode( QListView::Multi ); |
1009 | setMultiSelection( true); | 1010 | setMultiSelection( true); |
1010 | mAllowPopupMenu = true; | 1011 | mAllowPopupMenu = true; |
1011 | mMouseDown = false; | 1012 | mMouseDown = false; |
1012 | 1013 | ||
1013 | } | 1014 | } |
1014 | void KOListViewListView::contentsMouseDoubleClickEvent(QMouseEvent *e) | 1015 | void KOListViewListView::contentsMouseDoubleClickEvent(QMouseEvent *e) |
1015 | { | 1016 | { |
1016 | if (!e) return; | 1017 | if (!e) return; |
1017 | QPoint vp = contentsToViewport(e->pos()); | 1018 | QPoint vp = contentsToViewport(e->pos()); |
1018 | QListViewItem *item = itemAt(vp); | 1019 | QListViewItem *item = itemAt(vp); |
1019 | if (!item) { | 1020 | if (!item) { |
1020 | emit newEvent(); | 1021 | emit newEvent(); |
1021 | return; | 1022 | return; |
1022 | } | 1023 | } |
1023 | KListView::contentsMouseDoubleClickEvent(e); | 1024 | KListView::contentsMouseDoubleClickEvent(e); |
1024 | } | 1025 | } |
1025 | 1026 | ||
1026 | 1027 | ||
1027 | void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) | 1028 | void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) |
1028 | { | 1029 | { |
1029 | //qDebug("contentsMousePressEvent++++ "); | 1030 | //qDebug("contentsMousePressEvent++++ "); |
1030 | if (! mMouseDown ) { | 1031 | if (! mMouseDown ) { |
1031 | mAllowPopupMenu = true; | 1032 | mAllowPopupMenu = true; |
1032 | mYMousePos = mapToGlobal( (e->pos())).y(); | 1033 | mYMousePos = mapToGlobal( (e->pos())).y(); |
1033 | } | 1034 | } |
1034 | if ( e->button() == RightButton && mMouseDown ) | 1035 | if ( e->button() == RightButton && mMouseDown ) |
1035 | return; | 1036 | return; |
1036 | if ( e->button() == LeftButton ) | 1037 | if ( e->button() == LeftButton ) |
1037 | mMouseDown = true; | 1038 | mMouseDown = true; |
1038 | KListView::contentsMousePressEvent( e ); | 1039 | KListView::contentsMousePressEvent( e ); |
1039 | } | 1040 | } |
1040 | void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) | 1041 | void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) |
1041 | { | 1042 | { |
1042 | //qDebug("contentsMouseReleaseEv---- "); | 1043 | //qDebug("contentsMouseReleaseEv---- "); |
1043 | if ( ! mMouseDown ) { | 1044 | if ( ! mMouseDown ) { |
1044 | if ( e->button() == RightButton && ! mAllowPopupMenu ) | 1045 | if ( e->button() == RightButton && ! mAllowPopupMenu ) |
1045 | return; | 1046 | return; |
1046 | QListViewItem* ci = currentItem(); | 1047 | QListViewItem* ci = currentItem(); |
1047 | if ( ci ) | 1048 | if ( ci ) |
1048 | ci->setSelected( true ); | 1049 | ci->setSelected( true ); |
1049 | KListView::contentsMouseReleaseEvent(e); | 1050 | KListView::contentsMouseReleaseEvent(e); |
1050 | return; | 1051 | return; |
1051 | } | 1052 | } |
1052 | if ( e->button() == LeftButton ) | 1053 | if ( e->button() == LeftButton ) |
1053 | mMouseDown = false; | 1054 | mMouseDown = false; |
1054 | if ( e->button() == RightButton && ! mAllowPopupMenu ) | 1055 | if ( e->button() == RightButton && ! mAllowPopupMenu ) |
1055 | return; | 1056 | return; |
1056 | if ( e->button() == RightButton ) { | 1057 | if ( e->button() == RightButton ) { |
1057 | QListViewItem* ci = currentItem(); | 1058 | QListViewItem* ci = currentItem(); |
1058 | if ( ci ) | 1059 | if ( ci ) |
1059 | ci->setSelected( true ); | 1060 | ci->setSelected( true ); |
1060 | } | 1061 | } |
1061 | KListView::contentsMouseReleaseEvent(e); | 1062 | KListView::contentsMouseReleaseEvent(e); |
1062 | } | 1063 | } |
1063 | void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) | 1064 | void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) |
1064 | { | 1065 | { |
1065 | // qDebug("contentsMouseMoveEv....... "); | 1066 | // qDebug("contentsMouseMoveEv....... "); |
1066 | // qDebug("start: %d current %d ",mYMousePos , mapToGlobal( (e->pos())).y() ); | 1067 | // qDebug("start: %d current %d ",mYMousePos , mapToGlobal( (e->pos())).y() ); |
1067 | int diff = mYMousePos - mapToGlobal( (e->pos())).y(); | 1068 | int diff = mYMousePos - mapToGlobal( (e->pos())).y(); |
1068 | if ( diff < 0 ) diff = -diff; | 1069 | if ( diff < 0 ) diff = -diff; |
1069 | if ( diff > 20 ) | 1070 | if ( diff > 20 ) |
1070 | mAllowPopupMenu = false; | 1071 | mAllowPopupMenu = false; |
1071 | KListView::contentsMouseMoveEvent(e); | 1072 | KListView::contentsMouseMoveEvent(e); |
1072 | } | 1073 | } |
diff --git a/korganizer/koprefs.cpp b/korganizer/koprefs.cpp index 258f738..ba1c6d1 100644 --- a/korganizer/koprefs.cpp +++ b/korganizer/koprefs.cpp | |||
@@ -1,566 +1,555 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <time.h> | 24 | #include <time.h> |
25 | #ifndef _WIN32_ | 25 | #ifndef _WIN32_ |
26 | #include <unistd.h> | 26 | #include <unistd.h> |
27 | #endif | 27 | #endif |
28 | #include <qdir.h> | 28 | #include <qdir.h> |
29 | #include <qtextstream.h> | 29 | #include <qtextstream.h> |
30 | #include <qtextcodec.h> | 30 | #include <qtextcodec.h> |
31 | #include <qstring.h> | 31 | #include <qstring.h> |
32 | #include <qregexp.h> | 32 | #include <qregexp.h> |
33 | #include <qfont.h> | 33 | #include <qfont.h> |
34 | #include <qcolor.h> | 34 | #include <qcolor.h> |
35 | #include <qstringlist.h> | 35 | #include <qstringlist.h> |
36 | #include <stdlib.h> | 36 | #include <stdlib.h> |
37 | 37 | ||
38 | #include <kglobal.h> | 38 | #include <kglobal.h> |
39 | #include <kconfig.h> | 39 | #include <kconfig.h> |
40 | #include <klocale.h> | 40 | #include <klocale.h> |
41 | #include <kdebug.h> | 41 | #include <kdebug.h> |
42 | #include <kemailsettings.h> | 42 | #include <kemailsettings.h> |
43 | #include <kstaticdeleter.h> | 43 | #include <kstaticdeleter.h> |
44 | #include <libkdepim/kpimglobalprefs.h> | 44 | #include <libkdepim/kpimglobalprefs.h> |
45 | 45 | ||
46 | #include "koprefs.h" | 46 | #include "koprefs.h" |
47 | #include "mainwindow.h" | 47 | #include "mainwindow.h" |
48 | 48 | ||
49 | const char *germanwords[][2] = { | 49 | const char *germanwords[][2] = { |
50 | #include "wordsgerman.h" | 50 | #include "wordsgerman.h" |
51 | "", "" | 51 | "", "" |
52 | }; | 52 | }; |
53 | 53 | ||
54 | KOPrefs *KOPrefs::mInstance = 0; | 54 | KOPrefs *KOPrefs::mInstance = 0; |
55 | static KStaticDeleter<KOPrefs> insd; | 55 | static KStaticDeleter<KOPrefs> insd; |
56 | 56 | ||
57 | KOPrefs::KOPrefs() : | 57 | KOPrefs::KOPrefs() : |
58 | KPimPrefs("korganizerrc") | 58 | KPimPrefs("korganizerrc") |
59 | { | 59 | { |
60 | mCategoryColors.setAutoDelete(true); | 60 | mCategoryColors.setAutoDelete(true); |
61 | mLocaleDict = 0; | 61 | mLocaleDict = 0; |
62 | fillMailDefaults(); | 62 | fillMailDefaults(); |
63 | mDefaultCategoryColor = QColor(175,210,255);//196,196,196); | 63 | mDefaultCategoryColor = QColor(175,210,255);//196,196,196); |
64 | QColor defaultHolidayColor = QColor(255,0,0); | 64 | QColor defaultHolidayColor = QColor(255,0,0); |
65 | QColor defaultHighlightColor = QColor(129,112,255);//64,64,255); | 65 | QColor defaultHighlightColor = QColor(129,112,255);//64,64,255); |
66 | QColor defaultAgendaBgColor = QColor(239,241,169);//128,128,128); | 66 | QColor defaultAgendaBgColor = QColor(239,241,169);//128,128,128); |
67 | QColor defaultWorkingHoursColor = QColor(170,223,150);//160,160,160); | 67 | QColor defaultWorkingHoursColor = QColor(170,223,150);//160,160,160); |
68 | QColor defaultTodoDueTodayColor = QColor(255,220,100); | 68 | QColor defaultTodoDueTodayColor = QColor(255,220,100); |
69 | QColor defaultTodoOverdueColor = QColor(255,153,125); | 69 | QColor defaultTodoOverdueColor = QColor(255,153,125); |
70 | 70 | ||
71 | mTimeBarFont = QFont("helvetica",10);//,QFont::Bold); | 71 | mTimeBarFont = QFont("helvetica",10);//,QFont::Bold); |
72 | mDefaultViewFont = QFont("helvetica",10); | 72 | mDefaultViewFont = QFont("helvetica",10); |
73 | mDefaultMonthViewFont = QFont("helvetica",8); | 73 | mDefaultMonthViewFont = QFont("helvetica",8); |
74 | mMarcusBainsFont= QFont("helvetica",10); | 74 | mMarcusBainsFont= QFont("helvetica",10); |
75 | mDateNavigatorFont= QFont("helvetica",10, QFont::Bold); | 75 | mDateNavigatorFont= QFont("helvetica",10, QFont::Bold); |
76 | mEditBoxFont = QFont("helvetica",12); | 76 | mEditBoxFont = QFont("helvetica",12); |
77 | mJornalViewFont = QFont("helvetica",12); | 77 | mJornalViewFont = QFont("helvetica",12); |
78 | 78 | ||
79 | KPrefs::setCurrentGroup("General"); | 79 | KPrefs::setCurrentGroup("General"); |
80 | 80 | ||
81 | 81 | ||
82 | addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); | 82 | addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); |
83 | 83 | ||
84 | addItemBool("ShowIconNewTodo",&mShowIconNewTodo,true); | 84 | addItemBool("ShowIconNewTodo",&mShowIconNewTodo,true); |
85 | addItemBool("ShowIconNewEvent",&mShowIconNewEvent,true); | 85 | addItemBool("ShowIconNewEvent",&mShowIconNewEvent,true); |
86 | addItemBool("ShowIconSearch",&mShowIconSearch,true); | 86 | addItemBool("ShowIconSearch",&mShowIconSearch,true); |
87 | addItemBool("ShowIconList",&mShowIconList,true); | 87 | addItemBool("ShowIconList",&mShowIconList,true); |
88 | addItemBool("ShowIconDay1",&mShowIconDay1,true); | 88 | addItemBool("ShowIconDay1",&mShowIconDay1,true); |
89 | addItemBool("ShowIconDay5",&mShowIconDay5,true); | 89 | addItemBool("ShowIconDay5",&mShowIconDay5,true); |
90 | addItemBool("ShowIconDay7",&mShowIconDay7,true); | 90 | addItemBool("ShowIconDay7",&mShowIconDay7,true); |
91 | addItemBool("ShowIconMonth",&mShowIconMonth,true); | 91 | addItemBool("ShowIconMonth",&mShowIconMonth,true); |
92 | addItemBool("ShowIconTodoview",&mShowIconTodoview,true); | 92 | addItemBool("ShowIconTodoview",&mShowIconTodoview,true); |
93 | addItemBool("ShowIconBackFast",&mShowIconBackFast,true); | 93 | addItemBool("ShowIconBackFast",&mShowIconBackFast,true); |
94 | addItemBool("ShowIconBack",&mShowIconBack,true); | 94 | addItemBool("ShowIconBack",&mShowIconBack,true); |
95 | addItemBool("ShowIconToday",&mShowIconToday,true); | 95 | addItemBool("ShowIconToday",&mShowIconToday,true); |
96 | addItemBool("ShowIconForward",&mShowIconForward,true); | 96 | addItemBool("ShowIconForward",&mShowIconForward,true); |
97 | addItemBool("ShowIconForwardFast",&mShowIconForwardFast,true); | 97 | addItemBool("ShowIconForwardFast",&mShowIconForwardFast,true); |
98 | addItemBool("ShowIconWhatsThis",&mShowIconWhatsThis,false); | 98 | addItemBool("ShowIconWhatsThis",&mShowIconWhatsThis,false); |
99 | addItemBool("ShowIconNextDays",&mShowIconNextDays,true); | 99 | addItemBool("ShowIconNextDays",&mShowIconNextDays,true); |
100 | addItemBool("ShowIconNext",&mShowIconNext,true); | 100 | addItemBool("ShowIconNext",&mShowIconNext,true); |
101 | addItemBool("ShowIconJournal",&mShowIconJournal,true); | 101 | addItemBool("ShowIconJournal",&mShowIconJournal,true); |
102 | addItemBool("ShowIconStretch",&mShowIconStretch,true); | 102 | addItemBool("ShowIconStretch",&mShowIconStretch,true); |
103 | addItemBool("LanguageChanged",&mLanguageChanged,false); | 103 | addItemBool("LanguageChanged",&mLanguageChanged,false); |
104 | 104 | ||
105 | addItemBool("AskForQuit",&mAskForQuit,false); | 105 | addItemBool("AskForQuit",&mAskForQuit,false); |
106 | 106 | ||
107 | #ifndef DESKTOP_VERSION | 107 | #ifndef DESKTOP_VERSION |
108 | addItemBool("ShowFullMenu",&mShowFullMenu,false); | 108 | addItemBool("ShowFullMenu",&mShowFullMenu,false); |
109 | #else | 109 | #else |
110 | addItemBool("ShowFullMenu",&mShowFullMenu,true); | 110 | addItemBool("ShowFullMenu",&mShowFullMenu,true); |
111 | #endif | 111 | #endif |
112 | addItemBool("ToolBarHor",&mToolBarHor, true ); | 112 | addItemBool("ToolBarHor",&mToolBarHor, true ); |
113 | addItemBool("ToolBarUp",&mToolBarUp, false ); | 113 | addItemBool("ToolBarUp",&mToolBarUp, false ); |
114 | addItemBool("ToolBarMiniIcons",&mToolBarMiniIcons, false ); | 114 | addItemBool("ToolBarMiniIcons",&mToolBarMiniIcons, false ); |
115 | addItemInt("Whats Next Days",&mWhatsNextDays,3); | 115 | addItemInt("Whats Next Days",&mWhatsNextDays,3); |
116 | addItemInt("Whats Next Prios",&mWhatsNextPrios,1); | 116 | addItemInt("Whats Next Prios",&mWhatsNextPrios,1); |
117 | 117 | ||
118 | addItemBool("ShowTodoInAgenda",&mShowTodoInAgenda,true); | 118 | addItemBool("ShowTodoInAgenda",&mShowTodoInAgenda,true); |
119 | addItemBool("ShowCompletedTodo",&mShowCompletedTodo,true); | 119 | addItemBool("ShowCompletedTodo",&mShowCompletedTodo,true); |
120 | addItemInt("AllDay Size",&mAllDaySize,28); | 120 | addItemInt("AllDay Size",&mAllDaySize,28); |
121 | QString defAlarm = KGlobal::iconLoader()->iconPath()+"koalarm.wav"; | 121 | QString defAlarm = KGlobal::iconLoader()->iconPath()+"koalarm.wav"; |
122 | addItemString("DefaultAlarmFile",&mDefaultAlarmFile,defAlarm ); | 122 | addItemString("DefaultAlarmFile",&mDefaultAlarmFile,defAlarm ); |
123 | 123 | ||
124 | addItemStringList("LocationDefaults",&mLocationDefaults ); | 124 | addItemStringList("LocationDefaults",&mLocationDefaults ); |
125 | addItemStringList("EventSummary User",&mEventSummaryUser); | 125 | addItemStringList("EventSummary User",&mEventSummaryUser); |
126 | addItemStringList("TodoSummary User",&mTodoSummaryUser); | 126 | addItemStringList("TodoSummary User",&mTodoSummaryUser); |
127 | 127 | ||
128 | addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); | 128 | addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); |
129 | addItemBool("Enable Project View",&mEnableProjectView,false); | 129 | addItemBool("Enable Project View",&mEnableProjectView,false); |
130 | addItemBool("Auto Save",&mAutoSave,false); | 130 | addItemBool("Auto Save",&mAutoSave,false); |
131 | addItemInt("Auto Save Interval",&mAutoSaveInterval,3); | 131 | addItemInt("Auto Save Interval",&mAutoSaveInterval,3); |
132 | addItemBool("Confirm Deletes",&mConfirm,true); | 132 | addItemBool("Confirm Deletes",&mConfirm,true); |
133 | addItemString("Archive File",&mArchiveFile); | 133 | addItemString("Archive File",&mArchiveFile); |
134 | addItemString("Html Export File",&mHtmlExportFile, | 134 | addItemString("Html Export File",&mHtmlExportFile, |
135 | QDir::homeDirPath() + "/" + i18n("Default export file", "calendar.html")); | 135 | QDir::homeDirPath() + "/" + i18n("Default export file", "calendar.html")); |
136 | addItemBool("Html With Save",&mHtmlWithSave,false); | 136 | addItemBool("Html With Save",&mHtmlWithSave,false); |
137 | 137 | ||
138 | KPrefs::setCurrentGroup("Personal Settings"); | 138 | KPrefs::setCurrentGroup("Personal Settings"); |
139 | 139 | ||
140 | addItemInt("Mail Client",&mMailClient,MailClientKMail); | 140 | addItemInt("Mail Client",&mMailClient,MailClientKMail); |
141 | addItemBool("Use Control Center Email",&mEmailControlCenter,false); | 141 | addItemBool("Use Control Center Email",&mEmailControlCenter,false); |
142 | addItemBool("Bcc",&mBcc,false); | 142 | addItemBool("Bcc",&mBcc,false); |
143 | 143 | ||
144 | KPrefs::setCurrentGroup("Time & Date"); | 144 | KPrefs::setCurrentGroup("Time & Date"); |
145 | 145 | ||
146 | // addItemString("Time Zone",&mTimeZone,"+0100"); | ||
147 | addItemString("TimeZoneName",&mTimeZoneId,i18n ("+01:00 Europe/Oslo(CET)") ); | ||
148 | // addItemInt("TimeZoneOffset",&mTimeZoneOffset,60); | ||
149 | addItemBool("UseDaylightsaving",&mUseDaylightsaving,true); | ||
150 | addItemInt("DaylightsavingStart",&mDaylightsavingStart,90); | ||
151 | addItemInt("DaylightsavingEnd",&mDaylightsavingEnd,304); | ||
152 | |||
153 | 146 | ||
154 | addItemInt("Default Start Time",&mStartTime,10); | 147 | addItemInt("Default Start Time",&mStartTime,10); |
155 | addItemInt("Default Duration",&mDefaultDuration,2); | 148 | addItemInt("Default Duration",&mDefaultDuration,2); |
156 | addItemInt("Default Alarm Time",&mAlarmTime,3); | 149 | addItemInt("Default Alarm Time",&mAlarmTime,3); |
157 | addItemInt("Daylight Savings",&mDaylightSavings,0); | ||
158 | KPrefs::setCurrentGroup("AlarmSettings"); | 150 | KPrefs::setCurrentGroup("AlarmSettings"); |
159 | addItemInt("AlarmPlayBeeps",&mAlarmPlayBeeps,20); | 151 | addItemInt("AlarmPlayBeeps",&mAlarmPlayBeeps,20); |
160 | addItemInt("AlarmSuspendTime",&mAlarmSuspendTime,7); | 152 | addItemInt("AlarmSuspendTime",&mAlarmSuspendTime,7); |
161 | addItemInt("AlarmSuspendCount",&mAlarmSuspendCount,5); | 153 | addItemInt("AlarmSuspendCount",&mAlarmSuspendCount,5); |
162 | addItemInt("AlarmBeepInterval",&mAlarmBeepInterval,3); | 154 | addItemInt("AlarmBeepInterval",&mAlarmBeepInterval,3); |
163 | 155 | ||
164 | 156 | ||
165 | KPrefs::setCurrentGroup("Calendar"); | 157 | KPrefs::setCurrentGroup("Calendar"); |
166 | 158 | ||
167 | addItemInt("Default Calendar Format",&mDefaultFormat,FormatICalendar); | 159 | addItemInt("Default Calendar Format",&mDefaultFormat,FormatICalendar); |
168 | 160 | ||
169 | KPrefs::setCurrentGroup("Fonts"); | 161 | KPrefs::setCurrentGroup("Fonts"); |
170 | // qDebug(" KPrefs::setCurrentGroup(Fonts); "); | 162 | // qDebug(" KPrefs::setCurrentGroup(Fonts); "); |
171 | addItemFont("TimeBar Font",&mTimeBarFont); | 163 | addItemFont("TimeBar Font",&mTimeBarFont); |
172 | addItemFont("MonthView Font",&mMonthViewFont); | 164 | addItemFont("MonthView Font",&mMonthViewFont); |
173 | addItemFont("AgendaView Font",&mAgendaViewFont); | 165 | addItemFont("AgendaView Font",&mAgendaViewFont); |
174 | addItemFont("MarcusBains Font",&mMarcusBainsFont); | 166 | addItemFont("MarcusBains Font",&mMarcusBainsFont); |
175 | addItemFont("TimeLabels Font",&mTimeLabelsFont); | 167 | addItemFont("TimeLabels Font",&mTimeLabelsFont); |
176 | addItemFont("TodoView Font",&mTodoViewFont); | 168 | addItemFont("TodoView Font",&mTodoViewFont); |
177 | addItemFont("ListView Font",&mListViewFont); | 169 | addItemFont("ListView Font",&mListViewFont); |
178 | addItemFont("DateNavigator Font",&mDateNavigatorFont); | 170 | addItemFont("DateNavigator Font",&mDateNavigatorFont); |
179 | addItemFont("EditBox Font",&mEditBoxFont); | 171 | addItemFont("EditBox Font",&mEditBoxFont); |
180 | addItemFont("JournalView Font",&mJornalViewFont); | 172 | addItemFont("JournalView Font",&mJornalViewFont); |
181 | addItemFont("WhatsNextView Font",&mWhatsNextFont); | 173 | addItemFont("WhatsNextView Font",&mWhatsNextFont); |
182 | addItemFont("EventView Font",&mEventViewFont); | 174 | addItemFont("EventView Font",&mEventViewFont); |
183 | 175 | ||
184 | // KPrefs::setCurrentGroup("SyncProfiles"); | 176 | // KPrefs::setCurrentGroup("SyncProfiles"); |
185 | // addItemString("LocalMachineName",&mLocalMachineName, "undefined"); | 177 | // addItemString("LocalMachineName",&mLocalMachineName, "undefined"); |
186 | // addItemStringList("SyncProfileNames",&mSyncProfileNames); | 178 | // addItemStringList("SyncProfileNames",&mSyncProfileNames); |
187 | // addItemStringList("ExternSyncProfiles",&mExternSyncProfileNames); | 179 | // addItemStringList("ExternSyncProfiles",&mExternSyncProfileNames); |
188 | 180 | ||
189 | KPrefs::setCurrentGroup("RemoteSyncing"); | 181 | KPrefs::setCurrentGroup("RemoteSyncing"); |
190 | // addItemBool("UsePasswd",&mUsePassWd,false); | 182 | // addItemBool("UsePasswd",&mUsePassWd,false); |
191 | // addItemBool("WriteBackFile",&mWriteBackFile,true); | 183 | // addItemBool("WriteBackFile",&mWriteBackFile,true); |
192 | // addItemBool("WriteBackExistingOnly",&mWriteBackExistingOnly,false); | 184 | // addItemBool("WriteBackExistingOnly",&mWriteBackExistingOnly,false); |
193 | // addItemBool("AskForPreferences",&mAskForPreferences,true); | 185 | // addItemBool("AskForPreferences",&mAskForPreferences,true); |
194 | // addItemBool("ShowSyncSummary",&mShowSyncSummary,true); | 186 | // addItemBool("ShowSyncSummary",&mShowSyncSummary,true); |
195 | addItemString("ActiveSyncPort",&mActiveSyncPort,"9197" ); | 187 | addItemString("ActiveSyncPort",&mActiveSyncPort,"9197" ); |
196 | addItemString("ActiveSyncIP",&mActiveSyncIP,"192.168.0.40" ); | 188 | addItemString("ActiveSyncIP",&mActiveSyncIP,"192.168.0.40" ); |
197 | addItemBool("ShowSyncEvents",&mShowSyncEvents,false); | 189 | addItemBool("ShowSyncEvents",&mShowSyncEvents,false); |
198 | addItemInt("LastSyncTime",&mLastSyncTime,0); | 190 | addItemInt("LastSyncTime",&mLastSyncTime,0); |
199 | 191 | ||
200 | #ifdef _WIN32_ | 192 | #ifdef _WIN32_ |
201 | QString hdp= locateLocal("data","korganizer")+"\\\\"; | 193 | QString hdp= locateLocal("data","korganizer")+"\\\\"; |
202 | #else | 194 | #else |
203 | QString hdp= locateLocal("data","korganizer")+"/"; | 195 | QString hdp= locateLocal("data","korganizer")+"/"; |
204 | #endif | 196 | #endif |
205 | 197 | ||
206 | KPrefs::setCurrentGroup("LoadSaveFileNames"); | 198 | KPrefs::setCurrentGroup("LoadSaveFileNames"); |
207 | 199 | ||
208 | addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" ); | 200 | addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" ); |
209 | addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" ); | 201 | addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" ); |
210 | addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" ); | 202 | addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" ); |
211 | addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" ); | 203 | addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" ); |
212 | 204 | ||
213 | 205 | ||
214 | KPrefs::setCurrentGroup("Locale"); | 206 | KPrefs::setCurrentGroup("Locale"); |
215 | addItemInt("PreferredLanguage",&mPreferredLanguage,0); | 207 | addItemInt("PreferredLanguage",&mPreferredLanguage,0); |
216 | addItemInt("PreferredTime",&mPreferredTime,0); | 208 | addItemInt("PreferredTime",&mPreferredTime,0); |
217 | addItemInt("PreferredDate",&mPreferredDate,0); | 209 | addItemInt("PreferredDate",&mPreferredDate,0); |
218 | addItemBool("WeekStartsOnSunday",&mWeekStartsOnSunday,false); | 210 | addItemBool("WeekStartsOnSunday",&mWeekStartsOnSunday,false); |
219 | addItemBool("ShortDateInViewer",&mShortDateInViewer,false); | 211 | addItemBool("ShortDateInViewer",&mShortDateInViewer,false); |
220 | addItemString("UserDateFormatLong", &mUserDateFormatLong, "%A %d %b %y"); | 212 | addItemString("UserDateFormatLong", &mUserDateFormatLong, "%A %d %b %y"); |
221 | addItemString("UserDateFormatShort", &mUserDateFormatShort, "%aK %d.%m.%y"); | 213 | addItemString("UserDateFormatShort", &mUserDateFormatShort, "%aK %d.%m.%y"); |
222 | 214 | ||
223 | 215 | ||
224 | KPrefs::setCurrentGroup("Colors"); | 216 | KPrefs::setCurrentGroup("Colors"); |
225 | addItemColor("Holiday Color",&mHolidayColor,defaultHolidayColor); | 217 | addItemColor("Holiday Color",&mHolidayColor,defaultHolidayColor); |
226 | addItemColor("Highlight Color",&mHighlightColor,defaultHighlightColor); | 218 | addItemColor("Highlight Color",&mHighlightColor,defaultHighlightColor); |
227 | addItemColor("Event Color",&mEventColor,mDefaultCategoryColor); | 219 | addItemColor("Event Color",&mEventColor,mDefaultCategoryColor); |
228 | addItemColor("Agenda Background Color",&mAgendaBgColor,defaultAgendaBgColor); | 220 | addItemColor("Agenda Background Color",&mAgendaBgColor,defaultAgendaBgColor); |
229 | addItemColor("WorkingHours Color",&mWorkingHoursColor,defaultWorkingHoursColor); | 221 | addItemColor("WorkingHours Color",&mWorkingHoursColor,defaultWorkingHoursColor); |
230 | addItemColor("Todo due today Color",&mTodoDueTodayColor,defaultTodoDueTodayColor); | 222 | addItemColor("Todo due today Color",&mTodoDueTodayColor,defaultTodoDueTodayColor); |
231 | addItemColor("Todo overdue Color",&mTodoOverdueColor,defaultTodoOverdueColor); | 223 | addItemColor("Todo overdue Color",&mTodoOverdueColor,defaultTodoOverdueColor); |
232 | addItemColor("MonthViewEvenColor",&mMonthViewEvenColor,QColor( 160,160,255 )); | 224 | addItemColor("MonthViewEvenColor",&mMonthViewEvenColor,QColor( 160,160,255 )); |
233 | addItemColor("MonthViewOddColor",&mMonthViewOddColor,QColor( 160,255,160 )); | 225 | addItemColor("MonthViewOddColor",&mMonthViewOddColor,QColor( 160,255,160 )); |
234 | addItemColor("MonthViewHolidayColor",&mMonthViewHolidayColor,QColor( 255,160,160 )); | 226 | addItemColor("MonthViewHolidayColor",&mMonthViewHolidayColor,QColor( 255,160,160 )); |
235 | addItemBool("MonthViewUsesDayColors",&mMonthViewUsesDayColors,true); | 227 | addItemBool("MonthViewUsesDayColors",&mMonthViewUsesDayColors,true); |
236 | addItemBool("MonthViewSatSunTog",&mMonthViewSatSunTog,true); | 228 | addItemBool("MonthViewSatSunTog",&mMonthViewSatSunTog,true); |
237 | addItemBool("HightlightDateTimeEdit",&mHightlightDateTimeEdit,false); | 229 | addItemBool("HightlightDateTimeEdit",&mHightlightDateTimeEdit,false); |
238 | addItemColor("AppColor1",&mAppColor1,QColor( 130,170,255 )); | 230 | addItemColor("AppColor1",&mAppColor1,QColor( 130,170,255 )); |
239 | addItemColor("AppColor2",&mAppColor2,QColor( 174,216,255 )); | 231 | addItemColor("AppColor2",&mAppColor2,QColor( 174,216,255 )); |
240 | addItemBool("UseAppColors",&mUseAppColors,false); | 232 | addItemBool("UseAppColors",&mUseAppColors,false); |
241 | 233 | ||
242 | 234 | ||
243 | 235 | ||
244 | KPrefs::setCurrentGroup("Views"); | 236 | KPrefs::setCurrentGroup("Views"); |
245 | addItemInt("Hour Size",&mHourSize,8); | 237 | addItemInt("Hour Size",&mHourSize,8); |
246 | addItemBool("Show Daily Recurrences",&mDailyRecur,true); | 238 | addItemBool("Show Daily Recurrences",&mDailyRecur,true); |
247 | addItemBool("Show Weekly Recurrences",&mWeeklyRecur,true); | 239 | addItemBool("Show Weekly Recurrences",&mWeeklyRecur,true); |
248 | addItemBool("Show Month Daily Recurrences",&mMonthDailyRecur,true); | 240 | addItemBool("Show Month Daily Recurrences",&mMonthDailyRecur,true); |
249 | addItemBool("Show Month Weekly Recurrences",&mMonthWeeklyRecur,true); | 241 | addItemBool("Show Month Weekly Recurrences",&mMonthWeeklyRecur,true); |
250 | addItemBool("ShowShortMonthName",&mMonthShowShort,false); | 242 | addItemBool("ShowShortMonthName",&mMonthShowShort,false); |
251 | addItemBool("ShowIconsInMonthCell",&mMonthShowIcons,true); | 243 | addItemBool("ShowIconsInMonthCell",&mMonthShowIcons,true); |
252 | addItemBool("Enable ToolTips",&mEnableToolTips,false); | 244 | addItemBool("Enable ToolTips",&mEnableToolTips,false); |
253 | addItemBool("Enable MonthView ScrollBars",&mEnableMonthScroll,false); | 245 | addItemBool("Enable MonthView ScrollBars",&mEnableMonthScroll,false); |
254 | addItemBool("Marcus Bains shows seconds",&mMarcusBainsShowSeconds,false); | 246 | addItemBool("Marcus Bains shows seconds",&mMarcusBainsShowSeconds,false); |
255 | addItemBool("Show Marcus Bains",&mMarcusBainsEnabled,true); | 247 | addItemBool("Show Marcus Bains",&mMarcusBainsEnabled,true); |
256 | addItemBool("EditOnDoubleClick",&mEditOnDoubleClick,true); | 248 | addItemBool("EditOnDoubleClick",&mEditOnDoubleClick,true); |
257 | addItemBool("ViewChangeHoldFullscreen",&mViewChangeHoldFullscreen,false); | 249 | addItemBool("ViewChangeHoldFullscreen",&mViewChangeHoldFullscreen,false); |
258 | addItemBool("ViewChangeHoldNonFullscreen",&mViewChangeHoldNonFullscreen,false); | 250 | addItemBool("ViewChangeHoldNonFullscreen",&mViewChangeHoldNonFullscreen,false); |
259 | addItemBool("CenterOnCurrentTime",&mCenterOnCurrentTime,false); | 251 | addItemBool("CenterOnCurrentTime",&mCenterOnCurrentTime,false); |
260 | addItemBool("SetTimeToDayStartAt",&mSetTimeToDayStartAt,true); | 252 | addItemBool("SetTimeToDayStartAt",&mSetTimeToDayStartAt,true); |
261 | addItemBool("HighlightCurrentDay",&mHighlightCurrentDay,true); | 253 | addItemBool("HighlightCurrentDay",&mHighlightCurrentDay,true); |
262 | addItemBool("WNViewShowsParents",&mWNViewShowsParents,true); | 254 | addItemBool("WNViewShowsParents",&mWNViewShowsParents,true); |
263 | addItemBool("WNViewShowLocation",&mWNViewShowLocation,false); | 255 | addItemBool("WNViewShowLocation",&mWNViewShowLocation,false); |
264 | addItemBool("UseHighlightLightColor",&mUseHighlightLightColor,false); | 256 | addItemBool("UseHighlightLightColor",&mUseHighlightLightColor,false); |
265 | addItemBool("ListViewMonthTimespan",&mListViewMonthTimespan,true); | 257 | addItemBool("ListViewMonthTimespan",&mListViewMonthTimespan,true); |
266 | addItemBool("TodoViewUsesCatColors",&mTodoViewUsesCatColors,false); | 258 | addItemBool("TodoViewUsesCatColors",&mTodoViewUsesCatColors,false); |
267 | addItemBool("TodoViewShowsPercentage",&mTodoViewShowsPercentage,false); | 259 | addItemBool("TodoViewShowsPercentage",&mTodoViewShowsPercentage,false); |
268 | addItemBool("TodoViewUsesSmallFont",&mTodoViewUsesSmallFont,false); | 260 | addItemBool("TodoViewUsesSmallFont",&mTodoViewUsesSmallFont,false); |
269 | addItemBool("TodoViewUsesForegroundColor",&mTodoViewUsesForegroundColor,false); | 261 | addItemBool("TodoViewUsesForegroundColor",&mTodoViewUsesForegroundColor,false); |
270 | addItemBool("MonthViewUsesForegroundColor",&mMonthViewUsesForegroundColor,false); | 262 | addItemBool("MonthViewUsesForegroundColor",&mMonthViewUsesForegroundColor,false); |
271 | #ifdef DESKTOP_VERSION | 263 | #ifdef DESKTOP_VERSION |
272 | addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,true); | 264 | addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,true); |
273 | #else | 265 | #else |
274 | addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,false); | 266 | addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,false); |
275 | #endif | 267 | #endif |
276 | addItemInt("Day Begins",&mDayBegins,7); | 268 | addItemInt("Day Begins",&mDayBegins,7); |
277 | addItemInt("Working Hours Start",&mWorkingHoursStart,8); | 269 | addItemInt("Working Hours Start",&mWorkingHoursStart,8); |
278 | addItemInt("Working Hours End",&mWorkingHoursEnd,17); | 270 | addItemInt("Working Hours End",&mWorkingHoursEnd,17); |
279 | addItemBool("Exclude Holidays",&mExcludeHolidays,true); | 271 | addItemBool("Exclude Holidays",&mExcludeHolidays,true); |
280 | addItemBool("Exclude Saturdays",&mExcludeSaturdays,true); | 272 | addItemBool("Exclude Saturdays",&mExcludeSaturdays,true); |
281 | 273 | ||
282 | addItemBool("Month View Uses Category Color",&mMonthViewUsesCategoryColor,false); | 274 | addItemBool("Month View Uses Category Color",&mMonthViewUsesCategoryColor,false); |
283 | addItemBool("Full View Month",&mFullViewMonth,true); | 275 | addItemBool("Full View Month",&mFullViewMonth,true); |
284 | addItemBool("Full View Todo",&mFullViewTodo,true); | 276 | addItemBool("Full View Todo",&mFullViewTodo,true); |
285 | addItemBool("Quick Todo",&mEnableQuickTodo,false); | 277 | addItemBool("Quick Todo",&mEnableQuickTodo,false); |
286 | 278 | ||
287 | addItemInt("Next X Days",&mNextXDays,3); | 279 | addItemInt("Next X Days",&mNextXDays,3); |
288 | 280 | ||
289 | KPrefs::setCurrentGroup("Printer"); | 281 | KPrefs::setCurrentGroup("Printer"); |
290 | 282 | ||
291 | KPrefs::setCurrentGroup("Layout"); | 283 | KPrefs::setCurrentGroup("Layout"); |
292 | 284 | ||
293 | addItemBool("CompactDialogs",&mCompactDialogs,false); | 285 | addItemBool("CompactDialogs",&mCompactDialogs,false); |
294 | addItemBool("VerticalScreen",&mVerticalScreen,true); | 286 | addItemBool("VerticalScreen",&mVerticalScreen,true); |
295 | 287 | ||
296 | KPrefs::setCurrentGroup("KOrganizer Plugins"); | 288 | KPrefs::setCurrentGroup("KOrganizer Plugins"); |
297 | 289 | ||
298 | addItemStringList("SelectedPlugins",&mSelectedPlugins,"holidays"); | 290 | addItemStringList("SelectedPlugins",&mSelectedPlugins,"holidays"); |
299 | 291 | ||
300 | KPrefs::setCurrentGroup("Group Scheduling"); | 292 | KPrefs::setCurrentGroup("Group Scheduling"); |
301 | 293 | ||
302 | addItemInt("IMIPScheduler",&mIMIPScheduler,IMIPKMail); | 294 | addItemInt("IMIPScheduler",&mIMIPScheduler,IMIPKMail); |
303 | addItemInt("IMIPSend",&mIMIPSend,IMIPdirectsend); | 295 | addItemInt("IMIPSend",&mIMIPSend,IMIPdirectsend); |
304 | addItemStringList("AdditionalMails",&mAdditionalMails,""); | 296 | addItemStringList("AdditionalMails",&mAdditionalMails,""); |
305 | addItemInt("IMIP auto refresh",&mIMIPAutoRefresh,neverAuto); | 297 | addItemInt("IMIP auto refresh",&mIMIPAutoRefresh,neverAuto); |
306 | addItemInt("IMIP auto insert request",&mIMIPAutoInsertRequest,neverAuto); | 298 | addItemInt("IMIP auto insert request",&mIMIPAutoInsertRequest,neverAuto); |
307 | addItemInt("IMIP auto insert reply",&mIMIPAutoInsertReply,neverAuto); | 299 | addItemInt("IMIP auto insert reply",&mIMIPAutoInsertReply,neverAuto); |
308 | addItemInt("IMIP auto FreeBusy",&mIMIPAutoFreeBusy,neverAuto); | 300 | addItemInt("IMIP auto FreeBusy",&mIMIPAutoFreeBusy,neverAuto); |
309 | addItemInt("IMIP auto save FreeBusy",&mIMIPAutoFreeBusyReply,neverAuto); | 301 | addItemInt("IMIP auto save FreeBusy",&mIMIPAutoFreeBusyReply,neverAuto); |
310 | 302 | ||
311 | KPrefs::setCurrentGroup( "Editors" ); | 303 | KPrefs::setCurrentGroup( "Editors" ); |
312 | 304 | ||
313 | addItemStringList( "EventTemplates", &mEventTemplates ); | 305 | addItemStringList( "EventTemplates", &mEventTemplates ); |
314 | addItemStringList( "TodoTemplates", &mTodoTemplates ); | 306 | addItemStringList( "TodoTemplates", &mTodoTemplates ); |
315 | 307 | ||
316 | addItemInt("DestinationPolicy",&mDestination,standardDestination); | 308 | addItemInt("DestinationPolicy",&mDestination,standardDestination); |
317 | 309 | ||
318 | 310 | ||
319 | 311 | ||
320 | } | 312 | } |
321 | 313 | ||
322 | 314 | ||
323 | KOPrefs::~KOPrefs() | 315 | KOPrefs::~KOPrefs() |
324 | { | 316 | { |
325 | if (mInstance == this) | 317 | if (mInstance == this) |
326 | mInstance = insd.setObject(0); | 318 | mInstance = insd.setObject(0); |
327 | setLocaleDict( 0 ); | 319 | setLocaleDict( 0 ); |
328 | if ( mLocaleDict ) | 320 | if ( mLocaleDict ) |
329 | delete mLocaleDict; | 321 | delete mLocaleDict; |
330 | //qDebug("KOPrefs::~KOPrefs() "); | 322 | //qDebug("KOPrefs::~KOPrefs() "); |
331 | } | 323 | } |
332 | 324 | ||
333 | 325 | ||
334 | KOPrefs *KOPrefs::instance() | 326 | KOPrefs *KOPrefs::instance() |
335 | { | 327 | { |
336 | if (!mInstance) { | 328 | if (!mInstance) { |
337 | mInstance = insd.setObject(new KOPrefs()); | 329 | mInstance = insd.setObject(new KOPrefs()); |
338 | mInstance->readConfig(); | 330 | mInstance->readConfig(); |
339 | } | 331 | } |
340 | 332 | ||
341 | return mInstance; | 333 | return mInstance; |
342 | } | 334 | } |
343 | 335 | ||
344 | void KOPrefs::usrSetDefaults() | 336 | void KOPrefs::usrSetDefaults() |
345 | { | 337 | { |
346 | 338 | ||
347 | } | 339 | } |
348 | 340 | ||
349 | void KOPrefs::fillMailDefaults() | 341 | void KOPrefs::fillMailDefaults() |
350 | { | 342 | { |
351 | if (mName.isEmpty()) mName = i18n("Anonymous"); | 343 | if (mName.isEmpty()) mName = i18n("Anonymous"); |
352 | if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere"); | 344 | if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere"); |
353 | } | 345 | } |
354 | 346 | ||
355 | void KOPrefs::setTimeZoneIdDefault() | 347 | void KOPrefs::setTimeZoneIdDefault() |
356 | { | 348 | { |
357 | mTimeZoneId = i18n("+01:00 Europe/Oslo(CET)"); | 349 | ; |
358 | } | 350 | } |
359 | 351 | ||
360 | void KOPrefs::setCategoryDefaults() | 352 | void KOPrefs::setCategoryDefaults() |
361 | { | 353 | { |
362 | mCustomCategories.clear(); | 354 | mCustomCategories.clear(); |
363 | mCustomCategories = getDefaultList(); | 355 | mCustomCategories = getDefaultList(); |
364 | 356 | ||
365 | QStringList::Iterator it; | 357 | QStringList::Iterator it; |
366 | for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { | 358 | for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { |
367 | setCategoryColor(*it,mDefaultCategoryColor); | 359 | setCategoryColor(*it,mDefaultCategoryColor); |
368 | } | 360 | } |
369 | } | 361 | } |
370 | 362 | ||
371 | QStringList KOPrefs::getDefaultList() | 363 | QStringList KOPrefs::getDefaultList() |
372 | { | 364 | { |
373 | QStringList retval ; | 365 | QStringList retval ; |
374 | retval << i18n("Anniversary") << i18n("Appointment") << i18n("Birthday") << i18n("Business") << i18n("Business Travel") << i18n("Cinema") << i18n("Customer") | 366 | retval << i18n("Anniversary") << i18n("Appointment") << i18n("Birthday") << i18n("Business") << i18n("Business Travel") << i18n("Cinema") << i18n("Customer") |
375 | << i18n("Break")<< i18n("Breakfast")<< i18n("Competition")<< i18n("Dinner") | 367 | << i18n("Break")<< i18n("Breakfast")<< i18n("Competition")<< i18n("Dinner") |
376 | << i18n("Education")<< i18n("Family") << i18n("Favorites") << i18n("Festival")<< i18n("Fishing")<< i18n("Flight") << i18n("Gifts") | 368 | << i18n("Education")<< i18n("Family") << i18n("Favorites") << i18n("Festival")<< i18n("Fishing")<< i18n("Flight") << i18n("Gifts") |
377 | << i18n("Holiday") << i18n("Holiday Cards")<< i18n("Hot Contacts") << i18n("Hiking") << i18n("Hunting") << i18n("Key Customer") << i18n("Kids") | 369 | << i18n("Holiday") << i18n("Holiday Cards")<< i18n("Hot Contacts") << i18n("Hiking") << i18n("Hunting") << i18n("Key Customer") << i18n("Kids") |
378 | << i18n("Lunch") << i18n("Meeting") << i18n("Miscellaneous") << i18n("Partner")<< i18n("Party") << i18n("Personal") << i18n("Personal Travel") | 370 | << i18n("Lunch") << i18n("Meeting") << i18n("Miscellaneous") << i18n("Partner")<< i18n("Party") << i18n("Personal") << i18n("Personal Travel") |
379 | << i18n("PHB") << i18n("Phone Calls") << i18n("Projects") << i18n("Recurring") << i18n("School") << i18n("Shopping") | 371 | << i18n("PHB") << i18n("Phone Calls") << i18n("Projects") << i18n("Recurring") << i18n("School") << i18n("Shopping") |
380 | << i18n("Speach") << i18n("Special Occasion") << i18n("Sports") << i18n("Talk") << i18n("Travel") << i18n("TV")<< i18n("University") | 372 | << i18n("Speach") << i18n("Special Occasion") << i18n("Sports") << i18n("Talk") << i18n("Travel") << i18n("TV")<< i18n("University") |
381 | << i18n("Vacation") << i18n("VIP") << i18n("SyncEvent") ; | 373 | << i18n("Vacation") << i18n("VIP") << i18n("SyncEvent") ; |
382 | retval.sort(); | 374 | retval.sort(); |
383 | return retval; | 375 | return retval; |
384 | } | 376 | } |
385 | 377 | ||
386 | void KOPrefs::usrReadConfig() | 378 | void KOPrefs::usrReadConfig() |
387 | { | 379 | { |
388 | mPreferredLanguage = KPimGlobalPrefs::instance()->mPreferredLanguage; | 380 | mPreferredLanguage = KPimGlobalPrefs::instance()->mPreferredLanguage; |
389 | mLocaleDict = 0; | 381 | mLocaleDict = 0; |
390 | // pending LR fix translation | 382 | // pending LR fix translation |
391 | // qDebug("KOPrefs::usrReadConfig() fix translation "); | 383 | // qDebug("KOPrefs::usrReadConfig() fix translation "); |
392 | if ( mPreferredLanguage > 0 && mPreferredLanguage < 5 ) { | 384 | if ( mPreferredLanguage > 0 && mPreferredLanguage < 5 ) { |
393 | if ( mPreferredLanguage == 1 ) { | 385 | if ( mPreferredLanguage == 1 ) { |
394 | mLocaleDict = new QDict<QString>; | 386 | mLocaleDict = new QDict<QString>; |
395 | int i = 0; | 387 | int i = 0; |
396 | QString fw ( germanwords[i] [0]); | 388 | QString fw ( germanwords[i] [0]); |
397 | while ( !fw.isEmpty() ) { | 389 | while ( !fw.isEmpty() ) { |
398 | mLocaleDict->insert( fw, new QString (germanwords[i] [1] )); | 390 | mLocaleDict->insert( fw, new QString (germanwords[i] [1] )); |
399 | ++i; | 391 | ++i; |
400 | fw = germanwords[i] [0]; | 392 | fw = germanwords[i] [0]; |
401 | } | 393 | } |
402 | 394 | ||
403 | setLocaleDict( mLocaleDict ); | 395 | setLocaleDict( mLocaleDict ); |
404 | } else { | 396 | } else { |
405 | QString fileName ; | 397 | QString fileName ; |
406 | if ( mPreferredLanguage == 4 ) | 398 | if ( mPreferredLanguage == 4 ) |
407 | fileName = MainWindow::resourcePath()+"usertranslation.txt"; | 399 | fileName = MainWindow::resourcePath()+"usertranslation.txt"; |
408 | else if ( mPreferredLanguage == 2 ) | 400 | else if ( mPreferredLanguage == 2 ) |
409 | fileName = MainWindow::resourcePath()+"frenchtranslation.txt"; | 401 | fileName = MainWindow::resourcePath()+"frenchtranslation.txt"; |
410 | else if ( mPreferredLanguage == 3 ) | 402 | else if ( mPreferredLanguage == 3 ) |
411 | fileName = MainWindow::resourcePath()+"italiantranslation.txt"; | 403 | fileName = MainWindow::resourcePath()+"italiantranslation.txt"; |
412 | QFile file( fileName ); | 404 | QFile file( fileName ); |
413 | if (file.open( IO_ReadOnly ) ) { | 405 | if (file.open( IO_ReadOnly ) ) { |
414 | QTextStream ts( &file ); | 406 | QTextStream ts( &file ); |
415 | ts.setEncoding( QTextStream::Latin1 ); | 407 | ts.setEncoding( QTextStream::Latin1 ); |
416 | //ts.setCodec( QTextCodec::latin1 ); | 408 | //ts.setCodec( QTextCodec::latin1 ); |
417 | QString text = ts.read(); | 409 | QString text = ts.read(); |
418 | file.close(); | 410 | file.close(); |
419 | text.replace( QRegExp("\\\\n"), "\n" ); | 411 | text.replace( QRegExp("\\\\n"), "\n" ); |
420 | QString line; | 412 | QString line; |
421 | QString we; | 413 | QString we; |
422 | QString wt; | 414 | QString wt; |
423 | int br = 0; | 415 | int br = 0; |
424 | int nbr; | 416 | int nbr; |
425 | nbr = text.find ( "},", br ); | 417 | nbr = text.find ( "},", br ); |
426 | line = text.mid( br, nbr - br ); | 418 | line = text.mid( br, nbr - br ); |
427 | br = nbr+1; | 419 | br = nbr+1; |
428 | int se, ee, st, et; | 420 | int se, ee, st, et; |
429 | mLocaleDict = new QDict<QString>; | 421 | mLocaleDict = new QDict<QString>; |
430 | QString end = "{ \"\",\"\" }"; | 422 | QString end = "{ \"\",\"\" }"; |
431 | while ( (line != end) && (br > 1) ) { | 423 | while ( (line != end) && (br > 1) ) { |
432 | //qDebug("%d *%s* ", br, line.latin1()); | 424 | //qDebug("%d *%s* ", br, line.latin1()); |
433 | se = line.find("\"")+1; | 425 | se = line.find("\"")+1; |
434 | et = line.findRev("\"",-1); | 426 | et = line.findRev("\"",-1); |
435 | ee = line.find("\",\""); | 427 | ee = line.find("\",\""); |
436 | st = ee+3; | 428 | st = ee+3; |
437 | we = line.mid( se, ee-se ); | 429 | we = line.mid( se, ee-se ); |
438 | wt = line.mid( st, et-st ); | 430 | wt = line.mid( st, et-st ); |
439 | //qDebug("*%s* *%s* ", we.latin1(), wt.latin1()); | 431 | //qDebug("*%s* *%s* ", we.latin1(), wt.latin1()); |
440 | mLocaleDict->insert( we, new QString (wt) ); | 432 | mLocaleDict->insert( we, new QString (wt) ); |
441 | nbr = text.find ( "}", br ); | 433 | nbr = text.find ( "}", br ); |
442 | line = text.mid( br, nbr - br ); | 434 | line = text.mid( br, nbr - br ); |
443 | br = nbr+1; | 435 | br = nbr+1; |
444 | } | 436 | } |
445 | //qDebug("end *%s* ", end.latin1()); | 437 | //qDebug("end *%s* ", end.latin1()); |
446 | 438 | ||
447 | setLocaleDict( mLocaleDict ); | 439 | setLocaleDict( mLocaleDict ); |
448 | } else { | 440 | } else { |
449 | qDebug("KO: Cannot find translation file %s",fileName.latin1() ); | 441 | qDebug("KO: Cannot find translation file %s",fileName.latin1() ); |
450 | } | 442 | } |
451 | 443 | ||
452 | } | 444 | } |
453 | } | 445 | } |
454 | config()->setGroup("General"); | 446 | config()->setGroup("General"); |
455 | 447 | ||
456 | mCustomCategories = config()->readListEntry("Custom Categories"); | 448 | mCustomCategories = config()->readListEntry("Custom Categories"); |
457 | if ( KOPrefs::instance()->mLanguageChanged ) { | 449 | if ( KOPrefs::instance()->mLanguageChanged ) { |
458 | mLocationDefaults.clear(); | 450 | mLocationDefaults.clear(); |
459 | mEventSummaryUser.clear(); | 451 | mEventSummaryUser.clear(); |
460 | mTodoSummaryUser.clear(); | 452 | mTodoSummaryUser.clear(); |
461 | } | 453 | } |
462 | if (mLocationDefaults.isEmpty()) { | 454 | if (mLocationDefaults.isEmpty()) { |
463 | mLocationDefaults << i18n("Home") << i18n("Office") << i18n("Library") << i18n("School") << i18n("Doctor") << i18n("Beach") | 455 | mLocationDefaults << i18n("Home") << i18n("Office") << i18n("Library") << i18n("School") << i18n("Doctor") << i18n("Beach") |
464 | << i18n("University") << i18n("Restaurant") << i18n("Bar") << i18n("Conference room") << i18n("Cinema") << i18n("Lake") << i18n("Kindergarten") | 456 | << i18n("University") << i18n("Restaurant") << i18n("Bar") << i18n("Conference room") << i18n("Cinema") << i18n("Lake") << i18n("Kindergarten") |
465 | << i18n("Germany") << i18n("Sweden") << i18n("Forest") << i18n("Desert") << i18n("Kitchen") ; | 457 | << i18n("Germany") << i18n("Sweden") << i18n("Forest") << i18n("Desert") << i18n("Kitchen") ; |
466 | // << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") | 458 | // << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") |
467 | mLocationDefaults.sort(); | 459 | mLocationDefaults.sort(); |
468 | } | 460 | } |
469 | 461 | ||
470 | if (mEventSummaryUser.isEmpty()) { | 462 | if (mEventSummaryUser.isEmpty()) { |
471 | mEventSummaryUser = getDefaultList() ; | 463 | mEventSummaryUser = getDefaultList() ; |
472 | } | 464 | } |
473 | if (mTodoSummaryUser.isEmpty()) { | 465 | if (mTodoSummaryUser.isEmpty()) { |
474 | mTodoSummaryUser = getDefaultList() ; | 466 | mTodoSummaryUser = getDefaultList() ; |
475 | } | 467 | } |
476 | 468 | ||
477 | if (mCustomCategories.isEmpty()) setCategoryDefaults(); | 469 | if (mCustomCategories.isEmpty()) setCategoryDefaults(); |
478 | 470 | ||
479 | config()->setGroup("Personal Settings"); | 471 | config()->setGroup("Personal Settings"); |
480 | mName = config()->readEntry("user_name",""); | 472 | mName = config()->readEntry("user_name",""); |
481 | mEmail = config()->readEntry("user_email",""); | 473 | mEmail = config()->readEntry("user_email",""); |
482 | fillMailDefaults(); | 474 | fillMailDefaults(); |
483 | 475 | ||
484 | config()->setGroup("Category Colors"); | 476 | config()->setGroup("Category Colors"); |
485 | QStringList::Iterator it; | 477 | QStringList::Iterator it; |
486 | for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { | 478 | for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { |
487 | setCategoryColor(*it,config()->readColorEntry(*it,&mDefaultCategoryColor)); | 479 | setCategoryColor(*it,config()->readColorEntry(*it,&mDefaultCategoryColor)); |
488 | 480 | ||
489 | } | 481 | } |
490 | 482 | ||
491 | if (mTimeZoneId.isEmpty()) { | ||
492 | setTimeZoneIdDefault(); | ||
493 | } | ||
494 | KPimPrefs::usrReadConfig(); | 483 | KPimPrefs::usrReadConfig(); |
495 | } | 484 | } |
496 | 485 | ||
497 | 486 | ||
498 | void KOPrefs::usrWriteConfig() | 487 | void KOPrefs::usrWriteConfig() |
499 | { | 488 | { |
500 | config()->setGroup("General"); | 489 | config()->setGroup("General"); |
501 | config()->writeEntry("Custom Categories",mCustomCategories); | 490 | config()->writeEntry("Custom Categories",mCustomCategories); |
502 | 491 | ||
503 | config()->setGroup("Personal Settings"); | 492 | config()->setGroup("Personal Settings"); |
504 | config()->writeEntry("user_name",mName); | 493 | config()->writeEntry("user_name",mName); |
505 | config()->writeEntry("user_email",mEmail); | 494 | config()->writeEntry("user_email",mEmail); |
506 | 495 | ||
507 | config()->setGroup("Category Colors"); | 496 | config()->setGroup("Category Colors"); |
508 | QDictIterator<QColor> it(mCategoryColors); | 497 | QDictIterator<QColor> it(mCategoryColors); |
509 | while (it.current()) { | 498 | while (it.current()) { |
510 | config()->writeEntry(it.currentKey(),*(it.current())); | 499 | config()->writeEntry(it.currentKey(),*(it.current())); |
511 | ++it; | 500 | ++it; |
512 | } | 501 | } |
513 | 502 | ||
514 | 503 | ||
515 | KPimPrefs::usrWriteConfig(); | 504 | KPimPrefs::usrWriteConfig(); |
516 | } | 505 | } |
517 | 506 | ||
518 | void KOPrefs::setCategoryColor(QString cat,const QColor & color) | 507 | void KOPrefs::setCategoryColor(QString cat,const QColor & color) |
519 | { | 508 | { |
520 | mCategoryColors.replace(cat,new QColor(color)); | 509 | mCategoryColors.replace(cat,new QColor(color)); |
521 | } | 510 | } |
522 | 511 | ||
523 | QColor *KOPrefs::categoryColor(QString cat) | 512 | QColor *KOPrefs::categoryColor(QString cat) |
524 | { | 513 | { |
525 | QColor *color = 0; | 514 | QColor *color = 0; |
526 | 515 | ||
527 | if (!cat.isEmpty()) color = mCategoryColors[cat]; | 516 | if (!cat.isEmpty()) color = mCategoryColors[cat]; |
528 | 517 | ||
529 | if (color) return color; | 518 | if (color) return color; |
530 | else return &mDefaultCategoryColor; | 519 | else return &mDefaultCategoryColor; |
531 | } | 520 | } |
532 | 521 | ||
533 | void KOPrefs::setFullName(const QString &name) | 522 | void KOPrefs::setFullName(const QString &name) |
534 | { | 523 | { |
535 | mName = name; | 524 | mName = name; |
536 | } | 525 | } |
537 | 526 | ||
538 | void KOPrefs::setEmail(const QString &email) | 527 | void KOPrefs::setEmail(const QString &email) |
539 | { | 528 | { |
540 | //qDebug(" KOPrefs::setEmai*********** %s",email.latin1() ); | 529 | //qDebug(" KOPrefs::setEmai*********** %s",email.latin1() ); |
541 | mEmail = email; | 530 | mEmail = email; |
542 | } | 531 | } |
543 | 532 | ||
544 | QString KOPrefs::fullName() | 533 | QString KOPrefs::fullName() |
545 | { | 534 | { |
546 | if (mEmailControlCenter) { | 535 | if (mEmailControlCenter) { |
547 | KEMailSettings settings; | 536 | KEMailSettings settings; |
548 | return settings.getSetting(KEMailSettings::RealName); | 537 | return settings.getSetting(KEMailSettings::RealName); |
549 | } else { | 538 | } else { |
550 | return mName; | 539 | return mName; |
551 | } | 540 | } |
552 | } | 541 | } |
553 | 542 | ||
554 | QString KOPrefs::email() | 543 | QString KOPrefs::email() |
555 | { | 544 | { |
556 | if (mEmailControlCenter) { | 545 | if (mEmailControlCenter) { |
557 | KEMailSettings settings; | 546 | KEMailSettings settings; |
558 | return settings.getSetting(KEMailSettings::EmailAddress); | 547 | return settings.getSetting(KEMailSettings::EmailAddress); |
559 | } else { | 548 | } else { |
560 | return mEmail; | 549 | return mEmail; |
561 | } | 550 | } |
562 | } | 551 | } |
563 | KConfig* KOPrefs::getConfig() | 552 | KConfig* KOPrefs::getConfig() |
564 | { | 553 | { |
565 | return config(); | 554 | return config(); |
566 | } | 555 | } |
diff --git a/korganizer/koprefs.h b/korganizer/koprefs.h index 03df59b..c74b0ef 100644 --- a/korganizer/koprefs.h +++ b/korganizer/koprefs.h | |||
@@ -1,292 +1,283 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | #ifndef KOPREFS_H | 23 | #ifndef KOPREFS_H |
24 | #define KOPREFS_H | 24 | #define KOPREFS_H |
25 | 25 | ||
26 | #include <qdict.h> | 26 | #include <qdict.h> |
27 | 27 | ||
28 | #include <libkdepim/kpimprefs.h> | 28 | #include <libkdepim/kpimprefs.h> |
29 | 29 | ||
30 | class KConfig; | 30 | class KConfig; |
31 | class QFont; | 31 | class QFont; |
32 | class QColor; | 32 | class QColor; |
33 | class QStringList; | 33 | class QStringList; |
34 | 34 | ||
35 | class KOPrefs : public KPimPrefs | 35 | class KOPrefs : public KPimPrefs |
36 | { | 36 | { |
37 | public: | 37 | public: |
38 | enum { FormatVCalendar, FormatICalendar }; | 38 | enum { FormatVCalendar, FormatICalendar }; |
39 | enum { MailClientKMail, MailClientSendmail }; | 39 | enum { MailClientKMail, MailClientSendmail }; |
40 | enum { IMIPDummy, IMIPKMail }; | 40 | enum { IMIPDummy, IMIPKMail }; |
41 | enum { IMIPOutbox, IMIPdirectsend }; | 41 | enum { IMIPOutbox, IMIPdirectsend }; |
42 | enum { neverAuto, addressbookAuto, selectedAuto }; | 42 | enum { neverAuto, addressbookAuto, selectedAuto }; |
43 | enum { standardDestination, askDestination }; | 43 | enum { standardDestination, askDestination }; |
44 | 44 | ||
45 | virtual ~KOPrefs(); | 45 | virtual ~KOPrefs(); |
46 | 46 | ||
47 | /** Get instance of KOPrefs. It is made sure that there is only one | 47 | /** Get instance of KOPrefs. It is made sure that there is only one |
48 | instance. */ | 48 | instance. */ |
49 | static KOPrefs *instance(); | 49 | static KOPrefs *instance(); |
50 | 50 | ||
51 | /** Set preferences to default values */ | 51 | /** Set preferences to default values */ |
52 | void usrSetDefaults(); | 52 | void usrSetDefaults(); |
53 | 53 | ||
54 | /** Read preferences from config file */ | 54 | /** Read preferences from config file */ |
55 | void usrReadConfig(); | 55 | void usrReadConfig(); |
56 | 56 | ||
57 | /** Write preferences to config file */ | 57 | /** Write preferences to config file */ |
58 | void usrWriteConfig(); | 58 | void usrWriteConfig(); |
59 | void setCategoryDefaults(); | 59 | void setCategoryDefaults(); |
60 | 60 | ||
61 | protected: | 61 | protected: |
62 | void setTimeZoneIdDefault(); | 62 | void setTimeZoneIdDefault(); |
63 | 63 | ||
64 | /** Fill empty mail fields with default values. */ | 64 | /** Fill empty mail fields with default values. */ |
65 | void fillMailDefaults(); | 65 | void fillMailDefaults(); |
66 | 66 | ||
67 | private: | 67 | private: |
68 | /** Constructor disabled for public. Use instance() to create a KOPrefs | 68 | /** Constructor disabled for public. Use instance() to create a KOPrefs |
69 | object. */ | 69 | object. */ |
70 | KOPrefs(); | 70 | KOPrefs(); |
71 | 71 | ||
72 | static KOPrefs *mInstance; | 72 | static KOPrefs *mInstance; |
73 | QDict<QString> *mLocaleDict; | 73 | QDict<QString> *mLocaleDict; |
74 | QStringList getDefaultList(); | 74 | QStringList getDefaultList(); |
75 | public: | 75 | public: |
76 | // preferences data | 76 | // preferences data |
77 | KConfig* getConfig(); | 77 | KConfig* getConfig(); |
78 | void setFullName(const QString &); | 78 | void setFullName(const QString &); |
79 | QString fullName(); | 79 | QString fullName(); |
80 | void setEmail(const QString &); | 80 | void setEmail(const QString &); |
81 | QString email(); | 81 | QString email(); |
82 | 82 | ||
83 | QString mAdditional; | 83 | QString mAdditional; |
84 | 84 | ||
85 | bool mEmailControlCenter; | 85 | bool mEmailControlCenter; |
86 | 86 | ||
87 | bool mBcc; | 87 | bool mBcc; |
88 | bool mAutoSave; | 88 | bool mAutoSave; |
89 | int mAutoSaveInterval; | 89 | int mAutoSaveInterval; |
90 | bool mConfirm; | 90 | bool mConfirm; |
91 | 91 | ||
92 | bool mEnableGroupScheduling; | 92 | bool mEnableGroupScheduling; |
93 | bool mEnableProjectView; | 93 | bool mEnableProjectView; |
94 | 94 | ||
95 | int mDefaultFormat; | 95 | int mDefaultFormat; |
96 | int mMailClient; | 96 | int mMailClient; |
97 | 97 | ||
98 | QString mTimeZone; | ||
99 | //QString mTimeZoneName; // e.g. +00:04:00 Indian/Mauritius | ||
100 | //int mTimeZoneOffset; // e.g. -240 min | ||
101 | int mStartTime; | 98 | int mStartTime; |
102 | int mDefaultDuration; | 99 | int mDefaultDuration; |
103 | int mAlarmTime; | 100 | int mAlarmTime; |
104 | int mDaylightSavings; | ||
105 | 101 | ||
106 | int mWorkingHoursStart; | 102 | int mWorkingHoursStart; |
107 | int mWorkingHoursEnd; | 103 | int mWorkingHoursEnd; |
108 | bool mExcludeHolidays; | 104 | bool mExcludeHolidays; |
109 | bool mExcludeSaturdays; | 105 | bool mExcludeSaturdays; |
110 | bool mMarcusBainsShowSeconds; | 106 | bool mMarcusBainsShowSeconds; |
111 | 107 | ||
112 | QFont mTimeBarFont; | 108 | QFont mTimeBarFont; |
113 | QFont mMonthViewFont; | 109 | QFont mMonthViewFont; |
114 | QFont mAgendaViewFont; | 110 | QFont mAgendaViewFont; |
115 | QFont mMarcusBainsFont; | 111 | QFont mMarcusBainsFont; |
116 | QFont mTimeLabelsFont; | 112 | QFont mTimeLabelsFont; |
117 | QFont mTodoViewFont; | 113 | QFont mTodoViewFont; |
118 | QFont mListViewFont; | 114 | QFont mListViewFont; |
119 | QFont mDateNavigatorFont; | 115 | QFont mDateNavigatorFont; |
120 | QFont mEditBoxFont; | 116 | QFont mEditBoxFont; |
121 | QFont mJornalViewFont; | 117 | QFont mJornalViewFont; |
122 | QFont mWhatsNextFont; | 118 | QFont mWhatsNextFont; |
123 | QFont mEventViewFont; | 119 | QFont mEventViewFont; |
124 | 120 | ||
125 | 121 | ||
126 | 122 | ||
127 | 123 | ||
128 | QColor mHolidayColor; | 124 | QColor mHolidayColor; |
129 | QColor mHighlightColor; | 125 | QColor mHighlightColor; |
130 | QColor mEventColor; | 126 | QColor mEventColor; |
131 | QColor mAgendaBgColor; | 127 | QColor mAgendaBgColor; |
132 | QColor mWorkingHoursColor; | 128 | QColor mWorkingHoursColor; |
133 | QColor mTodoDueTodayColor; | 129 | QColor mTodoDueTodayColor; |
134 | QColor mTodoOverdueColor; | 130 | QColor mTodoOverdueColor; |
135 | QColor mMonthViewEvenColor; | 131 | QColor mMonthViewEvenColor; |
136 | QColor mMonthViewOddColor; | 132 | QColor mMonthViewOddColor; |
137 | QColor mMonthViewHolidayColor; | 133 | QColor mMonthViewHolidayColor; |
138 | bool mMonthViewUsesDayColors; | 134 | bool mMonthViewUsesDayColors; |
139 | bool mMonthViewSatSunTog; | 135 | bool mMonthViewSatSunTog; |
140 | QColor mAppColor1; | 136 | QColor mAppColor1; |
141 | QColor mAppColor2; | 137 | QColor mAppColor2; |
142 | bool mUseAppColors; | 138 | bool mUseAppColors; |
143 | 139 | ||
144 | int mDayBegins; | 140 | int mDayBegins; |
145 | int mHourSize; | 141 | int mHourSize; |
146 | int mAllDaySize; | 142 | int mAllDaySize; |
147 | bool mShowFullMenu; | 143 | bool mShowFullMenu; |
148 | bool mDailyRecur; | 144 | bool mDailyRecur; |
149 | bool mWeeklyRecur; | 145 | bool mWeeklyRecur; |
150 | bool mMonthDailyRecur; | 146 | bool mMonthDailyRecur; |
151 | bool mMonthWeeklyRecur; | 147 | bool mMonthWeeklyRecur; |
152 | bool mMonthShowIcons; | 148 | bool mMonthShowIcons; |
153 | bool mMonthShowShort; | 149 | bool mMonthShowShort; |
154 | bool mEnableToolTips; | 150 | bool mEnableToolTips; |
155 | bool mEnableMonthScroll; | 151 | bool mEnableMonthScroll; |
156 | bool mFullViewMonth; | 152 | bool mFullViewMonth; |
157 | bool mMonthViewUsesCategoryColor; | 153 | bool mMonthViewUsesCategoryColor; |
158 | bool mFullViewTodo; | 154 | bool mFullViewTodo; |
159 | bool mShowCompletedTodo; | 155 | bool mShowCompletedTodo; |
160 | bool mMarcusBainsEnabled; | 156 | bool mMarcusBainsEnabled; |
161 | int mNextXDays; | 157 | int mNextXDays; |
162 | int mWhatsNextDays; | 158 | int mWhatsNextDays; |
163 | int mWhatsNextPrios; | 159 | int mWhatsNextPrios; |
164 | bool mEnableQuickTodo; | 160 | bool mEnableQuickTodo; |
165 | bool mLanguageChanged; | 161 | bool mLanguageChanged; |
166 | 162 | ||
167 | bool mCompactDialogs; | 163 | bool mCompactDialogs; |
168 | bool mVerticalScreen; | 164 | bool mVerticalScreen; |
169 | 165 | ||
170 | bool mShowIconNewTodo; | 166 | bool mShowIconNewTodo; |
171 | bool mShowIconNewEvent; | 167 | bool mShowIconNewEvent; |
172 | bool mShowIconSearch; | 168 | bool mShowIconSearch; |
173 | bool mShowIconList; | 169 | bool mShowIconList; |
174 | bool mShowIconDay1; | 170 | bool mShowIconDay1; |
175 | bool mShowIconDay5; | 171 | bool mShowIconDay5; |
176 | bool mShowIconDay7; | 172 | bool mShowIconDay7; |
177 | bool mShowIconMonth; | 173 | bool mShowIconMonth; |
178 | bool mShowIconTodoview; | 174 | bool mShowIconTodoview; |
179 | bool mShowIconBackFast; | 175 | bool mShowIconBackFast; |
180 | bool mShowIconBack; | 176 | bool mShowIconBack; |
181 | bool mShowIconToday; | 177 | bool mShowIconToday; |
182 | bool mShowIconForward; | 178 | bool mShowIconForward; |
183 | bool mShowIconForwardFast; | 179 | bool mShowIconForwardFast; |
184 | bool mShowIconWhatsThis; | 180 | bool mShowIconWhatsThis; |
185 | bool mShowIconNextDays; | 181 | bool mShowIconNextDays; |
186 | bool mShowIconNext; | 182 | bool mShowIconNext; |
187 | bool mShowIconJournal; | 183 | bool mShowIconJournal; |
188 | 184 | ||
189 | bool mShowIconStretch; | 185 | bool mShowIconStretch; |
190 | 186 | ||
191 | bool mToolBarHor; | 187 | bool mToolBarHor; |
192 | bool mToolBarUp; | 188 | bool mToolBarUp; |
193 | bool mToolBarMiniIcons; | 189 | bool mToolBarMiniIcons; |
194 | 190 | ||
195 | bool mAskForQuit; | 191 | bool mAskForQuit; |
196 | bool mUsePassWd; | 192 | bool mUsePassWd; |
197 | bool mShowSyncEvents; | 193 | bool mShowSyncEvents; |
198 | bool mShowTodoInAgenda; | 194 | bool mShowTodoInAgenda; |
199 | 195 | ||
200 | int mLastSyncTime; | 196 | int mLastSyncTime; |
201 | void setCategoryColor(QString cat,const QColor & color); | 197 | void setCategoryColor(QString cat,const QColor & color); |
202 | QColor *categoryColor(QString cat); | 198 | QColor *categoryColor(QString cat); |
203 | 199 | ||
204 | QString mArchiveFile; | 200 | QString mArchiveFile; |
205 | QString mHtmlExportFile; | 201 | QString mHtmlExportFile; |
206 | bool mHtmlWithSave; | 202 | bool mHtmlWithSave; |
207 | 203 | ||
208 | QStringList mSelectedPlugins; | 204 | QStringList mSelectedPlugins; |
209 | 205 | ||
210 | QString mLastImportFile; | 206 | QString mLastImportFile; |
211 | QString mLastVcalFile; | 207 | QString mLastVcalFile; |
212 | QString mLastSaveFile; | 208 | QString mLastSaveFile; |
213 | QString mLastLoadFile; | 209 | QString mLastLoadFile; |
214 | 210 | ||
215 | 211 | ||
216 | QString mDefaultAlarmFile; | 212 | QString mDefaultAlarmFile; |
217 | int mIMIPScheduler; | 213 | int mIMIPScheduler; |
218 | int mIMIPSend; | 214 | int mIMIPSend; |
219 | QStringList mAdditionalMails; | 215 | QStringList mAdditionalMails; |
220 | int mIMIPAutoRefresh; | 216 | int mIMIPAutoRefresh; |
221 | int mIMIPAutoInsertReply; | 217 | int mIMIPAutoInsertReply; |
222 | int mIMIPAutoInsertRequest; | 218 | int mIMIPAutoInsertRequest; |
223 | int mIMIPAutoFreeBusy; | 219 | int mIMIPAutoFreeBusy; |
224 | int mIMIPAutoFreeBusyReply; | 220 | int mIMIPAutoFreeBusyReply; |
225 | 221 | ||
226 | QStringList mTodoTemplates; | 222 | QStringList mTodoTemplates; |
227 | QStringList mEventTemplates; | 223 | QStringList mEventTemplates; |
228 | 224 | ||
229 | int mDestination; | 225 | int mDestination; |
230 | 226 | ||
231 | 227 | ||
232 | bool mEditOnDoubleClick; | 228 | bool mEditOnDoubleClick; |
233 | bool mViewChangeHoldFullscreen; | 229 | bool mViewChangeHoldFullscreen; |
234 | bool mViewChangeHoldNonFullscreen; | 230 | bool mViewChangeHoldNonFullscreen; |
235 | bool mCenterOnCurrentTime; | 231 | bool mCenterOnCurrentTime; |
236 | bool mSetTimeToDayStartAt; | 232 | bool mSetTimeToDayStartAt; |
237 | bool mHighlightCurrentDay; | 233 | bool mHighlightCurrentDay; |
238 | bool mUseHighlightLightColor; | 234 | bool mUseHighlightLightColor; |
239 | bool mListViewMonthTimespan; | 235 | bool mListViewMonthTimespan; |
240 | bool mWNViewShowsParents; | 236 | bool mWNViewShowsParents; |
241 | bool mWNViewShowLocation; | 237 | bool mWNViewShowLocation; |
242 | bool mTodoViewShowsPercentage; | 238 | bool mTodoViewShowsPercentage; |
243 | bool mTodoViewUsesCatColors; | 239 | bool mTodoViewUsesCatColors; |
244 | bool mTodoViewUsesSmallFont; | 240 | bool mTodoViewUsesSmallFont; |
245 | bool mTodoViewUsesForegroundColor; | 241 | bool mTodoViewUsesForegroundColor; |
246 | bool mMonthViewUsesForegroundColor; | 242 | bool mMonthViewUsesForegroundColor; |
247 | 243 | ||
248 | bool mHightlightDateTimeEdit; | 244 | bool mHightlightDateTimeEdit; |
249 | bool mShortDateInViewer; | 245 | bool mShortDateInViewer; |
250 | 246 | ||
251 | QStringList mLocationDefaults; | 247 | QStringList mLocationDefaults; |
252 | QStringList mEventSummaryUser; | 248 | QStringList mEventSummaryUser; |
253 | QStringList mTodoSummaryUser; | 249 | QStringList mTodoSummaryUser; |
254 | 250 | ||
255 | bool mUseInternalAlarmNotification; | 251 | bool mUseInternalAlarmNotification; |
256 | int mAlarmPlayBeeps; | 252 | int mAlarmPlayBeeps; |
257 | int mAlarmSuspendTime; | 253 | int mAlarmSuspendTime; |
258 | int mAlarmSuspendCount; | 254 | int mAlarmSuspendCount; |
259 | int mAlarmBeepInterval; | 255 | int mAlarmBeepInterval; |
260 | 256 | ||
261 | 257 | ||
262 | QString mActiveSyncPort; | 258 | QString mActiveSyncPort; |
263 | QString mActiveSyncIP; | 259 | QString mActiveSyncIP; |
264 | 260 | ||
265 | 261 | ||
266 | //US I copied the following settings into KPimGlobalPrefs | 262 | //US I copied the following settings into KPimGlobalPrefs |
267 | // that allows us later to easily remove the settings from here. | 263 | // that allows us later to easily remove the settings from here. |
268 | int mPreferredDate; | 264 | int mPreferredDate; |
269 | QString mUserDateFormatLong; | 265 | QString mUserDateFormatLong; |
270 | QString mUserDateFormatShort; | 266 | QString mUserDateFormatShort; |
271 | int mPreferredLanguage; | 267 | int mPreferredLanguage; |
272 | int mPreferredTime; | 268 | int mPreferredTime; |
273 | bool mWeekStartsOnSunday; | 269 | bool mWeekStartsOnSunday; |
274 | QString mTimeZoneId; | ||
275 | bool mUseDaylightsaving; | ||
276 | int mDaylightsavingStart; | ||
277 | int mDaylightsavingEnd; | ||
278 | |||
279 | 270 | ||
280 | private: | 271 | private: |
281 | QDict<QColor> mCategoryColors; | 272 | QDict<QColor> mCategoryColors; |
282 | QColor mDefaultCategoryColor; | 273 | QColor mDefaultCategoryColor; |
283 | 274 | ||
284 | QFont mDefaultTimeBarFont; | 275 | QFont mDefaultTimeBarFont; |
285 | QFont mDefaultViewFont; | 276 | QFont mDefaultViewFont; |
286 | QFont mDefaultMonthViewFont; | 277 | QFont mDefaultMonthViewFont; |
287 | 278 | ||
288 | QString mName; | 279 | QString mName; |
289 | QString mEmail; | 280 | QString mEmail; |
290 | }; | 281 | }; |
291 | 282 | ||
292 | #endif | 283 | #endif |
diff --git a/libkdepim/kpimglobalprefs.cpp b/libkdepim/kpimglobalprefs.cpp index 7cd6038..0a580ca 100644 --- a/libkdepim/kpimglobalprefs.cpp +++ b/libkdepim/kpimglobalprefs.cpp | |||
@@ -1,139 +1,139 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkdepim. | 2 | This file is part of libkdepim. |
3 | Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | /* | 24 | /* |
25 | Enhanced Version of the file for platform independent KDE tools. | 25 | Enhanced Version of the file for platform independent KDE tools. |
26 | Copyright (c) 2004 Ulf Schenk | 26 | Copyright (c) 2004 Ulf Schenk |
27 | 27 | ||
28 | $Id$ | 28 | $Id$ |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include <kglobal.h> | 31 | #include <kglobal.h> |
32 | #include <kconfig.h> | 32 | #include <kconfig.h> |
33 | #include <klocale.h> | 33 | #include <klocale.h> |
34 | #include <kdebug.h> | 34 | #include <kdebug.h> |
35 | #include <kstaticdeleter.h> | 35 | #include <kstaticdeleter.h> |
36 | 36 | ||
37 | #include <qregexp.h> | 37 | #include <qregexp.h> |
38 | #include "kpimglobalprefs.h" | 38 | #include "kpimglobalprefs.h" |
39 | 39 | ||
40 | KPimGlobalPrefs *KPimGlobalPrefs::sInstance = 0; | 40 | KPimGlobalPrefs *KPimGlobalPrefs::sInstance = 0; |
41 | static KStaticDeleter<KPimGlobalPrefs> staticDeleter; | 41 | static KStaticDeleter<KPimGlobalPrefs> staticDeleter; |
42 | 42 | ||
43 | 43 | ||
44 | KPimGlobalPrefs::KPimGlobalPrefs( const QString &name ) | 44 | KPimGlobalPrefs::KPimGlobalPrefs( const QString &name ) |
45 | : KPrefs("microkdeglobalrc") | 45 | : KPrefs("microkdeglobalrc") |
46 | { | 46 | { |
47 | 47 | ||
48 | KPrefs::setCurrentGroup("Locale"); | 48 | KPrefs::setCurrentGroup("Locale"); |
49 | addItemInt("PreferredLanguage",&mPreferredLanguage,0); | 49 | addItemInt("PreferredLanguage",&mPreferredLanguage,0); |
50 | addItemInt("PreferredTime",&mPreferredTime,0); | 50 | addItemInt("PreferredTime",&mPreferredTime,0); |
51 | addItemInt("PreferredDate",&mPreferredDate,0); | 51 | addItemInt("PreferredDate",&mPreferredDate,0); |
52 | addItemBool("WeekStartsOnSunday",&mWeekStartsOnSunday,false); | 52 | addItemBool("WeekStartsOnSunday",&mWeekStartsOnSunday,false); |
53 | //addItemBool("QuickSavingWOUnicode",&mUseQuicksave,false); | 53 | //addItemBool("QuickSavingWOUnicode",&mUseQuicksave,false); |
54 | // addItemBool("ShortDateInViewer",&mShortDateInViewer,false); | 54 | // addItemBool("ShortDateInViewer",&mShortDateInViewer,false); |
55 | addItemString("UserDateFormatLong", &mUserDateFormatLong, "%A %d %b %y"); | 55 | addItemString("UserDateFormatLong", &mUserDateFormatLong, "%A %d %b %y"); |
56 | addItemString("UserDateFormatShort", &mUserDateFormatShort, "%aK %d.%m.%y"); | 56 | addItemString("UserDateFormatShort", &mUserDateFormatShort, "%aK %d.%m.%y"); |
57 | 57 | ||
58 | KPrefs::setCurrentGroup("Time & Date"); | 58 | KPrefs::setCurrentGroup("Time & Date"); |
59 | 59 | ||
60 | addItemString("TimeZoneName",&mTimeZoneId,i18n ("+01:00 Europe/Oslo(CET)") ); | 60 | addItemString("TimeZoneName",&mTimeZoneId, ("+01:00 Europe/Oslo(CET)") ); |
61 | addItemBool("UseDaylightsaving",&mUseDaylightsaving,true); | 61 | addItemBool("UseDaylightsaving",&mUseDaylightsaving,true); |
62 | addItemBool("TimeZoneAdd30min",&mTimeZoneAdd30min,false); | 62 | addItemBool("TimeZoneAdd30min",&mTimeZoneAdd30min,false); |
63 | addItemInt("DaylightsavingStart",&mDaylightsavingStart,90); | 63 | addItemInt("DaylightsavingStart",&mDaylightsavingStart,90); |
64 | addItemInt("DaylightsavingEnd",&mDaylightsavingEnd,304); | 64 | addItemInt("DaylightsavingEnd",&mDaylightsavingEnd,304); |
65 | 65 | ||
66 | KPrefs::setCurrentGroup( "ExternalApplications" ); | 66 | KPrefs::setCurrentGroup( "ExternalApplications" ); |
67 | 67 | ||
68 | addItemInt( "EmailChannelType", &mEmailClient, OMPI_EMC ); | 68 | addItemInt( "EmailChannelType", &mEmailClient, OMPI_EMC ); |
69 | addItemString( "EmailChannel", &mEmailOtherChannel, "" ); | 69 | addItemString( "EmailChannel", &mEmailOtherChannel, "" ); |
70 | addItemString( "EmailChannelMessage", &mEmailOtherMessage, "" ); | 70 | addItemString( "EmailChannelMessage", &mEmailOtherMessage, "" ); |
71 | addItemString( "EmailChannelParameters", &mEmailOtherMessageParameters, "" ); | 71 | addItemString( "EmailChannelParameters", &mEmailOtherMessageParameters, "" ); |
72 | addItemString( "EmailChannelMessage2", &mEmailOtherMessage2, "" ); | 72 | addItemString( "EmailChannelMessage2", &mEmailOtherMessage2, "" ); |
73 | addItemString( "EmailChannelParameters2", &mEmailOtherMessageParameters2, "" ); | 73 | addItemString( "EmailChannelParameters2", &mEmailOtherMessageParameters2, "" ); |
74 | 74 | ||
75 | addItemInt( "PhoneChannelType", &mPhoneClient, KPPI_PHC ); | 75 | addItemInt( "PhoneChannelType", &mPhoneClient, KPPI_PHC ); |
76 | addItemString( "PhoneChannel", &mPhoneOtherChannel, "" ); | 76 | addItemString( "PhoneChannel", &mPhoneOtherChannel, "" ); |
77 | addItemString( "PhoneChannelMessage", &mPhoneOtherMessage, "" ); | 77 | addItemString( "PhoneChannelMessage", &mPhoneOtherMessage, "" ); |
78 | addItemString( "PhoneChannelParameters", &mPhoneOtherMessageParameters, "" ); | 78 | addItemString( "PhoneChannelParameters", &mPhoneOtherMessageParameters, "" ); |
79 | 79 | ||
80 | addItemInt( "FaxChannelType", &mFaxClient, NONE_FAC ); | 80 | addItemInt( "FaxChannelType", &mFaxClient, NONE_FAC ); |
81 | addItemString( "FaxChannel", &mFaxOtherChannel, "" ); | 81 | addItemString( "FaxChannel", &mFaxOtherChannel, "" ); |
82 | addItemString( "FaxChannelMessage", &mFaxOtherMessage, "" ); | 82 | addItemString( "FaxChannelMessage", &mFaxOtherMessage, "" ); |
83 | addItemString( "FaxChannelParameters", &mFaxOtherMessageParameters, "" ); | 83 | addItemString( "FaxChannelParameters", &mFaxOtherMessageParameters, "" ); |
84 | 84 | ||
85 | addItemInt( "SMSChannelType", &mSMSClient, NONE_SMC ); | 85 | addItemInt( "SMSChannelType", &mSMSClient, NONE_SMC ); |
86 | addItemString( "SMSChannel", &mSMSOtherChannel, "" ); | 86 | addItemString( "SMSChannel", &mSMSOtherChannel, "" ); |
87 | addItemString( "SMSChannelMessage", &mSMSOtherMessage, "" ); | 87 | addItemString( "SMSChannelMessage", &mSMSOtherMessage, "" ); |
88 | addItemString( "SMSChannelParameters", &mSMSOtherMessageParameters, "" ); | 88 | addItemString( "SMSChannelParameters", &mSMSOtherMessageParameters, "" ); |
89 | 89 | ||
90 | addItemInt( "PagerChannelType", &mPagerClient, NONE_PAC ); | 90 | addItemInt( "PagerChannelType", &mPagerClient, NONE_PAC ); |
91 | addItemString( "PagerChannel", &mPagerOtherChannel, "" ); | 91 | addItemString( "PagerChannel", &mPagerOtherChannel, "" ); |
92 | addItemString( "PagerChannelMessage", &mPagerOtherMessage, "" ); | 92 | addItemString( "PagerChannelMessage", &mPagerOtherMessage, "" ); |
93 | addItemString( "PagerChannelParameters", &mPagerOtherMessageParameters, "" ); | 93 | addItemString( "PagerChannelParameters", &mPagerOtherMessageParameters, "" ); |
94 | 94 | ||
95 | addItemInt( "SIPChannelType", &mSipClient, KPPI_SIC ); | 95 | addItemInt( "SIPChannelType", &mSipClient, KPPI_SIC ); |
96 | addItemString( "SIPChannel", &mSipOtherChannel, "" ); | 96 | addItemString( "SIPChannel", &mSipOtherChannel, "" ); |
97 | addItemString( "SIPChannelMessage", &mSipOtherMessage, "" ); | 97 | addItemString( "SIPChannelMessage", &mSipOtherMessage, "" ); |
98 | addItemString( "SIPChannelParameters", &mSipOtherMessageParameters, "" ); | 98 | addItemString( "SIPChannelParameters", &mSipOtherMessageParameters, "" ); |
99 | 99 | ||
100 | KPrefs::setCurrentGroup( "PhoneAccess" ); | 100 | KPrefs::setCurrentGroup( "PhoneAccess" ); |
101 | addItemString("Ex2PhoneDevice",&mEx2PhoneDevice,"/dev/ircomm"); | 101 | addItemString("Ex2PhoneDevice",&mEx2PhoneDevice,"/dev/ircomm"); |
102 | addItemString("Ex2PhoneConnection",&mEx2PhoneConnection,"irda"); | 102 | addItemString("Ex2PhoneConnection",&mEx2PhoneConnection,"irda"); |
103 | addItemString("Ex2PhoneModel",&mEx2PhoneModel,"6310i"); | 103 | addItemString("Ex2PhoneModel",&mEx2PhoneModel,"6310i"); |
104 | 104 | ||
105 | } | 105 | } |
106 | 106 | ||
107 | 107 | ||
108 | void KPimGlobalPrefs::setGlobalConfig() | 108 | void KPimGlobalPrefs::setGlobalConfig() |
109 | { | 109 | { |
110 | 110 | ||
111 | KGlobal::locale()->setHore24Format( !mPreferredTime ); | 111 | KGlobal::locale()->setHore24Format( !mPreferredTime ); |
112 | KGlobal::locale()->setWeekStartMonday( !mWeekStartsOnSunday ); | 112 | KGlobal::locale()->setWeekStartMonday( !mWeekStartsOnSunday ); |
113 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)mPreferredDate ); | 113 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)mPreferredDate ); |
114 | KGlobal::locale()->setLanguage( mPreferredLanguage ); | 114 | KGlobal::locale()->setLanguage( mPreferredLanguage ); |
115 | QString dummy = mUserDateFormatLong; | 115 | QString dummy = mUserDateFormatLong; |
116 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); | 116 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); |
117 | dummy = mUserDateFormatShort; | 117 | dummy = mUserDateFormatShort; |
118 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); | 118 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); |
119 | KGlobal::locale()->setDaylightSaving( mUseDaylightsaving, | 119 | KGlobal::locale()->setDaylightSaving( mUseDaylightsaving, |
120 | mDaylightsavingStart, | 120 | mDaylightsavingStart, |
121 | mDaylightsavingEnd ); | 121 | mDaylightsavingEnd ); |
122 | KGlobal::locale()->setTimezone( mTimeZoneId, mTimeZoneAdd30min ); | 122 | KGlobal::locale()->setTimezone( mTimeZoneId, mTimeZoneAdd30min ); |
123 | 123 | ||
124 | } | 124 | } |
125 | KPimGlobalPrefs::~KPimGlobalPrefs() | 125 | KPimGlobalPrefs::~KPimGlobalPrefs() |
126 | { | 126 | { |
127 | //qDebug("KPimGlobalPrefs::~KPimGlobalPrefs() "); | 127 | //qDebug("KPimGlobalPrefs::~KPimGlobalPrefs() "); |
128 | writeConfig(); | 128 | writeConfig(); |
129 | } | 129 | } |
130 | 130 | ||
131 | KPimGlobalPrefs *KPimGlobalPrefs::instance() | 131 | KPimGlobalPrefs *KPimGlobalPrefs::instance() |
132 | { | 132 | { |
133 | if ( !sInstance ) { | 133 | if ( !sInstance ) { |
134 | sInstance = staticDeleter.setObject( new KPimGlobalPrefs() ); | 134 | sInstance = staticDeleter.setObject( new KPimGlobalPrefs() ); |
135 | sInstance->readConfig(); | 135 | sInstance->readConfig(); |
136 | } | 136 | } |
137 | 137 | ||
138 | return sInstance; | 138 | return sInstance; |
139 | } | 139 | } |
diff --git a/microkde/kdecore/klocale.cpp b/microkde/kdecore/klocale.cpp index 21e6937..d3b04dc 100644 --- a/microkde/kdecore/klocale.cpp +++ b/microkde/kdecore/klocale.cpp | |||
@@ -1,926 +1,926 @@ | |||
1 | #include <qregexp.h> | 1 | #include <qregexp.h> |
2 | #include <qapplication.h> | 2 | #include <qapplication.h> |
3 | 3 | ||
4 | #include "kdebug.h" | 4 | #include "kdebug.h" |
5 | #include "kcalendarsystemgregorian.h" | 5 | #include "kcalendarsystemgregorian.h" |
6 | 6 | ||
7 | #include "klocale.h" | 7 | #include "klocale.h" |
8 | 8 | ||
9 | #include <qstringlist.h> | 9 | #include <qstringlist.h> |
10 | QStringList missingTrans; | 10 | QStringList missingTrans; |
11 | 11 | ||
12 | QDict<QString> *mLocaleDict = 0; | 12 | QDict<QString> *mLocaleDict = 0; |
13 | void setLocaleDict( QDict<QString> * dict ) | 13 | void setLocaleDict( QDict<QString> * dict ) |
14 | { | 14 | { |
15 | mLocaleDict = dict; | 15 | mLocaleDict = dict; |
16 | 16 | ||
17 | } | 17 | } |
18 | void addMissing(const char *text) | 18 | void addMissing(const char *text) |
19 | { | 19 | { |
20 | return; | 20 | return; |
21 | QString mis ( text ); | 21 | QString mis ( text ); |
22 | if ( !missingTrans.contains( mis ) ) | 22 | if ( !missingTrans.contains( mis ) ) |
23 | missingTrans.append(mis); | 23 | missingTrans.append(mis); |
24 | 24 | ||
25 | } | 25 | } |
26 | 26 | ||
27 | #include <qfile.h> | 27 | #include <qfile.h> |
28 | #include <qtextstream.h> | 28 | #include <qtextstream.h> |
29 | #include <qtextcodec.h> | 29 | #include <qtextcodec.h> |
30 | void dumpMissing() | 30 | void dumpMissing() |
31 | { | 31 | { |
32 | return; | 32 | return; |
33 | QString fileName = "/tmp/usertrans.txt"; | 33 | QString fileName = "/tmp/usertrans.txt"; |
34 | QFile file( fileName ); | 34 | QFile file( fileName ); |
35 | if (!file.open( IO_WriteOnly ) ) { | 35 | if (!file.open( IO_WriteOnly ) ) { |
36 | return ; | 36 | return ; |
37 | } | 37 | } |
38 | QTextStream ts( &file ); | 38 | QTextStream ts( &file ); |
39 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 39 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
40 | 40 | ||
41 | int i; | 41 | int i; |
42 | for ( i = 0; i< missingTrans.count(); ++i ) { | 42 | for ( i = 0; i< missingTrans.count(); ++i ) { |
43 | 43 | ||
44 | QString text = missingTrans[i].replace( QRegExp("\n"),"\\n" ); | 44 | QString text = missingTrans[i].replace( QRegExp("\n"),"\\n" ); |
45 | ts << "{ \""<<text<< "\",\""<< text <<"\" },\n"; | 45 | ts << "{ \""<<text<< "\",\""<< text <<"\" },\n"; |
46 | 46 | ||
47 | } | 47 | } |
48 | file.close(); | 48 | file.close(); |
49 | } | 49 | } |
50 | 50 | ||
51 | QString i18n(const char *text) | 51 | QString i18n(const char *text) |
52 | { | 52 | { |
53 | if ( ! mLocaleDict ) { | 53 | if ( ! mLocaleDict ) { |
54 | addMissing( text ); | 54 | addMissing( text ); |
55 | return QString( text ); | 55 | return QString( text ); |
56 | } | 56 | } |
57 | else { | 57 | else { |
58 | QString* ret = mLocaleDict->find(QString(text)) ; | 58 | QString* ret = mLocaleDict->find(QString(text)) ; |
59 | if ( ret == 0 ) { | 59 | if ( ret == 0 ) { |
60 | addMissing( text ); | 60 | addMissing( text ); |
61 | return QString( text ); | 61 | return QString( text ); |
62 | } | 62 | } |
63 | else { | 63 | else { |
64 | if ( (*ret).isEmpty() ) { | 64 | if ( (*ret).isEmpty() ) { |
65 | addMissing( text ); | 65 | addMissing( text ); |
66 | return QString( text ); | 66 | return QString( text ); |
67 | } | 67 | } |
68 | else | 68 | else |
69 | return (*ret); | 69 | return (*ret); |
70 | } | 70 | } |
71 | } | 71 | } |
72 | 72 | ||
73 | } | 73 | } |
74 | 74 | ||
75 | QString i18n(const char *,const char *text) | 75 | QString i18n(const char *,const char *text) |
76 | { | 76 | { |
77 | return i18n( text ); | 77 | return i18n( text ); |
78 | } | 78 | } |
79 | 79 | ||
80 | QString i18n(const char *text1, const char *textn, int num) | 80 | QString i18n(const char *text1, const char *textn, int num) |
81 | { | 81 | { |
82 | if ( num == 1 ) return i18n( text1 ); | 82 | if ( num == 1 ) return i18n( text1 ); |
83 | else { | 83 | else { |
84 | QString text = i18n( textn ); | 84 | QString text = i18n( textn ); |
85 | int pos = text.find( "%n" ); | 85 | int pos = text.find( "%n" ); |
86 | if ( pos >= 0 ) text.replace( pos, 2, QString::number( num ) ); | 86 | if ( pos >= 0 ) text.replace( pos, 2, QString::number( num ) ); |
87 | return text; | 87 | return text; |
88 | } | 88 | } |
89 | } | 89 | } |
90 | 90 | ||
91 | inline void put_it_in( QChar *buffer, uint& index, const QString &s ) | 91 | inline void put_it_in( QChar *buffer, uint& index, const QString &s ) |
92 | { | 92 | { |
93 | for ( uint l = 0; l < s.length(); l++ ) | 93 | for ( uint l = 0; l < s.length(); l++ ) |
94 | buffer[index++] = s.at( l ); | 94 | buffer[index++] = s.at( l ); |
95 | } | 95 | } |
96 | 96 | ||
97 | inline void put_it_in( QChar *buffer, uint& index, int number ) | 97 | inline void put_it_in( QChar *buffer, uint& index, int number ) |
98 | { | 98 | { |
99 | buffer[index++] = number / 10 + '0'; | 99 | buffer[index++] = number / 10 + '0'; |
100 | buffer[index++] = number % 10 + '0'; | 100 | buffer[index++] = number % 10 + '0'; |
101 | } | 101 | } |
102 | 102 | ||
103 | static int readInt(const QString &str, uint &pos) | 103 | static int readInt(const QString &str, uint &pos) |
104 | { | 104 | { |
105 | if (!str.at(pos).isDigit()) return -1; | 105 | if (!str.at(pos).isDigit()) return -1; |
106 | int result = 0; | 106 | int result = 0; |
107 | for (; str.length() > pos && str.at(pos).isDigit(); pos++) | 107 | for (; str.length() > pos && str.at(pos).isDigit(); pos++) |
108 | { | 108 | { |
109 | result *= 10; | 109 | result *= 10; |
110 | result += str.at(pos).digitValue(); | 110 | result += str.at(pos).digitValue(); |
111 | } | 111 | } |
112 | 112 | ||
113 | return result; | 113 | return result; |
114 | } | 114 | } |
115 | 115 | ||
116 | KLocale::KLocale() : mCalendarSystem( 0 ) | 116 | KLocale::KLocale() : mCalendarSystem( 0 ) |
117 | { | 117 | { |
118 | 118 | ||
119 | m_decimalSymbol = "."; | 119 | m_decimalSymbol = "."; |
120 | m_positiveSign = ""; | 120 | m_positiveSign = ""; |
121 | m_negativeSign = "-"; | 121 | m_negativeSign = "-"; |
122 | m_thousandsSeparator = ","; | 122 | m_thousandsSeparator = ","; |
123 | 123 | ||
124 | 124 | ||
125 | 125 | ||
126 | 126 | ||
127 | mWeekStartsMonday = true; | 127 | mWeekStartsMonday = true; |
128 | mHourF24Format = true; | 128 | mHourF24Format = true; |
129 | mIntDateFormat = Default; | 129 | mIntDateFormat = Default; |
130 | mIntTimeFormat = Default; | 130 | mIntTimeFormat = Default; |
131 | mLanguage = 0; | 131 | mLanguage = 0; |
132 | mDateFormat = "%a %Y %b %d"; | 132 | mDateFormat = "%a %Y %b %d"; |
133 | mDateFormatShort = "%Y-%m-%d"; | 133 | mDateFormatShort = "%Y-%m-%d"; |
134 | mTimeZoneList << i18n ("-11:00 US/Samoa") | 134 | mTimeZoneList << ("-11:00 US/Samoa") |
135 | << i18n ("-10:00 US/Hawaii") | 135 | << ("-10:00 US/Hawaii") |
136 | << i18n ("-09:00 US/Alaska") | 136 | << ("-09:00 US/Alaska") |
137 | << i18n ("-08:00 US/Pacific") | 137 | << ("-08:00 US/Pacific") |
138 | << i18n ("-07:00 US/Mountain") | 138 | << ("-07:00 US/Mountain") |
139 | << i18n ("-06:00 US/Central") | 139 | << ("-06:00 US/Central") |
140 | << i18n ("-05:00 US/Eastern") | 140 | << ("-05:00 US/Eastern") |
141 | << i18n ("-04:00 Brazil/West") | 141 | << ("-04:00 Brazil/West") |
142 | << i18n ("-03:00 Brazil/East") | 142 | << ("-03:00 Brazil/East") |
143 | << i18n ("-02:00 Brazil/DeNoronha") | 143 | << ("-02:00 Brazil/DeNoronha") |
144 | << i18n ("-01:00 Atlantic/Azores") | 144 | << ("-01:00 Atlantic/Azores") |
145 | << i18n (" 00:00 Europe/London(UTC)") | 145 | << (" 00:00 Europe/London(UTC)") |
146 | << i18n ("+01:00 Europe/Oslo(CET)") | 146 | << ("+01:00 Europe/Oslo(CET)") |
147 | << i18n ("+02:00 Europe/Helsinki") | 147 | << ("+02:00 Europe/Helsinki") |
148 | << i18n ("+03:00 Europe/Moscow") | 148 | << ("+03:00 Europe/Moscow") |
149 | << i18n ("+04:00 Indian/Mauritius") | 149 | << ("+04:00 Indian/Mauritius") |
150 | << i18n ("+05:00 Indian/Maldives") | 150 | << ("+05:00 Indian/Maldives") |
151 | << i18n ("+06:00 Indian/Chagos") | 151 | << ("+06:00 Indian/Chagos") |
152 | << i18n ("+07:00 Asia/Bangkok") | 152 | << ("+07:00 Asia/Bangkok") |
153 | << i18n ("+08:00 Asia/Hongkong") | 153 | << ("+08:00 Asia/Hongkong") |
154 | << i18n ("+09:00 Asia/Tokyo") | 154 | << ("+09:00 Asia/Tokyo") |
155 | << i18n ("+10:00 Asia/Vladivostok") | 155 | << ("+10:00 Asia/Vladivostok") |
156 | << i18n ("+11:00 Asia/Magadan") | 156 | << ("+11:00 Asia/Magadan") |
157 | << i18n ("+12:00 Asia/Kamchatka") | 157 | << ("+12:00 Asia/Kamchatka") |
158 | // << i18n (" xx:xx User defined offset") | 158 | // << (" xx:xx User defined offset") |
159 | << i18n (" Local Time"); | 159 | << i18n (" Local Time"); |
160 | mSouthDaylight = false; | 160 | mSouthDaylight = false; |
161 | mTimeZoneOffset = 0; | 161 | mTimeZoneOffset = 0; |
162 | daylightEnabled = false; | 162 | daylightEnabled = false; |
163 | } | 163 | } |
164 | 164 | ||
165 | void KLocale::setDateFormat( QString s ) | 165 | void KLocale::setDateFormat( QString s ) |
166 | { | 166 | { |
167 | mDateFormat = s; | 167 | mDateFormat = s; |
168 | } | 168 | } |
169 | 169 | ||
170 | void KLocale::setDateFormatShort( QString s ) | 170 | void KLocale::setDateFormatShort( QString s ) |
171 | { | 171 | { |
172 | mDateFormatShort = s; | 172 | mDateFormatShort = s; |
173 | } | 173 | } |
174 | 174 | ||
175 | void KLocale::setHore24Format ( bool b ) | 175 | void KLocale::setHore24Format ( bool b ) |
176 | { | 176 | { |
177 | mHourF24Format = b; | 177 | mHourF24Format = b; |
178 | } | 178 | } |
179 | void KLocale::setWeekStartMonday( bool b ) | 179 | void KLocale::setWeekStartMonday( bool b ) |
180 | { | 180 | { |
181 | mWeekStartsMonday = b; | 181 | mWeekStartsMonday = b; |
182 | } | 182 | } |
183 | 183 | ||
184 | KLocale::IntDateFormat KLocale::getIntDateFormat( ) | 184 | KLocale::IntDateFormat KLocale::getIntDateFormat( ) |
185 | { | 185 | { |
186 | return mIntDateFormat; | 186 | return mIntDateFormat; |
187 | 187 | ||
188 | } | 188 | } |
189 | void KLocale::setIntDateFormat( KLocale::IntDateFormat i ) | 189 | void KLocale::setIntDateFormat( KLocale::IntDateFormat i ) |
190 | { | 190 | { |
191 | mIntDateFormat = i; | 191 | mIntDateFormat = i; |
192 | } | 192 | } |
193 | KLocale::IntDateFormat KLocale::getIntTimeFormat( ) | 193 | KLocale::IntDateFormat KLocale::getIntTimeFormat( ) |
194 | { | 194 | { |
195 | return mIntTimeFormat; | 195 | return mIntTimeFormat; |
196 | 196 | ||
197 | } | 197 | } |
198 | void KLocale::setIntTimeFormat( KLocale::IntDateFormat i ) | 198 | void KLocale::setIntTimeFormat( KLocale::IntDateFormat i ) |
199 | { | 199 | { |
200 | mIntTimeFormat = i; | 200 | mIntTimeFormat = i; |
201 | } | 201 | } |
202 | 202 | ||
203 | void KLocale::setLanguage( int i ) | 203 | void KLocale::setLanguage( int i ) |
204 | { | 204 | { |
205 | mLanguage = i; | 205 | mLanguage = i; |
206 | } | 206 | } |
207 | int KLocale::language( ) | 207 | int KLocale::language( ) |
208 | { | 208 | { |
209 | return mLanguage; | 209 | return mLanguage; |
210 | } | 210 | } |
211 | QString KLocale::translate( const char *index ) const | 211 | QString KLocale::translate( const char *index ) const |
212 | { | 212 | { |
213 | return i18n( index ); | 213 | return i18n( index ); |
214 | } | 214 | } |
215 | 215 | ||
216 | QString KLocale::translate( const char *, const char *fallback) const | 216 | QString KLocale::translate( const char *, const char *fallback) const |
217 | { | 217 | { |
218 | return i18n( fallback ); | 218 | return i18n( fallback ); |
219 | } | 219 | } |
220 | 220 | ||
221 | QString KLocale::formatTime(const QTime &pTime, bool includeSecs, IntDateFormat intIntDateFormat) const | 221 | QString KLocale::formatTime(const QTime &pTime, bool includeSecs, IntDateFormat intIntDateFormat) const |
222 | { | 222 | { |
223 | const QString rst = timeFormat(intIntDateFormat); | 223 | const QString rst = timeFormat(intIntDateFormat); |
224 | 224 | ||
225 | // only "pm/am" here can grow, the rest shrinks, but | 225 | // only "pm/am" here can grow, the rest shrinks, but |
226 | // I'm rather safe than sorry | 226 | // I'm rather safe than sorry |
227 | QChar *buffer = new QChar[rst.length() * 3 / 2 + 30]; | 227 | QChar *buffer = new QChar[rst.length() * 3 / 2 + 30]; |
228 | 228 | ||
229 | uint index = 0; | 229 | uint index = 0; |
230 | bool escape = false; | 230 | bool escape = false; |
231 | int number = 0; | 231 | int number = 0; |
232 | 232 | ||
233 | for ( uint format_index = 0; format_index < rst.length(); format_index++ ) | 233 | for ( uint format_index = 0; format_index < rst.length(); format_index++ ) |
234 | { | 234 | { |
235 | if ( !escape ) | 235 | if ( !escape ) |
236 | { | 236 | { |
237 | if ( rst.at( format_index ).unicode() == '%' ) | 237 | if ( rst.at( format_index ).unicode() == '%' ) |
238 | escape = true; | 238 | escape = true; |
239 | else | 239 | else |
240 | buffer[index++] = rst.at( format_index ); | 240 | buffer[index++] = rst.at( format_index ); |
241 | } | 241 | } |
242 | else | 242 | else |
243 | { | 243 | { |
244 | switch ( rst.at( format_index ).unicode() ) | 244 | switch ( rst.at( format_index ).unicode() ) |
245 | { | 245 | { |
246 | case '%': | 246 | case '%': |
247 | buffer[index++] = '%'; | 247 | buffer[index++] = '%'; |
248 | break; | 248 | break; |
249 | case 'H': | 249 | case 'H': |
250 | put_it_in( buffer, index, pTime.hour() ); | 250 | put_it_in( buffer, index, pTime.hour() ); |
251 | break; | 251 | break; |
252 | case 'I': | 252 | case 'I': |
253 | put_it_in( buffer, index, ( pTime.hour() + 11) % 12 + 1 ); | 253 | put_it_in( buffer, index, ( pTime.hour() + 11) % 12 + 1 ); |
254 | break; | 254 | break; |
255 | case 'M': | 255 | case 'M': |
256 | put_it_in( buffer, index, pTime.minute() ); | 256 | put_it_in( buffer, index, pTime.minute() ); |
257 | break; | 257 | break; |
258 | case 'S': | 258 | case 'S': |
259 | if (includeSecs) | 259 | if (includeSecs) |
260 | put_it_in( buffer, index, pTime.second() ); | 260 | put_it_in( buffer, index, pTime.second() ); |
261 | else | 261 | else |
262 | { | 262 | { |
263 | // we remove the seperator sign before the seconds and | 263 | // we remove the seperator sign before the seconds and |
264 | // assume that works everywhere | 264 | // assume that works everywhere |
265 | --index; | 265 | --index; |
266 | break; | 266 | break; |
267 | } | 267 | } |
268 | break; | 268 | break; |
269 | case 'k': | 269 | case 'k': |
270 | number = pTime.hour(); | 270 | number = pTime.hour(); |
271 | case 'l': | 271 | case 'l': |
272 | // to share the code | 272 | // to share the code |
273 | if ( rst.at( format_index ).unicode() == 'l' ) | 273 | if ( rst.at( format_index ).unicode() == 'l' ) |
274 | number = (pTime.hour() + 11) % 12 + 1; | 274 | number = (pTime.hour() + 11) % 12 + 1; |
275 | if ( number / 10 ) | 275 | if ( number / 10 ) |
276 | buffer[index++] = number / 10 + '0'; | 276 | buffer[index++] = number / 10 + '0'; |
277 | buffer[index++] = number % 10 + '0'; | 277 | buffer[index++] = number % 10 + '0'; |
278 | break; | 278 | break; |
279 | case 'p': | 279 | case 'p': |
280 | { | 280 | { |
281 | QString s; | 281 | QString s; |
282 | if ( pTime.hour() >= 12 ) | 282 | if ( pTime.hour() >= 12 ) |
283 | put_it_in( buffer, index, i18n("pm") ); | 283 | put_it_in( buffer, index, i18n("pm") ); |
284 | else | 284 | else |
285 | put_it_in( buffer, index, i18n("am") ); | 285 | put_it_in( buffer, index, i18n("am") ); |
286 | break; | 286 | break; |
287 | } | 287 | } |
288 | default: | 288 | default: |
289 | buffer[index++] = rst.at( format_index ); | 289 | buffer[index++] = rst.at( format_index ); |
290 | break; | 290 | break; |
291 | } | 291 | } |
292 | escape = false; | 292 | escape = false; |
293 | } | 293 | } |
294 | } | 294 | } |
295 | QString ret( buffer, index ); | 295 | QString ret( buffer, index ); |
296 | delete [] buffer; | 296 | delete [] buffer; |
297 | return ret; | 297 | return ret; |
298 | } | 298 | } |
299 | 299 | ||
300 | QString KLocale::formatDate(const QDate &pDate, bool shortFormat, IntDateFormat intIntDateFormat) const | 300 | QString KLocale::formatDate(const QDate &pDate, bool shortFormat, IntDateFormat intIntDateFormat) const |
301 | { | 301 | { |
302 | const QString rst = shortFormat?dateFormatShort(intIntDateFormat):dateFormat(intIntDateFormat); | 302 | const QString rst = shortFormat?dateFormatShort(intIntDateFormat):dateFormat(intIntDateFormat); |
303 | 303 | ||
304 | // I'm rather safe than sorry | 304 | // I'm rather safe than sorry |
305 | QChar *buffer = new QChar[rst.length() * 3 / 2 + 50]; | 305 | QChar *buffer = new QChar[rst.length() * 3 / 2 + 50]; |
306 | 306 | ||
307 | unsigned int index = 0; | 307 | unsigned int index = 0; |
308 | bool escape = false; | 308 | bool escape = false; |
309 | int number = 0; | 309 | int number = 0; |
310 | 310 | ||
311 | for ( uint format_index = 0; format_index < rst.length(); ++format_index ) | 311 | for ( uint format_index = 0; format_index < rst.length(); ++format_index ) |
312 | { | 312 | { |
313 | if ( !escape ) | 313 | if ( !escape ) |
314 | { | 314 | { |
315 | if ( rst.at( format_index ).unicode() == '%' ) | 315 | if ( rst.at( format_index ).unicode() == '%' ) |
316 | escape = true; | 316 | escape = true; |
317 | else | 317 | else |
318 | buffer[index++] = rst.at( format_index ); | 318 | buffer[index++] = rst.at( format_index ); |
319 | } | 319 | } |
320 | else | 320 | else |
321 | { | 321 | { |
322 | switch ( rst.at( format_index ).unicode() ) | 322 | switch ( rst.at( format_index ).unicode() ) |
323 | { | 323 | { |
324 | case '%': | 324 | case '%': |
325 | buffer[index++] = '%'; | 325 | buffer[index++] = '%'; |
326 | break; | 326 | break; |
327 | case 'Y': | 327 | case 'Y': |
328 | put_it_in( buffer, index, pDate.year() / 100 ); | 328 | put_it_in( buffer, index, pDate.year() / 100 ); |
329 | case 'y': | 329 | case 'y': |
330 | put_it_in( buffer, index, pDate.year() % 100 ); | 330 | put_it_in( buffer, index, pDate.year() % 100 ); |
331 | break; | 331 | break; |
332 | case 'n': | 332 | case 'n': |
333 | number = pDate.month(); | 333 | number = pDate.month(); |
334 | case 'e': | 334 | case 'e': |
335 | // to share the code | 335 | // to share the code |
336 | if ( rst.at( format_index ).unicode() == 'e' ) | 336 | if ( rst.at( format_index ).unicode() == 'e' ) |
337 | number = pDate.day(); | 337 | number = pDate.day(); |
338 | if ( number / 10 ) | 338 | if ( number / 10 ) |
339 | buffer[index++] = number / 10 + '0'; | 339 | buffer[index++] = number / 10 + '0'; |
340 | buffer[index++] = number % 10 + '0'; | 340 | buffer[index++] = number % 10 + '0'; |
341 | break; | 341 | break; |
342 | case 'm': | 342 | case 'm': |
343 | put_it_in( buffer, index, pDate.month() ); | 343 | put_it_in( buffer, index, pDate.month() ); |
344 | break; | 344 | break; |
345 | case 'b': | 345 | case 'b': |
346 | put_it_in( buffer, index, monthName(pDate.month(), true) ); | 346 | put_it_in( buffer, index, monthName(pDate.month(), true) ); |
347 | break; | 347 | break; |
348 | case 'B': | 348 | case 'B': |
349 | put_it_in( buffer, index, monthName(pDate.month(), false) ); | 349 | put_it_in( buffer, index, monthName(pDate.month(), false) ); |
350 | break; | 350 | break; |
351 | case 'd': | 351 | case 'd': |
352 | put_it_in( buffer, index, pDate.day() ); | 352 | put_it_in( buffer, index, pDate.day() ); |
353 | break; | 353 | break; |
354 | case 'a': | 354 | case 'a': |
355 | put_it_in( buffer, index, weekDayName(pDate.dayOfWeek(), true) ); | 355 | put_it_in( buffer, index, weekDayName(pDate.dayOfWeek(), true) ); |
356 | break; | 356 | break; |
357 | case 'A': | 357 | case 'A': |
358 | put_it_in( buffer, index, weekDayName(pDate.dayOfWeek(), false) ); | 358 | put_it_in( buffer, index, weekDayName(pDate.dayOfWeek(), false) ); |
359 | break; | 359 | break; |
360 | default: | 360 | default: |
361 | buffer[index++] = rst.at( format_index ); | 361 | buffer[index++] = rst.at( format_index ); |
362 | break; | 362 | break; |
363 | } | 363 | } |
364 | escape = false; | 364 | escape = false; |
365 | } | 365 | } |
366 | } | 366 | } |
367 | QString ret( buffer, index ); | 367 | QString ret( buffer, index ); |
368 | delete [] buffer; | 368 | delete [] buffer; |
369 | return ret; | 369 | return ret; |
370 | } | 370 | } |
371 | 371 | ||
372 | QString KLocale::formatDateTime(const QDateTime &pDateTime, | 372 | QString KLocale::formatDateTime(const QDateTime &pDateTime, |
373 | bool shortFormat, | 373 | bool shortFormat, |
374 | bool includeSeconds, | 374 | bool includeSeconds, |
375 | IntDateFormat intIntDateFormat) const | 375 | IntDateFormat intIntDateFormat) const |
376 | { | 376 | { |
377 | QString format("%1 %2"); | 377 | QString format("%1 %2"); |
378 | 378 | ||
379 | if ( intIntDateFormat == Default ) | 379 | if ( intIntDateFormat == Default ) |
380 | format = "%1 %2"; | 380 | format = "%1 %2"; |
381 | else if ( intIntDateFormat == Format1 ) | 381 | else if ( intIntDateFormat == Format1 ) |
382 | format = "%1 %2"; | 382 | format = "%1 %2"; |
383 | else if ( intIntDateFormat == ISODate ) | 383 | else if ( intIntDateFormat == ISODate ) |
384 | format = "%1T%2"; | 384 | format = "%1T%2"; |
385 | 385 | ||
386 | QString res = format.arg(formatDate( pDateTime.date(), shortFormat, intIntDateFormat )) | 386 | QString res = format.arg(formatDate( pDateTime.date(), shortFormat, intIntDateFormat )) |
387 | .arg(formatTime( pDateTime.time(), includeSeconds , intIntDateFormat )); | 387 | .arg(formatTime( pDateTime.time(), includeSeconds , intIntDateFormat )); |
388 | 388 | ||
389 | //qDebug("KLocale::formatDateTime transformed %s, into %s", pDateTime.toString().latin1(), res.latin1() ); | 389 | //qDebug("KLocale::formatDateTime transformed %s, into %s", pDateTime.toString().latin1(), res.latin1() ); |
390 | 390 | ||
391 | return res; | 391 | return res; |
392 | } | 392 | } |
393 | 393 | ||
394 | QString KLocale::formatDateTime(const QDateTime &pDateTime, IntDateFormat intIntDateFormat) const | 394 | QString KLocale::formatDateTime(const QDateTime &pDateTime, IntDateFormat intIntDateFormat) const |
395 | { | 395 | { |
396 | return formatDateTime(pDateTime, true, true, intIntDateFormat); | 396 | return formatDateTime(pDateTime, true, true, intIntDateFormat); |
397 | } | 397 | } |
398 | 398 | ||
399 | QDate KLocale::readDate(const QString &intstr, bool* ok) const | 399 | QDate KLocale::readDate(const QString &intstr, bool* ok) const |
400 | { | 400 | { |
401 | QDate date; | 401 | QDate date; |
402 | date = readDate(intstr, true, ok); | 402 | date = readDate(intstr, true, ok); |
403 | if (date.isValid()) return date; | 403 | if (date.isValid()) return date; |
404 | return readDate(intstr, false, ok); | 404 | return readDate(intstr, false, ok); |
405 | } | 405 | } |
406 | 406 | ||
407 | QDate KLocale::readDate(const QString &intstr, bool shortFormat, bool* ok) const | 407 | QDate KLocale::readDate(const QString &intstr, bool shortFormat, bool* ok) const |
408 | { | 408 | { |
409 | QString fmt = (shortFormat ? dateFormatShort() : dateFormat()).simplifyWhiteSpace(); | 409 | QString fmt = (shortFormat ? dateFormatShort() : dateFormat()).simplifyWhiteSpace(); |
410 | return readDate( intstr, fmt, ok ); | 410 | return readDate( intstr, fmt, ok ); |
411 | } | 411 | } |
412 | 412 | ||
413 | QDate KLocale::readDate(const QString &intstr, const QString &fmt, bool* ok) const | 413 | QDate KLocale::readDate(const QString &intstr, const QString &fmt, bool* ok) const |
414 | { | 414 | { |
415 | //kdDebug(173) << "KLocale::readDate intstr=" << intstr << " fmt=" << fmt << endl; | 415 | //kdDebug(173) << "KLocale::readDate intstr=" << intstr << " fmt=" << fmt << endl; |
416 | QString str = intstr.simplifyWhiteSpace().lower(); | 416 | QString str = intstr.simplifyWhiteSpace().lower(); |
417 | int day = -1, month = -1; | 417 | int day = -1, month = -1; |
418 | // allow the year to be omitted if not in the format | 418 | // allow the year to be omitted if not in the format |
419 | int year = QDate::currentDate().year(); | 419 | int year = QDate::currentDate().year(); |
420 | uint strpos = 0; | 420 | uint strpos = 0; |
421 | uint fmtpos = 0; | 421 | uint fmtpos = 0; |
422 | 422 | ||
423 | while (fmt.length() > fmtpos || str.length() > strpos) | 423 | while (fmt.length() > fmtpos || str.length() > strpos) |
424 | { | 424 | { |
425 | if ( !(fmt.length() > fmtpos && str.length() > strpos) ) | 425 | if ( !(fmt.length() > fmtpos && str.length() > strpos) ) |
426 | goto error; | 426 | goto error; |
427 | 427 | ||
428 | QChar c = fmt.at(fmtpos++); | 428 | QChar c = fmt.at(fmtpos++); |
429 | 429 | ||
430 | if (c != '%') { | 430 | if (c != '%') { |
431 | if (c.isSpace()) | 431 | if (c.isSpace()) |
432 | strpos++; | 432 | strpos++; |
433 | else if (c != str.at(strpos++)) | 433 | else if (c != str.at(strpos++)) |
434 | goto error; | 434 | goto error; |
435 | continue; | 435 | continue; |
436 | } | 436 | } |
437 | 437 | ||
438 | // remove space at the begining | 438 | // remove space at the begining |
439 | if (str.length() > strpos && str.at(strpos).isSpace()) | 439 | if (str.length() > strpos && str.at(strpos).isSpace()) |
440 | strpos++; | 440 | strpos++; |
441 | 441 | ||
442 | c = fmt.at(fmtpos++); | 442 | c = fmt.at(fmtpos++); |
443 | switch (c) | 443 | switch (c) |
444 | { | 444 | { |
445 | case 'a': | 445 | case 'a': |
446 | case 'A': | 446 | case 'A': |
447 | // this will just be ignored | 447 | // this will just be ignored |
448 | { // Cristian Tache: porting to Win: Block added because of "j" redefinition | 448 | { // Cristian Tache: porting to Win: Block added because of "j" redefinition |
449 | for (int j = 1; j < 8; j++) { | 449 | for (int j = 1; j < 8; j++) { |
450 | QString s = weekDayName(j, c == 'a').lower(); | 450 | QString s = weekDayName(j, c == 'a').lower(); |
451 | int len = s.length(); | 451 | int len = s.length(); |
452 | if (str.mid(strpos, len) == s) | 452 | if (str.mid(strpos, len) == s) |
453 | strpos += len; | 453 | strpos += len; |
454 | } | 454 | } |
455 | break; | 455 | break; |
456 | } | 456 | } |
457 | case 'b': | 457 | case 'b': |
458 | case 'B': | 458 | case 'B': |
459 | { // Cristian Tache: porting to Win: Block added because of "j" redefinition | 459 | { // Cristian Tache: porting to Win: Block added because of "j" redefinition |
460 | for (int j = 1; j < 13; j++) { | 460 | for (int j = 1; j < 13; j++) { |
461 | QString s = monthName(j, c == 'b').lower(); | 461 | QString s = monthName(j, c == 'b').lower(); |
462 | int len = s.length(); | 462 | int len = s.length(); |
463 | if (str.mid(strpos, len) == s) { | 463 | if (str.mid(strpos, len) == s) { |
464 | month = j; | 464 | month = j; |
465 | strpos += len; | 465 | strpos += len; |
466 | } | 466 | } |
467 | } | 467 | } |
468 | break; | 468 | break; |
469 | } | 469 | } |
470 | case 'd': | 470 | case 'd': |
471 | case 'e': | 471 | case 'e': |
472 | day = readInt(str, strpos); | 472 | day = readInt(str, strpos); |
473 | if (day < 1 || day > 31) | 473 | if (day < 1 || day > 31) |
474 | goto error; | 474 | goto error; |
475 | 475 | ||
476 | break; | 476 | break; |
477 | 477 | ||
478 | case 'n': | 478 | case 'n': |
479 | case 'm': | 479 | case 'm': |
480 | month = readInt(str, strpos); | 480 | month = readInt(str, strpos); |
481 | if (month < 1 || month > 12) | 481 | if (month < 1 || month > 12) |
482 | goto error; | 482 | goto error; |
483 | 483 | ||
484 | break; | 484 | break; |
485 | 485 | ||
486 | case 'Y': | 486 | case 'Y': |
487 | case 'y': | 487 | case 'y': |
488 | year = readInt(str, strpos); | 488 | year = readInt(str, strpos); |
489 | if (year < 0) | 489 | if (year < 0) |
490 | goto error; | 490 | goto error; |
491 | // Qt treats a year in the range 0-100 as 1900-1999. | 491 | // Qt treats a year in the range 0-100 as 1900-1999. |
492 | // It is nicer for the user if we treat 0-68 as 2000-2068 | 492 | // It is nicer for the user if we treat 0-68 as 2000-2068 |
493 | if (year < 69) | 493 | if (year < 69) |
494 | year += 2000; | 494 | year += 2000; |
495 | else if (c == 'y') | 495 | else if (c == 'y') |
496 | year += 1900; | 496 | year += 1900; |
497 | 497 | ||
498 | break; | 498 | break; |
499 | } | 499 | } |
500 | } | 500 | } |
501 | //kdDebug(173) << "KLocale::readDate day=" << day << " month=" << month << " year=" << year << endl; | 501 | //kdDebug(173) << "KLocale::readDate day=" << day << " month=" << month << " year=" << year << endl; |
502 | if ( year != -1 && month != -1 && day != -1 ) | 502 | if ( year != -1 && month != -1 && day != -1 ) |
503 | { | 503 | { |
504 | if (ok) *ok = true; | 504 | if (ok) *ok = true; |
505 | return QDate(year, month, day); | 505 | return QDate(year, month, day); |
506 | } | 506 | } |
507 | error: | 507 | error: |
508 | if (ok) *ok = false; | 508 | if (ok) *ok = false; |
509 | return QDate(); // invalid date | 509 | return QDate(); // invalid date |
510 | } | 510 | } |
511 | 511 | ||
512 | QTime KLocale::readTime(const QString &intstr, bool *ok) const | 512 | QTime KLocale::readTime(const QString &intstr, bool *ok) const |
513 | { | 513 | { |
514 | QTime _time; | 514 | QTime _time; |
515 | _time = readTime(intstr, true, ok); | 515 | _time = readTime(intstr, true, ok); |
516 | if (_time.isValid()) return _time; | 516 | if (_time.isValid()) return _time; |
517 | return readTime(intstr, false, ok); | 517 | return readTime(intstr, false, ok); |
518 | } | 518 | } |
519 | 519 | ||
520 | QTime KLocale::readTime(const QString &intstr, bool seconds, bool *ok) const | 520 | QTime KLocale::readTime(const QString &intstr, bool seconds, bool *ok) const |
521 | { | 521 | { |
522 | QString str = intstr.simplifyWhiteSpace().lower(); | 522 | QString str = intstr.simplifyWhiteSpace().lower(); |
523 | QString Format = timeFormat().simplifyWhiteSpace(); | 523 | QString Format = timeFormat().simplifyWhiteSpace(); |
524 | if (!seconds) | 524 | if (!seconds) |
525 | Format.replace(QRegExp(QString::fromLatin1(".%S")), QString::null); | 525 | Format.replace(QRegExp(QString::fromLatin1(".%S")), QString::null); |
526 | 526 | ||
527 | int hour = -1, minute = -1, second = seconds ? -1 : 0; // don't require seconds | 527 | int hour = -1, minute = -1, second = seconds ? -1 : 0; // don't require seconds |
528 | 528 | ||
529 | bool g_12h = false; | 529 | bool g_12h = false; |
530 | bool pm = false; | 530 | bool pm = false; |
531 | uint strpos = 0; | 531 | uint strpos = 0; |
532 | uint Formatpos = 0; | 532 | uint Formatpos = 0; |
533 | 533 | ||
534 | while (Format.length() > Formatpos || str.length() > strpos) | 534 | while (Format.length() > Formatpos || str.length() > strpos) |
535 | { | 535 | { |
536 | if ( !(Format.length() > Formatpos && str.length() > strpos) ) goto error; | 536 | if ( !(Format.length() > Formatpos && str.length() > strpos) ) goto error; |
537 | 537 | ||
538 | QChar c = Format.at(Formatpos++); | 538 | QChar c = Format.at(Formatpos++); |
539 | 539 | ||
540 | if (c != '%') | 540 | if (c != '%') |
541 | { | 541 | { |
542 | if (c.isSpace()) | 542 | if (c.isSpace()) |
543 | strpos++; | 543 | strpos++; |
544 | else if (c != str.at(strpos++)) | 544 | else if (c != str.at(strpos++)) |
545 | goto error; | 545 | goto error; |
546 | continue; | 546 | continue; |
547 | } | 547 | } |
548 | 548 | ||
549 | // remove space at the begining | 549 | // remove space at the begining |
550 | if (str.length() > strpos && str.at(strpos).isSpace()) | 550 | if (str.length() > strpos && str.at(strpos).isSpace()) |
551 | strpos++; | 551 | strpos++; |
552 | 552 | ||
553 | c = Format.at(Formatpos++); | 553 | c = Format.at(Formatpos++); |
554 | switch (c) | 554 | switch (c) |
555 | { | 555 | { |
556 | case 'p': | 556 | case 'p': |
557 | { | 557 | { |
558 | QString s; | 558 | QString s; |
559 | s = i18n("pm").lower(); | 559 | s = i18n("pm").lower(); |
560 | int len = s.length(); | 560 | int len = s.length(); |
561 | if (str.mid(strpos, len) == s) | 561 | if (str.mid(strpos, len) == s) |
562 | { | 562 | { |
563 | pm = true; | 563 | pm = true; |
564 | strpos += len; | 564 | strpos += len; |
565 | } | 565 | } |
566 | else | 566 | else |
567 | { | 567 | { |
568 | s = i18n("am").lower(); | 568 | s = i18n("am").lower(); |
569 | len = s.length(); | 569 | len = s.length(); |
570 | if (str.mid(strpos, len) == s) { | 570 | if (str.mid(strpos, len) == s) { |
571 | pm = false; | 571 | pm = false; |
572 | strpos += len; | 572 | strpos += len; |
573 | } | 573 | } |
574 | else | 574 | else |
575 | goto error; | 575 | goto error; |
576 | } | 576 | } |
577 | } | 577 | } |
578 | break; | 578 | break; |
579 | 579 | ||
580 | case 'k': | 580 | case 'k': |
581 | case 'H': | 581 | case 'H': |
582 | g_12h = false; | 582 | g_12h = false; |
583 | hour = readInt(str, strpos); | 583 | hour = readInt(str, strpos); |
584 | if (hour < 0 || hour > 23) | 584 | if (hour < 0 || hour > 23) |
585 | goto error; | 585 | goto error; |
586 | 586 | ||
587 | break; | 587 | break; |
588 | 588 | ||
589 | case 'l': | 589 | case 'l': |
590 | case 'I': | 590 | case 'I': |
591 | g_12h = true; | 591 | g_12h = true; |
592 | hour = readInt(str, strpos); | 592 | hour = readInt(str, strpos); |
593 | if (hour < 1 || hour > 12) | 593 | if (hour < 1 || hour > 12) |
594 | goto error; | 594 | goto error; |
595 | 595 | ||
596 | break; | 596 | break; |
597 | 597 | ||
598 | case 'M': | 598 | case 'M': |
599 | minute = readInt(str, strpos); | 599 | minute = readInt(str, strpos); |
600 | if (minute < 0 || minute > 59) | 600 | if (minute < 0 || minute > 59) |
601 | goto error; | 601 | goto error; |
602 | 602 | ||
603 | break; | 603 | break; |
604 | 604 | ||
605 | case 'S': | 605 | case 'S': |
606 | second = readInt(str, strpos); | 606 | second = readInt(str, strpos); |
607 | if (second < 0 || second > 59) | 607 | if (second < 0 || second > 59) |
608 | goto error; | 608 | goto error; |
609 | 609 | ||
610 | break; | 610 | break; |
611 | } | 611 | } |
612 | } | 612 | } |
613 | if (g_12h) | 613 | if (g_12h) |
614 | { | 614 | { |
615 | hour %= 12; | 615 | hour %= 12; |
616 | if (pm) hour += 12; | 616 | if (pm) hour += 12; |
617 | } | 617 | } |
618 | 618 | ||
619 | if (ok) *ok = true; | 619 | if (ok) *ok = true; |
620 | return QTime(hour, minute, second); | 620 | return QTime(hour, minute, second); |
621 | 621 | ||
622 | error: | 622 | error: |
623 | if (ok) *ok = false; | 623 | if (ok) *ok = false; |
624 | return QTime(-1, -1, -1); // return invalid date if it didn't work | 624 | return QTime(-1, -1, -1); // return invalid date if it didn't work |
625 | // This will be removed in the near future, since it gives a warning on stderr. | 625 | // This will be removed in the near future, since it gives a warning on stderr. |
626 | // The presence of the bool* (since KDE-3.0) removes the need for an invalid QTime. | 626 | // The presence of the bool* (since KDE-3.0) removes the need for an invalid QTime. |
627 | } | 627 | } |
628 | 628 | ||
629 | QDateTime KLocale::readDateTime(const QString &intstr, | 629 | QDateTime KLocale::readDateTime(const QString &intstr, |
630 | IntDateFormat intIntDateFormat, | 630 | IntDateFormat intIntDateFormat, |
631 | bool* ok) const | 631 | bool* ok) const |
632 | { | 632 | { |
633 | bool ok1, ok2; | 633 | bool ok1, ok2; |
634 | 634 | ||
635 | // AT the moment we can not read any other format then ISODate | 635 | // AT the moment we can not read any other format then ISODate |
636 | if ( intIntDateFormat != ISODate ) | 636 | if ( intIntDateFormat != ISODate ) |
637 | { | 637 | { |
638 | qDebug("KLocale::readDateTime, only ISODate is supported."); | 638 | qDebug("KLocale::readDateTime, only ISODate is supported."); |
639 | return QDateTime(); | 639 | return QDateTime(); |
640 | } | 640 | } |
641 | 641 | ||
642 | int pos = intstr.find("T"); | 642 | int pos = intstr.find("T"); |
643 | QString date = intstr.left(pos); | 643 | QString date = intstr.left(pos); |
644 | QString time = intstr.mid(pos+1); | 644 | QString time = intstr.mid(pos+1); |
645 | 645 | ||
646 | QString dformat = dateFormat(intIntDateFormat); | 646 | QString dformat = dateFormat(intIntDateFormat); |
647 | QString tformat = timeFormat(intIntDateFormat); | 647 | QString tformat = timeFormat(intIntDateFormat); |
648 | 648 | ||
649 | QDate m_date = readDate(date, dformat, &ok1); | 649 | QDate m_date = readDate(date, dformat, &ok1); |
650 | QTime m_time = readTime(time, tformat, &ok2); | 650 | QTime m_time = readTime(time, tformat, &ok2); |
651 | 651 | ||
652 | QDateTime m_dt; | 652 | QDateTime m_dt; |
653 | 653 | ||
654 | if (ok) | 654 | if (ok) |
655 | { | 655 | { |
656 | if ((ok1 == false) || (ok2 == false)) | 656 | if ((ok1 == false) || (ok2 == false)) |
657 | *ok = false; | 657 | *ok = false; |
658 | else | 658 | else |
659 | *ok = true; | 659 | *ok = true; |
660 | } | 660 | } |
661 | 661 | ||
662 | //only set values if both operations returned true. | 662 | //only set values if both operations returned true. |
663 | if ((ok1 == true) && (ok2 == true)) | 663 | if ((ok1 == true) && (ok2 == true)) |
664 | { | 664 | { |
665 | m_dt.setDate(m_date); | 665 | m_dt.setDate(m_date); |
666 | m_dt.setTime(m_time); | 666 | m_dt.setTime(m_time); |
667 | } | 667 | } |
668 | 668 | ||
669 | //qDebug("KLocale::readDateTime() transformed %s into %s (%s), %s (%s) : err1=%i, err2=%i", intstr.latin1(), date.latin1(), dformat.latin1(), time.latin1(), tformat.latin1(), ok1, ok2); | 669 | //qDebug("KLocale::readDateTime() transformed %s into %s (%s), %s (%s) : err1=%i, err2=%i", intstr.latin1(), date.latin1(), dformat.latin1(), time.latin1(), tformat.latin1(), ok1, ok2); |
670 | return m_dt; | 670 | return m_dt; |
671 | } | 671 | } |
672 | 672 | ||
673 | QDate KLocale::readDate(const QString &intstr, | 673 | QDate KLocale::readDate(const QString &intstr, |
674 | IntDateFormat intIntDateFormat, | 674 | IntDateFormat intIntDateFormat, |
675 | bool* ok) const | 675 | bool* ok) const |
676 | { | 676 | { |
677 | bool ok1; | 677 | bool ok1; |
678 | 678 | ||
679 | QString dformat = dateFormat(intIntDateFormat); | 679 | QString dformat = dateFormat(intIntDateFormat); |
680 | 680 | ||
681 | QDate m_date = readDate(intstr, dformat, &ok1); | 681 | QDate m_date = readDate(intstr, dformat, &ok1); |
682 | 682 | ||
683 | if (ok) | 683 | if (ok) |
684 | *ok = ok1; | 684 | *ok = ok1; |
685 | 685 | ||
686 | //qDebug("KLocale::readDate() transformed %s into %s (%s), %s (%s) : err1=%i, err2=%i", intstr.latin1(), date.latin1(), dformat.latin1(), time.latin1(), tformat.latin1(), ok1, ok2); | 686 | //qDebug("KLocale::readDate() transformed %s into %s (%s), %s (%s) : err1=%i, err2=%i", intstr.latin1(), date.latin1(), dformat.latin1(), time.latin1(), tformat.latin1(), ok1, ok2); |
687 | return m_date; | 687 | return m_date; |
688 | } | 688 | } |
689 | 689 | ||
690 | 690 | ||
691 | bool KLocale::use12Clock() const | 691 | bool KLocale::use12Clock() const |
692 | { | 692 | { |
693 | return !mHourF24Format ;; | 693 | return !mHourF24Format ;; |
694 | } | 694 | } |
695 | 695 | ||
696 | bool KLocale::weekStartsMonday() const | 696 | bool KLocale::weekStartsMonday() const |
697 | { | 697 | { |
698 | return mWeekStartsMonday; | 698 | return mWeekStartsMonday; |
699 | } | 699 | } |
700 | 700 | ||
701 | int KLocale::weekStartDay() const | 701 | int KLocale::weekStartDay() const |
702 | { | 702 | { |
703 | if ( mWeekStartsMonday ) | 703 | if ( mWeekStartsMonday ) |
704 | return 1; | 704 | return 1; |
705 | return 7; | 705 | return 7; |
706 | } | 706 | } |
707 | 707 | ||
708 | QString KLocale::weekDayName(int i,bool shortName) const | 708 | QString KLocale::weekDayName(int i,bool shortName) const |
709 | { | 709 | { |
710 | if ( shortName ) | 710 | if ( shortName ) |
711 | switch ( i ) | 711 | switch ( i ) |
712 | { | 712 | { |
713 | case 1: return i18n("Monday", "Mon"); | 713 | case 1: return i18n("Monday", "Mon"); |
714 | case 2: return i18n("Tuesday", "Tue"); | 714 | case 2: return i18n("Tuesday", "Tue"); |
715 | case 3: return i18n("Wednesday", "Wed"); | 715 | case 3: return i18n("Wednesday", "Wed"); |
716 | case 4: return i18n("Thursday", "Thu"); | 716 | case 4: return i18n("Thursday", "Thu"); |
717 | case 5: return i18n("Friday", "Fri"); | 717 | case 5: return i18n("Friday", "Fri"); |
718 | case 6: return i18n("Saturday", "Sat"); | 718 | case 6: return i18n("Saturday", "Sat"); |
719 | case 7: return i18n("Sunday", "Sun"); | 719 | case 7: return i18n("Sunday", "Sun"); |
720 | } | 720 | } |
721 | else | 721 | else |
722 | switch ( i ) | 722 | switch ( i ) |
723 | { | 723 | { |
724 | case 1: return i18n("Monday"); | 724 | case 1: return i18n("Monday"); |
725 | case 2: return i18n("Tuesday"); | 725 | case 2: return i18n("Tuesday"); |
726 | case 3: return i18n("Wednesday"); | 726 | case 3: return i18n("Wednesday"); |
727 | case 4: return i18n("Thursday"); | 727 | case 4: return i18n("Thursday"); |
728 | case 5: return i18n("Friday"); | 728 | case 5: return i18n("Friday"); |
729 | case 6: return i18n("Saturday"); | 729 | case 6: return i18n("Saturday"); |
730 | case 7: return i18n("Sunday"); | 730 | case 7: return i18n("Sunday"); |
731 | } | 731 | } |
732 | 732 | ||
733 | return QString::null; | 733 | return QString::null; |
734 | } | 734 | } |
735 | 735 | ||
736 | QString KLocale::monthName(int i,bool shortName) const | 736 | QString KLocale::monthName(int i,bool shortName) const |
737 | { | 737 | { |
738 | if ( shortName ) | 738 | if ( shortName ) |
739 | switch ( i ) | 739 | switch ( i ) |
740 | { | 740 | { |
741 | case 1: return i18n("January", "Jan"); | 741 | case 1: return i18n("January", "Jan"); |
742 | case 2: return i18n("February", "Feb"); | 742 | case 2: return i18n("February", "Feb"); |
743 | case 3: return i18n("March", "Mar"); | 743 | case 3: return i18n("March", "Mar"); |
744 | case 4: return i18n("April", "Apr"); | 744 | case 4: return i18n("April", "Apr"); |
745 | case 5: return i18n("May short", "May"); | 745 | case 5: return i18n("May short", "May"); |
746 | case 6: return i18n("June", "Jun"); | 746 | case 6: return i18n("June", "Jun"); |
747 | case 7: return i18n("July", "Jul"); | 747 | case 7: return i18n("July", "Jul"); |
748 | case 8: return i18n("August", "Aug"); | 748 | case 8: return i18n("August", "Aug"); |
749 | case 9: return i18n("September", "Sep"); | 749 | case 9: return i18n("September", "Sep"); |
750 | case 10: return i18n("October", "Oct"); | 750 | case 10: return i18n("October", "Oct"); |
751 | case 11: return i18n("November", "Nov"); | 751 | case 11: return i18n("November", "Nov"); |
752 | case 12: return i18n("December", "Dec"); | 752 | case 12: return i18n("December", "Dec"); |
753 | } | 753 | } |
754 | else | 754 | else |
755 | switch (i) | 755 | switch (i) |
756 | { | 756 | { |
757 | case 1: return i18n("January"); | 757 | case 1: return i18n("January"); |
758 | case 2: return i18n("February"); | 758 | case 2: return i18n("February"); |
759 | case 3: return i18n("March"); | 759 | case 3: return i18n("March"); |
760 | case 4: return i18n("April"); | 760 | case 4: return i18n("April"); |
761 | case 5: return i18n("May long", "May"); | 761 | case 5: return i18n("May long", "May"); |
762 | case 6: return i18n("June"); | 762 | case 6: return i18n("June"); |
763 | case 7: return i18n("July"); | 763 | case 7: return i18n("July"); |
764 | case 8: return i18n("August"); | 764 | case 8: return i18n("August"); |
765 | case 9: return i18n("September"); | 765 | case 9: return i18n("September"); |
766 | case 10: return i18n("October"); | 766 | case 10: return i18n("October"); |
767 | case 11: return i18n("November"); | 767 | case 11: return i18n("November"); |
768 | case 12: return i18n("December"); | 768 | case 12: return i18n("December"); |
769 | } | 769 | } |
770 | 770 | ||
771 | return QString::null; | 771 | return QString::null; |
772 | } | 772 | } |
773 | 773 | ||
774 | QString KLocale::country() const | 774 | QString KLocale::country() const |
775 | { | 775 | { |
776 | return QString::null; | 776 | return QString::null; |
777 | } | 777 | } |
778 | 778 | ||
779 | QString KLocale::dateFormat(IntDateFormat intIntDateFormat) const | 779 | QString KLocale::dateFormat(IntDateFormat intIntDateFormat) const |
780 | { | 780 | { |
781 | const IntDateFormat dformat = (intIntDateFormat == Undefined)?mIntDateFormat:intIntDateFormat; | 781 | const IntDateFormat dformat = (intIntDateFormat == Undefined)?mIntDateFormat:intIntDateFormat; |
782 | 782 | ||
783 | if ( dformat == ISODate ) | 783 | if ( dformat == ISODate ) |
784 | return "%Y-%m-%d"; | 784 | return "%Y-%m-%d"; |
785 | 785 | ||
786 | if ( QApplication::desktop()->width() < 480 ) { | 786 | if ( QApplication::desktop()->width() < 480 ) { |
787 | if ( dformat == Default ) | 787 | if ( dformat == Default ) |
788 | return "%a %d %b %Y"; | 788 | return "%a %d %b %Y"; |
789 | else if ( dformat == Format1 ) | 789 | else if ( dformat == Format1 ) |
790 | return "%a %b %d %Y"; | 790 | return "%a %b %d %Y"; |
791 | } else { | 791 | } else { |
792 | if ( dformat == Default ) | 792 | if ( dformat == Default ) |
793 | return "%A %d %B %Y"; | 793 | return "%A %d %B %Y"; |
794 | else if ( dformat == Format1 ) | 794 | else if ( dformat == Format1 ) |
795 | return "%A %B %d %Y"; | 795 | return "%A %B %d %Y"; |
796 | 796 | ||
797 | } | 797 | } |
798 | return mDateFormat ; | 798 | return mDateFormat ; |
799 | } | 799 | } |
800 | 800 | ||
801 | QString KLocale::dateFormatShort(IntDateFormat intIntDateFormat) const | 801 | QString KLocale::dateFormatShort(IntDateFormat intIntDateFormat) const |
802 | { | 802 | { |
803 | const IntDateFormat dformat = (intIntDateFormat == Undefined)?mIntDateFormat:intIntDateFormat; | 803 | const IntDateFormat dformat = (intIntDateFormat == Undefined)?mIntDateFormat:intIntDateFormat; |
804 | 804 | ||
805 | if ( dformat == Default ) | 805 | if ( dformat == Default ) |
806 | return "%d.%m.%Y"; | 806 | return "%d.%m.%Y"; |
807 | else if ( dformat == Format1 ) | 807 | else if ( dformat == Format1 ) |
808 | return "%m.%d.%Y"; | 808 | return "%m.%d.%Y"; |
809 | else if ( dformat == ISODate ) // = Qt::ISODate | 809 | else if ( dformat == ISODate ) // = Qt::ISODate |
810 | return "%Y-%m-%d"; | 810 | return "%Y-%m-%d"; |
811 | return mDateFormatShort ; | 811 | return mDateFormatShort ; |
812 | 812 | ||
813 | } | 813 | } |
814 | 814 | ||
815 | 815 | ||
816 | QString KLocale::timeFormat(IntDateFormat intIntTimeFormat) const | 816 | QString KLocale::timeFormat(IntDateFormat intIntTimeFormat) const |
817 | { | 817 | { |
818 | const IntDateFormat tformat = (intIntTimeFormat == Undefined)?mIntTimeFormat:intIntTimeFormat; | 818 | const IntDateFormat tformat = (intIntTimeFormat == Undefined)?mIntTimeFormat:intIntTimeFormat; |
819 | 819 | ||
820 | if ( tformat == Default ) | 820 | if ( tformat == Default ) |
821 | if ( mHourF24Format) | 821 | if ( mHourF24Format) |
822 | return "%H:%M:%S"; | 822 | return "%H:%M:%S"; |
823 | else | 823 | else |
824 | return "%I:%M:%S%p"; | 824 | return "%I:%M:%S%p"; |
825 | 825 | ||
826 | else if ( tformat == Format1 ) | 826 | else if ( tformat == Format1 ) |
827 | if ( mHourF24Format) | 827 | if ( mHourF24Format) |
828 | return "%H:%M:%S"; | 828 | return "%H:%M:%S"; |
829 | else | 829 | else |
830 | return "%I:%M:%S%p"; | 830 | return "%I:%M:%S%p"; |
831 | 831 | ||
832 | else if ( tformat == ISODate ) // = Qt::ISODate | 832 | else if ( tformat == ISODate ) // = Qt::ISODate |
833 | if ( mHourF24Format) | 833 | if ( mHourF24Format) |
834 | return "%H:%M:%S"; | 834 | return "%H:%M:%S"; |
835 | else | 835 | else |
836 | return "%I:%M:%S%p"; | 836 | return "%I:%M:%S%p"; |
837 | 837 | ||
838 | } | 838 | } |
839 | 839 | ||
840 | void KLocale::insertCatalogue ( const QString & ) | 840 | void KLocale::insertCatalogue ( const QString & ) |
841 | { | 841 | { |
842 | } | 842 | } |
843 | 843 | ||
844 | KCalendarSystem *KLocale::calendar() | 844 | KCalendarSystem *KLocale::calendar() |
845 | { | 845 | { |
846 | if ( !mCalendarSystem ) { | 846 | if ( !mCalendarSystem ) { |
847 | mCalendarSystem = new KCalendarSystemGregorian; | 847 | mCalendarSystem = new KCalendarSystemGregorian; |
848 | } | 848 | } |
849 | 849 | ||
850 | return mCalendarSystem; | 850 | return mCalendarSystem; |
851 | } | 851 | } |
852 | 852 | ||
853 | int KLocale::timezoneOffset( QString timeZone ) | 853 | int KLocale::timezoneOffset( QString timeZone ) |
854 | { | 854 | { |
855 | int ret = 1001; | 855 | int ret = 1001; |
856 | int index = mTimeZoneList.findIndex( timeZone ); | 856 | int index = mTimeZoneList.findIndex( timeZone ); |
857 | if ( index < 24 ) | 857 | if ( index < 24 ) |
858 | ret = ( index-11 ) * 60 ; | 858 | ret = ( index-11 ) * 60 ; |
859 | return ret; | 859 | return ret; |
860 | } | 860 | } |
861 | 861 | ||
862 | QStringList KLocale::timeZoneList() const | 862 | QStringList KLocale::timeZoneList() const |
863 | { | 863 | { |
864 | return mTimeZoneList; | 864 | return mTimeZoneList; |
865 | } | 865 | } |
866 | void KLocale::setTimezone( const QString &timeZone, bool oddTZ ) | 866 | void KLocale::setTimezone( const QString &timeZone, bool oddTZ ) |
867 | { | 867 | { |
868 | mTimeZoneOffset = timezoneOffset( timeZone ); | 868 | mTimeZoneOffset = timezoneOffset( timeZone ); |
869 | if ( oddTZ ) | 869 | if ( oddTZ ) |
870 | mTimeZoneOffset += 30; | 870 | mTimeZoneOffset += 30; |
871 | } | 871 | } |
872 | 872 | ||
873 | void KLocale::setDaylightSaving( bool b, int start , int end ) | 873 | void KLocale::setDaylightSaving( bool b, int start , int end ) |
874 | { | 874 | { |
875 | daylightEnabled = b; | 875 | daylightEnabled = b; |
876 | daylightStart = start; | 876 | daylightStart = start; |
877 | daylightEnd = end; | 877 | daylightEnd = end; |
878 | mSouthDaylight = (end < start); | 878 | mSouthDaylight = (end < start); |
879 | // qDebug("klocale daylight %d %d %d ", b, start , end ); | 879 | // qDebug("klocale daylight %d %d %d ", b, start , end ); |
880 | } | 880 | } |
881 | 881 | ||
882 | int KLocale::localTimeOffset( const QDateTime &dt ) | 882 | int KLocale::localTimeOffset( const QDateTime &dt ) |
883 | { | 883 | { |
884 | bool addDaylight = false; | 884 | bool addDaylight = false; |
885 | if ( daylightEnabled ) { | 885 | if ( daylightEnabled ) { |
886 | int d_end, d_start; | 886 | int d_end, d_start; |
887 | int dayofyear = dt.date().dayOfYear(); | 887 | int dayofyear = dt.date().dayOfYear(); |
888 | int year = dt.date().year(); | 888 | int year = dt.date().year(); |
889 | int add = 0; | 889 | int add = 0; |
890 | if ( QDate::leapYear(year) ) | 890 | if ( QDate::leapYear(year) ) |
891 | add = 1; | 891 | add = 1; |
892 | QDate date ( year,1,1 ); | 892 | QDate date ( year,1,1 ); |
893 | if ( daylightEnd > 59 ) | 893 | if ( daylightEnd > 59 ) |
894 | d_end = daylightEnd +add; | 894 | d_end = daylightEnd +add; |
895 | else | 895 | else |
896 | d_end = daylightEnd; | 896 | d_end = daylightEnd; |
897 | if ( daylightStart > 59 ) | 897 | if ( daylightStart > 59 ) |
898 | d_start = daylightStart +add; | 898 | d_start = daylightStart +add; |
899 | else | 899 | else |
900 | d_start = daylightStart; | 900 | d_start = daylightStart; |
901 | QDate s_date = date.addDays( d_start -1 ); | 901 | QDate s_date = date.addDays( d_start -1 ); |
902 | QDate e_date = date.addDays( d_end -1 ); | 902 | QDate e_date = date.addDays( d_end -1 ); |
903 | int dof = s_date.dayOfWeek(); | 903 | int dof = s_date.dayOfWeek(); |
904 | if ( dof < 7 ) | 904 | if ( dof < 7 ) |
905 | s_date = s_date.addDays( -dof ); | 905 | s_date = s_date.addDays( -dof ); |
906 | dof = e_date.dayOfWeek(); | 906 | dof = e_date.dayOfWeek(); |
907 | if ( dof < 7 ) | 907 | if ( dof < 7 ) |
908 | e_date = e_date.addDays( -dof ); | 908 | e_date = e_date.addDays( -dof ); |
909 | QTime startTime ( 3,0,0 ); | 909 | QTime startTime ( 3,0,0 ); |
910 | QDateTime startDt( s_date, startTime ); | 910 | QDateTime startDt( s_date, startTime ); |
911 | QDateTime endDt( e_date, startTime ); | 911 | QDateTime endDt( e_date, startTime ); |
912 | //qDebug("dayligt saving start %s end %s ",startDt.toString().latin1(),endDt.toString().latin1( )); | 912 | //qDebug("dayligt saving start %s end %s ",startDt.toString().latin1(),endDt.toString().latin1( )); |
913 | if ( mSouthDaylight ) { | 913 | if ( mSouthDaylight ) { |
914 | if ( ! ( endDt < dt && dt < startDt) ) | 914 | if ( ! ( endDt < dt && dt < startDt) ) |
915 | addDaylight = true; | 915 | addDaylight = true; |
916 | } else { | 916 | } else { |
917 | if ( startDt < dt && dt < endDt ) | 917 | if ( startDt < dt && dt < endDt ) |
918 | addDaylight = true; | 918 | addDaylight = true; |
919 | 919 | ||
920 | 920 | ||
921 | } | 921 | } |
922 | } | 922 | } |
923 | int addMin = 0; | 923 | int addMin = 0; |
924 | if ( addDaylight ) | 924 | if ( addDaylight ) |
925 | addMin = 60; | 925 | addMin = 60; |
926 | return mTimeZoneOffset + addMin; | 926 | return mTimeZoneOffset + addMin; |