summaryrefslogtreecommitdiff
authortille <tille>2003-05-08 13:55:09 (UTC)
committer tille <tille>2003-05-08 13:55:09 (UTC)
commit0cb4111d34d9fe96731f48983e1ff2e67262db02 (patch) (side-by-side diff)
treece6ec869ae7753ab0261e7ad075a10ad8b0a404b
parent78c60031b506b85dc20bd555d83486aeb831bf38 (diff)
downloadopie-0cb4111d34d9fe96731f48983e1ff2e67262db02.zip
opie-0cb4111d34d9fe96731f48983e1ff2e67262db02.tar.gz
opie-0cb4111d34d9fe96731f48983e1ff2e67262db02.tar.bz2
search stuff
and match, toRichText & toShortText in oevent
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/pim/ocontact.cpp9
-rw-r--r--libopie/pim/ocontact.h3
-rw-r--r--libopie/pim/ocontactaccess.cpp13
-rw-r--r--libopie/pim/ocontactaccess.h6
-rw-r--r--libopie/pim/odatebookaccessbackend_xml.cpp18
-rw-r--r--libopie/pim/odatebookaccessbackend_xml.h1
-rw-r--r--libopie/pim/oevent.cpp41
-rw-r--r--libopie/pim/oevent.h2
-rw-r--r--libopie/pim/opimaccessbackend.h6
-rw-r--r--libopie/pim/opimaccesstemplate.h12
-rw-r--r--libopie/pim/opimrecord.h6
-rw-r--r--libopie/pim/otodo.h2
-rw-r--r--libopie/pim/otodoaccessvcal.cpp4
-rw-r--r--libopie/pim/otodoaccessvcal.h1
-rw-r--r--libopie/pim/otodoaccessxml.cpp16
-rw-r--r--libopie/pim/otodoaccessxml.h1
-rw-r--r--libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp18
-rw-r--r--libopie2/opiepim/backend/odatebookaccessbackend_xml.h1
-rw-r--r--libopie2/opiepim/backend/opimaccessbackend.h6
-rw-r--r--libopie2/opiepim/backend/otodoaccessvcal.cpp4
-rw-r--r--libopie2/opiepim/backend/otodoaccessvcal.h1
-rw-r--r--libopie2/opiepim/backend/otodoaccessxml.cpp16
-rw-r--r--libopie2/opiepim/backend/otodoaccessxml.h1
-rw-r--r--libopie2/opiepim/core/ocontactaccess.cpp13
-rw-r--r--libopie2/opiepim/core/ocontactaccess.h6
-rw-r--r--libopie2/opiepim/core/opimaccesstemplate.h12
-rw-r--r--libopie2/opiepim/core/opimrecord.h6
-rw-r--r--libopie2/opiepim/ocontact.cpp9
-rw-r--r--libopie2/opiepim/ocontact.h3
-rw-r--r--libopie2/opiepim/oevent.cpp41
-rw-r--r--libopie2/opiepim/oevent.h2
-rw-r--r--libopie2/opiepim/otodo.h2
32 files changed, 228 insertions, 54 deletions
diff --git a/libopie/pim/ocontact.cpp b/libopie/pim/ocontact.cpp
index 96a5f65..a38b62b 100644
--- a/libopie/pim/ocontact.cpp
+++ b/libopie/pim/ocontact.cpp
@@ -947,15 +947,6 @@ void OContact::setChildren( const QString &str )
}
/*!
- Returns TRUE if the contact matches the regular expression \a regexp.
- Otherwise returns FALSE.
-*/
-bool OContact::match( const QString &regexp ) const
-{
- return match(QRegExp(regexp));
-}
-
-/*!
\overload
Returns TRUE if the contact matches the regular expression \a regexp.
Otherwise returns FALSE.
diff --git a/libopie/pim/ocontact.h b/libopie/pim/ocontact.h
index 50f6176..0e6cbd2 100644
--- a/libopie/pim/ocontact.h
+++ b/libopie/pim/ocontact.h
@@ -111,8 +111,7 @@ public:
// other
void setNotes( const QString &v ) { replace( Qtopia::Notes, v); }
- bool match( const QString &regexp ) const;
- bool match( const QRegExp &regexp ) const;
+ virtual bool match( const QRegExp &regexp ) const;
// // custom
// void setCustomField( const QString &key, const QString &v )
diff --git a/libopie/pim/ocontactaccess.cpp b/libopie/pim/ocontactaccess.cpp
index 9c9338e..2e3ec1f 100644
--- a/libopie/pim/ocontactaccess.cpp
+++ b/libopie/pim/ocontactaccess.cpp
@@ -21,6 +21,10 @@
* =====================================================================
* History:
* $Log$
+ * Revision 1.8 2003/05/08 13:55:09 tille
+ * search stuff
+ * and match, toRichText & toShortText in oevent
+ *
* Revision 1.7 2002/11/13 14:14:51 eilers
* Added sorted for Contacts..
*
@@ -73,7 +77,7 @@ OContactAccess::OContactAccess ( const QString appname, const QString ,
OContactAccessBackend* end, bool autosync ):
OPimAccessTemplate<OContact>( end )
{
- /* take care of the backend. If there is no one defined, we
+ /* take care of the backend. If there is no one defined, we
* will use the XML-Backend as default (until we have a cute SQL-Backend..).
*/
if( end == 0 ) {
@@ -83,7 +87,7 @@ OContactAccess::OContactAccess ( const QString appname, const QString ,
// Set backend locally and in template
m_backEnd = end;
OPimAccessTemplate<OContact>::setBackEnd (end);
-
+
/* Connect signal of external db change to function */
QCopChannel *dbchannel = new QCopChannel( "QPE/PIM", this );
@@ -126,11 +130,6 @@ bool OContactAccess::save ()
return true;
}
-ORecordList<OContact> OContactAccess::matchRegexp( const QRegExp &r ) const{
- QArray<int> matchingContacts = m_backEnd -> matchRegexp( r );
- return ( ORecordList<OContact>(matchingContacts, this) );
-}
-
const uint OContactAccess::querySettings()
{
return ( m_backEnd->querySettings() );
diff --git a/libopie/pim/ocontactaccess.h b/libopie/pim/ocontactaccess.h
index d7ceaf2..e90db32 100644
--- a/libopie/pim/ocontactaccess.h
+++ b/libopie/pim/ocontactaccess.h
@@ -17,6 +17,10 @@
* =====================================================================
* History:
* $Log$
+ * Revision 1.8 2003/05/08 13:55:09 tille
+ * search stuff
+ * and match, toRichText & toShortText in oevent
+ *
* Revision 1.7 2003/04/13 18:07:10 zecke
* More API doc
* QString -> const QString&
@@ -110,8 +114,6 @@ class OContactAccess: public QObject, public OPimAccessTemplate<OContact>
};
- ORecordList<OContact> matchRegexp( const QRegExp &r )const;
-
/** Return all Contacts in a sorted manner.
* @param ascending true: Sorted in acending order.
* @param sortOrder Currently not implemented. Just defined to stay compatible to otodoaccess
diff --git a/libopie/pim/odatebookaccessbackend_xml.cpp b/libopie/pim/odatebookaccessbackend_xml.cpp
index a0ae7b7..ab2eea4 100644
--- a/libopie/pim/odatebookaccessbackend_xml.cpp
+++ b/libopie/pim/odatebookaccessbackend_xml.cpp
@@ -586,3 +586,21 @@ void ODateBookAccessBackend_XML::setField( OEvent& e, int id, const QString& val
break;
}
}
+QArray<int> ODateBookAccessBackend_XML::matchRegexp( const QRegExp &r ) const
+{
+ QArray<int> m_currentQuery( m_raw.count()+ m_rep.count() );
+ uint arraycounter = 0;
+ QMap<int, OEvent>::ConstIterator it;
+
+ for ( it = m_raw.begin(); it != m_raw.end(); ++it )
+ if ( it.data().match( r ) )
+ m_currentQuery[arraycounter++] = it.data().uid();
+ for ( it = m_rep.begin(); it != m_rep.end(); ++it )
+ if ( it.data().match( r ) )
+ m_currentQuery[arraycounter++] = it.data().uid();
+
+ // Shrink to fit..
+ m_currentQuery.resize(arraycounter);
+
+ return m_currentQuery;
+}
diff --git a/libopie/pim/odatebookaccessbackend_xml.h b/libopie/pim/odatebookaccessbackend_xml.h
index 7848f7c..a5cc0fc 100644
--- a/libopie/pim/odatebookaccessbackend_xml.h
+++ b/libopie/pim/odatebookaccessbackend_xml.h
@@ -22,6 +22,7 @@ public:
bool save();
QArray<int> allRecords()const;
+ QArray<int> matchRegexp(const QRegExp &r) const;
QArray<int> queryByExample( const OEvent&, int, const QDateTime& d = QDateTime() );
OEvent find( int uid )const;
void clear();
diff --git a/libopie/pim/oevent.cpp b/libopie/pim/oevent.cpp
index 3ba8a52..28cf873 100644
--- a/libopie/pim/oevent.cpp
+++ b/libopie/pim/oevent.cpp
@@ -2,6 +2,7 @@
#include <qpe/palmtopuidgen.h>
#include <qpe/categories.h>
+#include <qpe/stringutil.h>
#include "orecur.h"
#include "opimresolver.h"
@@ -210,16 +211,46 @@ QString OEvent::timeZone()const {
if (data->isAllDay ) return QString::fromLatin1("UTC");
return data->timezone;
}
-bool OEvent::match( const QRegExp& )const {
- // FIXME
+bool OEvent::match( const QRegExp& re )const {
+ if (data->description.contains( re ) )
+ return true;
+ if ( data->note.contains( re ) )
+ return true;
+ if ( data->location.contains( re ) )
+ return true;
+ if ( data->start.toString().contains( re ) )
+ return true;
+ if ( data->end.toString().contains( re ) )
+ return true;
return false;
}
QString OEvent::toRichText()const {
- // FIXME
- return "OEvent test";
+ QString text;
+ if ( !description().isEmpty() ) {
+ text += "<b>" + QObject::tr( "Description:") + "</b><br>";
+ text += Qtopia::escapeString(description() ).
+ replace(QRegExp( "[\n]"), "<br>" ) + "<br>";
+ }
+ if ( startDateTime().isValid() ) {
+ text += "<b>" + QObject::tr( "Start:") + "</b> ";
+ text += Qtopia::escapeString(startDateTime().toString() ).
+ replace(QRegExp( "[\n]"), "<br>" ) + "<br>";
+ }
+ if ( endDateTime().isValid() ) {
+ text += "<b>" + QObject::tr( "End:") + "</b> ";
+ text += Qtopia::escapeString(endDateTime().toString() ).
+ replace(QRegExp( "[\n]"), "<br>" ) + "<br>";
+ }
+ 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 {
- return "OEvent shotText";
+ return description();
}
QString OEvent::type()const {
return QString::fromLatin1("OEvent");
diff --git a/libopie/pim/oevent.h b/libopie/pim/oevent.h
index 57d32d0..b696d81 100644
--- a/libopie/pim/oevent.h
+++ b/libopie/pim/oevent.h
@@ -113,7 +113,7 @@ public:
QString timeZone()const;
- bool match( const QRegExp& )const;
+ virtual bool match( const QRegExp& )const;
/** For exception to recurrence here is a list of children... */
QArray<int> children()const;
diff --git a/libopie/pim/opimaccessbackend.h b/libopie/pim/opimaccessbackend.h
index 01a0c86..f4bbe35 100644
--- a/libopie/pim/opimaccessbackend.h
+++ b/libopie/pim/opimaccessbackend.h
@@ -46,6 +46,12 @@ public:
*/
virtual QArray<int> allRecords()const = 0;
+ /**
+ * return a List of records
+ * that match the regex
+ */
+ virtual QArray<int> matchRegexp(const QRegExp &r) const = 0;
+
/**
* queryByExample for T with the given Settings
*
diff --git a/libopie/pim/opimaccesstemplate.h b/libopie/pim/opimaccesstemplate.h
index 6a3a0db..8ff205c 100644
--- a/libopie/pim/opimaccesstemplate.h
+++ b/libopie/pim/opimaccesstemplate.h
@@ -69,6 +69,12 @@ public:
* you can iterate over them
*/
virtual List allRecords()const;
+
+ /**
+ * return a List of records
+ * that match the regex
+ */
+ virtual List matchRegexp( const QRegExp &r ) const;
/**
* queryByExample.
@@ -181,6 +187,12 @@ typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::allRecords()const {
return lis;
}
template <class T>
+typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::matchRegexp( const QRegExp &r )const {
+ QArray<int> ints = m_backEnd->matchRegexp( r );
+ List lis(ints, this );
+ return lis;
+}
+template <class T>
QArray<int> OPimAccessTemplate<T>::records()const {
return m_backEnd->allRecords();
}
diff --git a/libopie/pim/opimrecord.h b/libopie/pim/opimrecord.h
index c7f9460..de2d9f4 100644
--- a/libopie/pim/opimrecord.h
+++ b/libopie/pim/opimrecord.h
@@ -73,6 +73,12 @@ public:
virtual QString type()const = 0;
/**
+ * matches the Records the regular expression?
+ */
+ virtual bool match( const QString &regexp ) const {return match(QRegExp(regexp));};
+ virtual bool match( const QRegExp &regexp ) const = 0;
+
+ /**
* converts the internal structure to a map
*/
virtual QMap<int, QString> toMap()const = 0;
diff --git a/libopie/pim/otodo.h b/libopie/pim/otodo.h
index a58d9aa..0e7c73f 100644
--- a/libopie/pim/otodo.h
+++ b/libopie/pim/otodo.h
@@ -258,7 +258,7 @@ public:
bool isOverdue();
- bool match( const QRegExp &r )const;
+ virtual bool match( const QRegExp &r )const;
bool operator<(const OTodo &toDoEvent )const;
bool operator<=(const OTodo &toDoEvent )const;
diff --git a/libopie/pim/otodoaccessvcal.cpp b/libopie/pim/otodoaccessvcal.cpp
index 9bc16c6..3577e14 100644
--- a/libopie/pim/otodoaccessvcal.cpp
+++ b/libopie/pim/otodoaccessvcal.cpp
@@ -185,6 +185,10 @@ QArray<int> OTodoAccessVCal::allRecords()const {
}
return ar;
}
+QArray<int> OTodoAccessVCal::matchRegexp(const QRegExp &r)const {
+ QArray<int> ar(0);
+ return ar;
+}
QArray<int> OTodoAccessVCal::queryByExample( const OTodo&, int, const QDateTime& ) {
QArray<int> ar(0);
return ar;
diff --git a/libopie/pim/otodoaccessvcal.h b/libopie/pim/otodoaccessvcal.h
index 489416b..2b17147 100644
--- a/libopie/pim/otodoaccessvcal.h
+++ b/libopie/pim/otodoaccessvcal.h
@@ -13,6 +13,7 @@ public:
bool save();
QArray<int> allRecords()const;
+ QArray<int> matchRegexp(const QRegExp &r) const;
QArray<int> queryByExample( const OTodo& t, int sort, const QDateTime& d = QDateTime() );
QArray<int> effectiveToDos( const QDate& start,
const QDate& end,
diff --git a/libopie/pim/otodoaccessxml.cpp b/libopie/pim/otodoaccessxml.cpp
index 285d2b8..69b7ab4 100644
--- a/libopie/pim/otodoaccessxml.cpp
+++ b/libopie/pim/otodoaccessxml.cpp
@@ -774,3 +774,19 @@ QBitArray OTodoAccessXML::sup() {
return ar;
}
+QArray<int> OTodoAccessXML::matchRegexp( const QRegExp &r ) const
+{
+ QArray<int> m_currentQuery( m_events.count() );
+ uint arraycounter = 0;
+
+ QMap<int, OTodo>::ConstIterator it;
+ for (it = m_events.begin(); it != m_events.end(); ++it ) {
+ if ( it.data().match( r ) )
+ m_currentQuery[arraycounter++] = it.data().uid();
+
+ }
+ // Shrink to fit..
+ m_currentQuery.resize(arraycounter);
+
+ return m_currentQuery;
+}
diff --git a/libopie/pim/otodoaccessxml.h b/libopie/pim/otodoaccessxml.h
index cc4a16f..e4850a1 100644
--- a/libopie/pim/otodoaccessxml.h
+++ b/libopie/pim/otodoaccessxml.h
@@ -24,6 +24,7 @@ public:
bool save();
QArray<int> allRecords()const;
+ QArray<int> matchRegexp(const QRegExp &r) const;
QArray<int> queryByExample( const OTodo&, int querysettings, const QDateTime& d = QDateTime() );
OTodo find( int uid )const;
void clear();
diff --git a/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp b/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp
index a0ae7b7..ab2eea4 100644
--- a/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp
+++ b/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp
@@ -586,3 +586,21 @@ void ODateBookAccessBackend_XML::setField( OEvent& e, int id, const QString& val
break;
}
}
+QArray<int> ODateBookAccessBackend_XML::matchRegexp( const QRegExp &r ) const
+{
+ QArray<int> m_currentQuery( m_raw.count()+ m_rep.count() );
+ uint arraycounter = 0;
+ QMap<int, OEvent>::ConstIterator it;
+
+ for ( it = m_raw.begin(); it != m_raw.end(); ++it )
+ if ( it.data().match( r ) )
+ m_currentQuery[arraycounter++] = it.data().uid();
+ for ( it = m_rep.begin(); it != m_rep.end(); ++it )
+ if ( it.data().match( r ) )
+ m_currentQuery[arraycounter++] = it.data().uid();
+
+ // Shrink to fit..
+ m_currentQuery.resize(arraycounter);
+
+ return m_currentQuery;
+}
diff --git a/libopie2/opiepim/backend/odatebookaccessbackend_xml.h b/libopie2/opiepim/backend/odatebookaccessbackend_xml.h
index 7848f7c..a5cc0fc 100644
--- a/libopie2/opiepim/backend/odatebookaccessbackend_xml.h
+++ b/libopie2/opiepim/backend/odatebookaccessbackend_xml.h
@@ -22,6 +22,7 @@ public:
bool save();
QArray<int> allRecords()const;
+ QArray<int> matchRegexp(const QRegExp &r) const;
QArray<int> queryByExample( const OEvent&, int, const QDateTime& d = QDateTime() );
OEvent find( int uid )const;
void clear();
diff --git a/libopie2/opiepim/backend/opimaccessbackend.h b/libopie2/opiepim/backend/opimaccessbackend.h
index 01a0c86..f4bbe35 100644
--- a/libopie2/opiepim/backend/opimaccessbackend.h
+++ b/libopie2/opiepim/backend/opimaccessbackend.h
@@ -46,6 +46,12 @@ public:
*/
virtual QArray<int> allRecords()const = 0;
+ /**
+ * return a List of records
+ * that match the regex
+ */
+ virtual QArray<int> matchRegexp(const QRegExp &r) const = 0;
+
/**
* queryByExample for T with the given Settings
*
diff --git a/libopie2/opiepim/backend/otodoaccessvcal.cpp b/libopie2/opiepim/backend/otodoaccessvcal.cpp
index 9bc16c6..3577e14 100644
--- a/libopie2/opiepim/backend/otodoaccessvcal.cpp
+++ b/libopie2/opiepim/backend/otodoaccessvcal.cpp
@@ -185,6 +185,10 @@ QArray<int> OTodoAccessVCal::allRecords()const {
}
return ar;
}
+QArray<int> OTodoAccessVCal::matchRegexp(const QRegExp &r)const {
+ QArray<int> ar(0);
+ return ar;
+}
QArray<int> OTodoAccessVCal::queryByExample( const OTodo&, int, const QDateTime& ) {
QArray<int> ar(0);
return ar;
diff --git a/libopie2/opiepim/backend/otodoaccessvcal.h b/libopie2/opiepim/backend/otodoaccessvcal.h
index 489416b..2b17147 100644
--- a/libopie2/opiepim/backend/otodoaccessvcal.h
+++ b/libopie2/opiepim/backend/otodoaccessvcal.h
@@ -13,6 +13,7 @@ public:
bool save();
QArray<int> allRecords()const;
+ QArray<int> matchRegexp(const QRegExp &r) const;
QArray<int> queryByExample( const OTodo& t, int sort, const QDateTime& d = QDateTime() );
QArray<int> effectiveToDos( const QDate& start,
const QDate& end,
diff --git a/libopie2/opiepim/backend/otodoaccessxml.cpp b/libopie2/opiepim/backend/otodoaccessxml.cpp
index 285d2b8..69b7ab4 100644
--- a/libopie2/opiepim/backend/otodoaccessxml.cpp
+++ b/libopie2/opiepim/backend/otodoaccessxml.cpp
@@ -774,3 +774,19 @@ QBitArray OTodoAccessXML::sup() {
return ar;
}
+QArray<int> OTodoAccessXML::matchRegexp( const QRegExp &r ) const
+{
+ QArray<int> m_currentQuery( m_events.count() );
+ uint arraycounter = 0;
+
+ QMap<int, OTodo>::ConstIterator it;
+ for (it = m_events.begin(); it != m_events.end(); ++it ) {
+ if ( it.data().match( r ) )
+ m_currentQuery[arraycounter++] = it.data().uid();
+
+ }
+ // Shrink to fit..
+ m_currentQuery.resize(arraycounter);
+
+ return m_currentQuery;
+}
diff --git a/libopie2/opiepim/backend/otodoaccessxml.h b/libopie2/opiepim/backend/otodoaccessxml.h
index cc4a16f..e4850a1 100644
--- a/libopie2/opiepim/backend/otodoaccessxml.h
+++ b/libopie2/opiepim/backend/otodoaccessxml.h
@@ -24,6 +24,7 @@ public:
bool save();
QArray<int> allRecords()const;
+ QArray<int> matchRegexp(const QRegExp &r) const;
QArray<int> queryByExample( const OTodo&, int querysettings, const QDateTime& d = QDateTime() );
OTodo find( int uid )const;
void clear();
diff --git a/libopie2/opiepim/core/ocontactaccess.cpp b/libopie2/opiepim/core/ocontactaccess.cpp
index 9c9338e..2e3ec1f 100644
--- a/libopie2/opiepim/core/ocontactaccess.cpp
+++ b/libopie2/opiepim/core/ocontactaccess.cpp
@@ -21,6 +21,10 @@
* =====================================================================
* History:
* $Log$
+ * Revision 1.8 2003/05/08 13:55:09 tille
+ * search stuff
+ * and match, toRichText & toShortText in oevent
+ *
* Revision 1.7 2002/11/13 14:14:51 eilers
* Added sorted for Contacts..
*
@@ -73,7 +77,7 @@ OContactAccess::OContactAccess ( const QString appname, const QString ,
OContactAccessBackend* end, bool autosync ):
OPimAccessTemplate<OContact>( end )
{
- /* take care of the backend. If there is no one defined, we
+ /* take care of the backend. If there is no one defined, we
* will use the XML-Backend as default (until we have a cute SQL-Backend..).
*/
if( end == 0 ) {
@@ -83,7 +87,7 @@ OContactAccess::OContactAccess ( const QString appname, const QString ,
// Set backend locally and in template
m_backEnd = end;
OPimAccessTemplate<OContact>::setBackEnd (end);
-
+
/* Connect signal of external db change to function */
QCopChannel *dbchannel = new QCopChannel( "QPE/PIM", this );
@@ -126,11 +130,6 @@ bool OContactAccess::save ()
return true;
}
-ORecordList<OContact> OContactAccess::matchRegexp( const QRegExp &r ) const{
- QArray<int> matchingContacts = m_backEnd -> matchRegexp( r );
- return ( ORecordList<OContact>(matchingContacts, this) );
-}
-
const uint OContactAccess::querySettings()
{
return ( m_backEnd->querySettings() );
diff --git a/libopie2/opiepim/core/ocontactaccess.h b/libopie2/opiepim/core/ocontactaccess.h
index d7ceaf2..e90db32 100644
--- a/libopie2/opiepim/core/ocontactaccess.h
+++ b/libopie2/opiepim/core/ocontactaccess.h
@@ -17,6 +17,10 @@
* =====================================================================
* History:
* $Log$
+ * Revision 1.8 2003/05/08 13:55:09 tille
+ * search stuff
+ * and match, toRichText & toShortText in oevent
+ *
* Revision 1.7 2003/04/13 18:07:10 zecke
* More API doc
* QString -> const QString&
@@ -110,8 +114,6 @@ class OContactAccess: public QObject, public OPimAccessTemplate<OContact>
};
- ORecordList<OContact> matchRegexp( const QRegExp &r )const;
-
/** Return all Contacts in a sorted manner.
* @param ascending true: Sorted in acending order.
* @param sortOrder Currently not implemented. Just defined to stay compatible to otodoaccess
diff --git a/libopie2/opiepim/core/opimaccesstemplate.h b/libopie2/opiepim/core/opimaccesstemplate.h
index 6a3a0db..8ff205c 100644
--- a/libopie2/opiepim/core/opimaccesstemplate.h
+++ b/libopie2/opiepim/core/opimaccesstemplate.h
@@ -69,6 +69,12 @@ public:
* you can iterate over them
*/
virtual List allRecords()const;
+
+ /**
+ * return a List of records
+ * that match the regex
+ */
+ virtual List matchRegexp( const QRegExp &r ) const;
/**
* queryByExample.
@@ -181,6 +187,12 @@ typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::allRecords()const {
return lis;
}
template <class T>
+typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::matchRegexp( const QRegExp &r )const {
+ QArray<int> ints = m_backEnd->matchRegexp( r );
+ List lis(ints, this );
+ return lis;
+}
+template <class T>
QArray<int> OPimAccessTemplate<T>::records()const {
return m_backEnd->allRecords();
}
diff --git a/libopie2/opiepim/core/opimrecord.h b/libopie2/opiepim/core/opimrecord.h
index c7f9460..de2d9f4 100644
--- a/libopie2/opiepim/core/opimrecord.h
+++ b/libopie2/opiepim/core/opimrecord.h
@@ -73,6 +73,12 @@ public:
virtual QString type()const = 0;
/**
+ * matches the Records the regular expression?
+ */
+ virtual bool match( const QString &regexp ) const {return match(QRegExp(regexp));};
+ virtual bool match( const QRegExp &regexp ) const = 0;
+
+ /**
* converts the internal structure to a map
*/
virtual QMap<int, QString> toMap()const = 0;
diff --git a/libopie2/opiepim/ocontact.cpp b/libopie2/opiepim/ocontact.cpp
index 96a5f65..a38b62b 100644
--- a/libopie2/opiepim/ocontact.cpp
+++ b/libopie2/opiepim/ocontact.cpp
@@ -947,15 +947,6 @@ void OContact::setChildren( const QString &str )
}
/*!
- Returns TRUE if the contact matches the regular expression \a regexp.
- Otherwise returns FALSE.
-*/
-bool OContact::match( const QString &regexp ) const
-{
- return match(QRegExp(regexp));
-}
-
-/*!
\overload
Returns TRUE if the contact matches the regular expression \a regexp.
Otherwise returns FALSE.
diff --git a/libopie2/opiepim/ocontact.h b/libopie2/opiepim/ocontact.h
index 50f6176..0e6cbd2 100644
--- a/libopie2/opiepim/ocontact.h
+++ b/libopie2/opiepim/ocontact.h
@@ -111,8 +111,7 @@ public:
// other
void setNotes( const QString &v ) { replace( Qtopia::Notes, v); }
- bool match( const QString &regexp ) const;
- bool match( const QRegExp &regexp ) const;
+ virtual bool match( const QRegExp &regexp ) const;
// // custom
// void setCustomField( const QString &key, const QString &v )
diff --git a/libopie2/opiepim/oevent.cpp b/libopie2/opiepim/oevent.cpp
index 3ba8a52..28cf873 100644
--- a/libopie2/opiepim/oevent.cpp
+++ b/libopie2/opiepim/oevent.cpp
@@ -2,6 +2,7 @@
#include <qpe/palmtopuidgen.h>
#include <qpe/categories.h>
+#include <qpe/stringutil.h>
#include "orecur.h"
#include "opimresolver.h"
@@ -210,16 +211,46 @@ QString OEvent::timeZone()const {
if (data->isAllDay ) return QString::fromLatin1("UTC");
return data->timezone;
}
-bool OEvent::match( const QRegExp& )const {
- // FIXME
+bool OEvent::match( const QRegExp& re )const {
+ if (data->description.contains( re ) )
+ return true;
+ if ( data->note.contains( re ) )
+ return true;
+ if ( data->location.contains( re ) )
+ return true;
+ if ( data->start.toString().contains( re ) )
+ return true;
+ if ( data->end.toString().contains( re ) )
+ return true;
return false;
}
QString OEvent::toRichText()const {
- // FIXME
- return "OEvent test";
+ QString text;
+ if ( !description().isEmpty() ) {
+ text += "<b>" + QObject::tr( "Description:") + "</b><br>";
+ text += Qtopia::escapeString(description() ).
+ replace(QRegExp( "[\n]"), "<br>" ) + "<br>";
+ }
+ if ( startDateTime().isValid() ) {
+ text += "<b>" + QObject::tr( "Start:") + "</b> ";
+ text += Qtopia::escapeString(startDateTime().toString() ).
+ replace(QRegExp( "[\n]"), "<br>" ) + "<br>";
+ }
+ if ( endDateTime().isValid() ) {
+ text += "<b>" + QObject::tr( "End:") + "</b> ";
+ text += Qtopia::escapeString(endDateTime().toString() ).
+ replace(QRegExp( "[\n]"), "<br>" ) + "<br>";
+ }
+ 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 {
- return "OEvent shotText";
+ return description();
}
QString OEvent::type()const {
return QString::fromLatin1("OEvent");
diff --git a/libopie2/opiepim/oevent.h b/libopie2/opiepim/oevent.h
index 57d32d0..b696d81 100644
--- a/libopie2/opiepim/oevent.h
+++ b/libopie2/opiepim/oevent.h
@@ -113,7 +113,7 @@ public:
QString timeZone()const;
- bool match( const QRegExp& )const;
+ virtual bool match( const QRegExp& )const;
/** For exception to recurrence here is a list of children... */
QArray<int> children()const;
diff --git a/libopie2/opiepim/otodo.h b/libopie2/opiepim/otodo.h
index a58d9aa..0e7c73f 100644
--- a/libopie2/opiepim/otodo.h
+++ b/libopie2/opiepim/otodo.h
@@ -258,7 +258,7 @@ public:
bool isOverdue();
- bool match( const QRegExp &r )const;
+ virtual bool match( const QRegExp &r )const;
bool operator<(const OTodo &toDoEvent )const;
bool operator<=(const OTodo &toDoEvent )const;