-rw-r--r-- | korganizer/kolistview.cpp | 10 | ||||
-rw-r--r-- | korganizer/kolistview.h | 1 | ||||
-rw-r--r-- | korganizer/komonthview.cpp | 35 | ||||
-rw-r--r-- | korganizer/komonthview.h | 4 |
4 files changed, 34 insertions, 16 deletions
diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp index 1b4397f..db3f802 100644 --- a/korganizer/kolistview.cpp +++ b/korganizer/kolistview.cpp @@ -319,16 +319,18 @@ KOListView::KOListView(Calendar *calendar, QWidget *parent, SLOT(setCat()),true); mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), i18n("Set alarm..."),this, SLOT(setAlarm()),true); QObject::connect(mCalPopup,SIGNAL(aboutToShow()),this, SLOT( populateCalPopup() )); QObject::connect(mCalPopup,SIGNAL(activated( int )),this, SLOT( setCalendar( int ) )); + QObject::connect(mPopupMenu,SIGNAL(categoryChanged( Incidence * )),this, + SLOT( catChanged( Incidence * ) )); QPopupMenu * exportPO = new QPopupMenu ( this ); mPopupMenu->insertItem( i18n("Export"), exportPO ); exportPO->insertItem( i18n("As iCal (ics) file..."),this, SLOT(saveToFile())); exportPO->insertItem( i18n("As vCal (vcs) file..."),this, SLOT(saveToFileVCS())); exportPO->insertItem( i18n("Journal/Details..."),this, SLOT(saveDescriptionToFile())); @@ -375,16 +377,24 @@ KOListView::~KOListView() delete mPopupMenu; #if QT_VERSION >= 0x030000 #else delete mKOListViewWhatsThis; #endif } +void KOListView::catChanged( Incidence* inc) +{ + KOListViewItem* item = getItemForEvent(inc); + if (item) { + ListItemVisitor v(item, mStartDate ); + inc->accept(v); + } +} QString KOListView::getWhatsThisText(QPoint p) { KOListViewItem* item = ( KOListViewItem* ) mListView->itemAt( p ); if ( item ) return KIncidenceFormatter::instance()->getFormattedText( item->data(), KOPrefs::instance()->mWTshowDetails, KOPrefs::instance()->mWTshowCreated, KOPrefs::instance()->mWTshowChanged); diff --git a/korganizer/kolistview.h b/korganizer/kolistview.h index a54b550..99d0561 100644 --- a/korganizer/kolistview.h +++ b/korganizer/kolistview.h @@ -289,16 +289,17 @@ class KOListView : public KOEventView void defaultItemAction(QListViewItem *item); void popupMenu(QListViewItem *item,const QPoint &,int); void setCalendar( int c ); void populateCalPopup(); protected slots: void processSelectionChange(QListViewItem *); + void catChanged( Incidence* ); protected: void writeToFile( bool iCal ); void addEvents(QPtrList<Event> eventList); void addIncidence(Incidence *); KOListViewItem *getItemForEvent(Incidence *event); private: 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() { diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h index a41eb54..4d62e9b 100644 --- a/korganizer/komonthview.h +++ b/korganizer/komonthview.h @@ -245,19 +245,20 @@ class KOMonthView: public KOEventView /** Returns number of currently shown dates. */ virtual int currentDateCount(); /** returns the currently selected events */ virtual QPtrList<Incidence> selectedIncidences(); /** returns dates of the currently selected events */ virtual DateList selectedDates(); - +#if 0 virtual void printPreview(CalPrinter *calPrinter, const QDate &, const QDate &); +#endif bool isMonthView() { return !mShowWeekView; } bool isUpdatePossible() { return updatePossible; } MonthViewCell * selectedCell(); bool skipResize; NavigatorBar* navigatorBar() { return mNavigatorBar ;} void clearList(); public slots: @@ -276,16 +277,17 @@ class KOMonthView: public KOEventView void showContextMenu( Incidence * ); void setSelectedCell( MonthViewCell * ); void setPopupCell( MonthViewCell * ); void switchView(); void setKeyBFocus(); protected slots: + void catChanged( Incidence * ); void setKeyBoardFocus(); void slotNewTodo(); void slotNewEvent(); void slotEditJournal(); void slotComputeLayout(); void selectInternalWeekNum ( int ); void processSelectionChange(); signals: |