summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--korganizer/kolistview.cpp21
-rw-r--r--korganizer/kotodoviewitem.cpp14
-rw-r--r--libkcal/incidence.cpp13
-rw-r--r--libkcal/incidence.h2
-rw-r--r--libkcal/incidencebase.cpp13
-rw-r--r--libkcal/incidencebase.h2
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
@@ -120,54 +120,52 @@ bool ListItemVisitor::visit(Event *e)
mItem->setText(0,e->summary());
mItem->setText(1,start);
if ( e->doesFloat() )
mItem->setText(2,"---");
else
mItem->setText(2,e->dtStartTimeStr());
mItem->setText(3,end);
if ( e->doesFloat() )
mItem->setText(4,"---");
else
mItem->setText(4,e->dtEndTimeStr());
mItem->setText(5, e->durationText());
if ( e->isAlarmEnabled() ) {
mItem->setText(6,e->alarms().first()->offsetText() );
} else {
mItem->setText(6, i18n("No"));
}
mItem->setText(7, e->recurrenceText());
if( ! e->doesRecur() )
mItem->setSortKey( 7, "-" );
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);
t = e->doesFloat() ? QTime(0,0) : e->dtEnd().time();
key.sprintf("%04d%02d%02d%02d%02d",de.year(),de.month(),de.day(),t.hour(),t.minute());
mItem->setSortKey(3,key);
return true;
}
bool ListItemVisitor::visit(Todo *t)
{
mItem->setText(0,t->summary());
if ( t->isCompleted() ) {
mItem->setSortKey(0,"99"+ t->summary().left(10));
} else
mItem->setSortKey(0,QString::number( t->percentComplete()+1 )+ t->summary().left(10));
mItem->setPixmap( 0, *(sgListViewCompletedPix[t->percentComplete()/20]));
if (t->hasStartDate()) {
mItem->setText(1,t->dtStartDateStr());
if (t->doesFloat()) {
mItem->setText(2,"---");
} else {
mItem->setText(2,t->dtStartTimeStr());
@@ -179,105 +177,100 @@ bool ListItemVisitor::visit(Todo *t)
if ( t->isAlarmEnabled() ) {
mItem->setText(6,t->alarms().first()->offsetText() );
} else {
mItem->setText(6, i18n("No"));
}
mItem->setText(7, t->recurrenceText());
if( ! t->doesRecur() )
mItem->setSortKey( 7, "-" );
if (t->hasDueDate()) {
mItem->setText(3,t->dtDueDateStr());
if (t->doesFloat()) {
mItem->setText(4,"---");
} else {
mItem->setText(4,t->dtDueTimeStr());
}
} else {
mItem->setText(3,"---");
mItem->setText(4,"---");
}
mItem->setText(5, t->durationText());
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());
mItem->setSortKey(3,key);
}
if ( t->hasStartDate() ) {
d = t->dtStart().date();
tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time();
key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute());
mItem->setSortKey(1,key);
}
return true;
}
bool ListItemVisitor::visit(Journal * j)
{
QString des;
mItem->setPixmap( 0, *sgListViewJournalPix);
if ( !j->summary().isEmpty() ) {
des = j->summary();
} else {
des = j->description().left(30);
des = des.simplifyWhiteSpace ();
des.replace (QRegExp ("\\n"),"" );
des.replace (QRegExp ("\\r"),"" );
}
mItem->setText(0,des.left(25));
mItem->setSortKey(0,"0"+ des.left(25));
mItem->setText(1,j->dtStartDateStr());
mItem->setText(2,"---");
mItem->setText(3,"---");
mItem->setText(4,"---");
mItem->setText(5,"---");
mItem->setText(6,"---");
mItem->setText(7,"---");
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,
const char *name)
: KOEventView(calendar, parent, name)
{
mActiveItem = 0;
mForceShowCompletedTodos = false;
mListView = new KOListViewListView(this);
mListView->addColumn(i18n("Summary"));
mListView->addColumn(i18n("Start Date"));
mListView->addColumn(i18n("Start Time"));
mListView->addColumn(i18n("End/Due Date"));
mListView->addColumn(i18n("End/Due Time"));
mListView->addColumn(i18n("Duration"));
mListView->addColumn(i18n("Alarm")); // alarm set?
mListView->addColumn(i18n("Recurs")); // recurs?
mListView->addColumn(i18n("Cancelled"));
mListView->addColumn(i18n("Categories"));
mListView->addColumn(i18n("Calendar"));
mListView->addColumn(i18n("Last Modified"));
diff --git a/korganizer/kotodoviewitem.cpp b/korganizer/kotodoviewitem.cpp
index bdef94c..848e9e7 100644
--- a/korganizer/kotodoviewitem.cpp
+++ b/korganizer/kotodoviewitem.cpp
@@ -98,101 +98,95 @@ void KOTodoViewItem::construct()
if (mTodo->hasDueDate()) {
setText(3, mTodo->dtDueDateStr());
QDate d = mTodo->dtDue().date();
keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
// setSortKey(3,keyd);
if (mTodo->doesFloat()) {
setText(4,"");
}
else {
setText(4,mTodo->dtDueTimeStr());
QTime t = mTodo->dtDue().time();
keyt.sprintf("%02d%02d",t.hour(),t.minute());
//setSortKey(4,keyt);
}
} else {
setText(3,"");
setText(4,"");
}
setSortKey(3,keyd);
setSortKey(4,keyt);
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() ) {
QDate d = mTodo->runStart().date();
QTime t = mTodo->runStart().time();
skeyt.sprintf("%02d%02d",t.hour(),t.minute());
skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
keyd = KGlobal::locale()->formatDate( d , true);
keyt = KGlobal::locale()->formatTime( t );
} else {
if (mTodo->hasStartDate()) {
keyd = mTodo->dtStartDateStr();
QDate d = mTodo->dtStart().date();
skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
if ( !mTodo->doesFloat()) {
keyt = mTodo->dtStartTimeStr();
QTime t = mTodo->dtStart().time();
skeyt.sprintf("%02d%02d",t.hour(),t.minute());
}
}
}
setText(5,keyd);
setText(6,keyt);
setSortKey(5,skeyd);
setSortKey(6,skeyt);
//setText(7,mTodo->cancelled() ? i18n("Yes") : i18n("No"));
setText(7,mTodo->categoriesStr());
setText(8,KOPrefs::instance()->calName( mTodo->calID()));
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
// of sort id.
int pos = mTodo->description().findRev('#');
if (pos < 0) {
setText(6,"");
} else {
QString str = mTodo->description().mid(pos+1);
str.stripWhiteSpace();
setText(6,str);
}
#endif
m_known = false;
m_init = false;
setMyPixmap();
}
void KOTodoViewItem::setMyPixmap()
{
int size = 5;
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp
index 39c14f5..fe9f854 100644
--- a/libkcal/incidence.cpp
+++ b/libkcal/incidence.cpp
@@ -321,61 +321,74 @@ void Incidence::cloneRelations( Incidence * newInc )
{
// newInc is already a clone of this incidence
Incidence * inc;
Incidence * cloneInc;
QPtrList<Incidence> Relations = relations();
for (inc=Relations.first();inc;inc=Relations.next()) {
cloneInc = inc->clone();
cloneInc->recreate();
cloneInc->setRelatedTo( newInc );
inc->cloneRelations( cloneInc );
}
}
void Incidence::setReadOnly( bool readOnly )
{
IncidenceBase::setReadOnly( readOnly );
if ( mRecurrence )
mRecurrence->setRecurReadOnly( readOnly);
}
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();
if ( mLastModifiedSub.isValid() )
return mLastModifiedSub;
mLastModifiedSub = lastModified();
Incidence * inc;
QPtrList<Incidence> Relations = relations();
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)
{
if (mReadOnly) return;
mCreated = getEvenTime(created);
}
QDateTime Incidence::created() const
{
return mCreated;
}
void Incidence::setRevision(int rev)
{
if (mReadOnly) return;
mRevision = rev;
updated();
}
int Incidence::revision() const
{
return mRevision;
diff --git a/libkcal/incidence.h b/libkcal/incidence.h
index eef9e64..dc49640 100644
--- a/libkcal/incidence.h
+++ b/libkcal/incidence.h
@@ -258,61 +258,63 @@ class Incidence : public IncidenceBase
ushort doesRecur() const;
/** set the event's/todo's location. Do _not_ use it with journal */
void setLocation(const QString &location);
/** return the event's/todo's location. Do _not_ use it with journal */
QString location() const;
/** returns TRUE or FALSE depending on whether the todo has a start date */
bool hasStartDate() const;
/** sets the event's hasStartDate value. */
void setHasStartDate(bool f);
QDateTime getNextOccurence( const QDateTime& dt, bool* yes ) const;
bool cancelled() const;
void setCancelled( bool b );
bool hasRecurrenceID() const;
void setHasRecurrenceID( bool b );
void setRecurrenceID(QDateTime);
QDateTime recurrenceID () const;
QDateTime dtStart() const;
bool isHoliday() const;
bool isBirthday() const;
bool isAnniversary() const;
QDateTime lastModifiedSub();
+ QString lastModifiedSubSortKey() const;
QString recurrenceText() const;
void setLastModifiedSubInvalid();
virtual QString durationText();
QString durationText4Time( int secs );
Recurrence *mRecurrence;
protected:
QPtrList<Alarm> mAlarms;
QPtrList<Incidence> mRelations;
QDateTime mRecurrenceID;
bool mHasRecurrenceID;
private:
void checkCategories();
+ QString mLastModifiedSubSortKey;
bool mHoliday, mBirthday, mAnniversary;
int mRevision;
bool mCancelled;
// base components of jounal, event and todo
QDateTime mCreated;
QDateTime mLastModifiedSub;
QString mDescription;
QString mSummary;
QStringList mCategories;
Incidence *mRelatedTo;
QString mRelatedToUid;
DateList mExDates;
QPtrList<Attachment> mAttachments;
QStringList mResources;
bool mHasStartDate; // if todo has associated start date
int mSecrecy;
int mPriority; // 1 = highest, 2 = less, etc.
//QPtrList<Alarm> mAlarms;
QString mLocation;
};
diff --git a/libkcal/incidencebase.cpp b/libkcal/incidencebase.cpp
index 022dead..cfef973 100644
--- a/libkcal/incidencebase.cpp
+++ b/libkcal/incidencebase.cpp
@@ -172,59 +172,70 @@ bool IncidenceBase::calEnabled() const
}
void IncidenceBase::setAlarmEnabled( bool b )
{
mAlarmEnabled = b;
}
bool IncidenceBase::alarmEnabled() const
{
return mAlarmEnabled;
}
void IncidenceBase::setUid(const QString &uid)
{
mUid = uid;
updated();
}
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;
}
void IncidenceBase::setOrganizer(const QString &o)
{
// we don't check for readonly here, because it is
// possible that by setting the organizer we are changing
// the event's readonly status...
mOrganizer = o;
if (mOrganizer.left(7).upper() == "MAILTO:")
mOrganizer = mOrganizer.remove(0,7);
updated();
}
QString IncidenceBase::organizer() const
{
return mOrganizer;
}
void IncidenceBase::setReadOnly( bool readOnly )
diff --git a/libkcal/incidencebase.h b/libkcal/incidencebase.h
index 665c1f6..444d4c4 100644
--- a/libkcal/incidencebase.h
+++ b/libkcal/incidencebase.h
@@ -42,48 +42,49 @@ typedef QValueList<QDate> DateList;
class IncidenceBase : public CustomProperties
{
public:
class Observer {
public:
virtual void incidenceUpdated( IncidenceBase * ) = 0;
};
IncidenceBase();
IncidenceBase(const IncidenceBase &);
virtual ~IncidenceBase();
virtual QCString type() const = 0;
virtual IncTypeID typeID() const = 0;
/** Set the unique id for the event */
void setUid(const QString &);
/** Return the unique id for the event */
QString uid() const;
/** 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;
/** Set readonly status. */
virtual void setReadOnly( bool );
/** Return if the object is read-only. */
bool isReadOnly() const { return mReadOnly; }
/** for setting the event's starting date/time with a QDateTime. */
virtual void setDtStart(const QDateTime &dtStart);
/** returns an event's starting date/time as a QDateTime. */
virtual QDateTime dtStart() const;
/** returns an event's starting time as a string formatted according to the
users locale settings */
QString dtStartTimeStr() const;
/** returns an event's starting date as a string formatted according to the
users locale settings */
QString dtStartDateStr(bool shortfmt=true) const;
/** returns an event's starting date and time as a string formatted according
to the users locale settings */
QString dtStartStr(bool shortfmt=true) const;
@@ -139,48 +140,49 @@ class IncidenceBase : public CustomProperties
void removeID(const QString &);
void registerObserver( Observer * );
void unRegisterObserver( Observer * );
void updated();
void setCalID( int id );
int calID() const;
void setCalEnabled( bool );
bool calEnabled() const;
void setAlarmEnabled( bool );
bool alarmEnabled() const;
bool isTagged() const;
void setTagged( bool );
virtual void setLastModifiedSubInvalid();
protected:
bool blockLastModified;
bool mIsTagged;
QDateTime mDtStart;
bool mReadOnly;
QDateTime getEvenTime( QDateTime );
private:
// base components
QString mOrganizer;
+ QString mLastModifiedKey;
QString mUid;
int mCalID;
bool mCalEnabled;
bool mAlarmEnabled;
QDateTime mLastModified;
QPtrList<Attendee> mAttendees;
bool mFloats;
int mDuration;
bool mHasDuration;
QString mExternalId;
int mTempSyncStat;
// PILOT SYNCHRONIZATION STUFF
int mPilotId; // unique id for pilot sync
int mSyncStatus; // status (for sync)
QPtrList<Observer> mObservers;
};
bool operator==( const IncidenceBase&, const IncidenceBase& );
}