66 } |
66 } |
67 |
67 |
68 void HsAddModeProxyModel::initilizeCwrtWidgetCache() |
68 void HsAddModeProxyModel::initilizeCwrtWidgetCache() |
69 { |
69 { |
70 QStringList entryTypeNames; |
70 QStringList entryTypeNames; |
71 entryTypeNames.append(applicationTypeName()); |
71 entryTypeNames.append(Hs::applicationTypeName); |
72 mQuery.setEntryTypeNames(entryTypeNames); |
72 mQuery.setEntryTypeNames(entryTypeNames); |
73 mQuery.setAttribute(swTypeKey(), HS_CWRT_APP_TYPE); |
73 mQuery.setAttribute(Hs::swTypeKey, Hs::HS_CWRT_APP_TYPE); |
74 mQuery.setAttribute(widgetUriAttributeName(), |
74 mQuery.setAttribute(Hs::widgetUriAttributeName, |
75 HS_WIDGET_URI_ATTRIBUTE_CWRT_VALUE); |
75 Hs::HS_WIDGET_URI_ATTRIBUTE_CWRT_VALUE); |
76 QList< QSharedPointer<CaEntry> > entries = |
76 QList< QSharedPointer<CaEntry> > entries = |
77 CaService::instance()->getEntries(mQuery); |
77 CaService::instance()->getEntries(mQuery); |
78 foreach (QSharedPointer<CaEntry> entry, entries) { |
78 foreach (QSharedPointer<CaEntry> entry, entries) { |
79 QVariantHash preferences; |
79 QVariantHash preferences; |
80 QMap<QString, QString> attributes = entry->attributes(); |
80 QMap<QString, QString> attributes = entry->attributes(); |
81 QMapIterator<QString, QString> i(attributes); |
81 QMapIterator<QString, QString> i(attributes); |
82 while (i.hasNext()) { |
82 while (i.hasNext()) { |
83 i.next(); |
83 i.next(); |
84 QString key(i.key()); |
84 QString key(i.key()); |
85 QString value(i.value()); |
85 QString value(i.value()); |
86 if (key.contains(widgetParam())) { |
86 if (key.contains(Hs::widgetParam)) { |
87 preferences.insert(key.remove(widgetParam()),value); |
87 preferences.insert(key.remove(Hs::widgetParam),value); |
88 } |
88 } |
89 } |
89 } |
90 int count(0); |
90 int count(0); |
91 HsContentService::instance()->widgets( |
91 HsContentService::instance()->widgets( |
92 HS_WIDGET_URI_ATTRIBUTE_CWRT_VALUE,preferences,count); |
92 Hs::HS_WIDGET_URI_ATTRIBUTE_CWRT_VALUE,preferences,count); |
93 mCwrtWidgetCache.insert(entry->id(), count > 0); |
93 mCwrtWidgetCache.insert(entry->id(), count > 0); |
94 } |
94 } |
95 |
95 |
|
96 } |
|
97 |
|
98 /* |
|
99 Reimplementated from QSortFilterProxyModel to forward signals from CaItemModel. |
|
100 \param sourceModel source model. |
|
101 */ |
|
102 void HsAddModeProxyModel::setSourceModel(QAbstractItemModel *sourceModel) |
|
103 { |
|
104 QSortFilterProxyModel::setSourceModel(sourceModel); |
|
105 connect(sourceModel, |
|
106 SIGNAL(scrollTo(int, QAbstractItemView::ScrollHint)), |
|
107 this, |
|
108 SIGNAL(scrollTo(int, QAbstractItemView::ScrollHint))); |
|
109 connect(sourceModel, |
|
110 SIGNAL(countChange()), |
|
111 this, |
|
112 SIGNAL(countChange())); |
96 } |
113 } |
97 |
114 |
98 /*! |
115 /*! |
99 Return entryid for given Cwrt with mini view widget. |
116 Return entryid for given Cwrt with mini view widget. |
100 \param uri of a widget. |
117 \param uri of a widget. |
105 { |
122 { |
106 int result = 0; |
123 int result = 0; |
107 CaQuery query; |
124 CaQuery query; |
108 QStringList entryTypeNames; |
125 QStringList entryTypeNames; |
109 query.setEntryTypeNames(entryTypeNames); |
126 query.setEntryTypeNames(entryTypeNames); |
110 query.setAttribute(swTypeKey(), HS_CWRT_APP_TYPE); |
127 query.setAttribute(Hs::swTypeKey, Hs::HS_CWRT_APP_TYPE); |
111 query.setAttribute(widgetUriAttributeName(), |
128 query.setAttribute(Hs::widgetUriAttributeName, |
112 HS_WIDGET_URI_ATTRIBUTE_CWRT_VALUE); |
129 Hs::HS_WIDGET_URI_ATTRIBUTE_CWRT_VALUE); |
113 foreach (QString key, preferences.keys()) { |
130 foreach (QString key, preferences.keys()) { |
114 query.setAttribute(widgetParam()+key, |
131 query.setAttribute(Hs::widgetParam+key, |
115 preferences.value(key).toString()); |
132 preferences.value(key).toString()); |
116 } |
133 } |
117 QList< QSharedPointer<CaEntry> > entries = |
134 QList< QSharedPointer<CaEntry> > entries = |
118 CaService::instance()->getEntries(query); |
135 CaService::instance()->getEntries(query); |
119 if( entries.count() > 0 ) |
136 if( entries.count() > 0 ) |
129 \param uri of a widget. |
146 \param uri of a widget. |
130 \param preferences widget preferences. |
147 \param preferences widget preferences. |
131 */ |
148 */ |
132 void HsAddModeProxyModel::updateCacheOnAddWidget(const QString &uri, |
149 void HsAddModeProxyModel::updateCacheOnAddWidget(const QString &uri, |
133 const QVariantHash &preferences){ |
150 const QVariantHash &preferences){ |
134 if (uri == HS_WIDGET_URI_ATTRIBUTE_CWRT_VALUE) { |
151 if (uri == Hs::HS_WIDGET_URI_ATTRIBUTE_CWRT_VALUE) { |
135 int entryId = findCwrtWidgetEntryId(preferences); |
152 int entryId = findCwrtWidgetEntryId(preferences); |
136 if (!mCwrtWidgetCache.value(entryId) ) { |
153 if (!mCwrtWidgetCache.value(entryId) ) { |
137 mCwrtWidgetCache.insert(entryId,true); |
154 mCwrtWidgetCache.insert(entryId,true); |
138 invalidateFilter(); |
155 invalidateFilter(); |
139 } |
156 } |
147 \param preferences widget preferences. |
164 \param preferences widget preferences. |
148 */ |
165 */ |
149 void HsAddModeProxyModel::updateCacheOnRemoveWidget(const QString &uri, |
166 void HsAddModeProxyModel::updateCacheOnRemoveWidget(const QString &uri, |
150 const QVariantHash &preferences) |
167 const QVariantHash &preferences) |
151 { |
168 { |
152 if (uri == HS_WIDGET_URI_ATTRIBUTE_CWRT_VALUE) { |
169 if (uri == Hs::HS_WIDGET_URI_ATTRIBUTE_CWRT_VALUE) { |
153 int entryId = findCwrtWidgetEntryId(preferences); |
170 int entryId = findCwrtWidgetEntryId(preferences); |
154 if (mCwrtWidgetCache.value(entryId)) { |
171 if (mCwrtWidgetCache.value(entryId)) { |
155 mCwrtWidgetCache.insert(entryId,false); |
172 mCwrtWidgetCache.insert(entryId,false); |
156 invalidateFilter(); |
173 invalidateFilter(); |
157 } |
174 } |