From a7924287e231b461585c4121f6ee2ce32f955089 Mon Sep 17 00:00:00 2001 From: zautrix Date: Fri, 01 Jul 2005 06:04:54 +0000 Subject: fixxx --- diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp index ce73168..f860f7d 100644 --- a/korganizer/koagenda.cpp +++ b/korganizer/koagenda.cpp @@ -408,7 +408,16 @@ void KOAgenda::popupMenu() mPopupItem = 0; mPopupKind = 0; } - +void KOAgenda::categoryChanged(Incidence * inc) +{ + KOAgendaItem *item; + for ( item=mItems.first(); item != 0; item=mItems.next() ) { + if ( item->incidence() == inc ) { + item->initColor (); + item->updateItem(); + } + } +} bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) { static int startX = 0; diff --git a/korganizer/koagenda.h b/korganizer/koagenda.h index fb9983e..de6acac 100644 --- a/korganizer/koagenda.h +++ b/korganizer/koagenda.h @@ -127,6 +127,7 @@ class KOAgenda : public QScrollView void setPopup( KOEventPopupMenu * p ) { mAllAgendaPopup = p; } public slots: + void categoryChanged(Incidence * inc); void slotClearSelection(); void popupMenu(); void newItem( int ); diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp index a8e0678..a42d07b 100644 --- a/korganizer/koagendaitem.cpp +++ b/korganizer/koagendaitem.cpp @@ -97,19 +97,13 @@ QString KOAgendaItem::getWhatsThisText() KOPrefs::instance()->mWTshowChanged); return "KOAgendaItem::getWhatsThisText()::internal error"; } -void KOAgendaItem::init ( Incidence *incidence, QDate qd ) + +void KOAgendaItem::initColor () { - mIncidence = incidence; - mDate = qd; - mFirstMultiItem = 0; - mNextMultiItem = 0; - mLastMultiItem = 0; - computeText(); - - if ( (incidence->typeID() == todoID ) && - ( !((static_cast(incidence))->isCompleted()) && - ((static_cast(incidence))->dtDue().date() <= QDate::currentDate()) ) ) { - if ( (static_cast(incidence))->dtDue() < QDateTime::currentDateTime().date()) + if ( (mIncidence->typeID() == todoID ) && + ( !((static_cast(mIncidence))->isCompleted()) && + ((static_cast(mIncidence))->dtDue().date() <= QDate::currentDate()) ) ) { + if ( (static_cast(mIncidence))->dtDue() < QDateTime::currentDateTime().date()) mBackgroundColor = KOPrefs::instance()->mTodoOverdueColor ; else mBackgroundColor = KOPrefs::instance()->mTodoDueTodayColor; @@ -118,13 +112,13 @@ void KOAgendaItem::init ( Incidence *incidence, QDate qd ) QStringList categories = mIncidence->categories(); QString cat = categories.first(); if (cat.isEmpty()) { - if ( (incidence->typeID() == todoID ) &&((static_cast(incidence))->isCompleted()) ) + if ( (mIncidence->typeID() == todoID ) &&((static_cast(mIncidence))->isCompleted()) ) mBackgroundColor =KOPrefs::instance()->mTodoDoneColor; else - mBackgroundColor =KOPrefs::instance()->defaultColor( incidence->calID() ); + mBackgroundColor =KOPrefs::instance()->defaultColor( mIncidence->calID() ); } else { mBackgroundColor = *KOPrefs::instance()->categoryColor(cat); - if ( (incidence->typeID() == todoID ) &&((static_cast(incidence))->isCompleted()) ) { + if ( (mIncidence->typeID() == todoID ) &&((static_cast(mIncidence))->isCompleted()) ) { if ( mBackgroundColor == KOPrefs::instance()->mEventColor ) mBackgroundColor = KOPrefs::instance()->mTodoDoneColor; } @@ -141,6 +135,16 @@ void KOAgendaItem::init ( Incidence *incidence, QDate qd ) BackgroundColor.dark(),BackgroundColor, black, BackgroundColor) ; setBackgroundColor( mBackgroundColor ); mWhiteText = (mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue() < 250); +} +void KOAgendaItem::init ( Incidence *incidence, QDate qd ) +{ + mIncidence = incidence; + mDate = qd; + mFirstMultiItem = 0; + mNextMultiItem = 0; + mLastMultiItem = 0; + computeText(); + initColor(); mConflictItems.clear(); setCellXY(0,0,1); setCellXWidth(0); diff --git a/korganizer/koagendaitem.h b/korganizer/koagendaitem.h index d1b1940..dc2316a 100644 --- a/korganizer/koagendaitem.h +++ b/korganizer/koagendaitem.h @@ -109,6 +109,7 @@ class KOAgendaItem : public QWidget void computeText(); void recreateIncidence(); bool checkLayout(); + void initColor (); public slots: bool updateIcons( QPainter *, bool ); void select(bool=true); diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp index c851ab5..a42227c 100644 --- a/korganizer/koagendaview.cpp +++ b/korganizer/koagendaview.cpp @@ -474,6 +474,11 @@ KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *))); + + connect(mAllAgendaPopup,SIGNAL(categoryChanged(Incidence *)), + this,SLOT(categoryChanged(Incidence *))); + + mAgenda->setPopup( mAllAgendaPopup ); mAllDayAgenda->setPopup( mAllAgendaPopup ); // make connections between dependent widgets @@ -588,7 +593,11 @@ void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) } } - +void KOAgendaView::categoryChanged(Incidence * inc) +{ + mAgenda->categoryChanged( inc ); + mAllDayAgenda->categoryChanged( inc ); +} KOAgendaView::~KOAgendaView() { delete mAllAgendaPopup; diff --git a/korganizer/koagendaview.h b/korganizer/koagendaview.h index cc953fc..a1cf308 100644 --- a/korganizer/koagendaview.h +++ b/korganizer/koagendaview.h @@ -239,6 +239,7 @@ class KOAgendaView : public KOEventView { void setHolidayMasks(); protected slots: + void categoryChanged( Incidence * ); void slotDaylabelClicked( int ); /** Update event belonging to agenda item */ void updateEventDates(KOAgendaItem *item, int mode = -1); diff --git a/korganizer/koeventpopupmenu.cpp b/korganizer/koeventpopupmenu.cpp index 17ef81e..90caaf4 100644 --- a/korganizer/koeventpopupmenu.cpp +++ b/korganizer/koeventpopupmenu.cpp @@ -30,8 +30,9 @@ #include #include "koeventpopupmenu.h" +#include "koprefs.h" -KOEventPopupMenu::KOEventPopupMenu() +KOEventPopupMenu::KOEventPopupMenu(): QPopupMenu() { mCurrentIncidence = 0; mHasAdditionalItems = false; @@ -52,10 +53,16 @@ KOEventPopupMenu::KOEventPopupMenu() mEditOnlyItems.append(insertItem (i18n("&Toggle Cancel"), this,SLOT(popupCancel()))); isDisabled = false; + mCatPopup = new QPopupMenu ( this ); + mCatPopup->setCheckable (true); + connect(mCatPopup,SIGNAL( aboutToShow ()), this ,SLOT( fillCatPopup())); + connect(mCatPopup,SIGNAL( activated ( int ) ), this ,SLOT( computeCatPopup( int ))); + mEditOnlyItems.append(insertItem (i18n("Categories"),mCatPopup )); QValueList::Iterator it; for( it = mEditOnlyItems.begin(); it != mEditOnlyItems.end(); ++it ) { mSingleOnlyItems.append(*it); } + } void KOEventPopupMenu::enableDefault( bool enable ) { @@ -67,6 +74,39 @@ void KOEventPopupMenu::enableDefault( bool enable ) } +void KOEventPopupMenu::fillCatPopup() +{ + mCatPopup->clear(); + QStringList checkedCategories = mCurrentIncidence->categories(); + int index = 0; + for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); + it != KOPrefs::instance()->mCustomCategories.end (); + ++it) { + mCatPopup->insertItem (*it, index ); + if (checkedCategories.find (*it) != checkedCategories.end ()) { + mCatPopup->setItemChecked (index, true); + } + ++index; + } +} +void KOEventPopupMenu::computeCatPopup( int index ) +{ + QStringList categories = mCurrentIncidence->categories(); + QString colcat = categories.first(); + if (categories.find (KOPrefs::instance()->mCustomCategories[index]) != categories.end ()) + categories.remove (KOPrefs::instance()->mCustomCategories[index]); + else + categories.insert (categories.end(), KOPrefs::instance()->mCustomCategories[index]); + categories.sort (); + if ( !colcat.isEmpty() ) { + if ( categories.find ( colcat ) != categories.end () ) { + categories.remove( colcat ); + categories.prepend( colcat ); + } + } + mCurrentIncidence->setCategories( categories ); + emit categoryChanged( mCurrentIncidence ); +} void KOEventPopupMenu::showIncidencePopup(Incidence *incidence) { mCurrentIncidence = incidence; @@ -80,8 +120,6 @@ void KOEventPopupMenu::showIncidencePopup(Incidence *incidence) } } popup(QCursor::pos()); - } else { - kdDebug() << "KOEventPopupMenu::showEventPopup(): No event selected" << endl; } } diff --git a/korganizer/koeventpopupmenu.h b/korganizer/koeventpopupmenu.h index 8fb51fa..3d8b595 100644 --- a/korganizer/koeventpopupmenu.h +++ b/korganizer/koeventpopupmenu.h @@ -54,6 +54,8 @@ class KOEventPopupMenu : public QPopupMenu { void popupCancel(); void popupMove(); void popupBeam(); + void fillCatPopup(); + void computeCatPopup( int ); signals: void editIncidenceSignal(Incidence *); @@ -63,6 +65,7 @@ class KOEventPopupMenu : public QPopupMenu { void cancelIncidenceSignal(Incidence *); void moveIncidenceSignal(Incidence *); void beamIncidenceSignal(Incidence *); + void categoryChanged( Incidence * ); private: Incidence *mCurrentIncidence; @@ -71,6 +74,7 @@ class KOEventPopupMenu : public QPopupMenu { QValueList mEditOnlyItems; QValueList mSingleOnlyItems; bool isDisabled; + QPopupMenu *mCatPopup; }; #endif diff --git a/korganizer/koeventview.cpp b/korganizer/koeventview.cpp index bce2626..1d26930 100644 --- a/korganizer/koeventview.cpp +++ b/korganizer/koeventview.cpp @@ -77,7 +77,6 @@ void KOEventView::showIncidencePopup(QPopupMenu *popup,Incidence *event) { mCurrentIncidence = event; if (event) popup->popup(QCursor::pos()); - else kdDebug() << "KOEventView::showEventPopup(): No event selected" << endl; } //--------------------------------------------------------------------------- diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp index 8f17e6e..43e1113 100644 --- a/korganizer/kolistview.cpp +++ b/korganizer/kolistview.cpp @@ -235,7 +235,7 @@ bool ListItemVisitor::visit(Journal * j) mItem->setText(7,j->dtStartDateStr()); mItem->setText(8,"---"); mItem->setText(9,"---"); - mItem->setText(10,i18n("Last Modified: ")+ KGlobal::locale()->formatDateTime( j->lastModified() , true) ); + mItem->setText(10,j->categoriesStr()); mItem->setText(11, KOPrefs::instance()->calName( j->calID() )); QString key; @@ -1011,16 +1011,12 @@ void KOListView::showDates(const QDate &start, const QDate &end) clear(); mStartDate = start; QDate date = start; - QPtrList j_list; while( date <= end ) { addEvents(calendar()->events(date)); addTodos(calendar()->todos(date)); - Journal* jo = calendar()->journal(date); - if ( jo ) - j_list.append( jo ); + addJournals( calendar()->journals4Date(date) ); date = date.addDays( 1 ); } - addJournals(j_list); emit incidenceSelected( 0 ); updateView(); -- cgit v0.9.0.2