mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-25 15:35:23 +00:00
CommandDelegate: extract a display type from a model if it isn't specified
This commit is contained in:
parent
2c4025ec72
commit
f84c36b500
@ -33,6 +33,9 @@ QVariant CSMWorld::IdTable::data (const QModelIndex & index, int role) const
|
||||
if (index.row() < 0 || index.column() < 0)
|
||||
return QVariant();
|
||||
|
||||
if (role==ColumnBase::Role_Display)
|
||||
return QVariant(mIdCollection->getColumn(index.column()).mDisplayType);
|
||||
|
||||
if (role==ColumnBase::Role_ColumnId)
|
||||
return QVariant (getColumnId (index.column()));
|
||||
|
||||
|
@ -40,6 +40,9 @@ QVariant CSMWorld::IdTree::data (const QModelIndex & index, int role) const
|
||||
std::pair<int, int> parentAddress(unfoldIndexAddress(index.internalId()));
|
||||
const NestableColumn *parentColumn = mNestedCollection->getNestableColumn(parentAddress.second);
|
||||
|
||||
if (role == ColumnBase::Role_Display)
|
||||
return parentColumn->nestedColumn(index.column()).mColumnId;
|
||||
|
||||
if (role == ColumnBase::Role_ColumnId)
|
||||
return parentColumn->nestedColumn(index.column()).mColumnId;
|
||||
|
||||
|
@ -111,6 +111,12 @@ CSMDoc::Document& CSVWorld::CommandDelegate::getDocument() const
|
||||
return mDocument;
|
||||
}
|
||||
|
||||
CSMWorld::ColumnBase::Display CSVWorld::CommandDelegate::getDisplayTypeFromIndex(const QModelIndex &index) const
|
||||
{
|
||||
int rawDisplay = index.data(CSMWorld::ColumnBase::Role_Display).toInt();
|
||||
return static_cast<CSMWorld::ColumnBase::Display>(rawDisplay);
|
||||
}
|
||||
|
||||
void CSVWorld::CommandDelegate::setModelDataImp (QWidget *editor, QAbstractItemModel *model,
|
||||
const QModelIndex& index) const
|
||||
{
|
||||
@ -146,7 +152,7 @@ void CSVWorld::CommandDelegate::setModelData (QWidget *editor, QAbstractItemMode
|
||||
QWidget *CSVWorld::CommandDelegate::createEditor (QWidget *parent, const QStyleOptionViewItem& option,
|
||||
const QModelIndex& index) const
|
||||
{
|
||||
return createEditor (parent, option, index, CSMWorld::ColumnBase::Display_None);
|
||||
return createEditor (parent, option, index, getDisplayTypeFromIndex(index));
|
||||
}
|
||||
|
||||
QWidget *CSVWorld::CommandDelegate::createEditor (QWidget *parent, const QStyleOptionViewItem& option,
|
||||
|
@ -124,6 +124,8 @@ namespace CSVWorld
|
||||
|
||||
CSMDoc::Document& getDocument() const;
|
||||
|
||||
CSMWorld::ColumnBase::Display getDisplayTypeFromIndex(const QModelIndex &index) const;
|
||||
|
||||
virtual void setModelDataImp (QWidget *editor, QAbstractItemModel *model,
|
||||
const QModelIndex& index) const;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user