add support for filtering applets based on specified application. useful for non-plasma targets (e.g. amarok). default behavious remains the same.
svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=733292
This commit is contained in:
parent
0f889fd7c8
commit
845139ae0a
@ -36,17 +36,19 @@ namespace Plasma
|
|||||||
class AppletBrowser::Private
|
class AppletBrowser::Private
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Private(Corona* co, Containment* cont, AppletBrowser* q)
|
Private(Corona* co, Containment* cont, AppletBrowser* q, const QString& app)
|
||||||
: corona(co),
|
: application( app ),
|
||||||
|
corona(co),
|
||||||
containment(cont),
|
containment(cont),
|
||||||
appletList(0),
|
appletList(0),
|
||||||
config("plasmarc"),
|
config("plasmarc"),
|
||||||
configGroup(&config, "Applet Browser"),
|
configGroup(&config, "Applet Browser"),
|
||||||
itemModel(configGroup, q),
|
itemModel(configGroup, app, q),
|
||||||
filterModel(q)
|
filterModel(q)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString application;
|
||||||
Plasma::Corona *corona;
|
Plasma::Corona *corona;
|
||||||
Plasma::Containment *containment;
|
Plasma::Containment *containment;
|
||||||
KCategorizedItemsView *appletList;
|
KCategorizedItemsView *appletList;
|
||||||
@ -58,16 +60,16 @@ public:
|
|||||||
KCategorizedItemsViewModels::DefaultFilterModel filterModel;
|
KCategorizedItemsViewModels::DefaultFilterModel filterModel;
|
||||||
};
|
};
|
||||||
|
|
||||||
AppletBrowser::AppletBrowser(Plasma::Corona * corona, QWidget * parent, Qt::WindowFlags f)
|
AppletBrowser::AppletBrowser(Plasma::Corona * corona, const QString& application, QWidget * parent, Qt::WindowFlags f)
|
||||||
: KDialog(parent, f),
|
: KDialog(parent, f),
|
||||||
d(new Private(corona, 0, this))
|
d(new Private(corona, 0, this, application))
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
AppletBrowser::AppletBrowser(Plasma::Containment * containment, QWidget * parent, Qt::WindowFlags f)
|
AppletBrowser::AppletBrowser(Plasma::Containment * containment, const QString& application, QWidget * parent, Qt::WindowFlags f)
|
||||||
: KDialog(parent, f),
|
: KDialog(parent, f),
|
||||||
d(new Private(0, containment, this))
|
d(new Private(0, containment, this, application))
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
@ -126,13 +128,13 @@ void AppletBrowser::init()
|
|||||||
KCategorizedItemsViewModels::Filter("used", true), new KIcon("history"));
|
KCategorizedItemsViewModels::Filter("used", true), new KIcon("history"));
|
||||||
|
|
||||||
d->filterModel.addSeparator(i18n("Categories:"));
|
d->filterModel.addSeparator(i18n("Categories:"));
|
||||||
|
|
||||||
|
|
||||||
// Filters: Categories
|
foreach (const QString& category, Plasma::Applet::knownCategories(d->application)) {
|
||||||
foreach (const QString& category, Plasma::Applet::knownCategories()) {
|
|
||||||
d->filterModel.addFilter(category,
|
d->filterModel.addFilter(category,
|
||||||
KCategorizedItemsViewModels::Filter("category", category));
|
KCategorizedItemsViewModels::Filter("category", category));
|
||||||
}
|
}
|
||||||
|
|
||||||
d->appletList->setFilterModel(&d->filterModel);
|
d->appletList->setFilterModel(&d->filterModel);
|
||||||
|
|
||||||
// Other models
|
// Other models
|
||||||
@ -144,6 +146,17 @@ AppletBrowser::~AppletBrowser()
|
|||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AppletBrowser::setApplication( const QString& app )
|
||||||
|
{
|
||||||
|
d->application = app;
|
||||||
|
d->itemModel.setApplication( app );
|
||||||
|
}
|
||||||
|
|
||||||
|
QString AppletBrowser::Application()
|
||||||
|
{
|
||||||
|
return d->application;
|
||||||
|
}
|
||||||
|
|
||||||
void AppletBrowser::addApplet()
|
void AppletBrowser::addApplet()
|
||||||
{
|
{
|
||||||
kDebug() << "Button ADD clicked";
|
kDebug() << "Button ADD clicked";
|
||||||
|
@ -34,10 +34,13 @@ class PLASMA_EXPORT AppletBrowser: public KDialog
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit AppletBrowser(Plasma::Corona *corona, QWidget *parent = 0, Qt::WindowFlags f = 0);
|
explicit AppletBrowser(Plasma::Corona *corona, const QString& app = QString(), QWidget *parent = 0, Qt::WindowFlags f = 0);
|
||||||
explicit AppletBrowser(Plasma::Containment *containment, QWidget *parent = 0, Qt::WindowFlags f = 0);
|
explicit AppletBrowser(Plasma::Containment *containment, const QString& = QString(), QWidget *parent = 0, Qt::WindowFlags f = 0);
|
||||||
virtual ~AppletBrowser();
|
virtual ~AppletBrowser();
|
||||||
|
|
||||||
|
void setApplication( const QString& application );
|
||||||
|
QString Application();
|
||||||
|
|
||||||
protected Q_SLOTS:
|
protected Q_SLOTS:
|
||||||
/**
|
/**
|
||||||
* Adds currently selected applets
|
* Adds currently selected applets
|
||||||
|
@ -80,8 +80,9 @@ QVariantList PlasmaAppletItem::arguments() const
|
|||||||
return qvariant_cast<QVariantList>(data().toMap()["arguments"]);
|
return qvariant_cast<QVariantList>(data().toMap()["arguments"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
PlasmaAppletItemModel::PlasmaAppletItemModel(KConfigGroup configGroup, QObject * parent) :
|
PlasmaAppletItemModel::PlasmaAppletItemModel(KConfigGroup configGroup, QString app, QObject * parent) :
|
||||||
KCategorizedItemsViewModels::DefaultItemModel(parent),
|
KCategorizedItemsViewModels::DefaultItemModel(parent),
|
||||||
|
m_application( app ),
|
||||||
m_configGroup(configGroup)
|
m_configGroup(configGroup)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -103,7 +104,7 @@ PlasmaAppletItemModel::PlasmaAppletItemModel(KConfigGroup configGroup, QObject *
|
|||||||
m_used = m_configGroup.readEntry("used").split(",");
|
m_used = m_configGroup.readEntry("used").split(",");
|
||||||
|
|
||||||
//TODO: get recommended, favorit, used, etc out of knownApplets()
|
//TODO: get recommended, favorit, used, etc out of knownApplets()
|
||||||
foreach (const KPluginInfo& info, Plasma::Applet::knownApplets()) {
|
foreach (const KPluginInfo& info, Plasma::Applet::knownApplets( QString(), m_application)) {
|
||||||
//kDebug() << info.pluginName() << "NoDisplay" << info.property("NoDisplay").toBool();
|
//kDebug() << info.pluginName() << "NoDisplay" << info.property("NoDisplay").toBool();
|
||||||
if (info.property("NoDisplay").toBool()) {
|
if (info.property("NoDisplay").toBool()) {
|
||||||
// we don't want to show the hidden category
|
// we don't want to show the hidden category
|
||||||
@ -181,6 +182,16 @@ void PlasmaAppletItemModel::setFavorite(QString plugin, bool favorite)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PlasmaAppletItemModel::setApplication(const QString& app)
|
||||||
|
{
|
||||||
|
m_application = app;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString& PlasmaAppletItemModel::Application()
|
||||||
|
{
|
||||||
|
return m_application;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Define function type to get the SuperKaramba themes
|
* Define function type to get the SuperKaramba themes
|
||||||
* from skapplet (see skapplet.cpp in kdeutils/superkaramba)
|
* from skapplet (see skapplet.cpp in kdeutils/superkaramba)
|
||||||
@ -223,4 +234,3 @@ void PlasmaAppletItemModel::loadSuperKarambaThemes(const KPluginInfo &info)
|
|||||||
kWarning() << "Could not load" << libName;
|
kWarning() << "Could not load" << libName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,15 +60,18 @@ class PlasmaAppletItemModel :
|
|||||||
public KCategorizedItemsViewModels::DefaultItemModel
|
public KCategorizedItemsViewModels::DefaultItemModel
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PlasmaAppletItemModel(KConfigGroup configGroup, QObject * parent = 0);
|
PlasmaAppletItemModel(KConfigGroup configGroup, QString parentApp = QString(), QObject * parent = 0);
|
||||||
|
|
||||||
QStringList mimeTypes() const;
|
QStringList mimeTypes() const;
|
||||||
|
|
||||||
QMimeData* mimeData(const QModelIndexList & indexes) const;
|
QMimeData* mimeData(const QModelIndexList & indexes) const;
|
||||||
|
|
||||||
void setFavorite(QString plugin, bool favorite);
|
void setFavorite(QString plugin, bool favorite);
|
||||||
|
void setApplication(const QString& app);
|
||||||
|
|
||||||
|
QString& Application();
|
||||||
private:
|
private:
|
||||||
|
QString m_application;
|
||||||
QStringList m_favorites;
|
QStringList m_favorites;
|
||||||
QStringList m_used;
|
QStringList m_used;
|
||||||
KConfigGroup m_configGroup;
|
KConfigGroup m_configGroup;
|
||||||
|
Loading…
Reference in New Issue
Block a user