summaryrefslogtreecommitdiffabout
path: root/korganizer
Side-by-side diff
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/komonthview.cpp120
-rw-r--r--korganizer/komonthview.h13
2 files changed, 124 insertions, 9 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index cba85fa..9b0389d 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -144,2 +144,3 @@ void KNoScrollListBox::focusOutEvent ( QFocusEvent * e )
setHScrollBarMode(QScrollView::AlwaysOff);
+ emit highligtIncidence( 0, (MonthViewCell*)this, 0 );
}
@@ -282,2 +283,3 @@ MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s)
{
+ mDisplayHightlighted = false;
mblockRepaint = true;
@@ -295,3 +297,4 @@ MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s)
void MonthViewItem::recycle( Incidence *incidence, QDate qd, const QString & s)
-{
+{
+ mDisplayHightlighted = false;
setText( s );
@@ -306,3 +309,25 @@ void MonthViewItem::recycle( Incidence *incidence, QDate qd, const QString & s)
}
+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)
@@ -319,4 +344,6 @@ void MonthViewItem::paint(QPainter *p)
int x = 1;
- if (KOPrefs::instance()->mMonthViewUsesCategoryColor)
+ if (KOPrefs::instance()->mMonthViewUsesCategoryColor || mDisplayHightlighted )
{
+ if ( mDisplayHightlighted )
+ sel = true;
p->setBackgroundColor( palette().color( QPalette::Normal, \
@@ -602,2 +629,3 @@ void MonthViewCell::startUpdateCell()
{
+
mdayCount = 0;
@@ -1085,4 +1113,8 @@ 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 );
@@ -1090,3 +1122,26 @@ void MonthViewCell::selection( QListBoxItem *item )
-
+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;
+}
// *******************************************************************************
@@ -1202,2 +1257,4 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
SLOT( prevCell() ) );
+ connect( cell, SIGNAL( highligtIncidence( Incidence * , MonthViewCell *, int ) ),
+ SLOT( incidenceHighlighted( Incidence *, MonthViewCell *, int ) ));
}
@@ -1219,2 +1276,4 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
SLOT( prevCell() ) );
+ connect( cell, SIGNAL( highligtIncidence( Incidence * , MonthViewCell *, int ) ),
+ SLOT( incidenceHighlighted( Incidence *, MonthViewCell *, int ) ));
cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont );
@@ -1290,2 +1349,53 @@ KOMonthView::~KOMonthView()
+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 )
diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h
index 65b5e77..159af16 100644
--- a/korganizer/komonthview.h
+++ b/korganizer/komonthview.h
@@ -46,2 +46,3 @@ class QToolTipGroup;
class KNOWhatsThis;
+class MonthViewCell;
class KOWeekButton : public QPushButton
@@ -87,2 +88,3 @@ class KNoScrollListBox: public QListBox
void prevCell();
+ void highligtIncidence( Incidence * , MonthViewCell*, int );
@@ -112,2 +114,3 @@ class MonthViewItem: public QListBoxItem
void setMultiDay(int type) { mMultiday = type; }
+ int multiDay() { return mMultiday; }
void setMultiDayPos(int type) { mdayPos = type; }
@@ -115,3 +118,3 @@ class MonthViewItem: public QListBoxItem
void setBlockRepaint(bool on) { mblockRepaint = on; }
-
+ bool setHighlighted( Incidence * );
@@ -119,3 +122,3 @@ class MonthViewItem: public QListBoxItem
QPalette palette() const { return mPalette; }
-
+ bool setHighlightedFalse();
Incidence *incidence() const { return mIncidence; }
@@ -137,2 +140,3 @@ class MonthViewItem: public QListBoxItem
bool mInfo;
+ bool mDisplayHightlighted;
@@ -177,3 +181,4 @@ class MonthViewCell : public KNoScrollListBox
QPushButton * dateLabel() { return mLabel; }
-
+ void deHightLight();
+ bool doHightLight( Incidence *);
void deselect();
@@ -194,3 +199,2 @@ public slots:
void showDay();
-
protected slots:
@@ -260,2 +264,3 @@ class KOMonthView: public KOEventView
public slots:
+ void incidenceHighlighted( Incidence *, MonthViewCell*, int );
void nextCell();