author | zautrix <zautrix> | 2005-03-20 00:09:33 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-03-20 00:09:33 (UTC) |
commit | 0ef9fe870982bd005806d7f51898a740cd52fec8 (patch) (side-by-side diff) | |
tree | 891d95449e3f23159c50d7a38f03006bedfb41be /korganizer | |
parent | 84c18843bbd1203878367572d3a6800a0586c7f1 (diff) | |
download | kdepimpi-0ef9fe870982bd005806d7f51898a740cd52fec8.zip kdepimpi-0ef9fe870982bd005806d7f51898a740cd52fec8.tar.gz kdepimpi-0ef9fe870982bd005806d7f51898a740cd52fec8.tar.bz2 |
cooooooool
-rw-r--r-- | korganizer/kodaymatrix.cpp | 110 | ||||
-rw-r--r-- | korganizer/kodaymatrix.h | 5 |
2 files changed, 107 insertions, 8 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 @@ #include <qtimer.h> +#include <qwhatsthis.h> @@ -60,2 +61,15 @@ DynamicTip::DynamicTip( QWidget * parent ) +class KODaymatrixWhatsThis :public QWhatsThis +{ +public: + KODaymatrixWhatsThis( KODayMatrix* view ) : QWhatsThis( view ),_view (view) { }; + +protected: + virtual QString text( const QPoint& p ) + { + return _view->getWhatsThisText( p ) ; + } +private: + KODayMatrix * _view; +}; @@ -97,6 +111,7 @@ KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const { - + new KODaymatrixWhatsThis(this); mPendingUpdateBeforeRepaint = false; - + mouseDown = false; // initialize dynamic arrays + bDays.resize ( NUMDAYS ); days = new QDate[NUMDAYS]; @@ -125,2 +140,61 @@ KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const } +QString KODayMatrix::getWhatsThisText( QPoint p ) +{ + + int tmp = getDayIndexFrom(p.x(), p.y()); + if ( tmp < 0 || tmp > NUMDAYS-1 || !mCalendar ) + return QString(); + QDate mDate = days[tmp]; + QPtrList<Event> eventlist = mCalendar->events(mDate); + Event *event; + QStringList mToolTip; + for(event=eventlist.first();event != 0;event=eventlist.next()) { + QString mToolTipText; + QString text; + int multiday = 0;// 1 = start, 2 = midddle, 3 = end day + if (event->isMultiDay()) { + QString prefix = "<->";multiday = 2; + QString time; + if ( event->doesRecur() ) { + if ( event->recursOn( mDate) ) { + prefix ="->" ;multiday = 1; + } + else { + int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); + if ( event->recursOn( mDate.addDays( -days)) ) { + prefix ="<-" ;multiday = 3; + } + } + } else { + if (mDate == event->dtStart().date()) { + prefix ="->" ;multiday = 1; + } else if (mDate == event->dtEnd().date()) { + prefix ="<-" ;multiday = 3; + } + } + if ( !event->doesFloat() ) { + if ( mDate == event->dtStart().date () ) + time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; + else if ( mDate == event->dtEnd().date () ) + time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; + + } + text = time + event->summary(); + mToolTipText += prefix + text; + } else { + if (event->doesFloat()) { + text = event->summary(); + mToolTipText += text; + } + else { + text = KGlobal::locale()->formatTime(event->dtStart().time()); + text += " " + event->summary(); + mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); + } + } + mToolTip.append( mToolTipText ); + } + mToolTip.sort(); + return "<b>"+KGlobal::locale()->formatDate(days[tmp]) + "</b><br>" + mToolTip.join("<br>"); +} void KODayMatrix::setCalendar( Calendar *cal ) @@ -248,2 +322,3 @@ void KODayMatrix::updateViewTimed() QString holiStr = ""; + bDays.clearBit(i); for(event=eventlist.first();event != 0;event=eventlist.next()) { @@ -259,2 +334,8 @@ void KODayMatrix::updateViewTimed() } + if ( event->categories().contains( i18n("Birthday") ) || event->categories().contains( "Birthday" )) { + if ( !holiStr.isEmpty() ) + holiStr += "\n"; + holiStr += event->summary(); + bDays.setBit(i); + } } @@ -309,7 +390,7 @@ void KODayMatrix::updateView(QDate actdate) #ifdef DESKTOP_VERSION - //mRepaintTimer->start( 250 ); - mUpdateTimer->start( 250 ); + //mRepaintTimer->start( 150 ); + mUpdateTimer->start( 150 ); #else mRepaintTimer->start( 350 ); - mUpdateTimer->start( 2000 ); + mUpdateTimer->start( 1200 ); #endif @@ -370,2 +451,5 @@ void KODayMatrix::mousePressEvent (QMouseEvent* e) { + + if ( e->button() == LeftButton ) + mouseDown = true; mSelStart = getDayIndexFrom(e->x(), e->y()); @@ -377,3 +461,8 @@ void KODayMatrix::mouseReleaseEvent (QMouseEvent* e) { - + if ( e->button() == LeftButton ) + if ( ! mouseDown ) { + return; + } + else + mouseDown = false; int tmp = getDayIndexFrom(e->x(), e->y()); @@ -409,2 +498,5 @@ void KODayMatrix::mouseMoveEvent (QMouseEvent* e) { + if ( ! mouseDown ) { + return; + } int tmp = getDayIndexFrom(e->x(), e->y()); @@ -632,2 +724,5 @@ void KODayMatrix::paintEvent(QPaintEvent * pevent) if (!mHolidays[i].isNull()) { + if ( bDays.testBit(i) ) { + p.setPen(Qt::green); + } else { if (actcol == mDefaultTextColor) { @@ -638,2 +733,3 @@ void KODayMatrix::paintEvent(QPaintEvent * pevent) } + } @@ -642,3 +738,3 @@ void KODayMatrix::paintEvent(QPaintEvent * pevent) if (i >= mSelStart && i <= mSelEnd) { - p.setPen(mSelectedDaysColor); + ;//p.setPen(mSelectedDaysColor); } 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 @@ #include <qpixmap.h> - +#include <qbitarray.h> #include <qmap.h> @@ -171,2 +171,3 @@ public: bool isEndOfMonth() const { return today>=27; } ; + QString getWhatsThisText( QPoint ) ; @@ -226,2 +227,4 @@ protected: private: + bool mouseDown; + QBitArray bDays; QPixmap myPix; |