summaryrefslogtreecommitdiff
path: root/libopie2
authoreilers <eilers>2004-12-28 12:14:44 (UTC)
committer eilers <eilers>2004-12-28 12:14:44 (UTC)
commit4f0a67218237c83bdd02d339835f62ad064dc248 (patch) (side-by-side diff)
tree26680f7a55cb0b09f158e1bf18b4bad4117e0db0 /libopie2
parent97a3d431ba9e33a3e256955755b23a55a9a9ea05 (diff)
downloadopie-4f0a67218237c83bdd02d339835f62ad064dc248.zip
opie-4f0a67218237c83bdd02d339835f62ad064dc248.tar.gz
opie-4f0a67218237c83bdd02d339835f62ad064dc248.tar.bz2
* Make improved query by example accessable via frontend
* Some API improvement
Diffstat (limited to 'libopie2') (more/less context) (show whitespace changes)
-rw-r--r--libopie2/opiepim/ChangeLog3
-rw-r--r--libopie2/opiepim/core/ocontactaccess.h2
-rw-r--r--libopie2/opiepim/core/opimaccesstemplate.h76
-rw-r--r--libopie2/opiepim/core/opimtemplatebase.h0
4 files changed, 73 insertions, 8 deletions
diff --git a/libopie2/opiepim/ChangeLog b/libopie2/opiepim/ChangeLog
index dd57259..564e92a 100644
--- a/libopie2/opiepim/ChangeLog
+++ b/libopie2/opiepim/ChangeLog
@@ -1,18 +1,21 @@
+2004-12-28 Stefan Eilers <stefan@eilers-online.net>
+ * Make improved query by example accessable via frontend
+ * Some API improvement
2004-11-23 Stefan Eilers <stefan@eilers-online.net>
* Implement fast and full featured version of sorted() for addressbook
* Implement generic queryByExample for all Addressboook backends. It allows incremental search.
* Update of API Documentation
2004-11-18 Holger Freyther <freyther@handhelds.org>
* Every Access can give a set of Occurrences for a period or a datetime
* QueryByExample, Find, Sort can be generically accessed by OPimBase
pointer interface
* OPimBackendOccurrence gets split up to OPimOccurrences by
OPimTemplateBase
* Add safeCast to various OPimRecords
* Kill memleak in OPimTodo
* Add SortVector implementations for OPimTodo and OPimContact
2004-??-?? The Opie Team <opie@handhelds.org>
* Implemented some important modifications to allow to use OPimRecords as it is, without
have to cast them. This makes it possible to write applications which handling pim
data in a generic manner (see opimconvertion tool) (eilers) \ No newline at end of file
diff --git a/libopie2/opiepim/core/ocontactaccess.h b/libopie2/opiepim/core/ocontactaccess.h
index bd85b4e..5051321 100644
--- a/libopie2/opiepim/core/ocontactaccess.h
+++ b/libopie2/opiepim/core/ocontactaccess.h
@@ -99,49 +99,49 @@ class OPimContactAccess: public QObject, public OPimAccessTemplate<OPimContact>
/**
* Create Database with contacts (addressbook).
* @param appname Name of application which wants access to the database
* (i.e. "todolist")
* @param filename The name of the database file. If not set, the default one
* is used.
* @param backend Pointer to an alternative Backend. If not set, we will use
* the default backend.
* @param handlesync If <b>true</b> the database stores the current state
* automatically if it receives the signals <i>flush()</i> and <i>reload()</i>
* which are used before and after synchronisation. If the application wants
* to react itself, it should be disabled by setting it to <b>false</b>
* @see OPimContactAccessBackend
*/
OPimContactAccess (const QString appname, const QString filename = 0l,
OPimContactAccessBackend* backend = 0l, bool handlesync = true);
~OPimContactAccess ();
/**
* Return all possible settings for queryByExample().
* @return All settings provided by the current backend
* (i.e.: WildCards & IgnoreCase)
- * @see QuerySettings in OPimBase for details of the parameter
+ * @see QuerySettings in OPimBase for details of the parameter, queryByExample()
*/
const uint querySettings();
/**
* Check whether settings are correct for queryByExample().
* @return <i>true</i> if the given settings are correct and possible.
* @see QuerySettings in OPimBase for details of the parameter
*/
bool hasQuerySettings ( int querySettings ) const;
/**
* if the resource was changed externally.
* You should use the signal instead of polling possible changes !
*/
bool wasChangedExternally()const;
/** Save contacts database.
* Save is more a "commit". After calling this function, all changes are public available.
* @return true if successful
*/
bool save();
/**
diff --git a/libopie2/opiepim/core/opimaccesstemplate.h b/libopie2/opiepim/core/opimaccesstemplate.h
index 073d5f9..3875f09 100644
--- a/libopie2/opiepim/core/opimaccesstemplate.h
+++ b/libopie2/opiepim/core/opimaccesstemplate.h
@@ -65,49 +65,89 @@ public:
SortedAccess
};
typedef OPimRecordList<T> List;
typedef OPimAccessBackend<T> BackEnd;
typedef OPimCache<T> Cache;
//@{
OPimAccessTemplate( BackEnd* end);
virtual ~OPimAccessTemplate();
//@}
//@{
bool load();
virtual bool reload();
bool save();
void clear() ;
//@}
bool wasChangedExternally()const;
//@{
virtual List allRecords()const;
virtual List matchRegexp( const QRegExp &r ) const;
- virtual List queryByExample( const T& t, int querySettings, const QDateTime& d = QDateTime() );
+
+ /**
+ * Query by example search interface.
+ * "Query by Example" provides a very powerful search engine. Use the query object
+ * (this may be a contact, a todo or databook event)
+ * as a search mask which is converted into a query regarding the querySettings. If a time period is needed
+ * (as for OpimBase::DateDiff), you have to use the date/time in the query object and the endperiod (the last parameter).
+ * @see QuerySettings in class OPimBase
+ * @param query The object which contains the query set
+ * @param querySettings This parameter defines what should be searched and how the query should be interpreted
+ * @param endperiod Defines the end of a period for some special queries.
+ */
+ virtual List queryByExample( const T& query, int querySettings, const QDateTime& endperiod = QDateTime() );
+
+ /**
+ * Generic query by example search interface. This is a special version which handles generic OPimRecord types. They are converted
+ * automatically into the right datatype.
+ * "Query by Example" provides a very powerful search engine. Use the query object (this may be a contact, a todo or databook event)
+ * as a search mask which is converted into a query regarding the querySettings. If a time period is needed
+ * (as for OpimBase::DateDiff), you have to use the date/time in the query object and the endperiod (the last parameter).
+ * @see QuerySettings in class OPimBase
+ * @param query The object which contains the query set
+ * @param querySettings This parameter defines what should be searched and how the query should be interpreted
+ * @param endperiod Defines the end of a period for some special queries.
+ */
+ virtual List queryByExample( const OPimRecord* query, int querySettings, const QDateTime& endperiod = QDateTime() );
+ /**
+ * Incremental query by example search interface. Providing incremental search, this one provides the feature
+ * to search in a list of records which may be returned by an other search.
+ * "Query by Example" provides a very powerful search engine. Use the query object (this may be a contact, a todo or databook event)
+ * as a search mask which is converted into a query regarding the querySettings. If a time period is needed
+ * (as for OpimBase::DateDiff), you have to use the date/time in the query object and the endperiod (the last parameter).
+ * @see QuerySettings in class OPimBase
+ * @param uidlist List of uid's which should be incorporated into the next search
+ * @param query The object which contains the query set
+ * @param querySettings This parameter defines what should be searched and how the query should be interpreted
+ * @param endperiod Defines the end of a period for some special queries.
+ */
+ virtual List queryByExample( const OPimAccessTemplate::List& uidlist, const T& query, int querySettings,
+ const QDateTime& endperiod = QDateTime() );
+
virtual T find( UID uid )const;
virtual T find( UID uid, const QArray<int>&,
uint current, typename OTemplateBase<T>::CacheDirection dir = OTemplateBase<T>::Forward )const;
//@}
/**
* Get sorted lists..
* @see OPimContactAccess, OPimTodoAccess and ODateBookAccess regarding more info for the following params:
* @param list of UID's received by allRecords() or others...
* @param sortOrder Setting the sort order defined by enum SortOrder
* @param ascending Sort in ascending order if true, otherwise descending
* @param sortFilter Setting the sort filter defined by enum SortFilter
* @param cat number of category.
*/
virtual List sorted( const List& list, bool ascending, int sortOrder,
int sortFilter, int cat )const;
/**
* Get sorted lists..
* @see OPimContactAccess, OPimTodoAccess and ODateBookAccess regarding more info for the following params:
* @param list of UID's received by allRecords() or others...
* @param sortOrder Setting the sort order defined by enum SortOrder
* @param ascending Sort in ascending order if true, otherwise descending
* @param sortFilter Setting the sort filter defined by enum SortFilter
@@ -248,62 +288,84 @@ typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::allRecords()const {
List lis(ints, this );
return lis;
}
/**
* return a List of records
* that match the regex
*/
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;
}
/**
* find the OPimRecord uid
*/
template <class T>
QArray<int> OPimAccessTemplate<T>::records()const {
return m_backEnd->allRecords();
}
-/**
- * queryByExample.
- * @see otodoaccess, ocontactaccess
- */
template <class T>
typename OPimAccessTemplate<T>::List
OPimAccessTemplate<T>::queryByExample( const T& t, int settings, const QDateTime& d ) {
QArray<int> ints = m_backEnd->queryByExample( t, settings, d );
- List lis(ints, this );
- return lis;
+ List list(ints, this );
+ return list;
}
template <class T>
+typename OPimAccessTemplate<T>::List
+OPimAccessTemplate<T>::queryByExample( const OPimRecord* t, int settings, const QDateTime& d ) {
+ T tempInstance;
+
+ if ( t->rtti() == tempInstance.rtti() ) {
+ QArray<int> ints = m_backEnd->queryByExample( t, settings, d );
+ List list( ints, this );
+ return list;
+ } else {
+ owarn << "Query not possible: Objecttype mismatch" << oendl;
+ }
+
+ return List();
+}
+
+template <class T>
+typename OPimAccessTemplate<T>::List
+OPimAccessTemplate<T>::queryByExample( const OPimAccessTemplate::List& uidlist, const T& t, int settings, const QDateTime& d ) {
+ QArray<int> ints = m_backEnd->queryByExample( uidlist.uids(), t, settings, d );
+
+ List list( ints, this );
+ return list;
+}
+
+
+template <class T>
T OPimAccessTemplate<T>::find( UID uid ) const{
// First search in cache..
if ( m_cache.contains( uid ) )
return m_cache.find( uid );
T t = m_backEnd->find( uid );
cache( t );
return t;
}
/**
* read ahead cache find method ;)
*/
template <class T>
T OPimAccessTemplate<T>::find( UID uid, const QArray<int>& ar,
uint current, typename OTemplateBase<T>::CacheDirection dir )const {
/*
* better do T.isEmpty()
* after a find this way we would
* avoid two finds in QCache...
*/
if (m_cache.contains( uid ) )
diff --git a/libopie2/opiepim/core/opimtemplatebase.h b/libopie2/opiepim/core/opimtemplatebase.h
index c8abab4..075e573 100644
--- a/libopie2/opiepim/core/opimtemplatebase.h
+++ b/libopie2/opiepim/core/opimtemplatebase.h