summaryrefslogtreecommitdiff
path: root/libopie2/opiepim
Side-by-side diff
Diffstat (limited to 'libopie2/opiepim') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/core/opimrecord.cpp8
-rw-r--r--libopie2/opiepim/core/opimrecord.h15
-rw-r--r--libopie2/opiepim/ocontact.cpp1
-rw-r--r--libopie2/opiepim/ocontact.h4
4 files changed, 22 insertions, 6 deletions
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
@@ -8,12 +8,13 @@
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 )
@@ -21,12 +22,13 @@ OPimRecord::OPimRecord( const OPimRecord& 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
*/
@@ -161,6 +163,12 @@ OPimXRefPartner OPimRecord::partner( QDataStream& stream ) {
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
@@ -72,14 +72,22 @@ public:
*/
virtual QString type()const = 0;
/**
* matches the Records the regular expression?
*/
- virtual bool match( const QString &regexp ) const
- {return Qtopia::Record::match(QRegExp(regexp));};
+ virtual bool match( const QString &regexp ) 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;
@@ -118,12 +126,15 @@ public:
* 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;
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
@@ -950,12 +950,13 @@ void OContact::setChildren( const QString &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() );
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
@@ -211,16 +211,12 @@ public:
// 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 );