-rw-r--r-- | korganizer/calendarview.cpp | 5 | ||||
-rw-r--r-- | korganizer/calendarview.h | 1 | ||||
-rw-r--r-- | korganizer/komonthview.cpp | 163 | ||||
-rw-r--r-- | korganizer/komonthview.h | 4 | ||||
-rw-r--r-- | korganizer/koprefs.cpp | 1 | ||||
-rw-r--r-- | korganizer/koprefs.h | 1 | ||||
-rw-r--r-- | korganizer/koviewmanager.cpp | 16 |
7 files changed, 174 insertions, 17 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index cca73f2..be78057 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -3856,2 +3856,7 @@ NavigatorBar *CalendarView::navigatorBar() | |||
3856 | } | 3856 | } |
3857 | void CalendarView::showNavigatorBar( bool b) | ||
3858 | { | ||
3859 | if ( b ) mNavigatorBar->show(); | ||
3860 | else mNavigatorBar->hide(); | ||
3861 | } | ||
3857 | 3862 | ||
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h index 7c59a8d..6ea8287 100644 --- a/korganizer/calendarview.h +++ b/korganizer/calendarview.h | |||
@@ -176,2 +176,3 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser | |||
176 | public slots: | 176 | public slots: |
177 | void showNavigatorBar(bool); | ||
177 | void showOpenError(); | 178 | void showOpenError(); |
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index 6411156..9888566 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp | |||
@@ -467,2 +467,9 @@ void MonthViewCell::insertEvent(Event *event) | |||
467 | } | 467 | } |
468 | if ( !event->doesFloat() ) { | ||
469 | if ( mDate == event->dtStart().date () ) | ||
470 | prefix += KGlobal::locale()->formatTime(event->dtStart().time())+" "; | ||
471 | else if ( mDate == event->dtEnd().date () ) | ||
472 | prefix += KGlobal::locale()->formatTime(event->dtEnd().time())+" "; | ||
473 | |||
474 | } | ||
468 | text = prefix + event->summary(); | 475 | text = prefix + event->summary(); |
@@ -569,3 +576,3 @@ void MonthViewCell::finishUpdateCell() | |||
569 | #endif | 576 | #endif |
570 | 577 | mItemList->sort(); | |
571 | //setMyPalette(); | 578 | //setMyPalette(); |
@@ -574,3 +581,3 @@ void MonthViewCell::finishUpdateCell() | |||
574 | bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; | 581 | bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; |
575 | if ( KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { | 582 | if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { |
576 | text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; | 583 | text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; |
@@ -690,6 +697,6 @@ void MonthViewCell::resizeEvent ( QResizeEvent * ) | |||
690 | #endif | 697 | #endif |
691 | int size = height() - mLabel->height(); | 698 | int size = height() - mLabel->height() - 2; |
692 | if ( size > 0 ) | 699 | if ( size > 0 ) |
693 | mItemList->verticalScrollBar()->setMaximumHeight( size ); | 700 | mItemList->verticalScrollBar()->setMaximumHeight( size ); |
694 | size = width() - mLabel->width(); | 701 | size = width() - mLabel->width() -2; |
695 | if ( size > 0 ) | 702 | if ( size > 0 ) |
@@ -734,3 +741,3 @@ void MonthViewCell::cellClicked( QListBoxItem *item ) | |||
734 | mMonthView->setSelectedCell( this ); | 741 | mMonthView->setSelectedCell( this ); |
735 | if( KOPrefs::instance()->mEnableMonthScroll ) enableScrollBars( true ); | 742 | if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) enableScrollBars( true ); |
736 | select(); | 743 | select(); |
@@ -765,3 +772,6 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) | |||
765 | { | 772 | { |
766 | 773 | mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); | |
774 | mShowWeekView = KOPrefs::instance()->mMonthViewWeek; | ||
775 | if ( mShowWeekView ) | ||
776 | mWeekStartsMonday = true; | ||
767 | updatePossible = false; | 777 | updatePossible = false; |
@@ -819,2 +829,4 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) | |||
819 | 829 | ||
830 | connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), | ||
831 | SLOT( switchView() ) ); | ||
820 | mContextMenu = eventPopup(); | 832 | mContextMenu = eventPopup(); |
@@ -829,2 +841,10 @@ KOMonthView::~KOMonthView() | |||
829 | } | 841 | } |
842 | void KOMonthView::switchView() | ||
843 | { | ||
844 | mShowWeekView = !mShowWeekView; | ||
845 | KOPrefs::instance()->mMonthViewWeek = mShowWeekView; | ||
846 | emit showNavigator( !mShowWeekView ); | ||
847 | computeLayout(); | ||
848 | updateConfig(); | ||
849 | } | ||
830 | 850 | ||
@@ -877,2 +897,4 @@ void KOMonthView::updateConfig() | |||
877 | 897 | ||
898 | if ( mShowWeekView ) | ||
899 | mWeekStartsMonday = true; | ||
878 | QFontMetrics fontmetric(mDayLabels[0]->font()); | 900 | QFontMetrics fontmetric(mDayLabels[0]->font()); |
@@ -982,3 +1004,6 @@ void KOMonthView::updateView() | |||
982 | int i; | 1004 | int i; |
983 | for( i = 0; i < mCells.count(); ++i ) { | 1005 | int timeSpan = mCells.size()-1; |
1006 | if ( KOPrefs::instance()->mMonthViewWeek ) | ||
1007 | timeSpan = 6; | ||
1008 | for( i = 0; i < timeSpan + 1; ++i ) { | ||
984 | mCells[i]->startUpdateCell(); | 1009 | mCells[i]->startUpdateCell(); |
@@ -990,3 +1015,2 @@ void KOMonthView::updateView() | |||
990 | bool ok; | 1015 | bool ok; |
991 | int timeSpan = mCells.size()-1; | ||
992 | QDate endDate = mStartDate.addDays( timeSpan ); | 1016 | QDate endDate = mStartDate.addDays( timeSpan ); |
@@ -1055,3 +1079,3 @@ void KOMonthView::updateView() | |||
1055 | int day = mStartDate.daysTo( todo->dtDue().date() ); | 1079 | int day = mStartDate.daysTo( todo->dtDue().date() ); |
1056 | if ( day >= 0 && day < mCells.size() ) { | 1080 | if ( day >= 0 && day < timeSpan + 1) { |
1057 | mCells[day]->insertTodo( todo ); | 1081 | mCells[day]->insertTodo( todo ); |
@@ -1061,3 +1085,3 @@ void KOMonthView::updateView() | |||
1061 | 1085 | ||
1062 | for( i = 0; i < mCells.count(); ++i ) { | 1086 | for( i = 0; i < timeSpan+1; ++i ) { |
1063 | mCells[i]->finishUpdateCell(); | 1087 | mCells[i]->finishUpdateCell(); |
@@ -1090,2 +1114,112 @@ void KOMonthView::resizeEvent(QResizeEvent * e) | |||
1090 | } | 1114 | } |
1115 | void KOMonthView::computeLayoutWeek() | ||
1116 | { | ||
1117 | |||
1118 | int daysToShow; | ||
1119 | bool combinedSatSun = false; | ||
1120 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { | ||
1121 | daysToShow = 6; | ||
1122 | combinedSatSun = true; | ||
1123 | } | ||
1124 | int tWid = topLevelWidget()->size().width(); | ||
1125 | int tHei = topLevelWidget()->size().height(); | ||
1126 | |||
1127 | int wid = size().width();//e | ||
1128 | int hei = size().height()-1; | ||
1129 | |||
1130 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) | ||
1131 | return; | ||
1132 | |||
1133 | if ( wid < hei ) | ||
1134 | daysToShow = 2; | ||
1135 | else | ||
1136 | daysToShow = 3; | ||
1137 | mShowSatSunComp = true; | ||
1138 | combinedSatSun = true; | ||
1139 | |||
1140 | //qDebug("KOMonthView::computeLayout()------------------------------------ "); | ||
1141 | QFontMetrics fm ( mWeekLabels[0]->font() ); | ||
1142 | int weeklabelwid = fm.width( "888" ); | ||
1143 | wid -= weeklabelwid; | ||
1144 | |||
1145 | int colWid = wid / daysToShow; | ||
1146 | int lastCol = wid - ( colWid*6 ); | ||
1147 | int dayLabelHei = mDayLabels[0]->sizeHint().height(); | ||
1148 | int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow ); | ||
1149 | int colModulo = wid % daysToShow; | ||
1150 | int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1; | ||
1151 | //qDebug("rowmod %d ", rowModulo); | ||
1152 | int i; | ||
1153 | int x,y,w,h; | ||
1154 | x= 0; | ||
1155 | y= 0; | ||
1156 | w = colWid; | ||
1157 | h = dayLabelHei ; | ||
1158 | for ( i = 0; i < 7; i++) { | ||
1159 | if ( i && !( i % daysToShow) && i < 6) { | ||
1160 | y += hei/(5-daysToShow); | ||
1161 | x = 0; | ||
1162 | } | ||
1163 | if ( i == daysToShow-colModulo ) | ||
1164 | ++w; | ||
1165 | if ( i >= 5 ) { | ||
1166 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); | ||
1167 | x -= w/2 ; | ||
1168 | } | ||
1169 | else | ||
1170 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); | ||
1171 | x += w; | ||
1172 | } | ||
1173 | x= 0; | ||
1174 | y= dayLabelHei; | ||
1175 | w = colWid; | ||
1176 | h = cellHei; | ||
1177 | for ( i = 0; i < mCells.count(); ++i) { | ||
1178 | if ( i > 6 ) { | ||
1179 | mCells[i]->hide(); | ||
1180 | continue; | ||
1181 | } | ||
1182 | |||
1183 | w = colWid; | ||
1184 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { | ||
1185 | ++w; | ||
1186 | } | ||
1187 | if ( i == (daysToShow-1-rowModulo)*7) | ||
1188 | ++h; | ||
1189 | |||
1190 | if ( i >= 5 ) { | ||
1191 | if ( i ==5 ) { | ||
1192 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); | ||
1193 | x -= w ;y += h/2; | ||
1194 | } else { | ||
1195 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); | ||
1196 | y -= h/2; | ||
1197 | } | ||
1198 | } else | ||
1199 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); | ||
1200 | |||
1201 | |||
1202 | x += w; | ||
1203 | if ( x + w/2 > wid ) { | ||
1204 | x = 0; | ||
1205 | y += h+dayLabelHei ; | ||
1206 | } | ||
1207 | } | ||
1208 | y= dayLabelHei; | ||
1209 | h = cellHei ; | ||
1210 | mWeekLabels[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei); | ||
1211 | for ( i = 1; i < 6; i++) { | ||
1212 | mWeekLabels[i]->hide(); | ||
1213 | } | ||
1214 | mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); | ||
1215 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); | ||
1216 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); | ||
1217 | mShortDayLabels = mDayLabels[0]->width() < mWidthLongDayLabel ; | ||
1218 | updateDayLabels(); | ||
1219 | bool forceUpdate = !updatePossible; | ||
1220 | updatePossible = true; | ||
1221 | mWeekLabels[mNumWeeks]->setText( i18n("M")); | ||
1222 | if ( forceUpdate ) | ||
1223 | updateView(); | ||
1224 | } | ||
1091 | void KOMonthView::computeLayout() | 1225 | void KOMonthView::computeLayout() |
@@ -1096,3 +1230,6 @@ void KOMonthView::computeLayout() | |||
1096 | // enough. | 1230 | // enough. |
1097 | 1231 | if ( mShowWeekView ){ | |
1232 | computeLayoutWeek(); | ||
1233 | return; | ||
1234 | } | ||
1098 | int daysToShow = 7; | 1235 | int daysToShow = 7; |
@@ -1148,3 +1285,3 @@ void KOMonthView::computeLayout() | |||
1148 | for ( i = 0; i < mCells.count(); ++i) { | 1285 | for ( i = 0; i < mCells.count(); ++i) { |
1149 | 1286 | mCells[i]->show(); | |
1150 | w = colWid; | 1287 | w = colWid; |
@@ -1179,2 +1316,3 @@ void KOMonthView::computeLayout() | |||
1179 | for ( i = 0; i < 6; i++) { | 1316 | for ( i = 0; i < 6; i++) { |
1317 | mWeekLabels[i]->show(); | ||
1180 | if ( i == (6-rowModulo)) | 1318 | if ( i == (6-rowModulo)) |
@@ -1191,2 +1329,3 @@ void KOMonthView::computeLayout() | |||
1191 | updatePossible = true; | 1329 | updatePossible = true; |
1330 | mWeekLabels[mNumWeeks]->setText( i18n("W")); | ||
1192 | if ( forceUpdate ) | 1331 | if ( forceUpdate ) |
diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h index b84065e..0bc3743 100644 --- a/korganizer/komonthview.h +++ b/korganizer/komonthview.h | |||
@@ -242,2 +242,3 @@ class KOMonthView: public KOEventView | |||
242 | protected slots: | 242 | protected slots: |
243 | void switchView(); | ||
243 | void processSelectionChange(); | 244 | void processSelectionChange(); |
@@ -246,2 +247,3 @@ class KOMonthView: public KOEventView | |||
246 | void prevMonth(); | 247 | void prevMonth(); |
248 | void showNavigator( bool ); | ||
247 | void selectWeekNum ( int ); | 249 | void selectWeekNum ( int ); |
@@ -254,2 +256,3 @@ class KOMonthView: public KOEventView | |||
254 | private: | 256 | private: |
257 | bool mShowWeekView; | ||
255 | bool updatePossible; | 258 | bool updatePossible; |
@@ -261,2 +264,3 @@ class KOMonthView: public KOEventView | |||
261 | void computeLayout(); | 264 | void computeLayout(); |
265 | void computeLayoutWeek(); | ||
262 | 266 | ||
diff --git a/korganizer/koprefs.cpp b/korganizer/koprefs.cpp index 0548f14..2fb7c36 100644 --- a/korganizer/koprefs.cpp +++ b/korganizer/koprefs.cpp | |||
@@ -209,2 +209,3 @@ KOPrefs::KOPrefs() : | |||
209 | addItemBool("MonthViewSatSunTog",&mMonthViewSatSunTog,true); | 209 | addItemBool("MonthViewSatSunTog",&mMonthViewSatSunTog,true); |
210 | addItemBool("MonthViewWeek",&mMonthViewWeek,false); | ||
210 | addItemBool("HightlightDateTimeEdit",&mHightlightDateTimeEdit,false); | 211 | addItemBool("HightlightDateTimeEdit",&mHightlightDateTimeEdit,false); |
diff --git a/korganizer/koprefs.h b/korganizer/koprefs.h index 8b849fa..6541af2 100644 --- a/korganizer/koprefs.h +++ b/korganizer/koprefs.h | |||
@@ -135,2 +135,3 @@ class KOPrefs : public KPimPrefs | |||
135 | bool mMonthViewSatSunTog; | 135 | bool mMonthViewSatSunTog; |
136 | bool mMonthViewWeek; | ||
136 | QColor mAppColor1; | 137 | QColor mAppColor1; |
diff --git a/korganizer/koviewmanager.cpp b/korganizer/koviewmanager.cpp index 7e126d9..6afd203 100644 --- a/korganizer/koviewmanager.cpp +++ b/korganizer/koviewmanager.cpp | |||
@@ -226,5 +226,7 @@ void KOViewManager::raiseCurrentView( bool fullScreen, bool callUpdateView ) | |||
226 | int hei = mMainView->height(); | 226 | int hei = mMainView->height(); |
227 | if ( mCurrentView == mMonthView ) { | 227 | if ( mCurrentView == mMonthView ) { |
228 | mMainView->navigatorBar()->show(); | 228 | if ( !KOPrefs::instance()->mMonthViewWeek ) { |
229 | hei -= mMainView->navigatorBar()->sizeHint().height(); | 229 | mMainView->navigatorBar()->show(); |
230 | hei -= mMainView->navigatorBar()->sizeHint().height(); | ||
231 | } | ||
230 | //mMainView->navigatorBar()->hide(); | 232 | //mMainView->navigatorBar()->hide(); |
@@ -529,3 +531,4 @@ void KOViewManager::showMonthView() | |||
529 | mMainView->navigatorBar(), SIGNAL(goPrevMonth() ) ); | 531 | mMainView->navigatorBar(), SIGNAL(goPrevMonth() ) ); |
530 | mMonthView->updateConfig(); | 532 | connect( mMonthView, SIGNAL( showNavigator(bool) ), |
533 | mMainView, SLOT ( showNavigatorBar(bool) ) ); | ||
531 | } | 534 | } |
@@ -535,3 +538,6 @@ void KOViewManager::showMonthView() | |||
535 | // if(mMonthView == mCurrentView) return; | 538 | // if(mMonthView == mCurrentView) return; |
536 | mMainView->dateNavigator()->selectMonth(); | 539 | if ( KOPrefs::instance()->mMonthViewWeek ) |
540 | mMainView->dateNavigator()->selectWeek(); | ||
541 | else | ||
542 | mMainView->dateNavigator()->selectMonth(); | ||
537 | 543 | ||