author | zecke <zecke> | 2003-06-20 15:40:07 (UTC) |
---|---|---|
committer | zecke <zecke> | 2003-06-20 15:40:07 (UTC) |
commit | ec80e207cce9ebb55be771603fc47a4e7892fd6c (patch) (side-by-side diff) | |
tree | 0ec055e15a0ca1ec9ff0e9c674ecbcca389acbf4 /libopie2 | |
parent | c57f817ceca0eff0f6f3e90ad01654252911c1c5 (diff) | |
download | opie-ec80e207cce9ebb55be771603fc47a4e7892fd6c.zip opie-ec80e207cce9ebb55be771603fc47a4e7892fd6c.tar.gz opie-ec80e207cce9ebb55be771603fc47a4e7892fd6c.tar.bz2 |
toExtraMap is no more virtual
we save custom entries now
setExtraMap added as well
-rw-r--r-- | libopie2/opiepim/backend/otodoaccessxml.cpp | 23 | ||||
-rw-r--r-- | libopie2/opiepim/core/opimrecord.cpp | 6 | ||||
-rw-r--r-- | libopie2/opiepim/core/opimrecord.h | 8 | ||||
-rw-r--r-- | libopie2/opiepim/ocontact.cpp | 10 | ||||
-rw-r--r-- | libopie2/opiepim/oevent.cpp | 11 | ||||
-rw-r--r-- | libopie2/opiepim/oevent.h | 1 | ||||
-rw-r--r-- | libopie2/opiepim/otodo.cpp | 13 | ||||
-rw-r--r-- | libopie2/opiepim/otodo.h | 1 |
8 files changed, 47 insertions, 26 deletions
diff --git a/libopie2/opiepim/backend/otodoaccessxml.cpp b/libopie2/opiepim/backend/otodoaccessxml.cpp index 2b62f0d..3d15354 100644 --- a/libopie2/opiepim/backend/otodoaccessxml.cpp +++ b/libopie2/opiepim/backend/otodoaccessxml.cpp @@ -484,35 +484,57 @@ void OTodoAccessXML::todo( QAsciiDict<int>* dict, OTodo& ev, recur()->setDays( val.toInt() ); break; case FRPosition: recur()->setPosition( val.toInt() ); break; case FRFreq: recur()->setFrequency( val.toInt() ); break; case FRHasEndDate: recur()->setHasEndDate( val.toInt() ); break; case FREndDate: { rp_end = (time_t) val.toLong(); break; } default: + ev.setCustomField( attr, val ); break; } } + +// from PalmtopRecord... GPL ### FIXME +namespace { +QString customToXml(const QMap<QString, QString>& customMap ) +{ + //qWarning(QString("writing custom %1").arg(customMap.count())); + QString buf(" "); + for ( QMap<QString, QString>::ConstIterator cit = customMap.begin(); + cit != customMap.end(); ++cit) { +// qWarning(".ITEM."); + buf += cit.key(); + buf += "=\""; + buf += Qtopia::escapeString(cit.data()); + buf += "\" "; + } + return buf; +} + + +} + QString OTodoAccessXML::toString( const OTodo& ev )const { QString str; str += "Completed=\"" + QString::number( ev.isCompleted() ) + "\" "; str += "HasDate=\"" + QString::number( ev.hasDueDate() ) + "\" "; str += "Priority=\"" + QString::number( ev.priority() ) + "\" "; str += "Progress=\"" + QString::number(ev.progress() ) + "\" "; str += "Categories=\"" + toString( ev.categories() ) + "\" "; str += "Description=\"" + Qtopia::escapeString( ev.description() ) + "\" "; str += "Summary=\"" + Qtopia::escapeString( ev.summary() ) + "\" "; if ( ev.hasDueDate() ) { str += "DateYear=\"" + QString::number( ev.dueDate().year() ) + "\" "; str += "DateMonth=\"" + QString::number( ev.dueDate().month() ) + "\" "; str += "DateDay=\"" + QString::number( ev.dueDate().day() ) + "\" "; @@ -568,32 +590,33 @@ QString OTodoAccessXML::toString( const OTodo& ev )const { str += "Alarms=\""+als.join(";") +"\" "; } /* * now the same for reminders but more easy. We just save the uid of the OEvent. */ OPimNotifyManager::Reminders reminders = manager.reminders(); if (!reminders.isEmpty() ) { OPimNotifyManager::Reminders::Iterator it = reminders.begin(); QStringList records; for ( ; it != reminders.end(); ++it ) { records << QString::number( (*it).recordUid() ); } str += "Reminders=\""+ records.join(";") +"\" "; } } + str += customToXml( ev.toExtraMap() ); return str; } QString OTodoAccessXML::toString( const QArray<int>& ints ) const { return Qtopia::Record::idsToString( ints ); } /* internal class for sorting * * Inspired by todoxmlio.cpp from TT */ struct OTodoXMLContainer { OTodo todo; }; diff --git a/libopie2/opiepim/core/opimrecord.cpp b/libopie2/opiepim/core/opimrecord.cpp index 0c9734d..2365748 100644 --- a/libopie2/opiepim/core/opimrecord.cpp +++ b/libopie2/opiepim/core/opimrecord.cpp @@ -161,16 +161,22 @@ OPimXRefPartner OPimRecord::partner( QDataStream& stream ) { par.setService( str ); stream >> i; par.setUid( i ); stream >> i ; par.setField( i ); return par; } void OPimRecord::setLastHitField( int lastHit )const { m_lastHit = lastHit; } int OPimRecord::lastHitField()const{ return m_lastHit; } +QMap<QString, QString> OPimRecord::toExtraMap()const { + return customMap; +} +void OPimRecord::setExtraMap( const QMap<QString, QString>& map) { + customMap = map; +} diff --git a/libopie2/opiepim/core/opimrecord.h b/libopie2/opiepim/core/opimrecord.h index 494c78e..563b19c 100644 --- a/libopie2/opiepim/core/opimrecord.h +++ b/libopie2/opiepim/core/opimrecord.h @@ -1,25 +1,30 @@ #ifndef OPIE_PIM_RECORD_H #define OPIE_PIM_RECORD_H #include <qdatastream.h> #include <qmap.h> #include <qstring.h> #include <qstringlist.h> +/* + * we need to get customMap which is private... + */ +#define private protected #include <qpe/palmtoprecord.h> +#undef private #include <opie/opimxrefmanager.h> /** * This is the base class for * all PIM Records * */ class OPimRecord : public Qtopia::Record { public: /** * c'tor * uid of 0 isEmpty * uid of 1 will be assigned a new one */ OPimRecord(int uid = 0); @@ -81,33 +86,34 @@ public: /** * if implemented this function returns which item has been * last hit by the match() function. * or -1 if not implemented or no hit has occured */ int lastHitField()const; /** * converts the internal structure to a map */ virtual QMap<int, QString> toMap()const = 0; /** * key value representation of extra items */ - virtual QMap<QString, QString> toExtraMap()const = 0; + QMap<QString, QString> toExtraMap()const; + void setExtraMap( const QMap<QString, QString>& ); /** * the name for a recordField */ virtual QString recordField(int)const = 0; /** * returns a reference of the * Cross Reference Manager * Partner 'One' is THIS PIM RECORD! * 'Two' is the Partner where we link to */ OPimXRefManager& xrefmanager(); /** * set the uid diff --git a/libopie2/opiepim/ocontact.cpp b/libopie2/opiepim/ocontact.cpp index a2fb68c..be4ce0a 100644 --- a/libopie2/opiepim/ocontact.cpp +++ b/libopie2/opiepim/ocontact.cpp @@ -428,33 +428,33 @@ QMap<int, QString> OContact::toMap() const return map; } /*! Returns a rich text formatted QString representing the contents the contact. */ QString OContact::toRichText() const { QString text; QString value, comp, state; QString str; bool marker = false; // name, jobtitle and company if ( !(value = fullName()).isEmpty() ) text += "<b><h3><img src=\"addressbook/AddressBook\">" + Qtopia::escapeString(value) + "</h3></b>"; - + if ( !(value = jobTitle()).isEmpty() ) text += Qtopia::escapeString(value) + "<br>"; comp = company(); if ( !(value = department()).isEmpty() ) { text += Qtopia::escapeString(value); if ( comp ) text += ", "; else text += "<br>"; } if ( !comp.isEmpty() ) text += Qtopia::escapeString(comp) + "<br>"; text += "<hr><br>"; @@ -969,39 +969,33 @@ bool OContact::match( const QRegExp &r ) const break; } } return match; } QString OContact::toShortText() const { return ( fullName() ); } QString OContact::type() const { return QString::fromLatin1( "OContact" ); } -// Definition is missing ! (se) -QMap<QString,QString> OContact::toExtraMap() const -{ - qWarning ("Function not implemented: OContact::toExtraMap()"); - QMap <QString,QString> useless; - return useless; -} + class QString OContact::recordField( int pos ) const { QStringList SLFIELDS = fields(); // ?? why this ? (se) return SLFIELDS[pos]; } // In future releases, we should store birthday and anniversary // internally as QDate instead of QString ! // QString is always too complicate to interprete (DD.MM.YY, DD/MM/YY, MM/DD/YY, etc..)(se) /*! \fn void OContact::setBirthday( const QDate& date ) Sets the birthday for the contact to \a date. If date is null the current stored date will be removed. */ void OContact::setBirthday( const QDate &v ) diff --git a/libopie2/opiepim/oevent.cpp b/libopie2/opiepim/oevent.cpp index e4f5d92..7bcf944 100644 --- a/libopie2/opiepim/oevent.cpp +++ b/libopie2/opiepim/oevent.cpp @@ -223,78 +223,78 @@ bool OEvent::match( const QRegExp& re )const { if ( re.match( data->location ) != -1 ){ setLastHitField( Qtopia::Location ); return true; } if ( re.match( data->start.toString() ) != -1 ){ setLastHitField( Qtopia::StartDateTime ); return true; } if ( re.match( data->end.toString() ) != -1 ){ setLastHitField( Qtopia::EndDateTime ); return true; } return false; } QString OEvent::toRichText()const { QString text, value; - + // description text += "<b><h3><img src=\"datebook/DateBook\">"; if ( !description().isEmpty() ) { text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "" ); } text += "</h3></b><br><hr><br>"; - + // location if ( !(value = location()).isEmpty() ) { text += "<b>" + QObject::tr( "Location:" ) + "</b> "; text += Qtopia::escapeString(value) + "<br>"; } // all day event if ( isAllDay() ) { text += "<b><i>" + QObject::tr( "This is an all day event" ) + "</i></b><br>"; } // multiple day event else if ( isMultipleDay () ) { text += "<b><i>" + QObject::tr( "This is a multiple day event" ) + "</i></b><br>"; } // start & end times else { // start time if ( startDateTime().isValid() ) { text += "<b>" + QObject::tr( "Start:") + "</b> "; text += Qtopia::escapeString(startDateTime().toString() ). replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; } // end time if ( endDateTime().isValid() ) { text += "<b>" + QObject::tr( "End:") + "</b> "; text += Qtopia::escapeString(endDateTime().toString() ). replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; } } - + // categories if ( categoryNames("Calendar").count() ){ text += "<b>" + QObject::tr( "Category:") + "</b> "; text += categoryNames("Calendar").join(", "); text += "<br>"; } - + //notes if ( !note().isEmpty() ) { text += "<b>" + QObject::tr( "Note:") + "</b><br>"; text += note(); // text += Qtopia::escapeString(note() ). // replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; } return text; } QString OEvent::toShortText()const { QString text; text += QString::number( startDateTime().date().day() ); text += "."; text += QString::number( startDateTime().date().month() ); text += "."; text += QString::number( startDateTime().date().year() ); @@ -347,35 +347,32 @@ void OEvent::changeOrModify() { d2->child->detach(); } data = d2; } } void OEvent::deref() { if ( data->deref() ) { delete data; data = 0; } } // FIXME QMap<int, QString> OEvent::toMap()const { return QMap<int, QString>(); } -QMap<QString, QString> OEvent::toExtraMap()const { - return QMap<QString, QString>(); -} int OEvent::parent()const { return data->parent; } void OEvent::setParent( int uid ) { changeOrModify(); data->parent = uid; } QArray<int> OEvent::children() const{ if (!data->child) return QArray<int>(); else return data->child->copy(); } void OEvent::setChildren( const QArray<int>& arr ) { changeOrModify(); if (data->child) delete data->child; diff --git a/libopie2/opiepim/oevent.h b/libopie2/opiepim/oevent.h index b696d81..30f442e 100644 --- a/libopie2/opiepim/oevent.h +++ b/libopie2/opiepim/oevent.h @@ -119,33 +119,32 @@ public: QArray<int> children()const; void setChildren( const QArray<int>& ); void addChild( int uid ); void removeChild( int uid ); /** return the parent OEvent */ int parent()const; void setParent( int uid ); /* needed reimp */ QString toRichText()const; QString toShortText()const; QString type()const; QMap<int, QString> toMap()const; - QMap<QString, QString> toExtraMap()const; QString recordField(int )const; static int rtti(); bool loadFromStream( QDataStream& ); bool saveToStream( QDataStream& )const; /* bool operator==( const OEvent& ); bool operator!=( const OEvent& ); bool operator<( const OEvent& ); bool operator<=( const OEvent& ); bool operator>( const OEvent& ); bool operator>=(const OEvent& ); */ private: inline void changeOrModify(); diff --git a/libopie2/opiepim/otodo.cpp b/libopie2/opiepim/otodo.cpp index c84eeeb..38b93f7 100644 --- a/libopie2/opiepim/otodo.cpp +++ b/libopie2/opiepim/otodo.cpp @@ -266,80 +266,80 @@ QString OTodo::toShortText() const { return summary(); } /*! Returns a richt text string */ QString OTodo::toRichText() const { QString text; QStringList catlist; // summary text += "<b><h3><img src=\"todo/TodoList\">"; if ( !summary().isEmpty() ) { text += Qtopia::escapeString(summary() ).replace(QRegExp( "[\n]"), "" ); } text += "</h3></b><br><hr><br>"; - + // description if( !description().isEmpty() ){ text += "<b>" + QObject::tr( "Description:" ) + "</b><br>"; text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "<br>" ) ; } // priority int priorityval = priority(); text += "<b>" + QObject::tr( "Priority:") +" </b><img src=\"todo/priority" + QString::number( priorityval ) + "\">"; // text += "<b>" + QObject::tr( "Priority:") +"</b><img src=\"todo/priority" + // QString::number( priority() ) + "\"><br>"; switch ( priorityval ) { case 1 : text += QObject::tr( "Very high" ); break; case 2 : text += QObject::tr( "High" ); break; case 3 : text += QObject::tr( "Normal" ); break; case 4 : text += QObject::tr( "Low" ); break; case 5 : text += QObject::tr( "Very low" ); break; }; text += "<br>"; - + // progress text += "<b>" + QObject::tr( "Progress:") + " </b>" + QString::number( progress() ) + " %<br>"; - + // due date if (hasDueDate() ){ QDate dd = dueDate(); int off = QDate::currentDate().daysTo( dd ); - + text += "<b>" + QObject::tr( "Deadline:" ) + " </b><font color=\""; if ( off < 0 ) text += "#FF0000"; else if ( off == 0 ) text += "#FFFF00"; else if ( off > 0 ) text += "#00FF00"; text += "\">" + dd.toString() + "</font><br>"; } - + // categories text += "<b>" + QObject::tr( "Category:") + "</b> "; text += categoryNames( "Todo List" ).join(", "); text += "<br>"; return text; } bool OTodo::hasNotifiers()const { if (!data->notifiers) return false; return !data->notifiers->isEmpty(); } OPimNotifyManager& OTodo::notifiers() { if (!data->notifiers ) data->notifiers = new OPimNotifyManager; return (*data->notifiers); } @@ -447,35 +447,32 @@ QMap<int, QString> OTodo::toMap() const { map.insert( Description, data->desc ); map.insert( Summary, data->sum ); map.insert( Priority, QString::number( data->priority ) ); map.insert( DateDay, QString::number( data->date.day() ) ); map.insert( DateMonth, QString::number( data->date.month() ) ); map.insert( DateYear, QString::number( data->date.year() ) ); map.insert( Progress, QString::number( data->prog ) ); // map.insert( CrossReference, crossToString() ); /* FIXME!!! map.insert( State, ); map.insert( Recurrence, ); map.insert( Reminders, ); map. */ return map; } -QMap<QString, QString> OTodo::toExtraMap()const { - return data->extra; -} /** * change or modify looks at the ref count and either * creates a new QShared Object or it can modify it * right in place */ void OTodo::changeOrModify() { if ( data->count != 1 ) { qWarning("changeOrModify"); data->deref(); OTodoData* d2 = new OTodoData(); copy(data, d2 ); data = d2; } } // WATCHOUT /* diff --git a/libopie2/opiepim/otodo.h b/libopie2/opiepim/otodo.h index 4d5ee36..f9a345a 100644 --- a/libopie2/opiepim/otodo.h +++ b/libopie2/opiepim/otodo.h @@ -180,33 +180,32 @@ public: */ /** * return a reference to our notifiers... */ OPimNotifyManager ¬ifiers(); /** * */ const OPimNotifyManager ¬ifiers()const; /** * reimplementations */ QString type()const; QString toShortText()const; - QMap<QString, QString> toExtraMap()const; QString recordField(int id )const; /** * toMap puts all data into the map. int relates * to ToDoEvent RecordFields enum */ QMap<int, QString> toMap()const; /** * Set if this Todo is completed */ void setCompleted(bool completed ); /** * set if this todo got an end data */ |