author | zautrix <zautrix> | 2005-06-27 17:25:27 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-06-27 17:25:27 (UTC) |
commit | 2a6c47afc7688923f427f4a38e3353e3503ab09a (patch) (side-by-side diff) | |
tree | f314e7062e60f8e0302714bcc6149f2e83c96e30 | |
parent | 58ad1402f6415de889e7a0dc98be29e9ae56d86c (diff) | |
download | kdepimpi-2a6c47afc7688923f427f4a38e3353e3503ab09a.zip kdepimpi-2a6c47afc7688923f427f4a38e3353e3503ab09a.tar.gz kdepimpi-2a6c47afc7688923f427f4a38e3353e3503ab09a.tar.bz2 |
monthview enh
-rw-r--r-- | korganizer/komonthview.cpp | 116 | ||||
-rw-r--r-- | korganizer/komonthview.h | 13 |
2 files changed, 122 insertions, 7 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index cba85fa..9b0389d 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp @@ -142,6 +142,7 @@ void KNoScrollListBox::focusOutEvent ( QFocusEvent * e ) QListBox::focusOutEvent ( e ); setVScrollBarMode(QScrollView::AlwaysOff); setHScrollBarMode(QScrollView::AlwaysOff); + emit highligtIncidence( 0, (MonthViewCell*)this, 0 ); } QString KNoScrollListBox::getWhatsThisText(QPoint p) @@ -280,6 +281,7 @@ void KNoScrollListBox::mousePressEvent(QMouseEvent *e) MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) : QListBoxItem() { + mDisplayHightlighted = false; mblockRepaint = true; setText( s ); mMultiday = 0; @@ -294,6 +296,7 @@ MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) } void MonthViewItem::recycle( Incidence *incidence, QDate qd, const QString & s) { + mDisplayHightlighted = false; setText( s ); mMultiday = 0; mIncidence = incidence; @@ -304,7 +307,29 @@ void MonthViewItem::recycle( Incidence *incidence, QDate qd, const QString & s) mInfo = false; mdayPos = 0; } +bool MonthViewItem::setHighlightedFalse() +{ + if ( !mDisplayHightlighted ) + return false; + mDisplayHightlighted = false; + return true; +} +bool MonthViewItem::setHighlighted( Incidence * inc ) +{ + if ( inc == mIncidence ) { + if ( mDisplayHightlighted ) + return false; + mDisplayHightlighted = true; + return true; + } else { + if ( !mDisplayHightlighted ) + return false; + mDisplayHightlighted = false; + return true; + } + return false; +} void MonthViewItem::paint(QPainter *p) { if ( mblockRepaint ) { @@ -317,8 +342,10 @@ void MonthViewItem::paint(QPainter *p) #endif int heihei = height( listBox () ); int x = 1; - if (KOPrefs::instance()->mMonthViewUsesCategoryColor) + if (KOPrefs::instance()->mMonthViewUsesCategoryColor || mDisplayHightlighted ) { + if ( mDisplayHightlighted ) + sel = true; p->setBackgroundColor( palette().color( QPalette::Normal, \ sel ? QColorGroup::Highlight : QColorGroup::Background ) ); p->eraseRect( 0, 0, listBox()->maxItemWidth(), heihei ); @@ -600,6 +627,7 @@ void MonthViewCell::setHoliday( const QString &holiday ) void MonthViewCell::startUpdateCell() { + mdayCount = 0; setFocusPolicy(NoFocus); if ( !mMonthView->isUpdatePossible() ) @@ -1083,12 +1111,39 @@ void MonthViewCell::contextMenu( QListBoxItem *item ) void MonthViewCell::selection( QListBoxItem *item ) { - if ( !item ) return; - + if ( !item ) { + emit highligtIncidence( 0 , this, 0 ); + return; + } + MonthViewItem * it = (static_cast<MonthViewItem *>( item )); + emit highligtIncidence( it->incidence(), this, it->multiDay() ); mMonthView->setSelectedCell( this ); } +void MonthViewCell::deHightLight() +{ + MonthViewItem *mitem = (MonthViewItem*) firstItem (); + while ( mitem ) { + if ( mitem->setHighlightedFalse() ) + updateItem ( mitem ); + mitem = (MonthViewItem *)mitem->next(); + } +} +// returns true if no inc found +bool MonthViewCell::doHightLight( Incidence * inc ) +{ + MonthViewItem *mitem = (MonthViewItem*) firstItem (); + while ( mitem ) { + if ( mitem->incidence() == inc ) { + if ( mitem->setHighlighted( inc ) ) + updateItem ( mitem ); + return false; + } + mitem = (MonthViewItem *)mitem->next(); + } + return true; +} // ******************************************************************************* // ******************************************************************************* // ******************************************************************************* @@ -1200,6 +1255,8 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) SLOT( nextCell() ) ); connect( cell, SIGNAL( prevCell() ), SLOT( prevCell() ) ); + connect( cell, SIGNAL( highligtIncidence( Incidence * , MonthViewCell *, int ) ), + SLOT( incidenceHighlighted( Incidence *, MonthViewCell *, int ) )); } } mCellsW.resize( mDaysPerWeek ); @@ -1217,6 +1274,8 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) SLOT( nextCell() ) ); connect( cell, SIGNAL( prevCell() ), SLOT( prevCell() ) ); + connect( cell, SIGNAL( highligtIncidence( Incidence * , MonthViewCell *, int ) ), + SLOT( incidenceHighlighted( Incidence *, MonthViewCell *, int ) )); cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont ); } @@ -1288,6 +1347,57 @@ KOMonthView::~KOMonthView() delete mContextMenu; } +void KOMonthView::incidenceHighlighted( Incidence * inc , MonthViewCell* mc, int mday ) +{ + //qDebug("KOMonthView::incidenceHighlighted %d %d %d", inc, mc, mday ); + static Incidence * lastInc = 0; + static MonthViewCell * lastCell = 0; + + if ( lastInc == inc && lastCell == mc ) + return; + lastInc = inc; + lastCell = mc; + //qDebug("KOMonthView::incidenceHighlighted %d %d %d", inc, mc, mday ); + + bool weekview = false; + int index = 0; + for (uint i = 0; i < mCellsW.count(); ++i) { + if ( mCellsW[i] == mc ) { + weekview = true; + index = i; + break; + } + } + QPtrVector<MonthViewCell> *cells; + if ( weekview ) + cells = &mCellsW; + else { + for (uint i = 0; i < mCells.count(); ++i) { + if ( mCells[i] == mc ) { + index = i; + break; + } + } + cells = &mCells; + } + for (uint i = 0; i < (*cells).count(); ++i) { + (*cells)[i]->deHightLight(); + } + if ( ! inc ) + return; + if ( mday > 1 && index > 0 ) + for (int i = index-1; i >= 0; --i) { + //qDebug("index %d iii %d ", index, i); + if ( (*cells)[(uint)i]->doHightLight(inc) ) + break; + } + if ( mday < 3 && mday > 0 && index < (*cells).count()-1) + for (uint i = index+1; i < (*cells).count(); ++i) { + if ( (*cells)[i]->doHightLight(inc) ) + break; + } + +} void KOMonthView::selectInternalWeekNum ( int n ) { switchView(); diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h index 65b5e77..159af16 100644 --- a/korganizer/komonthview.h +++ b/korganizer/komonthview.h @@ -44,6 +44,7 @@ class QToolTipGroup; #endif class KNOWhatsThis; +class MonthViewCell; class KOWeekButton : public QPushButton { Q_OBJECT @@ -85,6 +86,7 @@ class KNoScrollListBox: public QListBox void rightClick(); void nextCell(); void prevCell(); + void highligtIncidence( Incidence * , MonthViewCell*, int ); protected slots: void oneDown(); @@ -110,14 +112,15 @@ class MonthViewItem: public QListBoxItem void setReply(bool on) { mReply = on; } void setMoreInfo(bool on) { mInfo = on; } void setMultiDay(int type) { mMultiday = type; } + int multiDay() { return mMultiday; } void setMultiDayPos(int type) { mdayPos = type; } int gettMultiDayPos() { return mdayPos; } void setBlockRepaint(bool on) { mblockRepaint = on; } - + bool setHighlighted( Incidence * ); void setPalette(const QPalette &p) { mPalette = p; } QPalette palette() const { return mPalette; } - + bool setHighlightedFalse(); Incidence *incidence() const { return mIncidence; } QDate incidenceDate() { return mDate; } @@ -135,6 +138,7 @@ class MonthViewItem: public QListBoxItem bool mAlarm; bool mReply; bool mInfo; + bool mDisplayHightlighted; QPalette mPalette; QDate mDate; @@ -175,7 +179,8 @@ class MonthViewCell : public KNoScrollListBox Incidence *selectedIncidence(); QDate selectedIncidenceDate(); QPushButton * dateLabel() { return mLabel; } - + void deHightLight(); + bool doHightLight( Incidence *); void deselect(); void select(); #ifdef DESKTOP_VERSION @@ -192,7 +197,6 @@ class MonthViewCell : public KNoScrollListBox public slots: void showDay(); - protected slots: void defaultAction( QListBoxItem * ); void contextMenu( QListBoxItem * ); @@ -258,6 +262,7 @@ class KOMonthView: public KOEventView NavigatorBar* navigatorBar() { return mNavigatorBar ;} void clearList(); public slots: + void incidenceHighlighted( Incidence *, MonthViewCell*, int ); void nextCell(); void prevCell(); virtual void updateView(); |