-rw-r--r-- | korganizer/kodaymatrix.cpp | 57 | ||||
-rw-r--r-- | korganizer/kodaymatrix.h | 1 |
2 files changed, 46 insertions, 12 deletions
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp index 53ebdb2..4366265 100644 --- a/korganizer/kodaymatrix.cpp +++ b/korganizer/kodaymatrix.cpp | |||
@@ -155,113 +155,146 @@ QString KODayMatrix::getWhatsThisText( QPoint p ) | |||
155 | Event *event; | 155 | Event *event; |
156 | QStringList mToolTip; | 156 | QStringList mToolTip; |
157 | for(event=eventlist.first();event != 0;event=eventlist.next()) { | 157 | for(event=eventlist.first();event != 0;event=eventlist.next()) { |
158 | QString mToolTipText; | 158 | QString mToolTipText; |
159 | QString text; | 159 | QString text; |
160 | int multiday = 0;// 1 = start, 2 = midddle, 3 = end day | 160 | int multiday = 0;// 1 = start, 2 = midddle, 3 = end day |
161 | if (event->isMultiDay()) { | 161 | if (event->isMultiDay()) { |
162 | QString prefix = "<->";multiday = 2; | 162 | QString prefix = "<->";multiday = 2; |
163 | QString time; | 163 | QString time; |
164 | if ( event->doesRecur() ) { | 164 | if ( event->doesRecur() ) { |
165 | if ( event->recursOn( mDate) ) { | 165 | if ( event->recursOn( mDate) ) { |
166 | prefix ="->" ;multiday = 1; | 166 | prefix ="->" ;multiday = 1; |
167 | } | 167 | } |
168 | else { | 168 | else { |
169 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); | 169 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); |
170 | if ( event->recursOn( mDate.addDays( -days)) ) { | 170 | if ( event->recursOn( mDate.addDays( -days)) ) { |
171 | prefix ="<-" ;multiday = 3; | 171 | prefix ="<-" ;multiday = 3; |
172 | } | 172 | } |
173 | } | 173 | } |
174 | } else { | 174 | } else { |
175 | if (mDate == event->dtStart().date()) { | 175 | if (mDate == event->dtStart().date()) { |
176 | prefix ="->" ;multiday = 1; | 176 | prefix ="->" ;multiday = 1; |
177 | } else if (mDate == event->dtEnd().date()) { | 177 | } else if (mDate == event->dtEnd().date()) { |
178 | prefix ="<-" ;multiday = 3; | 178 | prefix ="<-" ;multiday = 3; |
179 | } | 179 | } |
180 | } | 180 | } |
181 | if ( !event->doesFloat() ) { | 181 | if ( !event->doesFloat() ) { |
182 | if ( mDate == event->dtStart().date () ) | 182 | if ( mDate == event->dtStart().date () ) |
183 | time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; | 183 | time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; |
184 | else if ( mDate == event->dtEnd().date () ) | 184 | else if ( mDate == event->dtEnd().date () ) |
185 | time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; | 185 | time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; |
186 | 186 | ||
187 | } | 187 | } |
188 | text = time + event->summary(); | 188 | text = time + event->summary(); |
189 | mToolTipText += prefix + text; | 189 | mToolTipText += prefix + text; |
190 | } else { | 190 | } else { |
191 | if (event->doesFloat()) { | 191 | if (event->doesFloat()) { |
192 | text = event->summary(); | 192 | text = event->summary(); |
193 | mToolTipText += text; | 193 | mToolTipText += text; |
194 | } | 194 | } |
195 | else { | 195 | else { |
196 | text = KGlobal::locale()->formatTime(event->dtStart().time()); | 196 | text = KGlobal::locale()->formatTime(event->dtStart().time()); |
197 | text += " " + event->summary(); | 197 | text += " " + event->summary(); |
198 | mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); | 198 | mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); |
199 | } | 199 | } |
200 | } | 200 | } |
201 | if ( !event->location().isEmpty() ) | 201 | if ( !event->location().isEmpty() ) |
202 | mToolTipText += " (" + event->location() + ")"; | 202 | mToolTipText += " (" + event->location() + ")"; |
203 | #if QT_VERSION >= 0x030000 | ||
204 | mToolTipText.replace( '<' , "<" ); | ||
205 | mToolTipText.replace( '>' , ">" ); | ||
206 | #else | ||
207 | if ( mToolTipText.find ('<') >= 0 ) { | ||
208 | mToolTipText.replace( QRegExp("<") , "<" ); | ||
209 | } | ||
210 | if ( mToolTipText.find ('>') >= 0 ) { | ||
211 | mToolTipText.replace( QRegExp(">") , ">" ); | ||
212 | } | ||
213 | #endif | ||
214 | //qDebug("TTT: %s ", mToolTipText.latin1()); | 203 | //qDebug("TTT: %s ", mToolTipText.latin1()); |
215 | mToolTip.append( mToolTipText ); | 204 | mToolTip.append( deTag( mToolTipText ) ); |
205 | } | ||
206 | if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_T_VIEW ) { | ||
207 | QPtrList<Todo> todolist = mCalendar->todos(mDate); | ||
208 | Todo *todo; | ||
209 | for(todo=todolist.first();todo != 0;todo=todolist.next()) { | ||
210 | QString mToolTipText; | ||
211 | if ( !todo->doesFloat() ) | ||
212 | mToolTipText += KGlobal::locale()->formatTime(todo->dtDue().time())+" "; | ||
213 | mToolTipText += todo->summary(); | ||
214 | if ( !todo->location().isEmpty() ) | ||
215 | mToolTipText += " (" + todo->location() + ")"; | ||
216 | mToolTipText = deTag( mToolTipText); | ||
217 | mToolTipText = "<b>" + i18n("Todo: ") + "</b>"+ mToolTipText; | ||
218 | mToolTip.append( mToolTipText ); | ||
219 | } | ||
216 | } | 220 | } |
217 | mToolTip.sort(); | 221 | mToolTip.sort(); |
222 | if (KOPrefs::instance()->mCurrentDisplayedView == VIEW_J_VIEW ) { | ||
223 | Journal *j = mCalendar->journal( mDate ); | ||
224 | if ( j ) { | ||
225 | QString mToolTipText = j->description().left(100); | ||
226 | if ( j->description().length() > 100 ) | ||
227 | mToolTipText += " ..."; | ||
228 | mToolTipText = deTag( mToolTipText); | ||
229 | mToolTipText = "<b>" + i18n("Journal: ") + "</b>"+ mToolTipText; | ||
230 | mToolTip.append( mToolTipText ); | ||
231 | } | ||
232 | } | ||
218 | return "<b>"+KGlobal::locale()->formatDate(days[tmp]) + "</b><br>" + mToolTip.join("<br>"); | 233 | return "<b>"+KGlobal::locale()->formatDate(days[tmp]) + "</b><br>" + mToolTip.join("<br>"); |
219 | } | 234 | } |
235 | |||
236 | |||
237 | QString KODayMatrix::deTag( QString mToolTipText ) | ||
238 | { | ||
239 | |||
240 | #if QT_VERSION >= 0x030000 | ||
241 | mToolTipText.replace( '<' , "<" ); | ||
242 | mToolTipText.replace( '>' , ">" ); | ||
243 | #else | ||
244 | if ( mToolTipText.find ('<') >= 0 ) { | ||
245 | mToolTipText.replace( QRegExp("<") , "<" ); | ||
246 | } | ||
247 | if ( mToolTipText.find ('>') >= 0 ) { | ||
248 | mToolTipText.replace( QRegExp(">") , ">" ); | ||
249 | } | ||
250 | #endif | ||
251 | return mToolTipText; | ||
252 | } | ||
220 | void KODayMatrix::setCalendar( Calendar *cal ) | 253 | void KODayMatrix::setCalendar( Calendar *cal ) |
221 | { | 254 | { |
222 | mCalendar = cal; | 255 | mCalendar = cal; |
223 | 256 | ||
224 | setAcceptDrops( mCalendar ); | 257 | setAcceptDrops( mCalendar ); |
225 | 258 | ||
226 | updateEvents(); | 259 | updateEvents(); |
227 | } | 260 | } |
228 | 261 | ||
229 | QColor KODayMatrix::getShadedColor(QColor color) | 262 | QColor KODayMatrix::getShadedColor(QColor color) |
230 | { | 263 | { |
231 | QColor shaded; | 264 | QColor shaded; |
232 | int h=0; | 265 | int h=0; |
233 | int s=0; | 266 | int s=0; |
234 | int v=0; | 267 | int v=0; |
235 | color.hsv(&h,&s,&v); | 268 | color.hsv(&h,&s,&v); |
236 | s = s/4; | 269 | s = s/4; |
237 | v = 192+v/4; | 270 | v = 192+v/4; |
238 | shaded.setHsv(h,s,v); | 271 | shaded.setHsv(h,s,v); |
239 | 272 | ||
240 | return shaded; | 273 | return shaded; |
241 | } | 274 | } |
242 | 275 | ||
243 | KODayMatrix::~KODayMatrix() | 276 | KODayMatrix::~KODayMatrix() |
244 | { | 277 | { |
245 | #if QT_VERSION >= 0x030000 | 278 | #if QT_VERSION >= 0x030000 |
246 | 279 | ||
247 | #else | 280 | #else |
248 | delete mKODaymatrixWhatsThis; | 281 | delete mKODaymatrixWhatsThis; |
249 | #endif | 282 | #endif |
250 | 283 | ||
251 | // delete mKODaymatrixWhatsThis; | 284 | // delete mKODaymatrixWhatsThis; |
252 | delete [] days; | 285 | delete [] days; |
253 | delete [] daylbls; | 286 | delete [] daylbls; |
254 | //delete [] events; | 287 | //delete [] events; |
255 | delete mToolTip; | 288 | delete mToolTip; |
256 | } | 289 | } |
257 | 290 | ||
258 | /* | 291 | /* |
259 | void KODayMatrix::setStartDate(QDate start) | 292 | void KODayMatrix::setStartDate(QDate start) |
260 | { | 293 | { |
261 | updateView(start); | 294 | updateView(start); |
262 | } | 295 | } |
263 | */ | 296 | */ |
264 | 297 | ||
265 | void KODayMatrix::addSelectedDaysTo(DateList& selDays) | 298 | void KODayMatrix::addSelectedDaysTo(DateList& selDays) |
266 | { | 299 | { |
267 | 300 | ||
diff --git a/korganizer/kodaymatrix.h b/korganizer/kodaymatrix.h index a3216d6..b96e08f 100644 --- a/korganizer/kodaymatrix.h +++ b/korganizer/kodaymatrix.h | |||
@@ -162,96 +162,97 @@ public: | |||
162 | */ | 162 | */ |
163 | bool isTodayVisible() const { return today>=0; } ; | 163 | bool isTodayVisible() const { return today>=0; } ; |
164 | 164 | ||
165 | /** If today is visible, then we can find out if today is | 165 | /** If today is visible, then we can find out if today is |
166 | * near the beginning or the end of the month. | 166 | * near the beginning or the end of the month. |
167 | * This is dependent on today remaining the index | 167 | * This is dependent on today remaining the index |
168 | * in the array of visible dates and going from | 168 | * in the array of visible dates and going from |
169 | * top left (0) to bottom right (41). | 169 | * top left (0) to bottom right (41). |
170 | */ | 170 | */ |
171 | bool isBeginningOfMonth() const { return today<=8; } ; | 171 | bool isBeginningOfMonth() const { return today<=8; } ; |
172 | bool isEndOfMonth() const { return today>=27; } ; | 172 | bool isEndOfMonth() const { return today>=27; } ; |
173 | QString getWhatsThisText( QPoint ) ; | 173 | QString getWhatsThisText( QPoint ) ; |
174 | QSize sizeHint() const; | 174 | QSize sizeHint() const; |
175 | QRect frameRect () const { int wid = frameWidth(); return QRect(0+wid,0+wid,width()-wid-wid,height()-wid-wid);} | 175 | QRect frameRect () const { int wid = frameWidth(); return QRect(0+wid,0+wid,width()-wid-wid,height()-wid-wid);} |
176 | public slots: | 176 | public slots: |
177 | /** Recalculates all the flags of the days in the matrix like holidays or events | 177 | /** Recalculates all the flags of the days in the matrix like holidays or events |
178 | * on a day (Actually calls above method with the actual startdate). | 178 | * on a day (Actually calls above method with the actual startdate). |
179 | */ | 179 | */ |
180 | void updateView(); | 180 | void updateView(); |
181 | void updateViewTimed(); | 181 | void updateViewTimed(); |
182 | void repaintViewTimed(); | 182 | void repaintViewTimed(); |
183 | 183 | ||
184 | /** | 184 | /** |
185 | * Calculate which square in the matrix should be | 185 | * Calculate which square in the matrix should be |
186 | * hilighted to indicate it's today. | 186 | * hilighted to indicate it's today. |
187 | */ | 187 | */ |
188 | void recalculateToday(); | 188 | void recalculateToday(); |
189 | 189 | ||
190 | /* | 190 | /* |
191 | void setStartDate(QDate); | 191 | void setStartDate(QDate); |
192 | */ | 192 | */ |
193 | 193 | ||
194 | signals: | 194 | signals: |
195 | 195 | ||
196 | /** emitted if the user selects a block of days with the mouse by dragging a rectangle | 196 | /** emitted if the user selects a block of days with the mouse by dragging a rectangle |
197 | * inside the matrix | 197 | * inside the matrix |
198 | * | 198 | * |
199 | * @param daylist list of days that have been selected by the user | 199 | * @param daylist list of days that have been selected by the user |
200 | */ | 200 | */ |
201 | void selected( const KCal::DateList &daylist ); | 201 | void selected( const KCal::DateList &daylist ); |
202 | 202 | ||
203 | /** emitted if the user has dropped an event inside the matrix | 203 | /** emitted if the user has dropped an event inside the matrix |
204 | * | 204 | * |
205 | * @param event the dropped calendar event | 205 | * @param event the dropped calendar event |
206 | */ | 206 | */ |
207 | void eventDropped(Event *event); | 207 | void eventDropped(Event *event); |
208 | 208 | ||
209 | protected: | 209 | protected: |
210 | QString deTag( QString mToolTipText ); | ||
210 | 211 | ||
211 | void paintEvent(QPaintEvent *ev); | 212 | void paintEvent(QPaintEvent *ev); |
212 | 213 | ||
213 | void mousePressEvent (QMouseEvent* e); | 214 | void mousePressEvent (QMouseEvent* e); |
214 | 215 | ||
215 | void mouseReleaseEvent (QMouseEvent* e); | 216 | void mouseReleaseEvent (QMouseEvent* e); |
216 | 217 | ||
217 | void mouseMoveEvent (QMouseEvent* e); | 218 | void mouseMoveEvent (QMouseEvent* e); |
218 | 219 | ||
219 | void dragEnterEvent(QDragEnterEvent *); | 220 | void dragEnterEvent(QDragEnterEvent *); |
220 | 221 | ||
221 | void dragMoveEvent(QDragMoveEvent *); | 222 | void dragMoveEvent(QDragMoveEvent *); |
222 | 223 | ||
223 | void dragLeaveEvent(QDragLeaveEvent *); | 224 | void dragLeaveEvent(QDragLeaveEvent *); |
224 | 225 | ||
225 | void dropEvent(QDropEvent *); | 226 | void dropEvent(QDropEvent *); |
226 | 227 | ||
227 | void resizeEvent(QResizeEvent *); | 228 | void resizeEvent(QResizeEvent *); |
228 | 229 | ||
229 | private: | 230 | private: |
230 | int mLastView; | 231 | int mLastView; |
231 | void computeEvent(Event *even, int dayindex ); | 232 | void computeEvent(Event *even, int dayindex ); |
232 | int oldW, oldH; | 233 | int oldW, oldH; |
233 | bool mRedrawNeeded; | 234 | bool mRedrawNeeded; |
234 | KODaymatrixWhatsThis* mKODaymatrixWhatsThis; | 235 | KODaymatrixWhatsThis* mKODaymatrixWhatsThis; |
235 | bool mouseDown; | 236 | bool mouseDown; |
236 | QBitArray bDays; | 237 | QBitArray bDays; |
237 | QBitArray hDays; | 238 | QBitArray hDays; |
238 | QBitArray eDays; | 239 | QBitArray eDays; |
239 | QBitArray pDays; | 240 | QBitArray pDays; |
240 | QPixmap myPix; | 241 | QPixmap myPix; |
241 | QTimer* mUpdateTimer; | 242 | QTimer* mUpdateTimer; |
242 | QTimer* mRepaintTimer; | 243 | QTimer* mRepaintTimer; |
243 | bool mDayChanged; | 244 | bool mDayChanged; |
244 | bool mPendingUpdateBeforeRepaint; | 245 | bool mPendingUpdateBeforeRepaint; |
245 | 246 | ||
246 | /** returns the index of the day located at the matrix's widget (x,y) position. | 247 | /** returns the index of the day located at the matrix's widget (x,y) position. |
247 | * | 248 | * |
248 | * @param x horizontal coordinate | 249 | * @param x horizontal coordinate |
249 | * @param y vertical coordinate | 250 | * @param y vertical coordinate |
250 | */ | 251 | */ |
251 | int getDayIndexFrom(int x, int y); | 252 | int getDayIndexFrom(int x, int y); |
252 | 253 | ||
253 | /** calculates a "shaded" color from the supplied color object. | 254 | /** calculates a "shaded" color from the supplied color object. |
254 | * (Copied from Cornelius's kdpdatebutton.cpp) | 255 | * (Copied from Cornelius's kdpdatebutton.cpp) |
255 | * | 256 | * |
256 | * @param color source based on which a shaded color should be calculated. | 257 | * @param color source based on which a shaded color should be calculated. |
257 | */ | 258 | */ |