summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp5
-rw-r--r--korganizer/calendarview.h1
-rw-r--r--korganizer/komonthview.cpp163
-rw-r--r--korganizer/komonthview.h4
-rw-r--r--korganizer/koprefs.cpp1
-rw-r--r--korganizer/koprefs.h1
-rw-r--r--korganizer/koviewmanager.cpp16
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()
}
+void CalendarView::showNavigatorBar( bool b)
+{
+ if ( b ) mNavigatorBar->show();
+ else mNavigatorBar->hide();
+}
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
public slots:
+ void showNavigatorBar(bool);
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)
}
+ if ( !event->doesFloat() ) {
+ if ( mDate == event->dtStart().date () )
+ prefix += KGlobal::locale()->formatTime(event->dtStart().time())+" ";
+ else if ( mDate == event->dtEnd().date () )
+ prefix += KGlobal::locale()->formatTime(event->dtEnd().time())+" ";
+
+ }
text = prefix + event->summary();
@@ -569,3 +576,3 @@ void MonthViewCell::finishUpdateCell()
#endif
-
+ mItemList->sort();
//setMyPalette();
@@ -574,3 +581,3 @@ void MonthViewCell::finishUpdateCell()
bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog;
- if ( KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) {
+ if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) {
text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " ";
@@ -690,6 +697,6 @@ void MonthViewCell::resizeEvent ( QResizeEvent * )
#endif
- int size = height() - mLabel->height();
+ int size = height() - mLabel->height() - 2;
if ( size > 0 )
mItemList->verticalScrollBar()->setMaximumHeight( size );
- size = width() - mLabel->width();
+ size = width() - mLabel->width() -2;
if ( size > 0 )
@@ -734,3 +741,3 @@ void MonthViewCell::cellClicked( QListBoxItem *item )
mMonthView->setSelectedCell( this );
- if( KOPrefs::instance()->mEnableMonthScroll ) enableScrollBars( true );
+ if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) enableScrollBars( true );
select();
@@ -765,3 +772,6 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
{
-
+ mWeekStartsMonday = KGlobal::locale()->weekStartsMonday();
+ mShowWeekView = KOPrefs::instance()->mMonthViewWeek;
+ if ( mShowWeekView )
+ mWeekStartsMonday = true;
updatePossible = false;
@@ -819,2 +829,4 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
+ connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ),
+ SLOT( switchView() ) );
mContextMenu = eventPopup();
@@ -829,2 +841,10 @@ KOMonthView::~KOMonthView()
}
+void KOMonthView::switchView()
+{
+ mShowWeekView = !mShowWeekView;
+ KOPrefs::instance()->mMonthViewWeek = mShowWeekView;
+ emit showNavigator( !mShowWeekView );
+ computeLayout();
+ updateConfig();
+}
@@ -877,2 +897,4 @@ void KOMonthView::updateConfig()
+ if ( mShowWeekView )
+ mWeekStartsMonday = true;
QFontMetrics fontmetric(mDayLabels[0]->font());
@@ -982,3 +1004,6 @@ void KOMonthView::updateView()
int i;
- for( i = 0; i < mCells.count(); ++i ) {
+ int timeSpan = mCells.size()-1;
+ if ( KOPrefs::instance()->mMonthViewWeek )
+ timeSpan = 6;
+ for( i = 0; i < timeSpan + 1; ++i ) {
mCells[i]->startUpdateCell();
@@ -990,3 +1015,2 @@ void KOMonthView::updateView()
bool ok;
- int timeSpan = mCells.size()-1;
QDate endDate = mStartDate.addDays( timeSpan );
@@ -1055,3 +1079,3 @@ void KOMonthView::updateView()
int day = mStartDate.daysTo( todo->dtDue().date() );
- if ( day >= 0 && day < mCells.size() ) {
+ if ( day >= 0 && day < timeSpan + 1) {
mCells[day]->insertTodo( todo );
@@ -1061,3 +1085,3 @@ void KOMonthView::updateView()
- for( i = 0; i < mCells.count(); ++i ) {
+ for( i = 0; i < timeSpan+1; ++i ) {
mCells[i]->finishUpdateCell();
@@ -1090,2 +1114,112 @@ void KOMonthView::resizeEvent(QResizeEvent * e)
}
+void KOMonthView::computeLayoutWeek()
+{
+
+ int daysToShow;
+ bool combinedSatSun = false;
+ if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) {
+ daysToShow = 6;
+ combinedSatSun = true;
+ }
+ int tWid = topLevelWidget()->size().width();
+ int tHei = topLevelWidget()->size().height();
+
+ int wid = size().width();//e
+ int hei = size().height()-1;
+
+ if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei )
+ return;
+
+ if ( wid < hei )
+ daysToShow = 2;
+ else
+ daysToShow = 3;
+ mShowSatSunComp = true;
+ combinedSatSun = true;
+
+ //qDebug("KOMonthView::computeLayout()------------------------------------ ");
+ QFontMetrics fm ( mWeekLabels[0]->font() );
+ int weeklabelwid = fm.width( "888" );
+ wid -= weeklabelwid;
+
+ int colWid = wid / daysToShow;
+ int lastCol = wid - ( colWid*6 );
+ int dayLabelHei = mDayLabels[0]->sizeHint().height();
+ int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow );
+ int colModulo = wid % daysToShow;
+ int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1;
+ //qDebug("rowmod %d ", rowModulo);
+ int i;
+ int x,y,w,h;
+ x= 0;
+ y= 0;
+ w = colWid;
+ h = dayLabelHei ;
+ for ( i = 0; i < 7; i++) {
+ if ( i && !( i % daysToShow) && i < 6) {
+ y += hei/(5-daysToShow);
+ x = 0;
+ }
+ if ( i == daysToShow-colModulo )
+ ++w;
+ if ( i >= 5 ) {
+ mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h);
+ x -= w/2 ;
+ }
+ else
+ mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h);
+ x += w;
+ }
+ x= 0;
+ y= dayLabelHei;
+ w = colWid;
+ h = cellHei;
+ for ( i = 0; i < mCells.count(); ++i) {
+ if ( i > 6 ) {
+ mCells[i]->hide();
+ continue;
+ }
+
+ w = colWid;
+ if ( ((i) % daysToShow) >= daysToShow-colModulo ) {
+ ++w;
+ }
+ if ( i == (daysToShow-1-rowModulo)*7)
+ ++h;
+
+ if ( i >= 5 ) {
+ if ( i ==5 ) {
+ mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 );
+ x -= w ;y += h/2;
+ } else {
+ mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 );
+ y -= h/2;
+ }
+ } else
+ mCells[i]->setGeometry ( x+weeklabelwid,y,w,h );
+
+
+ x += w;
+ if ( x + w/2 > wid ) {
+ x = 0;
+ y += h+dayLabelHei ;
+ }
+ }
+ y= dayLabelHei;
+ h = cellHei ;
+ mWeekLabels[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei);
+ for ( i = 1; i < 6; i++) {
+ mWeekLabels[i]->hide();
+ }
+ mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei);
+ // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height());
+ //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height());
+ mShortDayLabels = mDayLabels[0]->width() < mWidthLongDayLabel ;
+ updateDayLabels();
+ bool forceUpdate = !updatePossible;
+ updatePossible = true;
+ mWeekLabels[mNumWeeks]->setText( i18n("M"));
+ if ( forceUpdate )
+ updateView();
+}
void KOMonthView::computeLayout()
@@ -1096,3 +1230,6 @@ void KOMonthView::computeLayout()
// enough.
-
+ if ( mShowWeekView ){
+ computeLayoutWeek();
+ return;
+ }
int daysToShow = 7;
@@ -1148,3 +1285,3 @@ void KOMonthView::computeLayout()
for ( i = 0; i < mCells.count(); ++i) {
-
+ mCells[i]->show();
w = colWid;
@@ -1179,2 +1316,3 @@ void KOMonthView::computeLayout()
for ( i = 0; i < 6; i++) {
+ mWeekLabels[i]->show();
if ( i == (6-rowModulo))
@@ -1191,2 +1329,3 @@ void KOMonthView::computeLayout()
updatePossible = true;
+ mWeekLabels[mNumWeeks]->setText( i18n("W"));
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
protected slots:
+ void switchView();
void processSelectionChange();
@@ -246,2 +247,3 @@ class KOMonthView: public KOEventView
void prevMonth();
+ void showNavigator( bool );
void selectWeekNum ( int );
@@ -254,2 +256,3 @@ class KOMonthView: public KOEventView
private:
+ bool mShowWeekView;
bool updatePossible;
@@ -261,2 +264,3 @@ class KOMonthView: public KOEventView
void computeLayout();
+ void computeLayoutWeek();
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() :
addItemBool("MonthViewSatSunTog",&mMonthViewSatSunTog,true);
+ addItemBool("MonthViewWeek",&mMonthViewWeek,false);
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
bool mMonthViewSatSunTog;
+ bool mMonthViewWeek;
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 )
int hei = mMainView->height();
- if ( mCurrentView == mMonthView ) {
- mMainView->navigatorBar()->show();
- hei -= mMainView->navigatorBar()->sizeHint().height();
+ if ( mCurrentView == mMonthView ) {
+ if ( !KOPrefs::instance()->mMonthViewWeek ) {
+ mMainView->navigatorBar()->show();
+ hei -= mMainView->navigatorBar()->sizeHint().height();
+ }
//mMainView->navigatorBar()->hide();
@@ -529,3 +531,4 @@ void KOViewManager::showMonthView()
mMainView->navigatorBar(), SIGNAL(goPrevMonth() ) );
- mMonthView->updateConfig();
+ connect( mMonthView, SIGNAL( showNavigator(bool) ),
+ mMainView, SLOT ( showNavigatorBar(bool) ) );
}
@@ -535,3 +538,6 @@ void KOViewManager::showMonthView()
// if(mMonthView == mCurrentView) return;
- mMainView->dateNavigator()->selectMonth();
+ if ( KOPrefs::instance()->mMonthViewWeek )
+ mMainView->dateNavigator()->selectWeek();
+ else
+ mMainView->dateNavigator()->selectMonth();