/* * Copyright 2008-2009 Ben Boeckel * * 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 . */ #ifndef SIGMODRTREE_BASEMODEL #define SIGMODRTREE_BASEMODEL // Sigmodr tree includes #include "Global.h" // Qt includes #include #include // Forward declarations class KMenu; class KUrl; class QDomDocument; namespace Sigmod { class Object; } namespace Sigmodr { namespace Tree { class SIGMODRTREE_NO_EXPORT BaseModel : public QObject { Q_OBJECT public: BaseModel(BaseModel* parent, Sigmod::Object* object, const QString& name = ""); virtual ~BaseModel(); BaseModel* parent(); virtual QVariant data(const int role = Qt::DisplayRole) const; virtual int rowCount() const = 0; virtual Qt::ItemFlags flags() const = 0; virtual bool setData(const QVariant& value, const int role = Qt::EditRole) = 0; virtual BaseModel* childItem(const int row) = 0; int indexNumber() const; virtual Qt::DropActions supportedDragActions() const = 0; virtual Qt::DropActions supportedDropActions() const = 0; virtual QString type() const; virtual QString types() const = 0; const Sigmod::Object* object() const; bool loadFromData(const QString& data, QDomDocument* xml) const; static const int TypeRole; static const int DropAcceptRole; static const int XmlRole; static const int WidgetRole; static const int ContextMenuRole; signals: void rowChanged(const int row); void rowsChanged(const QList& rows); protected: virtual int findChild(BaseModel* model) const = 0; BaseModel* m_parent; Sigmod::Object* m_object; QString m_name; protected slots: void childRowChanged(const int row); void childRowsChanged(const QList& rows); }; } } Q_DECLARE_METATYPE(KMenu*) #endif