summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagenda.cpp11
-rw-r--r--korganizer/koagenda.h1
-rw-r--r--korganizer/koagendaitem.cpp34
-rw-r--r--korganizer/koagendaitem.h1
-rw-r--r--korganizer/koagendaview.cpp11
-rw-r--r--korganizer/koagendaview.h1
-rw-r--r--korganizer/koeventpopupmenu.cpp44
-rw-r--r--korganizer/koeventpopupmenu.h4
-rw-r--r--korganizer/koeventview.cpp1
-rw-r--r--korganizer/kolistview.cpp8
10 files changed, 89 insertions, 27 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp
index ce73168..f860f7d 100644
--- a/korganizer/koagenda.cpp
+++ b/korganizer/koagenda.cpp
@@ -405,13 +405,22 @@ void KOAgenda::popupMenu()
}
mLeftMouseDown = false;
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;
static int startY = 0;
int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 7 : 9 );
static bool blockMoving = true;
diff --git a/korganizer/koagenda.h b/korganizer/koagenda.h
index fb9983e..de6acac 100644
--- a/korganizer/koagenda.h
+++ b/korganizer/koagenda.h
@@ -124,12 +124,13 @@ class KOAgenda : public QScrollView
void printSelection();
void storePosition();
void restorePosition();
void setPopup( KOEventPopupMenu * p ) { mAllAgendaPopup = p; }
public slots:
+ void categoryChanged(Incidence * inc);
void slotClearSelection();
void popupMenu();
void newItem( int );
void moveChild( QWidget *, int, int );
void scrollUp();
void scrollDown();
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp
index a8e0678..a42d07b 100644
--- a/korganizer/koagendaitem.cpp
+++ b/korganizer/koagendaitem.cpp
@@ -94,40 +94,34 @@ QString KOAgendaItem::getWhatsThisText()
return KIncidenceFormatter::instance()->getFormattedText( mIncidence,
KOPrefs::instance()->mWTshowDetails,
KOPrefs::instance()->mWTshowCreated,
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<Todo*>(incidence))->isCompleted()) &&
- ((static_cast<Todo*>(incidence))->dtDue().date() <= QDate::currentDate()) ) ) {
- if ( (static_cast<Todo*>(incidence))->dtDue() < QDateTime::currentDateTime().date())
+ if ( (mIncidence->typeID() == todoID ) &&
+ ( !((static_cast<Todo*>(mIncidence))->isCompleted()) &&
+ ((static_cast<Todo*>(mIncidence))->dtDue().date() <= QDate::currentDate()) ) ) {
+ if ( (static_cast<Todo*>(mIncidence))->dtDue() < QDateTime::currentDateTime().date())
mBackgroundColor = KOPrefs::instance()->mTodoOverdueColor ;
else
mBackgroundColor = KOPrefs::instance()->mTodoDueTodayColor;
}
else {
QStringList categories = mIncidence->categories();
QString cat = categories.first();
if (cat.isEmpty()) {
- if ( (incidence->typeID() == todoID ) &&((static_cast<Todo*>(incidence))->isCompleted()) )
+ if ( (mIncidence->typeID() == todoID ) &&((static_cast<Todo*>(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<Todo*>(incidence))->isCompleted()) ) {
+ if ( (mIncidence->typeID() == todoID ) &&((static_cast<Todo*>(mIncidence))->isCompleted()) ) {
if ( mBackgroundColor == KOPrefs::instance()->mEventColor )
mBackgroundColor = KOPrefs::instance()->mTodoDoneColor;
}
}
}
@@ -138,12 +132,22 @@ void KOAgendaItem::init ( Incidence *incidence, QDate qd )
}
mColorGroup = QColorGroup( BackgroundColor.light(),
BackgroundColor.dark(),BackgroundColor.light(),
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);
setSubCell(0);
setSubCells(1);
setMultiItem(0,0,0);
diff --git a/korganizer/koagendaitem.h b/korganizer/koagendaitem.h
index d1b1940..dc2316a 100644
--- a/korganizer/koagendaitem.h
+++ b/korganizer/koagendaitem.h
@@ -106,12 +106,13 @@ class KOAgendaItem : public QWidget
static QPixmap * paintPixSel();
static QPixmap * paintPixAllday();
void updateItem();
void computeText();
void recreateIncidence();
bool checkLayout();
+ void initColor ();
public slots:
bool updateIcons( QPainter *, bool );
void select(bool=true);
protected:
void dragEnterEvent(QDragEnterEvent *e);
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index c851ab5..a42227c 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -471,12 +471,17 @@ KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) :
#endif
connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
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
mTimeLabels->setAgenda(mAgenda);
// Update widgets to reflect user preferences
@@ -585,13 +590,17 @@ void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld )
emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED );
else
emit incidenceChanged(incOld, KOGlobals::EVENTEDITED);
}
}
-
+void KOAgendaView::categoryChanged(Incidence * inc)
+{
+ mAgenda->categoryChanged( inc );
+ mAllDayAgenda->categoryChanged( inc );
+}
KOAgendaView::~KOAgendaView()
{
delete mAllAgendaPopup;
//delete mAllDayAgendaPopup;
delete KOAgendaItem::paintPix();
delete KOAgendaItem::paintPixSel();
diff --git a/korganizer/koagendaview.h b/korganizer/koagendaview.h
index cc953fc..a1cf308 100644
--- a/korganizer/koagendaview.h
+++ b/korganizer/koagendaview.h
@@ -236,12 +236,13 @@ class KOAgendaView : public KOEventView {
/**
Set the masks on the agenda widgets indicating, which days are holidays.
*/
void setHolidayMasks();
protected slots:
+ void categoryChanged( Incidence * );
void slotDaylabelClicked( int );
/** Update event belonging to agenda item */
void updateEventDates(KOAgendaItem *item, int mode = -1);
//void updateMovedTodo();
void updateEventIndicatorTop(int newY);
diff --git a/korganizer/koeventpopupmenu.cpp b/korganizer/koeventpopupmenu.cpp
index 17ef81e..90caaf4 100644
--- a/korganizer/koeventpopupmenu.cpp
+++ b/korganizer/koeventpopupmenu.cpp
@@ -27,14 +27,15 @@
#include <kdebug.h>
#include <kiconloader.h>
#include <libkcal/event.h>
#include "koeventpopupmenu.h"
+#include "koprefs.h"
-KOEventPopupMenu::KOEventPopupMenu()
+KOEventPopupMenu::KOEventPopupMenu(): QPopupMenu()
{
mCurrentIncidence = 0;
mHasAdditionalItems = false;
mSingleOnlyItems.append( insertItem (i18n("&Show"),this,SLOT(popupShow())));
@@ -49,27 +50,66 @@ KOEventPopupMenu::KOEventPopupMenu()
mEditOnlyItems.append(insertItem (i18n("&Beam..."),
this,SLOT(popupBeam())));
#endif
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<int>::Iterator it;
for( it = mEditOnlyItems.begin(); it != mEditOnlyItems.end(); ++it ) {
mSingleOnlyItems.append(*it);
}
+
}
void KOEventPopupMenu::enableDefault( bool enable )
{
isDisabled = !enable;
QValueList<int>::Iterator it;
for( it = mSingleOnlyItems.begin(); it != mSingleOnlyItems.end(); ++it ) {
setItemEnabled(*it,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;
if (mCurrentIncidence) {
// Enable/Disabled menu items only valid for editable events.
@@ -77,14 +117,12 @@ void KOEventPopupMenu::showIncidencePopup(Incidence *incidence)
QValueList<int>::Iterator it;
for( it = mEditOnlyItems.begin(); it != mEditOnlyItems.end(); ++it ) {
setItemEnabled(*it,!mCurrentIncidence->isReadOnly());
}
}
popup(QCursor::pos());
- } else {
- kdDebug() << "KOEventPopupMenu::showEventPopup(): No event selected" << endl;
}
}
void KOEventPopupMenu::addAdditionalItem(const QIconSet &icon,const QString &text,
const QObject *receiver, const char *member,
bool editOnly)
diff --git a/korganizer/koeventpopupmenu.h b/korganizer/koeventpopupmenu.h
index 8fb51fa..3d8b595 100644
--- a/korganizer/koeventpopupmenu.h
+++ b/korganizer/koeventpopupmenu.h
@@ -51,26 +51,30 @@ class KOEventPopupMenu : public QPopupMenu {
void popupEdit();
void popupDelete();
void popupClone();
void popupCancel();
void popupMove();
void popupBeam();
+ void fillCatPopup();
+ void computeCatPopup( int );
signals:
void editIncidenceSignal(Incidence *);
void showIncidenceSignal(Incidence *);
void deleteIncidenceSignal(Incidence *);
void cloneIncidenceSignal(Incidence *);
void cancelIncidenceSignal(Incidence *);
void moveIncidenceSignal(Incidence *);
void beamIncidenceSignal(Incidence *);
+ void categoryChanged( Incidence * );
private:
Incidence *mCurrentIncidence;
bool mHasAdditionalItems;
QValueList<int> mEditOnlyItems;
QValueList<int> 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
@@ -74,13 +74,12 @@ KOEventPopupMenu *KOEventView::eventPopup()
//---------------------------------------------------------------------------
void KOEventView::showIncidencePopup(QPopupMenu *popup,Incidence *event)
{
mCurrentIncidence = event;
if (event) popup->popup(QCursor::pos());
- else kdDebug() << "KOEventView::showEventPopup(): No event selected" << endl;
}
//---------------------------------------------------------------------------
void KOEventView::popupShow()
{
diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp
index 8f17e6e..43e1113 100644
--- a/korganizer/kolistview.cpp
+++ b/korganizer/kolistview.cpp
@@ -232,13 +232,13 @@ bool ListItemVisitor::visit(Journal * j)
mItem->setText(4,"---");
mItem->setText(5,"---");
mItem->setText(6,"---");
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;
QDate d = j->dtStart().date();
key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
mItem->setSortKey(1,key);
@@ -1008,22 +1008,18 @@ void KOListView::setStartDate(const QDate &start)
void KOListView::showDates(const QDate &start, const QDate &end)
{
clear();
mStartDate = start;
QDate date = start;
- QPtrList<Journal> 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();
}
void KOListView::addEvents(QPtrList<Event> eventList)