-rw-r--r-- | korganizer/komonthview.cpp | 207 | ||||
-rw-r--r-- | korganizer/komonthview.h | 10 |
2 files changed, 166 insertions, 51 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index 9c1e4c3..daa37fd 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp @@ -10,32 +10,33 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include <qpopupmenu.h> #include <qfont.h> #include <qfontmetrics.h> #include <qkeycode.h> #include <qhbox.h> #include <qvbox.h> +#include <qwidgetstack.h> #include <qpushbutton.h> #include <qtooltip.h> #include <qpainter.h> #include <qwhatsthis.h> #ifndef DESKTOP_VERSION #include <qpe/qpeapplication.h> #else #include <qapplication.h> #endif #include <kdebug.h> #include <klocale.h> #include <kglobal.h> #include <kconfig.h> #include <kiconloader.h> @@ -255,34 +256,34 @@ int MonthViewItem::width(const QListBox *lb) const x += size + 1; } if( mRecur ) { x += size+1; } if( mAlarm ) { x += size+1; } if( mReply ) { x += size+1; } return( x + lb->fontMetrics().width( text() ) + 1 ); } -MonthViewCell::MonthViewCell( KOMonthView *parent) - : QWidget( parent ), +MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) + : QWidget( par ), mMonthView( parent ) { QVBoxLayout *topLayout = new QVBoxLayout( this ); // mLabel = new QLabel( this );QPushButton mLabel = new QPushButton( this ); //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); //mLabel->setLineWidth( 1 ); //mLabel->setAlignment( AlignCenter ); mLabel->setFlat( true ); mItemList = new KNoScrollListBox( this ); mItemList->setMinimumSize( 10, 10 ); mItemList->setFrameStyle( QFrame::Panel | QFrame::Plain ); mItemList->setLineWidth( 1 ); topLayout->addWidget( mItemList ); @@ -753,121 +754,185 @@ void MonthViewCell::selection( QListBoxItem *item ) if ( !item ) return; mMonthView->setSelectedCell( this ); } // ******************************************************************************* // ******************************************************************************* // ******************************************************************************* KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) : KOEventView( calendar, parent, name ), mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), mShortDayLabels( false ), mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) { + + clPending = true; + mWidStack = new QWidgetStack( this ); + QHBoxLayout* hb = new QHBoxLayout( this ); + mMonthView = new QWidget( mWidStack ); + mWeekView = new QWidget( mWidStack ); +#if QT_VERSION >= 0x030000 + mWidStack->addWidget(mMonthView ); + mWidStack->addWidget(mWeekView ); +#else + mWidStack->addWidget( mMonthView, 1 ); + mWidStack->addWidget( mWeekView , 1 ); +#endif + hb->addWidget( mWidStack ); mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); mShowWeekView = KOPrefs::instance()->mMonthViewWeek; if ( mShowWeekView ) mWeekStartsMonday = true; updatePossible = false; mCells.setAutoDelete( true ); mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; - // mDayLayout = new QGridLayout( this ); - // create the day of the week labels (Sun, Mon, etc) and add them to - // the layout. mDayLabels.resize( mDaysPerWeek ); + mDayLabelsW.resize( mDaysPerWeek ); QFont bfont = font(); if ( QApplication::desktop()->width() < 650 ) { bfont.setPointSize( bfont.pointSize() - 2 ); } bfont.setBold( true ); int i; for( i = 0; i < mDaysPerWeek; i++ ) { - QLabel *label = new QLabel( this ); + QLabel *label = new QLabel( mMonthView ); label->setFont(bfont); label->setFrameStyle(QFrame::Panel|QFrame::Raised); label->setLineWidth(1); label->setAlignment(AlignCenter); mDayLabels.insert( i, label ); + label = new QLabel( mWeekView ); + label->setFont(bfont); + label->setFrameStyle(QFrame::Panel|QFrame::Raised); + label->setLineWidth(1); + label->setAlignment(AlignCenter); + mDayLabelsW.insert( i, label ); } bfont.setBold( false ); mWeekLabels.resize( mNumWeeks+1 ); + mWeekLabelsW.resize( 2 ); for( i = 0; i < mNumWeeks+1; i++ ) { - KOWeekButton *label = new KOWeekButton( this ); + KOWeekButton *label = new KOWeekButton( mMonthView ); label->setFont(bfont); connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); label->setFlat(true); QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); //label->setFrameStyle(QFrame::Panel|QFrame::Raised); //label->setLineWidth(1); //label->setAlignment(AlignCenter); mWeekLabels.insert( i, label ); } - mWeekLabels[mNumWeeks]->setText( i18n("")); + mWeekLabels[mNumWeeks]->setText( i18n("W")); QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); + + for( i = 0; i < 1+1; i++ ) { + KOWeekButton *label = new KOWeekButton( mWeekView ); + label->setFont(bfont); + connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); + label->setFlat(true); + QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); + //label->setFrameStyle(QFrame::Panel|QFrame::Raised); + //label->setLineWidth(1); + //label->setAlignment(AlignCenter); + mWeekLabelsW.insert( i, label ); + } + mWeekLabelsW[1]->setText( i18n("W")); + + int row, col; mCells.resize( mNumCells ); for( row = 0; row < mNumWeeks; ++row ) { for( col = 0; col < mDaysPerWeek; ++col ) { - MonthViewCell *cell = new MonthViewCell( this ); + MonthViewCell *cell = new MonthViewCell( this, mMonthView ); mCells.insert( row * mDaysPerWeek + col, cell ); connect( cell, SIGNAL( defaultAction( Incidence * ) ), SLOT( defaultAction( Incidence * ) ) ); connect( cell, SIGNAL( newEventSignal( QDateTime ) ), SIGNAL( newEventSignal( QDateTime ) ) ); connect( cell, SIGNAL( showDaySignal( QDate ) ), SIGNAL( showDaySignal( QDate ) ) ); } } + mCellsW.resize( mDaysPerWeek ); + for( col = 0; col < mDaysPerWeek; ++col ) { + MonthViewCell *cell = new MonthViewCell( this, mWeekView ); + mCellsW.insert( col, cell ); + + connect( cell, SIGNAL( defaultAction( Incidence * ) ), + SLOT( defaultAction( Incidence * ) ) ); + connect( cell, SIGNAL( newEventSignal( QDateTime ) ), + SIGNAL( newEventSignal( QDateTime ) ) ); + connect( cell, SIGNAL( showDaySignal( QDate ) ), + SIGNAL( showDaySignal( QDate ) ) ); + } //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); mContextMenu = eventPopup(); // updateConfig(); //useless here - mWeekLabels[mNumWeeks]->setText( i18n("W")); + //mWeekLabels[mNumWeeks]->setText( i18n("W")); +#if 0 + mWidStack = new QWidgetStack( this ); + mMonthView = new QWidget( mWidStack ); + mWeekView = new QWidget( mWidStack ); +#endif + if ( mShowWeekView ) + mWidStack->raiseWidget( mWeekView ); + else + mWidStack->raiseWidget( mMonthView ); + emit incidenceSelected( 0 ); } KOMonthView::~KOMonthView() { delete mContextMenu; } void KOMonthView::selectDateWeekNum ( int ) { } void KOMonthView::selectInternalWeekNum ( int n ) { - emit selectWeekNum ( n ); switchView(); + emit selectWeekNum ( n ); } void KOMonthView::switchView() { + if ( selectedCell( ) ) selectedCell()->deselect(); mShowWeekView = !mShowWeekView; KOPrefs::instance()->mMonthViewWeek = mShowWeekView; //emit showNavigator( !mShowWeekView ); - computeLayout(); - updateConfig(); + if ( clPending ) { + computeLayout(); + updateConfig(); + } + if ( mShowWeekView ) + mWidStack->raiseWidget( mWeekView ); + else + mWidStack->raiseWidget( mMonthView ); + clPending = false; } int KOMonthView::maxDatesHint() { return mNumCells; } int KOMonthView::currentDateCount() { return mNumCells; } QPtrList<Incidence> KOMonthView::selectedIncidences() { QPtrList<Incidence> selected; @@ -893,249 +958,296 @@ DateList KOMonthView::selectedDates() void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, const QDate &td) { #ifndef KORG_NOPRINTER calPrinter->preview(CalPrinter::Month, fd, td); #endif } void KOMonthView::updateConfig() { mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); if ( mShowWeekView ) { mWeekStartsMonday = true; - } + } 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; } bool temp = mShowSatSunComp ; mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; if ( ! mShowWeekView ) { if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) computeLayout(); } updateDayLabels(); //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; //resizeEvent( 0 ); for (uint i = 0; i < mCells.count(); ++i) { mCells[i]->updateConfig(); } #ifdef DESKTOP_VERSION MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); #endif updateView(); } void KOMonthView::updateDayLabels() { + QPtrVector<QLabel> *mDayLabelsT; +#if 0 + if (mShowWeekView ) + mDayLabelsT = &mDayLabelsW; + else + mDayLabelsT = &mDayLabels; +#endif + + mDayLabelsT = &mDayLabelsW; + for (int i = 0; i < 7; i++) { + if (mWeekStartsMonday) { + bool show = mShortDayLabels; + if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) + show = true; + (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); + } else { + if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels)); + else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels)); + + } + } + mDayLabelsT = &mDayLabels; for (int i = 0; i < 7; i++) { if (mWeekStartsMonday) { bool show = mShortDayLabels; - if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > mDayLabels[i]->width() ) + if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) show = true; - mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); + (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); } else { - if (i==0) mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels)); - else mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels)); + if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels)); + else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels)); } } + } void KOMonthView::showDates(const QDate &start, const QDate &) { // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; + QPtrVector<MonthViewCell> *cells; + QPtrVector<QLabel> *dayLabels; + QPtrVector<KOWeekButton> *weekLabels; + int weekNum = 6; + if ( mShowWeekView ) { + weekNum = 1; + cells = &mCellsW; + dayLabels = &mDayLabelsW; + weekLabels = &mWeekLabelsW; + } else { + cells = &mCells; + dayLabels = &mDayLabels; + weekLabels = &mWeekLabels; + } mStartDate = start; int startWeekDay = mWeekStartsMonday ? 1 : 7; while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { mStartDate = mStartDate.addDays( -1 ); } bool primary = false; uint i; - for( i = 0; i < mCells.size(); ++i ) { + for( i = 0; i < (*cells).size(); ++i ) { QDate date = mStartDate.addDays( i ); - mCells[i]->setDate( date ); + (*cells)[i]->setDate( date ); #ifndef KORG_NOPLUGINS // add holiday, if present QString hstring(KOCore::self()->holiday(date)); - mCells[i]->setHoliday( hstring ); + (*cells)[i]->setHoliday( hstring ); #endif } QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); - for( i = 0; i < 6; ++i ) { + for( i = 0; i < weekNum; ++i ) { int wno; // remember, according to ISO 8601, the first week of the year is the // first week that contains a thursday. Thus we must subtract off 4, // not just 1. int dayOfYear = date.dayOfYear(); if (dayOfYear % 7 != 0) wno = dayOfYear / 7 + 1; else wno =dayOfYear / 7; - mWeekLabels[i]->setWeekNum( wno ); + (*weekLabels)[i]->setWeekNum( wno ); date = date.addDays( 7 ); } updateView(); } void KOMonthView::showEvents(QPtrList<Event>) { qDebug("KOMonthView::selectEvents is not implemented yet. "); } void KOMonthView::changeEventDisplay(Event *, int) { // this should be re-written to be much more efficient, but this // quick-and-dirty-hack gets the job done for right now. updateView(); } void KOMonthView::updateView() { if ( !updatePossible ) return; //QTime ti; //ti.start(); + QPtrVector<MonthViewCell> *cells; + if ( mShowWeekView ) { + cells = &mCellsW; + } else { + cells = &mCells; + } #if 1 int i; - int timeSpan = mCells.size()-1; + int timeSpan = (*cells).size()-1; if ( KOPrefs::instance()->mMonthViewWeek ) timeSpan = 6; for( i = 0; i < timeSpan + 1; ++i ) { - mCells[i]->startUpdateCell(); + (*cells)[i]->startUpdateCell(); } QPtrList<Event> events = calendar()->events(); Event *event; QDateTime dt; bool ok; QDate endDate = mStartDate.addDays( timeSpan ); for( event = events.first(); event; event = events.next() ) { // for event if ( event->doesRecur() ) { bool last; QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); QDateTime incidenceEnd; int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); bool invalid = false; while( true ) { if ( incidenceStart.isValid() ) { incidenceEnd = incidenceStart.addDays( eventlen ); int st = incidenceStart.date().daysTo( endDate ); if ( st >= 0 ) { // start before timeend int end = mStartDate.daysTo( incidenceEnd.date() ); if ( end >= 0 ) { // end after timestart --- got one! //normalize st = timeSpan - st; if ( st < 0 ) st = 0; if ( end > timeSpan ) end = timeSpan; int iii; //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); for ( iii = st;iii<= end;++iii) - mCells[iii]->insertEvent( event ); + (*cells)[iii]->insertEvent( event ); } } } else { if ( invalid ) break; invalid = true; //qDebug("invalid %s", event->summary().latin1()); incidenceStart = QDateTime( mStartDate ); } if ( last ) break; bool ok; incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); if ( ! ok ) break; if ( incidenceStart.date() > endDate ) break; } } else { // no recur int st = event->dtStart().date().daysTo( endDate ); if ( st >= 0 ) { // start before timeend int end = mStartDate.daysTo( event->dtEnd().date() ); if ( end >= 0 ) { // end after timestart --- got one! //normalize st = timeSpan - st; if ( st < 0 ) st = 0; if ( end > timeSpan ) end = timeSpan; int iii; for ( iii = st;iii<= end;++iii) - mCells[iii]->insertEvent( event ); + (*cells)[iii]->insertEvent( event ); } } } } // insert due todos QPtrList<Todo> todos = calendar()->todos( ); Todo *todo; for(todo = todos.first(); todo; todo = todos.next()) { //insertTodo( todo ); if ( todo->hasDueDate() ) { int day = mStartDate.daysTo( todo->dtDue().date() ); if ( day >= 0 && day < timeSpan + 1) { - mCells[day]->insertTodo( todo ); + (*cells)[day]->insertTodo( todo ); } } } for( i = 0; i < timeSpan+1; ++i ) { - mCells[i]->finishUpdateCell(); + (*cells)[i]->finishUpdateCell(); } processSelectionChange(); - mCells[0]->setFocus(); + (*cells)[0]->setFocus(); #else // old code //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); int i; - for( i = 0; i < mCells.count(); ++i ) { - mCells[i]->updateCell(); + for( i = 0; i < (*cells).count(); ++i ) { + (*cells)[i]->updateCell(); } //qDebug("KOMonthView::updateView() "); processSelectionChange(); // qDebug("---------------------------------------------------------------------+ "); - mCells[0]->setFocus(); + (*cells)[0]->setFocus(); #endif //qDebug("update time %d ", ti.elapsed()); } void KOMonthView::resizeEvent(QResizeEvent * e) { computeLayout(); - mCells[0]->setFocus(); + clPending = true; + if ( mShowWeekView ) + mCellsW[0]->setFocus(); + else + mCells[0]->setFocus(); } 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; @@ -1143,108 +1255,105 @@ void KOMonthView::computeLayoutWeek() 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 dayLabelHei = mDayLabelsW[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; w = colWid; } if ( ((i) % daysToShow) >= daysToShow-colModulo ) { ++w; } if ( i >= 5 ) { - mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2+w%2,h); + mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w/2+w%2,h); x -= (w/2 ); } else - mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); + mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w,h); x += w; } x= 0; y= dayLabelHei; w = colWid; h = cellHei; - for ( i = 0; i < mCells.count(); ++i) { + for ( i = 0; i < mCellsW.count(); ++i) { if ( i > 6 ) { - mCells[i]->hide(); + mCellsW[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 ); + mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); x -= w ;y += h/2; } else { if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) { ++w; } - mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); + mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); y -= h/2; } } else - mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); + mCellsW[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); + 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()); - mShortDayLabels = mDayLabels[0]->width() < mWidthLongDayLabel ; + mShortDayLabels = mDayLabelsW[0]->width() < mWidthLongDayLabel ; updateDayLabels(); bool forceUpdate = !updatePossible; updatePossible = true; //mWeekLabels[mNumWeeks]->setText( i18n("M")); if ( forceUpdate ) updateView(); } 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. if ( mShowWeekView ){ computeLayoutWeek(); return; @@ -1287,64 +1396,62 @@ void KOMonthView::computeLayout() if ( combinedSatSun ) { if ( i >= daysToShow-1 ) { mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); x -= w/2 ; } else mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); } 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) { - mCells[i]->show(); w = colWid; if ( ((i) % 7) >= 7-colModulo ) { ++w; } if ( i == (6-rowModulo)*7) ++h; if ( combinedSatSun ) { if ( (i)%7 >= daysToShow-1 ) { if ( (i)%7 == daysToShow-1 ) { 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 ); } else mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); x += w; if ( x + w/2 > wid ) { x = 0; y += h; } } y= dayLabelHei; h = cellHei ; for ( i = 0; i < 6; i++) { - mWeekLabels[i]->show(); 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()); mShortDayLabels = mDayLabels[0]->width() < mWidthLongDayLabel ; updateDayLabels(); bool forceUpdate = !updatePossible; updatePossible = true; //mWeekLabels[mNumWeeks]->setText( i18n("W")); if ( forceUpdate ) updateView(); } diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h index 1ed200b..b89b2bc 100644 --- a/korganizer/komonthview.h +++ b/korganizer/komonthview.h @@ -12,32 +12,33 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef _KOMONTHVIEW_H #define _KOMONTHVIEW_H #include <qlabel.h> #include <qframe.h> #include <qdatetime.h> #include <qlistbox.h> #include <qpoint.h> +#include <qwidgetstack.h> #include <qlayout.h> #include <qintdict.h> #include <qpushbutton.h> #include <qvaluelist.h> #include <qptrvector.h> #include <libkcal/calendar.h> #include <libkcal/event.h> #include "koeventview.h" #ifdef DESKTOP_VERSION class QToolTipGroup; #endif class KNOWhatsThis; @@ -112,33 +113,33 @@ class MonthViewItem: public QListBoxItem bool mReply; bool mInfo; QPalette mPalette; QDate mDate; Incidence *mIncidence; }; class KOMonthView; class MonthViewCell : public QWidget { Q_OBJECT public: - MonthViewCell( KOMonthView * ); + MonthViewCell(KOMonthView *,QWidget* ); void setDate( const QDate & ); QDate date() const; void setPrimary( bool ); bool isPrimary() const; void setHoliday( bool ); void setHoliday( const QString & ); void updateCell(); void startUpdateCell(); void finishUpdateCell(); void insertEvent(Event *); void insertTodo(Todo *); @@ -243,43 +244,50 @@ class KOMonthView: public KOEventView void selectDateWeekNum ( int ); void selectInternalWeekNum ( int ); void switchView(); void processSelectionChange(); signals: void nextMonth(); void prevMonth(); void showNavigator( bool ); void selectWeekNum ( int ); void showDaySignal( QDate ); protected: void resizeEvent(QResizeEvent *); void viewChanged(); void updateDayLabels(); private: + bool clPending; + QWidgetStack * mWidStack; + QWidget* mMonthView; + QWidget* mWeekView; bool mShowWeekView; bool updatePossible; int mDaysPerWeek; int mNumWeeks; int mNumCells; bool mWeekStartsMonday; bool mShowSatSunComp; void computeLayout(); void computeLayoutWeek(); QPtrVector<MonthViewCell> mCells; QPtrVector<QLabel> mDayLabels; QPtrVector<KOWeekButton> mWeekLabels; + QPtrVector<MonthViewCell> mCellsW; + QPtrVector<QLabel> mDayLabelsW; + QPtrVector<KOWeekButton> mWeekLabelsW; bool mShortDayLabels; int mWidthLongDayLabel; QDate mStartDate; MonthViewCell *mSelectedCell; KOEventPopupMenu *mContextMenu; void keyPressEvent ( QKeyEvent * ) ; }; #endif |