diff --git a/plugins/extensions/gmic/Category.h b/plugins/extensions/gmic/Category.h index 4c614fccf2..062cc8d6c7 100644 --- a/plugins/extensions/gmic/Category.h +++ b/plugins/extensions/gmic/Category.h @@ -1,78 +1,77 @@ /* * Copyright (c) 2013 Lukáš Tvrdý #include #include class Category : public Component { - Q_OBJECT public: Category(Component * parent = 0); virtual ~Category(); virtual void add(Component *c); virtual Component* child(int index) const; virtual Component* parent() { return m_parent; } void setParent(Component * parent) { m_parent = parent; } virtual int row() const; virtual int indexOf(const Component* c) const; virtual int childCount() const; virtual int columnCount() const; void processCategoryName(const QString &line); virtual void print(int level = 0); virtual QVariant data(int column); template int indexOf(const QString &componentName) const { for (int i = 0; i < m_components.size(); i++) { const T * component = dynamic_cast(m_components.at(i)); if (component) { if (component->name() == componentName) { return i; } } } return -1; } void replace(int position, Component * c); public: QList m_components; // categories and commands private: Component * m_parent; }; #endif diff --git a/plugins/extensions/gmic/Command.h b/plugins/extensions/gmic/Command.h index 67502d14e6..1486d12b69 100644 --- a/plugins/extensions/gmic/Command.h +++ b/plugins/extensions/gmic/Command.h @@ -1,100 +1,99 @@ /* * Copyright (c) 2013-2015 Lukáš Tvrdý * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef COMMAND_H #define COMMAND_H #include #include "kis_gmic_filter_settings.h" #include "Parameter.h" #include class QWidget; class QString; class QStringList; class Parameter; /* This class represents one filter definition: command for preview and filter and parameters for filter */ class Command : public Component { - Q_OBJECT public: Command(Component * parent = 0); virtual ~Command(); QString m_command; QString m_commandPreview; QString m_commandPreviewZoom; QList m_parameters; virtual void add(Component* c); virtual Component* child(int index) const; virtual Component* parent(); void setParent(Component * parent) { m_parent = parent; } virtual int row() const; virtual int childCount() const; virtual int columnCount() const; virtual QVariant data(int column); void setParameter(const QString &name, const QString &value); QString parameter(const QString &name) const; // reset to default values void reset(); void print(int level); void processCommandName(const QString &line); /* return true if the parameter parsed is complete */ bool processParameter(const QStringList &block); // QWidget * createSettingsWidget(); void writeConfiguration(KisGmicFilterSetting * setting); bool hasParameterName(const QString& paramName, const QString& paramType = QString()); private: QString mergeBlockToLine(const QStringList &block); QString buildCommand(const QString &baseCommand); private: Component * m_parent; /* param [in] line param [out] lastTokenEnclosed if the last token-parameter is not enclosed and continue on the next line, this flag is false, true otherwise @return set of tokens, e.g. note = [ 'note("example")', 'sep = separator()' ] */ QStringList breakIntoTokens(const QString &line, bool &lastTokenEnclosed); /** * param [in] token - string describing one parameter. e.g. Height = _int(128,8,256) or note = note{"Example"} * param [out] parameterName "Height" or "note" etc. * param [out] parameterDefinition "_int(128,8,256)" or "note{"Example"}" * */ bool processToken(const QString &token, QString ¶meterName, QString ¶meterDefinition); // return new index pointing to non-whitespace, index can be line.size() int skipWhitespace(const QString &line, int index); }; Q_DECLARE_METATYPE(Command*) #endif diff --git a/plugins/extensions/gmic/Component.h b/plugins/extensions/gmic/Component.h index 7c4fab31c5..0203a0f85f 100644 --- a/plugins/extensions/gmic/Component.h +++ b/plugins/extensions/gmic/Component.h @@ -1,58 +1,56 @@ /* * Copyright (c) 2013 Lukáš Tvrdý #include #include -class Component : public QObject +class Component { - Q_OBJECT public: Component(); virtual ~Component(); virtual void add(Component *c) = 0; virtual Component * child(int index) const = 0; virtual Component * parent() = 0; virtual int row() const = 0; virtual int childCount() const = 0; virtual int columnCount() const = 0; virtual int indexOf(const Component *c) const { Q_UNUSED(c); return -1; } virtual void setName(const QString &name) { m_name = name; } virtual QString name() const { return m_name; } virtual void print(int level = 0) { Q_UNUSED(level); } virtual QVariant data(int column) { Q_UNUSED(column); return QVariant(); } private: QString m_name; }; #endif diff --git a/plugins/extensions/gmic/kis_gmic_blacklister.h b/plugins/extensions/gmic/kis_gmic_blacklister.h index 85a7820799..cfa0dbc668 100644 --- a/plugins/extensions/gmic/kis_gmic_blacklister.h +++ b/plugins/extensions/gmic/kis_gmic_blacklister.h @@ -1,72 +1,71 @@ /* * Copyright (c) 2013 Lukáš Tvrdý * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef _KIS_GMIC_BLACKLISTER_H_ #define _KIS_GMIC_BLACKLISTER_H_ #include #include #include #include #include #include class QDomDocument; class Command; class Component; class ComponentIterator { public: ComponentIterator(const Component * c); ~ComponentIterator(); bool hasNext() const; const Component * next(); private: QQueue m_queue; }; -class KisGmicBlacklister : public QObject +class KisGmicBlacklister { - Q_OBJECT public: KisGmicBlacklister(const QString& filePath); ~KisGmicBlacklister(); bool parseBlacklist(); bool isBlacklisted(const QString &filterName, const QString &filterCategory); void dump(); static QString toPlainText(const QString& htmlText); // finds the first filter that matches the filter category and name static Command* findFilter(const Component* rootNode, const QString& filterCategory, const QString& filterName); static Component* findFilterByPath(const Component* rootNode, const Component * path); static QList findFilterByParamName(const Component* rootNode, const QString& paramName, const QString& paramType = QString()); static QVector filtersByName(const Component* rootNode, const QString& filterName); static QDomDocument dumpFiltersToXML(const Component* rootNode); private: QString m_fileName; QHash > m_categoryNameBlacklist; }; #endif diff --git a/plugins/extensions/gmic/kis_gmic_filter_model.h b/plugins/extensions/gmic/kis_gmic_filter_model.h index ee0914d4b2..3e3ae93492 100644 --- a/plugins/extensions/gmic/kis_gmic_filter_model.h +++ b/plugins/extensions/gmic/kis_gmic_filter_model.h @@ -1,71 +1,70 @@ /* * Copyright (c) 2013 Lukáš Tvrdý #include #include -#include #include "Component.h" #include "kis_gmic_blacklister.h" // introduce "rolespace", let's not collide with some other Qt::UserRole + 1 roles e.g. in ui/kis_categorized_list_model.h static const int GmicRolespace = 100; enum { CommandRole = Qt::UserRole + GmicRolespace + 1, FilterSettingsRole = Qt::UserRole + GmicRolespace + 2 }; class KisGmicFilterModel : public QAbstractItemModel { Q_OBJECT public: // takes ownershop of component KisGmicFilterModel(Component * rootComponent, QObject *parent = 0); ~KisGmicFilterModel(); QVariant data(const QModelIndex &index, int role) const; // virtual bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole); Qt::ItemFlags flags(const QModelIndex &index) const; QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const; QModelIndex parent(const QModelIndex &index) const; int rowCount(const QModelIndex &parent = QModelIndex()) const; int columnCount(const QModelIndex &parent = QModelIndex()) const; // takes ownership void setBlacklister(KisGmicBlacklister * blacklister); private: - QPointer m_rootComponent; - QPointer m_blacklister; + Component * m_rootComponent; + KisGmicBlacklister * m_blacklister; }; #endif