-rw-r--r-- | korganizer/komonthview.cpp | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index 4fc447e..2289977 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp @@ -197,17 +197,17 @@ void KNoScrollListBox::keyPressEvent(QKeyEvent *e) } break; case Key_Down: if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { e->ignore(); break; } if ( count () ) { - if ( currentItem()+1 == count () ) { + if ( ((uint)currentItem()+1) == count () ) { emit nextCell(); } else { setCurrentItem((currentItem()+1)%count()); if(!itemVisible(currentItem())) { if(currentItem() == 0) { setTopItem(0); } else { setTopItem(topItem()+1); @@ -238,17 +238,17 @@ void KNoScrollListBox::keyPressEvent(QKeyEvent *e) e->ignore(); break; } } void KNoScrollListBox::oneDown() { if ( count () ) { - if ( currentItem()+1 == count () ) { + if ( ((uint)currentItem()+1) == count () ) { emit nextCell(); } else { resetOnFocusIn = false; setCurrentItem((currentItem()+1)%count()); if(!itemVisible(currentItem())) { if(currentItem() == 0) { setTopItem(0); } else { @@ -1287,16 +1287,18 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) SLOT(slotNewEvent()),false); mContextMenu->addAdditionalItem(QIconSet(QPixmap()), i18n("New Todo..."),this, SLOT(slotNewTodo()),false); mContextMenu->addAdditionalItem(QIconSet(QPixmap()), i18n("Journal"),this, SLOT(slotEditJournal()),false); + connect (mContextMenu ,SIGNAL(categoryChanged( Incidence * )),this, + SLOT( catChanged( Incidence * ) )); QString pathString = ""; if ( !KOPrefs::instance()->mToolBarMiniIcons ) { if ( QApplication::desktop()->width() < 480 ) pathString += "icons16/"; } else pathString += "iconsmini/"; @@ -1343,29 +1345,33 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) mWidStack->raiseWidget( mMonthView ); } KOMonthView::~KOMonthView() { delete mContextMenu; } +void KOMonthView::catChanged( Incidence * ) +{ + updateView(); +} void KOMonthView::incidenceHighlighted( Incidence * inc , MonthViewCell* mc, int mday ) { static Incidence * lastInc = 0; static MonthViewCell * lastCell = 0; if ( lastInc == inc && lastCell == mc ) return; lastInc = inc; lastCell = mc; //qDebug("KOMonthView::incidenceHighlighted %d %d %d", inc, mc, mday ); bool weekview = false; - int index = 0; + uint index = 0; for (uint i = 0; i < mCellsW.count(); ++i) { if ( mCellsW[i] == mc ) { weekview = true; index = i; break; } } QPtrVector<MonthViewCell> *cells; @@ -1381,30 +1387,30 @@ void KOMonthView::incidenceHighlighted( Incidence * inc , MonthViewCell* mc, int cells = &mCells; } for (uint i = 0; i < (*cells).count(); ++i) { (*cells)[i]->deHighLight(); } if ( ! inc ) return; - int count = (*cells).count(); + uint count = (*cells).count(); bool goLeft = (mday > 1 && index > 0); bool goRight = (mday < 3 && mday > 0 && index < count -1); for (uint iii = 1; iii < count; ++iii) { if ( goLeft ) { int left = index - iii; if ( left >= 0 ) { if ( (*cells)[(uint)left]->doHighLight(inc) ) goLeft = false; } else goLeft = false; } if ( goRight ) { - int right = index + iii; + uint right = index + iii; if ( right < count ) { if ( (*cells)[right]->doHighLight(inc) ) goRight = false; } else goRight = false; } @@ -1484,25 +1490,25 @@ DateList KOMonthView::selectedDates() if ( mSelectedCell ) { QDate qd = mSelectedCell->selectedIncidenceDate(); if ( qd.isValid() ) selected.append( qd ); } return selected; } - +#if 0 void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, const QDate &td) { #ifndef KORG_NOPRINTER calPrinter->preview(CalPrinter::Month, fd, td); #endif } - +#endif void KOMonthView::updateConfig() { int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { mWeekStartsMonday = true; } @@ -1578,17 +1584,17 @@ void KOMonthView::clearList() } 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; + uint weekNum = 6; mStartDate = start; if ( mShowWeekView ) { weekNum = 1; cells = &mCellsW; dayLabels = &mDayLabelsW; weekLabels = &mWeekLabelsW; if ( !KGlobal::locale()->weekStartsMonday() ) { mStartDate = mStartDate.addDays( 1 ); @@ -1604,17 +1610,16 @@ void KOMonthView::showDates(const QDate &start, const QDate &) if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { mWeekStartsMonday = true; } 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 < (*cells).size(); ++i ) { QDate date = mStartDate.addDays( i ); (*cells)[i]->setDate( date ); #ifndef KORG_NOPLUGINS // add holiday, if present QString hstring(KOCore::self()->holiday(date)); @@ -1674,17 +1679,16 @@ void KOMonthView::updateView() timeSpan = 6; for( i = 0; i < timeSpan + 1; ++i ) { (*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; @@ -1806,16 +1810,17 @@ void KOMonthView::setKeyBFocus() void KOMonthView::resizeEvent(QResizeEvent * e) { //qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height()); if ( isVisible() ) { //qDebug("KOMonthView::isVisible "); slotComputeLayout(); } else mComputeLayoutTimer->start( 100 ); + KOEventView::resizeEvent( e ); } void KOMonthView::slotComputeLayout() { mComputeLayoutTimer->stop(); //qDebug("KOMonthView::Post - resizeEvent %d %d ", width(), height() ); computeLayout(); clPending = true; @@ -1856,17 +1861,16 @@ void KOMonthView::computeLayoutWeek() combinedSatSun = true; //qDebug("KOMonthView::computeLayout() WWW ------------------------------------ "); QFontMetrics fm ( mWeekLabels[0]->font() ); int weeklabelwid = fm.width( "888" ); wid -= weeklabelwid; int colWid = wid / daysToShow; - int lastCol = wid - ( colWid*6 ); 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; @@ -1900,17 +1904,18 @@ void KOMonthView::computeLayoutWeek() } x += w; } x= 0; y= dayLabelHei; w = colWid; h = cellHei; int max = 0; - for ( i = 0; i < mCellsW.count(); ++i) { + int w_count = mCellsW.count(); + for ( i = 0; i < w_count; ++i) { if ( i > 6 ) { mCellsW[i]->hide(); continue; } w = colWid; if ( ((i) % daysToShow) >= daysToShow-colModulo ) { ++w; @@ -1992,17 +1997,16 @@ void KOMonthView::computeLayout() lastWid = width(); lastHei = height(); //qDebug("KOMonthView::computeLayout() MMM ------------------- "); 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 - dayLabelHei) /6; int colModulo = wid % daysToShow; int rowModulo = (hei- dayLabelHei) % 6; //qDebug("rowmod %d ", rowModulo); int i; int x,y,w,h; x= 0; @@ -2027,17 +2031,18 @@ void KOMonthView::computeLayout() mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); x += w; } x= 0; y= dayLabelHei; w = colWid; h = cellHei ; int max = 0; - for ( i = 0; i < mCells.count(); ++i) { + int mc_count = mCells.count(); + for ( i = 0; i < mc_count; ++i) { //qDebug("iii %d ", i); w = colWid; if ( ((i) % 7) >= 7-colModulo ) { ++w; } if ( i == (6-rowModulo)*7) ++h; if ( combinedSatSun ) { @@ -2205,17 +2210,17 @@ void KOMonthView::keyPressEvent ( QKeyEvent * e ) default: e->ignore(); break; } } void KOMonthView::nextCell() { - bool res = focusNextPrevChild ( true ); + focusNextPrevChild ( true ); } void KOMonthView::prevCell() { focusNextPrevChild ( false ); } void KOMonthView::slotNewTodo() { |