Commit af0b2e08 authored by Halla Rempt's avatar Halla Rempt

Rename classes to follow conventions for plugins

parent b58ebbe1
......@@ -2,14 +2,14 @@ add_subdirectory( tests )
set(kritaresourcemanager_PART_SRCS
resourcemanager.cpp
KoXmlResourceBundleManifest.cpp
KoResourceBundle.cpp
KoDlgCreateBundle.cpp
resourcebundle_manifest.cpp
resourcebundle.cpp
dlg_create_bundle.cpp
dlg_bundle_manager.cpp
)
kde4_add_ui_files(kritaresourcemanager_PART_SRCS
wdg_dlgcreatebundle.ui
wdgdlgcreatebundle.ui
wdgdlgbundlemanager.ui
)
......
......@@ -48,11 +48,11 @@ DlgBundleManager::DlgBundleManager(QWidget *parent)
m_ui->bnRemove->setIcon(koIcon("arrow-left"));
connect(m_ui->bnRemove, SIGNAL(clicked()), SLOT(removeSelected()));
KoResourceServer<KoResourceBundle> *bundleServer = ResourceBundleServerProvider::instance()->resourceBundleServer();
KoResourceServer<ResourceBundle> *bundleServer = ResourceBundleServerProvider::instance()->resourceBundleServer();
foreach(const QString &f, bundleServer->blackListedFiles()) {
KoResourceBundle *bundle = new KoResourceBundle(f);
ResourceBundle *bundle = new ResourceBundle(f);
bundle->load();
if (bundle->valid()) {
m_blacklistedBundles[f] = bundle;
......@@ -60,7 +60,7 @@ DlgBundleManager::DlgBundleManager(QWidget *parent)
}
fillListWidget(m_blacklistedBundles.values(), m_ui->listInactive);
foreach(KoResourceBundle *bundle, bundleServer->resources()) {
foreach(ResourceBundle *bundle, bundleServer->resources()) {
qDebug() << "\tbunde" << bundle->name() << bundle->valid();
if (bundle->valid()) {
m_activeBundles[bundle->filename()] = bundle;
......@@ -79,12 +79,12 @@ void DlgBundleManager::removeSelected()
}
void DlgBundleManager::fillListWidget(QList<KoResourceBundle *> bundles, QListWidget *w)
void DlgBundleManager::fillListWidget(QList<ResourceBundle *> bundles, QListWidget *w)
{
w->setIconSize(QSize(ICON_SIZE, ICON_SIZE));
w->setSelectionMode(QAbstractItemView::MultiSelection);
foreach(KoResourceBundle *bundle, bundles) {
foreach(ResourceBundle *bundle, bundles) {
QPixmap pixmap(ICON_SIZE, ICON_SIZE);
if (!bundle->image().isNull()) {
QImage scaled = bundle->image().scaled(ICON_SIZE, ICON_SIZE, Qt::KeepAspectRatio, Qt::SmoothTransformation);
......
......@@ -23,7 +23,7 @@
#include <kdialog.h>
class KoResourceBundle;
class ResourceBundle;
class QListWidget;
namespace Ui
......@@ -47,10 +47,10 @@ private:
QWidget *m_page;
Ui::WdgDlgBundleManager *m_ui;
void fillListWidget(QList<KoResourceBundle*> bundles, QListWidget *w);
void fillListWidget(QList<ResourceBundle*> bundles, QListWidget *w);
QMap<QString, KoResourceBundle*> m_blacklistedBundles;
QMap<QString, KoResourceBundle*> m_activeBundles;
QMap<QString, ResourceBundle*> m_blacklistedBundles;
QMap<QString, ResourceBundle*> m_activeBundles;
};
#endif // DLG_BUNDLE_MANAGER_H
......@@ -16,9 +16,9 @@
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "KoDlgCreateBundle.h"
#include "dlg_create_bundle.h"
#include "ui_wdg_dlgcreatebundle.h"
#include "ui_wdgdlgcreatebundle.h"
#include <QProcessEnvironment>
#include <QFileInfo>
......@@ -45,7 +45,7 @@
#define ICON_SIZE 48
KoDlgCreateBundle::KoDlgCreateBundle(QWidget *parent)
DlgCreateBundle::DlgCreateBundle(QWidget *parent)
: KDialog(parent)
, m_ui(new Ui::WdgDlgCreateBundle)
{
......@@ -95,52 +95,52 @@ KoDlgCreateBundle::KoDlgCreateBundle(QWidget *parent)
resourceTypeSelected(0);
}
KoDlgCreateBundle::~KoDlgCreateBundle()
DlgCreateBundle::~DlgCreateBundle()
{
delete m_ui;
}
QString KoDlgCreateBundle::bundleName() const
QString DlgCreateBundle::bundleName() const
{
return m_ui->editBundleName->text().replace(" ", "_");
}
QString KoDlgCreateBundle::authorName() const
QString DlgCreateBundle::authorName() const
{
return m_ui->editAuthor->text();
}
QString KoDlgCreateBundle::email() const
QString DlgCreateBundle::email() const
{
return m_ui->editEmail->text();
}
QString KoDlgCreateBundle::website() const
QString DlgCreateBundle::website() const
{
return m_ui->editWebsite->text();
}
QString KoDlgCreateBundle::license() const
QString DlgCreateBundle::license() const
{
return m_ui->editLicense->text();
}
QString KoDlgCreateBundle::description() const
QString DlgCreateBundle::description() const
{
return m_ui->editDescription->document()->toPlainText();
}
QString KoDlgCreateBundle::saveLocation() const
QString DlgCreateBundle::saveLocation() const
{
return m_ui->lblSaveLocation->text();
}
QString KoDlgCreateBundle::previewImage() const
QString DlgCreateBundle::previewImage() const
{
return m_previewImage;
}
void KoDlgCreateBundle::accept()
void DlgCreateBundle::accept()
{
QString name = m_ui->editBundleName->text().remove(" ");
......@@ -169,7 +169,7 @@ void KoDlgCreateBundle::accept()
}
}
void KoDlgCreateBundle::selectSaveLocation()
void DlgCreateBundle::selectSaveLocation()
{
KoFileDialog dlg(this, KoFileDialog::OpenDirectory, "resourcebundlesavelocation");
dlg.setDefaultDir(m_ui->lblSaveLocation->text());
......@@ -178,7 +178,7 @@ void KoDlgCreateBundle::selectSaveLocation()
m_ui->lblSaveLocation->setText(location);
}
void KoDlgCreateBundle::addSelected()
void DlgCreateBundle::addSelected()
{
foreach(QListWidgetItem *item, m_ui->tableAvailable->selectedItems()) {
m_ui->tableSelected->addItem(m_ui->tableAvailable->takeItem(m_ui->tableAvailable->row(item)));
......@@ -205,7 +205,7 @@ void KoDlgCreateBundle::addSelected()
}
}
void KoDlgCreateBundle::removeSelected()
void DlgCreateBundle::removeSelected()
{
foreach(QListWidgetItem *item, m_ui->tableSelected->selectedItems()) {
m_ui->tableAvailable->addItem(m_ui->tableSelected->takeItem(m_ui->tableSelected->row(item)));
......@@ -244,7 +244,7 @@ QPixmap imageToIcon(const QImage &img) {
return pixmap;
}
void KoDlgCreateBundle::resourceTypeSelected(int idx)
void DlgCreateBundle::resourceTypeSelected(int idx)
{
QString resourceType = m_ui->cmbResourceTypes->itemData(idx).toString();
......@@ -337,7 +337,7 @@ void KoDlgCreateBundle::resourceTypeSelected(int idx)
}
}
void KoDlgCreateBundle::getPreviewImage()
void DlgCreateBundle::getPreviewImage()
{
KoFileDialog dialog(this, KoFileDialog::OpenFile, "BundlePreviewImage");
dialog.setCaption(i18n("Select file to use as dynamic file layer."));
......
......@@ -26,13 +26,13 @@ namespace Ui
class WdgDlgCreateBundle;
}
class KoDlgCreateBundle : public KDialog
class DlgCreateBundle : public KDialog
{
Q_OBJECT
public:
explicit KoDlgCreateBundle(QWidget *parent = 0);
~KoDlgCreateBundle();
explicit DlgCreateBundle(QWidget *parent = 0);
~DlgCreateBundle();
QString bundleName() const;
QString authorName() const;
......
......@@ -17,8 +17,8 @@
* Boston, MA 02110-1301, USA.
*/
#include "KoResourceBundle.h"
#include "KoXmlResourceBundleManifest.h"
#include "resourcebundle.h"
#include "resourcebundle_manifest.h"
#include <KoXmlReader.h>
#include <KoXmlWriter.h>
......@@ -51,7 +51,7 @@
#include <resourcemanager.h>
KoResourceBundle::KoResourceBundle(QString const& fileName)
ResourceBundle::ResourceBundle(QString const& fileName)
: KoResource(fileName)\
{
setName(QFileInfo(fileName).baseName());
......@@ -69,16 +69,16 @@ KoResourceBundle::KoResourceBundle(QString const& fileName)
m_metadata["generator"] = "Krita (" + version + ")";
}
KoResourceBundle::~KoResourceBundle()
ResourceBundle::~ResourceBundle()
{
}
QString KoResourceBundle::defaultFileExtension() const
QString ResourceBundle::defaultFileExtension() const
{
return QString(".bundle");
}
bool KoResourceBundle::load()
bool ResourceBundle::load()
{
if (filename().isEmpty()) return false;
QScopedPointer<KoStore> resourceStore(KoStore::createStore(filename(), KoStore::Read, "application/x-krita-resourcebundle", KoStore::Zip));
......@@ -98,7 +98,7 @@ bool KoResourceBundle::load()
}
resourceStore->close();
foreach(KoXmlResourceBundleManifest::ResourceReference ref, m_manifest.files()) {
foreach(ResourceBundleManifest::ResourceReference ref, m_manifest.files()) {
if (!resourceStore->open(ref.resourcePath)) {
qWarning() << "Bundle is broken. File" << ref.resourcePath << "is missing";
return false;
......@@ -186,7 +186,7 @@ bool KoResourceBundle::load()
return true;
}
bool KoResourceBundle::loadFromDevice(QIODevice *)
bool ResourceBundle::loadFromDevice(QIODevice *)
{
return false;
}
......@@ -224,7 +224,7 @@ bool saveResourceToStore(KoResource *resource, KoStore *store, const QString &re
}
bool KoResourceBundle::save()
bool ResourceBundle::save()
{
if (filename().isEmpty()) return false;
......@@ -240,7 +240,7 @@ bool KoResourceBundle::save()
foreach(const QString &resType, m_manifest.types()) {
if (resType == "ko_gradients") {
KoResourceServer<KoAbstractGradient>* gradientServer = KoResourceServerProvider::instance()->gradientServer();
foreach(const KoXmlResourceBundleManifest::ResourceReference &ref, m_manifest.files(resType)) {
foreach(const ResourceBundleManifest::ResourceReference &ref, m_manifest.files(resType)) {
KoResource *res = gradientServer->resourceByMD5(ref.md5sum);
if (!res) res = gradientServer->resourceByFilename(QFileInfo(ref.resourcePath).completeBaseName());
saveResourceToStore(res, store.data(), "gradients");
......@@ -248,7 +248,7 @@ bool KoResourceBundle::save()
}
else if (resType == "ko_patterns") {
KoResourceServer<KoPattern>* patternServer = KoResourceServerProvider::instance()->patternServer();
foreach(const KoXmlResourceBundleManifest::ResourceReference &ref, m_manifest.files(resType)) {
foreach(const ResourceBundleManifest::ResourceReference &ref, m_manifest.files(resType)) {
KoResource *res = patternServer->resourceByMD5(ref.md5sum);
if (!res) res = patternServer->resourceByFilename(QFileInfo(ref.resourcePath).completeBaseName());
saveResourceToStore(res, store.data(), "patterns");
......@@ -256,7 +256,7 @@ bool KoResourceBundle::save()
}
else if (resType == "kis_brushes") {
KisBrushResourceServer* brushServer = KisBrushServer::instance()->brushServer();
foreach(const KoXmlResourceBundleManifest::ResourceReference &ref, m_manifest.files(resType)) {
foreach(const ResourceBundleManifest::ResourceReference &ref, m_manifest.files(resType)) {
KisBrushSP brush = brushServer->resourceByMD5(ref.md5sum);
if (!brush) brush = brushServer->resourceByFilename(QFileInfo(ref.resourcePath).completeBaseName());
KoResource *res = brush.data();
......@@ -265,7 +265,7 @@ bool KoResourceBundle::save()
}
else if (resType == "ko_palettes") {
KoResourceServer<KoColorSet>* paletteServer = KoResourceServerProvider::instance()->paletteServer();
foreach(const KoXmlResourceBundleManifest::ResourceReference &ref, m_manifest.files(resType)) {
foreach(const ResourceBundleManifest::ResourceReference &ref, m_manifest.files(resType)) {
KoResource *res = paletteServer->resourceByMD5(ref.md5sum);
if (!res) res = paletteServer->resourceByFilename(QFileInfo(ref.resourcePath).completeBaseName());
saveResourceToStore(res, store.data(), "palettes");
......@@ -273,7 +273,7 @@ bool KoResourceBundle::save()
}
else if (resType == "kis_workspaces") {
KoResourceServer< KisWorkspaceResource >* workspaceServer = KisResourceServerProvider::instance()->workspaceServer();
foreach(const KoXmlResourceBundleManifest::ResourceReference &ref, m_manifest.files(resType)) {
foreach(const ResourceBundleManifest::ResourceReference &ref, m_manifest.files(resType)) {
KoResource *res = workspaceServer->resourceByMD5(ref.md5sum);
if (!res) res = workspaceServer->resourceByFilename(QFileInfo(ref.resourcePath).completeBaseName());
saveResourceToStore(res, store.data(), "workspaces");
......@@ -281,7 +281,7 @@ bool KoResourceBundle::save()
}
else if (resType == "kis_paintoppresets") {
KoResourceServer<KisPaintOpPreset>* paintoppresetServer = KisResourceServerProvider::instance()->paintOpPresetServer();
foreach(const KoXmlResourceBundleManifest::ResourceReference &ref, m_manifest.files(resType)) {
foreach(const ResourceBundleManifest::ResourceReference &ref, m_manifest.files(resType)) {
KoResource *res = paintoppresetServer->resourceByMD5(ref.md5sum);
if (!res) res = paintoppresetServer->resourceByFilename(QFileInfo(ref.resourcePath).completeBaseName());
saveResourceToStore(res, store.data(), "paintoppresets");
......@@ -348,12 +348,12 @@ bool KoResourceBundle::save()
return true;
}
bool KoResourceBundle::saveToDevice(QIODevice */*dev*/) const
bool ResourceBundle::saveToDevice(QIODevice */*dev*/) const
{
return false;
}
void KoResourceBundle::install()
void ResourceBundle::install()
{
if (filename().isEmpty()) return;
QScopedPointer<KoStore> resourceStore(KoStore::createStore(filename(), KoStore::Read, "application/x-krita-resourcebundle", KoStore::Zip));
......@@ -362,7 +362,7 @@ void KoResourceBundle::install()
foreach(const QString &resType, m_manifest.types()) {
if (resType == "ko_gradients") {
KoResourceServer<KoAbstractGradient>* gradientServer = KoResourceServerProvider::instance()->gradientServer();
foreach(const KoXmlResourceBundleManifest::ResourceReference &ref, m_manifest.files(resType)) {
foreach(const ResourceBundleManifest::ResourceReference &ref, m_manifest.files(resType)) {
KoAbstractGradient *res = gradientServer->createResource(ref.resourcePath);
if (!resourceStore->open(ref.resourcePath)) {
qWarning() << "Failed to open" << ref.resourcePath << "from bundle" << filename();
......@@ -379,7 +379,7 @@ void KoResourceBundle::install()
}
else if (resType == "ko_patterns") {
KoResourceServer<KoPattern>* patternServer = KoResourceServerProvider::instance()->patternServer();
foreach(const KoXmlResourceBundleManifest::ResourceReference &ref, m_manifest.files(resType)) {
foreach(const ResourceBundleManifest::ResourceReference &ref, m_manifest.files(resType)) {
KoPattern *res = patternServer->createResource(ref.resourcePath);
if (!resourceStore->open(ref.resourcePath)) {
qWarning() << "Failed to open" << ref.resourcePath << "from bundle" << filename();
......@@ -396,7 +396,7 @@ void KoResourceBundle::install()
}
else if (resType == "kis_brushes") {
KisBrushResourceServer *brushServer = KisBrushServer::instance()->brushServer();
foreach(const KoXmlResourceBundleManifest::ResourceReference &ref, m_manifest.files(resType)) {
foreach(const ResourceBundleManifest::ResourceReference &ref, m_manifest.files(resType)) {
KisBrushSP res = brushServer->createResource(ref.resourcePath);
if (!resourceStore->open(ref.resourcePath)) {
qWarning() << "Failed to open" << ref.resourcePath << "from bundle" << filename();
......@@ -413,7 +413,7 @@ void KoResourceBundle::install()
}
else if (resType == "ko_palettes") {
KoResourceServer<KoColorSet>* paletteServer = KoResourceServerProvider::instance()->paletteServer();
foreach(const KoXmlResourceBundleManifest::ResourceReference &ref, m_manifest.files(resType)) {
foreach(const ResourceBundleManifest::ResourceReference &ref, m_manifest.files(resType)) {
KoColorSet *res = paletteServer->createResource(ref.resourcePath);
if (!resourceStore->open(ref.resourcePath)) {
qWarning() << "Failed to open" << ref.resourcePath << "from bundle" << filename();
......@@ -430,7 +430,7 @@ void KoResourceBundle::install()
}
else if (resType == "kis_workspaces") {
KoResourceServer< KisWorkspaceResource >* workspaceServer = KisResourceServerProvider::instance()->workspaceServer();
foreach(const KoXmlResourceBundleManifest::ResourceReference &ref, m_manifest.files(resType)) {
foreach(const ResourceBundleManifest::ResourceReference &ref, m_manifest.files(resType)) {
KisWorkspaceResource *res = workspaceServer->createResource(ref.resourcePath);
if (!resourceStore->open(ref.resourcePath)) {
qWarning() << "Failed to open" << ref.resourcePath << "from bundle" << filename();
......@@ -447,7 +447,7 @@ void KoResourceBundle::install()
}
else if (resType == "kis_paintoppresets") {
KoResourceServer<KisPaintOpPreset>* paintoppresetServer = KisResourceServerProvider::instance()->paintOpPresetServer();
foreach(const KoXmlResourceBundleManifest::ResourceReference &ref, m_manifest.files(resType)) {
foreach(const ResourceBundleManifest::ResourceReference &ref, m_manifest.files(resType)) {
KisPaintOpPreset *res = paintoppresetServer->createResource(ref.resourcePath);
if (!resourceStore->open(ref.resourcePath)) {
qWarning() << "Failed to open" << ref.resourcePath << "from bundle" << filename();
......@@ -466,7 +466,7 @@ void KoResourceBundle::install()
m_installed = true;
}
void KoResourceBundle::uninstall()
void ResourceBundle::uninstall()
{
// if (!m_installed)
// return;
......@@ -488,12 +488,12 @@ void KoResourceBundle::uninstall()
// save();
}
void KoResourceBundle::addMeta(const QString &type, const QString &value)
void ResourceBundle::addMeta(const QString &type, const QString &value)
{
m_metadata.insert(type, value);
}
const QString KoResourceBundle::getMeta(const QString &type, const QString &defaultValue) const
const QString ResourceBundle::getMeta(const QString &type, const QString &defaultValue) const
{
if (m_metadata.contains(type)) {
return m_metadata[type];
......@@ -504,23 +504,23 @@ const QString KoResourceBundle::getMeta(const QString &type, const QString &defa
}
void KoResourceBundle::addResource(QString fileType, QString filePath, QStringList fileTagList, const QByteArray md5sum)
void ResourceBundle::addResource(QString fileType, QString filePath, QStringList fileTagList, const QByteArray md5sum)
{
m_manifest.addResource(fileType, filePath, fileTagList, md5sum);
}
QList<QString> KoResourceBundle::getTagsList()
QList<QString> ResourceBundle::getTagsList()
{
return QList<QString>::fromSet(m_bundletags);
}
void KoResourceBundle::removeFile(QString fileName)
void ResourceBundle::removeFile(QString fileName)
{
m_manifest.removeFile(fileName);
}
void KoResourceBundle::addResourceDirs()
void ResourceBundle::addResourceDirs()
{
QDir bundleDir = KGlobal::dirs()->saveLocation("appdata", "bundles");
bundleDir.cdUp();
......@@ -530,12 +530,12 @@ void KoResourceBundle::addResourceDirs()
}
}
bool KoResourceBundle::isInstalled()
bool ResourceBundle::isInstalled()
{
return m_installed;
}
void KoResourceBundle::rename(QString filename, QString name)
void ResourceBundle::rename(QString filename, QString name)
{
QString oldName = shortFilename();
QString shortName = name.section('.', 0, 0);
......@@ -561,12 +561,12 @@ void KoResourceBundle::rename(QString filename, QString name)
save();
}
void KoResourceBundle::removeTag(QString tagName)
void ResourceBundle::removeTag(QString tagName)
{
m_bundletags.remove(tagName);
}
void KoResourceBundle::setThumbnail(QString filename)
void ResourceBundle::setThumbnail(QString filename)
{
if (QFileInfo(filename).exists()) {
m_thumbnail = QImage(filename);
......@@ -581,12 +581,12 @@ void KoResourceBundle::setThumbnail(QString filename)
}
}
void KoResourceBundle::addTag(const QString &tagName)
void ResourceBundle::addTag(const QString &tagName)
{
m_bundletags << tagName;
}
QByteArray KoResourceBundle::generateMD5() const
QByteArray ResourceBundle::generateMD5() const
{
QFile f(filename());
if (f.exists()) {
......@@ -599,7 +599,7 @@ QByteArray KoResourceBundle::generateMD5() const
return QByteArray();
}
void KoResourceBundle::writeMeta(const char *metaTag, const QString &metaKey, KoXmlWriter *writer)
void ResourceBundle::writeMeta(const char *metaTag, const QString &metaKey, KoXmlWriter *writer)
{
if (m_metadata.contains(metaKey)) {
writer->startElement(metaTag);
......@@ -608,7 +608,7 @@ void KoResourceBundle::writeMeta(const char *metaTag, const QString &metaKey, Ko
}
}
void KoResourceBundle::writeUserDefinedMeta(const QString &metaKey, KoXmlWriter *writer)
void ResourceBundle::writeUserDefinedMeta(const QString &metaKey, KoXmlWriter *writer)
{
if (m_metadata.contains(metaKey)) {
writer->startElement("meta:meta-userdefined");
......
......@@ -25,25 +25,25 @@
#include <KoXmlWriter.h>
#include "KoResource.h"
#include "KoXmlResourceBundleManifest.h"
#include "resourcebundle_manifest.h"
/**
* @brief The KoResourceBundle class
* @brief The ResourceBundle class
* @details Describe the resource bundles as KoResources
*/
class KoResourceBundle : public KoResource
class ResourceBundle : public KoResource
{
public:
/**
* @brief KoResourceBundle : Ctor * @param bundlePath the path of the bundle
* @brief ResourceBundle : Ctor * @param bundlePath the path of the bundle
*/
KoResourceBundle(QString const& fileName);
ResourceBundle(QString const& fileName);
/**
* @brief ~KoResourceBundle : Dtor
* @brief ~ResourceBundle : Dtor
*/
virtual ~KoResourceBundle();
virtual ~ResourceBundle();
/**
* @brief defaultFileExtension
......@@ -131,7 +131,7 @@ private:
private:
QImage m_thumbnail;
KoXmlResourceBundleManifest m_manifest;
ResourceBundleManifest m_manifest;
QMap<QString, QString> m_metadata;
QSet<QString> m_bundletags;
bool m_installed;
......
......@@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "KoXmlResourceBundleManifest.h"
#include "resourcebundle_manifest.h"
#include <QList>
#include <QString>
......@@ -56,15 +56,15 @@ QString manifestTypeToResourceType(const QString &type) {
}
}
KoXmlResourceBundleManifest::KoXmlResourceBundleManifest()
ResourceBundleManifest::ResourceBundleManifest()
{
}
KoXmlResourceBundleManifest::~KoXmlResourceBundleManifest()
ResourceBundleManifest::~ResourceBundleManifest()
{
}
bool KoXmlResourceBundleManifest::load(QIODevice *device)
bool ResourceBundleManifest::load(QIODevice *device)
{
m_resources.clear();