on xenial help sign in
more review changes. plugin renaming
commit6b9d8f58d5f7cef1da7867bcee4e493ede881e11 authorNick Dedekind <nicholas.dedekind@gmail.com> dateWed 26 Jun 2013, 16:58 (13 years ago) parent2e1beb4
2 files changed+48−38
modules/Unity/Indicators/indicatorsmodel.cpp+47−37 modules/Unity/Indicators/indicatorsmodel.h+1−1
modules/Unity/Indicators/indicatorsmodel.cpp+47−37
@@ -30,7 +30,7 @@
3030 \qmltype IndicatorsModel
3131 \inherits QAbstractListModel
3232
33− \brief The IndicatorsModel class defines the list model for indicators plugins
33+ \brief The IndicatorsModel class defines the list model for indicators
3434
3535 \b {This component is under heavy development.}
3636
@@ -81,18 +81,18 @@ int IndicatorsModel::count() const
8181/*!
8282 \qmlmethod IndicatorsModel::unload()
8383
84− Load all plugins.
84+ Load all indicators.
8585*/
8686void IndicatorsModel::load()
8787{
88− m_plugins.clear();
88+ m_indicators.clear();
8989 m_manager->load();
9090}
9191
9292/*!
9393 \qmlmethod IndicatorsModel::unload()
9494
95− Unload all plugins.
95+ Unload all indicators.
9696*/
9797void IndicatorsModel::unload()
9898{
@@ -100,49 +100,57 @@ void IndicatorsModel::unload()
100100}
101101
102102/*! \internal */
103−void IndicatorsModel::onIndicatorLoaded(const QString& indicator)
103+void IndicatorsModel::onIndicatorLoaded(const QString& indicator_name)
104104{
105− Indicator::Ptr plugin = m_manager->indicator(indicator);
106− if (!plugin)
105+ Indicator::Ptr indicator = m_manager->indicator(indicator_name);
106+ if (!indicator)
107+ {
107108 return;
109+ }
108110
109− if (m_plugins.indexOf(plugin) >= 0)
111+ if (m_indicators.indexOf(indicator) >= 0)
112+ {
110113 return;
114+ }
111115
112116 // find the insert position
113117 int pos = 0;
114− while (pos < count()) {
118+ while (pos < count())
119+ {
115120 // keep going while the existing priority is less.
116− if (indicatorData(plugin, Priority).toInt() < data(index(pos), Priority).toInt())
121+ if (indicatorData(indicator, Priority).toInt() < data(index(pos), Priority).toInt())
117122 break;
118123 pos++;
119124 }
120125
121− QObject::connect(plugin.data(), SIGNAL(identifierChanged(const QString&)), this, SLOT(onIdentifierChanged()));
122− QObject::connect(plugin.data(), SIGNAL(indicatorPropertiesChanged(const QVariant&)), this, SLOT(onIndicatorPropertiesChanged()));
126+ QObject::connect(indicator.data(), SIGNAL(identifierChanged(const QString&)), this, SLOT(onIdentifierChanged()));
127+ QObject::connect(indicator.data(), SIGNAL(indicatorPropertiesChanged(const QVariant&)), this, SLOT(onIndicatorPropertiesChanged()));
123128
124129 beginInsertRows(QModelIndex(), pos, pos);
125130
126− m_plugins.insert(pos, plugin);
131+ m_indicators.insert(pos, indicator);
127132 endInsertRows();
128133}
129134
130135/*! \internal */
131−void IndicatorsModel::onIndicatorAboutToBeUnloaded(const QString& indicator)
136+void IndicatorsModel::onIndicatorAboutToBeUnloaded(const QString& indicator_name)
132137{
133− Indicator::Ptr plugin = m_manager->indicator(indicator);
134− if (!plugin)
138+ Indicator::Ptr indicator = m_manager->indicator(indicator_name);
139+ if (!indicator)
140+ {
135141 return;
142+ }
136143
137144 int i = 0;
138− QMutableListIterator<Indicator::Ptr> iter(m_plugins);
145+ QMutableListIterator<Indicator::Ptr> iter(m_indicators);
139146 while(iter.hasNext())
140147 {
141− if (plugin == iter.next())
148+ if (indicator == iter.next())
142149 {
143150 beginRemoveRows(QModelIndex(), i, i);
144151 iter.remove();
145152 endRemoveRows();
153+ break;
146154 }
147155 i++;
148156 }
@@ -164,15 +172,17 @@ void IndicatorsModel::onIndicatorPropertiesChanged()
164172/*! \internal */
165173void IndicatorsModel::notifyDataChanged(QObject *sender, int role)
166174{
167− Indicator* plugin = qobject_cast<Indicator*>(sender);
168− if (!plugin)
175+ Indicator* indicator = qobject_cast<Indicator*>(sender);
176+ if (!indicator)
177+ {
169178 return;
179+ }
170180
171181 int index = 0;
172− QMutableListIterator<Indicator::Ptr> iter(m_plugins);
182+ QMutableListIterator<Indicator::Ptr> iter(m_indicators);
173183 while(iter.hasNext())
174184 {
175− if (iter.next().data() == plugin)
185+ if (indicator == iter.next())
176186 {
177187 QModelIndex changedIndex = this->index(index);
178188 dataChanged(changedIndex, changedIndex, QVector<int>() << role);
@@ -207,14 +217,14 @@ int IndicatorsModel::columnCount(const QModelIndex &) const
207217}
208218
209219/*! \internal */
210−QVariant IndicatorsModel::defaultData(Indicator::Ptr plugin, int role)
220+QVariant IndicatorsModel::defaultData(Indicator::Ptr indicator, int role)
211221{
212222 switch (role)
213223 {
214224 case Priority:
215225 return 0;
216226 case Title:
217− return plugin ? plugin->identifier() : "Unknown";
227+ return indicator ? indicator->identifier() : "Unknown";
218228 case Description:
219229 return "";
220230 case WidgetSource:
@@ -233,47 +243,47 @@ Q_INVOKABLE QVariant IndicatorsModel::data(int row, int role) const
233243/*! \internal */
234244QVariant IndicatorsModel::data(const QModelIndex &index, int role) const
235245{
236− if (!index.isValid() || index.row() >= m_plugins.size())
246+ if (!index.isValid() || index.row() >= m_indicators.size())
237247 return QVariant();
238248
239− Indicator::Ptr plugin = m_plugins[index.row()];
249+ Indicator::Ptr indicator = m_indicators[index.row()];
240250
241251 switch (role)
242252 {
243253 case Identifier:
244− if (plugin)
254+ if (indicator)
245255 {
246− return QVariant(plugin->identifier());
256+ return QVariant(indicator->identifier());
247257 }
248258 break;
249259 case IndicatorProperties:
250− if (plugin)
260+ if (indicator)
251261 {
252− return QVariant(plugin->indicatorProperties());
262+ return QVariant(indicator->indicatorProperties());
253263 }
254264 break;
255265 case IsValid:
256− return (plugin ? true : false);
266+ return (indicator ? true : false);
257267 case Priority:
258268 case Title:
259269 case Description:
260270 case WidgetSource:
261271 case PageSource:
262− return indicatorData(plugin, role);
272+ return indicatorData(indicator, role);
263273 default:
264274 break;
265275 }
266276 return QVariant();
267277}
268278
269−QVariant IndicatorsModel::indicatorData(const Indicator::Ptr& plugin, int role) const
279+QVariant IndicatorsModel::indicatorData(const Indicator::Ptr& indicator, int role) const
270280{
271− if (plugin && m_parsed_indicator_data.contains(plugin->identifier()))
281+ if (indicator && m_parsed_indicator_data.contains(indicator->identifier()))
272282 {
273− QVariantMap data = m_parsed_indicator_data[plugin->identifier()];
283+ QVariantMap data = m_parsed_indicator_data[indicator->identifier()];
274284 return data.value(roleNames()[role], QVariant());
275285 }
276− return defaultData(plugin, role);
286+ return defaultData(indicator, role);
277287}
278288
279289/*! \internal */
@@ -285,7 +295,7 @@ QModelIndex IndicatorsModel::parent(const QModelIndex&) const
285295/*! \internal */
286296int IndicatorsModel::rowCount(const QModelIndex&) const
287297{
288− return m_plugins.count();
298+ return m_indicators.count();
289299}
290300
291301void IndicatorsModel::setIndicatorData(const QVariant& data)
modules/Unity/Indicators/indicatorsmodel.h+1−1
@@ -78,7 +78,7 @@ private Q_SLOTS:
7878private:
7979 IndicatorsManager *m_manager;
8080
81− QList<Indicator::Ptr> m_plugins;
81+ QList<Indicator::Ptr> m_indicators;
8282 QVariant m_indicator_data;
8383 QMap<QString, QVariantMap> m_parsed_indicator_data;
8484