author | eilers <eilers> | 2004-12-20 14:14:07 (UTC) |
---|---|---|
committer | eilers <eilers> | 2004-12-20 14:14:07 (UTC) |
commit | 18e47153532d016d878f47e0ce11cb1a9716218e (patch) (unidiff) | |
tree | 52eb6c25258fda0b2f295a29809c4603f5e17b0b /libopie2 | |
parent | 876e48baa20213d8265041cfac3034fe92cb0590 (diff) | |
download | opie-18e47153532d016d878f47e0ce11cb1a9716218e.zip opie-18e47153532d016d878f47e0ce11cb1a9716218e.tar.gz opie-18e47153532d016d878f47e0ce11cb1a9716218e.tar.bz2 |
Recovery of the following Changes:
* 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
-rw-r--r-- | libopie2/opiepim/ChangeLog | 4 | ||||
-rw-r--r-- | libopie2/opiepim/backend/ocontactaccessbackend.cpp | 205 | ||||
-rw-r--r-- | libopie2/opiepim/backend/ocontactaccessbackend.h | 9 | ||||
-rw-r--r-- | libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp | 144 | ||||
-rw-r--r-- | libopie2/opiepim/backend/ocontactaccessbackend_sql.h | 23 | ||||
-rw-r--r-- | libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp | 14 | ||||
-rw-r--r-- | libopie2/opiepim/backend/ocontactaccessbackend_vcard.h | 4 | ||||
-rw-r--r-- | libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp | 205 | ||||
-rw-r--r-- | libopie2/opiepim/backend/ocontactaccessbackend_xml.h | 9 | ||||
-rw-r--r-- | libopie2/opiepim/backend/opimaccessbackend.h | 40 | ||||
-rw-r--r-- | libopie2/opiepim/core/ocontactaccess.h | 37 | ||||
-rw-r--r-- | libopie2/opiepim/core/opimaccesstemplate.h | 53 | ||||
-rw-r--r-- | libopie2/opiepim/core/opimtemplatebase.h | 57 | ||||
-rw-r--r-- | libopie2/opiepim/opiepim.pro | 2 |
14 files changed, 493 insertions, 313 deletions
diff --git a/libopie2/opiepim/ChangeLog b/libopie2/opiepim/ChangeLog index 9c85e4b..dd57259 100644 --- a/libopie2/opiepim/ChangeLog +++ b/libopie2/opiepim/ChangeLog | |||
@@ -1 +1,5 @@ | |||
1 | 2004-11-23 Stefan Eilers <stefan@eilers-online.net> | ||
2 | * Implement fast and full featured version of sorted() for addressbook | ||
3 | * Implement generic queryByExample for all Addressboook backends. It allows incremental search. | ||
4 | * Update of API Documentation | ||
1 | 2004-11-18 Holger Freyther <freyther@handhelds.org> | 5 | 2004-11-18 Holger Freyther <freyther@handhelds.org> |
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend.cpp b/libopie2/opiepim/backend/ocontactaccessbackend.cpp index 6ef60eb..b4fdd46 100644 --- a/libopie2/opiepim/backend/ocontactaccessbackend.cpp +++ b/libopie2/opiepim/backend/ocontactaccessbackend.cpp | |||
@@ -35,2 +35,4 @@ | |||
35 | 35 | ||
36 | #include <qdatetime.h> | ||
37 | |||
36 | namespace Opie { | 38 | namespace Opie { |
@@ -38,10 +40,201 @@ OPimContactAccessBackend::OPimContactAccessBackend() {} | |||
38 | 40 | ||
39 | UIDArray | 41 | UIDArray OPimContactAccessBackend::queryByExample( const UIDArray& uid_array, const OPimContact& query, int settings, |
40 | OPimContactAccessBackend::queryByExample( const OPimContact&, int, | 42 | const QDateTime& d )const { |
41 | const QDateTime& )const { | 43 | odebug << "Using Unaccelerated OPimContactAccessBackend implementation of queryByExample!" << oendl; |
42 | return UIDArray(); | 44 | |
45 | UIDArray m_currentQuery( uid_array.count() ); | ||
46 | uint arraycounter = 0; | ||
47 | |||
48 | for( uint it = 0; it < uid_array.count(); ++it ){ | ||
49 | /* Search all fields and compare them with query object. Store them into list | ||
50 | * if all fields matches. | ||
51 | */ | ||
52 | QDate* queryDate = 0l; | ||
53 | QDate* checkDate = 0l; | ||
54 | bool allcorrect = true; | ||
55 | for ( int i = 0; i < Qtopia::Groups; i++ ) { | ||
56 | // Birthday and anniversary are special nonstring fields and should | ||
57 | // be handled specially | ||
58 | switch ( i ){ | ||
59 | case Qtopia::Birthday: | ||
60 | queryDate = new QDate( query.birthday() ); | ||
61 | checkDate = new QDate( find( uid_array[it] ).birthday() ); | ||
62 | // fall through | ||
63 | case Qtopia::Anniversary: | ||
64 | if ( queryDate == 0l ){ | ||
65 | queryDate = new QDate( query.anniversary() ); | ||
66 | checkDate = new QDate( find( uid_array[it] ).anniversary() ); | ||
67 | } | ||
68 | |||
69 | if ( queryDate->isValid() ){ | ||
70 | if( checkDate->isValid() ){ | ||
71 | if ( settings & OPimContactAccess::DateYear ){ | ||
72 | if ( queryDate->year() != checkDate->year() ) | ||
73 | allcorrect = false; | ||
74 | } | ||
75 | if ( settings & OPimContactAccess::DateMonth ){ | ||
76 | if ( queryDate->month() != checkDate->month() ) | ||
77 | allcorrect = false; | ||
78 | } | ||
79 | if ( settings & OPimContactAccess::DateDay ){ | ||
80 | if ( queryDate->day() != checkDate->day() ) | ||
81 | allcorrect = false; | ||
82 | } | ||
83 | if ( settings & OPimContactAccess::DateDiff ) { | ||
84 | QDate current; | ||
85 | // If we get an additional date, we | ||
86 | // will take this date instead of | ||
87 | // the current one.. | ||
88 | if ( !d.date().isValid() ) | ||
89 | current = QDate::currentDate(); | ||
90 | else | ||
91 | current = d.date(); | ||
92 | |||
93 | // We have to equalize the year, otherwise | ||
94 | // the search will fail.. | ||
95 | checkDate->setYMD( current.year(), | ||
96 | checkDate->month(), | ||
97 | checkDate->day() ); | ||
98 | if ( *checkDate < current ) | ||
99 | checkDate->setYMD( current.year()+1, | ||
100 | checkDate->month(), | ||
101 | checkDate->day() ); | ||
102 | |||
103 | // Check whether the birthday/anniversary date is between | ||
104 | // the current/given date and the maximum date | ||
105 | // ( maximum time range ) ! | ||
106 | if ( current.daysTo( *queryDate ) >= 0 ){ | ||
107 | if ( !( ( *checkDate >= current ) && | ||
108 | ( *checkDate <= *queryDate ) ) ){ | ||
109 | allcorrect = false; | ||
110 | } | ||
111 | } | ||
112 | } | ||
113 | } else{ | ||
114 | // checkDate is invalid. Therefore this entry is always rejected | ||
115 | allcorrect = false; | ||
116 | } | ||
117 | } | ||
118 | |||
119 | delete queryDate; | ||
120 | queryDate = 0l; | ||
121 | delete checkDate; | ||
122 | checkDate = 0l; | ||
123 | break; | ||
124 | default: | ||
125 | /* Just compare fields which are not empty in the query object */ | ||
126 | if ( !query.field(i).isEmpty() ){ | ||
127 | switch ( settings & ~( OPimContactAccess::IgnoreCase | ||
128 | | OPimContactAccess::DateDiff | ||
129 | | OPimContactAccess::DateYear | ||
130 | | OPimContactAccess::DateMonth | ||
131 | | OPimContactAccess::DateDay | ||
132 | | OPimContactAccess::MatchOne | ||
133 | ) ){ | ||
134 | |||
135 | case OPimContactAccess::RegExp:{ | ||
136 | QRegExp expr ( query.field(i), | ||
137 | !(settings & OPimContactAccess::IgnoreCase), | ||
138 | false ); | ||
139 | if ( expr.find ( find( uid_array[it] ).field(i), 0 ) == -1 ) | ||
140 | allcorrect = false; | ||
141 | } | ||
142 | break; | ||
143 | case OPimContactAccess::WildCards:{ | ||
144 | QRegExp expr ( query.field(i), | ||
145 | !(settings & OPimContactAccess::IgnoreCase), | ||
146 | true ); | ||
147 | if ( expr.find ( find( uid_array[it] ).field(i), 0 ) == -1 ) | ||
148 | allcorrect = false; | ||
149 | } | ||
150 | break; | ||
151 | case OPimContactAccess::ExactMatch:{ | ||
152 | if (settings & OPimContactAccess::IgnoreCase){ | ||
153 | if ( query.field(i).upper() != | ||
154 | find( uid_array[it] ).field(i).upper() ) | ||
155 | allcorrect = false; | ||
156 | }else{ | ||
157 | if ( query.field(i) != find( uid_array[it] ).field(i) ) | ||
158 | allcorrect = false; | ||
159 | } | ||
160 | } | ||
161 | break; | ||
162 | } | ||
163 | } | ||
164 | } | ||
165 | } | ||
166 | if ( allcorrect ){ | ||
167 | m_currentQuery[arraycounter++] = uid_array[it]; | ||
168 | } | ||
169 | } | ||
170 | |||
171 | // Shrink to fit.. | ||
172 | m_currentQuery.resize(arraycounter); | ||
173 | |||
174 | return m_currentQuery; | ||
175 | |||
43 | } | 176 | } |
44 | 177 | ||
45 | UIDArray | 178 | const uint OPimContactAccessBackend::querySettings() const |
46 | OPimContactAccessBackend::sorted( const UIDArray& ar, bool asc, int sortOrder, | 179 | { |
180 | return ( OPimContactAccess::WildCards | ||
181 | | OPimContactAccess::IgnoreCase | ||
182 | | OPimContactAccess::RegExp | ||
183 | | OPimContactAccess::ExactMatch | ||
184 | | OPimContactAccess::DateDiff | ||
185 | | OPimContactAccess::DateYear | ||
186 | | OPimContactAccess::DateMonth | ||
187 | | OPimContactAccess::DateDay | ||
188 | ); | ||
189 | } | ||
190 | |||
191 | bool OPimContactAccessBackend::hasQuerySettings (uint querySettings) const | ||
192 | { | ||
193 | /* OPimContactAccess::IgnoreCase, DateDiff, DateYear, DateMonth, DateDay | ||
194 | * may be added with any of the other settings. IgnoreCase should never used alone. | ||
195 | * Wildcards, RegExp, ExactMatch should never used at the same time... | ||
196 | */ | ||
197 | |||
198 | // Step 1: Check whether the given settings are supported by this backend | ||
199 | if ( ( querySettings & ( | ||
200 | OPimContactAccess::IgnoreCase | ||
201 | | OPimContactAccess::WildCards | ||
202 | | OPimContactAccess::DateDiff | ||
203 | | OPimContactAccess::DateYear | ||
204 | | OPimContactAccess::DateMonth | ||
205 | | OPimContactAccess::DateDay | ||
206 | | OPimContactAccess::RegExp | ||
207 | | OPimContactAccess::ExactMatch | ||
208 | ) ) != querySettings ) | ||
209 | return false; | ||
210 | |||
211 | // Step 2: Check whether the given combinations are ok.. | ||
212 | |||
213 | // IngoreCase alone is invalid | ||
214 | if ( querySettings == OPimContactAccess::IgnoreCase ) | ||
215 | return false; | ||
216 | |||
217 | // WildCards, RegExp and ExactMatch should never used at the same time | ||
218 | switch ( querySettings & ~( OPimContactAccess::IgnoreCase | ||
219 | | OPimContactAccess::DateDiff | ||
220 | | OPimContactAccess::DateYear | ||
221 | | OPimContactAccess::DateMonth | ||
222 | | OPimContactAccess::DateDay | ||
223 | ) | ||
224 | ){ | ||
225 | case OPimContactAccess::RegExp: | ||
226 | return ( true ); | ||
227 | case OPimContactAccess::WildCards: | ||
228 | return ( true ); | ||
229 | case OPimContactAccess::ExactMatch: | ||
230 | return ( true ); | ||
231 | case 0: // one of the upper removed bits were set.. | ||
232 | return ( true ); | ||
233 | default: | ||
234 | return ( false ); | ||
235 | } | ||
236 | } | ||
237 | |||
238 | |||
239 | UIDArray OPimContactAccessBackend::sorted( const UIDArray& ar, bool asc, int sortOrder, | ||
47 | int filter, const QArray<int>& categories)const { | 240 | int filter, const QArray<int>& categories)const { |
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend.h b/libopie2/opiepim/backend/ocontactaccessbackend.h index efb04c7..ee6dbc2 100644 --- a/libopie2/opiepim/backend/ocontactaccessbackend.h +++ b/libopie2/opiepim/backend/ocontactaccessbackend.h | |||
@@ -82,3 +82,3 @@ class OPimContactAccessBackend: public OPimAccessBackend<OPimContact> { | |||
82 | */ | 82 | */ |
83 | virtual const uint querySettings() = 0; | 83 | virtual const uint querySettings() const; |
84 | 84 | ||
@@ -88,4 +88,8 @@ class OPimContactAccessBackend: public OPimAccessBackend<OPimContact> { | |||
88 | */ | 88 | */ |
89 | virtual bool hasQuerySettings (uint querySettings) const = 0; | 89 | virtual bool hasQuerySettings (uint querySettings) const; |
90 | 90 | ||
91 | /** | ||
92 | * Advanced search mechanism. | ||
93 | */ | ||
94 | UIDArray queryByExample( const UIDArray& uidlist, const OPimContact&, int settings, const QDateTime &d = QDateTime() ) const; | ||
91 | /** | 95 | /** |
@@ -94,3 +98,2 @@ class OPimContactAccessBackend: public OPimAccessBackend<OPimContact> { | |||
94 | //@{ | 98 | //@{ |
95 | UIDArray queryByExample( const OPimContact&, int settings, const QDateTime& d = QDateTime() )const; | ||
96 | UIDArray sorted( const UIDArray&, bool asc, int, int, const QArray<int>& )const; | 99 | UIDArray sorted( const UIDArray&, bool asc, int, int, const QArray<int>& )const; |
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp b/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp index 3d284f7..9375f43 100644 --- a/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp +++ b/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp | |||
@@ -129,3 +129,3 @@ namespace { | |||
129 | FindQuery(int uid); | 129 | FindQuery(int uid); |
130 | FindQuery(const QArray<int>& ); | 130 | FindQuery(const UIDArray& ); |
131 | ~FindQuery(); | 131 | ~FindQuery(); |
@@ -135,3 +135,3 @@ namespace { | |||
135 | QString multi()const; | 135 | QString multi()const; |
136 | QArray<int> m_uids; | 136 | UIDArray m_uids; |
137 | int m_uid; | 137 | int m_uid; |
@@ -145,3 +145,3 @@ namespace { | |||
145 | FindCustomQuery(int uid); | 145 | FindCustomQuery(int uid); |
146 | FindCustomQuery(const QArray<int>& ); | 146 | FindCustomQuery(const UIDArray& ); |
147 | ~FindCustomQuery(); | 147 | ~FindCustomQuery(); |
@@ -151,3 +151,3 @@ namespace { | |||
151 | QString multi()const; | 151 | QString multi()const; |
152 | QArray<int> m_uids; | 152 | UIDArray m_uids; |
153 | int m_uid; | 153 | int m_uid; |
@@ -296,3 +296,3 @@ namespace { | |||
296 | } | 296 | } |
297 | FindQuery::FindQuery(const QArray<int>& ints) | 297 | FindQuery::FindQuery(const UIDArray& ints) |
298 | : OSQLQuery(), m_uids( ints ){ | 298 | : OSQLQuery(), m_uids( ints ){ |
@@ -331,3 +331,3 @@ namespace { | |||
331 | } | 331 | } |
332 | FindCustomQuery::FindCustomQuery(const QArray<int>& ints) | 332 | FindCustomQuery::FindCustomQuery(const UIDArray& ints) |
333 | : OSQLQuery(), m_uids( ints ){ | 333 | : OSQLQuery(), m_uids( ints ){ |
@@ -424,3 +424,3 @@ bool OPimContactAccessBackend_SQL::wasChangedExternally() | |||
424 | 424 | ||
425 | QArray<int> OPimContactAccessBackend_SQL::allRecords() const | 425 | UIDArray OPimContactAccessBackend_SQL::allRecords() const |
426 | { | 426 | { |
@@ -487,3 +487,3 @@ OPimContact OPimContactAccessBackend_SQL::find ( int uid ) const | |||
487 | 487 | ||
488 | OPimContact OPimContactAccessBackend_SQL::find( int uid, const QArray<int>& queryUids, uint current, Frontend::CacheDirection direction ) const | 488 | OPimContact OPimContactAccessBackend_SQL::find( int uid, const UIDArray& queryUids, uint current, Frontend::CacheDirection direction ) const |
489 | { | 489 | { |
@@ -530,3 +530,4 @@ OPimContact OPimContactAccessBackend_SQL::find( int uid, const QArray<int>& quer | |||
530 | 530 | ||
531 | QArray<int> OPimContactAccessBackend_SQL::queryByExample ( const OPimContact &query, int settings, const QDateTime& qd ) | 531 | UIDArray OPimContactAccessBackend_SQL::queryByExample ( const OPimContact &query, int settings, |
532 | const QDateTime& qd ) const | ||
532 | { | 533 | { |
@@ -641,3 +642,3 @@ QArray<int> OPimContactAccessBackend_SQL::queryByExample ( const OPimContact &qu | |||
641 | if ( res.state() != OSQLResult::Success ){ | 642 | if ( res.state() != OSQLResult::Success ){ |
642 | QArray<int> empty; | 643 | UIDArray empty; |
643 | return empty; | 644 | return empty; |
@@ -645,3 +646,3 @@ QArray<int> OPimContactAccessBackend_SQL::queryByExample ( const OPimContact &qu | |||
645 | 646 | ||
646 | QArray<int> list = extractUids( res ); | 647 | UIDArray list = extractUids( res ); |
647 | 648 | ||
@@ -650,3 +651,3 @@ QArray<int> OPimContactAccessBackend_SQL::queryByExample ( const OPimContact &qu | |||
650 | 651 | ||
651 | QArray<int> OPimContactAccessBackend_SQL::matchRegexp( const QRegExp &r ) const | 652 | UIDArray OPimContactAccessBackend_SQL::matchRegexp( const QRegExp &r ) const |
652 | { | 653 | { |
@@ -681,3 +682,3 @@ QArray<int> OPimContactAccessBackend_SQL::matchRegexp( const QRegExp &r ) const | |||
681 | 682 | ||
682 | const uint OPimContactAccessBackend_SQL::querySettings() | 683 | const uint OPimContactAccessBackend_SQL::querySettings() const |
683 | { | 684 | { |
@@ -740,3 +741,4 @@ bool OPimContactAccessBackend_SQL::hasQuerySettings (uint querySettings) const | |||
740 | 741 | ||
741 | QArray<int> OPimContactAccessBackend_SQL::sorted( bool asc, int , int , int ) | 742 | UIDArray OPimContactAccessBackend_SQL::sorted( const UIDArray& ar, bool asc, int sortOrder, |
743 | int filter, const QArray<int>& categories )const | ||
742 | { | 744 | { |
@@ -745,9 +747,103 @@ QArray<int> OPimContactAccessBackend_SQL::sorted( bool asc, int , int , int ) | |||
745 | 747 | ||
746 | QString query = "SELECT uid FROM addressbook "; | 748 | QString query = "SELECT uid FROM addressbook"; |
747 | query += "ORDER BY \"Last Name\" "; | 749 | |
750 | query += " WHERE ("; | ||
751 | for ( uint i = 0; i < ar.count(); i++ ) { | ||
752 | query += " uid = " + QString::number( ar[i] ) + " OR"; | ||
753 | } | ||
754 | query.remove( query.length()-2, 2 ); // Hmmmm.. | ||
755 | query += ")"; | ||
756 | |||
757 | |||
758 | if ( filter != OPimBase::FilterOff ){ | ||
759 | if ( filter & OPimContactAccess::DoNotShowWithCategory ){ | ||
760 | query += " AND ( \"Categories\" == '' )"; | ||
761 | } else if ( filter & OPimBase::FilterCategory ){ | ||
762 | query += " AND ("; | ||
763 | for ( uint i = 0; i < categories.count(); i++ ){ | ||
764 | query += "\"Categories\" LIKE"; | ||
765 | query += QString( " '%" ) + QString::number( categories[i] ) + "%' OR"; | ||
766 | } | ||
767 | query.remove( query.length()-2, 2 ); // Hmmmm.. | ||
768 | query += ")"; | ||
769 | } | ||
770 | |||
771 | if ( filter & OPimContactAccess::DoNotShowWithoutChildren ){ | ||
772 | query += " AND ( \"Children\" != '' )"; | ||
773 | } | ||
774 | |||
775 | if ( filter & OPimContactAccess::DoNotShowWithoutAnniversary ){ | ||
776 | query += " AND ( \"Anniversary\" != '' )"; | ||
777 | } | ||
778 | |||
779 | if ( filter & OPimContactAccess::DoNotShowWithoutBirthday ){ | ||
780 | query += " AND ( \"Birthday\" != '' )"; | ||
781 | } | ||
782 | |||
783 | if ( filter & OPimContactAccess::DoNotShowWithoutHomeAddress ){ | ||
784 | // Expect that no Street means no Address, too! (eilers) | ||
785 | query += " AND ( \"Home Street\" != '' )"; | ||
786 | } | ||
787 | |||
788 | if ( filter & OPimContactAccess::DoNotShowWithoutBusinessAddress ){ | ||
789 | // Expect that no Street means no Address, too! (eilers) | ||
790 | query += " AND ( \"Business Street\" != '' )"; | ||
791 | } | ||
792 | |||
793 | } | ||
794 | |||
795 | query += " ORDER BY"; | ||
796 | |||
797 | switch ( sortOrder ) { | ||
798 | case OPimContactAccess::SortSummary: | ||
799 | query += " \"Notes\""; | ||
800 | break; | ||
801 | case OPimContactAccess::SortByCategory: | ||
802 | query += " \"Categories\""; | ||
803 | break; | ||
804 | case OPimContactAccess::SortByDate: | ||
805 | query += " \"\""; | ||
806 | break; | ||
807 | case OPimContactAccess::SortTitle: | ||
808 | query += " \"Name Title\""; | ||
809 | break; | ||
810 | case OPimContactAccess::SortFirstName: | ||
811 | query += " \"First Name\""; | ||
812 | break; | ||
813 | case OPimContactAccess::SortMiddleName: | ||
814 | query += " \"Middle Name\""; | ||
815 | break; | ||
816 | case OPimContactAccess::SortLastName: | ||
817 | query += " \"Last Name\""; | ||
818 | break; | ||
819 | case OPimContactAccess::SortFileAsName: | ||
820 | query += " \"File As\""; | ||
821 | break; | ||
822 | case OPimContactAccess::SortSuffix: | ||
823 | query += " \"Suffix\""; | ||
824 | break; | ||
825 | case OPimContactAccess::SortEmail: | ||
826 | query += " \"Default Email\""; | ||
827 | break; | ||
828 | case OPimContactAccess::SortNickname: | ||
829 | query += " \"Nickname\""; | ||
830 | break; | ||
831 | case OPimContactAccess::SortAnniversary: | ||
832 | query += " \"Anniversary\""; | ||
833 | break; | ||
834 | case OPimContactAccess::SortBirthday: | ||
835 | query += " \"Birthday\""; | ||
836 | break; | ||
837 | case OPimContactAccess::SortGender: | ||
838 | query += " \"Gender\""; | ||
839 | break; | ||
840 | default: | ||
841 | query += " \"Last Name\""; | ||
842 | } | ||
748 | 843 | ||
749 | if ( !asc ) | 844 | if ( !asc ) |
750 | query += "DESC"; | 845 | query += " DESC"; |
846 | |||
751 | 847 | ||
752 | // odebug << "sorted query is: " << query << "" << oendl; | 848 | odebug << "sorted query is: " << query << "" << oendl; |
753 | 849 | ||
@@ -756,3 +852,3 @@ QArray<int> OPimContactAccessBackend_SQL::sorted( bool asc, int , int , int ) | |||
756 | if ( res.state() != OSQLResult::Success ){ | 852 | if ( res.state() != OSQLResult::Success ){ |
757 | QArray<int> empty; | 853 | UIDArray empty; |
758 | return empty; | 854 | return empty; |
@@ -760,3 +856,3 @@ QArray<int> OPimContactAccessBackend_SQL::sorted( bool asc, int , int , int ) | |||
760 | 856 | ||
761 | QArray<int> list = extractUids( res ); | 857 | UIDArray list = extractUids( res ); |
762 | 858 | ||
@@ -788,3 +884,3 @@ void OPimContactAccessBackend_SQL::update() | |||
788 | 884 | ||
789 | QArray<int> OPimContactAccessBackend_SQL::extractUids( OSQLResult& res ) const | 885 | UIDArray OPimContactAccessBackend_SQL::extractUids( OSQLResult& res ) const |
790 | { | 886 | { |
@@ -795,3 +891,3 @@ QArray<int> OPimContactAccessBackend_SQL::extractUids( OSQLResult& res ) const | |||
795 | OSQLResultItem::ValueList::Iterator it; | 891 | OSQLResultItem::ValueList::Iterator it; |
796 | QArray<int> ints(list.count() ); | 892 | UIDArray ints(list.count() ); |
797 | odebug << " count = " << list.count() << "" << oendl; | 893 | odebug << " count = " << list.count() << "" << oendl; |
@@ -839,3 +935,3 @@ QMap<int, QString> OPimContactAccessBackend_SQL::requestNonCustom( int uid ) co | |||
839 | /* Returns contact requested by uid and fills cache with contacts requested by uids in the cachelist */ | 935 | /* Returns contact requested by uid and fills cache with contacts requested by uids in the cachelist */ |
840 | OPimContact OPimContactAccessBackend_SQL::requestContactsAndCache( int uid, const QArray<int>& uidlist )const | 936 | OPimContact OPimContactAccessBackend_SQL::requestContactsAndCache( int uid, const UIDArray& uidlist )const |
841 | { | 937 | { |
@@ -845,3 +941,3 @@ OPimContact OPimContactAccessBackend_SQL::requestContactsAndCache( int uid, cons | |||
845 | // by using the cache.. | 941 | // by using the cache.. |
846 | QArray<int> cachelist = uidlist; | 942 | UIDArray cachelist = uidlist; |
847 | OPimContact retContact; | 943 | OPimContact retContact; |
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_sql.h b/libopie2/opiepim/backend/ocontactaccessbackend_sql.h index 28d9746..299c175 100644 --- a/libopie2/opiepim/backend/ocontactaccessbackend_sql.h +++ b/libopie2/opiepim/backend/ocontactaccessbackend_sql.h | |||
@@ -72,13 +72,13 @@ class OPimContactAccessBackend_SQL : public OPimContactAccessBackend { | |||
72 | 72 | ||
73 | QArray<int> allRecords() const; | 73 | UIDArray allRecords() const; |
74 | 74 | ||
75 | OPimContact find( int uid ) const; | 75 | OPimContact find( int uid ) const; |
76 | OPimContact find( int uid, const QArray<int>& items, uint cur, Frontend::CacheDirection ) const; | 76 | OPimContact find( int uid, const UIDArray& items, uint cur, Frontend::CacheDirection ) const; |
77 | 77 | ||
78 | QArray<int> queryByExample ( const OPimContact &query, int settings, | 78 | UIDArray queryByExample ( const OPimContact &query, int settings, |
79 | const QDateTime& d ); | 79 | const QDateTime& d ) const; |
80 | 80 | ||
81 | QArray<int> matchRegexp( const QRegExp &r ) const; | 81 | UIDArray matchRegexp( const QRegExp &r ) const; |
82 | 82 | ||
83 | const uint querySettings(); | 83 | const uint querySettings() const; |
84 | 84 | ||
@@ -86,5 +86,6 @@ class OPimContactAccessBackend_SQL : public OPimContactAccessBackend { | |||
86 | 86 | ||
87 | // Currently only asc implemented.. | 87 | UIDArray sorted( const UIDArray& ar, bool asc, int sortOrder, |
88 | QArray<int> sorted( bool asc, int , int , int ); | 88 | int filter, const QArray<int>& categories)const; |
89 | bool add ( const OPimContact &newcontact ); | 89 | |
90 | bool add ( const OPimContact &newcontact ); | ||
90 | 91 | ||
@@ -96,3 +97,3 @@ class OPimContactAccessBackend_SQL : public OPimContactAccessBackend { | |||
96 | private: | 97 | private: |
97 | QArray<int> extractUids( Opie::DB::OSQLResult& res ) const; | 98 | UIDArray extractUids( Opie::DB::OSQLResult& res ) const; |
98 | QMap<int, QString> requestNonCustom( int uid ) const; | 99 | QMap<int, QString> requestNonCustom( int uid ) const; |
@@ -106,3 +107,3 @@ class OPimContactAccessBackend_SQL : public OPimContactAccessBackend { | |||
106 | QString m_fileName; | 107 | QString m_fileName; |
107 | QArray<int> m_uids; | 108 | UIDArray m_uids; |
108 | 109 | ||
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp b/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp index 5bb21c7..f3b6d56 100644 --- a/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp +++ b/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp | |||
@@ -159,5 +159,5 @@ OPimContact OPimContactAccessBackend_VCard::find ( int uid ) const | |||
159 | 159 | ||
160 | QArray<int> OPimContactAccessBackend_VCard::allRecords() const | 160 | UIDArray OPimContactAccessBackend_VCard::allRecords() const |
161 | { | 161 | { |
162 | QArray<int> ar( m_map.count() ); | 162 | UIDArray ar( m_map.count() ); |
163 | QMap<int, OPimContact>::ConstIterator it; | 163 | QMap<int, OPimContact>::ConstIterator it; |
@@ -171,12 +171,2 @@ QArray<int> OPimContactAccessBackend_VCard::allRecords() const | |||
171 | 171 | ||
172 | const uint OPimContactAccessBackend_VCard::querySettings() | ||
173 | { | ||
174 | return 0; // No search possible | ||
175 | } | ||
176 | |||
177 | bool OPimContactAccessBackend_VCard::hasQuerySettings (uint ) const | ||
178 | { | ||
179 | return false; // No search possible, therefore all settings invalid ;) | ||
180 | } | ||
181 | |||
182 | bool OPimContactAccessBackend_VCard::wasChangedExternally() | 172 | bool OPimContactAccessBackend_VCard::wasChangedExternally() |
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_vcard.h b/libopie2/opiepim/backend/ocontactaccessbackend_vcard.h index b734530..3591988 100644 --- a/libopie2/opiepim/backend/ocontactaccessbackend_vcard.h +++ b/libopie2/opiepim/backend/ocontactaccessbackend_vcard.h | |||
@@ -60,6 +60,4 @@ class OPimContactAccessBackend_VCard : public OPimContactAccessBackend { | |||
60 | OPimContact find ( int uid ) const; | 60 | OPimContact find ( int uid ) const; |
61 | QArray<int> allRecords() const; | 61 | UIDArray allRecords() const; |
62 | 62 | ||
63 | const uint querySettings(); | ||
64 | bool hasQuerySettings (uint querySettings) const; | ||
65 | bool wasChangedExternally(); | 63 | bool wasChangedExternally(); |
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp b/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp index 5df7253..f96f1bf 100644 --- a/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp +++ b/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp | |||
@@ -185,5 +185,5 @@ bool OPimContactAccessBackend_XML::wasChangedExternally() | |||
185 | 185 | ||
186 | QArray<int> OPimContactAccessBackend_XML::allRecords() const | 186 | UIDArray OPimContactAccessBackend_XML::allRecords() const |
187 | { | 187 | { |
188 | QArray<int> uid_list( m_contactList.count() ); | 188 | UIDArray uid_list( m_contactList.count() ); |
189 | 189 | ||
@@ -211,141 +211,6 @@ OPimContact OPimContactAccessBackend_XML::find ( int uid ) const | |||
211 | 211 | ||
212 | QArray<int> OPimContactAccessBackend_XML::queryByExample ( const OPimContact &query, int settings, | ||
213 | const QDateTime& d )const | ||
214 | { | ||
215 | QArray<int> m_currentQuery( m_contactList.count() ); | ||
216 | QListIterator<OPimContact> it( m_contactList ); | ||
217 | uint arraycounter = 0; | ||
218 | |||
219 | for( ; it.current(); ++it ){ | ||
220 | /* Search all fields and compare them with query object. Store them into list | ||
221 | * if all fields matches. | ||
222 | */ | ||
223 | QDate* queryDate = 0l; | ||
224 | QDate* checkDate = 0l; | ||
225 | bool allcorrect = true; | ||
226 | for ( int i = 0; i < Qtopia::Groups; i++ ) { | ||
227 | // Birthday and anniversary are special nonstring fields and should | ||
228 | // be handled specially | ||
229 | switch ( i ){ | ||
230 | case Qtopia::Birthday: | ||
231 | queryDate = new QDate( query.birthday() ); | ||
232 | checkDate = new QDate( (*it)->birthday() ); | ||
233 | // fall through | ||
234 | case Qtopia::Anniversary: | ||
235 | if ( queryDate == 0l ){ | ||
236 | queryDate = new QDate( query.anniversary() ); | ||
237 | checkDate = new QDate( (*it)->anniversary() ); | ||
238 | } | ||
239 | |||
240 | if ( queryDate->isValid() ){ | ||
241 | if( checkDate->isValid() ){ | ||
242 | if ( settings & OPimContactAccess::DateYear ){ | ||
243 | if ( queryDate->year() != checkDate->year() ) | ||
244 | allcorrect = false; | ||
245 | } | ||
246 | if ( settings & OPimContactAccess::DateMonth ){ | ||
247 | if ( queryDate->month() != checkDate->month() ) | ||
248 | allcorrect = false; | ||
249 | } | ||
250 | if ( settings & OPimContactAccess::DateDay ){ | ||
251 | if ( queryDate->day() != checkDate->day() ) | ||
252 | allcorrect = false; | ||
253 | } | ||
254 | if ( settings & OPimContactAccess::DateDiff ) { | ||
255 | QDate current; | ||
256 | // If we get an additional date, we | ||
257 | // will take this date instead of | ||
258 | // the current one.. | ||
259 | if ( !d.date().isValid() ) | ||
260 | current = QDate::currentDate(); | ||
261 | else | ||
262 | current = d.date(); | ||
263 | |||
264 | // We have to equalize the year, otherwise | ||
265 | // the search will fail.. | ||
266 | checkDate->setYMD( current.year(), | ||
267 | checkDate->month(), | ||
268 | checkDate->day() ); | ||
269 | if ( *checkDate < current ) | ||
270 | checkDate->setYMD( current.year()+1, | ||
271 | checkDate->month(), | ||
272 | checkDate->day() ); | ||
273 | |||
274 | // Check whether the birthday/anniversary date is between | ||
275 | // the current/given date and the maximum date | ||
276 | // ( maximum time range ) ! | ||
277 | if ( current.daysTo( *queryDate ) >= 0 ){ | ||
278 | if ( !( ( *checkDate >= current ) && | ||
279 | ( *checkDate <= *queryDate ) ) ){ | ||
280 | allcorrect = false; | ||
281 | } | ||
282 | } | ||
283 | } | ||
284 | } else{ | ||
285 | // checkDate is invalid. Therefore this entry is always rejected | ||
286 | allcorrect = false; | ||
287 | } | ||
288 | } | ||
289 | 212 | ||
290 | delete queryDate; | 213 | UIDArray OPimContactAccessBackend_XML::matchRegexp( const QRegExp &r ) const |
291 | queryDate = 0l; | ||
292 | delete checkDate; | ||
293 | checkDate = 0l; | ||
294 | break; | ||
295 | default: | ||
296 | /* Just compare fields which are not empty in the query object */ | ||
297 | if ( !query.field(i).isEmpty() ){ | ||
298 | switch ( settings & ~( OPimContactAccess::IgnoreCase | ||
299 | | OPimContactAccess::DateDiff | ||
300 | | OPimContactAccess::DateYear | ||
301 | | OPimContactAccess::DateMonth | ||
302 | | OPimContactAccess::DateDay | ||
303 | | OPimContactAccess::MatchOne | ||
304 | ) ){ | ||
305 | |||
306 | case OPimContactAccess::RegExp:{ | ||
307 | QRegExp expr ( query.field(i), | ||
308 | !(settings & OPimContactAccess::IgnoreCase), | ||
309 | false ); | ||
310 | if ( expr.find ( (*it)->field(i), 0 ) == -1 ) | ||
311 | allcorrect = false; | ||
312 | } | ||
313 | break; | ||
314 | case OPimContactAccess::WildCards:{ | ||
315 | QRegExp expr ( query.field(i), | ||
316 | !(settings & OPimContactAccess::IgnoreCase), | ||
317 | true ); | ||
318 | if ( expr.find ( (*it)->field(i), 0 ) == -1 ) | ||
319 | allcorrect = false; | ||
320 | } | ||
321 | break; | ||
322 | case OPimContactAccess::ExactMatch:{ | ||
323 | if (settings & OPimContactAccess::IgnoreCase){ | ||
324 | if ( query.field(i).upper() != | ||
325 | (*it)->field(i).upper() ) | ||
326 | allcorrect = false; | ||
327 | }else{ | ||
328 | if ( query.field(i) != (*it)->field(i) ) | ||
329 | allcorrect = false; | ||
330 | } | ||
331 | } | ||
332 | break; | ||
333 | } | ||
334 | } | ||
335 | } | ||
336 | } | ||
337 | if ( allcorrect ){ | ||
338 | m_currentQuery[arraycounter++] = (*it)->uid(); | ||
339 | } | ||
340 | } | ||
341 | |||
342 | // Shrink to fit.. | ||
343 | m_currentQuery.resize(arraycounter); | ||
344 | |||
345 | return m_currentQuery; | ||
346 | } | ||
347 | |||
348 | QArray<int> OPimContactAccessBackend_XML::matchRegexp( const QRegExp &r ) const | ||
349 | { | 214 | { |
350 | QArray<int> m_currentQuery( m_contactList.count() ); | 215 | UIDArray m_currentQuery( m_contactList.count() ); |
351 | QListIterator<OPimContact> it( m_contactList ); | 216 | QListIterator<OPimContact> it( m_contactList ); |
@@ -365,61 +230,3 @@ QArray<int> OPimContactAccessBackend_XML::matchRegexp( const QRegExp &r ) const | |||
365 | 230 | ||
366 | const uint OPimContactAccessBackend_XML::querySettings() | ||
367 | { | ||
368 | return ( OPimContactAccess::WildCards | ||
369 | | OPimContactAccess::IgnoreCase | ||
370 | | OPimContactAccess::RegExp | ||
371 | | OPimContactAccess::ExactMatch | ||
372 | | OPimContactAccess::DateDiff | ||
373 | | OPimContactAccess::DateYear | ||
374 | | OPimContactAccess::DateMonth | ||
375 | | OPimContactAccess::DateDay | ||
376 | ); | ||
377 | } | ||
378 | 231 | ||
379 | bool OPimContactAccessBackend_XML::hasQuerySettings (uint querySettings) const | ||
380 | { | ||
381 | /* OPimContactAccess::IgnoreCase, DateDiff, DateYear, DateMonth, DateDay | ||
382 | * may be added with any of the other settings. IgnoreCase should never used alone. | ||
383 | * Wildcards, RegExp, ExactMatch should never used at the same time... | ||
384 | */ | ||
385 | |||
386 | // Step 1: Check whether the given settings are supported by this backend | ||
387 | if ( ( querySettings & ( | ||
388 | OPimContactAccess::IgnoreCase | ||
389 | | OPimContactAccess::WildCards | ||
390 | | OPimContactAccess::DateDiff | ||
391 | | OPimContactAccess::DateYear | ||
392 | | OPimContactAccess::DateMonth | ||
393 | | OPimContactAccess::DateDay | ||
394 | | OPimContactAccess::RegExp | ||
395 | | OPimContactAccess::ExactMatch | ||
396 | ) ) != querySettings ) | ||
397 | return false; | ||
398 | |||
399 | // Step 2: Check whether the given combinations are ok.. | ||
400 | |||
401 | // IngoreCase alone is invalid | ||
402 | if ( querySettings == OPimContactAccess::IgnoreCase ) | ||
403 | return false; | ||
404 | |||
405 | // WildCards, RegExp and ExactMatch should never used at the same time | ||
406 | switch ( querySettings & ~( OPimContactAccess::IgnoreCase | ||
407 | | OPimContactAccess::DateDiff | ||
408 | | OPimContactAccess::DateYear | ||
409 | | OPimContactAccess::DateMonth | ||
410 | | OPimContactAccess::DateDay | ||
411 | ) | ||
412 | ){ | ||
413 | case OPimContactAccess::RegExp: | ||
414 | return ( true ); | ||
415 | case OPimContactAccess::WildCards: | ||
416 | return ( true ); | ||
417 | case OPimContactAccess::ExactMatch: | ||
418 | return ( true ); | ||
419 | case 0: // one of the upper removed bits were set.. | ||
420 | return ( true ); | ||
421 | default: | ||
422 | return ( false ); | ||
423 | } | ||
424 | } | ||
425 | 232 | ||
@@ -427,3 +234,3 @@ bool OPimContactAccessBackend_XML::hasQuerySettings (uint querySettings) const | |||
427 | // Currently only asc implemented.. | 234 | // Currently only asc implemented.. |
428 | QArray<int> OPimContactAccessBackend_XML::sorted( bool asc, int , int , int ) | 235 | UIDArray OPimContactAccessBackend_XML::sorted( bool asc, int , int , int ) |
429 | { | 236 | { |
@@ -431,3 +238,3 @@ QArray<int> OPimContactAccessBackend_XML::sorted( bool asc, int , int , int ) | |||
431 | QStringList names; | 238 | QStringList names; |
432 | QArray<int> m_currentQuery( m_contactList.count() ); | 239 | UIDArray m_currentQuery( m_contactList.count() ); |
433 | 240 | ||
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_xml.h b/libopie2/opiepim/backend/ocontactaccessbackend_xml.h index 3e4f1e1..39378ec 100644 --- a/libopie2/opiepim/backend/ocontactaccessbackend_xml.h +++ b/libopie2/opiepim/backend/ocontactaccessbackend_xml.h | |||
@@ -60,3 +60,3 @@ class OPimContactAccessBackend_XML : public OPimContactAccessBackend { | |||
60 | 60 | ||
61 | QArray<int> allRecords() const; | 61 | UIDArray allRecords() const; |
62 | 62 | ||
@@ -64,8 +64,3 @@ class OPimContactAccessBackend_XML : public OPimContactAccessBackend { | |||
64 | 64 | ||
65 | QArray<int> queryByExample ( const OPimContact &query, int settings, const QDateTime& d )const; | 65 | UIDArray matchRegexp( const QRegExp &r ) const; |
66 | QArray<int> matchRegexp( const QRegExp &r ) const; | ||
67 | |||
68 | const uint querySettings(); | ||
69 | |||
70 | bool hasQuerySettings (uint querySettings) const; | ||
71 | 66 | ||
diff --git a/libopie2/opiepim/backend/opimaccessbackend.h b/libopie2/opiepim/backend/opimaccessbackend.h index 0d112c9..7321758 100644 --- a/libopie2/opiepim/backend/opimaccessbackend.h +++ b/libopie2/opiepim/backend/opimaccessbackend.h | |||
@@ -68,2 +68,21 @@ public: | |||
68 | 68 | ||
69 | //@{ | ||
70 | // FIXME: Uncommented some of the abstract functions below. This should be removed as they are implemented in | ||
71 | // all typespecifc backenends (eilers) | ||
72 | /** | ||
73 | * Return all possible settings for queryByExample() | ||
74 | * @return All settings provided by the current backend | ||
75 | * (i.e.: query_WildCards & query_IgnoreCase) | ||
76 | * See implementation in the specific backends for contacts, todo and dates. | ||
77 | */ | ||
78 | virtual const uint querySettings() const { return 0; } /* FIXME: Make Abstrakt !! = 0; */ | ||
79 | |||
80 | /** | ||
81 | * Check whether settings are correct for queryByExample() | ||
82 | * See implementation in the specific backends for OPimContactAccess, OPimTodoAccess and ODateBookAccess. | ||
83 | * @return <i>true</i> if the given settings are correct and possible. | ||
84 | */ | ||
85 | virtual bool hasQuerySettings (uint querySettings) const { return false; } /* FIXME: Make Abstrakt !! = 0; */ | ||
86 | //@} | ||
87 | |||
69 | 88 | ||
@@ -72,5 +91,7 @@ public: | |||
72 | virtual UIDArray matchRegexp(const QRegExp &r) const; | 91 | virtual UIDArray matchRegexp(const QRegExp &r) const; |
73 | virtual UIDArray queryByExample( const T& t, int settings, const QDateTime& d = QDateTime() )const = 0; | 92 | virtual UIDArray queryByExample( const UIDArray&, const T& t, |
74 | virtual UIDArray queryByExample( const OPimRecord* rec, int, const QDateTime& d = QDateTime() )const; | 93 | int settings, const QDateTime& d = QDateTime() )const { return UIDArray(); } /* FIXME: Make Abstrakt !! = 0; */ |
75 | virtual UIDArray sorted( const UIDArray&, bool asc, int sortOrder, int sortFilter, const QArray<int>& cats )const; | 94 | virtual UIDArray queryByExample( const T& t, int settings, const QDateTime& d = QDateTime() )const; |
95 | virtual UIDArray queryByExample( const OPimRecord* rec, int settings, const QDateTime& d = QDateTime() )const; | ||
96 | virtual UIDArray sorted( const UIDArray&, bool asc, int sortOrder, int sortFilter, const QArray<int>& cats )const = 0; | ||
76 | virtual UIDArray sorted( bool asc, int sortOrder, int sortFilter, const QArray<int>& cats )const; | 97 | virtual UIDArray sorted( bool asc, int sortOrder, int sortFilter, const QArray<int>& cats )const; |
@@ -152,2 +173,9 @@ UIDArray OPimAccessBackend<T>::matchRegexp( const QRegExp& reg )const { | |||
152 | template <class T> | 173 | template <class T> |
174 | UIDArray OPimAccessBackend<T>::queryByExample( const T& rec, int settings, | ||
175 | const QDateTime& datetime )const { | ||
176 | |||
177 | return queryByExample( allRecords(), rec, settings, datetime ); | ||
178 | } | ||
179 | |||
180 | template <class T> | ||
153 | UIDArray OPimAccessBackend<T>::queryByExample( const OPimRecord* rec, int settings, | 181 | UIDArray OPimAccessBackend<T>::queryByExample( const OPimRecord* rec, int settings, |
@@ -163,8 +191,2 @@ UIDArray OPimAccessBackend<T>::queryByExample( const OPimRecord* rec, int settin | |||
163 | template <class T> | 191 | template <class T> |
164 | UIDArray OPimAccessBackend<T>::sorted( const UIDArray& ids, bool, | ||
165 | int, int, const QArray<int>& ) const { | ||
166 | return ids; | ||
167 | } | ||
168 | |||
169 | template <class T> | ||
170 | UIDArray OPimAccessBackend<T>::sorted( bool asc, int order, int filter, | 192 | UIDArray OPimAccessBackend<T>::sorted( bool asc, int order, int filter, |
diff --git a/libopie2/opiepim/core/ocontactaccess.h b/libopie2/opiepim/core/ocontactaccess.h index 691ece2..bd85b4e 100644 --- a/libopie2/opiepim/core/ocontactaccess.h +++ b/libopie2/opiepim/core/ocontactaccess.h | |||
@@ -62,10 +62,25 @@ class OPimContactAccess: public QObject, public OPimAccessTemplate<OPimContact> | |||
62 | public: | 62 | public: |
63 | /** | ||
64 | * Filter for sorted() | ||
65 | * @see SortFilterBase in OPimBase | ||
66 | */ | ||
63 | enum SortFilter { | 67 | enum SortFilter { |
64 | DoNotShowNoneChildren = FilterCustom<<1, | 68 | /** Don't return entries who don't have children */ |
65 | DoNotShowNoneAnniversary = FilterCustom<<2, | 69 | DoNotShowWithoutChildren = FilterCustom<<1, |
66 | DoNotShowNoneBirthday = FilterCustom<<3, | 70 | /** Don't return entries who don't have an anniversary */ |
67 | DoNotShowNoHomeAddress = FilterCustom<<4, | 71 | DoNotShowWithoutAnniversary = FilterCustom<<2, |
68 | DoNotShowNoBusinessAddress = FilterCustom<<5 | 72 | /** Don't return entries who don't have a birthday */ |
73 | DoNotShowWithoutBirthday = FilterCustom<<3, | ||
74 | /** Don't return entries who don't have a home address */ | ||
75 | DoNotShowWithoutHomeAddress = FilterCustom<<4, | ||
76 | /** Don't return entries who don't have a business address */ | ||
77 | DoNotShowWithoutBusinessAddress = FilterCustom<<5, | ||
78 | /** Don't return entries which hava any category */ | ||
79 | DoNotShowWithCategory = FilterCustom << 6 | ||
69 | }; | 80 | }; |
70 | 81 | ||
82 | /** | ||
83 | * Sort order for sorted() | ||
84 | * @see SortOrderBase in OPimBase | ||
85 | */ | ||
71 | enum SortOrder { | 86 | enum SortOrder { |
@@ -74,2 +89,3 @@ class OPimContactAccess: public QObject, public OPimAccessTemplate<OPimContact> | |||
74 | SortMiddleName, | 89 | SortMiddleName, |
90 | SortLastName, | ||
75 | SortSuffix, | 91 | SortSuffix, |
@@ -77,2 +93,3 @@ class OPimContactAccess: public QObject, public OPimAccessTemplate<OPimContact> | |||
77 | SortNickname, | 93 | SortNickname, |
94 | SortFileAsName, | ||
78 | SortAnniversary, | 95 | SortAnniversary, |
@@ -101,5 +118,7 @@ class OPimContactAccess: public QObject, public OPimAccessTemplate<OPimContact> | |||
101 | 118 | ||
102 | /** Return all possible settings. | 119 | /** |
120 | * Return all possible settings for queryByExample(). | ||
103 | * @return All settings provided by the current backend | 121 | * @return All settings provided by the current backend |
104 | * (i.e.: query_WildCards & query_IgnoreCase) | 122 | * (i.e.: WildCards & IgnoreCase) |
123 | * @see QuerySettings in OPimBase for details of the parameter | ||
105 | */ | 124 | */ |
@@ -107,4 +126,6 @@ class OPimContactAccess: public QObject, public OPimAccessTemplate<OPimContact> | |||
107 | 126 | ||
108 | /** Check whether settings are correct. | 127 | /** |
128 | * Check whether settings are correct for queryByExample(). | ||
109 | * @return <i>true</i> if the given settings are correct and possible. | 129 | * @return <i>true</i> if the given settings are correct and possible. |
130 | * @see QuerySettings in OPimBase for details of the parameter | ||
110 | */ | 131 | */ |
diff --git a/libopie2/opiepim/core/opimaccesstemplate.h b/libopie2/opiepim/core/opimaccesstemplate.h index 2deb92a..073d5f9 100644 --- a/libopie2/opiepim/core/opimaccesstemplate.h +++ b/libopie2/opiepim/core/opimaccesstemplate.h | |||
@@ -92,11 +92,48 @@ public: | |||
92 | uint current, typename OTemplateBase<T>::CacheDirection dir = OTemplateBase<T>::Forward )const; | 92 | uint current, typename OTemplateBase<T>::CacheDirection dir = OTemplateBase<T>::Forward )const; |
93 | virtual List sorted( const List&, bool ascending, int sortOrder, | 93 | //@} |
94 | |||
95 | /** | ||
96 | * Get sorted lists.. | ||
97 | * @see OPimContactAccess, OPimTodoAccess and ODateBookAccess regarding more info for the following params: | ||
98 | * @param list of UID's received by allRecords() or others... | ||
99 | * @param sortOrder Setting the sort order defined by enum SortOrder | ||
100 | * @param ascending Sort in ascending order if true, otherwise descending | ||
101 | * @param sortFilter Setting the sort filter defined by enum SortFilter | ||
102 | * @param cat number of category. | ||
103 | */ | ||
104 | virtual List sorted( const List& list, bool ascending, int sortOrder, | ||
94 | int sortFilter, int cat )const; | 105 | int sortFilter, int cat )const; |
95 | virtual List sorted( const List&, bool ascending, int sortOrder, | 106 | |
107 | /** | ||
108 | * Get sorted lists.. | ||
109 | * @see OPimContactAccess, OPimTodoAccess and ODateBookAccess regarding more info for the following params: | ||
110 | * @param list of UID's received by allRecords() or others... | ||
111 | * @param sortOrder Setting the sort order defined by enum SortOrder | ||
112 | * @param ascending Sort in ascending order if true, otherwise descending | ||
113 | * @param sortFilter Setting the sort filter defined by enum SortFilter | ||
114 | * @param cats List of categories. | ||
115 | */ | ||
116 | virtual List sorted( const List& list, bool ascending, int sortOrder, | ||
96 | int sortFilter, const QArray<UID>& cats )const; | 117 | int sortFilter, const QArray<UID>& cats )const; |
118 | |||
119 | /** | ||
120 | * Get sorted lists.. | ||
121 | * @see OPimContactAccess, OPimTodoAccess and ODateBookAccess regarding more info for the following params: | ||
122 | * @param ascending Sort in ascending order if true, otherwise descending | ||
123 | * @param sortOrder Setting the sort order defined by enum SortOrder | ||
124 | * @param sortFilter Setting the sort filter defined by enum SortFilter | ||
125 | * @param cat number of category. | ||
126 | */ | ||
97 | virtual List sorted( bool ascending, int sortOrder, int sortFilter, int cat )const; | 127 | virtual List sorted( bool ascending, int sortOrder, int sortFilter, int cat )const; |
98 | virtual List sorted( bool ascending, int sortOrder, int sortOrder, | ||
99 | const QArray<UID>& cats )const; | ||
100 | //@} | ||
101 | 128 | ||
129 | /** | ||
130 | * Get sorted lists.. | ||
131 | * @see OPimContactAccess, OPimTodoAccess and ODateBookAccess regarding more info for the following params: | ||
132 | * @param ascending Sort in ascending order if true, otherwise descending | ||
133 | * @param sortOrder Setting the sort order defined by enum SortOrder | ||
134 | * @param sortFilter Setting the sort filter defined by enum SortFilter | ||
135 | * @param cats List of categories. | ||
136 | */ | ||
137 | virtual List sorted( bool ascending, int sortOrder, int sortFilter, | ||
138 | const QArray<UID>& cats )const; | ||
102 | /** | 139 | /** |
@@ -131,3 +168,2 @@ public: | |||
131 | void setReadAhead( uint count ); | 168 | void setReadAhead( uint count ); |
132 | virtual T cacheFind( int uid )const; | ||
133 | void cache( const T& )const; | 169 | void cache( const T& )const; |
@@ -260,7 +296,2 @@ T OPimAccessTemplate<T>::find( UID uid ) const{ | |||
260 | 296 | ||
261 | template <class T> | ||
262 | T OPimAccessTemplate<T>::cacheFind( int uid ) const | ||
263 | { | ||
264 | return m_cache.find( uid ); | ||
265 | } | ||
266 | 297 | ||
diff --git a/libopie2/opiepim/core/opimtemplatebase.h b/libopie2/opiepim/core/opimtemplatebase.h index b238a68..c8abab4 100644 --- a/libopie2/opiepim/core/opimtemplatebase.h +++ b/libopie2/opiepim/core/opimtemplatebase.h | |||
@@ -82,2 +82,3 @@ struct OPimBase { | |||
82 | virtual QArray<UID> records()const = 0; | 82 | virtual QArray<UID> records()const = 0; |
83 | //@} | ||
83 | 84 | ||
@@ -89,12 +90,22 @@ struct OPimBase { | |||
89 | enum QuerySettings { | 90 | enum QuerySettings { |
90 | WildCards = 0x0001, /** Use Wildcards */ | 91 | /** Use Wildcards */ |
91 | IgnoreCase = 0x0002, /** Ignore the Case */ | 92 | WildCards = 0x0001, |
92 | RegExp = 0x0004, /** Do a Regular Expression match */ | 93 | /** Ignore the Case */ |
93 | ExactMatch = 0x0008, /** It needs to exactly match */ | 94 | IgnoreCase = 0x0002, |
94 | MatchOne = 0x0010, /** Only one Entry must match */ | 95 | /** Do a Regular Expression match */ |
95 | DateDiff = 0x0020, /** Find all entries from today until given date */ | 96 | RegExp = 0x0004, |
96 | DateYear = 0x0040, /** The year matches */ | 97 | /** It needs to exactly match */ |
97 | DateMonth = 0x0080, /** The month matches */ | 98 | ExactMatch = 0x0008, |
98 | DateDay = 0x0100, /** The day matches */ | 99 | /** Only one Entry must match */ |
99 | LastItem = 0xffff /** the last possible name */ | 100 | MatchOne = 0x0010, |
101 | /** Find all entries from today until given date */ | ||
102 | DateDiff = 0x0020, | ||
103 | /** The year matches */ | ||
104 | DateYear = 0x0040, | ||
105 | /** The month matches */ | ||
106 | DateMonth = 0x0080, | ||
107 | /** The day matches */ | ||
108 | DateDay = 0x0100, | ||
109 | /** The last possible name matches */ | ||
110 | LastItem = 0xffff | ||
100 | }; | 111 | }; |
@@ -105,7 +116,12 @@ struct OPimBase { | |||
105 | enum SortOrderBase { | 116 | enum SortOrderBase { |
106 | SortSummary = 0, /** Sort by a Summary of the records */ | 117 | /** Sort by a Summary of the records */ |
107 | SortByCategory = 1, /** Sort by Category */ | 118 | SortSummary = 0, |
108 | SortByDate = 2, /** Sort by Date */ | 119 | /** Sort by Category */ |
109 | SortCustom = 10, /** The First available sort number for the OPimAccessTemplates */ | 120 | SortByCategory = 1, |
110 | LastSortOrderBase = 0xffff /** make this enum 16bit large */ | 121 | /** Sort by Date */ |
122 | SortByDate = 2, | ||
123 | /** The First available sort number for the OPimAccessTemplates */ | ||
124 | SortCustom = 10, | ||
125 | /** make this enum 16bit large */ | ||
126 | LastSortOrderBase = 0xffff | ||
111 | }; | 127 | }; |
@@ -113,4 +129,3 @@ struct OPimBase { | |||
113 | /** | 129 | /** |
114 | * Sort with the help of the \sa sorted function | 130 | * Sort a list of Items with the help of the sorted() function. |
115 | * a list of Items. | ||
116 | * The Item you provide in SortOrder will be used | 131 | * The Item you provide in SortOrder will be used |
@@ -118,7 +133,11 @@ struct OPimBase { | |||
118 | * | 133 | * |
119 | * @see sorted | 134 | * @see OPimAccessTemplate<>::sorted() |
120 | */ | 135 | */ |
121 | enum SortFilterBase { | 136 | enum SortFilterBase { |
137 | /** Do not filter anything. */ | ||
138 | FilterOff = 0, | ||
139 | /** Use given Categories for filter */ | ||
122 | FilterCategory = 1, | 140 | FilterCategory = 1, |
123 | FilterCustom = 1024, | 141 | /** The first available custom filter defined in the specialized frontends */ |
142 | FilterCustom = 1024, | ||
124 | LastSortFilterBase = 0xffffffff | 143 | LastSortFilterBase = 0xffffffff |
diff --git a/libopie2/opiepim/opiepim.pro b/libopie2/opiepim/opiepim.pro index 47ec6da..992fb8b 100644 --- a/libopie2/opiepim/opiepim.pro +++ b/libopie2/opiepim/opiepim.pro | |||
@@ -6,3 +6,3 @@ INTERFACES = | |||
6 | TARGET = opiepim2 | 6 | TARGET = opiepim2 |
7 | VERSION = 1.9.1 | 7 | VERSION = 1.8.6 |
8 | INCLUDEPATH += $(OPIEDIR)/include | 8 | INCLUDEPATH += $(OPIEDIR)/include |