use Keywords instead of X-KDE-PluginInfo-Category so we can be translated and even support multiple categories!
svn path=/trunk/KDE/kdelibs/; revision=961933
This commit is contained in:
parent
347c0caac4
commit
0b5c4e1947
30
applet.cpp
30
applet.cpp
@ -748,7 +748,7 @@ QString Applet::category() const
|
||||
|
||||
QString Applet::category(const KPluginInfo &applet)
|
||||
{
|
||||
return applet.property("X-KDE-PluginInfo-Category").toString();
|
||||
return applet.property("Keywords").toStringList().first();
|
||||
}
|
||||
|
||||
QString Applet::category(const QString &appletName)
|
||||
@ -764,7 +764,7 @@ QString Applet::category(const QString &appletName)
|
||||
return QString();
|
||||
}
|
||||
|
||||
return offers.first()->property("X-KDE-PluginInfo-Category").toString();
|
||||
return offers.first()->property("Keywords").toStringList().first();
|
||||
}
|
||||
|
||||
ImmutabilityType Applet::immutability() const
|
||||
@ -1644,14 +1644,12 @@ KPluginInfo::List Applet::listAppletInfo(const QString &category,
|
||||
KConfigGroup group(KGlobal::config(), "General");
|
||||
QStringList excluded = group.readEntry("ExcludeCategories", QStringList());
|
||||
foreach (const QString &category, excluded) {
|
||||
constraint.append(" and [X-KDE-PluginInfo-Category] != '").append(category).append("'");
|
||||
constraint.append(" and not '").append(category).append("' ~in Keywords");
|
||||
}
|
||||
} else { //specific category (this could be an excluded one - is that bad?)
|
||||
constraint.append(" and ");
|
||||
|
||||
constraint.append("[X-KDE-PluginInfo-Category] == '").append(category).append("'");
|
||||
constraint.append(" and ").append("'").append(category).append("'").append(" in Keywords");
|
||||
if (category == "Miscellaneous") {
|
||||
constraint.append(" or (not exist [X-KDE-PluginInfo-Category] or [X-KDE-PluginInfo-Category] == '')");
|
||||
constraint.append(" or not exist Keywords");
|
||||
}
|
||||
}
|
||||
|
||||
@ -1693,7 +1691,7 @@ KPluginInfo::List Applet::listAppletInfoForMimetype(const QString &mimetype)
|
||||
|
||||
QStringList Applet::listCategories(const QString &parentApp, bool visibleOnly)
|
||||
{
|
||||
QString constraint = "exist [X-KDE-PluginInfo-Category]";
|
||||
QString constraint = "exist Keywords";
|
||||
|
||||
if (parentApp.isEmpty()) {
|
||||
constraint.append(" and not exist [X-KDE-ParentApp]");
|
||||
@ -1704,25 +1702,31 @@ QStringList Applet::listCategories(const QString &parentApp, bool visibleOnly)
|
||||
KConfigGroup group(KGlobal::config(), "General");
|
||||
QStringList excluded = group.readEntry("ExcludeCategories", QStringList());
|
||||
foreach (const QString &category, excluded) {
|
||||
constraint.append(" and [X-KDE-PluginInfo-Category] != '").append(category).append("'");
|
||||
constraint.append(" and not '").append(category).append("' in Keywords");
|
||||
}
|
||||
|
||||
KService::List offers = KServiceTypeTrader::self()->query("Plasma/Applet", constraint);
|
||||
//TODO: this is potentially slow using a QStringList if there are lots and lots of categories
|
||||
QStringList categories;
|
||||
foreach (const KService::Ptr &applet, offers) {
|
||||
QString appletCategory = applet->property("X-KDE-PluginInfo-Category").toString();
|
||||
if (visibleOnly && applet->noDisplay()) {
|
||||
// we don't want to show the hidden category
|
||||
continue;
|
||||
}
|
||||
|
||||
QStringList appletCategories = applet->property("Keywords").toStringList();
|
||||
|
||||
//kDebug() << " and we have " << appletCategory;
|
||||
if (appletCategory.isEmpty()) {
|
||||
if (appletCategories.isEmpty()) {
|
||||
if (!categories.contains(i18nc("misc category", "Miscellaneous"))) {
|
||||
categories << i18nc("misc category", "Miscellaneous");
|
||||
}
|
||||
} else if (!categories.contains(appletCategory)) {
|
||||
categories << appletCategory;
|
||||
} else {
|
||||
foreach (const QString &category, appletCategories) {
|
||||
if (!categories.contains(category, Qt::CaseInsensitive)) {
|
||||
categories << category;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -891,9 +891,9 @@ KPluginInfo::List Containment::listContainmentsOfType(const QString &type,
|
||||
constraint.append(" and ");
|
||||
}
|
||||
|
||||
constraint.append("[X-KDE-PluginInfo-Category] == '").append(category).append("'");
|
||||
constraint.append("'").append(category).append("' in Keywords");
|
||||
if (category == "Miscellaneous") {
|
||||
constraint.append(" or (not exist [X-KDE-PluginInfo-Category] or [X-KDE-PluginInfo-Category] == '')");
|
||||
constraint.append(" or not exist Keywords");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -37,6 +37,7 @@ class PackageMetadataPrivate
|
||||
|
||||
QString name;
|
||||
QString description;
|
||||
QStringList keywords;
|
||||
QString author;
|
||||
QString email;
|
||||
QString version;
|
||||
@ -83,6 +84,7 @@ void PackageMetadata::write(const QString &filename) const
|
||||
|
||||
config.writeEntry("Name", d->name);
|
||||
config.writeEntry("Comment", d->description);
|
||||
config.writeEntry("Keywords", d->keywords);
|
||||
config.writeEntry("X-KDE-ServiceTypes", d->serviceType);
|
||||
config.writeEntry("X-KDE-PluginInfo-Name", d->pluginName);
|
||||
config.writeEntry("X-KDE-PluginInfo-Author", d->author);
|
||||
@ -107,6 +109,7 @@ void PackageMetadata::read(const QString &filename)
|
||||
|
||||
d->name = config.readEntry("Name", d->name);
|
||||
d->description = config.readEntry("Comment", d->description);
|
||||
d->keywords = config.readEntry("Keywords", d->keywords);
|
||||
d->serviceType = config.readEntry("X-KDE-ServiceTypes", d->serviceType);
|
||||
d->pluginName = config.readEntry("X-KDE-PluginInfo-Name", d->pluginName);
|
||||
d->author = config.readEntry("X-KDE-PluginInfo-Author", d->author);
|
||||
@ -114,7 +117,7 @@ void PackageMetadata::read(const QString &filename)
|
||||
d->version = config.readEntry("X-KDE-PluginInfo-Version", d->version);
|
||||
d->website = config.readEntry("X-KDE-PluginInfo-Website", d->website);
|
||||
d->license = config.readEntry("X-KDE-PluginInfo-License", d->license);
|
||||
d->category = config.readEntry("X-KDE-PluginInfo-Category", d->category);
|
||||
d->category = config.readEntry("KDE-PluginInfo-Category", d->category);
|
||||
d->api = config.readEntry("X-Plasma-API", d->api);
|
||||
d->app = config.readEntry("X-KDE-ParentApp", d->app);
|
||||
d->type = config.readEntry("Type", d->type);
|
||||
@ -170,6 +173,16 @@ QString PackageMetadata::category() const
|
||||
return d->category;
|
||||
}
|
||||
|
||||
void PackageMetadata::setKeywords(const QStringList &keywords)
|
||||
{
|
||||
d->keywords = keywords;
|
||||
}
|
||||
|
||||
QStringList PackageMetadata::keywords() const
|
||||
{
|
||||
return d->keywords;
|
||||
}
|
||||
|
||||
QString PackageMetadata::requiredVersion() const
|
||||
{
|
||||
return d->requiredVersion;
|
||||
|
@ -75,6 +75,7 @@ public:
|
||||
|
||||
QString name() const;
|
||||
QString description() const;
|
||||
QStringList keywords() const;
|
||||
QString serviceType() const;
|
||||
QString author() const;
|
||||
QString email() const;
|
||||
@ -101,6 +102,12 @@ public:
|
||||
*/
|
||||
void setDescription(const QString &);
|
||||
|
||||
/**
|
||||
* Set the keywords used to provide search and categorizations
|
||||
* @param keywords the keywords to associate with this package
|
||||
*/
|
||||
void setKeywords(const QStringList &keywords);
|
||||
|
||||
/**
|
||||
* Set the service-type which defines the X-KDE-ServiceTypes
|
||||
* type within the desktop file. If not defined this
|
||||
|
Loading…
Reference in New Issue
Block a user