1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-27 12:35:46 +00:00

Nested model supports editing now.

This commit is contained in:
Marek Kochanowicz 2014-06-30 14:12:57 +02:00
parent 5eac32e3d3
commit c96d48fb91
3 changed files with 27 additions and 3 deletions

View File

@ -80,3 +80,14 @@ QVariant CSMWorld::NestedTableModel::headerData(int section,
{ {
return mMainModel->nestedHeaderData(mParentColumn, section, orientation, role); return mMainModel->nestedHeaderData(mParentColumn, section, orientation, role);
} }
bool CSMWorld::NestedTableModel::setData ( const QModelIndex & index, const QVariant & value, int role)
{
return mMainModel->setData(mapToSource(index), value, role);
}
Qt::ItemFlags CSMWorld::NestedTableModel::flags(const QModelIndex& index) const
{
return mMainModel->flags(mMainModel->index(0, mParentColumn));
}

View File

@ -45,6 +45,10 @@ namespace CSMWorld
virtual QVariant headerData ( int section, Qt::Orientation orientation, int role ) const; virtual QVariant headerData ( int section, Qt::Orientation orientation, int role ) const;
virtual bool setData ( const QModelIndex & index, const QVariant & value, int role = Qt::EditRole );
virtual Qt::ItemFlags flags(const QModelIndex& index) const;
private: private:
void setupHeaderVectors(ColumnBase::Display columnId); void setupHeaderVectors(ColumnBase::Display columnId);
}; };

View File

@ -3,13 +3,19 @@
#include "../../model/world/universalid.hpp" #include "../../model/world/universalid.hpp"
#include "util.hpp" #include "util.hpp"
#include <QHeaderView>
CSVWorld::NestedTable::NestedTable(QUndoStack& undoStack, CSVWorld::NestedTable::NestedTable(QUndoStack& undoStack,
CSMWorld::NestedTableModel* model, CSMWorld::NestedTableModel* model,
QWidget* parent) QWidget* parent)
: QTableView(parent) : QTableView(parent)
{ {
setModel(model);
setAcceptDrops(true); setSelectionBehavior (QAbstractItemView::SelectRows);
setSelectionMode (QAbstractItemView::ExtendedSelection);
horizontalHeader()->setResizeMode (QHeaderView::Interactive);
verticalHeader()->hide();
int columns = model->columnCount(QModelIndex()); int columns = model->columnCount(QModelIndex());
@ -24,6 +30,9 @@ CSVWorld::NestedTable::NestedTable(QUndoStack& undoStack,
setItemDelegateForColumn(i, delegate); setItemDelegateForColumn(i, delegate);
} }
setModel(model);
setAcceptDrops(true);
} }
void CSVWorld::NestedTable::dragEnterEvent(QDragEnterEvent *event) void CSVWorld::NestedTable::dragEnterEvent(QDragEnterEvent *event)