* const correctness fixes

* allow setting/getting a service type

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=690113
This commit is contained in:
Aaron J. Seigo 2007-07-20 04:14:13 +00:00
parent 43a98e8fc1
commit 0f2acacbe7
2 changed files with 54 additions and 46 deletions

View File

@ -44,6 +44,7 @@ class PackageMetadata::Private
QString icon; QString icon;
QString preview; QString preview;
QString type; QString type;
QString serviceType;
}; };
PackageMetadata::PackageMetadata() PackageMetadata::PackageMetadata()
@ -62,24 +63,17 @@ PackageMetadata::~PackageMetadata()
delete d; delete d;
} }
bool PackageMetadata::isComplete() bool PackageMetadata::isComplete() const
{ {
if (d->name.isEmpty() || return ! (d->name.isEmpty() ||
// d->description.isEmpty() || d->author.isEmpty() ||
d->author.isEmpty() || d->version.isEmpty() ||
d->version.isEmpty() || d->license.isEmpty() ||
d->license.isEmpty() || d->app.isEmpty() ||
// d->mainFile.isEmpty() || d->type.isEmpty());
d->app.isEmpty() ||
// d->requiredVersion.isEmpty() ||
d->type.isEmpty()) {
return false;
} else {
return true;
}
} }
void PackageMetadata::write(const QString& filename) void PackageMetadata::write(const QString& filename) const
{ {
KConfig cfg(filename); KConfig cfg(filename);
KConfigGroup config(&cfg, "Desktop Entry"); KConfigGroup config(&cfg, "Desktop Entry");
@ -89,6 +83,7 @@ void PackageMetadata::write(const QString& filename)
config.writeEntry("Name", d->name); config.writeEntry("Name", d->name);
config.writeEntry("Description", d->description); config.writeEntry("Description", d->description);
config.writeEntry("Icon", d->icon); config.writeEntry("Icon", d->icon);
config.writeEntry("ServiceTypes", d->serviceType);
config.writeEntry("X-KDE-PluginInfo-Name", d->name); config.writeEntry("X-KDE-PluginInfo-Name", d->name);
config.writeEntry("X-KDE-PluginInfo-Author", d->author); config.writeEntry("X-KDE-PluginInfo-Author", d->author);
config.writeEntry("X-KDE-PluginInfo-Email", d->email); config.writeEntry("X-KDE-PluginInfo-Email", d->email);
@ -110,6 +105,7 @@ void PackageMetadata::read(const QString& filename)
d->name = config.readEntry("X-KDE-PluginInfo-Name", d->name); d->name = config.readEntry("X-KDE-PluginInfo-Name", d->name);
d->description = config.readEntry("Description", d->description); d->description = config.readEntry("Description", d->description);
d->icon = config.readEntry("Icon", d->icon); d->icon = config.readEntry("Icon", d->icon);
d->serviceType = config.readEntry("ServiceTypes", d->serviceType);
d->author = config.readEntry("X-KDE-PluginInfo-Author", d->author); d->author = config.readEntry("X-KDE-PluginInfo-Author", d->author);
d->email = config.readEntry("X-KDE-PluginInfo-Email", d->email); d->email = config.readEntry("X-KDE-PluginInfo-Email", d->email);
d->version = config.readEntry("X-KDE-PluginInfo-Version", d->version); d->version = config.readEntry("X-KDE-PluginInfo-Version", d->version);
@ -121,72 +117,77 @@ void PackageMetadata::read(const QString& filename)
d->requiredVersion = config.readEntry("X-KDE-Plasmagik-RequiredVersion", d->requiredVersion); d->requiredVersion = config.readEntry("X-KDE-Plasmagik-RequiredVersion", d->requiredVersion);
} }
QString PackageMetadata::name() QString PackageMetadata::name() const
{ {
return d->name; return d->name;
} }
QString PackageMetadata::description() QString PackageMetadata::description() const
{ {
return d->description; return d->description;
} }
QString PackageMetadata::author() QString PackageMetadata::serviceType() const
{
return d->serviceType;
}
QString PackageMetadata::author() const
{ {
return d->author; return d->author;
} }
QString PackageMetadata::email() QString PackageMetadata::email() const
{ {
return d->email; return d->email;
} }
QString PackageMetadata::version() QString PackageMetadata::version() const
{ {
return d->version; return d->version;
} }
QString PackageMetadata::website() QString PackageMetadata::website() const
{ {
return d->website; return d->website;
} }
QString PackageMetadata::license() QString PackageMetadata::license() const
{ {
return d->license; return d->license;
} }
QString PackageMetadata::mainFile() QString PackageMetadata::mainFile() const
{ {
return d->mainFile; return d->mainFile;
} }
QString PackageMetadata::application() QString PackageMetadata::application() const
{ {
return d->app; return d->app;
} }
QString PackageMetadata::requiredVersion() QString PackageMetadata::requiredVersion() const
{ {
return d->requiredVersion; return d->requiredVersion;
} }
QString PackageMetadata::releaseNotes() QString PackageMetadata::releaseNotes() const
{ {
return d->releaseNotes; return d->releaseNotes;
} }
QString PackageMetadata::icon() QString PackageMetadata::icon() const
{ {
return d->icon; return d->icon;
} }
QString PackageMetadata::preview() QString PackageMetadata::preview() const
{ {
return d->preview; return d->preview;
} }
QString PackageMetadata::type() QString PackageMetadata::type() const
{ {
return d->type; return d->type;
} }
@ -201,6 +202,11 @@ void PackageMetadata::setDescription(const QString &description)
d->description = description; d->description = description;
} }
void PackageMetadata::setServiceType(const QString &serviceType)
{
d->serviceType = serviceType;
}
void PackageMetadata::setAuthor(const QString &author) void PackageMetadata::setAuthor(const QString &author)
{ {
d->author = author; d->author = author;

View File

@ -43,7 +43,7 @@ public:
PackageMetadata(const QString& path); PackageMetadata(const QString& path);
~PackageMetadata(); ~PackageMetadata();
bool isComplete(); bool isComplete() const;
/** /**
* Writes out the metadata to filename, which should be a .desktop * Writes out the metadata to filename, which should be a .desktop
@ -53,7 +53,7 @@ public:
* *
* @arg filename path to the file to write to * @arg filename path to the file to write to
**/ **/
void write(const QString& filename); void write(const QString& filename) const;
/** /**
* Reads in metadata from a file, which should be a .desktop * Reads in metadata from a file, which should be a .desktop
@ -65,20 +65,21 @@ public:
**/ **/
void read(const QString& filename); void read(const QString& filename);
QString name(); QString name() const;
QString description(); QString description() const;
QString author(); QString serviceType() const;
QString email(); QString author() const;
QString version(); QString email() const;
QString website(); QString version() const;
QString license(); QString website() const;
QString mainFile(); QString license() const;
QString application(); QString mainFile() const;
QString requiredVersion(); QString application() const;
QString releaseNotes(); QString requiredVersion() const;
QString filenameToSave(); QString releaseNotes() const;
QString filenameToSave() const;
// filename // filename
QString icon(); QString icon() const;
/** /**
* Path to a PNG file containing a preview image. * Path to a PNG file containing a preview image.
@ -87,12 +88,13 @@ public:
* @return path to a local image file, or QString() if no * @return path to a local image file, or QString() if no
* preview is available * preview is available
**/ **/
QString preview(); QString preview() const;
QString type(); QString type() const;
void setName(const QString &); void setName(const QString &);
void setDescription(const QString &); void setDescription(const QString &);
void setServiceType(const QString &);
void setAuthor(const QString &); void setAuthor(const QString &);
void setEmail(const QString &); void setEmail(const QString &);
void setVersion(const QString &); void setVersion(const QString &);