2015-03-30 05:41:55 +00:00
|
|
|
#ifndef CSM_WOLRD_NESTEDTABLEPROXYMODEL_H
|
|
|
|
#define CSM_WOLRD_NESTEDTABLEPROXYMODEL_H
|
2014-06-18 13:35:31 +00:00
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include <QAbstractProxyModel>
|
|
|
|
|
|
|
|
#include "universalid.hpp"
|
|
|
|
#include "columns.hpp"
|
|
|
|
#include "columnbase.hpp"
|
|
|
|
|
|
|
|
/*! \brief
|
|
|
|
* Proxy model used to connect view in the dialogue into the nested columns of the main model.
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace CSMWorld
|
|
|
|
{
|
|
|
|
class CollectionBase;
|
2015-04-09 11:23:02 +00:00
|
|
|
struct RecordBase;
|
2015-04-02 09:19:15 +00:00
|
|
|
class IdTree;
|
2014-06-18 13:35:31 +00:00
|
|
|
|
2015-03-30 05:41:55 +00:00
|
|
|
class NestedTableProxyModel : public QAbstractProxyModel
|
2014-06-18 13:35:31 +00:00
|
|
|
{
|
2014-07-02 11:13:03 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
2014-06-18 13:35:31 +00:00
|
|
|
const int mParentColumn;
|
2015-04-02 09:19:15 +00:00
|
|
|
IdTree* mMainModel;
|
2014-06-18 13:35:31 +00:00
|
|
|
std::string mId;
|
2014-06-18 14:53:46 +00:00
|
|
|
|
2015-04-09 09:33:42 +00:00
|
|
|
public:
|
2015-03-30 05:41:55 +00:00
|
|
|
NestedTableProxyModel(const QModelIndex& parent,
|
2014-06-18 13:35:31 +00:00
|
|
|
ColumnBase::Display displayType,
|
2015-04-02 09:19:15 +00:00
|
|
|
IdTree* parentModel);
|
2014-06-18 13:35:31 +00:00
|
|
|
//parent is the parent of columns to work with. Columnid provides information about the column
|
2014-06-18 14:53:46 +00:00
|
|
|
|
2014-07-01 18:52:27 +00:00
|
|
|
std::string getParentId() const;
|
2015-03-30 05:41:55 +00:00
|
|
|
|
2014-07-01 18:52:27 +00:00
|
|
|
int getParentColumn() const;
|
2015-03-30 05:41:55 +00:00
|
|
|
|
2015-04-02 09:19:15 +00:00
|
|
|
CSMWorld::IdTree* model() const;
|
2014-07-01 18:52:27 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
QModelIndex mapFromSource(const QModelIndex& sourceIndex) const override;
|
2014-06-18 14:53:46 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
QModelIndex mapToSource(const QModelIndex& proxyIndex) const override;
|
2014-06-18 14:53:46 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
int rowCount(const QModelIndex& parent) const override;
|
2014-06-18 14:53:46 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
int columnCount(const QModelIndex& parent) const override;
|
2014-06-18 14:53:46 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const override;
|
2014-06-18 14:53:46 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
QModelIndex parent(const QModelIndex& index) const override;
|
2014-06-18 15:34:21 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
QVariant headerData (int section, Qt::Orientation orientation, int role) const override;
|
2015-03-30 05:41:55 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const override;
|
2015-04-11 01:27:48 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
bool setData (const QModelIndex & index, const QVariant & value, int role = Qt::EditRole) override;
|
2015-03-30 05:41:55 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
Qt::ItemFlags flags(const QModelIndex& index) const override;
|
2015-03-30 05:41:55 +00:00
|
|
|
|
2014-06-18 15:34:21 +00:00
|
|
|
private:
|
|
|
|
void setupHeaderVectors(ColumnBase::Display columnId);
|
2014-07-02 11:13:03 +00:00
|
|
|
|
|
|
|
bool indexIsParent(const QModelIndex& index);
|
2015-03-30 05:41:55 +00:00
|
|
|
|
2014-07-02 11:13:03 +00:00
|
|
|
private slots:
|
|
|
|
void forwardRowsAboutToInserted(const QModelIndex & parent, int first, int last);
|
2015-03-30 05:41:55 +00:00
|
|
|
|
2014-07-02 11:13:03 +00:00
|
|
|
void forwardRowsInserted(const QModelIndex & parent, int first, int last);
|
2014-07-02 11:29:25 +00:00
|
|
|
|
|
|
|
void forwardRowsAboutToRemoved(const QModelIndex & parent, int first, int last);
|
|
|
|
|
|
|
|
void forwardRowsRemoved(const QModelIndex & parent, int first, int last);
|
2015-03-30 05:41:55 +00:00
|
|
|
|
2014-07-20 20:39:39 +00:00
|
|
|
void forwardResetStart(const QString& id);
|
2015-03-30 05:41:55 +00:00
|
|
|
|
2014-07-20 20:39:39 +00:00
|
|
|
void forwardResetEnd(const QString& id);
|
2015-04-16 15:27:36 +00:00
|
|
|
|
|
|
|
void forwardDataChanged (const QModelIndex& topLeft, const QModelIndex& bottomRight);
|
2014-06-18 13:35:31 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|