author | zautrix <zautrix> | 2005-06-27 17:25:27 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-06-27 17:25:27 (UTC) |
commit | 2a6c47afc7688923f427f4a38e3353e3503ab09a (patch) (unidiff) | |
tree | f314e7062e60f8e0302714bcc6149f2e83c96e30 /korganizer | |
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 ) | |||
142 | QListBox::focusOutEvent ( e ); | 142 | QListBox::focusOutEvent ( e ); |
143 | setVScrollBarMode(QScrollView::AlwaysOff); | 143 | setVScrollBarMode(QScrollView::AlwaysOff); |
144 | setHScrollBarMode(QScrollView::AlwaysOff); | 144 | setHScrollBarMode(QScrollView::AlwaysOff); |
145 | emit highligtIncidence( 0, (MonthViewCell*)this, 0 ); | ||
145 | } | 146 | } |
146 | 147 | ||
147 | QString KNoScrollListBox::getWhatsThisText(QPoint p) | 148 | QString KNoScrollListBox::getWhatsThisText(QPoint p) |
@@ -280,6 +281,7 @@ void KNoScrollListBox::mousePressEvent(QMouseEvent *e) | |||
280 | MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) | 281 | MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) |
281 | : QListBoxItem() | 282 | : QListBoxItem() |
282 | { | 283 | { |
284 | mDisplayHightlighted = false; | ||
283 | mblockRepaint = true; | 285 | mblockRepaint = true; |
284 | setText( s ); | 286 | setText( s ); |
285 | mMultiday = 0; | 287 | mMultiday = 0; |
@@ -294,6 +296,7 @@ MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) | |||
294 | } | 296 | } |
295 | void MonthViewItem::recycle( Incidence *incidence, QDate qd, const QString & s) | 297 | void MonthViewItem::recycle( Incidence *incidence, QDate qd, const QString & s) |
296 | { | 298 | { |
299 | mDisplayHightlighted = false; | ||
297 | setText( s ); | 300 | setText( s ); |
298 | mMultiday = 0; | 301 | mMultiday = 0; |
299 | mIncidence = incidence; | 302 | mIncidence = incidence; |
@@ -304,7 +307,29 @@ void MonthViewItem::recycle( Incidence *incidence, QDate qd, const QString & s) | |||
304 | mInfo = false; | 307 | mInfo = false; |
305 | mdayPos = 0; | 308 | mdayPos = 0; |
306 | } | 309 | } |
310 | bool MonthViewItem::setHighlightedFalse() | ||
311 | { | ||
312 | if ( !mDisplayHightlighted ) | ||
313 | return false; | ||
314 | mDisplayHightlighted = false; | ||
315 | return true; | ||
316 | } | ||
307 | 317 | ||
318 | bool MonthViewItem::setHighlighted( Incidence * inc ) | ||
319 | { | ||
320 | if ( inc == mIncidence ) { | ||
321 | if ( mDisplayHightlighted ) | ||
322 | return false; | ||
323 | mDisplayHightlighted = true; | ||
324 | return true; | ||
325 | } else { | ||
326 | if ( !mDisplayHightlighted ) | ||
327 | return false; | ||
328 | mDisplayHightlighted = false; | ||
329 | return true; | ||
330 | } | ||
331 | return false; | ||
332 | } | ||
308 | void MonthViewItem::paint(QPainter *p) | 333 | void MonthViewItem::paint(QPainter *p) |
309 | { | 334 | { |
310 | if ( mblockRepaint ) { | 335 | if ( mblockRepaint ) { |
@@ -317,8 +342,10 @@ void MonthViewItem::paint(QPainter *p) | |||
317 | #endif | 342 | #endif |
318 | int heihei = height( listBox () ); | 343 | int heihei = height( listBox () ); |
319 | int x = 1; | 344 | int x = 1; |
320 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) | 345 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor || mDisplayHightlighted ) |
321 | { | 346 | { |
347 | if ( mDisplayHightlighted ) | ||
348 | sel = true; | ||
322 | p->setBackgroundColor( palette().color( QPalette::Normal, \ | 349 | p->setBackgroundColor( palette().color( QPalette::Normal, \ |
323 | sel ? QColorGroup::Highlight : QColorGroup::Background ) ); | 350 | sel ? QColorGroup::Highlight : QColorGroup::Background ) ); |
324 | p->eraseRect( 0, 0, listBox()->maxItemWidth(), heihei ); | 351 | p->eraseRect( 0, 0, listBox()->maxItemWidth(), heihei ); |
@@ -600,6 +627,7 @@ void MonthViewCell::setHoliday( const QString &holiday ) | |||
600 | 627 | ||
601 | void MonthViewCell::startUpdateCell() | 628 | void MonthViewCell::startUpdateCell() |
602 | { | 629 | { |
630 | |||
603 | mdayCount = 0; | 631 | mdayCount = 0; |
604 | setFocusPolicy(NoFocus); | 632 | setFocusPolicy(NoFocus); |
605 | if ( !mMonthView->isUpdatePossible() ) | 633 | if ( !mMonthView->isUpdatePossible() ) |
@@ -1083,12 +1111,39 @@ void MonthViewCell::contextMenu( QListBoxItem *item ) | |||
1083 | 1111 | ||
1084 | void MonthViewCell::selection( QListBoxItem *item ) | 1112 | void MonthViewCell::selection( QListBoxItem *item ) |
1085 | { | 1113 | { |
1086 | if ( !item ) return; | 1114 | if ( !item ) { |
1087 | 1115 | emit highligtIncidence( 0 , this, 0 ); | |
1116 | return; | ||
1117 | } | ||
1118 | MonthViewItem * it = (static_cast<MonthViewItem *>( item )); | ||
1119 | emit highligtIncidence( it->incidence(), this, it->multiDay() ); | ||
1088 | mMonthView->setSelectedCell( this ); | 1120 | mMonthView->setSelectedCell( this ); |
1089 | } | 1121 | } |
1090 | 1122 | ||
1123 | void MonthViewCell::deHightLight() | ||
1124 | { | ||
1125 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); | ||
1126 | while ( mitem ) { | ||
1127 | if ( mitem->setHighlightedFalse() ) | ||
1128 | updateItem ( mitem ); | ||
1129 | mitem = (MonthViewItem *)mitem->next(); | ||
1130 | } | ||
1131 | } | ||
1132 | // returns true if no inc found | ||
1133 | bool MonthViewCell::doHightLight( Incidence * inc ) | ||
1134 | { | ||
1091 | 1135 | ||
1136 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); | ||
1137 | while ( mitem ) { | ||
1138 | if ( mitem->incidence() == inc ) { | ||
1139 | if ( mitem->setHighlighted( inc ) ) | ||
1140 | updateItem ( mitem ); | ||
1141 | return false; | ||
1142 | } | ||
1143 | mitem = (MonthViewItem *)mitem->next(); | ||
1144 | } | ||
1145 | return true; | ||
1146 | } | ||
1092 | // ******************************************************************************* | 1147 | // ******************************************************************************* |
1093 | // ******************************************************************************* | 1148 | // ******************************************************************************* |
1094 | // ******************************************************************************* | 1149 | // ******************************************************************************* |
@@ -1200,6 +1255,8 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) | |||
1200 | SLOT( nextCell() ) ); | 1255 | SLOT( nextCell() ) ); |
1201 | connect( cell, SIGNAL( prevCell() ), | 1256 | connect( cell, SIGNAL( prevCell() ), |
1202 | SLOT( prevCell() ) ); | 1257 | SLOT( prevCell() ) ); |
1258 | connect( cell, SIGNAL( highligtIncidence( Incidence * , MonthViewCell *, int ) ), | ||
1259 | SLOT( incidenceHighlighted( Incidence *, MonthViewCell *, int ) )); | ||
1203 | } | 1260 | } |
1204 | } | 1261 | } |
1205 | mCellsW.resize( mDaysPerWeek ); | 1262 | mCellsW.resize( mDaysPerWeek ); |
@@ -1217,6 +1274,8 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) | |||
1217 | SLOT( nextCell() ) ); | 1274 | SLOT( nextCell() ) ); |
1218 | connect( cell, SIGNAL( prevCell() ), | 1275 | connect( cell, SIGNAL( prevCell() ), |
1219 | SLOT( prevCell() ) ); | 1276 | SLOT( prevCell() ) ); |
1277 | connect( cell, SIGNAL( highligtIncidence( Incidence * , MonthViewCell *, int ) ), | ||
1278 | SLOT( incidenceHighlighted( Incidence *, MonthViewCell *, int ) )); | ||
1220 | cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont ); | 1279 | cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont ); |
1221 | } | 1280 | } |
1222 | 1281 | ||
@@ -1288,6 +1347,57 @@ KOMonthView::~KOMonthView() | |||
1288 | delete mContextMenu; | 1347 | delete mContextMenu; |
1289 | } | 1348 | } |
1290 | 1349 | ||
1350 | void KOMonthView::incidenceHighlighted( Incidence * inc , MonthViewCell* mc, int mday ) | ||
1351 | { | ||
1352 | //qDebug("KOMonthView::incidenceHighlighted %d %d %d", inc, mc, mday ); | ||
1353 | static Incidence * lastInc = 0; | ||
1354 | static MonthViewCell * lastCell = 0; | ||
1355 | |||
1356 | if ( lastInc == inc && lastCell == mc ) | ||
1357 | return; | ||
1358 | lastInc = inc; | ||
1359 | lastCell = mc; | ||
1360 | //qDebug("KOMonthView::incidenceHighlighted %d %d %d", inc, mc, mday ); | ||
1361 | |||
1362 | bool weekview = false; | ||
1363 | int index = 0; | ||
1364 | for (uint i = 0; i < mCellsW.count(); ++i) { | ||
1365 | if ( mCellsW[i] == mc ) { | ||
1366 | weekview = true; | ||
1367 | index = i; | ||
1368 | break; | ||
1369 | } | ||
1370 | } | ||
1371 | QPtrVector<MonthViewCell> *cells; | ||
1372 | if ( weekview ) | ||
1373 | cells = &mCellsW; | ||
1374 | else { | ||
1375 | for (uint i = 0; i < mCells.count(); ++i) { | ||
1376 | if ( mCells[i] == mc ) { | ||
1377 | index = i; | ||
1378 | break; | ||
1379 | } | ||
1380 | } | ||
1381 | cells = &mCells; | ||
1382 | } | ||
1383 | for (uint i = 0; i < (*cells).count(); ++i) { | ||
1384 | (*cells)[i]->deHightLight(); | ||
1385 | } | ||
1386 | if ( ! inc ) | ||
1387 | return; | ||
1388 | if ( mday > 1 && index > 0 ) | ||
1389 | for (int i = index-1; i >= 0; --i) { | ||
1390 | //qDebug("index %d iii %d ", index, i); | ||
1391 | if ( (*cells)[(uint)i]->doHightLight(inc) ) | ||
1392 | break; | ||
1393 | } | ||
1394 | if ( mday < 3 && mday > 0 && index < (*cells).count()-1) | ||
1395 | for (uint i = index+1; i < (*cells).count(); ++i) { | ||
1396 | if ( (*cells)[i]->doHightLight(inc) ) | ||
1397 | break; | ||
1398 | } | ||
1399 | |||
1400 | } | ||
1291 | void KOMonthView::selectInternalWeekNum ( int n ) | 1401 | void KOMonthView::selectInternalWeekNum ( int n ) |
1292 | { | 1402 | { |
1293 | switchView(); | 1403 | 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; | |||
44 | #endif | 44 | #endif |
45 | 45 | ||
46 | class KNOWhatsThis; | 46 | class KNOWhatsThis; |
47 | class MonthViewCell; | ||
47 | class KOWeekButton : public QPushButton | 48 | class KOWeekButton : public QPushButton |
48 | { | 49 | { |
49 | Q_OBJECT | 50 | Q_OBJECT |
@@ -85,6 +86,7 @@ class KNoScrollListBox: public QListBox | |||
85 | void rightClick(); | 86 | void rightClick(); |
86 | void nextCell(); | 87 | void nextCell(); |
87 | void prevCell(); | 88 | void prevCell(); |
89 | void highligtIncidence( Incidence * , MonthViewCell*, int ); | ||
88 | 90 | ||
89 | protected slots: | 91 | protected slots: |
90 | void oneDown(); | 92 | void oneDown(); |
@@ -110,14 +112,15 @@ class MonthViewItem: public QListBoxItem | |||
110 | void setReply(bool on) { mReply = on; } | 112 | void setReply(bool on) { mReply = on; } |
111 | void setMoreInfo(bool on) { mInfo = on; } | 113 | void setMoreInfo(bool on) { mInfo = on; } |
112 | void setMultiDay(int type) { mMultiday = type; } | 114 | void setMultiDay(int type) { mMultiday = type; } |
115 | int multiDay() { return mMultiday; } | ||
113 | void setMultiDayPos(int type) { mdayPos = type; } | 116 | void setMultiDayPos(int type) { mdayPos = type; } |
114 | int gettMultiDayPos() { return mdayPos; } | 117 | int gettMultiDayPos() { return mdayPos; } |
115 | void setBlockRepaint(bool on) { mblockRepaint = on; } | 118 | void setBlockRepaint(bool on) { mblockRepaint = on; } |
116 | 119 | bool setHighlighted( Incidence * ); | |
117 | 120 | ||
118 | void setPalette(const QPalette &p) { mPalette = p; } | 121 | void setPalette(const QPalette &p) { mPalette = p; } |
119 | QPalette palette() const { return mPalette; } | 122 | QPalette palette() const { return mPalette; } |
120 | 123 | bool setHighlightedFalse(); | |
121 | Incidence *incidence() const { return mIncidence; } | 124 | Incidence *incidence() const { return mIncidence; } |
122 | QDate incidenceDate() { return mDate; } | 125 | QDate incidenceDate() { return mDate; } |
123 | 126 | ||
@@ -135,6 +138,7 @@ class MonthViewItem: public QListBoxItem | |||
135 | bool mAlarm; | 138 | bool mAlarm; |
136 | bool mReply; | 139 | bool mReply; |
137 | bool mInfo; | 140 | bool mInfo; |
141 | bool mDisplayHightlighted; | ||
138 | 142 | ||
139 | QPalette mPalette; | 143 | QPalette mPalette; |
140 | QDate mDate; | 144 | QDate mDate; |
@@ -175,7 +179,8 @@ class MonthViewCell : public KNoScrollListBox | |||
175 | Incidence *selectedIncidence(); | 179 | Incidence *selectedIncidence(); |
176 | QDate selectedIncidenceDate(); | 180 | QDate selectedIncidenceDate(); |
177 | QPushButton * dateLabel() { return mLabel; } | 181 | QPushButton * dateLabel() { return mLabel; } |
178 | 182 | void deHightLight(); | |
183 | bool doHightLight( Incidence *); | ||
179 | void deselect(); | 184 | void deselect(); |
180 | void select(); | 185 | void select(); |
181 | #ifdef DESKTOP_VERSION | 186 | #ifdef DESKTOP_VERSION |
@@ -192,7 +197,6 @@ class MonthViewCell : public KNoScrollListBox | |||
192 | 197 | ||
193 | public slots: | 198 | public slots: |
194 | void showDay(); | 199 | void showDay(); |
195 | |||
196 | protected slots: | 200 | protected slots: |
197 | void defaultAction( QListBoxItem * ); | 201 | void defaultAction( QListBoxItem * ); |
198 | void contextMenu( QListBoxItem * ); | 202 | void contextMenu( QListBoxItem * ); |
@@ -258,6 +262,7 @@ class KOMonthView: public KOEventView | |||
258 | NavigatorBar* navigatorBar() { return mNavigatorBar ;} | 262 | NavigatorBar* navigatorBar() { return mNavigatorBar ;} |
259 | void clearList(); | 263 | void clearList(); |
260 | public slots: | 264 | public slots: |
265 | void incidenceHighlighted( Incidence *, MonthViewCell*, int ); | ||
261 | void nextCell(); | 266 | void nextCell(); |
262 | void prevCell(); | 267 | void prevCell(); |
263 | virtual void updateView(); | 268 | virtual void updateView(); |