|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the examples of the Qt Toolkit. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 //#ifdef SYMBIAN_BACKEND_USE_SQLITE |
|
42 |
|
43 #include <QObject> |
|
44 #include <QString> |
|
45 |
|
46 // If this macro is defined, searches like "102" are made on one table only |
|
47 #define SEARCH_FROM_ONE_TABLE |
|
48 |
|
49 // If defined, De Morgan's laws are used to replace ORs with ANDs in the |
|
50 // SELECT statement. |
|
51 #define USE_DEMORGAN |
|
52 |
|
53 class CQwertyKeyMap; |
|
54 class C12keyKeyMap; |
|
55 |
|
56 class CntSqlSearch// : public QObject |
|
57 { |
|
58 //Q_OBJECT |
|
59 |
|
60 public: |
|
61 |
|
62 enum SearchMethod { Undefinded, ZerosEndOfFirstToken, ZeroIsFirstNumber }; |
|
63 |
|
64 enum QueryType |
|
65 { |
|
66 TwelveTable = 0, |
|
67 QwertyEmail, |
|
68 QwertyContact |
|
69 }; |
|
70 |
|
71 public: |
|
72 CntSqlSearch(); |
|
73 |
|
74 ~CntSqlSearch(); |
|
75 |
|
76 QString CreatePredictiveSearch(const QString &pattern); |
|
77 |
|
78 |
|
79 private: |
|
80 |
|
81 QString selectQweryTable(const QString &pattern) const; |
|
82 |
|
83 QString SelectTable(const QString &pattern) const; |
|
84 |
|
85 QStringList GetTokens(const QString& pattern) const; |
|
86 |
|
87 QString CreateQwertyQuery( |
|
88 const QString& pattern) const; |
|
89 |
|
90 QString CreateQuery(const QString& pattern) const; |
|
91 |
|
92 QString ExactMatchSearch(const QString& pattern) const; |
|
93 |
|
94 QString ExactMatchSearchQwerty(const QString& pattern) const; |
|
95 |
|
96 QString CreateSpaceStringSearch(QStringList numbers, const QString &pattern) const; |
|
97 |
|
98 QString IntersectionSearch(const QString& pattern, |
|
99 const QStringList& numbers) const; |
|
100 QString SearchTokensFromOneTable(const QString& pattern, |
|
101 const QStringList& tokens, |
|
102 QueryType queryType = TwelveTable) const; |
|
103 |
|
104 QString IdenticalTokensSearch(const QString& pattern, |
|
105 const QStringList& numbers) const; |
|
106 |
|
107 QString CompareTwoColumns(const QString& lower, |
|
108 const QString& upper, |
|
109 const QString& lower2, |
|
110 const QString& upper2) const; |
|
111 |
|
112 QString CompareTwoQwertyColumns(const QString& lower, |
|
113 const QString& upper, |
|
114 const QString& lower2, |
|
115 const QString& upper2) const; |
|
116 |
|
117 QString TwoDifferentTokensSearch(const QString& pattern, |
|
118 const QStringList& tokens) const; |
|
119 |
|
120 QString CompareTwoColumnsWithModifiedPattern(const QString& pattern, |
|
121 const QStringList& tokens) const; |
|
122 |
|
123 QString ModifiedMatchColumns(const QString& pattern) const; |
|
124 |
|
125 QString ExactMatch(const QString& pattern, QString table = "") const; |
|
126 |
|
127 QString ExactMatchQwerty(const QString& pattern, QString table = "") const; |
|
128 |
|
129 QString CreateJoinTableSearch(QString pattern, QStringList numbers) const; |
|
130 |
|
131 QString ExactMatchColumns(QStringList numbers) const; |
|
132 |
|
133 QString Order(QStringList numbers, QueryType queryType = TwelveTable ) const; |
|
134 |
|
135 QString UpperLimit( const QString &pattern ) const; |
|
136 |
|
137 QString LowerLimit( const QString &pattern ) const; |
|
138 |
|
139 QString ChangeStringPadings( const QString &pattern ) const; |
|
140 |
|
141 bool TestPattern( const QString &pattern, SearchMethod searchMethod = Undefinded ) const; |
|
142 |
|
143 QString Pad( const QString &pattern, char padChar ) const; |
|
144 |
|
145 bool isQwerty(const QString &pattern); |
|
146 |
|
147 QStringList qwertyTokens(const QString &pattern) const; |
|
148 |
|
149 private: |
|
150 |
|
151 CQwertyKeyMap* mQertyKeyMap; |
|
152 C12keyKeyMap* mkeyKeyMap; |
|
153 |
|
154 friend class UT_CntSqlSearch; |
|
155 }; |
|
156 //#endif |