Commit f63e2145 authored by Thomas Zander's avatar Thomas Zander

Move the KoID concept out of the generic KoGenericRegistry to the individual registries

We have a lot more registries than 2 years ago and because of Windows compiler
all of those are forced to have a name() method, while nobody uses that value
at all.
So, what about moving the listKeys() method to the registry that actually uses
it and not bother all the other registries with it.

svn path=/trunk/koffice/; revision=1068218
parent 3b96189a
......@@ -21,8 +21,6 @@
#ifndef _KO_GENERIC_REGISTRY_H_
#define _KO_GENERIC_REGISTRY_H_
#include "KoID.h"
#include <kdemacros.h>
#include <QtCore/QList>
#include <QtCore/QString>
......@@ -115,20 +113,6 @@ public:
return m_hash.value(id);
}
/**
* This function return a list of all the keys in KoID format by using the name() method
* on the objects stored in the registry.
*/
QList<KoID> listKeys() const {
QList<KoID> answer;
typename QHash<QString, T>::const_iterator it = m_hash.begin();
// we do not use foreach() here because of GCC 3.3.x bug
for (; it != m_hash.end(); ++it)
answer.append(KoID(it.key(), it.value()->name()));
return answer;
}
/**
* @return a list of all keys
*/
......
......@@ -146,4 +146,14 @@ QString KisPaintOpRegistry::pixmap(const KoID & id) const
return f->pixmap();
}
QList<KoID> KisPaintOpRegistry::listKeys() const
{
QList<KoID> answer;
foreach (const QString key, keys()) {
answer.append(KoID(key, get(key)->name()));
}
return answer;
}
#include "kis_paintop_registry.moc"
......@@ -74,6 +74,12 @@ public:
// Get the name of the icon to show in the toolchest
QString pixmap(const KoID & id) const;
/**
* This function return a list of all the keys in KoID format by using the name() method
* on the objects stored in the registry.
*/
QList<KoID> listKeys() const;
public:
static KisPaintOpRegistry* instance();
......
......@@ -201,3 +201,12 @@ KisFilterStrategyRegistry* KisFilterStrategyRegistry::instance()
return s_instance;
}
QList<KoID> KisFilterStrategyRegistry::listKeys() const
{
QList<KoID> answer;
foreach (const QString key, keys()) {
answer.append(KoID(key, get(key)->name()));
}
return answer;
}
......@@ -162,6 +162,12 @@ public:
static KisFilterStrategyRegistry* instance();
/**
* This function return a list of all the keys in KoID format by using the name() method
* on the objects stored in the registry.
*/
QList<KoID> listKeys() const;
private:
KisFilterStrategyRegistry();
......
......@@ -68,15 +68,6 @@ public:
/// Creates the dock widget
/// @return the created dock widget
virtual QDockWidget* createDockWidget() = 0;
#ifdef Q_CC_MSVC
/// @cond PRIVATE
/// Dummy method, needed only when used with KoGenericRegistry under msvc.
QString name() const {
return QString();
}
/// @endcond
#endif
};
#endif
......@@ -22,7 +22,7 @@
#include <KLocale>
KoLineBorderFactory::KoLineBorderFactory(QObject *parent)
: KoShapeBorderFactory(parent, "LineBorder", i18n("Line Border"))
: KoShapeBorderFactory(parent, "LineBorder")
{
}
......
......@@ -23,14 +23,13 @@
class KoShapeBorderFactory::Private
{
public:
Private(const QString &i, const QString &n) : id(i), name(n) { }
Private(const QString &i) : id(i) { }
const QString id;
const QString name;
};
KoShapeBorderFactory::KoShapeBorderFactory(QObject *parent, const QString &id, const QString &name)
KoShapeBorderFactory::KoShapeBorderFactory(QObject *parent, const QString &id)
: QObject(parent),
d(new Private(id, name))
d(new Private(id))
{
}
......@@ -39,11 +38,6 @@ KoShapeBorderFactory::~KoShapeBorderFactory()
delete d;
}
QString KoShapeBorderFactory::name() const
{
return d->name;
}
QString KoShapeBorderFactory::id() const
{
return d->id;
......
......@@ -30,7 +30,7 @@ class FLAKE_EXPORT KoShapeBorderFactory : public QObject
Q_OBJECT
public:
KoShapeBorderFactory(QObject *parent, const QString &id, const QString &name);
KoShapeBorderFactory(QObject *parent, const QString &id);
virtual ~KoShapeBorderFactory();
/**
......@@ -48,11 +48,6 @@ public:
* @return the id for the shape this factory creates.
*/
QString id() const;
/**
* return the user visible (and translated) name to be seen by the user.
* @return the user visible (and translated) name to be seen by the user.
*/
QString name() const;
private:
class Private;
......
......@@ -64,11 +64,6 @@ public:
/// If showInMenu() returns true; the returned text is used in the context menu.
QString title() const;
QString name() const
{
return QString();
}
protected:
/**
* Set if the plugin this factory creates has to be shown in the context menu.
......
......@@ -86,11 +86,7 @@ public:
QStringList odfElementNames() const;
const QString & odfNameSpace() const;
#ifdef KDE_FULL_TEMPLATE_EXPORT_INSTANTIATION
QString name() const {
Q_ASSERT(0); return QString();
}
#endif
protected:
/**
* Add a template with the properties of a speficic type of object this factory can generate
......
......@@ -520,3 +520,14 @@ const KoColorSpace* KoColorSpaceRegistry::permanentColorspace( const KoColorSpac
return cs;
}
}
QList<KoID> KoColorSpaceRegistry::listKeys() const
{
QList<KoID> answer;
foreach (const QString key, keys()) {
answer.append(KoID(key, get(key)->name()));
}
return answer;
}
......@@ -241,6 +241,13 @@ public:
* as the one given in argument
*/
const KoColorSpace* permanentColorspace( const KoColorSpace* _colorSpace );
/**
* This function return a list of all the keys in KoID format by using the name() method
* on the objects stored in the registry.
*/
QList<KoID> listKeys() const;
private:
bool isCached(const QString & csId, const QString & profileName) const;
......
......@@ -24,7 +24,8 @@
#include "pigment_export.h"
#include "KoGenericRegistry.h"
#include <KoGenericRegistry.h>
#include <KoID.h>
class QString;
class KoChannelInfo;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment