-rw-r--r-- | korganizer/koagendaview.cpp | 19 | ||||
-rw-r--r-- | korganizer/komonthview.cpp | 2 |
2 files changed, 17 insertions, 4 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp index 749204b..c5acafd 100644 --- a/korganizer/koagendaview.cpp +++ b/korganizer/koagendaview.cpp | |||
@@ -1185,259 +1185,272 @@ void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd, | |||
1185 | #endif | 1185 | #endif |
1186 | } | 1186 | } |
1187 | 1187 | ||
1188 | // void KOAgendaView::updateMovedTodo() | 1188 | // void KOAgendaView::updateMovedTodo() |
1189 | // { | 1189 | // { |
1190 | // // updateConfig(); | 1190 | // // updateConfig(); |
1191 | // // emit updateTodoViews(); | 1191 | // // emit updateTodoViews(); |
1192 | // } | 1192 | // } |
1193 | 1193 | ||
1194 | void KOAgendaView::newEvent(int gx, int gy) | 1194 | void KOAgendaView::newEvent(int gx, int gy) |
1195 | { | 1195 | { |
1196 | if (!mSelectedDates.count()) return; | 1196 | if (!mSelectedDates.count()) return; |
1197 | 1197 | ||
1198 | QDate day = mSelectedDates[gx]; | 1198 | QDate day = mSelectedDates[gx]; |
1199 | 1199 | ||
1200 | QTime time = mAgenda->gyToTime(gy); | 1200 | QTime time = mAgenda->gyToTime(gy); |
1201 | QDateTime dt(day,time); | 1201 | QDateTime dt(day,time); |
1202 | // if ( dt < QDateTime::currentDateTime () ) | 1202 | // if ( dt < QDateTime::currentDateTime () ) |
1203 | // dt = QDateTime::currentDateTime ().addSecs( 3600 ); | 1203 | // dt = QDateTime::currentDateTime ().addSecs( 3600 ); |
1204 | emit newEventSignal(dt); | 1204 | emit newEventSignal(dt); |
1205 | } | 1205 | } |
1206 | 1206 | ||
1207 | void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd) | 1207 | void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd) |
1208 | { | 1208 | { |
1209 | if (!mSelectedDates.count()) return; | 1209 | if (!mSelectedDates.count()) return; |
1210 | 1210 | ||
1211 | QDate dayStart = mSelectedDates[gxStart]; | 1211 | QDate dayStart = mSelectedDates[gxStart]; |
1212 | QDate dayEnd = mSelectedDates[gxEnd]; | 1212 | QDate dayEnd = mSelectedDates[gxEnd]; |
1213 | 1213 | ||
1214 | QTime timeStart = mAgenda->gyToTime(gyStart); | 1214 | QTime timeStart = mAgenda->gyToTime(gyStart); |
1215 | QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); | 1215 | QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); |
1216 | 1216 | ||
1217 | QDateTime dtStart(dayStart,timeStart); | 1217 | QDateTime dtStart(dayStart,timeStart); |
1218 | QDateTime dtEnd(dayEnd,timeEnd); | 1218 | QDateTime dtEnd(dayEnd,timeEnd); |
1219 | 1219 | ||
1220 | emit newEventSignal(dtStart,dtEnd); | 1220 | emit newEventSignal(dtStart,dtEnd); |
1221 | } | 1221 | } |
1222 | 1222 | ||
1223 | void KOAgendaView::newEventAllDay(int gx, int ) | 1223 | void KOAgendaView::newEventAllDay(int gx, int ) |
1224 | { | 1224 | { |
1225 | if (!mSelectedDates.count()) return; | 1225 | if (!mSelectedDates.count()) return; |
1226 | 1226 | ||
1227 | QDate day = mSelectedDates[gx]; | 1227 | QDate day = mSelectedDates[gx]; |
1228 | 1228 | ||
1229 | emit newEventSignal(day); | 1229 | emit newEventSignal(day); |
1230 | } | 1230 | } |
1231 | 1231 | ||
1232 | void KOAgendaView::updateEventIndicatorTop(int newY) | 1232 | void KOAgendaView::updateEventIndicatorTop(int newY) |
1233 | { | 1233 | { |
1234 | uint i; | 1234 | uint i; |
1235 | for(i=0;i<mMinY.size();++i) { | 1235 | for(i=0;i<mMinY.size();++i) { |
1236 | if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true); | 1236 | if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true); |
1237 | else mEventIndicatorTop->enableColumn(i,false); | 1237 | else mEventIndicatorTop->enableColumn(i,false); |
1238 | } | 1238 | } |
1239 | 1239 | ||
1240 | mEventIndicatorTop->update(); | 1240 | mEventIndicatorTop->update(); |
1241 | } | 1241 | } |
1242 | 1242 | ||
1243 | void KOAgendaView::updateEventIndicatorBottom(int newY) | 1243 | void KOAgendaView::updateEventIndicatorBottom(int newY) |
1244 | { | 1244 | { |
1245 | uint i; | 1245 | uint i; |
1246 | for(i=0;i<mMaxY.size();++i) { | 1246 | for(i=0;i<mMaxY.size();++i) { |
1247 | if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true); | 1247 | if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true); |
1248 | else mEventIndicatorBottom->enableColumn(i,false); | 1248 | else mEventIndicatorBottom->enableColumn(i,false); |
1249 | } | 1249 | } |
1250 | 1250 | ||
1251 | mEventIndicatorBottom->update(); | 1251 | mEventIndicatorBottom->update(); |
1252 | } | 1252 | } |
1253 | 1253 | ||
1254 | void KOAgendaView::startDrag(Event *event) | 1254 | void KOAgendaView::startDrag(Event *event) |
1255 | { | 1255 | { |
1256 | #ifndef KORG_NODND | 1256 | #ifndef KORG_NODND |
1257 | DndFactory factory( calendar() ); | 1257 | DndFactory factory( calendar() ); |
1258 | ICalDrag *vd = factory.createDrag(event,this); | 1258 | ICalDrag *vd = factory.createDrag(event,this); |
1259 | if (vd->drag()) { | 1259 | if (vd->drag()) { |
1260 | kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl; | 1260 | kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl; |
1261 | } | 1261 | } |
1262 | #endif | 1262 | #endif |
1263 | } | 1263 | } |
1264 | 1264 | ||
1265 | void KOAgendaView::readSettings() | 1265 | void KOAgendaView::readSettings() |
1266 | { | 1266 | { |
1267 | readSettings(KOGlobals::config()); | 1267 | readSettings(KOGlobals::config()); |
1268 | } | 1268 | } |
1269 | 1269 | ||
1270 | void KOAgendaView::readSettings(KConfig *config) | 1270 | void KOAgendaView::readSettings(KConfig *config) |
1271 | { | 1271 | { |
1272 | // kdDebug() << "KOAgendaView::readSettings()" << endl; | 1272 | // kdDebug() << "KOAgendaView::readSettings()" << endl; |
1273 | 1273 | ||
1274 | config->setGroup("Views"); | 1274 | config->setGroup("Views"); |
1275 | 1275 | ||
1276 | //#ifndef KORG_NOSPLITTER | 1276 | //#ifndef KORG_NOSPLITTER |
1277 | QValueList<int> sizes = config->readIntListEntry("Separator AgendaView"); | 1277 | QValueList<int> sizes = config->readIntListEntry("Separator AgendaView"); |
1278 | if (sizes.count() == 2) { | 1278 | if (sizes.count() == 2) { |
1279 | if ( sizes[0] < 20 ) { | 1279 | if ( sizes[0] < 20 ) { |
1280 | sizes[1] = sizes[1] +20 - sizes[0]; | 1280 | sizes[1] = sizes[1] +20 - sizes[0]; |
1281 | sizes[0] = 20; | 1281 | sizes[0] = 20; |
1282 | } | 1282 | } |
1283 | mSplitterAgenda->setSizes(sizes); | 1283 | mSplitterAgenda->setSizes(sizes); |
1284 | // qDebug("read %d %d ",sizes[0],sizes[1] ); | 1284 | // qDebug("read %d %d ",sizes[0],sizes[1] ); |
1285 | } | 1285 | } |
1286 | //#endif | 1286 | //#endif |
1287 | 1287 | ||
1288 | // updateConfig(); | 1288 | // updateConfig(); |
1289 | } | 1289 | } |
1290 | 1290 | ||
1291 | void KOAgendaView::writeSettings(KConfig *config) | 1291 | void KOAgendaView::writeSettings(KConfig *config) |
1292 | { | 1292 | { |
1293 | // kdDebug() << "KOAgendaView::writeSettings()" << endl; | 1293 | // kdDebug() << "KOAgendaView::writeSettings()" << endl; |
1294 | 1294 | ||
1295 | config->setGroup("Views"); | 1295 | config->setGroup("Views"); |
1296 | 1296 | ||
1297 | //#ifndef KORG_NOSPLITTER | 1297 | //#ifndef KORG_NOSPLITTER |
1298 | QValueList<int> list = mSplitterAgenda->sizes(); | 1298 | QValueList<int> list = mSplitterAgenda->sizes(); |
1299 | config->writeEntry("Separator AgendaView",list); | 1299 | config->writeEntry("Separator AgendaView",list); |
1300 | //qDebug("write %d %d ", list[0],list[1] ); | 1300 | //qDebug("write %d %d ", list[0],list[1] ); |
1301 | //#endif | 1301 | //#endif |
1302 | } | 1302 | } |
1303 | 1303 | ||
1304 | void KOAgendaView::setHolidayMasks() | 1304 | void KOAgendaView::setHolidayMasks() |
1305 | { | 1305 | { |
1306 | mHolidayMask.resize(mSelectedDates.count()); | 1306 | mHolidayMask.resize(mSelectedDates.count()); |
1307 | 1307 | ||
1308 | uint i; | 1308 | uint i; |
1309 | for(i=0;i<mSelectedDates.count();++i) { | 1309 | for(i=0;i<mSelectedDates.count();++i) { |
1310 | QDate date = mSelectedDates[i]; | 1310 | QDate date = mSelectedDates[i]; |
1311 | bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6); | 1311 | bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6); |
1312 | bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7); | 1312 | bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7); |
1313 | bool showHoliday = false; | ||
1314 | if ( KOPrefs::instance()->mExcludeHolidays ) { | ||
1315 | QPtrList<Event> events = calendar()->events( date, true ); | ||
1316 | Event *event; | ||
1317 | for( event = events.first(); event; event = events.next() ) { | ||
1318 | if ( event->categories().contains("Holiday") || | ||
1319 | event->categories().contains(i18n("Holiday"))) { | ||
1320 | showHoliday = true; | ||
1321 | break; | ||
1322 | } | ||
1323 | } | ||
1324 | |||
1325 | } | ||
1326 | |||
1313 | #ifndef KORG_NOPLUGINS | 1327 | #ifndef KORG_NOPLUGINS |
1314 | bool showHoliday = KOPrefs::instance()->mExcludeHolidays && | 1328 | bool showHoliday = KOPrefs::instance()->mExcludeHolidays && |
1315 | !KOCore::self()->holiday(date).isEmpty(); | 1329 | !KOCore::self()->holiday(date).isEmpty(); |
1316 | bool showDay = showSaturday || showSunday || showHoliday; | ||
1317 | #else | ||
1318 | bool showDay = showSaturday || showSunday; | ||
1319 | #endif | 1330 | #endif |
1331 | bool showDay = showSaturday || showSunday || showHoliday; | ||
1332 | |||
1320 | if (showDay) { | 1333 | if (showDay) { |
1321 | mHolidayMask.at(i) = true; | 1334 | mHolidayMask.at(i) = true; |
1322 | } else { | 1335 | } else { |
1323 | mHolidayMask.at(i) = false; | 1336 | mHolidayMask.at(i) = false; |
1324 | } | 1337 | } |
1325 | } | 1338 | } |
1326 | 1339 | ||
1327 | mAgenda->setHolidayMask(&mHolidayMask); | 1340 | mAgenda->setHolidayMask(&mHolidayMask); |
1328 | mAllDayAgenda->setHolidayMask(&mHolidayMask); | 1341 | mAllDayAgenda->setHolidayMask(&mHolidayMask); |
1329 | } | 1342 | } |
1330 | 1343 | ||
1331 | void KOAgendaView::setContentsPos(int y) | 1344 | void KOAgendaView::setContentsPos(int y) |
1332 | { | 1345 | { |
1333 | mAgenda->setContentsPos(0,y); | 1346 | mAgenda->setContentsPos(0,y); |
1334 | } | 1347 | } |
1335 | 1348 | ||
1336 | void KOAgendaView::setExpandedButton( bool expanded ) | 1349 | void KOAgendaView::setExpandedButton( bool expanded ) |
1337 | { | 1350 | { |
1338 | if ( expanded ) { | 1351 | if ( expanded ) { |
1339 | mExpandButton->setPixmap( mExpandedPixmap ); | 1352 | mExpandButton->setPixmap( mExpandedPixmap ); |
1340 | } else { | 1353 | } else { |
1341 | mExpandButton->setPixmap( mNotExpandedPixmap ); | 1354 | mExpandButton->setPixmap( mNotExpandedPixmap ); |
1342 | } | 1355 | } |
1343 | } | 1356 | } |
1344 | 1357 | ||
1345 | void KOAgendaView::clearSelection() | 1358 | void KOAgendaView::clearSelection() |
1346 | { | 1359 | { |
1347 | mAgenda->deselectItem(); | 1360 | mAgenda->deselectItem(); |
1348 | mAllDayAgenda->deselectItem(); | 1361 | mAllDayAgenda->deselectItem(); |
1349 | } | 1362 | } |
1350 | 1363 | ||
1351 | void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart, | 1364 | void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart, |
1352 | int gxEnd, int gyEnd) | 1365 | int gxEnd, int gyEnd) |
1353 | { | 1366 | { |
1354 | mTimeSpanInAllDay = true; | 1367 | mTimeSpanInAllDay = true; |
1355 | newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd); | 1368 | newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd); |
1356 | } | 1369 | } |
1357 | 1370 | ||
1358 | 1371 | ||
1359 | 1372 | ||
1360 | 1373 | ||
1361 | void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart, | 1374 | void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart, |
1362 | int gxEnd, int gyEnd) | 1375 | int gxEnd, int gyEnd) |
1363 | { | 1376 | { |
1364 | if (!mSelectedDates.count()) return; | 1377 | if (!mSelectedDates.count()) return; |
1365 | 1378 | ||
1366 | QDate dayStart = mSelectedDates[gxStart]; | 1379 | QDate dayStart = mSelectedDates[gxStart]; |
1367 | QDate dayEnd = mSelectedDates[gxEnd]; | 1380 | QDate dayEnd = mSelectedDates[gxEnd]; |
1368 | 1381 | ||
1369 | QTime timeStart = mAgenda->gyToTime(gyStart); | 1382 | QTime timeStart = mAgenda->gyToTime(gyStart); |
1370 | QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); | 1383 | QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); |
1371 | 1384 | ||
1372 | QDateTime dtStart(dayStart,timeStart); | 1385 | QDateTime dtStart(dayStart,timeStart); |
1373 | QDateTime dtEnd(dayEnd,timeEnd); | 1386 | QDateTime dtEnd(dayEnd,timeEnd); |
1374 | 1387 | ||
1375 | mTimeSpanBegin = dtStart; | 1388 | mTimeSpanBegin = dtStart; |
1376 | mTimeSpanEnd = dtEnd; | 1389 | mTimeSpanEnd = dtEnd; |
1377 | 1390 | ||
1378 | } | 1391 | } |
1379 | 1392 | ||
1380 | void KOAgendaView::deleteSelectedDateTime() | 1393 | void KOAgendaView::deleteSelectedDateTime() |
1381 | { | 1394 | { |
1382 | mTimeSpanBegin.setDate(QDate()); | 1395 | mTimeSpanBegin.setDate(QDate()); |
1383 | mTimeSpanEnd.setDate(QDate()); | 1396 | mTimeSpanEnd.setDate(QDate()); |
1384 | mTimeSpanInAllDay = false; | 1397 | mTimeSpanInAllDay = false; |
1385 | } | 1398 | } |
1386 | 1399 | ||
1387 | void KOAgendaView::keyPressEvent ( QKeyEvent * e ) | 1400 | void KOAgendaView::keyPressEvent ( QKeyEvent * e ) |
1388 | { | 1401 | { |
1389 | e->ignore(); | 1402 | e->ignore(); |
1390 | } | 1403 | } |
1391 | 1404 | ||
1392 | void KOAgendaView::scrollOneHourUp() | 1405 | void KOAgendaView::scrollOneHourUp() |
1393 | { | 1406 | { |
1394 | 1407 | ||
1395 | mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 ); | 1408 | mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 ); |
1396 | } | 1409 | } |
1397 | void KOAgendaView::scrollOneHourDown() | 1410 | void KOAgendaView::scrollOneHourDown() |
1398 | { | 1411 | { |
1399 | mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 ); | 1412 | mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 ); |
1400 | } | 1413 | } |
1401 | 1414 | ||
1402 | void KOAgendaView::setStartHour( int h ) | 1415 | void KOAgendaView::setStartHour( int h ) |
1403 | { | 1416 | { |
1404 | mAgenda->setStartHour( h ); | 1417 | mAgenda->setStartHour( h ); |
1405 | 1418 | ||
1406 | } | 1419 | } |
1407 | 1420 | ||
1408 | void KOAgendaView::updateTodo( Todo * t, int ) | 1421 | void KOAgendaView::updateTodo( Todo * t, int ) |
1409 | { | 1422 | { |
1410 | 1423 | ||
1411 | bool remove = false; | 1424 | bool remove = false; |
1412 | bool removeAD = false; | 1425 | bool removeAD = false; |
1413 | if ( ! t->hasDueDate() ) { | 1426 | if ( ! t->hasDueDate() ) { |
1414 | remove = true; | 1427 | remove = true; |
1415 | removeAD = true; | 1428 | removeAD = true; |
1416 | } | 1429 | } |
1417 | else { | 1430 | else { |
1418 | bool overdue = (!t->isCompleted()) && (t->dtDue() < QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ; | 1431 | bool overdue = (!t->isCompleted()) && (t->dtDue() < QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ; |
1419 | if ( overdue && | 1432 | if ( overdue && |
1420 | QDate::currentDate() >= mSelectedDates.first() && | 1433 | QDate::currentDate() >= mSelectedDates.first() && |
1421 | QDate::currentDate() <= mSelectedDates.last()) { | 1434 | QDate::currentDate() <= mSelectedDates.last()) { |
1422 | removeAD = false; | 1435 | removeAD = false; |
1423 | remove = true; | 1436 | remove = true; |
1424 | } | 1437 | } |
1425 | else { | 1438 | else { |
1426 | if ( t->dtDue().date() < mSelectedDates.first() || | 1439 | if ( t->dtDue().date() < mSelectedDates.first() || |
1427 | t->dtDue().date() > mSelectedDates.last() ) { | 1440 | t->dtDue().date() > mSelectedDates.last() ) { |
1428 | remove = true; | 1441 | remove = true; |
1429 | removeAD = true; | 1442 | removeAD = true; |
1430 | } else { | 1443 | } else { |
1431 | remove = t->doesFloat(); | 1444 | remove = t->doesFloat(); |
1432 | removeAD = !remove; | 1445 | removeAD = !remove; |
1433 | } | 1446 | } |
1434 | } | 1447 | } |
1435 | } | 1448 | } |
1436 | int days = mSelectedDates.first().daysTo( t->dtDue().date() ); | 1449 | int days = mSelectedDates.first().daysTo( t->dtDue().date() ); |
1437 | // qDebug("daysto %d ", days ); | 1450 | // qDebug("daysto %d ", days ); |
1438 | mAgenda->updateTodo( t , days, remove); | 1451 | mAgenda->updateTodo( t , days, remove); |
1439 | if ( KOPrefs::instance()->mShowTodoInAgenda ) | 1452 | if ( KOPrefs::instance()->mShowTodoInAgenda ) |
1440 | mAllDayAgenda->updateTodo( t , days, removeAD); | 1453 | mAllDayAgenda->updateTodo( t , days, removeAD); |
1441 | //qDebug("KOAgendaView::updateTodo( Todo *, int ) "); | 1454 | //qDebug("KOAgendaView::updateTodo( Todo *, int ) "); |
1442 | 1455 | ||
1443 | } | 1456 | } |
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index 688d9e1..7d1e82f 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp | |||
@@ -260,257 +260,257 @@ MonthViewCell::MonthViewCell( KOMonthView *parent) | |||
260 | : QWidget( parent ), | 260 | : QWidget( parent ), |
261 | mMonthView( parent ) | 261 | mMonthView( parent ) |
262 | { | 262 | { |
263 | 263 | ||
264 | QVBoxLayout *topLayout = new QVBoxLayout( this ); | 264 | QVBoxLayout *topLayout = new QVBoxLayout( this ); |
265 | 265 | ||
266 | // mLabel = new QLabel( this );QPushButton | 266 | // mLabel = new QLabel( this );QPushButton |
267 | mLabel = new QPushButton( this ); | 267 | mLabel = new QPushButton( this ); |
268 | //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); | 268 | //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); |
269 | //mLabel->setLineWidth( 1 ); | 269 | //mLabel->setLineWidth( 1 ); |
270 | //mLabel->setAlignment( AlignCenter ); | 270 | //mLabel->setAlignment( AlignCenter ); |
271 | mLabel->setFlat( true ); | 271 | mLabel->setFlat( true ); |
272 | mItemList = new KNoScrollListBox( this ); | 272 | mItemList = new KNoScrollListBox( this ); |
273 | mItemList->setMinimumSize( 10, 10 ); | 273 | mItemList->setMinimumSize( 10, 10 ); |
274 | mItemList->setFrameStyle( QFrame::Panel | QFrame::Plain ); | 274 | mItemList->setFrameStyle( QFrame::Panel | QFrame::Plain ); |
275 | mItemList->setLineWidth( 1 ); | 275 | mItemList->setLineWidth( 1 ); |
276 | topLayout->addWidget( mItemList ); | 276 | topLayout->addWidget( mItemList ); |
277 | mLabel->raise(); | 277 | mLabel->raise(); |
278 | // QColor( 0,0,255 ) QColor( 160,1600,255 ) | 278 | // QColor( 0,0,255 ) QColor( 160,1600,255 ) |
279 | mStandardPalette = palette(); | 279 | mStandardPalette = palette(); |
280 | mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); | 280 | mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); |
281 | 281 | ||
282 | enableScrollBars( false ); | 282 | enableScrollBars( false ); |
283 | updateConfig(); | 283 | updateConfig(); |
284 | connect( mLabel, SIGNAL( clicked( )), | 284 | connect( mLabel, SIGNAL( clicked( )), |
285 | SLOT( newEvent() )); | 285 | SLOT( newEvent() )); |
286 | connect( mItemList, SIGNAL( doubleClicked( QListBoxItem *) ), | 286 | connect( mItemList, SIGNAL( doubleClicked( QListBoxItem *) ), |
287 | SLOT( defaultAction( QListBoxItem * ) ) ); | 287 | SLOT( defaultAction( QListBoxItem * ) ) ); |
288 | connect( mItemList, SIGNAL( rightButtonPressed( QListBoxItem *, | 288 | connect( mItemList, SIGNAL( rightButtonPressed( QListBoxItem *, |
289 | const QPoint &) ), | 289 | const QPoint &) ), |
290 | SLOT( contextMenu( QListBoxItem * ) ) ); | 290 | SLOT( contextMenu( QListBoxItem * ) ) ); |
291 | connect( mItemList, SIGNAL( highlighted( QListBoxItem *) ), | 291 | connect( mItemList, SIGNAL( highlighted( QListBoxItem *) ), |
292 | SLOT( selection( QListBoxItem * ) ) ); | 292 | SLOT( selection( QListBoxItem * ) ) ); |
293 | connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), | 293 | connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), |
294 | SLOT( cellClicked( QListBoxItem * ) ) ); | 294 | SLOT( cellClicked( QListBoxItem * ) ) ); |
295 | connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), | 295 | connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), |
296 | SLOT( selection( QListBoxItem * ) ) ); | 296 | SLOT( selection( QListBoxItem * ) ) ); |
297 | } | 297 | } |
298 | 298 | ||
299 | void MonthViewCell::setDate( const QDate &date ) | 299 | void MonthViewCell::setDate( const QDate &date ) |
300 | { | 300 | { |
301 | // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; | 301 | // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; |
302 | 302 | ||
303 | mDate = date; | 303 | mDate = date; |
304 | 304 | ||
305 | QString text; | 305 | QString text; |
306 | bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; | 306 | bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; |
307 | if ( KOGlobals::self()->calendarSystem()->day( date ) == 1 || (date.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { | 307 | if ( KOGlobals::self()->calendarSystem()->day( date ) == 1 || (date.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { |
308 | text = KOGlobals::self()->calendarSystem()->monthName( date, true ) + " "; | 308 | text = KOGlobals::self()->calendarSystem()->monthName( date, true ) + " "; |
309 | mLabel->resize( mLabelBigSize ); | 309 | mLabel->resize( mLabelBigSize ); |
310 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); | 310 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); |
311 | } else { | 311 | } else { |
312 | mLabel->resize( mLabelSize ); | 312 | mLabel->resize( mLabelSize ); |
313 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); | 313 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); |
314 | } | 314 | } |
315 | mLabel->setText( text ); | 315 | mLabel->setText( text ); |
316 | 316 | ||
317 | //resizeEvent( 0 ); | 317 | //resizeEvent( 0 ); |
318 | } | 318 | } |
319 | 319 | ||
320 | QDate MonthViewCell::date() const | 320 | QDate MonthViewCell::date() const |
321 | { | 321 | { |
322 | return mDate; | 322 | return mDate; |
323 | } | 323 | } |
324 | 324 | ||
325 | void MonthViewCell::setPrimary( bool primary ) | 325 | void MonthViewCell::setPrimary( bool primary ) |
326 | { | 326 | { |
327 | mPrimary = primary; | 327 | mPrimary = primary; |
328 | //setMyPalette(); | 328 | //setMyPalette(); |
329 | } | 329 | } |
330 | void MonthViewCell::setMyPalette() | 330 | void MonthViewCell::setMyPalette() |
331 | { | 331 | { |
332 | 332 | ||
333 | if ( mHoliday) { | 333 | if ( mHoliday) { |
334 | setPalette( mHolidayPalette ); | 334 | setPalette( mHolidayPalette ); |
335 | } else { | 335 | } else { |
336 | if ( mPrimary ) { | 336 | if ( mPrimary ) { |
337 | setPalette( mPrimaryPalette ); | 337 | setPalette( mPrimaryPalette ); |
338 | } else { | 338 | } else { |
339 | setPalette( mNonPrimaryPalette ); | 339 | setPalette( mNonPrimaryPalette ); |
340 | } | 340 | } |
341 | } | 341 | } |
342 | QPalette pal = palette(); | 342 | QPalette pal = palette(); |
343 | 343 | ||
344 | mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); | 344 | mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); |
345 | } | 345 | } |
346 | QPalette MonthViewCell::getPalette () | 346 | QPalette MonthViewCell::getPalette () |
347 | { | 347 | { |
348 | if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) | 348 | if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) |
349 | return mStandardPalette; | 349 | return mStandardPalette; |
350 | if ( mHoliday) { | 350 | if ( mHoliday) { |
351 | return mHolidayPalette ; | 351 | return mHolidayPalette ; |
352 | } else { | 352 | } else { |
353 | if ( mPrimary ) { | 353 | if ( mPrimary ) { |
354 | return mPrimaryPalette ; | 354 | return mPrimaryPalette ; |
355 | } | 355 | } |
356 | } | 356 | } |
357 | return mNonPrimaryPalette; | 357 | return mNonPrimaryPalette; |
358 | } | 358 | } |
359 | bool MonthViewCell::isPrimary() const | 359 | bool MonthViewCell::isPrimary() const |
360 | { | 360 | { |
361 | return mPrimary; | 361 | return mPrimary; |
362 | } | 362 | } |
363 | 363 | ||
364 | void MonthViewCell::setHoliday( bool holiday ) | 364 | void MonthViewCell::setHoliday( bool holiday ) |
365 | { | 365 | { |
366 | mHoliday = holiday; | 366 | mHoliday = holiday; |
367 | //setMyPalette(); | 367 | //setMyPalette(); |
368 | } | 368 | } |
369 | 369 | ||
370 | void MonthViewCell::setHoliday( const QString &holiday ) | 370 | void MonthViewCell::setHoliday( const QString &holiday ) |
371 | { | 371 | { |
372 | mHolidayString = holiday; | 372 | mHolidayString = holiday; |
373 | 373 | ||
374 | if ( !holiday.isEmpty() ) { | 374 | if ( !holiday.isEmpty() ) { |
375 | setHoliday( true ); | 375 | setHoliday( true ); |
376 | } | 376 | } |
377 | } | 377 | } |
378 | void MonthViewCell::keyPressEvent ( QKeyEvent * e ) | 378 | void MonthViewCell::keyPressEvent ( QKeyEvent * e ) |
379 | { | 379 | { |
380 | 380 | ||
381 | e->ignore(); | 381 | e->ignore(); |
382 | 382 | ||
383 | } | 383 | } |
384 | void MonthViewCell::updateCell() | 384 | void MonthViewCell::updateCell() |
385 | { | 385 | { |
386 | 386 | ||
387 | setPrimary( mDate.month()%2 ); | 387 | setPrimary( mDate.month()%2 ); |
388 | setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() ); | 388 | setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); |
389 | if ( mDate == QDate::currentDate() ) { | 389 | if ( mDate == QDate::currentDate() ) { |
390 | mItemList->setLineWidth( 3 ); | 390 | mItemList->setLineWidth( 3 ); |
391 | } else { | 391 | } else { |
392 | mItemList->setLineWidth( 1 ); | 392 | mItemList->setLineWidth( 1 ); |
393 | } | 393 | } |
394 | mItemList->clear(); | 394 | mItemList->clear(); |
395 | //qApp->processEvents(); | 395 | //qApp->processEvents(); |
396 | if ( !mHolidayString.isEmpty() ) { | 396 | if ( !mHolidayString.isEmpty() ) { |
397 | MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); | 397 | MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); |
398 | item->setPalette( mHolidayPalette ); | 398 | item->setPalette( mHolidayPalette ); |
399 | mItemList->insertItem( item ); | 399 | mItemList->insertItem( item ); |
400 | } | 400 | } |
401 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); | 401 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); |
402 | QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); | 402 | QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); |
403 | Event *event; | 403 | Event *event; |
404 | for( event = events.first(); event; event = events.next() ) { | 404 | for( event = events.first(); event; event = events.next() ) { |
405 | if ( event->categories().contains("Holiday") || | 405 | if ( event->categories().contains("Holiday") || |
406 | event->categories().contains(i18n("Holiday"))) { | 406 | event->categories().contains(i18n("Holiday"))) { |
407 | setHoliday( true ); | 407 | setHoliday( true ); |
408 | if ( mDate.dayOfWeek() == 7 ) | 408 | if ( mDate.dayOfWeek() == 7 ) |
409 | mItemList->setLineWidth( 3 ); | 409 | mItemList->setLineWidth( 3 ); |
410 | } | 410 | } |
411 | QString text; | 411 | QString text; |
412 | if (event->isMultiDay()) { | 412 | if (event->isMultiDay()) { |
413 | QString prefix = "<->"; | 413 | QString prefix = "<->"; |
414 | if ( event->doesRecur() ) { | 414 | if ( event->doesRecur() ) { |
415 | if ( event->recursOn( mDate) ) | 415 | if ( event->recursOn( mDate) ) |
416 | prefix ="->" ; | 416 | prefix ="->" ; |
417 | else { | 417 | else { |
418 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); | 418 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); |
419 | if ( event->recursOn( mDate.addDays( -days)) ) | 419 | if ( event->recursOn( mDate.addDays( -days)) ) |
420 | prefix ="<-" ; | 420 | prefix ="<-" ; |
421 | } | 421 | } |
422 | 422 | ||
423 | } else { | 423 | } else { |
424 | if (mDate == event->dtStart().date()) { | 424 | if (mDate == event->dtStart().date()) { |
425 | prefix ="->" ; | 425 | prefix ="->" ; |
426 | } else if (mDate == event->dtEnd().date()) { | 426 | } else if (mDate == event->dtEnd().date()) { |
427 | prefix ="<-" ; | 427 | prefix ="<-" ; |
428 | } | 428 | } |
429 | } | 429 | } |
430 | text = prefix + event->summary(); | 430 | text = prefix + event->summary(); |
431 | } else { | 431 | } else { |
432 | if (event->doesFloat()) | 432 | if (event->doesFloat()) |
433 | text = event->summary(); | 433 | text = event->summary(); |
434 | else { | 434 | else { |
435 | text = KGlobal::locale()->formatTime(event->dtStart().time()); | 435 | text = KGlobal::locale()->formatTime(event->dtStart().time()); |
436 | text += " " + event->summary(); | 436 | text += " " + event->summary(); |
437 | } | 437 | } |
438 | } | 438 | } |
439 | 439 | ||
440 | MonthViewItem *item = new MonthViewItem( event, mDate, text ); | 440 | MonthViewItem *item = new MonthViewItem( event, mDate, text ); |
441 | QPalette pal; | 441 | QPalette pal; |
442 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { | 442 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { |
443 | QStringList categories = event->categories(); | 443 | QStringList categories = event->categories(); |
444 | QString cat = categories.first(); | 444 | QString cat = categories.first(); |
445 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { | 445 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { |
446 | pal = getPalette(); | 446 | pal = getPalette(); |
447 | if (cat.isEmpty()) { | 447 | if (cat.isEmpty()) { |
448 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); | 448 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); |
449 | } else { | 449 | } else { |
450 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); | 450 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); |
451 | } | 451 | } |
452 | 452 | ||
453 | } else { | 453 | } else { |
454 | if (cat.isEmpty()) { | 454 | if (cat.isEmpty()) { |
455 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); | 455 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); |
456 | } else { | 456 | } else { |
457 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); | 457 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); |
458 | } | 458 | } |
459 | } | 459 | } |
460 | 460 | ||
461 | } else { | 461 | } else { |
462 | pal = mStandardPalette ; | 462 | pal = mStandardPalette ; |
463 | } | 463 | } |
464 | item->setPalette( pal ); | 464 | item->setPalette( pal ); |
465 | item->setRecur( event->recurrence()->doesRecur() ); | 465 | item->setRecur( event->recurrence()->doesRecur() ); |
466 | item->setAlarm( event->isAlarmEnabled() ); | 466 | item->setAlarm( event->isAlarmEnabled() ); |
467 | item->setMoreInfo( event->description().length() > 0 ); | 467 | item->setMoreInfo( event->description().length() > 0 ); |
468 | Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, | 468 | Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, |
469 | KOPrefs::instance()->email()); | 469 | KOPrefs::instance()->email()); |
470 | if ( me != 0 ) { | 470 | if ( me != 0 ) { |
471 | if ( me->status() == Attendee::NeedsAction && me->RSVP()) | 471 | if ( me->status() == Attendee::NeedsAction && me->RSVP()) |
472 | item->setReply(true); | 472 | item->setReply(true); |
473 | else | 473 | else |
474 | item->setReply(false); | 474 | item->setReply(false); |
475 | } else | 475 | } else |
476 | item->setReply(false); | 476 | item->setReply(false); |
477 | bool insert = true; | 477 | bool insert = true; |
478 | if ( !(event->doesRecur() == Recurrence::rNone) ) { | 478 | if ( !(event->doesRecur() == Recurrence::rNone) ) { |
479 | if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) | 479 | if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) |
480 | insert = false; | 480 | insert = false; |
481 | else | 481 | else |
482 | if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) | 482 | if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) |
483 | insert = false; | 483 | insert = false; |
484 | 484 | ||
485 | } | 485 | } |
486 | if ( insert ) | 486 | if ( insert ) |
487 | mItemList->insertItem( item ); | 487 | mItemList->insertItem( item ); |
488 | } | 488 | } |
489 | 489 | ||
490 | // insert due todos | 490 | // insert due todos |
491 | QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); | 491 | QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); |
492 | Todo *todo; | 492 | Todo *todo; |
493 | for(todo = todos.first(); todo; todo = todos.next()) { | 493 | for(todo = todos.first(); todo; todo = todos.next()) { |
494 | QString text; | 494 | QString text; |
495 | if (todo->hasDueDate()) { | 495 | if (todo->hasDueDate()) { |
496 | if (!todo->doesFloat()) { | 496 | if (!todo->doesFloat()) { |
497 | text += KGlobal::locale()->formatTime(todo->dtDue().time()); | 497 | text += KGlobal::locale()->formatTime(todo->dtDue().time()); |
498 | text += " "; | 498 | text += " "; |
499 | } | 499 | } |
500 | } | 500 | } |
501 | text += i18n("To-Do: %1").arg(todo->summary()); | 501 | text += i18n("To-Do: %1").arg(todo->summary()); |
502 | 502 | ||
503 | MonthViewItem *item = new MonthViewItem( todo, mDate, text ); | 503 | MonthViewItem *item = new MonthViewItem( todo, mDate, text ); |
504 | //item->setPalette( mStandardPalette ); | 504 | //item->setPalette( mStandardPalette ); |
505 | QPalette pal; | 505 | QPalette pal; |
506 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { | 506 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { |
507 | QStringList categories = todo->categories(); | 507 | QStringList categories = todo->categories(); |
508 | QString cat = categories.first(); | 508 | QString cat = categories.first(); |
509 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { | 509 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { |
510 | pal = getPalette(); | 510 | pal = getPalette(); |
511 | if (cat.isEmpty()) { | 511 | if (cat.isEmpty()) { |
512 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); | 512 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); |
513 | } else { | 513 | } else { |
514 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); | 514 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); |
515 | } | 515 | } |
516 | 516 | ||