mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-03-13 07:14:31 +00:00
handle color
This commit is contained in:
parent
73cb3ac0ed
commit
874847c959
@ -127,9 +127,14 @@ QSize CSVWorld::DialogueDelegateDispatcher::sizeHint (const QStyleOptionViewItem
|
|||||||
QWidget* CSVWorld::DialogueDelegateDispatcher::makeEditor(CSMWorld::ColumnBase::Display display, const QModelIndex& index)
|
QWidget* CSVWorld::DialogueDelegateDispatcher::makeEditor(CSMWorld::ColumnBase::Display display, const QModelIndex& index)
|
||||||
{
|
{
|
||||||
bool hasEnums = CSMWorld::Columns::hasEnums(static_cast<CSMWorld::Columns::ColumnId>(mTable->getColumnId(index.column() ) ) );
|
bool hasEnums = CSMWorld::Columns::hasEnums(static_cast<CSMWorld::Columns::ColumnId>(mTable->getColumnId(index.column() ) ) );
|
||||||
if (display == CSMWorld::ColumnBase::Display_Boolean)
|
QVariant variant = index.data();
|
||||||
|
if (!variant.isValid())
|
||||||
{
|
{
|
||||||
hasEnums = true;
|
variant = index.data(Qt::DisplayRole);
|
||||||
|
if (!variant.isValid())
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget* editor = NULL;
|
QWidget* editor = NULL;
|
||||||
@ -138,11 +143,6 @@ QWidget* CSVWorld::DialogueDelegateDispatcher::makeEditor(CSMWorld::ColumnBase::
|
|||||||
{
|
{
|
||||||
editor = delegateIt->second->createEditor(dynamic_cast<QWidget*>(mParent), QStyleOptionViewItem(), index, display);
|
editor = delegateIt->second->createEditor(dynamic_cast<QWidget*>(mParent), QStyleOptionViewItem(), index, display);
|
||||||
DialogueDelegateDispatcherProxy* proxy = new DialogueDelegateDispatcherProxy(editor, display);
|
DialogueDelegateDispatcherProxy* proxy = new DialogueDelegateDispatcherProxy(editor, display);
|
||||||
if (display == CSMWorld::ColumnBase::Display_Boolean)
|
|
||||||
{
|
|
||||||
connect(editor, SIGNAL(stateChanged(int)), proxy, SLOT(editorDataCommited()));
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
if (hasEnums) //combox is used for all enums
|
if (hasEnums) //combox is used for all enums
|
||||||
{
|
{
|
||||||
connect(editor, SIGNAL(currentIndexChanged (int)), proxy, SLOT(editorDataCommited()));
|
connect(editor, SIGNAL(currentIndexChanged (int)), proxy, SLOT(editorDataCommited()));
|
||||||
@ -150,7 +150,6 @@ QWidget* CSVWorld::DialogueDelegateDispatcher::makeEditor(CSMWorld::ColumnBase::
|
|||||||
{
|
{
|
||||||
connect(editor, SIGNAL(editingFinished()), proxy, SLOT(editorDataCommited()));
|
connect(editor, SIGNAL(editingFinished()), proxy, SLOT(editorDataCommited()));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
connect(proxy, SIGNAL(editorDataCommited(QWidget*, const QModelIndex&, CSMWorld::ColumnBase::Display)), this, SLOT(editorDataCommited(QWidget*, const QModelIndex&, CSMWorld::ColumnBase::Display)));
|
connect(proxy, SIGNAL(editorDataCommited(QWidget*, const QModelIndex&, CSMWorld::ColumnBase::Display)), this, SLOT(editorDataCommited(QWidget*, const QModelIndex&, CSMWorld::ColumnBase::Display)));
|
||||||
mProxys.push_back(proxy); //deleted in the destructor
|
mProxys.push_back(proxy); //deleted in the destructor
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
|
|
||||||
#include "../../model/world/commands.hpp"
|
#include "../../model/world/commands.hpp"
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
CSVWorld::NastyTableModelHack::NastyTableModelHack (QAbstractItemModel& model)
|
CSVWorld::NastyTableModelHack::NastyTableModelHack (QAbstractItemModel& model)
|
||||||
: mModel (model)
|
: mModel (model)
|
||||||
@ -126,18 +127,27 @@ void CSVWorld::CommandDelegate::setModelData (QWidget *editor, QAbstractItemMode
|
|||||||
QWidget *CSVWorld::CommandDelegate::createEditor (QWidget *parent, const QStyleOptionViewItem& option,
|
QWidget *CSVWorld::CommandDelegate::createEditor (QWidget *parent, const QStyleOptionViewItem& option,
|
||||||
const QModelIndex& index, CSMWorld::ColumnBase::Display display) const
|
const QModelIndex& index, CSMWorld::ColumnBase::Display display) const
|
||||||
{
|
{
|
||||||
if (!(index.data(Qt::EditRole).isValid() or index.data(Qt::DisplayRole).isValid()))
|
QVariant variant = index.data();
|
||||||
|
if (!variant.isValid())
|
||||||
|
{
|
||||||
|
variant = index.data(Qt::DisplayRole);
|
||||||
|
if (!variant.isValid())
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (display != CSMWorld::ColumnBase::Display_None)
|
if (display != CSMWorld::ColumnBase::Display_None)
|
||||||
{
|
{
|
||||||
|
if (variant.type() == QVariant::Color)
|
||||||
|
{
|
||||||
|
return new QLineEdit(parent);
|
||||||
|
}
|
||||||
if (display == CSMWorld::ColumnBase::Display_Integer)
|
if (display == CSMWorld::ColumnBase::Display_Integer)
|
||||||
{
|
{
|
||||||
return new QSpinBox(parent);
|
return new QSpinBox(parent);
|
||||||
}
|
}
|
||||||
if (display == CSMWorld::ColumnBase::Display_Integer)
|
if (display == CSMWorld::ColumnBase::Display_Float)
|
||||||
{
|
{
|
||||||
return new QDoubleSpinBox(parent);
|
return new QDoubleSpinBox(parent);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user