diff --git a/components/shellprivate/widgetexplorer/widgetexplorer.h b/components/shellprivate/widgetexplorer/widgetexplorer.h --- a/components/shellprivate/widgetexplorer/widgetexplorer.h +++ b/components/shellprivate/widgetexplorer/widgetexplorer.h @@ -25,6 +25,7 @@ #include #include +#include #include "plasmaappletitemmodel_p.h" @@ -50,10 +51,11 @@ void separatorChanged(); }; -class WidgetExplorer : public QObject +class WidgetExplorer : public QObject, public QQmlParserStatus { Q_OBJECT + Q_INTERFACES(QQmlParserStatus) /** * Model that lists all applets @@ -66,6 +68,11 @@ Q_PROPERTY(QObject * filterModel READ filterModel CONSTANT) /** + * Whether to show special filters such as "Running" and "Uninstallable" in the filterModel. + */ + Q_PROPERTY(bool showSpecialFilters READ showSpecialFilters WRITE setShowSpecialFilters NOTIFY showSpecialFiltersChanged) + + /** * Actions for adding widgets, like download plasma widgets, download google gadgets, install from local file */ Q_PROPERTY(QList widgetsMenuActions READ widgetsMenuActions NOTIFY widgetsMenuActionsChanged) @@ -125,14 +132,20 @@ QObject *widgetsModel() const; QObject *filterModel() const; + bool showSpecialFilters() const; + void setShowSpecialFilters(bool show); + QList widgetsMenuActions(); QList extraActions() const; /** * Uninstall a plasmoid with a given plugin name. only user-installed ones are uninstallable */ Q_INVOKABLE void uninstall(const QString &pluginName); + void classBegin(); + void componentComplete(); + Q_SIGNALS: void widgetsMenuActionsChanged(); void extraActionsChanged(); @@ -150,6 +163,9 @@ void openWidgetFile(); void downloadWidgets(const QString &type); +Q_SIGNALS: + void showSpecialFiltersChanged() const; + protected Q_SLOTS: void immutabilityChanged(Plasma::Types::ImmutabilityType); diff --git a/components/shellprivate/widgetexplorer/widgetexplorer.cpp b/components/shellprivate/widgetexplorer/widgetexplorer.cpp --- a/components/shellprivate/widgetexplorer/widgetexplorer.cpp +++ b/components/shellprivate/widgetexplorer/widgetexplorer.cpp @@ -105,27 +105,32 @@ PlasmaAppletItemModel itemModel; KCategorizedItemsViewModels::DefaultFilterModel filterModel; + bool showSpecialFilters = true; DefaultItemFilterProxyModel filterItemModel; QPointer newStuffDialog; QScopedPointer activitiesConsumer; }; void WidgetExplorerPrivate::initFilters() { - filterModel.addFilter(i18n("All Widgets"), - KCategorizedItemsViewModels::Filter(), QIcon::fromTheme(QStringLiteral("plasma"))); + filterModel.clear(); - // Filters: Special - filterModel.addFilter(i18n("Running"), - KCategorizedItemsViewModels::Filter(QStringLiteral("running"), true), - QIcon::fromTheme(QStringLiteral("dialog-ok"))); + if (showSpecialFilters) { + filterModel.addFilter(i18n("All Widgets"), + KCategorizedItemsViewModels::Filter(), QIcon::fromTheme(QStringLiteral("plasma"))); - filterModel.addFilter(i18n("Uninstallable"), - KCategorizedItemsViewModels::Filter(QStringLiteral("local"), true), - QIcon::fromTheme(QStringLiteral("list-remove"))); + // Filters: Special + filterModel.addFilter(i18n("Running"), + KCategorizedItemsViewModels::Filter(QStringLiteral("running"), true), + QIcon::fromTheme(QStringLiteral("dialog-ok"))); - filterModel.addSeparator(i18n("Categories:")); + filterModel.addFilter(i18n("Uninstallable"), + KCategorizedItemsViewModels::Filter(QStringLiteral("local"), true), + QIcon::fromTheme(QStringLiteral("list-remove"))); + + filterModel.addSeparator(i18n("Categories:")); + } typedef QPair catPair; QMap categories; @@ -164,6 +169,15 @@ } +void WidgetExplorer::classBegin() +{ +} + +void WidgetExplorer::componentComplete() +{ + setApplication(); + d->initRunningApplets(); +} QObject *WidgetExplorer::widgetsModel() const { @@ -175,6 +189,20 @@ return &d->filterModel; } +bool WidgetExplorer::showSpecialFilters() const +{ + return d->showSpecialFilters; +} + +void WidgetExplorer::setShowSpecialFilters(bool show) +{ + if (d->showSpecialFilters != show) { + d->showSpecialFilters = show; + d->initFilters(); + emit showSpecialFiltersChanged(); + } +} + QList WidgetExplorer::widgetsMenuActions() { QList actionList; @@ -302,10 +330,6 @@ : QObject(parent), d(new WidgetExplorerPrivate(this)) { - //FIXME: delay - setApplication(); - d->initRunningApplets(); - d->filterItemModel.setSortCaseSensitivity(Qt::CaseInsensitive); d->filterItemModel.setDynamicSortFilter(true); d->filterItemModel.setSourceModel(&d->itemModel);