|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: read api implementation |
|
15 * |
|
16 */ |
|
17 #include "contentinfodbreadprivate.h" |
|
18 #include "contentinfodb.h" |
|
19 #include "cpixcontentinfodbread.h" |
|
20 |
|
21 |
|
22 // --------------------------------------------------------------------------- |
|
23 // ContentInfoDbReadPrivate::ContentInfoDbReadPrivate() |
|
24 // --------------------------------------------------------------------------- |
|
25 // |
|
26 ContentInfoDbReadPrivate::ContentInfoDbReadPrivate(QObject* aParent) |
|
27 { |
|
28 iReadPtr = reinterpret_cast<ContentInfoDbRead*> (aParent); |
|
29 mdb = ContentInfoDb::instance(); |
|
30 connect(mdb, SIGNAL(dbUpdated()),this, SLOT(slotdataChanged())); |
|
31 |
|
32 } |
|
33 // --------------------------------------------------------------------------- |
|
34 // ContentInfoDbReadPrivate::ContentInfoDbReadPrivate() |
|
35 // --------------------------------------------------------------------------- |
|
36 // |
|
37 ContentInfoDbReadPrivate::~ContentInfoDbReadPrivate() |
|
38 { |
|
39 ContentInfoDb::deleteinstance(); |
|
40 } |
|
41 // --------------------------------------------------------------------------- |
|
42 // ContentInfoDbReadPrivate::ContentInfoDbReadPrivate() |
|
43 // --------------------------------------------------------------------------- |
|
44 // |
|
45 QStringList ContentInfoDbReadPrivate::getPrimaryKeys() |
|
46 { |
|
47 return mdb->readData(QString(QUERYSORT)); |
|
48 } |
|
49 // --------------------------------------------------------------------------- |
|
50 // ContentInfoDbReadPrivate::ContentInfoDbReadPrivate() |
|
51 // --------------------------------------------------------------------------- |
|
52 // |
|
53 QString ContentInfoDbReadPrivate::getValues(QString Key, QString columnname) |
|
54 { |
|
55 return mdb->readStringData( |
|
56 QString(QUERYDATARETRIVAL).arg(columnname).arg(MAINTABLENAME).arg( |
|
57 TAGPRIMARYKEY).arg(Key)); |
|
58 } |
|
59 // --------------------------------------------------------------------------- |
|
60 // ContentInfoDbReadPrivate::ContentInfoDbReadPrivate() |
|
61 // --------------------------------------------------------------------------- |
|
62 // |
|
63 QStringList ContentInfoDbReadPrivate::getActionuri(QString Key) |
|
64 { |
|
65 QString tablename = mdb->readStringData(QString(QUERYDATARETRIVAL).arg( |
|
66 TAGACTIONURI).arg(MAINTABLENAME).arg(TAGPRIMARYKEY).arg(Key)); |
|
67 if (!tablename.length()) |
|
68 return QStringList(); |
|
69 return mdb->readData( |
|
70 QString(QUERYPRIMARYKEYS).arg(TAGACTIONURISTRING).arg(tablename)); |
|
71 } |
|
72 // --------------------------------------------------------------------------- |
|
73 // ContentInfoDbReadPrivate::ContentInfoDbReadPrivate() |
|
74 // --------------------------------------------------------------------------- |
|
75 // |
|
76 QString ContentInfoDbReadPrivate::getShortTaburi(QString Key) |
|
77 { |
|
78 QString tablename = mdb->readStringData(QString(QUERYDATARETRIVAL).arg( |
|
79 TAGACTIONURI).arg(MAINTABLENAME).arg(TAGPRIMARYKEY).arg(Key)); |
|
80 if (!tablename.length()) |
|
81 return NULL; |
|
82 return mdb->readStringData(QString(QUERYFILTERDATA).arg( |
|
83 TAGACTIONURISTRING).arg(tablename).arg(TAGACTION).arg( |
|
84 PRIMARYVALUE)); |
|
85 } |
|
86 // --------------------------------------------------------------------------- |
|
87 // ContentInfoDbReadPrivate::ContentInfoDbReadPrivate() |
|
88 // --------------------------------------------------------------------------- |
|
89 // |
|
90 QStringList ContentInfoDbReadPrivate::getLongTaburi(QString Key, |
|
91 QString FieldName) |
|
92 { |
|
93 QStringList longurilist; |
|
94 |
|
95 QString tablename = mdb->readStringData(QString(QUERYDATARETRIVAL).arg( |
|
96 TAGACTIONURI).arg(MAINTABLENAME).arg(TAGPRIMARYKEY).arg(Key)); |
|
97 if (!tablename.length()) |
|
98 return QStringList(); |
|
99 QString fieldmaptable = |
|
100 mdb->readStringData( |
|
101 QString(QUERYDATARETRIVAL).arg(TAGFIELDMAP).arg( |
|
102 MAINTABLENAME).arg(TAGPRIMARYKEY).arg(Key)); |
|
103 |
|
104 QString |
|
105 filedmapsubtable = mdb->readStringData( |
|
106 QString(QUERYDATARETRIVAL).arg(TAGURILIST).arg( |
|
107 fieldmaptable).arg(TAGFIELD).arg(FieldName)); |
|
108 |
|
109 QStringList urireflist = mdb->readData(QString(QUERYPRIMARYKEYS).arg( |
|
110 TAGAURI).arg(filedmapsubtable)); |
|
111 |
|
112 for (int i = 0; i < urireflist.count(); i++) |
|
113 { |
|
114 QString str; |
|
115 |
|
116 str = mdb->readStringData(QString(QUERYDATARETRIVAL).arg( |
|
117 TAGACTIONURISTRING).arg(tablename).arg(TAGURIREF).arg( |
|
118 urireflist.at(i))); |
|
119 |
|
120 if (str.length()) |
|
121 longurilist.append(str); |
|
122 } |
|
123 return longurilist; |
|
124 } |
|
125 // --------------------------------------------------------------------------- |
|
126 // ContentInfoDbReadPrivate::ContentInfoDbReadPrivate() |
|
127 // --------------------------------------------------------------------------- |
|
128 // |
|
129 bool ContentInfoDbReadPrivate::geturiDetails(QString key, QString uri, |
|
130 QString& iconname, QString& displayname) |
|
131 { |
|
132 QString tablename = mdb->readStringData(QString(QUERYDATARETRIVAL).arg( |
|
133 TAGACTIONURI).arg(MAINTABLENAME).arg(TAGPRIMARYKEY).arg(key)); |
|
134 |
|
135 if (!tablename.length()) |
|
136 return false; |
|
137 |
|
138 iconname = QString(); |
|
139 displayname = QString(); |
|
140 |
|
141 iconname = mdb->readStringData( |
|
142 QString(QUERYDATARETRIVAL).arg(TAGLNAME).arg(tablename).arg( |
|
143 TAGACTIONURISTRING).arg(uri)); |
|
144 |
|
145 displayname = mdb->readStringData( |
|
146 QString(QUERYDATARETRIVAL).arg(TAGLICON).arg(tablename).arg( |
|
147 TAGACTIONURISTRING).arg(uri)); |
|
148 if (iconname.length() && displayname.length()) |
|
149 return true; |
|
150 return false; |
|
151 } |
|
152 // --------------------------------------------------------------------------- |
|
153 // ContentInfoDbReadPrivate::slotdataChanged() |
|
154 // --------------------------------------------------------------------------- |
|
155 // |
|
156 void ContentInfoDbReadPrivate::slotdataChanged() |
|
157 { |
|
158 if(iReadPtr) |
|
159 emit iReadPtr->dataChanged(); |
|
160 } |
|
161 // --------------------------------------------------------------------------- |
|
162 // ContentInfoDbReadPrivate::categoryCount() |
|
163 // --------------------------------------------------------------------------- |
|
164 // |
|
165 int ContentInfoDbReadPrivate::categoryCount() |
|
166 { |
|
167 return (mdb->readStringData(QString(QUERYCOUNT))).toInt(); |
|
168 } |