From 4f0a67218237c83bdd02d339835f62ad064dc248 Mon Sep 17 00:00:00 2001 From: eilers Date: Tue, 28 Dec 2004 12:14:44 +0000 Subject: * Make improved query by example accessable via frontend * Some API improvement --- (limited to 'libopie2/opiepim/core/opimaccesstemplate.h') 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 @@ -86,7 +86,47 @@ public: //@{ 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&, uint current, typename OTemplateBase::CacheDirection dir = OTemplateBase::Forward )const; @@ -269,20 +309,42 @@ QArray OPimAccessTemplate::records()const { } -/** - * queryByExample. - * @see otodoaccess, ocontactaccess - */ template typename OPimAccessTemplate::List OPimAccessTemplate::queryByExample( const T& t, int settings, const QDateTime& d ) { QArray ints = m_backEnd->queryByExample( t, settings, d ); - List lis(ints, this ); - return lis; + List list(ints, this ); + return list; } template +typename OPimAccessTemplate::List +OPimAccessTemplate::queryByExample( const OPimRecord* t, int settings, const QDateTime& d ) { + T tempInstance; + + if ( t->rtti() == tempInstance.rtti() ) { + QArray ints = m_backEnd->queryByExample( t, settings, d ); + List list( ints, this ); + return list; + } else { + owarn << "Query not possible: Objecttype mismatch" << oendl; + } + + return List(); +} + +template +typename OPimAccessTemplate::List +OPimAccessTemplate::queryByExample( const OPimAccessTemplate::List& uidlist, const T& t, int settings, const QDateTime& d ) { + QArray ints = m_backEnd->queryByExample( uidlist.uids(), t, settings, d ); + + List list( ints, this ); + return list; +} + + +template T OPimAccessTemplate::find( UID uid ) const{ // First search in cache.. if ( m_cache.contains( uid ) ) -- cgit v0.9.0.2