forked from teamnwah/openmw-tes3coop
Nested model supports editing now.
This commit is contained in:
parent
5eac32e3d3
commit
c96d48fb91
3 changed files with 27 additions and 3 deletions
|
@ -80,3 +80,14 @@ QVariant CSMWorld::NestedTableModel::headerData(int section,
|
|||
{
|
||||
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));
|
||||
}
|
||||
|
|
|
@ -45,6 +45,10 @@ namespace CSMWorld
|
|||
|
||||
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:
|
||||
void setupHeaderVectors(ColumnBase::Display columnId);
|
||||
};
|
||||
|
|
|
@ -3,13 +3,19 @@
|
|||
#include "../../model/world/universalid.hpp"
|
||||
#include "util.hpp"
|
||||
|
||||
#include <QHeaderView>
|
||||
|
||||
CSVWorld::NestedTable::NestedTable(QUndoStack& undoStack,
|
||||
CSMWorld::NestedTableModel* model,
|
||||
QWidget* parent)
|
||||
: QTableView(parent)
|
||||
{
|
||||
setModel(model);
|
||||
setAcceptDrops(true);
|
||||
|
||||
setSelectionBehavior (QAbstractItemView::SelectRows);
|
||||
setSelectionMode (QAbstractItemView::ExtendedSelection);
|
||||
|
||||
horizontalHeader()->setResizeMode (QHeaderView::Interactive);
|
||||
verticalHeader()->hide();
|
||||
|
||||
int columns = model->columnCount(QModelIndex());
|
||||
|
||||
|
@ -17,13 +23,16 @@ CSVWorld::NestedTable::NestedTable(QUndoStack& undoStack,
|
|||
{
|
||||
CSMWorld::ColumnBase::Display display = static_cast<CSMWorld::ColumnBase::Display> (
|
||||
model->headerData (i, Qt::Horizontal, CSMWorld::ColumnBase::Role_Display).toInt());
|
||||
|
||||
|
||||
CommandDelegate *delegate = CommandDelegateFactoryCollection::get().makeDelegate(display,
|
||||
undoStack,
|
||||
this);
|
||||
|
||||
setItemDelegateForColumn(i, delegate);
|
||||
}
|
||||
|
||||
setModel(model);
|
||||
setAcceptDrops(true);
|
||||
}
|
||||
|
||||
void CSVWorld::NestedTable::dragEnterEvent(QDragEnterEvent *event)
|
||||
|
|
Loading…
Reference in a new issue