Commit 04b52402 authored by Cyrille Berger's avatar Cyrille Berger

* make a KisSerializedWhateverConfigurationFactory generic to...

* make a KisSerializedWhateverConfigurationFactory generic to KisBaseProcessor, and remove all the children of KisFilterConfigurationFactory (and remove it too)

(I strongly suggest a make clean in Krita after those change, if you want properly working filters)

CCMAIL:kimageshop@kde.org

svn path=/trunk/koffice/; revision=939162
parent 32c3fbb3
......@@ -78,11 +78,10 @@ KoID KisFilter::categoryOther()
}
KisFilter::KisFilter(const KoID& id, const KoID & category, const QString & entry)
: KisBaseProcessor(id, category, entry)
KisFilter::KisFilter(const KoID& _id, const KoID & category, const QString & entry)
: KisBaseProcessor(_id, category, entry)
{
setBookmarkManager(new KisBookmarkedConfigurationManager(configEntryGroup(),
new KisFilterConfigurationFactory(id.id(), 1)));
init(id() + "_filter_bookmarks");
}
KisFilter::~KisFilter()
......@@ -110,10 +109,6 @@ void KisFilter::process(KisPaintDeviceSP device, const QRect& rect, const KisFil
process(info, info, rect.size(), config, 0);
}
QString KisFilter::configEntryGroup() const
{
return id() + "_filter_bookmarks";
}
bool KisFilter::workWith(const KoColorSpace* cs) const
{
......
......@@ -155,31 +155,3 @@ void KisFilterConfiguration::setChannelFlags(QBitArray channelFlags)
{
d->channelFlags = channelFlags;
}
struct KisFilterConfigurationFactory::Private {
QString name;
qint32 version;
};
KisFilterConfigurationFactory::KisFilterConfigurationFactory(const QString & name, qint32 version) : d(new Private)
{
d->name = name;
d->version = version;
}
KisFilterConfigurationFactory::~KisFilterConfigurationFactory()
{
delete d;
}
KisSerializableConfiguration* KisFilterConfigurationFactory::createDefault()
{
return new KisFilterConfiguration(d->name, d->version);
}
KisSerializableConfiguration* KisFilterConfigurationFactory::create(const QDomElement& e)
{
KisFilterConfiguration* fc = new KisFilterConfiguration(d->name, d->version);
fc->fromXML(e);
return fc;
}
......@@ -107,16 +107,4 @@ private:
Private* const d;
};
class KRITAIMAGE_EXPORT KisFilterConfigurationFactory : public KisSerializableConfigurationFactory
{
public:
KisFilterConfigurationFactory(const QString & name, qint32 version);
virtual ~KisFilterConfigurationFactory();
virtual KisSerializableConfiguration* createDefault();
virtual KisSerializableConfiguration* create(const QDomElement& e);
private:
struct Private;
Private* const d;
};
#endif // _KIS_FILTER_CONFIGURATION_H_
......@@ -29,10 +29,11 @@
#include "kis_selection.h"
#include "kis_types.h"
KisGenerator::KisGenerator(const KoID& id, const KoID & category, const QString & entry)
: KisBaseProcessor(id, category, entry)
KisGenerator::KisGenerator(const KoID& _id, const KoID & category, const QString & entry)
: KisBaseProcessor(_id, category, entry)
{
setBookmarkManager(new KisBookmarkedConfigurationManager(configEntryGroup(), new KisFilterConfigurationFactory(id.id(), 1)));
init(id() + "_generator_bookmarks");
}
KisGenerator::~KisGenerator()
......@@ -52,11 +53,6 @@ const KoColorSpace * KisGenerator::colorSpace()
return 0;
}
QString KisGenerator::configEntryGroup() const
{
return id() + "_generator_bookmarks";
}
QRect KisGenerator::generatedRect( QRect _imageArea, const KisFilterConfiguration* ) const
{
return _imageArea;
......
......@@ -43,7 +43,7 @@ class KisProcessingInformation;
*/
class KRITAIMAGE_EXPORT KisGenerator : public KisBaseProcessor
{
friend class KisGeneratorConfigurationFactory;
public:
KisGenerator(const KoID& id, const KoID & category, const QString & entry);
......
......@@ -26,6 +26,25 @@
#include "kis_selection.h"
#include "kis_types.h"
class KisBaseProcessorConfigurationFactory : public KisSerializableConfigurationFactory
{
public:
KisBaseProcessorConfigurationFactory(KisBaseProcessor* _generator) : m_generator(_generator) {}
virtual ~KisBaseProcessorConfigurationFactory() {}
virtual KisSerializableConfiguration* createDefault() {
return m_generator->factoryConfiguration(0);
}
virtual KisSerializableConfiguration* create(const QDomElement& e)
{
KisSerializableConfiguration* config = m_generator->factoryConfiguration(0);
config->fromXML(e);
return config;
}
private:
KisBaseProcessor* m_generator;
};
struct KisBaseProcessor::Private {
Private()
: bookmarkManager(0)
......@@ -59,6 +78,11 @@ KisBaseProcessor::KisBaseProcessor(const KoID& id, const KoID & category, const
d->entry = entry;
}
void KisBaseProcessor::init(const QString& configEntryGroup)
{
d->bookmarkManager = new KisBookmarkedConfigurationManager(configEntryGroup, new KisBaseProcessorConfigurationFactory(this));
}
KisBaseProcessor::~KisBaseProcessor()
{
delete d->bookmarkManager;
......@@ -97,12 +121,6 @@ const KisBookmarkedConfigurationManager* KisBaseProcessor::bookmarkManager() con
return d->bookmarkManager;
}
void KisBaseProcessor::setBookmarkManager(KisBookmarkedConfigurationManager* bm)
{
delete d->bookmarkManager;
d->bookmarkManager = bm;
}
QString KisBaseProcessor::id() const
{
return d->id.id();
......
......@@ -55,6 +55,7 @@ class KisConfigWidget;
*/
class KRITAIMAGE_EXPORT KisBaseProcessor : public KisShared
{
friend class KisBaseProcessorConfigurationFactory;
public:
......@@ -72,7 +73,7 @@ public:
*
* @return the default configuration of this widget
*/
virtual KisFilterConfiguration * defaultConfiguration(const KisPaintDeviceSP) const;
KisFilterConfiguration * defaultConfiguration(const KisPaintDeviceSP) const;
/**
* @return the bookmark manager for this processor
......@@ -148,10 +149,7 @@ protected:
protected:
void setBookmarkManager(KisBookmarkedConfigurationManager*);
/// @return the name of config group in KConfig
virtual QString configEntryGroup() const = 0;
void init(const QString& configEntryGroup);
/// @return the default configuration as defined by whoever wrote the plugin
virtual KisFilterConfiguration* factoryConfiguration(const KisPaintDeviceSP) const;
......
......@@ -50,21 +50,6 @@
#include "kis_histogram.h"
#include "kis_painter.h"
class KisBrightnessContrastFilterConfigurationFactory : public KisFilterConfigurationFactory
{
public:
KisBrightnessContrastFilterConfigurationFactory() : KisFilterConfigurationFactory("brightnesscontrast", 1) {}
virtual ~KisBrightnessContrastFilterConfigurationFactory() { }
virtual KisSerializableConfiguration* createDefault() {
return new KisBrightnessContrastFilterConfiguration();
}
virtual KisSerializableConfiguration* create(const QDomElement& e) {
KisFilterConfiguration* fc = new KisBrightnessContrastFilterConfiguration();
fc->fromXML(e);
return fc;
}
};
KisBrightnessContrastFilterConfiguration::KisBrightnessContrastFilterConfiguration()
: KisFilterConfiguration("brightnesscontrast", 1)
{
......@@ -160,8 +145,6 @@ KisBrightnessContrastFilter::KisBrightnessContrastFilter()
setSupportsPreview(true);
setSupportsIncrementalPainting(false);
setColorSpaceIndependence(TO_LAB16);
setBookmarkManager(new KisBookmarkedConfigurationManager(configEntryGroup(), new KisBrightnessContrastFilterConfigurationFactory()));
}
KisConfigWidget * KisBrightnessContrastFilter::createConfigurationWidget(QWidget *parent, const KisPaintDeviceSP dev, const KisImageSP image) const
......@@ -173,8 +156,7 @@ KisConfigWidget * KisBrightnessContrastFilter::createConfigurationWidget(QWidget
KisFilterConfiguration* KisBrightnessContrastFilter::factoryConfiguration(const KisPaintDeviceSP)
const
{
KisFilterConfiguration* config = new KisBrightnessContrastFilterConfiguration();
return config;
return new KisBrightnessContrastFilterConfiguration();
}
......
......@@ -255,21 +255,6 @@ void KisPerChannelConfigWidget::setConfiguration(const KisPropertiesConfiguratio
}
class KisPerChannelFilterConfigurationFactory : public KisFilterConfigurationFactory
{
public:
KisPerChannelFilterConfigurationFactory() : KisFilterConfigurationFactory("perchannel", 1) {}
virtual ~KisPerChannelFilterConfigurationFactory() { }
virtual KisSerializableConfiguration* createDefault() {
return new KisPerChannelFilterConfiguration(0);
}
virtual KisSerializableConfiguration* create(const QDomElement& e) {
KisFilterConfiguration* fc = new KisPerChannelFilterConfiguration(0);
fc->fromXML(e);
return fc;
}
};
KisPerChannelFilterConfiguration::KisPerChannelFilterConfiguration(int nCh)
: KisFilterConfiguration("perchannel", 1)
{
......@@ -481,8 +466,6 @@ KisPerChannelFilter::KisPerChannelFilter() : KisFilter(id(), categoryAdjust(), i
setSupportsPreview(true);
setSupportsIncrementalPainting(false);
setColorSpaceIndependence(TO_LAB16);
setBookmarkManager(new KisBookmarkedConfigurationManager(configEntryGroup(),
new KisPerChannelFilterConfigurationFactory()));
}
KisConfigWidget * KisPerChannelFilter::createConfigurationWidget(QWidget *parent, const KisPaintDeviceSP dev, const KisImageSP image) const
......
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