summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2004-10-29 22:27:13 (UTC)
committer zautrix <zautrix>2004-10-29 22:27:13 (UTC)
commitaafa695508796e86e9f267633ea5e6965d876031 (patch) (unidiff)
tree8ff03f51e99f7e90b85e8f94af157a883bcd48f8 /korganizer
parent8e08679a79398def54980c0e838b242d69ca6030 (diff)
downloadkdepimpi-aafa695508796e86e9f267633ea5e6965d876031.zip
kdepimpi-aafa695508796e86e9f267633ea5e6965d876031.tar.gz
kdepimpi-aafa695508796e86e9f267633ea5e6965d876031.tar.bz2
monthview exclude sat fix
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagendaview.cpp19
-rw-r--r--korganizer/komonthview.cpp2
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
@@ -1057,387 +1057,400 @@ void KOAgendaView::fillAgenda()
1057 } 1057 }
1058 } 1058 }
1059 int startY = mAgenda->timeToY(event->dtStart().time()); 1059 int startY = mAgenda->timeToY(event->dtStart().time());
1060 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; 1060 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
1061 //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); 1061 //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol );
1062 if ((beginX <= 0 && curCol == 0) || beginX == curCol) { 1062 if ((beginX <= 0 && curCol == 0) || beginX == curCol) {
1063 //qDebug("insert!!! "); 1063 //qDebug("insert!!! ");
1064 mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); 1064 mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY);
1065 } 1065 }
1066 if (beginX == curCol) { 1066 if (beginX == curCol) {
1067 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); 1067 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59));
1068 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1068 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1069 } else if (endX == curCol) { 1069 } else if (endX == curCol) {
1070 mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); 1070 mMinY[curCol] = mAgenda->timeToY(QTime(0,0));
1071 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1071 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1072 } else { 1072 } else {
1073 mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); 1073 mMinY[curCol] = mAgenda->timeToY(QTime(0,0));
1074 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); 1074 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59));
1075 } 1075 }
1076 } else { 1076 } else {
1077 int startY = mAgenda->timeToY(event->dtStart().time()); 1077 int startY = mAgenda->timeToY(event->dtStart().time());
1078 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; 1078 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
1079 if (endY < startY) endY = startY; 1079 if (endY < startY) endY = startY;
1080 mAgenda->insertItem(event,currentDate,curCol,startY,endY); 1080 mAgenda->insertItem(event,currentDate,curCol,startY,endY);
1081 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1081 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1082 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1082 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1083 } 1083 }
1084 } 1084 }
1085 // ---------- [display Todos -------------- 1085 // ---------- [display Todos --------------
1086 unsigned int numTodo; 1086 unsigned int numTodo;
1087 for (numTodo = 0; numTodo < todos.count(); ++numTodo) { 1087 for (numTodo = 0; numTodo < todos.count(); ++numTodo) {
1088 Todo *todo = todos.at(numTodo); 1088 Todo *todo = todos.at(numTodo);
1089 1089
1090 if ( ! todo->hasDueDate() ) continue; // todo shall not be displayed if it has no date 1090 if ( ! todo->hasDueDate() ) continue; // todo shall not be displayed if it has no date
1091 1091
1092 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. 1092 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue.
1093 // Already completed items can be displayed on their original due date 1093 // Already completed items can be displayed on their original due date
1094 //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda 1094 //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda
1095 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; 1095 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda;
1096 1096
1097 if ( ((todo->dtDue().date() == currentDate) && !overdue) || 1097 if ( ((todo->dtDue().date() == currentDate) && !overdue) ||
1098 ((currentDate == today) && overdue) ) { 1098 ((currentDate == today) && overdue) ) {
1099 if ( todo->doesFloat() || overdue ) { // Todo has no due-time set or is already overdue 1099 if ( todo->doesFloat() || overdue ) { // Todo has no due-time set or is already overdue
1100 if ( KOPrefs::instance()->mShowTodoInAgenda ) 1100 if ( KOPrefs::instance()->mShowTodoInAgenda )
1101 mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); 1101 mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol);
1102 } 1102 }
1103 else { 1103 else {
1104 1104
1105 int endY = mAgenda->timeToY(todo->dtDue().time()) - 1; 1105 int endY = mAgenda->timeToY(todo->dtDue().time()) - 1;
1106 int hi = (18/KOPrefs::instance()->mHourSize); 1106 int hi = (18/KOPrefs::instance()->mHourSize);
1107 //qDebug("hei %d ",KOPrefs::instance()->mHourSize); 1107 //qDebug("hei %d ",KOPrefs::instance()->mHourSize);
1108 int startY = endY -hi; 1108 int startY = endY -hi;
1109 1109
1110 mAgenda->insertItem(todo,currentDate,curCol,startY,endY); 1110 mAgenda->insertItem(todo,currentDate,curCol,startY,endY);
1111 1111
1112 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1112 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1113 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1113 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1114 } 1114 }
1115 } 1115 }
1116 } 1116 }
1117 // ---------- display Todos] -------------- 1117 // ---------- display Todos] --------------
1118 1118
1119 ++curCol; 1119 ++curCol;
1120 } 1120 }
1121 mAgenda->hideUnused(); 1121 mAgenda->hideUnused();
1122 mAllDayAgenda->hideUnused(); 1122 mAllDayAgenda->hideUnused();
1123 mAgenda->checkScrollBoundaries(); 1123 mAgenda->checkScrollBoundaries();
1124 1124
1125 deleteSelectedDateTime(); 1125 deleteSelectedDateTime();
1126 1126
1127 createDayLabels(); 1127 createDayLabels();
1128 emit incidenceSelected( 0 ); 1128 emit incidenceSelected( 0 );
1129 1129
1130 if ( globalFlagBlockAgenda == 2 ) { 1130 if ( globalFlagBlockAgenda == 2 ) {
1131 if ( KOPrefs::instance()->mSetTimeToDayStartAt ) 1131 if ( KOPrefs::instance()->mSetTimeToDayStartAt )
1132 setStartHour( KOPrefs::instance()->mDayBegins ); 1132 setStartHour( KOPrefs::instance()->mDayBegins );
1133 else if ( KOPrefs::instance()->mCenterOnCurrentTime ) 1133 else if ( KOPrefs::instance()->mCenterOnCurrentTime )
1134 setStartHour( QTime::currentTime ().hour() ); 1134 setStartHour( QTime::currentTime ().hour() );
1135 // qApp->processEvents(); 1135 // qApp->processEvents();
1136 } 1136 }
1137 qApp->processEvents(); 1137 qApp->processEvents();
1138 //qDebug("qApp->processEvents(); END "); 1138 //qDebug("qApp->processEvents(); END ");
1139 globalFlagBlockAgenda = 0; 1139 globalFlagBlockAgenda = 0;
1140 1140
1141 // mAgenda->hideUnused(); 1141 // mAgenda->hideUnused();
1142 //mAllDayAgenda->hideUnused(); 1142 //mAllDayAgenda->hideUnused();
1143 mAllDayAgenda->drawContentsToPainter(); 1143 mAllDayAgenda->drawContentsToPainter();
1144 mAgenda->drawContentsToPainter(); 1144 mAgenda->drawContentsToPainter();
1145 repaintAgenda(); 1145 repaintAgenda();
1146 // mAgenda->finishUpdate(); 1146 // mAgenda->finishUpdate();
1147 //mAllDayAgenda->finishUpdate(); 1147 //mAllDayAgenda->finishUpdate();
1148 1148
1149 // repaintAgenda(); 1149 // repaintAgenda();
1150 //qApp->processEvents(); 1150 //qApp->processEvents();
1151 // globalFlagBlockAgenda = 0; 1151 // globalFlagBlockAgenda = 0;
1152} 1152}
1153void KOAgendaView::repaintAgenda() 1153void KOAgendaView::repaintAgenda()
1154{ 1154{
1155 // mAllDayAgenda->drawContentsToPainter(); 1155 // mAllDayAgenda->drawContentsToPainter();
1156// mAllDayAgenda->viewport()->repaint( false ); 1156// mAllDayAgenda->viewport()->repaint( false );
1157// mAgenda->drawContentsToPainter(); 1157// mAgenda->drawContentsToPainter();
1158// mAgenda->viewport()->repaint( false ); 1158// mAgenda->viewport()->repaint( false );
1159// qApp->processEvents(); 1159// qApp->processEvents();
1160 1160
1161 //qDebug("KOAgendaView::repaintAgenda() "); 1161 //qDebug("KOAgendaView::repaintAgenda() ");
1162 //qApp->processEvents(); 1162 //qApp->processEvents();
1163 mAgenda->viewport()->repaint( false ); 1163 mAgenda->viewport()->repaint( false );
1164 mAllDayAgenda->viewport()->repaint( false ); 1164 mAllDayAgenda->viewport()->repaint( false );
1165 mAgenda->finishUpdate(); 1165 mAgenda->finishUpdate();
1166 mAllDayAgenda->finishUpdate(); 1166 mAllDayAgenda->finishUpdate();
1167} 1167}
1168 1168
1169 1169
1170void KOAgendaView::clearView() 1170void KOAgendaView::clearView()
1171{ 1171{
1172 // kdDebug() << "ClearView" << endl; 1172 // kdDebug() << "ClearView" << endl;
1173 mAllDayAgenda->clear(); 1173 mAllDayAgenda->clear();
1174 mAgenda->clear(); 1174 mAgenda->clear();
1175} 1175}
1176 1176
1177void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd, 1177void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd,
1178 const QDate &td) 1178 const QDate &td)
1179{ 1179{
1180#ifndef KORG_NOPRINTER 1180#ifndef KORG_NOPRINTER
1181 if (fd == td) 1181 if (fd == td)
1182 calPrinter->preview(CalPrinter::Day, fd, td); 1182 calPrinter->preview(CalPrinter::Day, fd, td);
1183 else 1183 else
1184 calPrinter->preview(CalPrinter::Week, fd, td); 1184 calPrinter->preview(CalPrinter::Week, fd, td);
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
1194void KOAgendaView::newEvent(int gx, int gy) 1194void 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
1207void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd) 1207void 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
1223void KOAgendaView::newEventAllDay(int gx, int ) 1223void 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
1232void KOAgendaView::updateEventIndicatorTop(int newY) 1232void 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
1243void KOAgendaView::updateEventIndicatorBottom(int newY) 1243void 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
1254void KOAgendaView::startDrag(Event *event) 1254void 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
1265void KOAgendaView::readSettings() 1265void KOAgendaView::readSettings()
1266{ 1266{
1267 readSettings(KOGlobals::config()); 1267 readSettings(KOGlobals::config());
1268} 1268}
1269 1269
1270void KOAgendaView::readSettings(KConfig *config) 1270void 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
1291void KOAgendaView::writeSettings(KConfig *config) 1291void 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
1304void KOAgendaView::setHolidayMasks() 1304void 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
1331void KOAgendaView::setContentsPos(int y) 1344void KOAgendaView::setContentsPos(int y)
1332{ 1345{
1333 mAgenda->setContentsPos(0,y); 1346 mAgenda->setContentsPos(0,y);
1334} 1347}
1335 1348
1336void KOAgendaView::setExpandedButton( bool expanded ) 1349void 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
1345void KOAgendaView::clearSelection() 1358void KOAgendaView::clearSelection()
1346{ 1359{
1347 mAgenda->deselectItem(); 1360 mAgenda->deselectItem();
1348 mAllDayAgenda->deselectItem(); 1361 mAllDayAgenda->deselectItem();
1349} 1362}
1350 1363
1351void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart, 1364void 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
1361void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart, 1374void 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
1380void KOAgendaView::deleteSelectedDateTime() 1393void 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
1387void KOAgendaView::keyPressEvent ( QKeyEvent * e ) 1400void KOAgendaView::keyPressEvent ( QKeyEvent * e )
1388{ 1401{
1389 e->ignore(); 1402 e->ignore();
1390} 1403}
1391 1404
1392void KOAgendaView::scrollOneHourUp() 1405void KOAgendaView::scrollOneHourUp()
1393{ 1406{
1394 1407
1395 mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 ); 1408 mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 );
1396} 1409}
1397void KOAgendaView::scrollOneHourDown() 1410void KOAgendaView::scrollOneHourDown()
1398{ 1411{
1399 mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 ); 1412 mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 );
1400} 1413}
1401 1414
1402void KOAgendaView::setStartHour( int h ) 1415void KOAgendaView::setStartHour( int h )
1403{ 1416{
1404 mAgenda->setStartHour( h ); 1417 mAgenda->setStartHour( h );
1405 1418
1406} 1419}
1407 1420
1408void KOAgendaView::updateTodo( Todo * t, int ) 1421void 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
@@ -132,513 +132,513 @@ void KNoScrollListBox::keyPressEvent(QKeyEvent *e)
132 break; 132 break;
133 case Key_Shift: 133 case Key_Shift:
134 emit shiftDown(); 134 emit shiftDown();
135 break; 135 break;
136 default: 136 default:
137 e->ignore(); 137 e->ignore();
138 break; 138 break;
139 } 139 }
140} 140}
141 141
142void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) 142void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e)
143{ 143{
144 switch(e->key()) { 144 switch(e->key()) {
145 case Key_Shift: 145 case Key_Shift:
146 emit shiftUp(); 146 emit shiftUp();
147 break; 147 break;
148 default: 148 default:
149 break; 149 break;
150 } 150 }
151} 151}
152 152
153void KNoScrollListBox::mousePressEvent(QMouseEvent *e) 153void KNoScrollListBox::mousePressEvent(QMouseEvent *e)
154{ 154{
155 QListBox::mousePressEvent(e); 155 QListBox::mousePressEvent(e);
156 156
157 if(e->button() == RightButton) { 157 if(e->button() == RightButton) {
158 emit rightClick(); 158 emit rightClick();
159 } 159 }
160} 160}
161 161
162MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) 162MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s)
163 : QListBoxItem() 163 : QListBoxItem()
164{ 164{
165 setText( s ); 165 setText( s );
166 166
167 mIncidence = incidence; 167 mIncidence = incidence;
168 mDate = qd; 168 mDate = qd;
169 // QWhatsThis::add(this,KIncidenceFormatter::instance()->getFormattedText( mIncidence )); 169 // QWhatsThis::add(this,KIncidenceFormatter::instance()->getFormattedText( mIncidence ));
170 mRecur = false; 170 mRecur = false;
171 mAlarm = false; 171 mAlarm = false;
172 mReply = false; 172 mReply = false;
173 mInfo = false; 173 mInfo = false;
174} 174}
175 175
176void MonthViewItem::paint(QPainter *p) 176void MonthViewItem::paint(QPainter *p)
177{ 177{
178#if QT_VERSION >= 0x030000 178#if QT_VERSION >= 0x030000
179 bool sel = isSelected(); 179 bool sel = isSelected();
180#else 180#else
181 bool sel = selected(); 181 bool sel = selected();
182#endif 182#endif
183 183
184 184
185 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) 185 if (KOPrefs::instance()->mMonthViewUsesCategoryColor)
186 { 186 {
187 p->setBackgroundColor( palette().color( QPalette::Normal, \ 187 p->setBackgroundColor( palette().color( QPalette::Normal, \
188 sel ? QColorGroup::Highlight : QColorGroup::Background ) ); 188 sel ? QColorGroup::Highlight : QColorGroup::Background ) );
189 p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) ); 189 p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) );
190 } 190 }
191 int x = 1; 191 int x = 1;
192 int y = 3;//(height() - mRecurPixmap.height()) /2; 192 int y = 3;//(height() - mRecurPixmap.height()) /2;
193 int size = PIXMAP_SIZE; 193 int size = PIXMAP_SIZE;
194 if ( QApplication::desktop()->width() < 300 ) 194 if ( QApplication::desktop()->width() < 300 )
195 size = 3; 195 size = 3;
196 if ( KOPrefs::instance()->mMonthShowIcons ) { 196 if ( KOPrefs::instance()->mMonthShowIcons ) {
197 if ( mInfo ) { 197 if ( mInfo ) {
198 p->fillRect ( x, y,size,size, Qt::darkGreen ); 198 p->fillRect ( x, y,size,size, Qt::darkGreen );
199 x += size + 1; 199 x += size + 1;
200 } 200 }
201 if ( mRecur ) { 201 if ( mRecur ) {
202 p->fillRect ( x, y,size,size, Qt::blue ); 202 p->fillRect ( x, y,size,size, Qt::blue );
203 x += size + 1; 203 x += size + 1;
204 } 204 }
205 if ( mAlarm ) { 205 if ( mAlarm ) {
206 p->fillRect ( x, y,size,size, Qt::red ); 206 p->fillRect ( x, y,size,size, Qt::red );
207 x += size + 1; 207 x += size + 1;
208 } 208 }
209 if ( mReply ) { 209 if ( mReply ) {
210 p->fillRect ( x, y,size,size, Qt::yellow ); 210 p->fillRect ( x, y,size,size, Qt::yellow );
211 x += size + 1; 211 x += size + 1;
212 } 212 }
213 } 213 }
214 QFontMetrics fm = p->fontMetrics(); 214 QFontMetrics fm = p->fontMetrics();
215 int yPos; 215 int yPos;
216 int pmheight = size; 216 int pmheight = size;
217 if( pmheight < fm.height() ) 217 if( pmheight < fm.height() )
218 yPos = fm.ascent() + fm.leading()/2; 218 yPos = fm.ascent() + fm.leading()/2;
219 else 219 else
220 yPos = pmheight/2 - fm.height()/2 + fm.ascent(); 220 yPos = pmheight/2 - fm.height()/2 + fm.ascent();
221 p->setPen( palette().color( QPalette::Normal, sel ? \ 221 p->setPen( palette().color( QPalette::Normal, sel ? \
222 QColorGroup::HighlightedText : QColorGroup::Foreground ) ); 222 QColorGroup::HighlightedText : QColorGroup::Foreground ) );
223 p->drawText( x, yPos, text() ); 223 p->drawText( x, yPos, text() );
224 if ( mIncidence->cancelled() ) { 224 if ( mIncidence->cancelled() ) {
225 int wid = fm.width( text() ); 225 int wid = fm.width( text() );
226 p->drawLine( x, yPos- fm.height()/2+2,x+wid, yPos- fm.height()/2 +2); 226 p->drawLine( x, yPos- fm.height()/2+2,x+wid, yPos- fm.height()/2 +2);
227 } 227 }
228 228
229} 229}
230 230
231int MonthViewItem::height(const QListBox *lb) const 231int MonthViewItem::height(const QListBox *lb) const
232{ 232{
233 return lb->fontMetrics().lineSpacing()+1; 233 return lb->fontMetrics().lineSpacing()+1;
234} 234}
235 235
236int MonthViewItem::width(const QListBox *lb) const 236int MonthViewItem::width(const QListBox *lb) const
237{ 237{
238 int size = PIXMAP_SIZE; 238 int size = PIXMAP_SIZE;
239 if ( QApplication::desktop()->width() < 300 ) 239 if ( QApplication::desktop()->width() < 300 )
240 size = 3; 240 size = 3;
241 int x = 1; 241 int x = 1;
242 if ( mInfo ) { 242 if ( mInfo ) {
243 x += size + 1; 243 x += size + 1;
244 } 244 }
245 if( mRecur ) { 245 if( mRecur ) {
246 x += size+1; 246 x += size+1;
247 } 247 }
248 if( mAlarm ) { 248 if( mAlarm ) {
249 x += size+1; 249 x += size+1;
250 } 250 }
251 if( mReply ) { 251 if( mReply ) {
252 x += size+1; 252 x += size+1;
253 } 253 }
254 254
255 return( x + lb->fontMetrics().width( text() ) + 1 ); 255 return( x + lb->fontMetrics().width( text() ) + 1 );
256} 256}
257 257
258 258
259MonthViewCell::MonthViewCell( KOMonthView *parent) 259MonthViewCell::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
299void MonthViewCell::setDate( const QDate &date ) 299void 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
320QDate MonthViewCell::date() const 320QDate MonthViewCell::date() const
321{ 321{
322 return mDate; 322 return mDate;
323} 323}
324 324
325void MonthViewCell::setPrimary( bool primary ) 325void MonthViewCell::setPrimary( bool primary )
326{ 326{
327 mPrimary = primary; 327 mPrimary = primary;
328 //setMyPalette(); 328 //setMyPalette();
329} 329}
330void MonthViewCell::setMyPalette() 330void 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}
346QPalette MonthViewCell::getPalette () 346QPalette 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}
359bool MonthViewCell::isPrimary() const 359bool MonthViewCell::isPrimary() const
360{ 360{
361 return mPrimary; 361 return mPrimary;
362} 362}
363 363
364void MonthViewCell::setHoliday( bool holiday ) 364void MonthViewCell::setHoliday( bool holiday )
365{ 365{
366 mHoliday = holiday; 366 mHoliday = holiday;
367 //setMyPalette(); 367 //setMyPalette();
368} 368}
369 369
370void MonthViewCell::setHoliday( const QString &holiday ) 370void 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}
378void MonthViewCell::keyPressEvent ( QKeyEvent * e ) 378void MonthViewCell::keyPressEvent ( QKeyEvent * e )
379{ 379{
380 380
381 e->ignore(); 381 e->ignore();
382 382
383} 383}
384void MonthViewCell::updateCell() 384void 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
517 } else { 517 } else {
518 if (cat.isEmpty()) { 518 if (cat.isEmpty()) {
519 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); 519 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor);
520 } else { 520 } else {
521 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); 521 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat)));
522 } 522 }
523 } 523 }
524 524
525 } else { 525 } else {
526 pal = mStandardPalette ; 526 pal = mStandardPalette ;
527 } 527 }
528 item->setPalette( pal ); 528 item->setPalette( pal );
529 mItemList->insertItem( item ); 529 mItemList->insertItem( item );
530 } 530 }
531 //setMyPalette(); 531 //setMyPalette();
532 setMyPalette(); 532 setMyPalette();
533 resizeEvent( 0 ); 533 resizeEvent( 0 );
534 // if ( isVisible()) 534 // if ( isVisible())
535 // qApp->processEvents(); 535 // qApp->processEvents();
536} 536}
537 537
538void MonthViewCell::updateConfig() 538void MonthViewCell::updateConfig()
539{ 539{
540 540
541 setFont( KOPrefs::instance()->mMonthViewFont ); 541 setFont( KOPrefs::instance()->mMonthViewFont );
542 542
543 QFontMetrics fm( font() ); 543 QFontMetrics fm( font() );
544 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); 544 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 );
545 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); 545 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 );
546 mHolidayPalette = mStandardPalette; 546 mHolidayPalette = mStandardPalette;
547 mPrimaryPalette = mStandardPalette; 547 mPrimaryPalette = mStandardPalette;
548 mNonPrimaryPalette = mStandardPalette; 548 mNonPrimaryPalette = mStandardPalette;
549 if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { 549 if ( KOPrefs::instance()->mMonthViewUsesDayColors ) {
550 mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); 550 mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor );
551 mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); 551 mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor );
552 mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); 552 mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark());
553 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); 553 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark());
554 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); 554 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor);
555 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); 555 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor);
556 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); 556 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark());
557 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); 557 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor);
558 mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); 558 mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor);
559 } 559 }
560 updateCell(); 560 updateCell();
561} 561}
562 562
563void MonthViewCell::enableScrollBars( bool enabled ) 563void MonthViewCell::enableScrollBars( bool enabled )
564{ 564{
565 if ( enabled ) { 565 if ( enabled ) {
566 mItemList->setVScrollBarMode(QScrollView::Auto); 566 mItemList->setVScrollBarMode(QScrollView::Auto);
567 mItemList->setHScrollBarMode(QScrollView::Auto); 567 mItemList->setHScrollBarMode(QScrollView::Auto);
568 } else { 568 } else {
569 mItemList->setVScrollBarMode(QScrollView::AlwaysOff); 569 mItemList->setVScrollBarMode(QScrollView::AlwaysOff);
570 mItemList->setHScrollBarMode(QScrollView::AlwaysOff); 570 mItemList->setHScrollBarMode(QScrollView::AlwaysOff);
571 } 571 }
572} 572}
573 573
574Incidence *MonthViewCell::selectedIncidence() 574Incidence *MonthViewCell::selectedIncidence()
575{ 575{
576 int index = mItemList->currentItem(); 576 int index = mItemList->currentItem();
577 if ( index < 0 ) return 0; 577 if ( index < 0 ) return 0;
578 578
579 MonthViewItem *item = 579 MonthViewItem *item =
580 static_cast<MonthViewItem *>( mItemList->item( index ) ); 580 static_cast<MonthViewItem *>( mItemList->item( index ) );
581 581
582 if ( !item ) return 0; 582 if ( !item ) return 0;
583 583
584 return item->incidence(); 584 return item->incidence();
585} 585}
586 586
587QDate MonthViewCell::selectedIncidenceDate() 587QDate MonthViewCell::selectedIncidenceDate()
588{ 588{
589 QDate qd; 589 QDate qd;
590 int index = mItemList->currentItem(); 590 int index = mItemList->currentItem();
591 if ( index < 0 ) return qd; 591 if ( index < 0 ) return qd;
592 592
593 MonthViewItem *item = 593 MonthViewItem *item =
594 static_cast<MonthViewItem *>( mItemList->item( index ) ); 594 static_cast<MonthViewItem *>( mItemList->item( index ) );
595 595
596 if ( !item ) return qd; 596 if ( !item ) return qd;
597 597
598 return item->incidenceDate(); 598 return item->incidenceDate();
599} 599}
600 600
601void MonthViewCell::deselect() 601void MonthViewCell::deselect()
602{ 602{
603 mItemList->clearSelection(); 603 mItemList->clearSelection();
604 enableScrollBars( false ); 604 enableScrollBars( false );
605 // updateCell(); 605 // updateCell();
606} 606}
607void MonthViewCell::select() 607void MonthViewCell::select()
608{ 608{
609 ;// updateCell(); 609 ;// updateCell();
610} 610}
611 611
612void MonthViewCell::resizeEvent ( QResizeEvent * ) 612void MonthViewCell::resizeEvent ( QResizeEvent * )
613{ 613{
614 int size = height() - mLabel->height(); 614 int size = height() - mLabel->height();
615 if ( size > 0 ) 615 if ( size > 0 )
616 mItemList->verticalScrollBar()->setMaximumHeight( size ); 616 mItemList->verticalScrollBar()->setMaximumHeight( size );
617 size = width() - mLabel->width(); 617 size = width() - mLabel->width();
618 if ( size > 0 ) 618 if ( size > 0 )
619 mItemList->horizontalScrollBar()->setMaximumWidth( size ); 619 mItemList->horizontalScrollBar()->setMaximumWidth( size );
620 mLabel->move( width()-mItemList->lineWidth() - mLabel->width(), height()-mItemList->lineWidth() - mLabel->height() ); 620 mLabel->move( width()-mItemList->lineWidth() - mLabel->width(), height()-mItemList->lineWidth() - mLabel->height() );
621 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 621 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
622} 622}
623 623
624void MonthViewCell::defaultAction( QListBoxItem *item ) 624void MonthViewCell::defaultAction( QListBoxItem *item )
625{ 625{
626 if ( !item ) return; 626 if ( !item ) return;
627 627
628 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); 628 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
629 Incidence *incidence = eventItem->incidence(); 629 Incidence *incidence = eventItem->incidence();
630 if ( incidence ) mMonthView->defaultAction( incidence ); 630 if ( incidence ) mMonthView->defaultAction( incidence );
631} 631}
632void MonthViewCell::newEvent() 632void MonthViewCell::newEvent()
633{ 633{
634 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 634 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
635 emit newEventSignal( dt ); 635 emit newEventSignal( dt );
636} 636}
637void MonthViewCell::cellClicked( QListBoxItem *item ) 637void MonthViewCell::cellClicked( QListBoxItem *item )
638{ 638{
639 static QListBoxItem * lastClicked = 0; 639 static QListBoxItem * lastClicked = 0;
640 if ( item == 0 ) { 640 if ( item == 0 ) {
641 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 641 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
642 emit newEventSignal( dt ); 642 emit newEventSignal( dt );
643 return; 643 return;
644 } 644 }