author | zautrix <zautrix> | 2005-02-06 20:09:33 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-02-06 20:09:33 (UTC) |
commit | 961fc44f4092c1f981eb3be4284715e6829f885c (patch) (side-by-side diff) | |
tree | 005e999ddbf07af42c7da4f9193874ba0ba3870c /korganizer | |
parent | 536a16498de6b9c10b3f5b147ca18c5e4421401c (diff) | |
download | kdepimpi-961fc44f4092c1f981eb3be4284715e6829f885c.zip kdepimpi-961fc44f4092c1f981eb3be4284715e6829f885c.tar.gz kdepimpi-961fc44f4092c1f981eb3be4284715e6829f885c.tar.bz2 |
fixesss
-rw-r--r-- | korganizer/komonthview.cpp | 90 | ||||
-rw-r--r-- | korganizer/komonthview.h | 3 | ||||
-rw-r--r-- | korganizer/koviewmanager.cpp | 4 |
3 files changed, 42 insertions, 55 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index ffb2e1e..70cbf96 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp @@ -904,13 +904,20 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) SIGNAL( showDaySignal( QDate ) ) ); cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont ); } //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); mContextMenu = eventPopup(); - updateConfig(); //useless here + //updateConfig(); //useless here ... + // ... but we need mWidthLongDayLabel computed + QFontMetrics fontmetric(mDayLabels[0]->font()); + mWidthLongDayLabel = 0; + for (int i = 0; i < 7; i++) { + int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); + if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; + } //mWeekLabels[mNumWeeks]->setText( i18n("W")); if ( mShowWeekView ) mWidStack->raiseWidget( mWeekView ); else @@ -1004,13 +1011,12 @@ void KOMonthView::updateConfig() if ( mShowWeekView ) { mWeekStartsMonday = true; } QFontMetrics fontmetric(mDayLabels[0]->font()); mWidthLongDayLabel = 0; - qDebug("KOMonthView::updateConfig() "); for (int i = 0; i < 7; i++) { int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; } if ( ! mShowWeekView ) { computeLayout(); @@ -1033,19 +1039,13 @@ void KOMonthView::updateConfig() } void KOMonthView::updateDayLabels() { QPtrVector<QLabel> *mDayLabelsT; -#if 0 - if (mShowWeekView ) - mDayLabelsT = &mDayLabelsW; - else - mDayLabelsT = &mDayLabels; -#endif - qDebug("updateDayLabels W %d M %d ",mShortDayLabelsW ,mShortDayLabelsM); + mDayLabelsT = &mDayLabelsW; for (int i = 0; i < 7; i++) { if (mWeekStartsMonday) { bool show = mShortDayLabelsW; if ( i > 4 && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) show = true; @@ -1260,53 +1260,45 @@ void KOMonthView::updateView() //qDebug("update time %d ", ti.elapsed()); } void KOMonthView::resizeEvent(QResizeEvent * e) { - qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height()); + //qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height()); if ( ignoreResizeEvent ) { - int diff = e->size().height() - e->oldSize().height(); - if ( diff < 0 ) - diff = diff * (-1); - if ( diff == ignoreResizeEventHeight ) { - qDebug("KOMonthView::resizeEvent ignored "); + //qDebug("KOMonthView::resizeEvent ignored "); --ignoreResizeEvent; return; } - ignoreResizeEvent = 0; - } if ( e->size().width()+ e->size().height() < 240 ) return; computeLayout(); clPending = true; if ( mShowWeekView ) mCellsW[0]->setFocus(); else mCells[0]->setFocus(); } void KOMonthView::computeLayoutWeek() { - + static int widd = 0; + static int heigg = 0; + if ( widd == width() && heigg == height () ) { + return; + } + widd = width() ; + heigg = height (); int daysToShow; - 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; bool 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 ); @@ -1377,14 +1369,13 @@ void KOMonthView::computeLayoutWeek() } } y= dayLabelHei; h = cellHei ; mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei); mWeekLabelsW[1]->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()); + mShortDayLabelsW = mDayLabelsW[0]->width() < mWidthLongDayLabel ; updateDayLabels(); bool forceUpdate = !updatePossible; updatePossible = true; //mWeekLabels[mNumWeeks]->setText( i18n("M")); if ( forceUpdate ) @@ -1393,31 +1384,41 @@ void KOMonthView::computeLayoutWeek() void KOMonthView::computeLayout() { // select the appropriate heading string size. E.g. "Wednesday" or "Wed". // note this only changes the text if the requested size crosses the // threshold between big enough to support the full name and not big // enough. + + 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 ( mShowWeekView ){ computeLayoutWeek(); return; } + static int widd = 0; + static int heigg = 0; + if ( widd == width() && heigg == height () ) { + return; + } + widd = width() ; + heigg = height (); + int daysToShow = 7; bool combinedSatSun = false; if (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; - //qDebug("KOMonthView::computeLayout()------------------------------------ "); QFontMetrics fm ( mWeekLabels[0]->font() ); int weeklabelwid = fm.width( "888" ); wid -= weeklabelwid; int colWid = wid / daysToShow; int lastCol = wid - ( colWid*6 ); @@ -1484,51 +1485,38 @@ void KOMonthView::computeLayout() if ( i == (6-rowModulo)) ++h; mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); y += h; } 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()); mShortDayLabelsM = mDayLabels[0]->width() < mWidthLongDayLabel ; qDebug("dlwid %d %d ",mDayLabels[0]->width() , mWidthLongDayLabel); updateDayLabels(); bool forceUpdate = !updatePossible; updatePossible = true; - //mWeekLabels[mNumWeeks]->setText( i18n("W")); if ( forceUpdate ) updateView(); } void KOMonthView::showContextMenu( Incidence *incidence ) { mContextMenu->showIncidencePopup(incidence); - /* - if( incidence && incidence->type() == "Event" ) { - Event *event = static_cast<Event *>(incidence); - mContextMenu->showEventPopup(event); - } else { - kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; - } - */ + } MonthViewCell * KOMonthView::selectedCell( ) { return mSelectedCell; } void KOMonthView::setSelectedCell( MonthViewCell *cell ) { - //qDebug("KOMonthView::setSelectedCell %x ", cell); if ( mSelectedCell && mSelectedCell != cell ) { MonthViewCell * mvc = mSelectedCell; mSelectedCell = cell; mvc->deselect(); } else mSelectedCell = cell; - // if ( mSelectedCell ) - // mSelectedCell->select(); if ( !mSelectedCell ) emit incidenceSelected( 0 ); else emit incidenceSelected( mSelectedCell->selectedIncidence() ); } diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h index d70cda1..9dbe319 100644 --- a/korganizer/komonthview.h +++ b/korganizer/komonthview.h @@ -223,13 +223,13 @@ class KOMonthView: public KOEventView virtual DateList selectedDates(); virtual void printPreview(CalPrinter *calPrinter, const QDate &, const QDate &); bool isMonthView() { return true; } bool isUpdatePossible() { return updatePossible; } - void setIgnoreResizeEvent( int c, int h ) { ignoreResizeEvent = c ;ignoreResizeEventHeight = h;} + void setIgnoreResizeEvent( int c ) { ignoreResizeEvent = c ;} MonthViewCell * selectedCell(); public slots: virtual void updateView(); virtual void updateConfig(); virtual void showDates(const QDate &start, const QDate &end); @@ -257,13 +257,12 @@ class KOMonthView: public KOEventView void resizeEvent(QResizeEvent *); void viewChanged(); void updateDayLabels(); private: int ignoreResizeEvent; - int ignoreResizeEventHeight; int currentWeek(); bool clPending; QWidgetStack * mWidStack; QWidget* mMonthView; QWidget* mWeekView; bool mShowWeekView; diff --git a/korganizer/koviewmanager.cpp b/korganizer/koviewmanager.cpp index c35de0a..62d3e7f 100644 --- a/korganizer/koviewmanager.cpp +++ b/korganizer/koviewmanager.cpp @@ -197,12 +197,14 @@ void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen ) bool full = fullScreen; if(view == mCurrentView && view != mWhatsNextView ) { if ( mCurrentAgendaView < 0 ) return; full = mMainView->leftFrame()->isVisible(); } else { + if ( view == mMonthView && mMonthView) + mMonthView->setIgnoreResizeEvent( 1 ); mCurrentView = view; // bool full = fullScreen; bool isFull = !mMainView->leftFrame()->isVisible(); if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen ) full = true; if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen ) @@ -220,14 +222,12 @@ void KOViewManager::raiseCurrentView( bool fullScreen, bool callUpdateView ) { mCurrentAgendaView = 0; int wid = mMainView->width() ; int hei = mMainView->height(); if ( mCurrentView == mMonthView ) { if ( true /* !KOPrefs::instance()->mMonthViewWeek*/ ) { - - mMonthView->setIgnoreResizeEvent( 2 ,mMainView->navigatorBar()->height()); mMainView->navigatorBar()->show(); hei -= mMainView->navigatorBar()->sizeHint().height(); } //mMainView->navigatorBar()->hide(); } else { mMainView->navigatorBar()->hide(); |