author | zecke <zecke> | 2003-05-14 14:41:47 (UTC) |
---|---|---|
committer | zecke <zecke> | 2003-05-14 14:41:47 (UTC) |
commit | cc794c5ba028bbf07fa280ed49bd0b8cfb745bd7 (patch) (side-by-side diff) | |
tree | a5496cd003388591cc4a5e323bb5c99646919b92 | |
parent | 3c4a67b8b8d3fb554c5259f9f5ca35c5c826b13c (diff) | |
download | opie-cc794c5ba028bbf07fa280ed49bd0b8cfb745bd7.zip opie-cc794c5ba028bbf07fa280ed49bd0b8cfb745bd7.tar.gz opie-cc794c5ba028bbf07fa280ed49bd0b8cfb745bd7.tar.bz2 |
move lastHitField stuff into OPIMRecord
-rw-r--r-- | libopie/pim/ocontact.cpp | 1 | ||||
-rw-r--r-- | libopie/pim/ocontact.h | 4 | ||||
-rw-r--r-- | libopie/pim/opimrecord.cpp | 8 | ||||
-rw-r--r-- | libopie/pim/opimrecord.h | 15 | ||||
-rw-r--r-- | libopie2/opiepim/core/opimrecord.cpp | 8 | ||||
-rw-r--r-- | libopie2/opiepim/core/opimrecord.h | 15 | ||||
-rw-r--r-- | libopie2/opiepim/ocontact.cpp | 1 | ||||
-rw-r--r-- | libopie2/opiepim/ocontact.h | 4 |
8 files changed, 44 insertions, 12 deletions
diff --git a/libopie/pim/ocontact.cpp b/libopie/pim/ocontact.cpp index aeb69ee..a7ca975 100644 --- a/libopie/pim/ocontact.cpp +++ b/libopie/pim/ocontact.cpp @@ -932,48 +932,49 @@ QStringList OContact::fields() Email address should be separated by ';'s. */ void OContact::setEmails( const QString &str ) { replace( Qtopia::Emails, str ); if ( str.isEmpty() ) setDefaultEmail( QString::null ); } /*! Sets the list of children for the contact to those contained in \a str. */ void OContact::setChildren( const QString &str ) { replace( Qtopia::Children, str ); } /*! \overload Returns TRUE if the contact matches the regular expression \a regexp. Otherwise returns FALSE. */ bool OContact::match( const QRegExp &r ) const { + setLastHitField( -1 ); bool match; match = false; QMap<int, QString>::ConstIterator it; for ( it = mMap.begin(); it != mMap.end(); ++it ) { if ( (*it).find( r ) > -1 ) { setLastHitField( it.key() ); match = true; break; } } return match; } QString OContact::toShortText() const { return ( fullName() ); } QString OContact::type() const { return QString::fromLatin1( "OContact" ); } // Definition is missing ! (se) diff --git a/libopie/pim/ocontact.h b/libopie/pim/ocontact.h index f79f0f3..dd2de17 100644 --- a/libopie/pim/ocontact.h +++ b/libopie/pim/ocontact.h @@ -193,52 +193,48 @@ public: // // custom // const QString &customField( const QString &key ) // { return find( Custom- + key ); } QString toRichText() const; QMap<int, QString> toMap() const; QString field( int key ) const { return find( key ); } void setUid( int i ); QString toShortText()const; QString OContact::type()const; QMap<QString,QString> OContact::toExtraMap() const; class QString OContact::recordField(int) const; // Why private ? (eilers,se) QString emailSeparator() const { return " "; } // the emails should be seperated by a comma void setEmails( const QString &v ); QString emails() const { return find( Qtopia::Emails ); } static int rtti(); - int lastHitField() const {return m_lastHitField;}; -protected: - mutable int m_lastHitField; - void setLastHitField(int i) const { m_lastHitField = i; }; private: // The XML-Backend needs some access to the private functions friend class OContactAccessBackend_XML; void insert( int key, const QString &value ); void replace( int key, const QString &value ); QString find( int key ) const; static QStringList fields(); void save( QString &buf ) const; QString displayAddress( const QString &street, const QString &city, const QString &state, const QString &zip, const QString &country ) const; QMap<int, QString> mMap; ContactPrivate *d; }; #endif diff --git a/libopie/pim/opimrecord.cpp b/libopie/pim/opimrecord.cpp index d45417a..9510357 100644 --- a/libopie/pim/opimrecord.cpp +++ b/libopie/pim/opimrecord.cpp @@ -1,50 +1,52 @@ #include <qarray.h> #include <qpe/categories.h> #include <qpe/categoryselect.h> #include "opimrecord.h" Qtopia::UidGen OPimRecord::m_uidGen( Qtopia::UidGen::Qtopia ); OPimRecord::OPimRecord( int uid ) : Qtopia::Record() { + m_lastHit = -1; setUid( uid ); } OPimRecord::~OPimRecord() { } OPimRecord::OPimRecord( const OPimRecord& rec ) : Qtopia::Record( rec ) { (*this) = rec; } OPimRecord &OPimRecord::operator=( const OPimRecord& rec) { Qtopia::Record::operator=( rec ); m_xrefman = rec.m_xrefman; + m_lastHit = rec.m_lastHit; return *this; } /* * category names */ QStringList OPimRecord::categoryNames( const QString& appname ) const { QStringList list; QArray<int> cats = categories(); Categories catDB; catDB.load( categoryFileName() ); for (uint i = 0; i < cats.count(); i++ ) { list << catDB.label( appname, cats[i] ); } return list; } void OPimRecord::setCategoryNames( const QStringList& ) { } void OPimRecord::addCategoryName( const QString& ) { Categories catDB; catDB.load( categoryFileName() ); @@ -143,24 +145,30 @@ bool OPimRecord::saveToStream( QDataStream& stream )const { } return true; } void OPimRecord::flush( const OPimXRefPartner& par, QDataStream& str ) const{ str << par.service(); str << par.uid(); str << par.field(); } OPimXRefPartner OPimRecord::partner( QDataStream& stream ) { OPimXRefPartner par; QString str; int i; stream >> str; 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; +} diff --git a/libopie/pim/opimrecord.h b/libopie/pim/opimrecord.h index 6e7c0da..494c78e 100644 --- a/libopie/pim/opimrecord.h +++ b/libopie/pim/opimrecord.h @@ -54,87 +54,98 @@ public: /** * if a Record isEmpty * it's empty if it's 0 */ virtual bool isEmpty()const; /** * toRichText summary */ virtual QString toRichText()const = 0; /** * a small one line summary */ virtual QString toShortText()const = 0; /** * the name of the Record */ virtual QString type()const = 0; /** * matches the Records the regular expression? */ - virtual bool match( const QString ®exp ) const - {return Qtopia::Record::match(QRegExp(regexp));}; + virtual bool match( const QString ®exp ) const + {setLastHitField( -1 ); + return Qtopia::Record::match(QRegExp(regexp));}; + + /** + * 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; /** * 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 */ virtual void setUid( int uid ); /* * used inside the Templates for casting * REIMPLEMENT in your .... */ static int rtti(); /** * some marshalling and de marshalling code * saves the OPimRecord * to and from a DataStream */ virtual bool loadFromStream(QDataStream& ); virtual bool saveToStream( QDataStream& stream )const; protected: + // need to be const cause it is called from const methods + mutable int m_lastHit; + void setLastHitField( int lastHit )const; Qtopia::UidGen &uidGen(); // QString crossToString()const; private: class OPimRecordPrivate; OPimRecordPrivate *d; OPimXRefManager m_xrefman; static Qtopia::UidGen m_uidGen; private: void flush( const OPimXRefPartner&, QDataStream& stream )const; OPimXRefPartner partner( QDataStream& ); }; #endif diff --git a/libopie2/opiepim/core/opimrecord.cpp b/libopie2/opiepim/core/opimrecord.cpp index d45417a..9510357 100644 --- a/libopie2/opiepim/core/opimrecord.cpp +++ b/libopie2/opiepim/core/opimrecord.cpp @@ -1,50 +1,52 @@ #include <qarray.h> #include <qpe/categories.h> #include <qpe/categoryselect.h> #include "opimrecord.h" Qtopia::UidGen OPimRecord::m_uidGen( Qtopia::UidGen::Qtopia ); OPimRecord::OPimRecord( int uid ) : Qtopia::Record() { + m_lastHit = -1; setUid( uid ); } OPimRecord::~OPimRecord() { } OPimRecord::OPimRecord( const OPimRecord& rec ) : Qtopia::Record( rec ) { (*this) = rec; } OPimRecord &OPimRecord::operator=( const OPimRecord& rec) { Qtopia::Record::operator=( rec ); m_xrefman = rec.m_xrefman; + m_lastHit = rec.m_lastHit; return *this; } /* * category names */ QStringList OPimRecord::categoryNames( const QString& appname ) const { QStringList list; QArray<int> cats = categories(); Categories catDB; catDB.load( categoryFileName() ); for (uint i = 0; i < cats.count(); i++ ) { list << catDB.label( appname, cats[i] ); } return list; } void OPimRecord::setCategoryNames( const QStringList& ) { } void OPimRecord::addCategoryName( const QString& ) { Categories catDB; catDB.load( categoryFileName() ); @@ -143,24 +145,30 @@ bool OPimRecord::saveToStream( QDataStream& stream )const { } return true; } void OPimRecord::flush( const OPimXRefPartner& par, QDataStream& str ) const{ str << par.service(); str << par.uid(); str << par.field(); } OPimXRefPartner OPimRecord::partner( QDataStream& stream ) { OPimXRefPartner par; QString str; int i; stream >> str; 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; +} diff --git a/libopie2/opiepim/core/opimrecord.h b/libopie2/opiepim/core/opimrecord.h index 6e7c0da..494c78e 100644 --- a/libopie2/opiepim/core/opimrecord.h +++ b/libopie2/opiepim/core/opimrecord.h @@ -54,87 +54,98 @@ public: /** * if a Record isEmpty * it's empty if it's 0 */ virtual bool isEmpty()const; /** * toRichText summary */ virtual QString toRichText()const = 0; /** * a small one line summary */ virtual QString toShortText()const = 0; /** * the name of the Record */ virtual QString type()const = 0; /** * matches the Records the regular expression? */ - virtual bool match( const QString ®exp ) const - {return Qtopia::Record::match(QRegExp(regexp));}; + virtual bool match( const QString ®exp ) const + {setLastHitField( -1 ); + return Qtopia::Record::match(QRegExp(regexp));}; + + /** + * 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; /** * 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 */ virtual void setUid( int uid ); /* * used inside the Templates for casting * REIMPLEMENT in your .... */ static int rtti(); /** * some marshalling and de marshalling code * saves the OPimRecord * to and from a DataStream */ virtual bool loadFromStream(QDataStream& ); virtual bool saveToStream( QDataStream& stream )const; protected: + // need to be const cause it is called from const methods + mutable int m_lastHit; + void setLastHitField( int lastHit )const; Qtopia::UidGen &uidGen(); // QString crossToString()const; private: class OPimRecordPrivate; OPimRecordPrivate *d; OPimXRefManager m_xrefman; static Qtopia::UidGen m_uidGen; private: void flush( const OPimXRefPartner&, QDataStream& stream )const; OPimXRefPartner partner( QDataStream& ); }; #endif diff --git a/libopie2/opiepim/ocontact.cpp b/libopie2/opiepim/ocontact.cpp index aeb69ee..a7ca975 100644 --- a/libopie2/opiepim/ocontact.cpp +++ b/libopie2/opiepim/ocontact.cpp @@ -932,48 +932,49 @@ QStringList OContact::fields() Email address should be separated by ';'s. */ void OContact::setEmails( const QString &str ) { replace( Qtopia::Emails, str ); if ( str.isEmpty() ) setDefaultEmail( QString::null ); } /*! Sets the list of children for the contact to those contained in \a str. */ void OContact::setChildren( const QString &str ) { replace( Qtopia::Children, str ); } /*! \overload Returns TRUE if the contact matches the regular expression \a regexp. Otherwise returns FALSE. */ bool OContact::match( const QRegExp &r ) const { + setLastHitField( -1 ); bool match; match = false; QMap<int, QString>::ConstIterator it; for ( it = mMap.begin(); it != mMap.end(); ++it ) { if ( (*it).find( r ) > -1 ) { setLastHitField( it.key() ); match = true; break; } } return match; } QString OContact::toShortText() const { return ( fullName() ); } QString OContact::type() const { return QString::fromLatin1( "OContact" ); } // Definition is missing ! (se) diff --git a/libopie2/opiepim/ocontact.h b/libopie2/opiepim/ocontact.h index f79f0f3..dd2de17 100644 --- a/libopie2/opiepim/ocontact.h +++ b/libopie2/opiepim/ocontact.h @@ -193,52 +193,48 @@ public: // // custom // const QString &customField( const QString &key ) // { return find( Custom- + key ); } QString toRichText() const; QMap<int, QString> toMap() const; QString field( int key ) const { return find( key ); } void setUid( int i ); QString toShortText()const; QString OContact::type()const; QMap<QString,QString> OContact::toExtraMap() const; class QString OContact::recordField(int) const; // Why private ? (eilers,se) QString emailSeparator() const { return " "; } // the emails should be seperated by a comma void setEmails( const QString &v ); QString emails() const { return find( Qtopia::Emails ); } static int rtti(); - int lastHitField() const {return m_lastHitField;}; -protected: - mutable int m_lastHitField; - void setLastHitField(int i) const { m_lastHitField = i; }; private: // The XML-Backend needs some access to the private functions friend class OContactAccessBackend_XML; void insert( int key, const QString &value ); void replace( int key, const QString &value ); QString find( int key ) const; static QStringList fields(); void save( QString &buf ) const; QString displayAddress( const QString &street, const QString &city, const QString &state, const QString &zip, const QString &country ) const; QMap<int, QString> mMap; ContactPrivate *d; }; #endif |