summaryrefslogtreecommitdiff
path: root/libopie/pim
authortille <tille>2003-05-08 13:55:09 (UTC)
committer tille <tille>2003-05-08 13:55:09 (UTC)
commit0cb4111d34d9fe96731f48983e1ff2e67262db02 (patch) (unidiff)
treece6ec869ae7753ab0261e7ad075a10ad8b0a404b /libopie/pim
parent78c60031b506b85dc20bd555d83486aeb831bf38 (diff)
downloadopie-0cb4111d34d9fe96731f48983e1ff2e67262db02.zip
opie-0cb4111d34d9fe96731f48983e1ff2e67262db02.tar.gz
opie-0cb4111d34d9fe96731f48983e1ff2e67262db02.tar.bz2
search stuff
and match, toRichText & toShortText in oevent
Diffstat (limited to 'libopie/pim') (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
16 files changed, 114 insertions, 27 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 )
947} 947}
948 948
949/*! 949/*!
950 Returns TRUE if the contact matches the regular expression \a regexp.
951 Otherwise returns FALSE.
952*/
953bool OContact::match( const QString &regexp ) const
954{
955 return match(QRegExp(regexp));
956}
957
958/*!
959 \overload 950 \overload
960 Returns TRUE if the contact matches the regular expression \a regexp. 951 Returns TRUE if the contact matches the regular expression \a regexp.
961 Otherwise returns FALSE. 952 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:
111 // other 111 // other
112 void setNotes( const QString &v ) { replace( Qtopia::Notes, v); } 112 void setNotes( const QString &v ) { replace( Qtopia::Notes, v); }
113 113
114 bool match( const QString &regexp ) const; 114 virtual bool match( const QRegExp &regexp ) const;
115 bool match( const QRegExp &regexp ) const;
116 115
117// // custom 116// // custom
118// void setCustomField( const QString &key, const QString &v ) 117// 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 @@
21 * ===================================================================== 21 * =====================================================================
22 * History: 22 * History:
23 * $Log$ 23 * $Log$
24 * Revision 1.8 2003/05/08 13:55:09 tille
25 * search stuff
26 * and match, toRichText & toShortText in oevent
27 *
24 * Revision 1.7 2002/11/13 14:14:51 eilers 28 * Revision 1.7 2002/11/13 14:14:51 eilers
25 * Added sorted for Contacts.. 29 * Added sorted for Contacts..
26 * 30 *
@@ -73,7 +77,7 @@ OContactAccess::OContactAccess ( const QString appname, const QString ,
73 OContactAccessBackend* end, bool autosync ): 77 OContactAccessBackend* end, bool autosync ):
74 OPimAccessTemplate<OContact>( end ) 78 OPimAccessTemplate<OContact>( end )
75{ 79{
76 /* take care of the backend. If there is no one defined, we 80 /* take care of the backend. If there is no one defined, we
77 * will use the XML-Backend as default (until we have a cute SQL-Backend..). 81 * will use the XML-Backend as default (until we have a cute SQL-Backend..).
78 */ 82 */
79 if( end == 0 ) { 83 if( end == 0 ) {
@@ -83,7 +87,7 @@ OContactAccess::OContactAccess ( const QString appname, const QString ,
83 // Set backend locally and in template 87 // Set backend locally and in template
84 m_backEnd = end; 88 m_backEnd = end;
85 OPimAccessTemplate<OContact>::setBackEnd (end); 89 OPimAccessTemplate<OContact>::setBackEnd (end);
86 90
87 91
88 /* Connect signal of external db change to function */ 92 /* Connect signal of external db change to function */
89 QCopChannel *dbchannel = new QCopChannel( "QPE/PIM", this ); 93 QCopChannel *dbchannel = new QCopChannel( "QPE/PIM", this );
@@ -126,11 +130,6 @@ bool OContactAccess::save ()
126 return true; 130 return true;
127} 131}
128 132
129ORecordList<OContact> OContactAccess::matchRegexp( const QRegExp &r ) const{
130 QArray<int> matchingContacts = m_backEnd -> matchRegexp( r );
131 return ( ORecordList<OContact>(matchingContacts, this) );
132}
133
134const uint OContactAccess::querySettings() 133const uint OContactAccess::querySettings()
135{ 134{
136 return ( m_backEnd->querySettings() ); 135 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 @@
17 * ===================================================================== 17 * =====================================================================
18 * History: 18 * History:
19 * $Log$ 19 * $Log$
20 * Revision 1.8 2003/05/08 13:55:09 tille
21 * search stuff
22 * and match, toRichText & toShortText in oevent
23 *
20 * Revision 1.7 2003/04/13 18:07:10 zecke 24 * Revision 1.7 2003/04/13 18:07:10 zecke
21 * More API doc 25 * More API doc
22 * QString -> const QString& 26 * QString -> const QString&
@@ -110,8 +114,6 @@ class OContactAccess: public QObject, public OPimAccessTemplate<OContact>
110 }; 114 };
111 115
112 116
113 ORecordList<OContact> matchRegexp( const QRegExp &r )const;
114
115 /** Return all Contacts in a sorted manner. 117 /** Return all Contacts in a sorted manner.
116 * @param ascending true: Sorted in acending order. 118 * @param ascending true: Sorted in acending order.
117 * @param sortOrder Currently not implemented. Just defined to stay compatible to otodoaccess 119 * @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
586 break; 586 break;
587 } 587 }
588} 588}
589QArray<int> ODateBookAccessBackend_XML::matchRegexp( const QRegExp &r ) const
590{
591 QArray<int> m_currentQuery( m_raw.count()+ m_rep.count() );
592 uint arraycounter = 0;
593 QMap<int, OEvent>::ConstIterator it;
594
595 for ( it = m_raw.begin(); it != m_raw.end(); ++it )
596 if ( it.data().match( r ) )
597 m_currentQuery[arraycounter++] = it.data().uid();
598 for ( it = m_rep.begin(); it != m_rep.end(); ++it )
599 if ( it.data().match( r ) )
600 m_currentQuery[arraycounter++] = it.data().uid();
601
602 // Shrink to fit..
603 m_currentQuery.resize(arraycounter);
604
605 return m_currentQuery;
606}
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:
22 bool save(); 22 bool save();
23 23
24 QArray<int> allRecords()const; 24 QArray<int> allRecords()const;
25 QArray<int> matchRegexp(const QRegExp &r) const;
25 QArray<int> queryByExample( const OEvent&, int, const QDateTime& d = QDateTime() ); 26 QArray<int> queryByExample( const OEvent&, int, const QDateTime& d = QDateTime() );
26 OEvent find( int uid )const; 27 OEvent find( int uid )const;
27 void clear(); 28 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 @@
2 2
3#include <qpe/palmtopuidgen.h> 3#include <qpe/palmtopuidgen.h>
4#include <qpe/categories.h> 4#include <qpe/categories.h>
5#include <qpe/stringutil.h>
5 6
6#include "orecur.h" 7#include "orecur.h"
7#include "opimresolver.h" 8#include "opimresolver.h"
@@ -210,16 +211,46 @@ QString OEvent::timeZone()const {
210 if (data->isAllDay ) return QString::fromLatin1("UTC"); 211 if (data->isAllDay ) return QString::fromLatin1("UTC");
211 return data->timezone; 212 return data->timezone;
212} 213}
213bool OEvent::match( const QRegExp& )const { 214bool OEvent::match( const QRegExp& re )const {
214 // FIXME 215 if (data->description.contains( re ) )
216 return true;
217 if ( data->note.contains( re ) )
218 return true;
219 if ( data->location.contains( re ) )
220 return true;
221 if ( data->start.toString().contains( re ) )
222 return true;
223 if ( data->end.toString().contains( re ) )
224 return true;
215 return false; 225 return false;
216} 226}
217QString OEvent::toRichText()const { 227QString OEvent::toRichText()const {
218 // FIXME 228 QString text;
219 return "OEvent test"; 229 if ( !description().isEmpty() ) {
230 text += "<b>" + QObject::tr( "Description:") + "</b><br>";
231 text += Qtopia::escapeString(description() ).
232 replace(QRegExp( "[\n]"), "<br>" ) + "<br>";
233 }
234 if ( startDateTime().isValid() ) {
235 text += "<b>" + QObject::tr( "Start:") + "</b> ";
236 text += Qtopia::escapeString(startDateTime().toString() ).
237 replace(QRegExp( "[\n]"), "<br>" ) + "<br>";
238 }
239 if ( endDateTime().isValid() ) {
240 text += "<b>" + QObject::tr( "End:") + "</b> ";
241 text += Qtopia::escapeString(endDateTime().toString() ).
242 replace(QRegExp( "[\n]"), "<br>" ) + "<br>";
243 }
244 if ( !note().isEmpty() ) {
245 text += "<b>" + QObject::tr( "Note:") + "</b><br>";
246 text += note();
247// text += Qtopia::escapeString(note() ).
248// replace(QRegExp( "[\n]"), "<br>" ) + "<br>";
249 }
250 return text;
220} 251}
221QString OEvent::toShortText()const { 252QString OEvent::toShortText()const {
222 return "OEvent shotText"; 253 return description();
223} 254}
224QString OEvent::type()const { 255QString OEvent::type()const {
225 return QString::fromLatin1("OEvent"); 256 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:
113 QString timeZone()const; 113 QString timeZone()const;
114 114
115 115
116 bool match( const QRegExp& )const; 116 virtual bool match( const QRegExp& )const;
117 117
118 /** For exception to recurrence here is a list of children... */ 118 /** For exception to recurrence here is a list of children... */
119 QArray<int> children()const; 119 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:
46 */ 46 */
47 virtual QArray<int> allRecords()const = 0; 47 virtual QArray<int> allRecords()const = 0;
48 48
49 /**
50 * return a List of records
51 * that match the regex
52 */
53 virtual QArray<int> matchRegexp(const QRegExp &r) const = 0;
54
49 /** 55 /**
50 * queryByExample for T with the given Settings 56 * queryByExample for T with the given Settings
51 * 57 *
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:
69 * you can iterate over them 69 * you can iterate over them
70 */ 70 */
71 virtual List allRecords()const; 71 virtual List allRecords()const;
72
73 /**
74 * return a List of records
75 * that match the regex
76 */
77 virtual List matchRegexp( const QRegExp &r ) const;
72 78
73 /** 79 /**
74 * queryByExample. 80 * queryByExample.
@@ -181,6 +187,12 @@ typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::allRecords()const {
181 return lis; 187 return lis;
182} 188}
183template <class T> 189template <class T>
190typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::matchRegexp( const QRegExp &r )const {
191 QArray<int> ints = m_backEnd->matchRegexp( r );
192 List lis(ints, this );
193 return lis;
194}
195template <class T>
184QArray<int> OPimAccessTemplate<T>::records()const { 196QArray<int> OPimAccessTemplate<T>::records()const {
185 return m_backEnd->allRecords(); 197 return m_backEnd->allRecords();
186} 198}
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:
73 virtual QString type()const = 0; 73 virtual QString type()const = 0;
74 74
75 /** 75 /**
76 * matches the Records the regular expression?
77 */
78 virtual bool match( const QString &regexp ) const {return match(QRegExp(regexp));};
79 virtual bool match( const QRegExp &regexp ) const = 0;
80
81 /**
76 * converts the internal structure to a map 82 * converts the internal structure to a map
77 */ 83 */
78 virtual QMap<int, QString> toMap()const = 0; 84 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:
258 bool isOverdue(); 258 bool isOverdue();
259 259
260 260
261 bool match( const QRegExp &r )const; 261 virtual bool match( const QRegExp &r )const;
262 262
263 bool operator<(const OTodo &toDoEvent )const; 263 bool operator<(const OTodo &toDoEvent )const;
264 bool operator<=(const OTodo &toDoEvent )const; 264 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 {
185 } 185 }
186 return ar; 186 return ar;
187} 187}
188QArray<int> OTodoAccessVCal::matchRegexp(const QRegExp &r)const {
189 QArray<int> ar(0);
190 return ar;
191}
188QArray<int> OTodoAccessVCal::queryByExample( const OTodo&, int, const QDateTime& ) { 192QArray<int> OTodoAccessVCal::queryByExample( const OTodo&, int, const QDateTime& ) {
189 QArray<int> ar(0); 193 QArray<int> ar(0);
190 return ar; 194 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:
13 bool save(); 13 bool save();
14 14
15 QArray<int> allRecords()const; 15 QArray<int> allRecords()const;
16 QArray<int> matchRegexp(const QRegExp &r) const;
16 QArray<int> queryByExample( const OTodo& t, int sort, const QDateTime& d = QDateTime() ); 17 QArray<int> queryByExample( const OTodo& t, int sort, const QDateTime& d = QDateTime() );
17 QArray<int> effectiveToDos( const QDate& start, 18 QArray<int> effectiveToDos( const QDate& start,
18 const QDate& end, 19 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() {
774 774
775 return ar; 775 return ar;
776} 776}
777QArray<int> OTodoAccessXML::matchRegexp( const QRegExp &r ) const
778{
779 QArray<int> m_currentQuery( m_events.count() );
780 uint arraycounter = 0;
781
782 QMap<int, OTodo>::ConstIterator it;
783 for (it = m_events.begin(); it != m_events.end(); ++it ) {
784 if ( it.data().match( r ) )
785 m_currentQuery[arraycounter++] = it.data().uid();
786
787 }
788 // Shrink to fit..
789 m_currentQuery.resize(arraycounter);
790
791 return m_currentQuery;
792}
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:
24 bool save(); 24 bool save();
25 25
26 QArray<int> allRecords()const; 26 QArray<int> allRecords()const;
27 QArray<int> matchRegexp(const QRegExp &r) const;
27 QArray<int> queryByExample( const OTodo&, int querysettings, const QDateTime& d = QDateTime() ); 28 QArray<int> queryByExample( const OTodo&, int querysettings, const QDateTime& d = QDateTime() );
28 OTodo find( int uid )const; 29 OTodo find( int uid )const;
29 void clear(); 30 void clear();