author | zautrix <zautrix> | 2005-03-19 19:11:16 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-03-19 19:11:16 (UTC) |
commit | 414b033f0c39b5122fd4899408a7045a6c29d7c9 (patch) (side-by-side diff) | |
tree | 802d40e62d1b55e9b3a2daca2ba74fc47af15137 /korganizer/kodaymatrix.cpp | |
parent | 0aa5a7dce6ac1224395f7cb3fae488ba566f0e38 (diff) | |
download | kdepimpi-414b033f0c39b5122fd4899408a7045a6c29d7c9.zip kdepimpi-414b033f0c39b5122fd4899408a7045a6c29d7c9.tar.gz kdepimpi-414b033f0c39b5122fd4899408a7045a6c29d7c9.tar.bz2 |
dnc
-rw-r--r-- | korganizer/kodaymatrix.cpp | 49 |
1 files changed, 46 insertions, 3 deletions
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp index 989f758..a886f4a 100644 --- a/korganizer/kodaymatrix.cpp +++ b/korganizer/kodaymatrix.cpp @@ -82,20 +82,25 @@ void DynamicTip::maybeTip( const QPoint &pos ) // ============================================================================ // K O D A Y M A T R I X // ============================================================================ const int KODayMatrix::NOSELECTION = -1000; const int KODayMatrix::NUMDAYS = 42; +KODayMatrix::KODayMatrix( QWidget *parent, const char *name ) + : QFrame( parent, name ), mCalendar( 0 ) + +#if 0 KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name) : QFrame(parent, name) +#endif { - mCalendar = calendar; + mPendingUpdateBeforeRepaint = false; // initialize dynamic arrays days = new QDate[NUMDAYS]; daylbls = new QString[NUMDAYS]; events = new int[NUMDAYS]; mToolTip = new DynamicTip(this); @@ -113,16 +118,24 @@ KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const mUpdateTimer = new QTimer( this ); connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( updateViewTimed() )); mRepaintTimer = new QTimer( this ); connect (mRepaintTimer ,SIGNAL(timeout()), this, SLOT ( repaintViewTimed() )); mDayChanged = false; updateView(); } +void KODayMatrix::setCalendar( Calendar *cal ) +{ + mCalendar = cal; + + setAcceptDrops( mCalendar ); + + updateEvents(); +} QColor KODayMatrix::getShadedColor(QColor color) { QColor shaded; int h=0; int s=0; int v=0; color.hsv(&h,&s,&v); @@ -181,16 +194,20 @@ void KODayMatrix::addSelectedDaysTo(DateList& selDays) } } void KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end) { mSelStart = startdate.daysTo(start); mSelEnd = startdate.daysTo(end); } +void KODayMatrix::clearSelection() +{ + mSelEnd = mSelStart = NOSELECTION; +} void KODayMatrix::recalculateToday() { today = -1; for (int i=0; i<NUMDAYS; i++) { events[i] = 0; days[i] = startdate.addDays(i); @@ -212,18 +229,22 @@ void KODayMatrix::updateView() } void KODayMatrix::repaintViewTimed() { mRepaintTimer->stop(); repaint(false); } void KODayMatrix::updateViewTimed() { - mUpdateTimer->stop(); + if ( !mCalendar ) { + qDebug("NOT CAL "); + return; + } + //qDebug("KODayMatrix::updateViewTimed "); for(int i = 0; i < NUMDAYS; i++) { // if events are set for the day then remember to draw it bold QPtrList<Event> eventlist = mCalendar->events(days[i]); Event *event; int numEvents = eventlist.count(); QString holiStr = ""; for(event=eventlist.first();event != 0;event=eventlist.next()) { ushort recurType = event->recurrence()->doesRecur(); @@ -289,16 +310,38 @@ void KODayMatrix::updateView(QDate actdate) //mRepaintTimer->start( 250 ); mUpdateTimer->start( 250 ); #else mRepaintTimer->start( 350 ); mUpdateTimer->start( 2000 ); #endif } } +void KODayMatrix::updateEvents() +{ + if ( !mCalendar ) return; + + for( int i = 0; i < NUMDAYS; i++ ) { + // if events are set for the day then remember to draw it bold + QPtrList<Event> eventlist = mCalendar->events( days[ i ] ); + int numEvents = eventlist.count(); + Event *event; + for( event = eventlist.first(); event != 0;event=eventlist.next()) { + ushort recurType = event->doesRecur(); + + if ( ( recurType == Recurrence::rDaily && + !KOPrefs::instance()->mDailyRecur ) || + ( recurType == Recurrence::rWeekly && + !KOPrefs::instance()->mWeeklyRecur ) ) { + numEvents--; + } + } + events[ i ] = numEvents; + } +} const QDate& KODayMatrix::getDate(int offset) { if (offset < 0 || offset > NUMDAYS-1) { qDebug("Wrong offset2 "); return days[0]; } return days[offset]; @@ -423,17 +466,17 @@ void KODayMatrix::dragLeaveEvent(QDragLeaveEvent */*dl*/) #endif } void KODayMatrix::dropEvent(QDropEvent *e) { #ifndef KORG_NODND // kdDebug() << "KODayMatrix::dropEvent(e) begin" << endl; - if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { + if (!mCalendar || !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { e->ignore(); return; } DndFactory factory( mCalendar ); Event *event = factory.createDrop(e); if (event) { |