Changeset View
Changeset View
Standalone View
Standalone View
src/plasmaquick/configmodel.cpp
Show First 20 Lines • Show All 51 Lines • ▼ Show 20 Line(s) | 50 | public: | |||
---|---|---|---|---|---|
52 | ~ConfigModelPrivate(); | 52 | ~ConfigModelPrivate(); | ||
53 | 53 | | |||
54 | ConfigModel *q; | 54 | ConfigModel *q; | ||
55 | QList<ConfigCategory *> categories; | 55 | QList<ConfigCategory *> categories; | ||
56 | QWeakPointer<Plasma::Applet> appletInterface; | 56 | QWeakPointer<Plasma::Applet> appletInterface; | ||
57 | QHash<QString, KQuickAddons::ConfigModule *> kcms; | 57 | QHash<QString, KQuickAddons::ConfigModule *> kcms; | ||
58 | 58 | | |||
59 | void appendCategory(ConfigCategory *c); | 59 | void appendCategory(ConfigCategory *c); | ||
60 | void removeCategory(ConfigCategory *c); | ||||
61 | void removeCategoryAt(int index); | ||||
60 | void clear(); | 62 | void clear(); | ||
61 | QVariant get(int row) const; | 63 | QVariant get(int row) const; | ||
62 | 64 | | |||
63 | static ConfigCategory *categories_at(QQmlListProperty<ConfigCategory> *prop, int index); | 65 | static ConfigCategory *categories_at(QQmlListProperty<ConfigCategory> *prop, int index); | ||
64 | static void categories_append(QQmlListProperty<ConfigCategory> *prop, ConfigCategory *o); | 66 | static void categories_append(QQmlListProperty<ConfigCategory> *prop, ConfigCategory *o); | ||
65 | static int categories_count(QQmlListProperty<ConfigCategory> *prop); | 67 | static int categories_count(QQmlListProperty<ConfigCategory> *prop); | ||
66 | static void categories_clear(QQmlListProperty<ConfigCategory> *prop); | 68 | static void categories_clear(QQmlListProperty<ConfigCategory> *prop); | ||
67 | }; | 69 | }; | ||
▲ Show 20 Lines • Show All 81 Lines • ▼ Show 20 Line(s) | 137 | { | |||
149 | QObject::connect(c, &ConfigCategory::sourceChanged, q, emitChange); | 151 | QObject::connect(c, &ConfigCategory::sourceChanged, q, emitChange); | ||
150 | QObject::connect(c, &ConfigCategory::pluginNameChanged, q, emitChange); | 152 | QObject::connect(c, &ConfigCategory::pluginNameChanged, q, emitChange); | ||
151 | QObject::connect(c, &ConfigCategory::visibleChanged, q, emitChange); | 153 | QObject::connect(c, &ConfigCategory::visibleChanged, q, emitChange); | ||
152 | 154 | | |||
153 | q->endInsertRows(); | 155 | q->endInsertRows(); | ||
154 | emit q->countChanged(); | 156 | emit q->countChanged(); | ||
155 | } | 157 | } | ||
156 | 158 | | |||
159 | void ConfigModelPrivate::removeCategory(ConfigCategory *c) | ||||
160 | { | ||||
161 | const int index = categories.indexOf(c); | ||||
162 | if (index > -1) { | ||||
163 | removeCategoryAt(index); | ||||
164 | } | ||||
165 | } | ||||
166 | | ||||
167 | void ConfigModelPrivate::removeCategoryAt(int index) | ||||
168 | { | ||||
169 | if (index < 0 || index >= categories.count()) { | ||||
170 | return; | ||||
171 | } | ||||
172 | | ||||
173 | q->beginRemoveRows(QModelIndex(), index, index); | ||||
174 | | ||||
175 | ConfigCategory *c = categories.takeAt(index); | ||||
176 | if (c->parent() == q) { | ||||
177 | c->deleteLater(); | ||||
178 | } | ||||
179 | | ||||
180 | q->endRemoveRows(); | ||||
181 | emit q->countChanged(); | ||||
182 | } | ||||
183 | | ||||
157 | QVariant ConfigModelPrivate::get(int row) const | 184 | QVariant ConfigModelPrivate::get(int row) const | ||
158 | { | 185 | { | ||
159 | QVariantMap value; | 186 | QVariantMap value; | ||
160 | if (row < 0 || row >= categories.count()) { | 187 | if (row < 0 || row >= categories.count()) { | ||
161 | return value; | 188 | return value; | ||
162 | } | 189 | } | ||
163 | 190 | | |||
164 | value[QStringLiteral("name")] = categories.at(row)->name(); | 191 | value[QStringLiteral("name")] = categories.at(row)->name(); | ||
▲ Show 20 Lines • Show All 117 Lines • ▼ Show 20 Line(s) | 307 | { | |||
282 | cat->setIcon(iconName); | 309 | cat->setIcon(iconName); | ||
283 | cat->setName(name); | 310 | cat->setName(name); | ||
284 | cat->setSource(path); | 311 | cat->setSource(path); | ||
285 | cat->setPluginName(pluginName); | 312 | cat->setPluginName(pluginName); | ||
286 | cat->setVisible(visible); | 313 | cat->setVisible(visible); | ||
287 | d->appendCategory(cat); | 314 | d->appendCategory(cat); | ||
288 | } | 315 | } | ||
289 | 316 | | |||
317 | void ConfigModel::appendCategory(ConfigCategory *category) | ||||
318 | { | ||||
319 | d->appendCategory(category); | ||||
320 | } | ||||
321 | | ||||
322 | void ConfigModel::removeCategory(ConfigCategory *category) | ||||
323 | { | ||||
324 | d->removeCategory(category); | ||||
325 | } | ||||
326 | | ||||
327 | void ConfigModel::removeCategoryAt(int index) | ||||
328 | { | ||||
329 | d->removeCategoryAt(index); | ||||
330 | } | ||||
331 | | ||||
290 | void ConfigModel::clear() | 332 | void ConfigModel::clear() | ||
291 | { | 333 | { | ||
292 | d->clear(); | 334 | d->clear(); | ||
293 | } | 335 | } | ||
294 | 336 | | |||
295 | void ConfigModel::setApplet(Plasma::Applet *interface) | 337 | void ConfigModel::setApplet(Plasma::Applet *interface) | ||
296 | { | 338 | { | ||
297 | d->appletInterface = interface; | 339 | d->appletInterface = interface; | ||
Show All 19 Lines |