-rw-r--r-- | korganizer/kolistview.cpp | 21 | ||||
-rw-r--r-- | korganizer/kotodoviewitem.cpp | 14 | ||||
-rw-r--r-- | libkcal/incidence.cpp | 13 | ||||
-rw-r--r-- | libkcal/incidence.h | 2 | ||||
-rw-r--r-- | libkcal/incidencebase.cpp | 13 | ||||
-rw-r--r-- | libkcal/incidencebase.h | 2 |
6 files changed, 40 insertions, 25 deletions
diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp index b236c2d..4fc1194 100644 --- a/korganizer/kolistview.cpp +++ b/korganizer/kolistview.cpp @@ -140,14 +140,12 @@ bool ListItemVisitor::visit(Event *e) mItem->setText(8, e->cancelled() ? i18n("Yes") : i18n("No")); mItem->setText(9,e->categoriesStr()); mItem->setText(10, KOPrefs::instance()->calName( e->calID() )); mItem->setText(11, KGlobal::locale()->formatDateTime( e->lastModified(), true, true )); + mItem->setSortKey(11,e->lastModifiedSortKey()); QString key; - QDate d = e->lastModified().date(); - QTime t = e->lastModified().time(); - key.sprintf("%04d%02d%02d%02d%02d%02d",d.year(),d.month(),d.day(),t.hour(),t.minute(),t.second() ); - mItem->setSortKey(12,key); + QTime t; t = e->doesFloat() ? QTime(0,0) : e->dtStart().time(); key.sprintf("%04d%02d%02d%02d%02d",ds.year(),ds.month(),ds.day(),t.hour(),t.minute()); mItem->setSortKey(1,key); @@ -199,13 +197,12 @@ bool ListItemVisitor::visit(Todo *t) mItem->setText(8, t->cancelled() ? i18n("Yes") : i18n("No")); mItem->setText(9,t->categoriesStr()); mItem->setText(10, KOPrefs::instance()->calName( t->calID() )); mItem->setText(11, KGlobal::locale()->formatDateTime( t->lastModified(), true, true )); + mItem->setSortKey(11,t->lastModifiedSortKey()); QString key; - QDate d = t->lastModified().date(); - QTime tm = t->lastModified().time(); - key.sprintf("%04d%02d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute(),tm.second() ); - mItem->setSortKey(11,key); + QDate d; + QTime tm; if (t->hasDueDate()) { d = t->dtDue().date(); tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time(); key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); @@ -245,19 +242,15 @@ bool ListItemVisitor::visit(Journal * j) mItem->setText(8,"---"); mItem->setText(9,j->categoriesStr()); mItem->setText(10, KOPrefs::instance()->calName( j->calID() )); mItem->setText(11, KGlobal::locale()->formatDateTime( j->lastModified(), true, true )); + mItem->setSortKey(11,j->lastModifiedSortKey()); QString key; - QDate d = j->lastModified().date(); - QTime tm = j->lastModified().time(); - key.sprintf("%04d%02d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute(),tm.second() ); - mItem->setSortKey(12,key); + QDate d; d = j->dtStart().date(); key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); mItem->setSortKey(1,key); - mItem->setSortKey(7,key); - return true; } KOListView::KOListView(Calendar *calendar, QWidget *parent, diff --git a/korganizer/kotodoviewitem.cpp b/korganizer/kotodoviewitem.cpp index bdef94c..848e9e7 100644 --- a/korganizer/kotodoviewitem.cpp +++ b/korganizer/kotodoviewitem.cpp @@ -118,10 +118,8 @@ void KOTodoViewItem::construct() if (mTodo->isCompleted()) setSortKey(1,"6" + QString::number(mTodo->priority())+keyd+keyt); else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt); - - keyd = ""; keyt = ""; if (mTodo->isRunning() ) { @@ -159,20 +157,16 @@ void KOTodoViewItem::construct() setText(9, KGlobal::locale()->formatDateTime( mTodo->lastModified(), true, true )); setText(10, KGlobal::locale()->formatDateTime( mTodo->created(), true, true )); setText(11, KGlobal::locale()->formatDateTime( mTodo->lastModifiedSub(), true, true )); QString key; - QDate d = mTodo->lastModified().date(); - QTime t = mTodo->lastModified().time(); - key.sprintf("%04d%02d%02d%02d%02d%02d",d.year(),d.month(),d.day(),t.hour(),t.minute(),t.second() ); - setSortKey(9,key); + QDate d; + QTime t; + setSortKey(9,mTodo->lastModifiedSortKey()); d = mTodo->created().date(); t = mTodo->created().time(); key.sprintf("%04d%02d%02d%02d%02d%02d",d.year(),d.month(),d.day(),t.hour(),t.minute(),t.second() ); setSortKey(10,key); - d = mTodo->lastModifiedSub().date(); - t = mTodo->lastModifiedSub().time(); - key.sprintf("%04d%02d%02d%02d%02d%02d",d.year(),d.month(),d.day(),t.hour(),t.minute(),t.second() ); - setSortKey(11,key); + setSortKey(11,mTodo->lastModifiedSubSortKey()); #if 0 // Find sort id in description. It's the text behind the last '#' character // found in the description. White spaces are removed from beginning and end diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp index 39c14f5..fe9f854 100644 --- a/libkcal/incidence.cpp +++ b/libkcal/incidence.cpp @@ -341,8 +341,14 @@ void Incidence::setLastModifiedSubInvalid() mLastModifiedSub = QDateTime(); if ( mRelatedTo ) mRelatedTo->setLastModifiedSubInvalid(); } +QString Incidence::lastModifiedSubSortKey() const +{ + if ( mLastModifiedSubSortKey.isEmpty() ) + return lastModifiedSortKey(); + return mLastModifiedSubSortKey; +} QDateTime Incidence::lastModifiedSub() { if ( !mRelations.count() ) return lastModified(); @@ -354,8 +360,15 @@ QDateTime Incidence::lastModifiedSub() for (inc=Relations.first();inc;inc=Relations.next()) { if ( inc->lastModifiedSub() > mLastModifiedSub ) mLastModifiedSub = inc->lastModifiedSub(); } + mLastModifiedSubSortKey.sprintf("%04d%02d%02d%02d%02d%02d", + mLastModifiedSub.date().year(), + mLastModifiedSub.date().month(), + mLastModifiedSub.date().day(), + mLastModifiedSub.time().hour(), + mLastModifiedSub.time().minute(), + mLastModifiedSub.time().second() ); return mLastModifiedSub; } void Incidence::setCreated(QDateTime created) { diff --git a/libkcal/incidence.h b/libkcal/incidence.h index eef9e64..dc49640 100644 --- a/libkcal/incidence.h +++ b/libkcal/incidence.h @@ -278,8 +278,9 @@ class Incidence : public IncidenceBase bool isHoliday() const; bool isBirthday() const; bool isAnniversary() const; QDateTime lastModifiedSub(); + QString lastModifiedSubSortKey() const; QString recurrenceText() const; void setLastModifiedSubInvalid(); virtual QString durationText(); @@ -291,8 +292,9 @@ protected: QDateTime mRecurrenceID; bool mHasRecurrenceID; private: void checkCategories(); + QString mLastModifiedSubSortKey; bool mHoliday, mBirthday, mAnniversary; int mRevision; bool mCancelled; diff --git a/libkcal/incidencebase.cpp b/libkcal/incidencebase.cpp index 022dead..cfef973 100644 --- a/libkcal/incidencebase.cpp +++ b/libkcal/incidencebase.cpp @@ -192,19 +192,30 @@ QString IncidenceBase::uid() const return mUid; } void IncidenceBase::setLastModifiedSubInvalid() { - + // virtual method } void IncidenceBase::setLastModified(const QDateTime &lm) { if ( blockLastModified ) return; // DON'T! updated() because we call this from // Calendar::updateEvent(). mLastModified = getEvenTime(lm); + mLastModifiedKey.sprintf("%04d%02d%02d%02d%02d%02d", + mLastModified.date().year(), + mLastModified.date().month(), + mLastModified.date().day(), + mLastModified.time().hour(), + mLastModified.time().minute(), + mLastModified.time().second() ); setLastModifiedSubInvalid(); //qDebug("IncidenceBase::setLastModified %s ",lm.toString().latin1()); } +QString IncidenceBase::lastModifiedSortKey() const +{ + return mLastModifiedKey; +} QDateTime IncidenceBase::lastModified() const { return mLastModified; diff --git a/libkcal/incidencebase.h b/libkcal/incidencebase.h index 665c1f6..444d4c4 100644 --- a/libkcal/incidencebase.h +++ b/libkcal/incidencebase.h @@ -62,8 +62,9 @@ class IncidenceBase : public CustomProperties /** Sets the time the incidence was last modified. */ void setLastModified(const QDateTime &lm); /** Return the time the incidence was last modified. */ QDateTime lastModified() const; + QString lastModifiedSortKey() const; /** sets the organizer for the event */ void setOrganizer(const QString &o); QString organizer() const; @@ -159,8 +160,9 @@ class IncidenceBase : public CustomProperties private: // base components QString mOrganizer; + QString mLastModifiedKey; QString mUid; int mCalID; bool mCalEnabled; bool mAlarmEnabled; |