summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-03-20 00:09:33 (UTC)
committer zautrix <zautrix>2005-03-20 00:09:33 (UTC)
commit0ef9fe870982bd005806d7f51898a740cd52fec8 (patch) (unidiff)
tree891d95449e3f23159c50d7a38f03006bedfb41be /korganizer
parent84c18843bbd1203878367572d3a6800a0586c7f1 (diff)
downloadkdepimpi-0ef9fe870982bd005806d7f51898a740cd52fec8.zip
kdepimpi-0ef9fe870982bd005806d7f51898a740cd52fec8.tar.gz
kdepimpi-0ef9fe870982bd005806d7f51898a740cd52fec8.tar.bz2
cooooooool
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kodaymatrix.cpp118
-rw-r--r--korganizer/kodaymatrix.h5
2 files changed, 111 insertions, 12 deletions
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp
index 17a8546..1cde616 100644
--- a/korganizer/kodaymatrix.cpp
+++ b/korganizer/kodaymatrix.cpp
@@ -28,2 +28,3 @@
28#include <qtimer.h> 28#include <qtimer.h>
29#include <qwhatsthis.h>
29 30
@@ -60,2 +61,15 @@ DynamicTip::DynamicTip( QWidget * parent )
60 61
62class KODaymatrixWhatsThis :public QWhatsThis
63{
64public:
65 KODaymatrixWhatsThis( KODayMatrix* view ) : QWhatsThis( view ),_view (view) { };
66
67protected:
68 virtual QString text( const QPoint& p )
69 {
70 return _view->getWhatsThisText( p ) ;
71 }
72private:
73 KODayMatrix * _view;
74};
61 75
@@ -97,6 +111,7 @@ KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const
97{ 111{
98 112 new KODaymatrixWhatsThis(this);
99 mPendingUpdateBeforeRepaint = false; 113 mPendingUpdateBeforeRepaint = false;
100 114 mouseDown = false;
101 // initialize dynamic arrays 115 // initialize dynamic arrays
116 bDays.resize ( NUMDAYS );
102 days = new QDate[NUMDAYS]; 117 days = new QDate[NUMDAYS];
@@ -125,2 +140,61 @@ KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const
125} 140}
141QString KODayMatrix::getWhatsThisText( QPoint p )
142{
143
144 int tmp = getDayIndexFrom(p.x(), p.y());
145 if ( tmp < 0 || tmp > NUMDAYS-1 || !mCalendar )
146 return QString();
147 QDate mDate = days[tmp];
148 QPtrList<Event> eventlist = mCalendar->events(mDate);
149 Event *event;
150 QStringList mToolTip;
151 for(event=eventlist.first();event != 0;event=eventlist.next()) {
152 QString mToolTipText;
153 QString text;
154 int multiday = 0;// 1 = start, 2 = midddle, 3 = end day
155 if (event->isMultiDay()) {
156 QString prefix = "<->";multiday = 2;
157 QString time;
158 if ( event->doesRecur() ) {
159 if ( event->recursOn( mDate) ) {
160 prefix ="->" ;multiday = 1;
161 }
162 else {
163 int days = event->dtStart().date().daysTo ( event->dtEnd().date() );
164 if ( event->recursOn( mDate.addDays( -days)) ) {
165 prefix ="<-" ;multiday = 3;
166 }
167 }
168 } else {
169 if (mDate == event->dtStart().date()) {
170 prefix ="->" ;multiday = 1;
171 } else if (mDate == event->dtEnd().date()) {
172 prefix ="<-" ;multiday = 3;
173 }
174 }
175 if ( !event->doesFloat() ) {
176 if ( mDate == event->dtStart().date () )
177 time = KGlobal::locale()->formatTime(event->dtStart().time())+" ";
178 else if ( mDate == event->dtEnd().date () )
179 time = KGlobal::locale()->formatTime(event->dtEnd().time())+" ";
180
181 }
182 text = time + event->summary();
183 mToolTipText += prefix + text;
184 } else {
185 if (event->doesFloat()) {
186 text = event->summary();
187 mToolTipText += text;
188 }
189 else {
190 text = KGlobal::locale()->formatTime(event->dtStart().time());
191 text += " " + event->summary();
192 mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary();
193 }
194 }
195 mToolTip.append( mToolTipText );
196 }
197 mToolTip.sort();
198 return "<b>"+KGlobal::locale()->formatDate(days[tmp]) + "</b><br>" + mToolTip.join("<br>");
199}
126void KODayMatrix::setCalendar( Calendar *cal ) 200void KODayMatrix::setCalendar( Calendar *cal )
@@ -248,2 +322,3 @@ void KODayMatrix::updateViewTimed()
248 QString holiStr = ""; 322 QString holiStr = "";
323 bDays.clearBit(i);
249 for(event=eventlist.first();event != 0;event=eventlist.next()) { 324 for(event=eventlist.first();event != 0;event=eventlist.next()) {
@@ -259,2 +334,8 @@ void KODayMatrix::updateViewTimed()
259 } 334 }
335 if ( event->categories().contains( i18n("Birthday") ) || event->categories().contains( "Birthday" )) {
336 if ( !holiStr.isEmpty() )
337 holiStr += "\n";
338 holiStr += event->summary();
339 bDays.setBit(i);
340 }
260 } 341 }
@@ -309,7 +390,7 @@ void KODayMatrix::updateView(QDate actdate)
309#ifdef DESKTOP_VERSION 390#ifdef DESKTOP_VERSION
310 //mRepaintTimer->start( 250 ); 391 //mRepaintTimer->start( 150 );
311 mUpdateTimer->start( 250 ); 392 mUpdateTimer->start( 150 );
312#else 393#else
313 mRepaintTimer->start( 350 ); 394 mRepaintTimer->start( 350 );
314 mUpdateTimer->start( 2000 ); 395 mUpdateTimer->start( 1200 );
315#endif 396#endif
@@ -370,2 +451,5 @@ void KODayMatrix::mousePressEvent (QMouseEvent* e)
370{ 451{
452
453 if ( e->button() == LeftButton )
454 mouseDown = true;
371 mSelStart = getDayIndexFrom(e->x(), e->y()); 455 mSelStart = getDayIndexFrom(e->x(), e->y());
@@ -377,3 +461,8 @@ void KODayMatrix::mouseReleaseEvent (QMouseEvent* e)
377{ 461{
378 462 if ( e->button() == LeftButton )
463 if ( ! mouseDown ) {
464 return;
465 }
466 else
467 mouseDown = false;
379 int tmp = getDayIndexFrom(e->x(), e->y()); 468 int tmp = getDayIndexFrom(e->x(), e->y());
@@ -408,3 +497,6 @@ void KODayMatrix::mouseReleaseEvent (QMouseEvent* e)
408void KODayMatrix::mouseMoveEvent (QMouseEvent* e) 497void KODayMatrix::mouseMoveEvent (QMouseEvent* e)
409{ 498{
499 if ( ! mouseDown ) {
500 return;
501 }
410 int tmp = getDayIndexFrom(e->x(), e->y()); 502 int tmp = getDayIndexFrom(e->x(), e->y());
@@ -632,6 +724,10 @@ void KODayMatrix::paintEvent(QPaintEvent * pevent)
632 if (!mHolidays[i].isNull()) { 724 if (!mHolidays[i].isNull()) {
633 if (actcol == mDefaultTextColor) { 725 if ( bDays.testBit(i) ) {
634 p.setPen(KOPrefs::instance()->mHolidayColor); 726 p.setPen(Qt::green);
635 } else { 727 } else {
636 p.setPen(mHolidayColorShaded); 728 if (actcol == mDefaultTextColor) {
729 p.setPen(KOPrefs::instance()->mHolidayColor);
730 } else {
731 p.setPen(mHolidayColorShaded);
732 }
637 } 733 }
@@ -642,3 +738,3 @@ void KODayMatrix::paintEvent(QPaintEvent * pevent)
642 if (i >= mSelStart && i <= mSelEnd) { 738 if (i >= mSelStart && i <= mSelEnd) {
643 p.setPen(mSelectedDaysColor); 739 ;//p.setPen(mSelectedDaysColor);
644 } 740 }
diff --git a/korganizer/kodaymatrix.h b/korganizer/kodaymatrix.h
index ba4853f..c049942 100644
--- a/korganizer/kodaymatrix.h
+++ b/korganizer/kodaymatrix.h
@@ -34,3 +34,3 @@
34#include <qpixmap.h> 34#include <qpixmap.h>
35 35#include <qbitarray.h>
36#include <qmap.h> 36#include <qmap.h>
@@ -171,2 +171,3 @@ public:
171 bool isEndOfMonth() const { return today>=27; } ; 171 bool isEndOfMonth() const { return today>=27; } ;
172 QString getWhatsThisText( QPoint ) ;
172 173
@@ -226,2 +227,4 @@ protected:
226private: 227private:
228 bool mouseDown;
229 QBitArray bDays;
227 QPixmap myPix; 230 QPixmap myPix;