diff options
author | Ben Boeckel <MathStuf@gmail.com> | 2009-03-26 04:43:59 -0400 |
---|---|---|
committer | Ben Boeckel <MathStuf@gmail.com> | 2009-03-26 04:43:59 -0400 |
commit | 0d642f3374d9be46fb49f7a3fa5e3707935aa0d9 (patch) | |
tree | 3de150b0df0cfca296fe0989c3a91b375942914a /sigtools | |
parent | b9e2d41050f332abda63b0eb1a2450672db4ec0d (diff) | |
download | sigen-0d642f3374d9be46fb49f7a3fa5e3707935aa0d9.tar.gz sigen-0d642f3374d9be46fb49f7a3fa5e3707935aa0d9.tar.xz sigen-0d642f3374d9be46fb49f7a3fa5e3707935aa0d9.zip |
Cleaning up
Diffstat (limited to 'sigtools')
-rw-r--r-- | sigtools/BaseModel.cpp | 64 | ||||
-rw-r--r-- | sigtools/BaseModel.h | 67 | ||||
-rw-r--r-- | sigtools/ClassModel.cpp | 101 | ||||
-rw-r--r-- | sigtools/ClassModel.h | 60 | ||||
-rw-r--r-- | sigtools/PluginModel.cpp | 169 | ||||
-rw-r--r-- | sigtools/PluginModel.h | 60 | ||||
-rw-r--r-- | sigtools/PluginTypeModel.cpp | 77 | ||||
-rw-r--r-- | sigtools/PluginTypeModel.h | 56 | ||||
-rw-r--r-- | sigtools/RootPluginModel.cpp | 66 | ||||
-rw-r--r-- | sigtools/RootPluginModel.h | 54 |
10 files changed, 0 insertions, 774 deletions
diff --git a/sigtools/BaseModel.cpp b/sigtools/BaseModel.cpp deleted file mode 100644 index c806bf83..00000000 --- a/sigtools/BaseModel.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 2009 Ben Boeckel <MathStuf@gmail.com> - * - * 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 3 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, see <http://www.gnu.org/licenses/>. - */ - -// Header include -#include "BaseModel.h" - -// Qt includes -#include <QtGui/QPainter> -#include <QtGui/QStyleOptionViewItem> - -using namespace Sigtools; - -const int BaseModel::borderWidth = 1; -const int BaseModel::vertSpacing = 1; -const int BaseModel::horizSpacing = 1; - -BaseModel::BaseModel(BaseModel* parent) : - m_parent(parent) -{ -} - -BaseModel::~BaseModel() -{ -} - -BaseModel* BaseModel::parent() -{ - return m_parent; -} - -void BaseModel::paint(QPainter* painter, const QStyleOptionViewItem& option) const -{ - if (option.rect.width() != m_pixmap.width()) - redraw(option.rect.width()); - painter->drawPixmap(option.rect.topLeft(), m_pixmap); -} - -QSize BaseModel::sizeHint(const QStyleOptionViewItem& option) const -{ - if (option.rect.width() != m_pixmap.width()) - redraw(option.rect.width()); - return m_pixmap.size(); -} - -int BaseModel::indexNumber() const -{ - if (m_parent) - return m_parent->findChild(const_cast<BaseModel*>(this)); - return -1; -} diff --git a/sigtools/BaseModel.h b/sigtools/BaseModel.h deleted file mode 100644 index 6761f1e3..00000000 --- a/sigtools/BaseModel.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright 2009 Ben Boeckel <MathStuf@gmail.com> - * - * 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 3 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, see <http://www.gnu.org/licenses/>. - */ - -#ifndef SIGTOOLS_BASEMODEL -#define SIGTOOLS_BASEMODEL - -// Sigtools includes -#include "Global.h" - -// Qt includes -#include <QtCore/QString> -#include <QtCore/QVariant> -#include <QtGui/QPixmap> - -// Forward declarations -class QPainter; -class QStyleOptionViewItem; - -namespace Sigtools -{ -class SIGTOOLS_NO_EXPORT BaseModel : public QObject -{ - Q_OBJECT - - public: - BaseModel(BaseModel* parent); - virtual ~BaseModel(); - - BaseModel* parent(); - - virtual int rowCount() const = 0; - - virtual Qt::ItemFlags flags() const = 0; - - void paint(QPainter* painter, const QStyleOptionViewItem& option) const; - QSize sizeHint(const QStyleOptionViewItem& option) const; - - virtual BaseModel* childItem(const int row) = 0; - int indexNumber() const; - protected: - virtual int findChild(BaseModel* model) const = 0; - virtual void redraw(const int width) const = 0; - - static const int borderWidth; - static const int vertSpacing; - static const int horizSpacing; - - BaseModel* m_parent; - mutable QPixmap m_pixmap; -}; -} - -#endif diff --git a/sigtools/ClassModel.cpp b/sigtools/ClassModel.cpp deleted file mode 100644 index 4e814216..00000000 --- a/sigtools/ClassModel.cpp +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright 2009 Ben Boeckel <MathStuf@gmail.com> - * - * 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 3 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, see <http://www.gnu.org/licenses/>. - */ - -// Header include -#include "ClassModel.h" - -// Sigtools includes -#include "PluginModel.h" - -// KDE includes -#include <KColorScheme> -#include <KGlobalSettings> -#include <KIcon> - -// Qt includes -#include <QtCore/QSize> -#include <QtGui/QFontMetrics> -#include <QtGui/QPainter> - -using namespace Sigtools; - -ClassModel::ClassModel(const QIcon& icon, const QString& name, const QString& description, PluginModel* parent) : - BaseModel(parent), - m_icon(icon), - m_name(name), - m_description(description) -{ -} - -int ClassModel::rowCount() const -{ - return 0; -} - -Qt::ItemFlags ClassModel::flags() const -{ - return Qt::ItemIsEnabled | Qt::ItemIsSelectable; -} - -BaseModel* ClassModel::childItem(const int row) -{ - Q_UNUSED(row) - return NULL; -} - -int ClassModel::findChild(BaseModel* model) const -{ - Q_UNUSED(model) - return -1; -} - -void ClassModel::redraw(const int width) const -{ - QFontMetrics regMetrics(KGlobalSettings::generalFont()); - QFont smallFont = KGlobalSettings::smallestReadableFont(); - smallFont.setItalic(true); - QFontMetrics smallMetrics(smallFont); - - QSize nameSize = regMetrics.size(0, m_name); - - int maxWidth = qMax(nameSize.width() + nameSize.width() + horizSpacing, width); - - QSize descSize = smallMetrics.boundingRect(QRect(0, 0, maxWidth, 0), Qt::TextWordWrap, m_description).size(); - - int maxHeight = nameSize.height() + descSize.height() + vertSpacing; - - m_pixmap = QPixmap(maxWidth + 2 * borderWidth, maxHeight + 2 * borderWidth); - m_pixmap.fill(KStatefulBrush(KColorScheme::View, KColorScheme::NormalBackground).brush(QPalette::Normal).color()); - QPainter painter(&m_pixmap); - - int h = borderWidth; - int w = borderWidth; - - painter.drawPixmap(w, h, KIcon(m_icon).pixmap(nameSize.height(), nameSize.height())); - - w += nameSize.height(); - w += horizSpacing; - - painter.drawText(QRect(QPoint(w, h), QSize(maxWidth - w, nameSize.height())), Qt::AlignBottom | Qt::AlignLeft, m_name); - - w = borderWidth; - h += nameSize.height(); - h += vertSpacing; - - painter.setFont(smallFont); - painter.drawText(QRect(QPoint(w, h), descSize), Qt::AlignBottom | Qt::AlignLeft | Qt::TextWordWrap, m_description); -} diff --git a/sigtools/ClassModel.h b/sigtools/ClassModel.h deleted file mode 100644 index 0454eabb..00000000 --- a/sigtools/ClassModel.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2009 Ben Boeckel <MathStuf@gmail.com> - * - * 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 3 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, see <http://www.gnu.org/licenses/>. - */ - -#ifndef SIGTOOLS_CLASSMODEL -#define SIGTOOLS_CLASSMODEL - -// Sigtools includes -#include "BaseModel.h" - -// KDE includes -#include <KService> - -// Qt includes -#include <QtGui/QIcon> - -namespace Sigtools -{ -// Forward declarations -class PluginModel; - -class SIGTOOLS_NO_EXPORT ClassModel : public BaseModel -{ - Q_OBJECT - - public: - ClassModel(const QIcon& icon, const QString& name, const QString& description, PluginModel* parent); - - int rowCount() const; - - Qt::ItemFlags flags() const; - - void paint(QPainter* painter, const QStyleOptionViewItem& option) const; - QSize sizeHint(const QStyleOptionViewItem& option) const; - - BaseModel* childItem(const int row); - protected: - int findChild(BaseModel* model) const; - void redraw(const int width) const; - - const QIcon m_icon; - const QString m_name; - const QString m_description; -}; -} - -#endif diff --git a/sigtools/PluginModel.cpp b/sigtools/PluginModel.cpp deleted file mode 100644 index 176c6a68..00000000 --- a/sigtools/PluginModel.cpp +++ /dev/null @@ -1,169 +0,0 @@ -/* - * Copyright 2009 Ben Boeckel <MathStuf@gmail.com> - * - * 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 3 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, see <http://www.gnu.org/licenses/>. - */ - -// Header include -#include "PluginModel.h" - -// Sigtools includes -#include "ClassModel.h" -#include "PluginTypeModel.h" - -// Sigencore includes -#include <sigencore/plugins/ArenaPlugin.h> -#include <sigencore/plugins/CanvasPlugin.h> - -// KDE includes -#include <KColorScheme> -#include <KGlobalSettings> -#include <KIcon> -#include <KMessageBox> -#include <KPluginInfo> - -// Qt includes -#include <QtGui/QPainter> - -using namespace Sigencore::Interfaces; -using namespace Sigtools; - -PluginModel::PluginModel(KService::Ptr service, PluginTypeModel* parent) : - BaseModel(parent), - m_service(service), - m_info(new KPluginInfo(m_service)) -{ - KPluginLoader loader(m_service->library()); - KPluginFactory *factory = loader.factory(); - - if (!factory) - { - KMessageBox::error(NULL, QString("The plugin of type \"%1\" with name \"%2\" is not a valid Sigen plugin. The error was:\n%3").arg(m_service->serviceTypes()[0]).arg(m_service->name()).arg(loader.errorString()), "Plugin loading error"); - return; - } - - const QStringList types = m_service->serviceTypes(); - foreach (const QString& type, types) - { - if (type == "Sigen/Arena") - { - ArenaPlugin* plugin = factory->create<ArenaPlugin>(this); - if (plugin) - { - QStringList arenas = plugin->arenas(); - foreach (const QString& arena, arenas) - m_classes.append(new ClassModel(plugin->icon(arena), arena, plugin->description(arena), this)); - } - } - else if (type == "Sigen/Canvas") - { - CanvasPlugin* plugin = factory->create<CanvasPlugin>(this); - if (plugin) - { - QStringList canvases = plugin->canvases(); - foreach (const QString& canvas, canvases) - m_classes.append(new ClassModel(plugin->icon(canvas), canvas, plugin->description(canvas), this)); - } - } - else - KMessageBox::information(NULL, QString("The plugin type \"%1\" is not supported.").arg(m_service->type()), "Unsupported plugin type"); - } -} - -int PluginModel::rowCount() const -{ - return m_classes.size(); -} - -Qt::ItemFlags PluginModel::flags() const -{ - return Qt::ItemIsEnabled; -} - -BaseModel* PluginModel::childItem(const int row) -{ - if ((0 <= row) && (row < m_classes.size())) - return m_classes[row]; - return NULL; -} - -int PluginModel::findChild(BaseModel* model) const -{ - return m_classes.indexOf(qobject_cast<ClassModel*>(model)); -} - -void PluginModel::redraw(const int width) const -{ - QFont regFont = KGlobalSettings::generalFont(); - QFontMetrics regMetrics(regFont); - QFont smallFont = KGlobalSettings::smallestReadableFont(); - smallFont.setItalic(true); - QFontMetrics smallMetrics(smallFont); - - QSize nameSize = regMetrics.size(0, m_info->name()); - QSize authorSize = smallMetrics.size(0, QString("by %1").arg(m_info->author())); - QSize versionSize = regMetrics.size(0, m_info->version()); - - int row1width; - int row1height; - - row1height = qMax(nameSize.height(), qMax(authorSize.height(), versionSize.height())); - row1width = row1height + nameSize.width() + authorSize.width() + versionSize.width(); - - QSize websiteSize = smallMetrics.size(0, m_info->website()); - - int maxWidth = qMax(qMax(row1width + 4 * horizSpacing, websiteSize.width()), width - 2 * borderWidth); - - QSize commentSize = smallMetrics.boundingRect(QRect(0, 0, maxWidth, 0), Qt::TextWordWrap, m_info->comment()).size(); - - int maxHeight = row1height + websiteSize.height() + commentSize.height() + 2 * vertSpacing; - - int h = borderWidth; - int w = borderWidth; - - m_pixmap = QPixmap(maxWidth + 2 * borderWidth, maxHeight + 2 * borderWidth); - m_pixmap.fill(KStatefulBrush(KColorScheme::View, KColorScheme::NormalBackground).brush(QPalette::Normal).color()); - QPainter painter(&m_pixmap); - - painter.drawPixmap(w, h, KIcon(m_info->icon()).pixmap(row1height, row1height)); - - w += row1height; - w += horizSpacing; - - painter.drawText(QRect(QPoint(w, h), QSize(row1width - w, row1height)), Qt::AlignBottom | Qt::AlignLeft, m_info->name()); - - w += nameSize.width(); - w += 2 * horizSpacing; - - painter.setFont(smallFont); - painter.drawText(QRect(QPoint(w, h), QSize(row1width - w, row1height)), Qt::AlignBottom | Qt::AlignLeft, QString("by %1").arg(m_info->author())); - - w += authorSize.width(); - w += horizSpacing; - - painter.setFont(regFont); - painter.drawText(QRect(QPoint(w, h), QSize(maxWidth - w, row1height)), Qt::AlignBottom | Qt::AlignRight, m_info->version()); - - h += row1height; - h += vertSpacing; - w = borderWidth; - - painter.setFont(smallFont); - painter.drawText(QRect(QPoint(w, h), websiteSize), Qt::AlignBottom | Qt::AlignLeft, m_info->website()); - - h += websiteSize.height(); - h += vertSpacing; - - painter.drawText(QRect(QPoint(w, h), commentSize), Qt::AlignTop | Qt::AlignLeft | Qt::TextWordWrap, m_info->comment()); -} diff --git a/sigtools/PluginModel.h b/sigtools/PluginModel.h deleted file mode 100644 index f2e0ede6..00000000 --- a/sigtools/PluginModel.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2009 Ben Boeckel <MathStuf@gmail.com> - * - * 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 3 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, see <http://www.gnu.org/licenses/>. - */ - -#ifndef SIGTOOLS_PLUGINMODEL -#define SIGTOOLS_PLUGINMODEL - -// Sigtools includes -#include "BaseModel.h" - -// KDE includes -#include <KService> - -// Qt includes -#include <QtGui/QPixmap> - -// Forward declarations -class KPluginInfo; - -namespace Sigtools -{ -class ClassModel; -class PluginTypeModel; - -class SIGTOOLS_NO_EXPORT PluginModel : public BaseModel -{ - Q_OBJECT - - public: - PluginModel(KService::Ptr service, PluginTypeModel* parent); - - int rowCount() const; - - Qt::ItemFlags flags() const; - - BaseModel* childItem(const int row); - protected: - int findChild(BaseModel* model) const; - void redraw(const int width) const; - - const KService::Ptr m_service; - const KPluginInfo* m_info; - QList<ClassModel*> m_classes; -}; -} - -#endif diff --git a/sigtools/PluginTypeModel.cpp b/sigtools/PluginTypeModel.cpp deleted file mode 100644 index 7e8a4c40..00000000 --- a/sigtools/PluginTypeModel.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright 2009 Ben Boeckel <MathStuf@gmail.com> - * - * 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 3 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, see <http://www.gnu.org/licenses/>. - */ - -// Header include -#include "PluginTypeModel.h" - -// Sigtools includes -#include "PluginModel.h" -#include "RootPluginModel.h" - -// KDE includes -#include <KColorScheme> -#include <KGlobalSettings> - -// Qt includes -#include <QtCore/QSize> -#include <QtGui/QFontMetrics> -#include <QtGui/QPainter> - -using namespace Sigtools; - -PluginTypeModel::PluginTypeModel(const QString& type, RootPluginModel* parent) : - BaseModel(parent), - m_type(type) -{ -} - -int PluginTypeModel::rowCount() const -{ - return m_plugins.size(); -} - -Qt::ItemFlags PluginTypeModel::flags() const -{ - return Qt::ItemIsEnabled; -} - -BaseModel* PluginTypeModel::childItem(const int row) -{ - if ((0 <= row) && (row < m_plugins.size())) - return m_plugins[row]; - return NULL; -} - -void PluginTypeModel::addPlugin(KService::Ptr service) -{ - m_plugins.append(new PluginModel(service, this)); -} - -int PluginTypeModel::findChild(BaseModel* model) const -{ - return m_plugins.indexOf(qobject_cast<PluginModel*>(model)); -} - -void PluginTypeModel::redraw(const int width) const -{ - QSize typeSize = QFontMetrics(KGlobalSettings::generalFont()).size(0, m_type) + QSize(2 * borderWidth, 2 * borderWidth); - m_pixmap = QPixmap(qMax(width, typeSize.width()) + 2 * borderWidth, typeSize.height() + 2 * borderWidth); - m_pixmap.fill(KStatefulBrush(KColorScheme::View, KColorScheme::NormalBackground).brush(QPalette::Normal).color()); - QPainter painter(&m_pixmap); - - painter.drawText(QRect(QPoint(borderWidth, borderWidth), typeSize), m_type); -} diff --git a/sigtools/PluginTypeModel.h b/sigtools/PluginTypeModel.h deleted file mode 100644 index 9caff55a..00000000 --- a/sigtools/PluginTypeModel.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2009 Ben Boeckel <MathStuf@gmail.com> - * - * 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 3 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, see <http://www.gnu.org/licenses/>. - */ - -#ifndef SIGTOOLS_PLUGINTYPEMODEL -#define SIGTOOLS_PLUGINTYPEMODEL - -// Sigtools includes -#include "BaseModel.h" - -// KDE includes -#include <KService> - -namespace Sigtools -{ -// Forward declarations -class PluginModel; -class RootPluginModel; - -class SIGTOOLS_NO_EXPORT PluginTypeModel : public BaseModel -{ - Q_OBJECT - - public: - PluginTypeModel(const QString& type, RootPluginModel* parent); - - int rowCount() const; - - Qt::ItemFlags flags() const; - - BaseModel* childItem(const int row); - - void addPlugin(KService::Ptr service); - protected: - int findChild(BaseModel* model) const; - void redraw(const int width) const; - - const QString m_type; - QList<PluginModel*> m_plugins; -}; -} - -#endif diff --git a/sigtools/RootPluginModel.cpp b/sigtools/RootPluginModel.cpp deleted file mode 100644 index 0722b58a..00000000 --- a/sigtools/RootPluginModel.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright 2009 Ben Boeckel <MathStuf@gmail.com> - * - * 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 3 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, see <http://www.gnu.org/licenses/>. - */ - -// Header include -#include "RootPluginModel.h" - -// Sigtools includes -#include "PluginTypeModel.h" - -// Qt includes -#include <QtCore/QSize> - -using namespace Sigtools; - -RootPluginModel::RootPluginModel() : - BaseModel(NULL) -{ -} - -int RootPluginModel::rowCount() const -{ - return m_types.size(); -} - -Qt::ItemFlags RootPluginModel::flags() const -{ - return Qt::ItemIsEnabled; -} - -BaseModel* RootPluginModel::childItem(const int row) -{ - if ((0 <= row) && (row < m_types.size())) - return m_types.values()[row]; - return NULL; -} - -void RootPluginModel::addPlugin(const QString& type, KService::Ptr service) -{ - if (!m_types.contains(type)) - m_types[type] = new PluginTypeModel(type, this); - m_types[type]->addPlugin(service); -} - -int RootPluginModel::findChild(BaseModel* model) const -{ - return m_types.values().indexOf(qobject_cast<PluginTypeModel*>(model)); -} - -void RootPluginModel::redraw(const int width) const -{ - Q_UNUSED(width) -} diff --git a/sigtools/RootPluginModel.h b/sigtools/RootPluginModel.h deleted file mode 100644 index ea170aa1..00000000 --- a/sigtools/RootPluginModel.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2009 Ben Boeckel <MathStuf@gmail.com> - * - * 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 3 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, see <http://www.gnu.org/licenses/>. - */ - -#ifndef SIGTOOLS_ROOTPLUGINMODEL -#define SIGTOOLS_ROOTPLUGINMODEL - -// Sigtools includes -#include "BaseModel.h" - -// KDE includes -#include <KService> - -namespace Sigtools -{ -// Forward declarations -class PluginTypeModel; - -class SIGTOOLS_NO_EXPORT RootPluginModel : public BaseModel -{ - Q_OBJECT - - public: - RootPluginModel(); - - int rowCount() const; - - Qt::ItemFlags flags() const; - - BaseModel* childItem(const int row); - - void addPlugin(const QString& type, KService::Ptr service); - protected: - int findChild(BaseModel* model) const; - void redraw(const int width) const; - - QMap<QString, PluginTypeModel*> m_types; -}; -} - -#endif |