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 | |
parent | 58ad1402f6415de889e7a0dc98be29e9ae56d86c (diff) | |
download | kdepimpi-2a6c47afc7688923f427f4a38e3353e3503ab09a.zip kdepimpi-2a6c47afc7688923f427f4a38e3353e3503ab09a.tar.gz kdepimpi-2a6c47afc7688923f427f4a38e3353e3503ab09a.tar.bz2 |
monthview enh
-rw-r--r-- | korganizer/komonthview.cpp | 120 | ||||
-rw-r--r-- | korganizer/komonthview.h | 13 |
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 | |||
@@ -129,32 +129,33 @@ void KNoScrollListBox::focusInEvent ( QFocusEvent * e ) | |||
129 | } else { | 129 | } else { |
130 | setVScrollBarMode(QScrollView::Auto); | 130 | setVScrollBarMode(QScrollView::Auto); |
131 | setHScrollBarMode(QScrollView::Auto); | 131 | setHScrollBarMode(QScrollView::Auto); |
132 | } | 132 | } |
133 | } | 133 | } |
134 | } | 134 | } |
135 | } | 135 | } |
136 | void KNoScrollListBox::focusOutEvent ( QFocusEvent * e ) | 136 | void KNoScrollListBox::focusOutEvent ( QFocusEvent * e ) |
137 | { | 137 | { |
138 | int i = currentItem (); | 138 | int i = currentItem (); |
139 | if ( i >= 0 ) { | 139 | if ( i >= 0 ) { |
140 | setSelected ( i, false ); | 140 | setSelected ( i, false ); |
141 | } | 141 | } |
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) |
148 | { | 149 | { |
149 | QListBoxItem* item = itemAt ( p ); | 150 | QListBoxItem* item = itemAt ( p ); |
150 | if ( ! item ) { | 151 | if ( ! item ) { |
151 | return i18n("Click in the cell\nto add an event!"); | 152 | return i18n("Click in the cell\nto add an event!"); |
152 | } | 153 | } |
153 | return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence(), | 154 | return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence(), |
154 | KOPrefs::instance()->mWTshowDetails, | 155 | KOPrefs::instance()->mWTshowDetails, |
155 | KOPrefs::instance()->mWTshowCreated, | 156 | KOPrefs::instance()->mWTshowCreated, |
156 | KOPrefs::instance()->mWTshowChanged); | 157 | KOPrefs::instance()->mWTshowChanged); |
157 | } | 158 | } |
158 | void KNoScrollListBox::keyPressEvent(QKeyEvent *e) | 159 | void KNoScrollListBox::keyPressEvent(QKeyEvent *e) |
159 | { | 160 | { |
160 | //qDebug("KNoScrollListBox::keyPressEvent "); | 161 | //qDebug("KNoScrollListBox::keyPressEvent "); |
@@ -267,71 +268,97 @@ void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) | |||
267 | break; | 268 | break; |
268 | } | 269 | } |
269 | } | 270 | } |
270 | 271 | ||
271 | void KNoScrollListBox::mousePressEvent(QMouseEvent *e) | 272 | void KNoScrollListBox::mousePressEvent(QMouseEvent *e) |
272 | { | 273 | { |
273 | QListBox::mousePressEvent(e); | 274 | QListBox::mousePressEvent(e); |
274 | 275 | ||
275 | if(e->button() == RightButton) { | 276 | if(e->button() == RightButton) { |
276 | emit rightClick(); | 277 | emit rightClick(); |
277 | } | 278 | } |
278 | } | 279 | } |
279 | 280 | ||
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; |
286 | mIncidence = incidence; | 288 | mIncidence = incidence; |
287 | mDate = qd; | 289 | mDate = qd; |
288 | mRecur = false; | 290 | mRecur = false; |
289 | mAlarm = false; | 291 | mAlarm = false; |
290 | mReply = false; | 292 | mReply = false; |
291 | mInfo = false; | 293 | mInfo = false; |
292 | mdayPos = 0; | 294 | mdayPos = 0; |
293 | isWeekItem = KOPrefs::instance()->mMonthViewWeek; | 295 | isWeekItem = KOPrefs::instance()->mMonthViewWeek; |
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; |
300 | mDate = qd; | 303 | mDate = qd; |
301 | mRecur = false; | 304 | mRecur = false; |
302 | mAlarm = false; | 305 | mAlarm = false; |
303 | mReply = false; | 306 | mReply = false; |
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 ) { |
311 | return; | 336 | return; |
312 | } | 337 | } |
313 | #if QT_VERSION >= 0x030000 | 338 | #if QT_VERSION >= 0x030000 |
314 | bool sel = isSelected(); | 339 | bool sel = isSelected(); |
315 | #else | 340 | #else |
316 | bool sel = selected(); | 341 | bool sel = selected(); |
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 ); |
325 | } | 352 | } |
326 | 353 | ||
327 | //int y = 3;//(height() - mRecurPixmap.height()) /2; | 354 | //int y = 3;//(height() - mRecurPixmap.height()) /2; |
328 | int size = PIXMAP_SIZE; | 355 | int size = PIXMAP_SIZE; |
329 | if ( QApplication::desktop()->width() < 300 ) | 356 | if ( QApplication::desktop()->width() < 300 ) |
330 | size = 3; | 357 | size = 3; |
331 | int y = (heihei - size -1 ) /2; | 358 | int y = (heihei - size -1 ) /2; |
332 | 359 | ||
333 | if ( mIncidence->calID() > 1 ) { | 360 | if ( mIncidence->calID() > 1 ) { |
334 | p->fillRect ( x, y-2,size,size+4, KOPrefs::instance()->defaultColor( mIncidence->calID() ) ); | 361 | p->fillRect ( x, y-2,size,size+4, KOPrefs::instance()->defaultColor( mIncidence->calID() ) ); |
335 | p->drawRect ( x, y-2,size,size+4); | 362 | p->drawRect ( x, y-2,size,size+4); |
336 | x += size + 1; | 363 | x += size + 1; |
337 | } | 364 | } |
@@ -587,32 +614,33 @@ void MonthViewCell::setHoliday( bool holiday ) | |||
587 | { | 614 | { |
588 | mHoliday = holiday; | 615 | mHoliday = holiday; |
589 | //setMyPalette(); | 616 | //setMyPalette(); |
590 | } | 617 | } |
591 | 618 | ||
592 | void MonthViewCell::setHoliday( const QString &holiday ) | 619 | void MonthViewCell::setHoliday( const QString &holiday ) |
593 | { | 620 | { |
594 | mHolidayString = holiday; | 621 | mHolidayString = holiday; |
595 | 622 | ||
596 | if ( !holiday.isEmpty() ) { | 623 | if ( !holiday.isEmpty() ) { |
597 | setHoliday( true ); | 624 | setHoliday( true ); |
598 | } | 625 | } |
599 | } | 626 | } |
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() ) |
606 | return; | 634 | return; |
607 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); | 635 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); |
608 | while ( mitem ) { | 636 | while ( mitem ) { |
609 | mitem->setBlockRepaint( true ); | 637 | mitem->setBlockRepaint( true ); |
610 | mitem = (MonthViewItem *)mitem->next(); | 638 | mitem = (MonthViewItem *)mitem->next(); |
611 | } | 639 | } |
612 | if ( mAvailItemList.count() > 20 ) { | 640 | if ( mAvailItemList.count() > 20 ) { |
613 | mAvailItemList.setAutoDelete( true ); | 641 | mAvailItemList.setAutoDelete( true ); |
614 | mAvailItemList.clear(); | 642 | mAvailItemList.clear(); |
615 | mAvailItemList.setAutoDelete( false ); | 643 | mAvailItemList.setAutoDelete( false ); |
616 | clear(); | 644 | clear(); |
617 | } | 645 | } |
618 | 646 | ||
@@ -1070,38 +1098,65 @@ void MonthViewCell::cellClicked( QListBoxItem *item ) | |||
1070 | } | 1098 | } |
1071 | 1099 | ||
1072 | void MonthViewCell::contextMenu( QListBoxItem *item ) | 1100 | void MonthViewCell::contextMenu( QListBoxItem *item ) |
1073 | { | 1101 | { |
1074 | mMonthView->setPopupCell( this ); | 1102 | mMonthView->setPopupCell( this ); |
1075 | if ( !item ) { | 1103 | if ( !item ) { |
1076 | mMonthView->showContextMenu( 0 ); | 1104 | mMonthView->showContextMenu( 0 ); |
1077 | return; | 1105 | return; |
1078 | } | 1106 | } |
1079 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); | 1107 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); |
1080 | Incidence *incidence = eventItem->incidence(); | 1108 | Incidence *incidence = eventItem->incidence(); |
1081 | if ( incidence ) mMonthView->showContextMenu( incidence ); | 1109 | if ( incidence ) mMonthView->showContextMenu( incidence ); |
1082 | } | 1110 | } |
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 | ||
1091 | 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 | { | ||
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 | // ******************************************************************************* |
1095 | 1150 | ||
1096 | 1151 | ||
1097 | KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) | 1152 | KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) |
1098 | : KOEventView( calendar, parent, name ), | 1153 | : KOEventView( calendar, parent, name ), |
1099 | mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), | 1154 | mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), |
1100 | mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) | 1155 | mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) |
1101 | { | 1156 | { |
1102 | mFlagKeyPressed = false; | 1157 | mFlagKeyPressed = false; |
1103 | mShortDayLabelsM = false; | 1158 | mShortDayLabelsM = false; |
1104 | mShortDayLabelsW = false; | 1159 | mShortDayLabelsW = false; |
1105 | skipResize = false; | 1160 | skipResize = false; |
1106 | clPending = true; | 1161 | clPending = true; |
1107 | mPopupCell = 0; | 1162 | mPopupCell = 0; |
@@ -1187,49 +1242,53 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) | |||
1187 | mCells.resize( mNumCells ); | 1242 | mCells.resize( mNumCells ); |
1188 | for( row = 0; row < mNumWeeks; ++row ) { | 1243 | for( row = 0; row < mNumWeeks; ++row ) { |
1189 | for( col = 0; col < mDaysPerWeek; ++col ) { | 1244 | for( col = 0; col < mDaysPerWeek; ++col ) { |
1190 | MonthViewCell *cell = new MonthViewCell( this, mMonthView ); | 1245 | MonthViewCell *cell = new MonthViewCell( this, mMonthView ); |
1191 | mCells.insert( row * mDaysPerWeek + col, cell ); | 1246 | mCells.insert( row * mDaysPerWeek + col, cell ); |
1192 | 1247 | ||
1193 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), | 1248 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), |
1194 | SLOT( defaultAction( Incidence * ) ) ); | 1249 | SLOT( defaultAction( Incidence * ) ) ); |
1195 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), | 1250 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), |
1196 | SIGNAL( newEventSignal( QDateTime ) ) ); | 1251 | SIGNAL( newEventSignal( QDateTime ) ) ); |
1197 | connect( cell, SIGNAL( showDaySignal( QDate ) ), | 1252 | connect( cell, SIGNAL( showDaySignal( QDate ) ), |
1198 | SIGNAL( showDaySignal( QDate ) ) ); | 1253 | SIGNAL( showDaySignal( QDate ) ) ); |
1199 | connect( cell, SIGNAL( nextCell() ), | 1254 | connect( cell, SIGNAL( nextCell() ), |
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 ); |
1206 | for( col = 0; col < mDaysPerWeek; ++col ) { | 1263 | for( col = 0; col < mDaysPerWeek; ++col ) { |
1207 | MonthViewCell *cell = new MonthViewCell( this, mWeekView ); | 1264 | MonthViewCell *cell = new MonthViewCell( this, mWeekView ); |
1208 | mCellsW.insert( col, cell ); | 1265 | mCellsW.insert( col, cell ); |
1209 | 1266 | ||
1210 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), | 1267 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), |
1211 | SLOT( defaultAction( Incidence * ) ) ); | 1268 | SLOT( defaultAction( Incidence * ) ) ); |
1212 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), | 1269 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), |
1213 | SIGNAL( newEventSignal( QDateTime ) ) ); | 1270 | SIGNAL( newEventSignal( QDateTime ) ) ); |
1214 | connect( cell, SIGNAL( showDaySignal( QDate ) ), | 1271 | connect( cell, SIGNAL( showDaySignal( QDate ) ), |
1215 | SIGNAL( showDaySignal( QDate ) ) ); | 1272 | SIGNAL( showDaySignal( QDate ) ) ); |
1216 | connect( cell, SIGNAL( nextCell() ), | 1273 | connect( cell, SIGNAL( nextCell() ), |
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 | ||
1223 | //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); | 1282 | //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); |
1224 | mContextMenu = eventPopup(); | 1283 | mContextMenu = eventPopup(); |
1225 | mContextMenu->addAdditionalItem(QIconSet(QPixmap()), | 1284 | mContextMenu->addAdditionalItem(QIconSet(QPixmap()), |
1226 | i18n("New Event..."),this, | 1285 | i18n("New Event..."),this, |
1227 | SLOT(slotNewEvent()),false); | 1286 | SLOT(slotNewEvent()),false); |
1228 | mContextMenu->addAdditionalItem(QIconSet(QPixmap()), | 1287 | mContextMenu->addAdditionalItem(QIconSet(QPixmap()), |
1229 | i18n("New Todo..."),this, | 1288 | i18n("New Todo..."),this, |
1230 | SLOT(slotNewTodo()),false); | 1289 | SLOT(slotNewTodo()),false); |
1231 | mContextMenu->addAdditionalItem(QIconSet(QPixmap()), | 1290 | mContextMenu->addAdditionalItem(QIconSet(QPixmap()), |
1232 | i18n("Journal"),this, | 1291 | i18n("Journal"),this, |
1233 | SLOT(slotEditJournal()),false); | 1292 | SLOT(slotEditJournal()),false); |
1234 | 1293 | ||
1235 | 1294 | ||
@@ -1275,32 +1334,83 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) | |||
1275 | resize(640, 480 ); | 1334 | resize(640, 480 ); |
1276 | updatePossible = true; | 1335 | updatePossible = true; |
1277 | #endif | 1336 | #endif |
1278 | computeLayout(); | 1337 | computeLayout(); |
1279 | 1338 | ||
1280 | if ( mShowWeekView ) | 1339 | if ( mShowWeekView ) |
1281 | mWidStack->raiseWidget( mWeekView ); | 1340 | mWidStack->raiseWidget( mWeekView ); |
1282 | else | 1341 | else |
1283 | mWidStack->raiseWidget( mMonthView ); | 1342 | mWidStack->raiseWidget( mMonthView ); |
1284 | } | 1343 | } |
1285 | 1344 | ||
1286 | KOMonthView::~KOMonthView() | 1345 | KOMonthView::~KOMonthView() |
1287 | { | 1346 | { |
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(); |
1294 | if ( !KOPrefs::instance()->mMonthViewWeek ) | 1404 | if ( !KOPrefs::instance()->mMonthViewWeek ) |
1295 | emit selectMonth (); | 1405 | emit selectMonth (); |
1296 | else | 1406 | else |
1297 | emit selectWeekNum ( n ); | 1407 | emit selectWeekNum ( n ); |
1298 | } | 1408 | } |
1299 | 1409 | ||
1300 | int KOMonthView::currentWeek() | 1410 | int KOMonthView::currentWeek() |
1301 | { | 1411 | { |
1302 | if ( mShowWeekView ) | 1412 | if ( mShowWeekView ) |
1303 | return mWeekLabelsW[0]->getWeekNum(); | 1413 | return mWeekLabelsW[0]->getWeekNum(); |
1304 | return mWeekLabels[0]->getWeekNum(); | 1414 | return mWeekLabels[0]->getWeekNum(); |
1305 | } | 1415 | } |
1306 | void KOMonthView::switchView() | 1416 | void KOMonthView::switchView() |
diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h index 65b5e77..159af16 100644 --- a/korganizer/komonthview.h +++ b/korganizer/komonthview.h | |||
@@ -31,32 +31,33 @@ | |||
31 | #include <qintdict.h> | 31 | #include <qintdict.h> |
32 | #include <qpushbutton.h> | 32 | #include <qpushbutton.h> |
33 | #include <qvaluelist.h> | 33 | #include <qvaluelist.h> |
34 | #include <qptrvector.h> | 34 | #include <qptrvector.h> |
35 | 35 | ||
36 | #include <libkcal/calendar.h> | 36 | #include <libkcal/calendar.h> |
37 | #include <libkcal/event.h> | 37 | #include <libkcal/event.h> |
38 | 38 | ||
39 | #include "koeventview.h" | 39 | #include "koeventview.h" |
40 | #include "navigatorbar.h" | 40 | #include "navigatorbar.h" |
41 | 41 | ||
42 | #ifdef DESKTOP_VERSION | 42 | #ifdef DESKTOP_VERSION |
43 | class QToolTipGroup; | 43 | 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 |
50 | public: | 51 | public: |
51 | KOWeekButton( QWidget *parent=0, const char *name=0 ) : | 52 | KOWeekButton( QWidget *parent=0, const char *name=0 ) : |
52 | QPushButton( parent, name) | 53 | QPushButton( parent, name) |
53 | { | 54 | { |
54 | connect( this, SIGNAL( clicked() ), | 55 | connect( this, SIGNAL( clicked() ), |
55 | SLOT( bottonClicked() )); | 56 | SLOT( bottonClicked() )); |
56 | mNumber = -1; | 57 | mNumber = -1; |
57 | } | 58 | } |
58 | void setWeekNum ( int num ) {mNumber = num; setText( QString::number ( num ));} | 59 | void setWeekNum ( int num ) {mNumber = num; setText( QString::number ( num ));} |
59 | int getWeekNum() { return mNumber;} | 60 | int getWeekNum() { return mNumber;} |
60 | signals: | 61 | signals: |
61 | void selectWeekNum ( int ); | 62 | void selectWeekNum ( int ); |
62 | private: | 63 | private: |
@@ -72,82 +73,85 @@ private slots : | |||
72 | }; | 73 | }; |
73 | 74 | ||
74 | class KNoScrollListBox: public QListBox | 75 | class KNoScrollListBox: public QListBox |
75 | { | 76 | { |
76 | Q_OBJECT | 77 | Q_OBJECT |
77 | public: | 78 | public: |
78 | KNoScrollListBox(QWidget *parent=0, const char *name=0); | 79 | KNoScrollListBox(QWidget *parent=0, const char *name=0); |
79 | ~KNoScrollListBox(); | 80 | ~KNoScrollListBox(); |
80 | QString getWhatsThisText(QPoint p) ; | 81 | QString getWhatsThisText(QPoint p) ; |
81 | 82 | ||
82 | signals: | 83 | signals: |
83 | void shiftDown(); | 84 | void shiftDown(); |
84 | void shiftUp(); | 85 | void shiftUp(); |
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(); |
91 | void keyPressEvent(QKeyEvent *); | 93 | void keyPressEvent(QKeyEvent *); |
92 | void keyReleaseEvent(QKeyEvent *); | 94 | void keyReleaseEvent(QKeyEvent *); |
93 | void mousePressEvent(QMouseEvent *); | 95 | void mousePressEvent(QMouseEvent *); |
94 | void focusInEvent ( QFocusEvent * ); | 96 | void focusInEvent ( QFocusEvent * ); |
95 | void focusOutEvent ( QFocusEvent * ); | 97 | void focusOutEvent ( QFocusEvent * ); |
96 | 98 | ||
97 | private: | 99 | private: |
98 | bool resetOnFocusIn; | 100 | bool resetOnFocusIn; |
99 | KNOWhatsThis * mWT; | 101 | KNOWhatsThis * mWT; |
100 | }; | 102 | }; |
101 | 103 | ||
102 | 104 | ||
103 | class MonthViewItem: public QListBoxItem | 105 | class MonthViewItem: public QListBoxItem |
104 | { | 106 | { |
105 | public: | 107 | public: |
106 | MonthViewItem( Incidence *, QDate qd, const QString & title ); | 108 | MonthViewItem( Incidence *, QDate qd, const QString & title ); |
107 | void recycle( Incidence *incidence, QDate qd, const QString & s); | 109 | void recycle( Incidence *incidence, QDate qd, const QString & s); |
108 | void setRecur(bool on) { mRecur = on; } | 110 | void setRecur(bool on) { mRecur = on; } |
109 | void setAlarm(bool on) { mAlarm = on; } | 111 | void setAlarm(bool on) { mAlarm = on; } |
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 | ||
124 | protected: | 127 | protected: |
125 | virtual void paint(QPainter *); | 128 | virtual void paint(QPainter *); |
126 | virtual int height(const QListBox *) const; | 129 | virtual int height(const QListBox *) const; |
127 | virtual int width(const QListBox *) const; | 130 | virtual int width(const QListBox *) const; |
128 | 131 | ||
129 | private: | 132 | private: |
130 | int mdayPos; | 133 | int mdayPos; |
131 | bool isWeekItem; | 134 | bool isWeekItem; |
132 | bool mblockRepaint; | 135 | bool mblockRepaint; |
133 | int mMultiday; | 136 | int mMultiday; |
134 | bool mRecur; | 137 | bool mRecur; |
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; |
141 | 145 | ||
142 | Incidence *mIncidence; | 146 | Incidence *mIncidence; |
143 | }; | 147 | }; |
144 | 148 | ||
145 | 149 | ||
146 | class KOMonthView; | 150 | class KOMonthView; |
147 | 151 | ||
148 | class MonthViewCell : public KNoScrollListBox | 152 | class MonthViewCell : public KNoScrollListBox |
149 | { | 153 | { |
150 | Q_OBJECT | 154 | Q_OBJECT |
151 | public: | 155 | public: |
152 | MonthViewCell(KOMonthView *,QWidget* ); | 156 | MonthViewCell(KOMonthView *,QWidget* ); |
153 | ~MonthViewCell() {mAvailItemList.setAutoDelete( true );} | 157 | ~MonthViewCell() {mAvailItemList.setAutoDelete( true );} |
@@ -162,50 +166,50 @@ class MonthViewCell : public KNoScrollListBox | |||
162 | void setHoliday( const QString & ); | 166 | void setHoliday( const QString & ); |
163 | 167 | ||
164 | void updateCell(); | 168 | void updateCell(); |
165 | void startUpdateCell(); | 169 | void startUpdateCell(); |
166 | void finishUpdateCell(); | 170 | void finishUpdateCell(); |
167 | void repaintfinishUpdateCell(); | 171 | void repaintfinishUpdateCell(); |
168 | int insertEvent(Event *); | 172 | int insertEvent(Event *); |
169 | void insertTodo(Todo *); | 173 | void insertTodo(Todo *); |
170 | 174 | ||
171 | void updateConfig( bool bigFont = false ); | 175 | void updateConfig( bool bigFont = false ); |
172 | 176 | ||
173 | void enableScrollBars( bool ); | 177 | void enableScrollBars( bool ); |
174 | 178 | ||
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 |
182 | static QToolTipGroup *toolTipGroup(); | 187 | static QToolTipGroup *toolTipGroup(); |
183 | #endif | 188 | #endif |
184 | signals: | 189 | signals: |
185 | void defaultAction( Incidence * ); | 190 | void defaultAction( Incidence * ); |
186 | void newEventSignal( QDateTime ); | 191 | void newEventSignal( QDateTime ); |
187 | void showDaySignal( QDate ); | 192 | void showDaySignal( QDate ); |
188 | 193 | ||
189 | protected: | 194 | protected: |
190 | QStringList mToolTip; | 195 | QStringList mToolTip; |
191 | void resizeEvent( QResizeEvent * ); | 196 | void resizeEvent( QResizeEvent * ); |
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 * ); |
199 | void selection( QListBoxItem * ); | 203 | void selection( QListBoxItem * ); |
200 | void cellClicked( QListBoxItem * ); | 204 | void cellClicked( QListBoxItem * ); |
201 | void newEvent(); | 205 | void newEvent(); |
202 | 206 | ||
203 | private: | 207 | private: |
204 | int mdayCount; | 208 | int mdayCount; |
205 | QPtrList <MonthViewItem> mAvailItemList; | 209 | QPtrList <MonthViewItem> mAvailItemList; |
206 | KOMonthView *mMonthView; | 210 | KOMonthView *mMonthView; |
207 | int currentPalette; | 211 | int currentPalette; |
208 | 212 | ||
209 | QDate mDate; | 213 | QDate mDate; |
210 | bool mPrimary; | 214 | bool mPrimary; |
211 | bool mHoliday; | 215 | bool mHoliday; |
@@ -245,32 +249,33 @@ class KOMonthView: public KOEventView | |||
245 | /** returns the currently selected events */ | 249 | /** returns the currently selected events */ |
246 | virtual QPtrList<Incidence> selectedIncidences(); | 250 | virtual QPtrList<Incidence> selectedIncidences(); |
247 | 251 | ||
248 | /** returns dates of the currently selected events */ | 252 | /** returns dates of the currently selected events */ |
249 | virtual DateList selectedDates(); | 253 | virtual DateList selectedDates(); |
250 | 254 | ||
251 | virtual void printPreview(CalPrinter *calPrinter, | 255 | virtual void printPreview(CalPrinter *calPrinter, |
252 | const QDate &, const QDate &); | 256 | const QDate &, const QDate &); |
253 | bool isMonthView() { return !mShowWeekView; } | 257 | bool isMonthView() { return !mShowWeekView; } |
254 | bool isUpdatePossible() { return updatePossible; } | 258 | bool isUpdatePossible() { return updatePossible; } |
255 | 259 | ||
256 | MonthViewCell * selectedCell(); | 260 | MonthViewCell * selectedCell(); |
257 | bool skipResize; | 261 | bool skipResize; |
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(); |
264 | virtual void updateConfig(); | 269 | virtual void updateConfig(); |
265 | virtual void showDates(const QDate &start, const QDate &end); | 270 | virtual void showDates(const QDate &start, const QDate &end); |
266 | virtual void showEvents(QPtrList<Event> eventList); | 271 | virtual void showEvents(QPtrList<Event> eventList); |
267 | 272 | ||
268 | void changeEventDisplay(Event *, int); | 273 | void changeEventDisplay(Event *, int); |
269 | 274 | ||
270 | void clearSelection(); | 275 | void clearSelection(); |
271 | 276 | ||
272 | void showContextMenu( Incidence * ); | 277 | void showContextMenu( Incidence * ); |
273 | 278 | ||
274 | void setSelectedCell( MonthViewCell * ); | 279 | void setSelectedCell( MonthViewCell * ); |
275 | void setPopupCell( MonthViewCell * ); | 280 | void setPopupCell( MonthViewCell * ); |
276 | void switchView(); | 281 | void switchView(); |