author | zautrix <zautrix> | 2005-03-21 14:42:01 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-03-21 14:42:01 (UTC) |
commit | 6e5a0c6cff04fff115e63b62537c5274dc7a5564 (patch) (unidiff) | |
tree | 5d40aadc33768fa31036aefdf965462248358361 | |
parent | 3bd97904e69bf586122ad82d279c37db0861eefb (diff) | |
download | kdepimpi-6e5a0c6cff04fff115e63b62537c5274dc7a5564.zip kdepimpi-6e5a0c6cff04fff115e63b62537c5274dc7a5564.tar.gz kdepimpi-6e5a0c6cff04fff115e63b62537c5274dc7a5564.tar.bz2 |
fix
-rw-r--r-- | korganizer/kodaymatrix.cpp | 5 | ||||
-rw-r--r-- | korganizer/koeventviewer.cpp | 4 | ||||
-rw-r--r-- | libkcal/kincidenceformatter.cpp | 4 |
3 files changed, 7 insertions, 6 deletions
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp index 493382d..a776cb6 100644 --- a/korganizer/kodaymatrix.cpp +++ b/korganizer/kodaymatrix.cpp | |||
@@ -1,923 +1,924 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Eitzenberger Thomas <thomas.eitzenberger@siemens.at> | 3 | Copyright (c) 2001 Eitzenberger Thomas <thomas.eitzenberger@siemens.at> |
4 | Parts of the source code have been copied from kdpdatebutton.cpp | 4 | Parts of the source code have been copied from kdpdatebutton.cpp |
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 ode for Qt in the source distribution. | 22 | without including the source ode for Qt in the source distribution. |
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include <qevent.h> | 25 | #include <qevent.h> |
26 | #include <qpainter.h> | 26 | #include <qpainter.h> |
27 | #include <qptrlist.h> | 27 | #include <qptrlist.h> |
28 | #include <qtimer.h> | 28 | #include <qtimer.h> |
29 | #include <qwhatsthis.h> | 29 | #include <qwhatsthis.h> |
30 | 30 | ||
31 | #include <kglobal.h> | 31 | #include <kglobal.h> |
32 | #include <kdebug.h> | 32 | #include <kdebug.h> |
33 | #include <klocale.h> | 33 | #include <klocale.h> |
34 | 34 | ||
35 | #include <libkcal/vcaldrag.h> | 35 | #include <libkcal/vcaldrag.h> |
36 | #include <libkcal/icaldrag.h> | 36 | #include <libkcal/icaldrag.h> |
37 | #include <libkcal/dndfactory.h> | 37 | #include <libkcal/dndfactory.h> |
38 | #include <libkcal/calendarresources.h> | 38 | #include <libkcal/calendarresources.h> |
39 | #include <libkcal/resourcecalendar.h> | 39 | #include <libkcal/resourcecalendar.h> |
40 | #include <kresources/resourceselectdialog.h> | 40 | #include <kresources/resourceselectdialog.h> |
41 | 41 | ||
42 | #include <kcalendarsystem.h> | 42 | #include <kcalendarsystem.h> |
43 | 43 | ||
44 | #ifndef KORG_NOPLUGINS | 44 | #ifndef KORG_NOPLUGINS |
45 | #include "kocore.h" | 45 | #include "kocore.h" |
46 | #endif | 46 | #endif |
47 | #include "koprefs.h" | 47 | #include "koprefs.h" |
48 | #include "koglobals.h" | 48 | #include "koglobals.h" |
49 | 49 | ||
50 | #include "kodaymatrix.h" | 50 | #include "kodaymatrix.h" |
51 | 51 | ||
52 | // ============================================================================ | 52 | // ============================================================================ |
53 | // D Y N A M I C T I P | 53 | // D Y N A M I C T I P |
54 | // ============================================================================ | 54 | // ============================================================================ |
55 | 55 | ||
56 | DynamicTip::DynamicTip( QWidget * parent ) | 56 | DynamicTip::DynamicTip( QWidget * parent ) |
57 | : QToolTip( parent ) | 57 | : QToolTip( parent ) |
58 | { | 58 | { |
59 | matrix = (KODayMatrix*)parent; | 59 | matrix = (KODayMatrix*)parent; |
60 | } | 60 | } |
61 | 61 | ||
62 | class KODaymatrixWhatsThis :public QWhatsThis | 62 | class KODaymatrixWhatsThis :public QWhatsThis |
63 | { | 63 | { |
64 | public: | 64 | public: |
65 | KODaymatrixWhatsThis( KODayMatrix* view ) : QWhatsThis( view ),_view (view) { ;}; | 65 | KODaymatrixWhatsThis( KODayMatrix* view ) : QWhatsThis( view ),_view (view) { ;}; |
66 | ~KODaymatrixWhatsThis() { ; }; | 66 | ~KODaymatrixWhatsThis() { ; }; |
67 | 67 | ||
68 | protected: | 68 | protected: |
69 | virtual QString text( const QPoint& p ) | 69 | virtual QString text( const QPoint& p ) |
70 | { | 70 | { |
71 | return _view->getWhatsThisText( p ) ; | 71 | return _view->getWhatsThisText( p ) ; |
72 | } | 72 | } |
73 | private: | 73 | private: |
74 | KODayMatrix * _view; | 74 | KODayMatrix * _view; |
75 | }; | 75 | }; |
76 | 76 | ||
77 | void DynamicTip::maybeTip( const QPoint &pos ) | 77 | void DynamicTip::maybeTip( const QPoint &pos ) |
78 | { | 78 | { |
79 | //calculate which cell of the matrix the mouse is in | 79 | //calculate which cell of the matrix the mouse is in |
80 | QRect sz = matrix->frameRect(); | 80 | QRect sz = matrix->frameRect(); |
81 | int dheight = sz.height()*7 / 42; | 81 | int dheight = sz.height()*7 / 42; |
82 | int dwidth = sz.width() / 7; | 82 | int dwidth = sz.width() / 7; |
83 | int row = pos.y()/dheight; | 83 | int row = pos.y()/dheight; |
84 | int col = pos.x()/dwidth; | 84 | int col = pos.x()/dwidth; |
85 | 85 | ||
86 | QRect rct(col*dwidth, row*dheight, dwidth, dheight); | 86 | QRect rct(col*dwidth, row*dheight, dwidth, dheight); |
87 | 87 | ||
88 | // kdDebug() << "DynamicTip::maybeTip matrix cell index [" << | 88 | // kdDebug() << "DynamicTip::maybeTip matrix cell index [" << |
89 | // col << "][" << row << "] => " <<(col+row*7) << endl; | 89 | // col << "][" << row << "] => " <<(col+row*7) << endl; |
90 | 90 | ||
91 | //show holiday names only | 91 | //show holiday names only |
92 | QString str = matrix->getHolidayLabel(col+row*7); | 92 | QString str = matrix->getHolidayLabel(col+row*7); |
93 | if (str.isEmpty()) return; | 93 | if (str.isEmpty()) return; |
94 | tip(rct, str); | 94 | tip(rct, str); |
95 | } | 95 | } |
96 | 96 | ||
97 | 97 | ||
98 | // ============================================================================ | 98 | // ============================================================================ |
99 | // K O D A Y M A T R I X | 99 | // K O D A Y M A T R I X |
100 | // ============================================================================ | 100 | // ============================================================================ |
101 | 101 | ||
102 | const int KODayMatrix::NOSELECTION = -1000; | 102 | const int KODayMatrix::NOSELECTION = -1000; |
103 | const int KODayMatrix::NUMDAYS = 42; | 103 | const int KODayMatrix::NUMDAYS = 42; |
104 | 104 | ||
105 | KODayMatrix::KODayMatrix( QWidget *parent, const char *name ) | 105 | KODayMatrix::KODayMatrix( QWidget *parent, const char *name ) |
106 | : QFrame( parent, name ), mCalendar( 0 ) | 106 | : QFrame( parent, name ), mCalendar( 0 ) |
107 | 107 | ||
108 | #if 0 | 108 | #if 0 |
109 | KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name) : | 109 | KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name) : |
110 | QFrame(parent, name) | 110 | QFrame(parent, name) |
111 | #endif | 111 | #endif |
112 | { | 112 | { |
113 | mKODaymatrixWhatsThis = new KODaymatrixWhatsThis(this); | 113 | mKODaymatrixWhatsThis = new KODaymatrixWhatsThis(this); |
114 | mPendingUpdateBeforeRepaint = false; | 114 | mPendingUpdateBeforeRepaint = false; |
115 | mouseDown = false; | 115 | mouseDown = false; |
116 | // initialize dynamic arrays | 116 | // initialize dynamic arrays |
117 | bDays.resize ( NUMDAYS ); | 117 | bDays.resize ( NUMDAYS ); |
118 | days = new QDate[NUMDAYS]; | 118 | days = new QDate[NUMDAYS]; |
119 | daylbls = new QString[NUMDAYS]; | 119 | daylbls = new QString[NUMDAYS]; |
120 | events = new int[NUMDAYS]; | 120 | events = new int[NUMDAYS]; |
121 | mToolTip = new DynamicTip(this); | 121 | mToolTip = new DynamicTip(this); |
122 | 122 | ||
123 | // set default values used for drawing the matrix | 123 | // set default values used for drawing the matrix |
124 | mDefaultBackColor = palette().active().base(); | 124 | mDefaultBackColor = palette().active().base(); |
125 | mDefaultTextColor = palette().active().foreground(); | 125 | mDefaultTextColor = palette().active().foreground(); |
126 | mDefaultTextColorShaded = getShadedColor(mDefaultTextColor); | 126 | mDefaultTextColorShaded = getShadedColor(mDefaultTextColor); |
127 | mHolidayColorShaded = getShadedColor(KOPrefs::instance()->mHolidayColor); | 127 | mHolidayColorShaded = getShadedColor(KOPrefs::instance()->mHolidayColor); |
128 | mSelectedDaysColor = QColor("white"); | 128 | mSelectedDaysColor = QColor("white"); |
129 | mTodayMarginWidth = 2; | 129 | mTodayMarginWidth = 2; |
130 | mSelEnd = mSelStart = NOSELECTION; | 130 | mSelEnd = mSelStart = NOSELECTION; |
131 | 131 | ||
132 | setAcceptDrops(true); | 132 | setAcceptDrops(true); |
133 | //setFont( QFont("Arial", 10) ); | 133 | //setFont( QFont("Arial", 10) ); |
134 | 134 | ||
135 | mUpdateTimer = new QTimer( this ); | 135 | mUpdateTimer = new QTimer( this ); |
136 | connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( updateViewTimed() )); | 136 | connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( updateViewTimed() )); |
137 | mRepaintTimer = new QTimer( this ); | 137 | mRepaintTimer = new QTimer( this ); |
138 | connect (mRepaintTimer ,SIGNAL(timeout()), this, SLOT ( repaintViewTimed() )); | 138 | connect (mRepaintTimer ,SIGNAL(timeout()), this, SLOT ( repaintViewTimed() )); |
139 | mDayChanged = false; | 139 | mDayChanged = false; |
140 | updateView(); | 140 | updateView(); |
141 | } | 141 | } |
142 | QString KODayMatrix::getWhatsThisText( QPoint p ) | 142 | QString KODayMatrix::getWhatsThisText( QPoint p ) |
143 | { | 143 | { |
144 | 144 | ||
145 | int tmp = getDayIndexFrom(p.x(), p.y()); | 145 | int tmp = getDayIndexFrom(p.x(), p.y()); |
146 | if ( tmp < 0 || tmp > NUMDAYS-1 || !mCalendar ) | 146 | if ( tmp < 0 || tmp > NUMDAYS-1 || !mCalendar ) |
147 | return QString(); | 147 | return QString(); |
148 | QDate mDate = days[tmp]; | 148 | QDate mDate = days[tmp]; |
149 | QPtrList<Event> eventlist = mCalendar->events(mDate); | 149 | QPtrList<Event> eventlist = mCalendar->events(mDate); |
150 | Event *event; | 150 | Event *event; |
151 | QStringList mToolTip; | 151 | QStringList mToolTip; |
152 | for(event=eventlist.first();event != 0;event=eventlist.next()) { | 152 | for(event=eventlist.first();event != 0;event=eventlist.next()) { |
153 | QString mToolTipText; | 153 | QString mToolTipText; |
154 | QString text; | 154 | QString text; |
155 | int multiday = 0;// 1 = start, 2 = midddle, 3 = end day | 155 | int multiday = 0;// 1 = start, 2 = midddle, 3 = end day |
156 | if (event->isMultiDay()) { | 156 | if (event->isMultiDay()) { |
157 | QString prefix = "<->";multiday = 2; | 157 | QString prefix = "<->";multiday = 2; |
158 | QString time; | 158 | QString time; |
159 | if ( event->doesRecur() ) { | 159 | if ( event->doesRecur() ) { |
160 | if ( event->recursOn( mDate) ) { | 160 | if ( event->recursOn( mDate) ) { |
161 | prefix ="->" ;multiday = 1; | 161 | prefix ="->" ;multiday = 1; |
162 | } | 162 | } |
163 | else { | 163 | else { |
164 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); | 164 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); |
165 | if ( event->recursOn( mDate.addDays( -days)) ) { | 165 | if ( event->recursOn( mDate.addDays( -days)) ) { |
166 | prefix ="<-" ;multiday = 3; | 166 | prefix ="<-" ;multiday = 3; |
167 | } | 167 | } |
168 | } | 168 | } |
169 | } else { | 169 | } else { |
170 | if (mDate == event->dtStart().date()) { | 170 | if (mDate == event->dtStart().date()) { |
171 | prefix ="->" ;multiday = 1; | 171 | prefix ="->" ;multiday = 1; |
172 | } else if (mDate == event->dtEnd().date()) { | 172 | } else if (mDate == event->dtEnd().date()) { |
173 | prefix ="<-" ;multiday = 3; | 173 | prefix ="<-" ;multiday = 3; |
174 | } | 174 | } |
175 | } | 175 | } |
176 | if ( !event->doesFloat() ) { | 176 | if ( !event->doesFloat() ) { |
177 | if ( mDate == event->dtStart().date () ) | 177 | if ( mDate == event->dtStart().date () ) |
178 | time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; | 178 | time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; |
179 | else if ( mDate == event->dtEnd().date () ) | 179 | else if ( mDate == event->dtEnd().date () ) |
180 | time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; | 180 | time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; |
181 | 181 | ||
182 | } | 182 | } |
183 | text = time + event->summary(); | 183 | text = time + event->summary(); |
184 | mToolTipText += prefix + text; | 184 | mToolTipText += prefix + text; |
185 | } else { | 185 | } else { |
186 | if (event->doesFloat()) { | 186 | if (event->doesFloat()) { |
187 | text = event->summary(); | 187 | text = event->summary(); |
188 | mToolTipText += text; | 188 | mToolTipText += text; |
189 | } | 189 | } |
190 | else { | 190 | else { |
191 | text = KGlobal::locale()->formatTime(event->dtStart().time()); | 191 | text = KGlobal::locale()->formatTime(event->dtStart().time()); |
192 | text += " " + event->summary(); | 192 | text += " " + event->summary(); |
193 | mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); | 193 | mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); |
194 | } | 194 | } |
195 | } | 195 | } |
196 | if ( !event->location().isEmpty() ) | 196 | if ( !event->location().isEmpty() ) |
197 | mToolTipText += " (" + event->location() + ")"; | 197 | mToolTipText += " (" + event->location() + ")"; |
198 | #if QT_VERSION >= 0x030000 | 198 | #if QT_VERSION >= 0x030000 |
199 | mToolTipText.replace( '<' , "<" ); | 199 | mToolTipText.replace( '<' , "<" ); |
200 | mToolTipText.replace( '>' , ">" ); | 200 | mToolTipText.replace( '>' , ">" ); |
201 | #else | 201 | #else |
202 | if ( mToolTipText.find ('<') > 0 ) { | 202 | if ( mToolTipText.find ('<') >= 0 ) { |
203 | mToolTipText.replace( QRegExp("<") , "<" ); | 203 | mToolTipText.replace( QRegExp("<") , "<" ); |
204 | } | 204 | } |
205 | if ( mToolTipText.find ('>') > 0 ) { | 205 | if ( mToolTipText.find ('>') >= 0 ) { |
206 | mToolTipText.replace( QRegExp(">") , ">" ); | 206 | mToolTipText.replace( QRegExp(">") , ">" ); |
207 | } | 207 | } |
208 | #endif | 208 | #endif |
209 | //qDebug("TTT: %s ", mToolTipText.latin1()); | ||
209 | mToolTip.append( mToolTipText ); | 210 | mToolTip.append( mToolTipText ); |
210 | } | 211 | } |
211 | mToolTip.sort(); | 212 | mToolTip.sort(); |
212 | return "<b>"+KGlobal::locale()->formatDate(days[tmp]) + "</b><br>" + mToolTip.join("<br>"); | 213 | return "<b>"+KGlobal::locale()->formatDate(days[tmp]) + "</b><br>" + mToolTip.join("<br>"); |
213 | } | 214 | } |
214 | void KODayMatrix::setCalendar( Calendar *cal ) | 215 | void KODayMatrix::setCalendar( Calendar *cal ) |
215 | { | 216 | { |
216 | mCalendar = cal; | 217 | mCalendar = cal; |
217 | 218 | ||
218 | setAcceptDrops( mCalendar ); | 219 | setAcceptDrops( mCalendar ); |
219 | 220 | ||
220 | updateEvents(); | 221 | updateEvents(); |
221 | } | 222 | } |
222 | 223 | ||
223 | QColor KODayMatrix::getShadedColor(QColor color) | 224 | QColor KODayMatrix::getShadedColor(QColor color) |
224 | { | 225 | { |
225 | QColor shaded; | 226 | QColor shaded; |
226 | int h=0; | 227 | int h=0; |
227 | int s=0; | 228 | int s=0; |
228 | int v=0; | 229 | int v=0; |
229 | color.hsv(&h,&s,&v); | 230 | color.hsv(&h,&s,&v); |
230 | s = s/4; | 231 | s = s/4; |
231 | v = 192+v/4; | 232 | v = 192+v/4; |
232 | shaded.setHsv(h,s,v); | 233 | shaded.setHsv(h,s,v); |
233 | 234 | ||
234 | return shaded; | 235 | return shaded; |
235 | } | 236 | } |
236 | 237 | ||
237 | KODayMatrix::~KODayMatrix() | 238 | KODayMatrix::~KODayMatrix() |
238 | { | 239 | { |
239 | // delete mKODaymatrixWhatsThis; | 240 | // delete mKODaymatrixWhatsThis; |
240 | delete [] days; | 241 | delete [] days; |
241 | delete [] daylbls; | 242 | delete [] daylbls; |
242 | delete [] events; | 243 | delete [] events; |
243 | delete mToolTip; | 244 | delete mToolTip; |
244 | } | 245 | } |
245 | 246 | ||
246 | /* | 247 | /* |
247 | void KODayMatrix::setStartDate(QDate start) | 248 | void KODayMatrix::setStartDate(QDate start) |
248 | { | 249 | { |
249 | updateView(start); | 250 | updateView(start); |
250 | } | 251 | } |
251 | */ | 252 | */ |
252 | 253 | ||
253 | void KODayMatrix::addSelectedDaysTo(DateList& selDays) | 254 | void KODayMatrix::addSelectedDaysTo(DateList& selDays) |
254 | { | 255 | { |
255 | 256 | ||
256 | if (mSelStart == NOSELECTION) { | 257 | if (mSelStart == NOSELECTION) { |
257 | return; | 258 | return; |
258 | } | 259 | } |
259 | 260 | ||
260 | //cope with selection being out of matrix limits at top (< 0) | 261 | //cope with selection being out of matrix limits at top (< 0) |
261 | int i0 = mSelStart; | 262 | int i0 = mSelStart; |
262 | if (i0 < 0) { | 263 | if (i0 < 0) { |
263 | for (int i = i0; i < 0; i++) { | 264 | for (int i = i0; i < 0; i++) { |
264 | selDays.append(days[0].addDays(i)); | 265 | selDays.append(days[0].addDays(i)); |
265 | } | 266 | } |
266 | i0 = 0; | 267 | i0 = 0; |
267 | } | 268 | } |
268 | 269 | ||
269 | //cope with selection being out of matrix limits at bottom (> NUMDAYS-1) | 270 | //cope with selection being out of matrix limits at bottom (> NUMDAYS-1) |
270 | if (mSelEnd > NUMDAYS-1) { | 271 | if (mSelEnd > NUMDAYS-1) { |
271 | for (int i = i0; i <= NUMDAYS-1; i++) { | 272 | for (int i = i0; i <= NUMDAYS-1; i++) { |
272 | selDays.append(days[i]); | 273 | selDays.append(days[i]); |
273 | } | 274 | } |
274 | for (int i = NUMDAYS; i < mSelEnd; i++) { | 275 | for (int i = NUMDAYS; i < mSelEnd; i++) { |
275 | selDays.append(days[0].addDays(i)); | 276 | selDays.append(days[0].addDays(i)); |
276 | } | 277 | } |
277 | 278 | ||
278 | // apply normal routine to selection being entirely within matrix limits | 279 | // apply normal routine to selection being entirely within matrix limits |
279 | } else { | 280 | } else { |
280 | for (int i = i0; i <= mSelEnd; i++) { | 281 | for (int i = i0; i <= mSelEnd; i++) { |
281 | selDays.append(days[i]); | 282 | selDays.append(days[i]); |
282 | } | 283 | } |
283 | } | 284 | } |
284 | } | 285 | } |
285 | 286 | ||
286 | void KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end) | 287 | void KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end) |
287 | { | 288 | { |
288 | mSelStart = startdate.daysTo(start); | 289 | mSelStart = startdate.daysTo(start); |
289 | if ( mSelStart < 0 ) | 290 | if ( mSelStart < 0 ) |
290 | mSelStart = 0; | 291 | mSelStart = 0; |
291 | mSelEnd = startdate.daysTo(end); | 292 | mSelEnd = startdate.daysTo(end); |
292 | if ( mSelEnd < 0 ) | 293 | if ( mSelEnd < 0 ) |
293 | clearSelection(); | 294 | clearSelection(); |
294 | } | 295 | } |
295 | void KODayMatrix::clearSelection() | 296 | void KODayMatrix::clearSelection() |
296 | { | 297 | { |
297 | mSelEnd = mSelStart = NOSELECTION; | 298 | mSelEnd = mSelStart = NOSELECTION; |
298 | } | 299 | } |
299 | 300 | ||
300 | 301 | ||
301 | void KODayMatrix::recalculateToday() | 302 | void KODayMatrix::recalculateToday() |
302 | { | 303 | { |
303 | today = -1; | 304 | today = -1; |
304 | for (int i=0; i<NUMDAYS; i++) { | 305 | for (int i=0; i<NUMDAYS; i++) { |
305 | events[i] = 0; | 306 | events[i] = 0; |
306 | days[i] = startdate.addDays(i); | 307 | days[i] = startdate.addDays(i); |
307 | daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] )); | 308 | daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] )); |
308 | 309 | ||
309 | // if today is in the currently displayed month, hilight today | 310 | // if today is in the currently displayed month, hilight today |
310 | if (days[i].year() == QDate::currentDate().year() && | 311 | if (days[i].year() == QDate::currentDate().year() && |
311 | days[i].month() == QDate::currentDate().month() && | 312 | days[i].month() == QDate::currentDate().month() && |
312 | days[i].day() == QDate::currentDate().day()) { | 313 | days[i].day() == QDate::currentDate().day()) { |
313 | today = i; | 314 | today = i; |
314 | } | 315 | } |
315 | } | 316 | } |
316 | // qDebug(QString("Today is visible at %1.").arg(today)); | 317 | // qDebug(QString("Today is visible at %1.").arg(today)); |
317 | } | 318 | } |
318 | 319 | ||
319 | void KODayMatrix::updateView() | 320 | void KODayMatrix::updateView() |
320 | { | 321 | { |
321 | updateView(startdate); | 322 | updateView(startdate); |
322 | } | 323 | } |
323 | void KODayMatrix::repaintViewTimed() | 324 | void KODayMatrix::repaintViewTimed() |
324 | { | 325 | { |
325 | mRepaintTimer->stop(); | 326 | mRepaintTimer->stop(); |
326 | repaint(false); | 327 | repaint(false); |
327 | } | 328 | } |
328 | void KODayMatrix::updateViewTimed() | 329 | void KODayMatrix::updateViewTimed() |
329 | { | 330 | { |
330 | mUpdateTimer->stop(); | 331 | mUpdateTimer->stop(); |
331 | if ( !mCalendar ) { | 332 | if ( !mCalendar ) { |
332 | qDebug("NOT CAL "); | 333 | qDebug("NOT CAL "); |
333 | return; | 334 | return; |
334 | } | 335 | } |
335 | //qDebug("KODayMatrix::updateViewTimed "); | 336 | //qDebug("KODayMatrix::updateViewTimed "); |
336 | for(int i = 0; i < NUMDAYS; i++) { | 337 | for(int i = 0; i < NUMDAYS; i++) { |
337 | // if events are set for the day then remember to draw it bold | 338 | // if events are set for the day then remember to draw it bold |
338 | QPtrList<Event> eventlist = mCalendar->events(days[i]); | 339 | QPtrList<Event> eventlist = mCalendar->events(days[i]); |
339 | Event *event; | 340 | Event *event; |
340 | int numEvents = eventlist.count(); | 341 | int numEvents = eventlist.count(); |
341 | QString holiStr = ""; | 342 | QString holiStr = ""; |
342 | bDays.clearBit(i); | 343 | bDays.clearBit(i); |
343 | for(event=eventlist.first();event != 0;event=eventlist.next()) { | 344 | for(event=eventlist.first();event != 0;event=eventlist.next()) { |
344 | ushort recurType = event->recurrence()->doesRecur(); | 345 | ushort recurType = event->recurrence()->doesRecur(); |
345 | if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || | 346 | if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || |
346 | (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { | 347 | (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { |
347 | numEvents--; | 348 | numEvents--; |
348 | } | 349 | } |
349 | if ( event->categories().contains( i18n("Holiday") ) || event->categories().contains( "Holiday" )) { | 350 | if ( event->categories().contains( i18n("Holiday") ) || event->categories().contains( "Holiday" )) { |
350 | if ( !holiStr.isEmpty() ) | 351 | if ( !holiStr.isEmpty() ) |
351 | holiStr += "\n"; | 352 | holiStr += "\n"; |
352 | holiStr += event->summary(); | 353 | holiStr += event->summary(); |
353 | if ( !event->location().isEmpty() ) | 354 | if ( !event->location().isEmpty() ) |
354 | holiStr += " (" + event->location() + ")"; | 355 | holiStr += " (" + event->location() + ")"; |
355 | } | 356 | } |
356 | if ( event->categories().contains( i18n("Birthday") ) || event->categories().contains( "Birthday" )) { | 357 | if ( event->categories().contains( i18n("Birthday") ) || event->categories().contains( "Birthday" )) { |
357 | if ( !holiStr.isEmpty() ) | 358 | if ( !holiStr.isEmpty() ) |
358 | holiStr += "\n"; | 359 | holiStr += "\n"; |
359 | holiStr += i18n("Birthday") + ": "+event->summary(); | 360 | holiStr += i18n("Birthday") + ": "+event->summary(); |
360 | if ( !event->location().isEmpty() ) | 361 | if ( !event->location().isEmpty() ) |
361 | holiStr += " (" + event->location() + ")"; | 362 | holiStr += " (" + event->location() + ")"; |
362 | bDays.setBit(i); | 363 | bDays.setBit(i); |
363 | } | 364 | } |
364 | } | 365 | } |
365 | events[i] = numEvents; | 366 | events[i] = numEvents; |
366 | //if it is a holy day then draw it red. Sundays are consider holidays, too | 367 | //if it is a holy day then draw it red. Sundays are consider holidays, too |
367 | if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) || | 368 | if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) || |
368 | !holiStr.isEmpty()) { | 369 | !holiStr.isEmpty()) { |
369 | mHolidays[i] = holiStr; | 370 | mHolidays[i] = holiStr; |
370 | } else { | 371 | } else { |
371 | mHolidays[i] = QString::null; | 372 | mHolidays[i] = QString::null; |
372 | } | 373 | } |
373 | } | 374 | } |
374 | if ( ! mPendingUpdateBeforeRepaint ) | 375 | if ( ! mPendingUpdateBeforeRepaint ) |
375 | repaint(false); | 376 | repaint(false); |
376 | } | 377 | } |
377 | void KODayMatrix::updateView(QDate actdate) | 378 | void KODayMatrix::updateView(QDate actdate) |
378 | { | 379 | { |
379 | 380 | ||
380 | if ( ! actdate.isValid() ) { | 381 | if ( ! actdate.isValid() ) { |
381 | //qDebug("date not valid "); | 382 | //qDebug("date not valid "); |
382 | return; | 383 | return; |
383 | } | 384 | } |
384 | mDayChanged = false; | 385 | mDayChanged = false; |
385 | //flag to indicate if the starting day of the matrix has changed by this call | 386 | //flag to indicate if the starting day of the matrix has changed by this call |
386 | //mDayChanged = false; | 387 | //mDayChanged = false; |
387 | // if a new startdate is to be set then apply Cornelius's calculation | 388 | // if a new startdate is to be set then apply Cornelius's calculation |
388 | // of the first day to be shown | 389 | // of the first day to be shown |
389 | if (actdate != startdate) { | 390 | if (actdate != startdate) { |
390 | // reset index of selection according to shift of starting date from startdate to actdate | 391 | // reset index of selection according to shift of starting date from startdate to actdate |
391 | if (mSelStart != NOSELECTION) { | 392 | if (mSelStart != NOSELECTION) { |
392 | int tmp = actdate.daysTo(startdate); | 393 | int tmp = actdate.daysTo(startdate); |
393 | //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl; | 394 | //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl; |
394 | // shift selection if new one would be visible at least partly ! | 395 | // shift selection if new one would be visible at least partly ! |
395 | 396 | ||
396 | if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) { | 397 | if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) { |
397 | // nested if is required for next X display pushed from a different month - correction required | 398 | // nested if is required for next X display pushed from a different month - correction required |
398 | // otherwise, for month forward and backward, it must be avoided | 399 | // otherwise, for month forward and backward, it must be avoided |
399 | if( mSelStart > NUMDAYS || mSelStart < 0 ) | 400 | if( mSelStart > NUMDAYS || mSelStart < 0 ) |
400 | mSelStart = mSelStart + tmp; | 401 | mSelStart = mSelStart + tmp; |
401 | if( mSelEnd > NUMDAYS || mSelEnd < 0 ) | 402 | if( mSelEnd > NUMDAYS || mSelEnd < 0 ) |
402 | mSelEnd = mSelEnd + tmp; | 403 | mSelEnd = mSelEnd + tmp; |
403 | } | 404 | } |
404 | } | 405 | } |
405 | startdate = actdate; | 406 | startdate = actdate; |
406 | mDayChanged = true; | 407 | mDayChanged = true; |
407 | recalculateToday(); | 408 | recalculateToday(); |
408 | } | 409 | } |
409 | //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() ); | 410 | //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() ); |
410 | if ( !isVisible() ) { | 411 | if ( !isVisible() ) { |
411 | mPendingUpdateBeforeRepaint = true; | 412 | mPendingUpdateBeforeRepaint = true; |
412 | } else { | 413 | } else { |
413 | #ifdef DESKTOP_VERSION | 414 | #ifdef DESKTOP_VERSION |
414 | //mRepaintTimer->start( 100 ); | 415 | //mRepaintTimer->start( 100 ); |
415 | mUpdateTimer->start( 100 ); | 416 | mUpdateTimer->start( 100 ); |
416 | #else | 417 | #else |
417 | mRepaintTimer->start( 350 ); | 418 | mRepaintTimer->start( 350 ); |
418 | mUpdateTimer->start( 1200 ); | 419 | mUpdateTimer->start( 1200 ); |
419 | #endif | 420 | #endif |
420 | } | 421 | } |
421 | } | 422 | } |
422 | void KODayMatrix::updateEvents() | 423 | void KODayMatrix::updateEvents() |
423 | { | 424 | { |
424 | if ( !mCalendar ) return; | 425 | if ( !mCalendar ) return; |
425 | 426 | ||
426 | for( int i = 0; i < NUMDAYS; i++ ) { | 427 | for( int i = 0; i < NUMDAYS; i++ ) { |
427 | // if events are set for the day then remember to draw it bold | 428 | // if events are set for the day then remember to draw it bold |
428 | QPtrList<Event> eventlist = mCalendar->events( days[ i ] ); | 429 | QPtrList<Event> eventlist = mCalendar->events( days[ i ] ); |
429 | int numEvents = eventlist.count(); | 430 | int numEvents = eventlist.count(); |
430 | Event *event; | 431 | Event *event; |
431 | for( event = eventlist.first(); event != 0;event=eventlist.next()) { | 432 | for( event = eventlist.first(); event != 0;event=eventlist.next()) { |
432 | ushort recurType = event->doesRecur(); | 433 | ushort recurType = event->doesRecur(); |
433 | 434 | ||
434 | if ( ( recurType == Recurrence::rDaily && | 435 | if ( ( recurType == Recurrence::rDaily && |
435 | !KOPrefs::instance()->mDailyRecur ) || | 436 | !KOPrefs::instance()->mDailyRecur ) || |
436 | ( recurType == Recurrence::rWeekly && | 437 | ( recurType == Recurrence::rWeekly && |
437 | !KOPrefs::instance()->mWeeklyRecur ) ) { | 438 | !KOPrefs::instance()->mWeeklyRecur ) ) { |
438 | numEvents--; | 439 | numEvents--; |
439 | } | 440 | } |
440 | } | 441 | } |
441 | events[ i ] = numEvents; | 442 | events[ i ] = numEvents; |
442 | } | 443 | } |
443 | } | 444 | } |
444 | 445 | ||
445 | const QDate& KODayMatrix::getDate(int offset) | 446 | const QDate& KODayMatrix::getDate(int offset) |
446 | { | 447 | { |
447 | if (offset < 0 || offset > NUMDAYS-1) { | 448 | if (offset < 0 || offset > NUMDAYS-1) { |
448 | qDebug("Wrong offset2 %d", offset); | 449 | qDebug("Wrong offset2 %d", offset); |
449 | return days[0]; | 450 | return days[0]; |
450 | } | 451 | } |
451 | return days[offset]; | 452 | return days[offset]; |
452 | } | 453 | } |
453 | 454 | ||
454 | QString KODayMatrix::getHolidayLabel(int offset) | 455 | QString KODayMatrix::getHolidayLabel(int offset) |
455 | { | 456 | { |
456 | if (offset < 0 || offset > NUMDAYS-1) { | 457 | if (offset < 0 || offset > NUMDAYS-1) { |
457 | qDebug("Wrong offset1 %d", offset); | 458 | qDebug("Wrong offset1 %d", offset); |
458 | return QString(); | 459 | return QString(); |
459 | } | 460 | } |
460 | return mHolidays[offset]; | 461 | return mHolidays[offset]; |
461 | } | 462 | } |
462 | 463 | ||
463 | int KODayMatrix::getDayIndexFrom(int x, int y) | 464 | int KODayMatrix::getDayIndexFrom(int x, int y) |
464 | { | 465 | { |
465 | int colModulo = (width()-2) % 7; | 466 | int colModulo = (width()-2) % 7; |
466 | int rowModulo = (height()-2) % 6; | 467 | int rowModulo = (height()-2) % 6; |
467 | #if 0 | 468 | #if 0 |
468 | return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ? | 469 | return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ? |
469 | 6 - x/daysize.width() : x/daysize.width()); | 470 | 6 - x/daysize.width() : x/daysize.width()); |
470 | #endif | 471 | #endif |
471 | int xVal = (x-colModulo/2-2)/daysize.width(); | 472 | int xVal = (x-colModulo/2-2)/daysize.width(); |
472 | int yVal = (y-rowModulo/2-2)/daysize.height(); | 473 | int yVal = (y-rowModulo/2-2)/daysize.height(); |
473 | 474 | ||
474 | 475 | ||
475 | return 7*(yVal) + xVal; | 476 | return 7*(yVal) + xVal; |
476 | 477 | ||
477 | } | 478 | } |
478 | 479 | ||
479 | // ---------------------------------------------------------------------------- | 480 | // ---------------------------------------------------------------------------- |
480 | // M O U S E E V E N T H A N D L I N G | 481 | // M O U S E E V E N T H A N D L I N G |
481 | // ---------------------------------------------------------------------------- | 482 | // ---------------------------------------------------------------------------- |
482 | 483 | ||
483 | void KODayMatrix::mousePressEvent (QMouseEvent* e) | 484 | void KODayMatrix::mousePressEvent (QMouseEvent* e) |
484 | { | 485 | { |
485 | 486 | ||
486 | if ( e->button() == LeftButton ) | 487 | if ( e->button() == LeftButton ) |
487 | mouseDown = true; | 488 | mouseDown = true; |
488 | mSelStart = getDayIndexFrom(e->x(), e->y()); | 489 | mSelStart = getDayIndexFrom(e->x(), e->y()); |
489 | if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1; | 490 | if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1; |
490 | mSelInit = mSelStart; | 491 | mSelInit = mSelStart; |
491 | mSelEnd = mSelStart; | 492 | mSelEnd = mSelStart; |
492 | repaint(false); | 493 | repaint(false); |
493 | } | 494 | } |
494 | 495 | ||
495 | void KODayMatrix::mouseReleaseEvent (QMouseEvent* e) | 496 | void KODayMatrix::mouseReleaseEvent (QMouseEvent* e) |
496 | { | 497 | { |
497 | if ( e->button() == LeftButton ) | 498 | if ( e->button() == LeftButton ) |
498 | if ( ! mouseDown ) { | 499 | if ( ! mouseDown ) { |
499 | return; | 500 | return; |
500 | } | 501 | } |
501 | else | 502 | else |
502 | mouseDown = false; | 503 | mouseDown = false; |
503 | int tmp = getDayIndexFrom(e->x(), e->y()); | 504 | int tmp = getDayIndexFrom(e->x(), e->y()); |
504 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; | 505 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; |
505 | 506 | ||
506 | if (mSelInit > tmp) { | 507 | if (mSelInit > tmp) { |
507 | mSelEnd = mSelInit; | 508 | mSelEnd = mSelInit; |
508 | if (tmp != mSelStart) { | 509 | if (tmp != mSelStart) { |
509 | mSelStart = tmp; | 510 | mSelStart = tmp; |
510 | repaint(false); | 511 | repaint(false); |
511 | } | 512 | } |
512 | } else { | 513 | } else { |
513 | mSelStart = mSelInit; | 514 | mSelStart = mSelInit; |
514 | 515 | ||
515 | //repaint only if selection has changed | 516 | //repaint only if selection has changed |
516 | if (tmp != mSelEnd) { | 517 | if (tmp != mSelEnd) { |
517 | mSelEnd = tmp; | 518 | mSelEnd = tmp; |
518 | repaint(false); | 519 | repaint(false); |
519 | } | 520 | } |
520 | } | 521 | } |
521 | 522 | ||
522 | DateList daylist; | 523 | DateList daylist; |
523 | if ( mSelStart < 0 ) | 524 | if ( mSelStart < 0 ) |
524 | mSelStart = 0; | 525 | mSelStart = 0; |
525 | for (int i = mSelStart; i <= mSelEnd; i++) { | 526 | for (int i = mSelStart; i <= mSelEnd; i++) { |
526 | daylist.append(days[i]); | 527 | daylist.append(days[i]); |
527 | } | 528 | } |
528 | emit selected((const DateList)daylist); | 529 | emit selected((const DateList)daylist); |
529 | 530 | ||
530 | } | 531 | } |
531 | 532 | ||
532 | void KODayMatrix::mouseMoveEvent (QMouseEvent* e) | 533 | void KODayMatrix::mouseMoveEvent (QMouseEvent* e) |
533 | { | 534 | { |
534 | if ( ! mouseDown ) { | 535 | if ( ! mouseDown ) { |
535 | return; | 536 | return; |
536 | } | 537 | } |
537 | int tmp = getDayIndexFrom(e->x(), e->y()); | 538 | int tmp = getDayIndexFrom(e->x(), e->y()); |
538 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; | 539 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; |
539 | 540 | ||
540 | if (mSelInit > tmp) { | 541 | if (mSelInit > tmp) { |
541 | mSelEnd = mSelInit; | 542 | mSelEnd = mSelInit; |
542 | if (tmp != mSelStart) { | 543 | if (tmp != mSelStart) { |
543 | mSelStart = tmp; | 544 | mSelStart = tmp; |
544 | repaint(false); | 545 | repaint(false); |
545 | } | 546 | } |
546 | } else { | 547 | } else { |
547 | mSelStart = mSelInit; | 548 | mSelStart = mSelInit; |
548 | 549 | ||
549 | //repaint only if selection has changed | 550 | //repaint only if selection has changed |
550 | if (tmp != mSelEnd) { | 551 | if (tmp != mSelEnd) { |
551 | mSelEnd = tmp; | 552 | mSelEnd = tmp; |
552 | repaint(false); | 553 | repaint(false); |
553 | } | 554 | } |
554 | } | 555 | } |
555 | } | 556 | } |
556 | 557 | ||
557 | // ---------------------------------------------------------------------------- | 558 | // ---------------------------------------------------------------------------- |
558 | // D R A G ' N D R O P H A N D L I N G | 559 | // D R A G ' N D R O P H A N D L I N G |
559 | // ---------------------------------------------------------------------------- | 560 | // ---------------------------------------------------------------------------- |
560 | 561 | ||
561 | void KODayMatrix::dragEnterEvent(QDragEnterEvent *e) | 562 | void KODayMatrix::dragEnterEvent(QDragEnterEvent *e) |
562 | { | 563 | { |
563 | #ifndef KORG_NODND | 564 | #ifndef KORG_NODND |
564 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { | 565 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { |
565 | e->ignore(); | 566 | e->ignore(); |
566 | return; | 567 | return; |
567 | } | 568 | } |
568 | 569 | ||
569 | // some visual feedback | 570 | // some visual feedback |
570 | // oldPalette = palette(); | 571 | // oldPalette = palette(); |
571 | // setPalette(my_HilitePalette); | 572 | // setPalette(my_HilitePalette); |
572 | // update(); | 573 | // update(); |
573 | #endif | 574 | #endif |
574 | } | 575 | } |
575 | 576 | ||
576 | void KODayMatrix::dragMoveEvent(QDragMoveEvent *e) | 577 | void KODayMatrix::dragMoveEvent(QDragMoveEvent *e) |
577 | { | 578 | { |
578 | #ifndef KORG_NODND | 579 | #ifndef KORG_NODND |
579 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { | 580 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { |
580 | e->ignore(); | 581 | e->ignore(); |
581 | return; | 582 | return; |
582 | } | 583 | } |
583 | 584 | ||
584 | e->accept(); | 585 | e->accept(); |
585 | #endif | 586 | #endif |
586 | } | 587 | } |
587 | 588 | ||
588 | void KODayMatrix::dragLeaveEvent(QDragLeaveEvent */*dl*/) | 589 | void KODayMatrix::dragLeaveEvent(QDragLeaveEvent */*dl*/) |
589 | { | 590 | { |
590 | #ifndef KORG_NODND | 591 | #ifndef KORG_NODND |
591 | // setPalette(oldPalette); | 592 | // setPalette(oldPalette); |
592 | // update(); | 593 | // update(); |
593 | #endif | 594 | #endif |
594 | } | 595 | } |
595 | 596 | ||
596 | void KODayMatrix::dropEvent(QDropEvent *e) | 597 | void KODayMatrix::dropEvent(QDropEvent *e) |
597 | { | 598 | { |
598 | #ifndef KORG_NODND | 599 | #ifndef KORG_NODND |
599 | // kdDebug() << "KODayMatrix::dropEvent(e) begin" << endl; | 600 | // kdDebug() << "KODayMatrix::dropEvent(e) begin" << endl; |
600 | 601 | ||
601 | if (!mCalendar || !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { | 602 | if (!mCalendar || !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { |
602 | e->ignore(); | 603 | e->ignore(); |
603 | return; | 604 | return; |
604 | } | 605 | } |
605 | 606 | ||
606 | DndFactory factory( mCalendar ); | 607 | DndFactory factory( mCalendar ); |
607 | Event *event = factory.createDrop(e); | 608 | Event *event = factory.createDrop(e); |
608 | 609 | ||
609 | if (event) { | 610 | if (event) { |
610 | e->acceptAction(); | 611 | e->acceptAction(); |
611 | 612 | ||
612 | Event *existingEvent = mCalendar->event(event->uid()); | 613 | Event *existingEvent = mCalendar->event(event->uid()); |
613 | 614 | ||
614 | if(existingEvent) { | 615 | if(existingEvent) { |
615 | // uniquify event | 616 | // uniquify event |
616 | event->recreate(); | 617 | event->recreate(); |
617 | /* | 618 | /* |
618 | KMessageBox::sorry(this, | 619 | KMessageBox::sorry(this, |
619 | i18n("Event already exists in this calendar."), | 620 | i18n("Event already exists in this calendar."), |
620 | i18n("Drop Event")); | 621 | i18n("Drop Event")); |
621 | delete event; | 622 | delete event; |
622 | return; | 623 | return; |
623 | */ | 624 | */ |
624 | } | 625 | } |
625 | // kdDebug() << "Drop new Event" << endl; | 626 | // kdDebug() << "Drop new Event" << endl; |
626 | // Adjust date | 627 | // Adjust date |
627 | QDateTime start = event->dtStart(); | 628 | QDateTime start = event->dtStart(); |
628 | QDateTime end = event->dtEnd(); | 629 | QDateTime end = event->dtEnd(); |
629 | int duration = start.daysTo(end); | 630 | int duration = start.daysTo(end); |
630 | int idx = getDayIndexFrom(e->pos().x(), e->pos().y()); | 631 | int idx = getDayIndexFrom(e->pos().x(), e->pos().y()); |
631 | 632 | ||
632 | start.setDate(days[idx]); | 633 | start.setDate(days[idx]); |
633 | end.setDate(days[idx].addDays(duration)); | 634 | end.setDate(days[idx].addDays(duration)); |
634 | 635 | ||
635 | event->setDtStart(start); | 636 | event->setDtStart(start); |
636 | event->setDtEnd(end); | 637 | event->setDtEnd(end); |
637 | mCalendar->addEvent(event); | 638 | mCalendar->addEvent(event); |
638 | 639 | ||
639 | emit eventDropped(event); | 640 | emit eventDropped(event); |
640 | } else { | 641 | } else { |
641 | // kdDebug() << "KODayMatrix::dropEvent(): Event from drop not decodable" << endl; | 642 | // kdDebug() << "KODayMatrix::dropEvent(): Event from drop not decodable" << endl; |
642 | e->ignore(); | 643 | e->ignore(); |
643 | } | 644 | } |
644 | #endif | 645 | #endif |
645 | } | 646 | } |
646 | 647 | ||
647 | // ---------------------------------------------------------------------------- | 648 | // ---------------------------------------------------------------------------- |
648 | // P A I N T E V E N T H A N D L I N G | 649 | // P A I N T E V E N T H A N D L I N G |
649 | // ---------------------------------------------------------------------------- | 650 | // ---------------------------------------------------------------------------- |
650 | 651 | ||
651 | void KODayMatrix::paintEvent(QPaintEvent * pevent) | 652 | void KODayMatrix::paintEvent(QPaintEvent * pevent) |
652 | { | 653 | { |
653 | QRect sz = frameRect(); | 654 | QRect sz = frameRect(); |
654 | if ( sz.width() <= 0 || sz.height() <= 0 ) | 655 | if ( sz.width() <= 0 || sz.height() <= 0 ) |
655 | return; | 656 | return; |
656 | if ( mPendingUpdateBeforeRepaint ) { | 657 | if ( mPendingUpdateBeforeRepaint ) { |
657 | updateViewTimed(); | 658 | updateViewTimed(); |
658 | mPendingUpdateBeforeRepaint = false; | 659 | mPendingUpdateBeforeRepaint = false; |
659 | } | 660 | } |
660 | if ( myPix.width() != sz.width() || myPix.height()!=sz.height() ) { | 661 | if ( myPix.width() != sz.width() || myPix.height()!=sz.height() ) { |
661 | myPix.resize(sz.size() ); | 662 | myPix.resize(sz.size() ); |
662 | } | 663 | } |
663 | QPainter p(&myPix); | 664 | QPainter p(&myPix); |
664 | p.setFont(font()); | 665 | p.setFont(font()); |
665 | 666 | ||
666 | 667 | ||
667 | int dheight = daysize.height(); | 668 | int dheight = daysize.height(); |
668 | int dwidth = daysize.width(); | 669 | int dwidth = daysize.width(); |
669 | int row,col; | 670 | int row,col; |
670 | int selw, selh; | 671 | int selw, selh; |
671 | int xyOff = frameWidth(); | 672 | int xyOff = frameWidth(); |
672 | int colModulo = sz.width() % 7; | 673 | int colModulo = sz.width() % 7; |
673 | int rowModulo = sz.height() % 6; | 674 | int rowModulo = sz.height() % 6; |
674 | //qDebug("col %d row %d ",colModulo,rowModulo ); | 675 | //qDebug("col %d row %d ",colModulo,rowModulo ); |
675 | 676 | ||
676 | bool isRTL = KOGlobals::self()->reverseLayout(); | 677 | bool isRTL = KOGlobals::self()->reverseLayout(); |
677 | 678 | ||
678 | // draw background and topleft frame | 679 | // draw background and topleft frame |
679 | p.fillRect(pevent->rect(), mDefaultBackColor); | 680 | p.fillRect(pevent->rect(), mDefaultBackColor); |
680 | p.setPen(mDefaultTextColor); | 681 | p.setPen(mDefaultTextColor); |
681 | p.drawRect(0, 0, sz.width()+1, sz.height()+1); | 682 | p.drawRect(0, 0, sz.width()+1, sz.height()+1); |
682 | int mSelStartT = mSelStart; | 683 | int mSelStartT = mSelStart; |
683 | int mSelEndT = mSelEnd; | 684 | int mSelEndT = mSelEnd; |
684 | if ( mSelEndT >= NUMDAYS ) | 685 | if ( mSelEndT >= NUMDAYS ) |
685 | mSelEndT = NUMDAYS-1; | 686 | mSelEndT = NUMDAYS-1; |
686 | // draw selected days with highlighted background color | 687 | // draw selected days with highlighted background color |
687 | if (mSelStart != NOSELECTION) { | 688 | if (mSelStart != NOSELECTION) { |
688 | bool skip = false; | 689 | bool skip = false; |
689 | if ( ! mouseDown ) { | 690 | if ( ! mouseDown ) { |
690 | int mo = days[20].month(); | 691 | int mo = days[20].month(); |
691 | //qDebug("-- %d %d ", mSelStartT, mSelEndT); | 692 | //qDebug("-- %d %d ", mSelStartT, mSelEndT); |
692 | //qDebug("%d %d %d - d %d", mo, days[mSelStartT].month() , days[mSelEndT].month(), days[mSelEndT].day() ); | 693 | //qDebug("%d %d %d - d %d", mo, days[mSelStartT].month() , days[mSelEndT].month(), days[mSelEndT].day() ); |
693 | if ( days[mSelStartT].month() > mo || days[mSelEndT].month() < mo ) { | 694 | if ( days[mSelStartT].month() > mo || days[mSelEndT].month() < mo ) { |
694 | skip = true; | 695 | skip = true; |
695 | } else { | 696 | } else { |
696 | if ( days[mSelStartT].month() != mo ) { | 697 | if ( days[mSelStartT].month() != mo ) { |
697 | int add = days[mSelStartT].daysInMonth ()-days[mSelStartT].day(); | 698 | int add = days[mSelStartT].daysInMonth ()-days[mSelStartT].day(); |
698 | mSelStartT += add +1; | 699 | mSelStartT += add +1; |
699 | } | 700 | } |
700 | if ( days[mSelEndT].month() != mo ) { | 701 | if ( days[mSelEndT].month() != mo ) { |
701 | int sub = days[mSelEndT].day(); | 702 | int sub = days[mSelEndT].day(); |
702 | mSelEndT -= sub ; | 703 | mSelEndT -= sub ; |
703 | } | 704 | } |
704 | } | 705 | } |
705 | } | 706 | } |
706 | if ( ! skip ) { | 707 | if ( ! skip ) { |
707 | row = mSelStartT/7; | 708 | row = mSelStartT/7; |
708 | col = mSelStartT -row*7; | 709 | col = mSelStartT -row*7; |
709 | QColor selcol = KOPrefs::instance()->mHighlightColor; | 710 | QColor selcol = KOPrefs::instance()->mHighlightColor; |
710 | int addCol = 0; | 711 | int addCol = 0; |
711 | int addRow = 0; | 712 | int addRow = 0; |
712 | int addRow2 = 0; | 713 | int addRow2 = 0; |
713 | int addCol2 = 0; | 714 | int addCol2 = 0; |
714 | if (row == mSelEndT/7) { | 715 | if (row == mSelEndT/7) { |
715 | if ( rowModulo ) { | 716 | if ( rowModulo ) { |
716 | if ( row >= 6 - rowModulo ) | 717 | if ( row >= 6 - rowModulo ) |
717 | addRow = row - 5 + rowModulo; | 718 | addRow = row - 5 + rowModulo; |
718 | } | 719 | } |
719 | if ( colModulo ) { | 720 | if ( colModulo ) { |
720 | int colt1 = mSelEndT%7; | 721 | int colt1 = mSelEndT%7; |
721 | //qDebug("colt1 %d ", colt1 ); | 722 | //qDebug("colt1 %d ", colt1 ); |
722 | if ( colt1 >= 7 - colModulo ) | 723 | if ( colt1 >= 7 - colModulo ) |
723 | addCol = colt1 - 7 + colModulo+1; | 724 | addCol = colt1 - 7 + colModulo+1; |
724 | int colt = mSelStartT%7; | 725 | int colt = mSelStartT%7; |
725 | if ( colt >= 7 - colModulo ) | 726 | if ( colt >= 7 - colModulo ) |
726 | addCol2 = colt - 7 + colModulo; | 727 | addCol2 = colt - 7 + colModulo; |
727 | addCol -= addCol2; | 728 | addCol -= addCol2; |
728 | //qDebug("COL %d %d %d %d ",col , colt1 ,addCol ,addCol2 ); | 729 | //qDebug("COL %d %d %d %d ",col , colt1 ,addCol ,addCol2 ); |
729 | } | 730 | } |
730 | // Single row selection | 731 | // Single row selection |
731 | if ( row == 0) | 732 | if ( row == 0) |
732 | addRow = 1; | 733 | addRow = 1; |
733 | p.fillRect(isRTL ? (7 - (mSelEndT-mSelStartT+1) - col)*dwidth : col*dwidth+1+addCol2, | 734 | p.fillRect(isRTL ? (7 - (mSelEndT-mSelStartT+1) - col)*dwidth : col*dwidth+1+addCol2, |
734 | row*dheight+addRow, (mSelEndT-mSelStartT+1)*dwidth+addCol, dheight+1, selcol); | 735 | row*dheight+addRow, (mSelEndT-mSelStartT+1)*dwidth+addCol, dheight+1, selcol); |
735 | } else { | 736 | } else { |
736 | // draw first row to the right | 737 | // draw first row to the right |
737 | if ( colModulo ) { | 738 | if ( colModulo ) { |
738 | if ( col >= 7 - colModulo ) | 739 | if ( col >= 7 - colModulo ) |
739 | addCol2 = col - 7 + colModulo; | 740 | addCol2 = col - 7 + colModulo; |
740 | } | 741 | } |
741 | if ( rowModulo ) { | 742 | if ( rowModulo ) { |
742 | if ( row >= 6 - rowModulo ) | 743 | if ( row >= 6 - rowModulo ) |
743 | addRow = row - 5 + rowModulo; | 744 | addRow = row - 5 + rowModulo; |
744 | } | 745 | } |
745 | if ( row == 0) | 746 | if ( row == 0) |
746 | addRow = 1; | 747 | addRow = 1; |
747 | p.fillRect(isRTL ? 0 : col*dwidth+1+addCol2, row*dheight+addRow, (7-col)*dwidth+colModulo, | 748 | p.fillRect(isRTL ? 0 : col*dwidth+1+addCol2, row*dheight+addRow, (7-col)*dwidth+colModulo, |
748 | dheight+1, selcol); | 749 | dheight+1, selcol); |
749 | // draw full block till last line | 750 | // draw full block till last line |
750 | selh = mSelEndT/7-row; | 751 | selh = mSelEndT/7-row; |
751 | addRow = 0; | 752 | addRow = 0; |
752 | if ( rowModulo ) { | 753 | if ( rowModulo ) { |
753 | if ( mSelEndT/7 >= 6 - rowModulo ) | 754 | if ( mSelEndT/7 >= 6 - rowModulo ) |
754 | addRow = mSelEndT/7 - 5 + rowModulo; | 755 | addRow = mSelEndT/7 - 5 + rowModulo; |
755 | } | 756 | } |
756 | if (selh > 1) { | 757 | if (selh > 1) { |
757 | p.fillRect(1, (row+1)*dheight, 7*dwidth+colModulo, (selh-1)*dheight+addRow,selcol); | 758 | p.fillRect(1, (row+1)*dheight, 7*dwidth+colModulo, (selh-1)*dheight+addRow,selcol); |
758 | } | 759 | } |
759 | // draw last block from left to mSelEndT | 760 | // draw last block from left to mSelEndT |
760 | selw = mSelEndT-7*(mSelEndT/7)+1; | 761 | selw = mSelEndT-7*(mSelEndT/7)+1; |
761 | //qDebug("esl %d ",selw ); | 762 | //qDebug("esl %d ",selw ); |
762 | int add = 0; | 763 | int add = 0; |
763 | if ( colModulo ) { | 764 | if ( colModulo ) { |
764 | add = 7 - colModulo; | 765 | add = 7 - colModulo; |
765 | if ( selw > add ) | 766 | if ( selw > add ) |
766 | add = selw - add; | 767 | add = selw - add; |
767 | else | 768 | else |
768 | add = 0; | 769 | add = 0; |
769 | } | 770 | } |
770 | //qDebug("add %d ", add); | 771 | //qDebug("add %d ", add); |
771 | p.fillRect(isRTL ? (7-selw)*dwidth : 1, (row+selh)*dheight+addRow, | 772 | p.fillRect(isRTL ? (7-selw)*dwidth : 1, (row+selh)*dheight+addRow, |
772 | selw*dwidth+add, dheight+1, selcol); | 773 | selw*dwidth+add, dheight+1, selcol); |
773 | } | 774 | } |
774 | } | 775 | } |
775 | } | 776 | } |
776 | 777 | ||
777 | // iterate over all days in the matrix and draw the day label in appropriate colors | 778 | // iterate over all days in the matrix and draw the day label in appropriate colors |
778 | QColor actcol = mDefaultTextColorShaded; | 779 | QColor actcol = mDefaultTextColorShaded; |
779 | p.setPen(actcol); | 780 | p.setPen(actcol); |
780 | QPen tmppen; | 781 | QPen tmppen; |
781 | for(int i = 0; i < NUMDAYS; i++) { | 782 | for(int i = 0; i < NUMDAYS; i++) { |
782 | row = i/7; | 783 | row = i/7; |
783 | col = isRTL ? 6-(i-row*7) : i-row*7; | 784 | col = isRTL ? 6-(i-row*7) : i-row*7; |
784 | 785 | ||
785 | // if it is the first day of a month switch color from normal to shaded and vice versa | 786 | // if it is the first day of a month switch color from normal to shaded and vice versa |
786 | if ( KOGlobals::self()->calendarSystem()->day( days[i] ) == 1) { | 787 | if ( KOGlobals::self()->calendarSystem()->day( days[i] ) == 1) { |
787 | if (actcol == mDefaultTextColorShaded) { | 788 | if (actcol == mDefaultTextColorShaded) { |
788 | actcol = mDefaultTextColor; | 789 | actcol = mDefaultTextColor; |
789 | } else { | 790 | } else { |
790 | actcol = mDefaultTextColorShaded; | 791 | actcol = mDefaultTextColorShaded; |
791 | } | 792 | } |
792 | p.setPen(actcol); | 793 | p.setPen(actcol); |
793 | } | 794 | } |
794 | if (actcol == mDefaultTextColorShaded) { | 795 | if (actcol == mDefaultTextColorShaded) { |
795 | if ( ! mouseDown ) { | 796 | if ( ! mouseDown ) { |
796 | continue; | 797 | continue; |
797 | } | 798 | } |
798 | } | 799 | } |
799 | //Reset pen color after selected days block | 800 | //Reset pen color after selected days block |
800 | if (i == mSelEndT+1) { | 801 | if (i == mSelEndT+1) { |
801 | p.setPen(actcol); | 802 | p.setPen(actcol); |
802 | } | 803 | } |
803 | 804 | ||
804 | // if today then draw rectangle around day | 805 | // if today then draw rectangle around day |
805 | if (today == i) { | 806 | if (today == i) { |
806 | tmppen = p.pen(); | 807 | tmppen = p.pen(); |
807 | QPen mTodayPen(p.pen()); | 808 | QPen mTodayPen(p.pen()); |
808 | if ( daysize.width() < 20 ) | 809 | if ( daysize.width() < 20 ) |
809 | mTodayPen.setWidth(1); | 810 | mTodayPen.setWidth(1); |
810 | else | 811 | else |
811 | mTodayPen.setWidth(mTodayMarginWidth); | 812 | mTodayPen.setWidth(mTodayMarginWidth); |
812 | //draw red rectangle for holidays | 813 | //draw red rectangle for holidays |
813 | if (!mHolidays[i].isNull()) { | 814 | if (!mHolidays[i].isNull()) { |
814 | if (actcol == mDefaultTextColor) { | 815 | if (actcol == mDefaultTextColor) { |
815 | mTodayPen.setColor(KOPrefs::instance()->mHolidayColor); | 816 | mTodayPen.setColor(KOPrefs::instance()->mHolidayColor); |
816 | } else { | 817 | } else { |
817 | mTodayPen.setColor(mHolidayColorShaded); | 818 | mTodayPen.setColor(mHolidayColorShaded); |
818 | } | 819 | } |
819 | } | 820 | } |
820 | //draw gray rectangle for today if in selection | 821 | //draw gray rectangle for today if in selection |
821 | if (i >= mSelStartT && i <= mSelEndT) { | 822 | if (i >= mSelStartT && i <= mSelEndT) { |
822 | QColor grey("grey"); | 823 | QColor grey("grey"); |
823 | mTodayPen.setColor(grey); | 824 | mTodayPen.setColor(grey); |
824 | } | 825 | } |
825 | p.setPen(mTodayPen); | 826 | p.setPen(mTodayPen); |
826 | 827 | ||
827 | 828 | ||
828 | int addCol = 0; | 829 | int addCol = 0; |
829 | int addRow = 0; | 830 | int addRow = 0; |
830 | if (rowModulo) { | 831 | if (rowModulo) { |
831 | if ( row >= 6 - rowModulo ) | 832 | if ( row >= 6 - rowModulo ) |
832 | addRow = row - 5 + rowModulo; | 833 | addRow = row - 5 + rowModulo; |
833 | } | 834 | } |
834 | if ( colModulo ) { | 835 | if ( colModulo ) { |
835 | if ( col >= 7 - colModulo ) | 836 | if ( col >= 7 - colModulo ) |
836 | addCol = col - 6 + colModulo-1; | 837 | addCol = col - 6 + colModulo-1; |
837 | } | 838 | } |
838 | if ( col == 0 ) | 839 | if ( col == 0 ) |
839 | addCol = 1; | 840 | addCol = 1; |
840 | p.drawRect(col*dwidth+addCol, row*dheight+addRow, dwidth, dheight+1); | 841 | p.drawRect(col*dwidth+addCol, row*dheight+addRow, dwidth, dheight+1); |
841 | p.setPen(tmppen); | 842 | p.setPen(tmppen); |
842 | } | 843 | } |
843 | 844 | ||
844 | // if any events are on that day then draw it using a bold font | 845 | // if any events are on that day then draw it using a bold font |
845 | if (events[i] > 0) { | 846 | if (events[i] > 0) { |
846 | QFont myFont = font(); | 847 | QFont myFont = font(); |
847 | myFont.setBold(true); | 848 | myFont.setBold(true); |
848 | p.setFont(myFont); | 849 | p.setFont(myFont); |
849 | } | 850 | } |
850 | 851 | ||
851 | // if it is a holiday then use the default holiday color | 852 | // if it is a holiday then use the default holiday color |
852 | if (!mHolidays[i].isNull()) { | 853 | if (!mHolidays[i].isNull()) { |
853 | if ( bDays.testBit(i) ) { | 854 | if ( bDays.testBit(i) ) { |
854 | p.setPen(Qt::green); | 855 | p.setPen(Qt::green); |
855 | } else { | 856 | } else { |
856 | if (actcol == mDefaultTextColor) { | 857 | if (actcol == mDefaultTextColor) { |
857 | p.setPen(KOPrefs::instance()->mHolidayColor); | 858 | p.setPen(KOPrefs::instance()->mHolidayColor); |
858 | } else { | 859 | } else { |
859 | p.setPen(mHolidayColorShaded); | 860 | p.setPen(mHolidayColorShaded); |
860 | } | 861 | } |
861 | } | 862 | } |
862 | } | 863 | } |
863 | 864 | ||
864 | // draw selected days with special color | 865 | // draw selected days with special color |
865 | // DO NOT specially highlight holidays in selection ! | 866 | // DO NOT specially highlight holidays in selection ! |
866 | if (i >= mSelStartT && i <= mSelEndT) { | 867 | if (i >= mSelStartT && i <= mSelEndT) { |
867 | ;//p.setPen(mSelectedDaysColor); | 868 | ;//p.setPen(mSelectedDaysColor); |
868 | } | 869 | } |
869 | 870 | ||
870 | int addCol = 0; | 871 | int addCol = 0; |
871 | int addRow = 0; | 872 | int addRow = 0; |
872 | if ( colModulo ) { | 873 | if ( colModulo ) { |
873 | if ( col >= 7 - colModulo ) | 874 | if ( col >= 7 - colModulo ) |
874 | addCol = col - 7 + colModulo; | 875 | addCol = col - 7 + colModulo; |
875 | } | 876 | } |
876 | if ( rowModulo ) { | 877 | if ( rowModulo ) { |
877 | if ( row >= 6 - rowModulo ) | 878 | if ( row >= 6 - rowModulo ) |
878 | addRow = row - 5 + rowModulo; | 879 | addRow = row - 5 + rowModulo; |
879 | } | 880 | } |
880 | //qDebug("add %d %d -- %d %d ", col, addCol, row, addRow); | 881 | //qDebug("add %d %d -- %d %d ", col, addCol, row, addRow); |
881 | ++addCol;//++addCol; | 882 | ++addCol;//++addCol; |
882 | if ( row == 0) | 883 | if ( row == 0) |
883 | addRow = 1; | 884 | addRow = 1; |
884 | p.drawText(col*dwidth+addCol, row*dheight+addRow, dwidth, dheight, | 885 | p.drawText(col*dwidth+addCol, row*dheight+addRow, dwidth, dheight, |
885 | Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]); | 886 | Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]); |
886 | 887 | ||
887 | // reset color to actual color | 888 | // reset color to actual color |
888 | if (!mHolidays[i].isNull()) { | 889 | if (!mHolidays[i].isNull()) { |
889 | p.setPen(actcol); | 890 | p.setPen(actcol); |
890 | } | 891 | } |
891 | // reset bold font to plain font | 892 | // reset bold font to plain font |
892 | if (events[i] > 0) { | 893 | if (events[i] > 0) { |
893 | QFont myFont = font(); | 894 | QFont myFont = font(); |
894 | myFont.setBold(false); | 895 | myFont.setBold(false); |
895 | p.setFont(myFont); | 896 | p.setFont(myFont); |
896 | } | 897 | } |
897 | } | 898 | } |
898 | int off = xyOff; | 899 | int off = xyOff; |
899 | bitBlt (this, off, off, &myPix, 0 ,0,width(), height() ,CopyROP); | 900 | bitBlt (this, off, off, &myPix, 0 ,0,width(), height() ,CopyROP); |
900 | //qDebug("ffffffffff %d ", off); | 901 | //qDebug("ffffffffff %d ", off); |
901 | } | 902 | } |
902 | 903 | ||
903 | // ---------------------------------------------------------------------------- | 904 | // ---------------------------------------------------------------------------- |
904 | // R E SI Z E E V E N T H A N D L I N G | 905 | // R E SI Z E E V E N T H A N D L I N G |
905 | // ---------------------------------------------------------------------------- | 906 | // ---------------------------------------------------------------------------- |
906 | 907 | ||
907 | void KODayMatrix::resizeEvent(QResizeEvent *) | 908 | void KODayMatrix::resizeEvent(QResizeEvent *) |
908 | { | 909 | { |
909 | QRect sz = frameRect(); | 910 | QRect sz = frameRect(); |
910 | daysize.setHeight(sz.height()*7 / NUMDAYS); | 911 | daysize.setHeight(sz.height()*7 / NUMDAYS); |
911 | daysize.setWidth(sz.width() / 7); | 912 | daysize.setWidth(sz.width() / 7); |
912 | } | 913 | } |
913 | 914 | ||
914 | QSize KODayMatrix::sizeHint() const | 915 | QSize KODayMatrix::sizeHint() const |
915 | { | 916 | { |
916 | 917 | ||
917 | QFontMetrics fm ( font() ); | 918 | QFontMetrics fm ( font() ); |
918 | int wid = fm.width( "30") *7+3; | 919 | int wid = fm.width( "30") *7+3; |
919 | int hei = fm.height() * 6+3; | 920 | int hei = fm.height() * 6+3; |
920 | //qDebug("KODayMatrix::sizeHint()********************* %d %d", wid , hei); | 921 | //qDebug("KODayMatrix::sizeHint()********************* %d %d", wid , hei); |
921 | return QSize ( wid, hei ); | 922 | return QSize ( wid, hei ); |
922 | 923 | ||
923 | } | 924 | } |
diff --git a/korganizer/koeventviewer.cpp b/korganizer/koeventviewer.cpp index 135ca73..1508638 100644 --- a/korganizer/koeventviewer.cpp +++ b/korganizer/koeventviewer.cpp | |||
@@ -1,721 +1,721 @@ | |||
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 | 19 | ||
20 | #include <qcstring.h> | 20 | #include <qcstring.h> |
21 | #include <qwhatsthis.h> | 21 | #include <qwhatsthis.h> |
22 | #include <qdialog.h> | 22 | #include <qdialog.h> |
23 | #include <qapplication.h> | 23 | #include <qapplication.h> |
24 | #include <qlabel.h> | 24 | #include <qlabel.h> |
25 | #include <qlayout.h> | 25 | #include <qlayout.h> |
26 | 26 | ||
27 | #include <klocale.h> | 27 | #include <klocale.h> |
28 | #include <kapplication.h> | 28 | #include <kapplication.h> |
29 | #include <libkcal/event.h> | 29 | #include <libkcal/event.h> |
30 | #include <libkcal/todo.h> | 30 | #include <libkcal/todo.h> |
31 | #include <kdebug.h> | 31 | #include <kdebug.h> |
32 | #include <kiconloader.h> | 32 | #include <kiconloader.h> |
33 | #include <krun.h> | 33 | #include <krun.h> |
34 | #include <kglobal.h> | 34 | #include <kglobal.h> |
35 | #include <kprocess.h> | 35 | #include <kprocess.h> |
36 | #include "koprefs.h" | 36 | #include "koprefs.h" |
37 | 37 | ||
38 | #include <kabc/stdaddressbook.h> | 38 | #include <kabc/stdaddressbook.h> |
39 | 39 | ||
40 | #ifndef KORG_NODCOP | 40 | #ifndef KORG_NODCOP |
41 | #include <dcopclient.h> | 41 | #include <dcopclient.h> |
42 | #include "korganizer.h" | 42 | #include "korganizer.h" |
43 | #include "koprefs.h" | 43 | #include "koprefs.h" |
44 | #include "actionmanager.h" | 44 | #include "actionmanager.h" |
45 | #endif | 45 | #endif |
46 | 46 | ||
47 | #include "koeventviewer.h" | 47 | #include "koeventviewer.h" |
48 | //#ifndef KORG_NOKABC | 48 | //#ifndef KORG_NOKABC |
49 | //#include <kabc/stdaddressbook.h> | 49 | //#include <kabc/stdaddressbook.h> |
50 | //#define size count | 50 | //#define size count |
51 | //#endif | 51 | //#endif |
52 | 52 | ||
53 | #ifdef DESKTOP_VERSION | 53 | #ifdef DESKTOP_VERSION |
54 | #include <kabc/addresseedialog.h> | 54 | #include <kabc/addresseedialog.h> |
55 | #include <kabc/addresseeview.h> | 55 | #include <kabc/addresseeview.h> |
56 | #else //DESKTOP_VERSION | 56 | #else //DESKTOP_VERSION |
57 | #include <externalapphandler.h> | 57 | #include <externalapphandler.h> |
58 | #include <qtopia/qcopenvelope_qws.h> | 58 | #include <qtopia/qcopenvelope_qws.h> |
59 | #endif //DESKTOP_VERSION | 59 | #endif //DESKTOP_VERSION |
60 | 60 | ||
61 | KOEventViewer::KOEventViewer(QWidget *parent,const char *name) | 61 | KOEventViewer::KOEventViewer(QWidget *parent,const char *name) |
62 | : QTextBrowser(parent,name) | 62 | : QTextBrowser(parent,name) |
63 | { | 63 | { |
64 | mSyncMode = false; | 64 | mSyncMode = false; |
65 | mColorMode = 0; | 65 | mColorMode = 0; |
66 | } | 66 | } |
67 | 67 | ||
68 | KOEventViewer::~KOEventViewer() | 68 | KOEventViewer::~KOEventViewer() |
69 | { | 69 | { |
70 | } | 70 | } |
71 | 71 | ||
72 | void KOEventViewer::setSource(const QString& n) | 72 | void KOEventViewer::setSource(const QString& n) |
73 | { | 73 | { |
74 | 74 | ||
75 | if ( n.left(3) == "uid" ) | 75 | if ( n.left(3) == "uid" ) |
76 | #ifdef DESKTOP_VERSION | 76 | #ifdef DESKTOP_VERSION |
77 | { | 77 | { |
78 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 78 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
79 | KABC::AddressBook::Iterator it; | 79 | KABC::AddressBook::Iterator it; |
80 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 80 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
81 | // LR I do not understand, why the uid string is different on zaurus and desktop | 81 | // LR I do not understand, why the uid string is different on zaurus and desktop |
82 | QString uid = "uid://"+(*it).uid(); | 82 | QString uid = "uid://"+(*it).uid(); |
83 | 83 | ||
84 | //qDebug("for *%s* +%s+ ", n.latin1(), uid.latin1()); | 84 | //qDebug("for *%s* +%s+ ", n.latin1(), uid.latin1()); |
85 | if (n == uid ) { | 85 | if (n == uid ) { |
86 | //qDebug("found %s ",(*it).mobileHomePhone().latin1() ); | 86 | //qDebug("found %s ",(*it).mobileHomePhone().latin1() ); |
87 | QDialog dia( this,"dia123", true ); | 87 | QDialog dia( this,"dia123", true ); |
88 | dia.setCaption( i18n("Details of attendee") ); | 88 | dia.setCaption( i18n("Details of attendee") ); |
89 | QVBoxLayout lay ( &dia ); | 89 | QVBoxLayout lay ( &dia ); |
90 | KABC::AddresseeView av ( &dia ); | 90 | KABC::AddresseeView av ( &dia ); |
91 | av.setAddressee( (*it) ); | 91 | av.setAddressee( (*it) ); |
92 | lay.addWidget( &av ); | 92 | lay.addWidget( &av ); |
93 | if ( QApplication::desktop()->width() < 480 ) | 93 | if ( QApplication::desktop()->width() < 480 ) |
94 | dia.resize( 220, 240); | 94 | dia.resize( 220, 240); |
95 | else { | 95 | else { |
96 | dia.resize( 400,400); | 96 | dia.resize( 400,400); |
97 | } | 97 | } |
98 | dia.exec(); | 98 | dia.exec(); |
99 | break; | 99 | break; |
100 | } | 100 | } |
101 | } | 101 | } |
102 | return; | 102 | return; |
103 | } | 103 | } |
104 | #else | 104 | #else |
105 | { | 105 | { |
106 | if ( "uid:organizer" == n ) { | 106 | if ( "uid:organizer" == n ) { |
107 | ExternalAppHandler::instance()->requestDetailsFromKAPI("", mCurrentIncidence->organizer(),""); | 107 | ExternalAppHandler::instance()->requestDetailsFromKAPI("", mCurrentIncidence->organizer(),""); |
108 | return; | 108 | return; |
109 | } | 109 | } |
110 | QPtrList<Attendee> attendees = mCurrentIncidence->attendees(); | 110 | QPtrList<Attendee> attendees = mCurrentIncidence->attendees(); |
111 | if (attendees.count()) { | 111 | if (attendees.count()) { |
112 | Attendee *a; | 112 | Attendee *a; |
113 | for(a=attendees.first();a;a=attendees.next()) { | 113 | for(a=attendees.first();a;a=attendees.next()) { |
114 | if ( "uid:"+a->uid() == n ) { | 114 | if ( "uid:"+a->uid() == n ) { |
115 | bool res = ExternalAppHandler::instance()->requestDetailsFromKAPI(a->name(), a->email(), a->uid()); | 115 | bool res = ExternalAppHandler::instance()->requestDetailsFromKAPI(a->name(), a->email(), a->uid()); |
116 | return; | 116 | return; |
117 | } | 117 | } |
118 | } | 118 | } |
119 | } | 119 | } |
120 | return; | 120 | return; |
121 | } | 121 | } |
122 | //requestNameEmailUidListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 122 | //requestNameEmailUidListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
123 | // the result should now arrive through method insertAttendees | 123 | // the result should now arrive through method insertAttendees |
124 | //QString uid = "uid:"+(*it).uid(); | 124 | //QString uid = "uid:"+(*it).uid(); |
125 | #endif | 125 | #endif |
126 | if ( n.left(6) == "mailto" ) { | 126 | if ( n.left(6) == "mailto" ) { |
127 | // qDebug("KOEventViewer::setSource %s ", n.mid(7).latin1()); | 127 | // qDebug("KOEventViewer::setSource %s ", n.mid(7).latin1()); |
128 | #ifndef DESKTOP_VERSION | 128 | #ifndef DESKTOP_VERSION |
129 | if ( n.mid(7,3) == "ALL" ) { | 129 | if ( n.mid(7,3) == "ALL" ) { |
130 | qDebug("all "); | 130 | qDebug("all "); |
131 | mailToAttendees( true ); | 131 | mailToAttendees( true ); |
132 | } else if ( n.mid(7,4) == "RSVP" ) { | 132 | } else if ( n.mid(7,4) == "RSVP" ) { |
133 | mailToAttendees( false ); | 133 | mailToAttendees( false ); |
134 | qDebug("rsvp "); | 134 | qDebug("rsvp "); |
135 | } else { | 135 | } else { |
136 | QCopEnvelope e("QPE/Application/ompi", "newMail(QString)" ); | 136 | QCopEnvelope e("QPE/Application/ompi", "newMail(QString)" ); |
137 | e << n.mid(7); | 137 | e << n.mid(7); |
138 | } | 138 | } |
139 | #endif | 139 | #endif |
140 | 140 | ||
141 | } | 141 | } |
142 | 142 | ||
143 | 143 | ||
144 | #ifndef KORG_NODCOP | 144 | #ifndef KORG_NODCOP |
145 | kdDebug() << "KOEventViewer::setSource(): " << n << endl; | 145 | kdDebug() << "KOEventViewer::setSource(): " << n << endl; |
146 | QString tmpStr; | 146 | QString tmpStr; |
147 | if (n.startsWith("mailto:")) { | 147 | if (n.startsWith("mailto:")) { |
148 | KApplication::kApplication()->invokeMailer(n.mid(7),QString::null); | 148 | KApplication::kApplication()->invokeMailer(n.mid(7),QString::null); |
149 | //emit showIncidence(n); | 149 | //emit showIncidence(n); |
150 | return; | 150 | return; |
151 | } else if (n.startsWith("uid:")) { | 151 | } else if (n.startsWith("uid:")) { |
152 | DCOPClient *client = KApplication::kApplication()->dcopClient(); | 152 | DCOPClient *client = KApplication::kApplication()->dcopClient(); |
153 | const QByteArray noParamData; | 153 | const QByteArray noParamData; |
154 | const QByteArray paramData; | 154 | const QByteArray paramData; |
155 | QByteArray replyData; | 155 | QByteArray replyData; |
156 | QCString replyTypeStr; | 156 | QCString replyTypeStr; |
157 | #define PING_ABBROWSER (client->call("kaddressbook", "KAddressBookIface", "interfaces()", noParamData, replyTypeStr, replyData)) | 157 | #define PING_ABBROWSER (client->call("kaddressbook", "KAddressBookIface", "interfaces()", noParamData, replyTypeStr, replyData)) |
158 | bool foundAbbrowser = PING_ABBROWSER; | 158 | bool foundAbbrowser = PING_ABBROWSER; |
159 | 159 | ||
160 | if (foundAbbrowser) { | 160 | if (foundAbbrowser) { |
161 | //KAddressbook is already running, so just DCOP to it to bring up the contact editor | 161 | //KAddressbook is already running, so just DCOP to it to bring up the contact editor |
162 | //client->send("kaddressbook","KAddressBookIface", | 162 | //client->send("kaddressbook","KAddressBookIface", |
163 | QDataStream arg(paramData, IO_WriteOnly); | 163 | QDataStream arg(paramData, IO_WriteOnly); |
164 | arg << n.mid(6); | 164 | arg << n.mid(6); |
165 | client->send("kaddressbook", "KAddressBookIface", "showContactEditor( QString )", paramData); | 165 | client->send("kaddressbook", "KAddressBookIface", "showContactEditor( QString )", paramData); |
166 | return; | 166 | return; |
167 | } else { | 167 | } else { |
168 | /* | 168 | /* |
169 | KaddressBook is not already running. Pass it the UID of the contact via the command line while starting it - its neater. | 169 | KaddressBook is not already running. Pass it the UID of the contact via the command line while starting it - its neater. |
170 | We start it without its main interface | 170 | We start it without its main interface |
171 | */ | 171 | */ |
172 | KIconLoader* iconLoader = new KIconLoader(); | 172 | KIconLoader* iconLoader = new KIconLoader(); |
173 | QString iconPath = iconLoader->iconPath("go",KIcon::Small); | 173 | QString iconPath = iconLoader->iconPath("go",KIcon::Small); |
174 | ActionManager::setStartedKAddressBook(true); | 174 | ActionManager::setStartedKAddressBook(true); |
175 | tmpStr = "kaddressbook --editor-only --uid "; | 175 | tmpStr = "kaddressbook --editor-only --uid "; |
176 | tmpStr += KProcess::quote(n.mid(6)); | 176 | tmpStr += KProcess::quote(n.mid(6)); |
177 | KRun::runCommand(tmpStr,"KAddressBook",iconPath); | 177 | KRun::runCommand(tmpStr,"KAddressBook",iconPath); |
178 | return; | 178 | return; |
179 | } | 179 | } |
180 | } else { | 180 | } else { |
181 | //QTextBrowser::setSource(n); | 181 | //QTextBrowser::setSource(n); |
182 | } | 182 | } |
183 | #endif | 183 | #endif |
184 | } | 184 | } |
185 | void KOEventViewer::mailToAttendees( bool all ) | 185 | void KOEventViewer::mailToAttendees( bool all ) |
186 | { | 186 | { |
187 | QPtrList<Attendee> attendees = mCurrentIncidence->attendees(); | 187 | QPtrList<Attendee> attendees = mCurrentIncidence->attendees(); |
188 | if (attendees.count() == 0) return; | 188 | if (attendees.count() == 0) return; |
189 | QStringList nameList; | 189 | QStringList nameList; |
190 | QStringList emailList; | 190 | QStringList emailList; |
191 | QStringList uidList; | 191 | QStringList uidList; |
192 | Attendee* a; | 192 | Attendee* a; |
193 | for(a=attendees.first();a;a=attendees.next()) { | 193 | for(a=attendees.first();a;a=attendees.next()) { |
194 | if ( !all && !a->RSVP() ) continue; | 194 | if ( !all && !a->RSVP() ) continue; |
195 | if (!a->email().isEmpty()) { | 195 | if (!a->email().isEmpty()) { |
196 | nameList.append (a->name() ); | 196 | nameList.append (a->name() ); |
197 | emailList.append (a->email() ); | 197 | emailList.append (a->email() ); |
198 | uidList.append (a->uid() ); | 198 | uidList.append (a->uid() ); |
199 | } | 199 | } |
200 | } | 200 | } |
201 | QString uid = "ComposeMailUIpick2"+mMailSubject; | 201 | QString uid = "ComposeMailUIpick2"+mMailSubject; |
202 | #ifndef DESKTOP_VERSION | 202 | #ifndef DESKTOP_VERSION |
203 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); | 203 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); |
204 | #endif | 204 | #endif |
205 | 205 | ||
206 | } | 206 | } |
207 | void KOEventViewer::addTag(const QString & tag,const QString & text) | 207 | void KOEventViewer::addTag(const QString & tag,const QString & text) |
208 | { | 208 | { |
209 | int number=text.contains("\n"); | 209 | int number=text.contains("\n"); |
210 | QString str = "<" + tag + ">"; | 210 | QString str = "<" + tag + ">"; |
211 | QString tmpText=text; | 211 | QString tmpText=text; |
212 | QString tmpStr=str; | 212 | QString tmpStr=str; |
213 | if(number !=-1) | 213 | if(number !=-1) |
214 | { | 214 | { |
215 | if (number > 0) { | 215 | if (number > 0) { |
216 | int pos=0; | 216 | int pos=0; |
217 | QString tmp; | 217 | QString tmp; |
218 | for(int i=0;i<=number;i++) { | 218 | for(int i=0;i<=number;i++) { |
219 | pos=tmpText.find("\n"); | 219 | pos=tmpText.find("\n"); |
220 | tmp=tmpText.left(pos); | 220 | tmp=tmpText.left(pos); |
221 | tmpText=tmpText.right(tmpText.length()-pos-1); | 221 | tmpText=tmpText.right(tmpText.length()-pos-1); |
222 | tmpStr+=tmp+"<br>"; | 222 | tmpStr+=tmp+"<br>"; |
223 | } | 223 | } |
224 | } | 224 | } |
225 | else tmpStr += tmpText; | 225 | else tmpStr += tmpText; |
226 | tmpStr+="</" + tag + ">"; | 226 | tmpStr+="</" + tag + ">"; |
227 | mText.append(tmpStr); | 227 | mText.append(tmpStr); |
228 | } | 228 | } |
229 | else | 229 | else |
230 | { | 230 | { |
231 | str += text + "</" + tag + ">"; | 231 | str += text + "</" + tag + ">"; |
232 | mText.append(str); | 232 | mText.append(str); |
233 | } | 233 | } |
234 | } | 234 | } |
235 | 235 | ||
236 | void KOEventViewer::setColorMode( int m ) | 236 | void KOEventViewer::setColorMode( int m ) |
237 | { | 237 | { |
238 | mColorMode = m; | 238 | mColorMode = m; |
239 | } | 239 | } |
240 | void KOEventViewer::appendEvent(Event *event, int mode ) | 240 | void KOEventViewer::appendEvent(Event *event, int mode ) |
241 | { | 241 | { |
242 | mMailSubject = ""; | 242 | mMailSubject = ""; |
243 | mCurrentIncidence = event; | 243 | mCurrentIncidence = event; |
244 | bool shortDate = KOPrefs::instance()->mShortDateInViewer; | 244 | bool shortDate = KOPrefs::instance()->mShortDateInViewer; |
245 | topLevelWidget()->setCaption(i18n("Event Viewer")); | 245 | topLevelWidget()->setCaption(i18n("Event Viewer")); |
246 | if ( mode == 0 ) { | 246 | if ( mode == 0 ) { |
247 | addTag("h2",deTag(event->summary())); | 247 | addTag("h2",deTag(event->summary())); |
248 | } | 248 | } |
249 | else { | 249 | else { |
250 | if ( mColorMode == 1 ) { | 250 | if ( mColorMode == 1 ) { |
251 | mText +="<font color=\"#00A000\">"; | 251 | mText +="<font color=\"#00A000\">"; |
252 | } | 252 | } |
253 | if ( mColorMode == 2 ) { | 253 | if ( mColorMode == 2 ) { |
254 | mText +="<font color=\"#C00000\">"; | 254 | mText +="<font color=\"#C00000\">"; |
255 | } | 255 | } |
256 | // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; | 256 | // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; |
257 | if ( mode == 1 ) { | 257 | if ( mode == 1 ) { |
258 | addTag("h2",i18n( "Local: " ) +deTag(event->summary())); | 258 | addTag("h2",i18n( "Local: " ) +deTag(event->summary())); |
259 | } else { | 259 | } else { |
260 | addTag("h2",i18n( "Remote: " ) +deTag(event->summary())); | 260 | addTag("h2",i18n( "Remote: " ) +deTag(event->summary())); |
261 | } | 261 | } |
262 | addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); | 262 | addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); |
263 | if ( mColorMode ) | 263 | if ( mColorMode ) |
264 | mText += "</font>"; | 264 | mText += "</font>"; |
265 | } | 265 | } |
266 | mMailSubject += i18n( "Meeting " )+ event->summary(); | 266 | mMailSubject += i18n( "Meeting " )+ event->summary(); |
267 | if (event->cancelled ()) { | 267 | if (event->cancelled ()) { |
268 | mText +="<font color=\"#B00000\">"; | 268 | mText +="<font color=\"#B00000\">"; |
269 | addTag("i",i18n("This event has been cancelled!")); | 269 | addTag("i",i18n("This event has been cancelled!")); |
270 | mText.append("<br>"); | 270 | mText.append("<br>"); |
271 | mText += "</font>"; | 271 | mText += "</font>"; |
272 | mMailSubject += i18n("(cancelled)"); | 272 | mMailSubject += i18n("(cancelled)"); |
273 | } | 273 | } |
274 | if (!event->location().isEmpty()) { | 274 | if (!event->location().isEmpty()) { |
275 | addTag("b",i18n("Location: ")); | 275 | addTag("b",i18n("Location: ")); |
276 | mText.append(deTag(event->location())+"<br>"); | 276 | mText.append(deTag(event->location())+"<br>"); |
277 | mMailSubject += i18n(" at ") + event->location(); | 277 | mMailSubject += i18n(" at ") + event->location(); |
278 | } | 278 | } |
279 | if (event->doesFloat()) { | 279 | if (event->doesFloat()) { |
280 | if (event->isMultiDay()) { | 280 | if (event->isMultiDay()) { |
281 | mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>") | 281 | mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>") |
282 | .arg(event->dtStartDateStr(shortDate)) | 282 | .arg(event->dtStartDateStr(shortDate)) |
283 | .arg(event->dtEndDateStr(shortDate))); | 283 | .arg(event->dtEndDateStr(shortDate))); |
284 | } else { | 284 | } else { |
285 | mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate ))); | 285 | mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate ))); |
286 | } | 286 | } |
287 | } else { | 287 | } else { |
288 | if (event->isMultiDay()) { | 288 | if (event->isMultiDay()) { |
289 | mText.append(i18n("<p><b>From:</b> %1</p> ") | 289 | mText.append(i18n("<p><b>From:</b> %1</p> ") |
290 | .arg(event->dtStartStr( shortDate))); | 290 | .arg(event->dtStartStr( shortDate))); |
291 | mText.append(i18n("<p><b>To:</b> %1</p>") | 291 | mText.append(i18n("<p><b>To:</b> %1</p>") |
292 | .arg(event->dtEndStr(shortDate))); | 292 | .arg(event->dtEndStr(shortDate))); |
293 | } else { | 293 | } else { |
294 | mText.append(i18n("<p><b>On:</b> %1</p> ") | 294 | mText.append(i18n("<p><b>On:</b> %1</p> ") |
295 | .arg(event->dtStartDateStr( shortDate ))); | 295 | .arg(event->dtStartDateStr( shortDate ))); |
296 | mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>") | 296 | mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>") |
297 | .arg(event->dtStartTimeStr()) | 297 | .arg(event->dtStartTimeStr()) |
298 | .arg(event->dtEndTimeStr())); | 298 | .arg(event->dtEndTimeStr())); |
299 | } | 299 | } |
300 | } | 300 | } |
301 | 301 | ||
302 | if (event->recurrence()->doesRecur()) { | 302 | if (event->recurrence()->doesRecur()) { |
303 | 303 | ||
304 | QString recurText = event->recurrence()->recurrenceText(); | 304 | QString recurText = event->recurrence()->recurrenceText(); |
305 | addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>"); | 305 | addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>"); |
306 | bool ok; | 306 | bool ok; |
307 | QDate start = QDate::currentDate(); | 307 | QDate start = QDate::currentDate(); |
308 | QDateTime next; | 308 | QDateTime next; |
309 | next = event->getNextOccurence( QDateTime::currentDateTime() , &ok ); | 309 | next = event->getNextOccurence( QDateTime::currentDateTime() , &ok ); |
310 | if ( ok ) { | 310 | if ( ok ) { |
311 | addTag("p",i18n("<b>Next recurrence is on:</b>") ); | 311 | addTag("p",i18n("<b>Next recurrence is on:</b>") ); |
312 | addTag("p", KGlobal::locale()->formatDate( next.date(), shortDate )); | 312 | addTag("p", KGlobal::locale()->formatDate( next.date(), shortDate )); |
313 | mMailSubject += i18n(" - " )+ KGlobal::locale()->formatDateTime( next, true ); | 313 | mMailSubject += i18n(" - " )+ KGlobal::locale()->formatDateTime( next, true ); |
314 | 314 | ||
315 | } else { | 315 | } else { |
316 | bool last; | 316 | bool last; |
317 | QDate nextd; | 317 | QDate nextd; |
318 | nextd = event->recurrence()->getPreviousDate( QDate::currentDate() , &last ); | 318 | nextd = event->recurrence()->getPreviousDate( QDate::currentDate() , &last ); |
319 | if ( last ) { | 319 | if ( last ) { |
320 | addTag("p",i18n("<b>Last recurrence was on:</b>") ); | 320 | addTag("p",i18n("<b>Last recurrence was on:</b>") ); |
321 | addTag("p", KGlobal::locale()->formatDate( nextd, shortDate )); | 321 | addTag("p", KGlobal::locale()->formatDate( nextd, shortDate )); |
322 | } | 322 | } |
323 | } | 323 | } |
324 | } else { | 324 | } else { |
325 | mMailSubject += i18n(" - " )+event->dtStartStr( true ); | 325 | mMailSubject += i18n(" - " )+event->dtStartStr( true ); |
326 | 326 | ||
327 | } | 327 | } |
328 | 328 | ||
329 | 329 | ||
330 | if (event->isAlarmEnabled()) { | 330 | if (event->isAlarmEnabled()) { |
331 | Alarm *alarm =event->alarms().first() ; | 331 | Alarm *alarm =event->alarms().first() ; |
332 | QDateTime t = alarm->time(); | 332 | QDateTime t = alarm->time(); |
333 | int min = t.secsTo( event->dtStart() )/60; | 333 | int min = t.secsTo( event->dtStart() )/60; |
334 | QString s =i18n("( %1 min before )").arg( min ); | 334 | QString s =i18n("( %1 min before )").arg( min ); |
335 | addTag("p",i18n("<b>Alarm on: ") + s +" </b>"); | 335 | addTag("p",i18n("<b>Alarm on: ") + s +" </b>"); |
336 | addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); | 336 | addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); |
337 | //addTag("p",s); | 337 | //addTag("p",s); |
338 | } | 338 | } |
339 | 339 | ||
340 | addTag("b",i18n("Access: ")); | 340 | addTag("b",i18n("Access: ")); |
341 | mText.append(event->secrecyStr()+"<br>"); | 341 | mText.append(event->secrecyStr()+"<br>"); |
342 | 342 | ||
343 | 343 | ||
344 | if ( KOPrefs::instance()->mEVshowDetails ) { | 344 | if ( KOPrefs::instance()->mEVshowDetails ) { |
345 | if (!event->description().isEmpty()) { | 345 | if (!event->description().isEmpty()) { |
346 | addTag("p",i18n("<b>Details: </b>")); | 346 | addTag("p",i18n("<b>Details: </b>")); |
347 | addTag("p",deTag(event->description())); | 347 | addTag("p",deTag(event->description())); |
348 | } | 348 | } |
349 | } | 349 | } |
350 | formatCategories(event); | 350 | formatCategories(event); |
351 | 351 | ||
352 | formatReadOnly(event); | 352 | formatReadOnly(event); |
353 | formatAttendees(event); | 353 | formatAttendees(event); |
354 | 354 | ||
355 | if ( KOPrefs::instance()->mEVshowCreated ) { | 355 | if ( KOPrefs::instance()->mEVshowCreated ) { |
356 | addTag("p",i18n("<b>Created: ") +" </b>"); | 356 | addTag("p",i18n("<b>Created: ") +" </b>"); |
357 | addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate )); | 357 | addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate )); |
358 | 358 | ||
359 | } | 359 | } |
360 | if ( KOPrefs::instance()->mEVshowChanged ) { | 360 | if ( KOPrefs::instance()->mEVshowChanged ) { |
361 | addTag("p",i18n("<b>Last modified: ") +" </b>"); | 361 | addTag("p",i18n("<b>Last modified: ") +" </b>"); |
362 | addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); | 362 | addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); |
363 | 363 | ||
364 | } | 364 | } |
365 | setText(mText); | 365 | setText(mText); |
366 | //QWhatsThis::add(this,mText); | 366 | //QWhatsThis::add(this,mText); |
367 | 367 | ||
368 | } | 368 | } |
369 | 369 | ||
370 | void KOEventViewer::appendTodo(Todo *event, int mode ) | 370 | void KOEventViewer::appendTodo(Todo *event, int mode ) |
371 | { | 371 | { |
372 | mMailSubject = ""; | 372 | mMailSubject = ""; |
373 | mCurrentIncidence = event; | 373 | mCurrentIncidence = event; |
374 | topLevelWidget()->setCaption(i18n("Todo Viewer")); | 374 | topLevelWidget()->setCaption(i18n("Todo Viewer")); |
375 | bool shortDate = KOPrefs::instance()->mShortDateInViewer; | 375 | bool shortDate = KOPrefs::instance()->mShortDateInViewer; |
376 | if (mode == 0 ) | 376 | if (mode == 0 ) |
377 | addTag("h2",deTag(event->summary())); | 377 | addTag("h2",deTag(event->summary())); |
378 | else { | 378 | else { |
379 | if ( mColorMode == 1 ) { | 379 | if ( mColorMode == 1 ) { |
380 | mText +="<font color=\"#00A000\">"; | 380 | mText +="<font color=\"#00A000\">"; |
381 | } | 381 | } |
382 | if ( mColorMode == 2 ) { | 382 | if ( mColorMode == 2 ) { |
383 | mText +="<font color=\"#B00000\">"; | 383 | mText +="<font color=\"#B00000\">"; |
384 | } | 384 | } |
385 | if ( mode == 1 ) { | 385 | if ( mode == 1 ) { |
386 | addTag("h2",i18n( "Local: " ) +deTag(event->summary())); | 386 | addTag("h2",i18n( "Local: " ) +deTag(event->summary())); |
387 | } else { | 387 | } else { |
388 | addTag("h2",i18n( "Remote: " ) +deTag(event->summary())); | 388 | addTag("h2",i18n( "Remote: " ) +deTag(event->summary())); |
389 | } | 389 | } |
390 | addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); | 390 | addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); |
391 | if ( mColorMode ) | 391 | if ( mColorMode ) |
392 | mText += "</font>"; | 392 | mText += "</font>"; |
393 | } | 393 | } |
394 | mMailSubject += i18n( "Todo " )+ event->summary(); | 394 | mMailSubject += i18n( "Todo " )+ event->summary(); |
395 | 395 | ||
396 | if ( event->percentComplete() == 100 && event->hasCompletedDate() ) { | 396 | if ( event->percentComplete() == 100 && event->hasCompletedDate() ) { |
397 | mText +="<font color=\"#B00000\">"; | 397 | mText +="<font color=\"#B00000\">"; |
398 | addTag("i", i18n("<p><i>Completed on %1</i></p>").arg( event->completedStr(KOPrefs::instance()->mShortDateInViewer) ) ); | 398 | addTag("i", i18n("<p><i>Completed on %1</i></p>").arg( event->completedStr(KOPrefs::instance()->mShortDateInViewer) ) ); |
399 | mText += "</font>"; | 399 | mText += "</font>"; |
400 | } else { | 400 | } else { |
401 | mText.append(i18n("<p><i>%1 % completed</i></p>") | 401 | mText.append(i18n("<p><i>%1 % completed</i></p>") |
402 | .arg(event->percentComplete())); | 402 | .arg(event->percentComplete())); |
403 | } | 403 | } |
404 | 404 | ||
405 | if (event->cancelled ()) { | 405 | if (event->cancelled ()) { |
406 | mText +="<font color=\"#B00000\">"; | 406 | mText +="<font color=\"#B00000\">"; |
407 | addTag("i",i18n("This todo has been cancelled!")); | 407 | addTag("i",i18n("This todo has been cancelled!")); |
408 | mText.append("<br>"); | 408 | mText.append("<br>"); |
409 | mText += "</font>"; | 409 | mText += "</font>"; |
410 | mMailSubject += i18n("(cancelled)"); | 410 | mMailSubject += i18n("(cancelled)"); |
411 | } | 411 | } |
412 | 412 | ||
413 | if (!event->location().isEmpty()) { | 413 | if (!event->location().isEmpty()) { |
414 | addTag("b",i18n("Location: ")); | 414 | addTag("b",i18n("Location: ")); |
415 | mText.append(deTag(event->location())+"<br>"); | 415 | mText.append(deTag(event->location())+"<br>"); |
416 | mMailSubject += i18n(" at ") + event->location(); | 416 | mMailSubject += i18n(" at ") + event->location(); |
417 | } | 417 | } |
418 | 418 | ||
419 | if (event->recurrence()->doesRecur()) { | 419 | if (event->recurrence()->doesRecur()) { |
420 | 420 | ||
421 | QString recurText = event->recurrence()->recurrenceText(); | 421 | QString recurText = event->recurrence()->recurrenceText(); |
422 | addTag("p","<em>" + i18n("This is a %1 recurring todo.").arg(recurText ) + "</em>"); | 422 | addTag("p","<em>" + i18n("This is a %1 recurring todo.").arg(recurText ) + "</em>"); |
423 | 423 | ||
424 | } | 424 | } |
425 | if (event->hasStartDate()) { | 425 | if (event->hasStartDate()) { |
426 | mText.append(i18n("<p><b>Start on:</b> %1</p>").arg(event->dtStartStr(KOPrefs::instance()->mShortDateInViewer))); | 426 | mText.append(i18n("<p><b>Start on:</b> %1</p>").arg(event->dtStartStr(KOPrefs::instance()->mShortDateInViewer))); |
427 | } | 427 | } |
428 | if (event->hasDueDate()) { | 428 | if (event->hasDueDate()) { |
429 | mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(KOPrefs::instance()->mShortDateInViewer))); | 429 | mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(KOPrefs::instance()->mShortDateInViewer))); |
430 | mMailSubject += i18n(" - " )+event->dtDueStr( true ); | 430 | mMailSubject += i18n(" - " )+event->dtDueStr( true ); |
431 | } | 431 | } |
432 | addTag("b",i18n("Access: ")); | 432 | addTag("b",i18n("Access: ")); |
433 | mText.append(event->secrecyStr()+"<br>"); | 433 | mText.append(event->secrecyStr()+"<br>"); |
434 | if ( KOPrefs::instance()->mEVshowDetails ) { | 434 | if ( KOPrefs::instance()->mEVshowDetails ) { |
435 | if (!event->description().isEmpty()) { | 435 | if (!event->description().isEmpty()) { |
436 | addTag("p",i18n("<b>Details: </b>")); | 436 | addTag("p",i18n("<b>Details: </b>")); |
437 | addTag("p",deTag(event->description())); | 437 | addTag("p",deTag(event->description())); |
438 | } | 438 | } |
439 | } | 439 | } |
440 | 440 | ||
441 | formatCategories(event); | 441 | formatCategories(event); |
442 | 442 | ||
443 | mText.append(i18n("<p><b>Priority:</b> %2</p>") | 443 | mText.append(i18n("<p><b>Priority:</b> %2</p>") |
444 | .arg(QString::number(event->priority()))); | 444 | .arg(QString::number(event->priority()))); |
445 | 445 | ||
446 | formatReadOnly(event); | 446 | formatReadOnly(event); |
447 | formatAttendees(event); | 447 | formatAttendees(event); |
448 | if ( event->relatedTo() ) { | 448 | if ( event->relatedTo() ) { |
449 | addTag("b",i18n("Parent todo:<br>")); | 449 | addTag("b",i18n("Parent todo:<br>")); |
450 | mText.append(deTag(event->relatedTo()->summary())+" [" +QString::number(event->relatedTo()->priority()) + "/" + QString::number(((Todo*)event->relatedTo())->percentComplete())+"%] <br>"); | 450 | mText.append(deTag(event->relatedTo()->summary())+" [" +QString::number(event->relatedTo()->priority()) + "/" + QString::number(((Todo*)event->relatedTo())->percentComplete())+"%] <br>"); |
451 | } | 451 | } |
452 | QPtrList<Incidence> Relations = event->relations(); | 452 | QPtrList<Incidence> Relations = event->relations(); |
453 | Incidence *to; | 453 | Incidence *to; |
454 | if ( Relations.first() ) | 454 | if ( Relations.first() ) |
455 | addTag("b",i18n("Sub todos:<br>")); | 455 | addTag("b",i18n("Sub todos:<br>")); |
456 | for (to=Relations.first();to;to=Relations.next()) { | 456 | for (to=Relations.first();to;to=Relations.next()) { |
457 | mText.append( deTag(to->summary())+" [" +QString::number(to->priority()) + "/" + QString::number(((Todo*)to)->percentComplete())+"%]<br>"); | 457 | mText.append( deTag(to->summary())+" [" +QString::number(to->priority()) + "/" + QString::number(((Todo*)to)->percentComplete())+"%]<br>"); |
458 | 458 | ||
459 | } | 459 | } |
460 | if ( KOPrefs::instance()->mEVshowCreated ) { | 460 | if ( KOPrefs::instance()->mEVshowCreated ) { |
461 | addTag("p",i18n("<b>Created: ") +" </b>"); | 461 | addTag("p",i18n("<b>Created: ") +" </b>"); |
462 | addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate )); | 462 | addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate )); |
463 | 463 | ||
464 | } | 464 | } |
465 | if ( KOPrefs::instance()->mEVshowChanged ) { | 465 | if ( KOPrefs::instance()->mEVshowChanged ) { |
466 | addTag("p",i18n("<b>Last modified: ") +" </b>"); | 466 | addTag("p",i18n("<b>Last modified: ") +" </b>"); |
467 | addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); | 467 | addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); |
468 | 468 | ||
469 | } | 469 | } |
470 | setText(mText); | 470 | setText(mText); |
471 | } | 471 | } |
472 | 472 | ||
473 | void KOEventViewer::formatCategories(Incidence *event) | 473 | void KOEventViewer::formatCategories(Incidence *event) |
474 | { | 474 | { |
475 | if (!event->categoriesStr().isEmpty()) { | 475 | if (!event->categoriesStr().isEmpty()) { |
476 | if (event->categories().count() == 1) { | 476 | if (event->categories().count() == 1) { |
477 | addTag("h3",i18n("Category")); | 477 | addTag("h3",i18n("Category")); |
478 | } else { | 478 | } else { |
479 | addTag("h3",i18n("Categories")); | 479 | addTag("h3",i18n("Categories")); |
480 | } | 480 | } |
481 | addTag("p",event->categoriesStr()); | 481 | addTag("p",event->categoriesStr()); |
482 | } | 482 | } |
483 | } | 483 | } |
484 | void KOEventViewer::formatAttendees(Incidence *event) | 484 | void KOEventViewer::formatAttendees(Incidence *event) |
485 | { | 485 | { |
486 | QPtrList<Attendee> attendees = event->attendees(); | 486 | QPtrList<Attendee> attendees = event->attendees(); |
487 | if (attendees.count()) { | 487 | if (attendees.count()) { |
488 | 488 | ||
489 | 489 | ||
490 | QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small); | 490 | QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small); |
491 | QString NOiconPath = KGlobal::iconLoader()->iconPath("nomailappt",KIcon::Small); | 491 | QString NOiconPath = KGlobal::iconLoader()->iconPath("nomailappt",KIcon::Small); |
492 | addTag("h3",i18n("Organizer")); | 492 | addTag("h3",i18n("Organizer")); |
493 | mText.append("<ul><li>"); | 493 | mText.append("<ul><li>"); |
494 | #ifndef KORG_NOKABC | 494 | #ifndef KORG_NOKABC |
495 | 495 | ||
496 | #ifdef DESKTOP_VERSION | 496 | #ifdef DESKTOP_VERSION |
497 | KABC::AddressBook *add_book = KABC::StdAddressBook::self(); | 497 | KABC::AddressBook *add_book = KABC::StdAddressBook::self(); |
498 | KABC::Addressee::List addressList; | 498 | KABC::Addressee::List addressList; |
499 | addressList = add_book->findByEmail(event->organizer()); | 499 | addressList = add_book->findByEmail(event->organizer()); |
500 | KABC::Addressee o = addressList.first(); | 500 | KABC::Addressee o = addressList.first(); |
501 | if (!o.isEmpty() && addressList.size()<2) { | 501 | if (!o.isEmpty() && addressList.size()<2) { |
502 | mText += "<a href=\"uid:" + o.uid() + "\">"; | 502 | mText += "<a href=\"uid:" + o.uid() + "\">"; |
503 | mText += o.formattedName(); | 503 | mText += o.formattedName(); |
504 | mText += "</a>\n"; | 504 | mText += "</a>\n"; |
505 | } else { | 505 | } else { |
506 | mText.append(event->organizer()); | 506 | mText.append(event->organizer()); |
507 | } | 507 | } |
508 | #else //DESKTOP_VERSION | 508 | #else //DESKTOP_VERSION |
509 | mText += "<a href=\"uid:organizer\">"; | 509 | mText += "<a href=\"uid:organizer\">"; |
510 | mText += event->organizer(); | 510 | mText += event->organizer(); |
511 | mText += "</a>\n"; | 511 | mText += "</a>\n"; |
512 | #endif //DESKTOP_VERSION | 512 | #endif //DESKTOP_VERSION |
513 | 513 | ||
514 | 514 | ||
515 | #else | 515 | #else |
516 | mText.append(event->organizer()); | 516 | mText.append(event->organizer()); |
517 | #endif | 517 | #endif |
518 | 518 | ||
519 | if (iconPath) { | 519 | if (iconPath) { |
520 | mText += " <a href=\"mailto:" + event->organizer() + "\">"; | 520 | mText += " <a href=\"mailto:" + event->organizer() + "\">"; |
521 | mText += "<IMG src=\"" + iconPath + "\">"; | 521 | mText += "<IMG src=\"" + iconPath + "\">"; |
522 | mText += "</a>\n"; | 522 | mText += "</a>\n"; |
523 | } | 523 | } |
524 | mText.append("</li></ul>"); | 524 | mText.append("</li></ul>"); |
525 | 525 | ||
526 | addTag("h3",i18n("Attendees")); | 526 | addTag("h3",i18n("Attendees")); |
527 | Attendee *a; | 527 | Attendee *a; |
528 | mText.append("<ul>"); | 528 | mText.append("<ul>"); |
529 | int a_count = 0; | 529 | int a_count = 0; |
530 | int a_count_nr = 0; | 530 | int a_count_nr = 0; |
531 | 531 | ||
532 | for(a=attendees.first();a;a=attendees.next()) { | 532 | for(a=attendees.first();a;a=attendees.next()) { |
533 | #ifndef KORG_NOKABC | 533 | #ifndef KORG_NOKABC |
534 | #ifdef DESKTOP_VERSION | 534 | #ifdef DESKTOP_VERSION |
535 | if (a->name().isEmpty()) { | 535 | if (a->name().isEmpty()) { |
536 | addressList = add_book->findByEmail(a->email()); | 536 | addressList = add_book->findByEmail(a->email()); |
537 | KABC::Addressee o = addressList.first(); | 537 | KABC::Addressee o = addressList.first(); |
538 | if (!o.isEmpty() && addressList.size()<2) { | 538 | if (!o.isEmpty() && addressList.size()<2) { |
539 | mText += "<a href=\"uid:" + o.uid() + "\">"; | 539 | mText += "<a href=\"uid:" + o.uid() + "\">"; |
540 | mText += o.formattedName(); | 540 | mText += o.formattedName(); |
541 | mText += "</a>\n"; | 541 | mText += "</a>\n"; |
542 | } else { | 542 | } else { |
543 | mText += "<li>"; | 543 | mText += "<li>"; |
544 | mText.append(a->email()); | 544 | mText.append(a->email()); |
545 | mText += "\n"; | 545 | mText += "\n"; |
546 | } | 546 | } |
547 | } else { | 547 | } else { |
548 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; | 548 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; |
549 | if (!a->name().isEmpty()) mText += a->name(); | 549 | if (!a->name().isEmpty()) mText += a->name(); |
550 | else mText += a->email(); | 550 | else mText += a->email(); |
551 | mText += "</a>\n"; | 551 | mText += "</a>\n"; |
552 | } | 552 | } |
553 | #else //DESKTOP_VERSION | 553 | #else //DESKTOP_VERSION |
554 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; | 554 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; |
555 | if (!a->name().isEmpty()) mText += a->name(); | 555 | if (!a->name().isEmpty()) mText += a->name(); |
556 | else mText += a->email(); | 556 | else mText += a->email(); |
557 | mText += "</a>\n"; | 557 | mText += "</a>\n"; |
558 | #endif //DESKTOP_VERSION | 558 | #endif //DESKTOP_VERSION |
559 | #else | 559 | #else |
560 | //qDebug("nokabc "); | 560 | //qDebug("nokabc "); |
561 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; | 561 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; |
562 | if (!a->name().isEmpty()) mText += a->name(); | 562 | if (!a->name().isEmpty()) mText += a->name(); |
563 | else mText += a->email(); | 563 | else mText += a->email(); |
564 | mText += "</a>\n"; | 564 | mText += "</a>\n"; |
565 | #endif | 565 | #endif |
566 | 566 | ||
567 | 567 | ||
568 | if (!a->email().isEmpty()) { | 568 | if (!a->email().isEmpty()) { |
569 | if (iconPath) { | 569 | if (iconPath) { |
570 | mText += "<a href=\"mailto:" + a->name() +" <" + a->email() + ">:" + mMailSubject + "\">"; | 570 | mText += "<a href=\"mailto:" + a->name() +" <" + a->email() + ">:" + mMailSubject + "\">"; |
571 | if ( a->RSVP() ) { | 571 | if ( a->RSVP() ) { |
572 | ++a_count_nr; | 572 | ++a_count_nr; |
573 | mText += "<IMG src=\"" + iconPath + "\">"; | 573 | mText += "<IMG src=\"" + iconPath + "\">"; |
574 | } | 574 | } |
575 | else { | 575 | else { |
576 | ++a_count; | 576 | ++a_count; |
577 | mText += "<IMG src=\"" + NOiconPath + "\">"; | 577 | mText += "<IMG src=\"" + NOiconPath + "\">"; |
578 | } | 578 | } |
579 | mText += "</a>\n"; | 579 | mText += "</a>\n"; |
580 | } | 580 | } |
581 | } | 581 | } |
582 | if (a->status() != Attendee::NeedsAction ) | 582 | if (a->status() != Attendee::NeedsAction ) |
583 | mText +="[" + a->statusStr() + "] "; | 583 | mText +="[" + a->statusStr() + "] "; |
584 | if (a->role() == Attendee::Chair ) | 584 | if (a->role() == Attendee::Chair ) |
585 | mText +="(" + a->roleStr().left(1) + ".)"; | 585 | mText +="(" + a->roleStr().left(1) + ".)"; |
586 | } | 586 | } |
587 | mText.append("</li></ul>"); | 587 | mText.append("</li></ul>"); |
588 | if ( (a_count+a_count_nr) > 1 ) { | 588 | if ( (a_count+a_count_nr) > 1 ) { |
589 | mText += "<a href=\"mailto:ALL\">"; | 589 | mText += "<a href=\"mailto:ALL\">"; |
590 | mText += i18n( "Mail to all" ); | 590 | mText += i18n( "Mail to all" ); |
591 | mText += "</a> ( "; | 591 | mText += "</a> ( "; |
592 | mText += "<IMG src=\"" + iconPath + "\">"; | 592 | mText += "<IMG src=\"" + iconPath + "\">"; |
593 | mText += i18n( " and " ); | 593 | mText += i18n( " and " ); |
594 | mText += "<IMG src=\"" + NOiconPath + "\"> )"; | 594 | mText += "<IMG src=\"" + NOiconPath + "\"> )"; |
595 | mText += "<br>\n"; | 595 | mText += "<br>\n"; |
596 | 596 | ||
597 | 597 | ||
598 | } | 598 | } |
599 | if ( a_count_nr > 1 ) { | 599 | if ( a_count_nr > 1 ) { |
600 | mText += "<a href=\"mailto:RSVP\">"; | 600 | mText += "<a href=\"mailto:RSVP\">"; |
601 | mText += i18n( "Mail to selected" ); | 601 | mText += i18n( "Mail to selected" ); |
602 | mText += "</a> ( "; | 602 | mText += "</a> ( "; |
603 | mText += i18n( "<IMG src=\"%1\"> only )").arg ( iconPath ); | 603 | mText += i18n( "<IMG src=\"%1\"> only )").arg ( iconPath ); |
604 | mText += "<br>\n"; | 604 | mText += "<br>\n"; |
605 | } | 605 | } |
606 | } | 606 | } |
607 | 607 | ||
608 | } | 608 | } |
609 | void KOEventViewer::appendJournal(Journal *jour, int mode ) | 609 | void KOEventViewer::appendJournal(Journal *jour, int mode ) |
610 | { | 610 | { |
611 | bool shortDate = KOPrefs::instance()->mShortDateInViewer; | 611 | bool shortDate = KOPrefs::instance()->mShortDateInViewer; |
612 | if (mode == 0 ) { | 612 | if (mode == 0 ) { |
613 | addTag("h2",i18n("Journal from: ")); | 613 | addTag("h2",i18n("Journal from: ")); |
614 | } | 614 | } |
615 | else { | 615 | else { |
616 | if ( mode == 1 ) { | 616 | if ( mode == 1 ) { |
617 | addTag("h2",i18n( "Local: " ) +i18n("Journal from: ")); | 617 | addTag("h2",i18n( "Local: " ) +i18n("Journal from: ")); |
618 | } else { | 618 | } else { |
619 | addTag("h2",i18n( "Remote: " ) +i18n("Journal from: ")); | 619 | addTag("h2",i18n( "Remote: " ) +i18n("Journal from: ")); |
620 | } | 620 | } |
621 | } | 621 | } |
622 | topLevelWidget()->setCaption("Journal Viewer"); | 622 | topLevelWidget()->setCaption("Journal Viewer"); |
623 | mText.append(i18n("<h3> %1 </h3> ").arg(jour->dtStartDateStr(KOPrefs::instance()->mShortDateInViewer))); | 623 | mText.append(i18n("<h3> %1 </h3> ").arg(jour->dtStartDateStr(KOPrefs::instance()->mShortDateInViewer))); |
624 | addTag("b",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(jour->lastModified(),shortDate ) ); | 624 | addTag("b",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(jour->lastModified(),shortDate ) ); |
625 | if (!jour->description().isEmpty()) { | 625 | if (!jour->description().isEmpty()) { |
626 | addTag("p",deTag(jour->description())); | 626 | addTag("p",deTag(jour->description())); |
627 | } | 627 | } |
628 | setText(mText); | 628 | setText(mText); |
629 | } | 629 | } |
630 | 630 | ||
631 | void KOEventViewer::formatReadOnly(Incidence *event) | 631 | void KOEventViewer::formatReadOnly(Incidence *event) |
632 | { | 632 | { |
633 | if (event->isReadOnly()) { | 633 | if (event->isReadOnly()) { |
634 | addTag("p","<em>(" + i18n("read-only") + ")</em>"); | 634 | addTag("p","<em>(" + i18n("read-only") + ")</em>"); |
635 | } | 635 | } |
636 | } | 636 | } |
637 | void KOEventViewer::setSyncMode( bool b ) | 637 | void KOEventViewer::setSyncMode( bool b ) |
638 | { | 638 | { |
639 | mSyncMode = b; | 639 | mSyncMode = b; |
640 | } | 640 | } |
641 | 641 | ||
642 | void KOEventViewer::setTodo(Todo *event, bool clearV ) | 642 | void KOEventViewer::setTodo(Todo *event, bool clearV ) |
643 | { | 643 | { |
644 | if ( clearV ) | 644 | if ( clearV ) |
645 | clearEvents(); | 645 | clearEvents(); |
646 | if ( mSyncMode ) { | 646 | if ( mSyncMode ) { |
647 | if ( clearV ) | 647 | if ( clearV ) |
648 | appendTodo(event,1 ); | 648 | appendTodo(event,1 ); |
649 | else | 649 | else |
650 | appendTodo(event,2); | 650 | appendTodo(event,2); |
651 | } else | 651 | } else |
652 | appendTodo(event); | 652 | appendTodo(event); |
653 | } | 653 | } |
654 | void KOEventViewer::setJournal(Journal *event, bool clearV ) | 654 | void KOEventViewer::setJournal(Journal *event, bool clearV ) |
655 | { | 655 | { |
656 | if ( clearV ) | 656 | if ( clearV ) |
657 | clearEvents(); | 657 | clearEvents(); |
658 | if ( mSyncMode ) { | 658 | if ( mSyncMode ) { |
659 | if ( clearV ) | 659 | if ( clearV ) |
660 | appendJournal(event, 1); | 660 | appendJournal(event, 1); |
661 | else | 661 | else |
662 | appendJournal(event, 2); | 662 | appendJournal(event, 2); |
663 | } else | 663 | } else |
664 | appendJournal(event); | 664 | appendJournal(event); |
665 | } | 665 | } |
666 | 666 | ||
667 | void KOEventViewer::setEvent(Event *event) | 667 | void KOEventViewer::setEvent(Event *event) |
668 | { | 668 | { |
669 | clearEvents(); | 669 | clearEvents(); |
670 | if ( mSyncMode ) | 670 | if ( mSyncMode ) |
671 | appendEvent(event, 1); | 671 | appendEvent(event, 1); |
672 | else | 672 | else |
673 | appendEvent(event); | 673 | appendEvent(event); |
674 | } | 674 | } |
675 | 675 | ||
676 | void KOEventViewer::addEvent(Event *event) | 676 | void KOEventViewer::addEvent(Event *event) |
677 | { | 677 | { |
678 | if ( mSyncMode ) | 678 | if ( mSyncMode ) |
679 | appendEvent(event, 2); | 679 | appendEvent(event, 2); |
680 | else | 680 | else |
681 | appendEvent(event); | 681 | appendEvent(event); |
682 | } | 682 | } |
683 | 683 | ||
684 | void KOEventViewer::clearEvents(bool now) | 684 | void KOEventViewer::clearEvents(bool now) |
685 | { | 685 | { |
686 | mText = ""; | 686 | mText = ""; |
687 | if (now) setText(mText); | 687 | if (now) setText(mText); |
688 | } | 688 | } |
689 | 689 | ||
690 | void KOEventViewer::addText(QString text) | 690 | void KOEventViewer::addText(QString text) |
691 | { | 691 | { |
692 | mText.append(text); | 692 | mText.append(text); |
693 | setText(mText); | 693 | setText(mText); |
694 | } | 694 | } |
695 | QString KOEventViewer::deTag(QString text) | 695 | QString KOEventViewer::deTag(QString text) |
696 | { | 696 | { |
697 | #if QT_VERSION >= 0x030000 | 697 | #if QT_VERSION >= 0x030000 |
698 | text.replace( '<' , "<" ); | 698 | text.replace( '<' , "<" ); |
699 | text.replace( '>' , ">" ); | 699 | text.replace( '>' , ">" ); |
700 | #else | 700 | #else |
701 | if ( text.find ('<') > 0 ) { | 701 | if ( text.find ('<') >= 0 ) { |
702 | text.replace( QRegExp("<") , "<" ); | 702 | text.replace( QRegExp("<") , "<" ); |
703 | } | 703 | } |
704 | if ( text.find ('>') > 0 ) { | 704 | if ( text.find ('>') >= 0 ) { |
705 | text.replace( QRegExp(">") , ">" ); | 705 | text.replace( QRegExp(">") , ">" ); |
706 | } | 706 | } |
707 | #endif | 707 | #endif |
708 | return text; | 708 | return text; |
709 | } | 709 | } |
710 | void KOEventViewer::keyPressEvent ( QKeyEvent * e ) | 710 | void KOEventViewer::keyPressEvent ( QKeyEvent * e ) |
711 | { | 711 | { |
712 | switch ( e->key() ) { | 712 | switch ( e->key() ) { |
713 | case Qt::Key_Return: | 713 | case Qt::Key_Return: |
714 | case Qt::Key_Enter : | 714 | case Qt::Key_Enter : |
715 | e->ignore(); | 715 | e->ignore(); |
716 | break; | 716 | break; |
717 | default: | 717 | default: |
718 | QTextBrowser::keyPressEvent ( e ); | 718 | QTextBrowser::keyPressEvent ( e ); |
719 | break; | 719 | break; |
720 | } | 720 | } |
721 | } | 721 | } |
diff --git a/libkcal/kincidenceformatter.cpp b/libkcal/kincidenceformatter.cpp index 57a9ede..e506a96 100644 --- a/libkcal/kincidenceformatter.cpp +++ b/libkcal/kincidenceformatter.cpp | |||
@@ -1,393 +1,393 @@ | |||
1 | #include "kincidenceformatter.h" | 1 | #include "kincidenceformatter.h" |
2 | #include <kstaticdeleter.h> | 2 | #include <kstaticdeleter.h> |
3 | #include <kglobal.h> | 3 | #include <kglobal.h> |
4 | #include <klocale.h> | 4 | #include <klocale.h> |
5 | #ifdef DEKTOP_VERSION | 5 | #ifdef DEKTOP_VERSION |
6 | #include <kabc/stdaddressbook.h> | 6 | #include <kabc/stdaddressbook.h> |
7 | #define size count | 7 | #define size count |
8 | #endif | 8 | #endif |
9 | 9 | ||
10 | KIncidenceFormatter* KIncidenceFormatter::mInstance = 0; | 10 | KIncidenceFormatter* KIncidenceFormatter::mInstance = 0; |
11 | static KStaticDeleter<KIncidenceFormatter> insd; | 11 | static KStaticDeleter<KIncidenceFormatter> insd; |
12 | 12 | ||
13 | QString KIncidenceFormatter::getFormattedText( Incidence * inc, bool details, bool created , bool modified ) | 13 | QString KIncidenceFormatter::getFormattedText( Incidence * inc, bool details, bool created , bool modified ) |
14 | { | 14 | { |
15 | // #ifndef QT_NO_INPUTDIALOG | 15 | // #ifndef QT_NO_INPUTDIALOG |
16 | // return QInputDialog::getItem( caption, label, items, current, editable ); | 16 | // return QInputDialog::getItem( caption, label, items, current, editable ); |
17 | // #else | 17 | // #else |
18 | // return QString::null; | 18 | // return QString::null; |
19 | // #endif | 19 | // #endif |
20 | mDetails = details; | 20 | mDetails = details; |
21 | mCreated = created ; | 21 | mCreated = created ; |
22 | mModified = modified; | 22 | mModified = modified; |
23 | mText = ""; | 23 | mText = ""; |
24 | if ( inc->type() == "Event" ) | 24 | if ( inc->type() == "Event" ) |
25 | setEvent((Event *) inc ); | 25 | setEvent((Event *) inc ); |
26 | else if ( inc->type() == "Todo" ) | 26 | else if ( inc->type() == "Todo" ) |
27 | setTodo((Todo *) inc ); | 27 | setTodo((Todo *) inc ); |
28 | return mText; | 28 | return mText; |
29 | } | 29 | } |
30 | 30 | ||
31 | KIncidenceFormatter* KIncidenceFormatter::instance() | 31 | KIncidenceFormatter* KIncidenceFormatter::instance() |
32 | { | 32 | { |
33 | if (!mInstance) { | 33 | if (!mInstance) { |
34 | mInstance = insd.setObject(new KIncidenceFormatter()); | 34 | mInstance = insd.setObject(new KIncidenceFormatter()); |
35 | } | 35 | } |
36 | return mInstance; | 36 | return mInstance; |
37 | } | 37 | } |
38 | KIncidenceFormatter::~KIncidenceFormatter() | 38 | KIncidenceFormatter::~KIncidenceFormatter() |
39 | { | 39 | { |
40 | if (mInstance == this) | 40 | if (mInstance == this) |
41 | mInstance = insd.setObject(0); | 41 | mInstance = insd.setObject(0); |
42 | //qDebug("KIncidenceFormatter::~KIncidenceFormatter "); | 42 | //qDebug("KIncidenceFormatter::~KIncidenceFormatter "); |
43 | } | 43 | } |
44 | KIncidenceFormatter::KIncidenceFormatter() | 44 | KIncidenceFormatter::KIncidenceFormatter() |
45 | { | 45 | { |
46 | mColorMode = 0; | 46 | mColorMode = 0; |
47 | } | 47 | } |
48 | void KIncidenceFormatter::setEvent(Event *event) | 48 | void KIncidenceFormatter::setEvent(Event *event) |
49 | { | 49 | { |
50 | int mode = 0; | 50 | int mode = 0; |
51 | mCurrentIncidence = event; | 51 | mCurrentIncidence = event; |
52 | bool shortDate = true; | 52 | bool shortDate = true; |
53 | if ( mode == 0 ) { | 53 | if ( mode == 0 ) { |
54 | addTag("h3",deTag(event->summary())); | 54 | addTag("h3",deTag(event->summary())); |
55 | } | 55 | } |
56 | else { | 56 | else { |
57 | if ( mColorMode == 1 ) { | 57 | if ( mColorMode == 1 ) { |
58 | mText +="<font color=\"#00A000\">"; | 58 | mText +="<font color=\"#00A000\">"; |
59 | } | 59 | } |
60 | if ( mColorMode == 2 ) { | 60 | if ( mColorMode == 2 ) { |
61 | mText +="<font color=\"#C00000\">"; | 61 | mText +="<font color=\"#C00000\">"; |
62 | } | 62 | } |
63 | // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; | 63 | // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; |
64 | if ( mode == 1 ) { | 64 | if ( mode == 1 ) { |
65 | addTag("h2",i18n( "Local: " ) +deTag(event->summary())); | 65 | addTag("h2",i18n( "Local: " ) +deTag(event->summary())); |
66 | } else { | 66 | } else { |
67 | addTag("h2",i18n( "Remote: " ) +deTag(event->summary())); | 67 | addTag("h2",i18n( "Remote: " ) +deTag(event->summary())); |
68 | } | 68 | } |
69 | addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); | 69 | addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); |
70 | if ( mColorMode ) | 70 | if ( mColorMode ) |
71 | mText += "</font>"; | 71 | mText += "</font>"; |
72 | } | 72 | } |
73 | if (event->cancelled ()) { | 73 | if (event->cancelled ()) { |
74 | mText +="<font color=\"#B00000\">"; | 74 | mText +="<font color=\"#B00000\">"; |
75 | addTag("i",i18n("This event has been cancelled!")); | 75 | addTag("i",i18n("This event has been cancelled!")); |
76 | mText.append("<br>"); | 76 | mText.append("<br>"); |
77 | mText += "</font>"; | 77 | mText += "</font>"; |
78 | } | 78 | } |
79 | if (!event->location().isEmpty()) { | 79 | if (!event->location().isEmpty()) { |
80 | addTag("b",i18n("Location: ")); | 80 | addTag("b",i18n("Location: ")); |
81 | mText.append(deTag(event->location())+"<br>"); | 81 | mText.append(deTag(event->location())+"<br>"); |
82 | } | 82 | } |
83 | if (event->doesFloat()) { | 83 | if (event->doesFloat()) { |
84 | if (event->isMultiDay()) { | 84 | if (event->isMultiDay()) { |
85 | mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>") | 85 | mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>") |
86 | .arg(event->dtStartDateStr(shortDate)) | 86 | .arg(event->dtStartDateStr(shortDate)) |
87 | .arg(event->dtEndDateStr(shortDate))); | 87 | .arg(event->dtEndDateStr(shortDate))); |
88 | } else { | 88 | } else { |
89 | mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate ))); | 89 | mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate ))); |
90 | } | 90 | } |
91 | } else { | 91 | } else { |
92 | if (event->isMultiDay()) { | 92 | if (event->isMultiDay()) { |
93 | mText.append(i18n("<p><b>From:</b> %1</p> ") | 93 | mText.append(i18n("<p><b>From:</b> %1</p> ") |
94 | .arg(event->dtStartStr( shortDate))); | 94 | .arg(event->dtStartStr( shortDate))); |
95 | mText.append(i18n("<p><b>To:</b> %1</p>") | 95 | mText.append(i18n("<p><b>To:</b> %1</p>") |
96 | .arg(event->dtEndStr(shortDate))); | 96 | .arg(event->dtEndStr(shortDate))); |
97 | } else { | 97 | } else { |
98 | mText.append(i18n("<p><b>On:</b> %1</p> ") | 98 | mText.append(i18n("<p><b>On:</b> %1</p> ") |
99 | .arg(event->dtStartDateStr( shortDate ))); | 99 | .arg(event->dtStartDateStr( shortDate ))); |
100 | mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>") | 100 | mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>") |
101 | .arg(event->dtStartTimeStr()) | 101 | .arg(event->dtStartTimeStr()) |
102 | .arg(event->dtEndTimeStr())); | 102 | .arg(event->dtEndTimeStr())); |
103 | } | 103 | } |
104 | } | 104 | } |
105 | 105 | ||
106 | if (event->recurrence()->doesRecur()) { | 106 | if (event->recurrence()->doesRecur()) { |
107 | 107 | ||
108 | QString recurText = event->recurrence()->recurrenceText(); | 108 | QString recurText = event->recurrence()->recurrenceText(); |
109 | addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>"); | 109 | addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>"); |
110 | 110 | ||
111 | bool ok; | 111 | bool ok; |
112 | QDate start = QDate::currentDate(); | 112 | QDate start = QDate::currentDate(); |
113 | QDateTime next; | 113 | QDateTime next; |
114 | next = event->getNextOccurence( QDateTime::currentDateTime() , &ok ); | 114 | next = event->getNextOccurence( QDateTime::currentDateTime() , &ok ); |
115 | if ( ok ) { | 115 | if ( ok ) { |
116 | addTag("p",i18n("<b>Next recurrence is on:</b>") ); | 116 | addTag("p",i18n("<b>Next recurrence is on:</b>") ); |
117 | addTag("p", KGlobal::locale()->formatDate( next.date(), shortDate )); | 117 | addTag("p", KGlobal::locale()->formatDate( next.date(), shortDate )); |
118 | 118 | ||
119 | } else { | 119 | } else { |
120 | bool last; | 120 | bool last; |
121 | QDate nextd; | 121 | QDate nextd; |
122 | nextd = event->recurrence()->getPreviousDate( QDate::currentDate() , &last ); | 122 | nextd = event->recurrence()->getPreviousDate( QDate::currentDate() , &last ); |
123 | if ( last ) { | 123 | if ( last ) { |
124 | addTag("p",i18n("<b>Last recurrence was on:</b>") ); | 124 | addTag("p",i18n("<b>Last recurrence was on:</b>") ); |
125 | addTag("p", KGlobal::locale()->formatDate( nextd, shortDate )); | 125 | addTag("p", KGlobal::locale()->formatDate( nextd, shortDate )); |
126 | } | 126 | } |
127 | } | 127 | } |
128 | } | 128 | } |
129 | 129 | ||
130 | 130 | ||
131 | if (event->isAlarmEnabled()) { | 131 | if (event->isAlarmEnabled()) { |
132 | Alarm *alarm =event->alarms().first() ; | 132 | Alarm *alarm =event->alarms().first() ; |
133 | QDateTime t = alarm->time(); | 133 | QDateTime t = alarm->time(); |
134 | int min = t.secsTo( event->dtStart() )/60; | 134 | int min = t.secsTo( event->dtStart() )/60; |
135 | QString s =i18n("(%1 min before)").arg( min ); | 135 | QString s =i18n("(%1 min before)").arg( min ); |
136 | addTag("p",i18n("<b>Alarm on: </b>") + s + ": "+KGlobal::locale()->formatDateTime( t, shortDate )); | 136 | addTag("p",i18n("<b>Alarm on: </b>") + s + ": "+KGlobal::locale()->formatDateTime( t, shortDate )); |
137 | //addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); | 137 | //addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); |
138 | //addTag("p",s); | 138 | //addTag("p",s); |
139 | } | 139 | } |
140 | 140 | ||
141 | addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() ); | 141 | addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() ); |
142 | // mText.append(event->secrecyStr()+"<br>"); | 142 | // mText.append(event->secrecyStr()+"<br>"); |
143 | formatCategories(event); | 143 | formatCategories(event); |
144 | if ( mDetails ) { | 144 | if ( mDetails ) { |
145 | if (!event->description().isEmpty()) { | 145 | if (!event->description().isEmpty()) { |
146 | addTag("p",i18n("<b>Details: </b>")); | 146 | addTag("p",i18n("<b>Details: </b>")); |
147 | addTag("p",deTag(event->description())); | 147 | addTag("p",deTag(event->description())); |
148 | } | 148 | } |
149 | } | 149 | } |
150 | 150 | ||
151 | formatReadOnly(event); | 151 | formatReadOnly(event); |
152 | formatAttendees(event); | 152 | formatAttendees(event); |
153 | 153 | ||
154 | if ( mCreated ) { | 154 | if ( mCreated ) { |
155 | addTag("p",i18n("<b>Created: ") +" </b>"); | 155 | addTag("p",i18n("<b>Created: ") +" </b>"); |
156 | addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate )); | 156 | addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate )); |
157 | 157 | ||
158 | } | 158 | } |
159 | if ( mModified ) { | 159 | if ( mModified ) { |
160 | addTag("p",i18n("<b>Last modified: ") +" </b>"); | 160 | addTag("p",i18n("<b>Last modified: ") +" </b>"); |
161 | addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); | 161 | addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); |
162 | 162 | ||
163 | } | 163 | } |
164 | 164 | ||
165 | } | 165 | } |
166 | 166 | ||
167 | void KIncidenceFormatter::setTodo(Todo *event ) | 167 | void KIncidenceFormatter::setTodo(Todo *event ) |
168 | { | 168 | { |
169 | int mode = 0; | 169 | int mode = 0; |
170 | mCurrentIncidence = event; | 170 | mCurrentIncidence = event; |
171 | bool shortDate = true; | 171 | bool shortDate = true; |
172 | if (mode == 0 ) | 172 | if (mode == 0 ) |
173 | addTag("h3",deTag(event->summary())); | 173 | addTag("h3",deTag(event->summary())); |
174 | else { | 174 | else { |
175 | if ( mColorMode == 1 ) { | 175 | if ( mColorMode == 1 ) { |
176 | mText +="<font color=\"#00A000\">"; | 176 | mText +="<font color=\"#00A000\">"; |
177 | } | 177 | } |
178 | if ( mColorMode == 2 ) { | 178 | if ( mColorMode == 2 ) { |
179 | mText +="<font color=\"#B00000\">"; | 179 | mText +="<font color=\"#B00000\">"; |
180 | } | 180 | } |
181 | if ( mode == 1 ) { | 181 | if ( mode == 1 ) { |
182 | addTag("h2",i18n( "Local: " ) +deTag(event->summary())); | 182 | addTag("h2",i18n( "Local: " ) +deTag(event->summary())); |
183 | } else { | 183 | } else { |
184 | addTag("h2",i18n( "Remote: " ) +deTag(event->summary())); | 184 | addTag("h2",i18n( "Remote: " ) +deTag(event->summary())); |
185 | } | 185 | } |
186 | addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); | 186 | addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); |
187 | if ( mColorMode ) | 187 | if ( mColorMode ) |
188 | mText += "</font>"; | 188 | mText += "</font>"; |
189 | } | 189 | } |
190 | if ( event->percentComplete() == 100 && event->hasCompletedDate() ) { | 190 | if ( event->percentComplete() == 100 && event->hasCompletedDate() ) { |
191 | mText +="<font color=\"#B00000\">"; | 191 | mText +="<font color=\"#B00000\">"; |
192 | addTag("i", i18n("<p><i>Completed on %1</i></p>").arg( event->completedStr(shortDate) ) ); | 192 | addTag("i", i18n("<p><i>Completed on %1</i></p>").arg( event->completedStr(shortDate) ) ); |
193 | mText += "</font>"; | 193 | mText += "</font>"; |
194 | } else { | 194 | } else { |
195 | mText.append(i18n("<p><i>%1 % completed</i></p>") | 195 | mText.append(i18n("<p><i>%1 % completed</i></p>") |
196 | .arg(event->percentComplete())); | 196 | .arg(event->percentComplete())); |
197 | } | 197 | } |
198 | if (event->cancelled ()) { | 198 | if (event->cancelled ()) { |
199 | mText +="<font color=\"#B00000\">"; | 199 | mText +="<font color=\"#B00000\">"; |
200 | addTag("i",i18n("This todo has been cancelled!")); | 200 | addTag("i",i18n("This todo has been cancelled!")); |
201 | mText.append("<br>"); | 201 | mText.append("<br>"); |
202 | mText += "</font>"; | 202 | mText += "</font>"; |
203 | } | 203 | } |
204 | 204 | ||
205 | if (!event->location().isEmpty()) { | 205 | if (!event->location().isEmpty()) { |
206 | addTag("b",i18n("Location: ")); | 206 | addTag("b",i18n("Location: ")); |
207 | mText.append(deTag(event->location())+"<br>"); | 207 | mText.append(deTag(event->location())+"<br>"); |
208 | } | 208 | } |
209 | 209 | ||
210 | if (event->recurrence()->doesRecur()) { | 210 | if (event->recurrence()->doesRecur()) { |
211 | 211 | ||
212 | QString recurText = event->recurrence()->recurrenceText(); | 212 | QString recurText = event->recurrence()->recurrenceText(); |
213 | addTag("p","<em>" + i18n("This is a %1 recurring todo.").arg(recurText ) + "</em>"); | 213 | addTag("p","<em>" + i18n("This is a %1 recurring todo.").arg(recurText ) + "</em>"); |
214 | } | 214 | } |
215 | 215 | ||
216 | if (event->hasStartDate()) { | 216 | if (event->hasStartDate()) { |
217 | mText.append(i18n("<p><b>Start on:</b> %1</p>").arg(event->dtStartStr(shortDate))); | 217 | mText.append(i18n("<p><b>Start on:</b> %1</p>").arg(event->dtStartStr(shortDate))); |
218 | } | 218 | } |
219 | 219 | ||
220 | 220 | ||
221 | if (event->hasDueDate()) { | 221 | if (event->hasDueDate()) { |
222 | mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(shortDate))); | 222 | mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(shortDate))); |
223 | } | 223 | } |
224 | mText.append(i18n("<p><b>Priority:</b> %2</p>") | 224 | mText.append(i18n("<p><b>Priority:</b> %2</p>") |
225 | .arg(QString::number(event->priority()))); | 225 | .arg(QString::number(event->priority()))); |
226 | 226 | ||
227 | addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() ); | 227 | addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() ); |
228 | formatCategories(event); | 228 | formatCategories(event); |
229 | if ( mDetails ) { | 229 | if ( mDetails ) { |
230 | if (!event->description().isEmpty()) { | 230 | if (!event->description().isEmpty()) { |
231 | addTag("p",i18n("<b>Details: </b>")); | 231 | addTag("p",i18n("<b>Details: </b>")); |
232 | addTag("p",deTag(event->description())); | 232 | addTag("p",deTag(event->description())); |
233 | } | 233 | } |
234 | } | 234 | } |
235 | formatReadOnly(event); | 235 | formatReadOnly(event); |
236 | formatAttendees(event); | 236 | formatAttendees(event); |
237 | if ( mCreated ) { | 237 | if ( mCreated ) { |
238 | addTag("p",i18n("<b>Created: ") +" </b>"); | 238 | addTag("p",i18n("<b>Created: ") +" </b>"); |
239 | addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate )); | 239 | addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate )); |
240 | 240 | ||
241 | } | 241 | } |
242 | if ( mModified ) { | 242 | if ( mModified ) { |
243 | addTag("p",i18n("<b>Last modified: ") +" </b>"); | 243 | addTag("p",i18n("<b>Last modified: ") +" </b>"); |
244 | addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); | 244 | addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); |
245 | 245 | ||
246 | } | 246 | } |
247 | } | 247 | } |
248 | 248 | ||
249 | void KIncidenceFormatter::setJournal(Journal* ) | 249 | void KIncidenceFormatter::setJournal(Journal* ) |
250 | { | 250 | { |
251 | 251 | ||
252 | } | 252 | } |
253 | 253 | ||
254 | void KIncidenceFormatter::formatCategories(Incidence *event) | 254 | void KIncidenceFormatter::formatCategories(Incidence *event) |
255 | { | 255 | { |
256 | if (!event->categoriesStr().isEmpty()) { | 256 | if (!event->categoriesStr().isEmpty()) { |
257 | addTag("p",i18n("<b>Categories: </b>")+event->categoriesStr() ); | 257 | addTag("p",i18n("<b>Categories: </b>")+event->categoriesStr() ); |
258 | //mText.append(event->categoriesStr()); | 258 | //mText.append(event->categoriesStr()); |
259 | } | 259 | } |
260 | } | 260 | } |
261 | void KIncidenceFormatter::addTag(const QString & tag,const QString & text) | 261 | void KIncidenceFormatter::addTag(const QString & tag,const QString & text) |
262 | { | 262 | { |
263 | int number=text.contains("\n"); | 263 | int number=text.contains("\n"); |
264 | QString str = "<" + tag + ">"; | 264 | QString str = "<" + tag + ">"; |
265 | QString tmpText=text; | 265 | QString tmpText=text; |
266 | QString tmpStr=str; | 266 | QString tmpStr=str; |
267 | if(number !=-1) | 267 | if(number !=-1) |
268 | { | 268 | { |
269 | if (number > 0) { | 269 | if (number > 0) { |
270 | int pos=0; | 270 | int pos=0; |
271 | QString tmp; | 271 | QString tmp; |
272 | for(int i=0;i<=number;i++) { | 272 | for(int i=0;i<=number;i++) { |
273 | pos=tmpText.find("\n"); | 273 | pos=tmpText.find("\n"); |
274 | tmp=tmpText.left(pos); | 274 | tmp=tmpText.left(pos); |
275 | tmpText=tmpText.right(tmpText.length()-pos-1); | 275 | tmpText=tmpText.right(tmpText.length()-pos-1); |
276 | tmpStr+=tmp+"<br>"; | 276 | tmpStr+=tmp+"<br>"; |
277 | } | 277 | } |
278 | } | 278 | } |
279 | else tmpStr += tmpText; | 279 | else tmpStr += tmpText; |
280 | tmpStr+="</" + tag + ">"; | 280 | tmpStr+="</" + tag + ">"; |
281 | mText.append(tmpStr); | 281 | mText.append(tmpStr); |
282 | } | 282 | } |
283 | else | 283 | else |
284 | { | 284 | { |
285 | str += text + "</" + tag + ">"; | 285 | str += text + "</" + tag + ">"; |
286 | mText.append(str); | 286 | mText.append(str); |
287 | } | 287 | } |
288 | } | 288 | } |
289 | 289 | ||
290 | void KIncidenceFormatter::formatAttendees(Incidence *event) | 290 | void KIncidenceFormatter::formatAttendees(Incidence *event) |
291 | { | 291 | { |
292 | QPtrList<Attendee> attendees = event->attendees(); | 292 | QPtrList<Attendee> attendees = event->attendees(); |
293 | if (attendees.count()) { | 293 | if (attendees.count()) { |
294 | QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small); | 294 | QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small); |
295 | QString NOiconPath = KGlobal::iconLoader()->iconPath("nomailappt",KIcon::Small); | 295 | QString NOiconPath = KGlobal::iconLoader()->iconPath("nomailappt",KIcon::Small); |
296 | addTag("h3",i18n("Organizer")); | 296 | addTag("h3",i18n("Organizer")); |
297 | mText.append("<ul><li>"); | 297 | mText.append("<ul><li>"); |
298 | #if 0 | 298 | #if 0 |
299 | //ndef KORG_NOKABC | 299 | //ndef KORG_NOKABC |
300 | 300 | ||
301 | KABC::AddressBook *add_book = KABC::StdAddressBook::self(); | 301 | KABC::AddressBook *add_book = KABC::StdAddressBook::self(); |
302 | KABC::Addressee::List addressList; | 302 | KABC::Addressee::List addressList; |
303 | addressList = add_book->findByEmail(event->organizer()); | 303 | addressList = add_book->findByEmail(event->organizer()); |
304 | KABC::Addressee o = addressList.first(); | 304 | KABC::Addressee o = addressList.first(); |
305 | if (!o.isEmpty() && addressList.size()<2) { | 305 | if (!o.isEmpty() && addressList.size()<2) { |
306 | mText += "<a href=\"uid:" + o.uid() + "\">"; | 306 | mText += "<a href=\"uid:" + o.uid() + "\">"; |
307 | mText += o.formattedName(); | 307 | mText += o.formattedName(); |
308 | mText += "</a>\n"; | 308 | mText += "</a>\n"; |
309 | } else { | 309 | } else { |
310 | mText.append(event->organizer()); | 310 | mText.append(event->organizer()); |
311 | } | 311 | } |
312 | #else | 312 | #else |
313 | mText.append(event->organizer()); | 313 | mText.append(event->organizer()); |
314 | #endif | 314 | #endif |
315 | if (iconPath) { | 315 | if (iconPath) { |
316 | mText += " <a href=\"mailto:" + event->organizer() + "\">"; | 316 | mText += " <a href=\"mailto:" + event->organizer() + "\">"; |
317 | mText += "<IMG src=\"" + iconPath + "\">"; | 317 | mText += "<IMG src=\"" + iconPath + "\">"; |
318 | mText += "</a>\n"; | 318 | mText += "</a>\n"; |
319 | } | 319 | } |
320 | mText.append("</li></ul>"); | 320 | mText.append("</li></ul>"); |
321 | 321 | ||
322 | addTag("h3",i18n("Attendees")); | 322 | addTag("h3",i18n("Attendees")); |
323 | Attendee *a; | 323 | Attendee *a; |
324 | mText.append("<ul>"); | 324 | mText.append("<ul>"); |
325 | for(a=attendees.first();a;a=attendees.next()) { | 325 | for(a=attendees.first();a;a=attendees.next()) { |
326 | #if 0 | 326 | #if 0 |
327 | //ndef KORG_NOKABC | 327 | //ndef KORG_NOKABC |
328 | if (a->name().isEmpty()) { | 328 | if (a->name().isEmpty()) { |
329 | addressList = add_book->findByEmail(a->email()); | 329 | addressList = add_book->findByEmail(a->email()); |
330 | KABC::Addressee o = addressList.first(); | 330 | KABC::Addressee o = addressList.first(); |
331 | if (!o.isEmpty() && addressList.size()<2) { | 331 | if (!o.isEmpty() && addressList.size()<2) { |
332 | mText += "<a href=\"uid:" + o.uid() + "\">"; | 332 | mText += "<a href=\"uid:" + o.uid() + "\">"; |
333 | mText += o.formattedName(); | 333 | mText += o.formattedName(); |
334 | mText += "</a>\n"; | 334 | mText += "</a>\n"; |
335 | } else { | 335 | } else { |
336 | mText += "<li>"; | 336 | mText += "<li>"; |
337 | mText.append(a->email()); | 337 | mText.append(a->email()); |
338 | mText += "\n"; | 338 | mText += "\n"; |
339 | } | 339 | } |
340 | } else { | 340 | } else { |
341 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; | 341 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; |
342 | if (!a->name().isEmpty()) mText += a->name(); | 342 | if (!a->name().isEmpty()) mText += a->name(); |
343 | else mText += a->email(); | 343 | else mText += a->email(); |
344 | mText += "</a>\n"; | 344 | mText += "</a>\n"; |
345 | } | 345 | } |
346 | #else | 346 | #else |
347 | //qDebug("nokabc "); | 347 | //qDebug("nokabc "); |
348 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; | 348 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; |
349 | if (!a->name().isEmpty()) mText += a->name(); | 349 | if (!a->name().isEmpty()) mText += a->name(); |
350 | else mText += a->email(); | 350 | else mText += a->email(); |
351 | mText += "</a>\n"; | 351 | mText += "</a>\n"; |
352 | #endif | 352 | #endif |
353 | 353 | ||
354 | if (!a->email().isEmpty()) { | 354 | if (!a->email().isEmpty()) { |
355 | if (iconPath) { | 355 | if (iconPath) { |
356 | mText += "<a href=\"mailto:" + a->name() +" "+ "<" + a->email() + ">" + "\">"; | 356 | mText += "<a href=\"mailto:" + a->name() +" "+ "<" + a->email() + ">" + "\">"; |
357 | if ( a->RSVP() ) | 357 | if ( a->RSVP() ) |
358 | mText += "<IMG src=\"" + iconPath + "\">"; | 358 | mText += "<IMG src=\"" + iconPath + "\">"; |
359 | else | 359 | else |
360 | mText += "<IMG src=\"" + NOiconPath + "\">"; | 360 | mText += "<IMG src=\"" + NOiconPath + "\">"; |
361 | mText += "</a>\n"; | 361 | mText += "</a>\n"; |
362 | } | 362 | } |
363 | } | 363 | } |
364 | if (a->status() != Attendee::NeedsAction ) | 364 | if (a->status() != Attendee::NeedsAction ) |
365 | mText +="[" + a->statusStr() + "] "; | 365 | mText +="[" + a->statusStr() + "] "; |
366 | if (a->role() == Attendee::Chair ) | 366 | if (a->role() == Attendee::Chair ) |
367 | mText +="(" + a->roleStr().left(1) + ".)"; | 367 | mText +="(" + a->roleStr().left(1) + ".)"; |
368 | } | 368 | } |
369 | mText.append("</li></ul>"); | 369 | mText.append("</li></ul>"); |
370 | } | 370 | } |
371 | } | 371 | } |
372 | 372 | ||
373 | void KIncidenceFormatter::formatReadOnly(Incidence *event) | 373 | void KIncidenceFormatter::formatReadOnly(Incidence *event) |
374 | { | 374 | { |
375 | if (event->isReadOnly()) { | 375 | if (event->isReadOnly()) { |
376 | addTag("p","<em>(" + i18n("read-only") + ")</em>"); | 376 | addTag("p","<em>(" + i18n("read-only") + ")</em>"); |
377 | } | 377 | } |
378 | } | 378 | } |
379 | QString KIncidenceFormatter::deTag(QString text) | 379 | QString KIncidenceFormatter::deTag(QString text) |
380 | { | 380 | { |
381 | #if QT_VERSION >= 0x030000 | 381 | #if QT_VERSION >= 0x030000 |
382 | text.replace( '<' , "<" ); | 382 | text.replace( '<' , "<" ); |
383 | text.replace( '>' , ">" ); | 383 | text.replace( '>' , ">" ); |
384 | #else | 384 | #else |
385 | if ( text.find ('<') > 0 ) { | 385 | if ( text.find ('<') >= 0 ) { |
386 | text.replace( QRegExp("<") , "<" ); | 386 | text.replace( QRegExp("<") , "<" ); |
387 | } | 387 | } |
388 | if ( text.find ('>') > 0 ) { | 388 | if ( text.find ('>') >= 0 ) { |
389 | text.replace( QRegExp(">") , ">" ); | 389 | text.replace( QRegExp(">") , ">" ); |
390 | } | 390 | } |
391 | #endif | 391 | #endif |
392 | return text; | 392 | return text; |
393 | } | 393 | } |