mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-21 09:53:50 +00:00
introduce longString
This commit is contained in:
parent
cc96a38921
commit
089732419a
6 changed files with 51 additions and 14 deletions
|
@ -28,6 +28,7 @@ namespace CSMWorld
|
||||||
{
|
{
|
||||||
Display_None, //Do not use
|
Display_None, //Do not use
|
||||||
Display_String,
|
Display_String,
|
||||||
|
Display_LongString,
|
||||||
|
|
||||||
//CONCRETE TYPES STARTS HERE
|
//CONCRETE TYPES STARTS HERE
|
||||||
Display_Skill,
|
Display_Skill,
|
||||||
|
|
|
@ -202,7 +202,7 @@ namespace CSMWorld
|
||||||
struct DescriptionColumn : public Column<ESXRecordT>
|
struct DescriptionColumn : public Column<ESXRecordT>
|
||||||
{
|
{
|
||||||
DescriptionColumn()
|
DescriptionColumn()
|
||||||
: Column<ESXRecordT> (Columns::ColumnId_Description, ColumnBase::Display_String)
|
: Column<ESXRecordT> (Columns::ColumnId_Description, ColumnBase::Display_LongString)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
virtual QVariant get (const Record<ESXRecordT>& record) const
|
virtual QVariant get (const Record<ESXRecordT>& record) const
|
||||||
|
@ -1380,7 +1380,7 @@ namespace CSMWorld
|
||||||
template<typename ESXRecordT>
|
template<typename ESXRecordT>
|
||||||
struct QuestDescriptionColumn : public Column<ESXRecordT>
|
struct QuestDescriptionColumn : public Column<ESXRecordT>
|
||||||
{
|
{
|
||||||
QuestDescriptionColumn() : Column<ESXRecordT> (Columns::ColumnId_QuestDescription, ColumnBase::Display_String) {}
|
QuestDescriptionColumn() : Column<ESXRecordT> (Columns::ColumnId_QuestDescription, ColumnBase::Display_LongString) {}
|
||||||
|
|
||||||
virtual QVariant get (const Record<ESXRecordT>& record) const
|
virtual QVariant get (const Record<ESXRecordT>& record) const
|
||||||
{
|
{
|
||||||
|
|
|
@ -13,6 +13,10 @@
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QEvent>
|
#include <QEvent>
|
||||||
#include <QDataWidgetMapper>
|
#include <QDataWidgetMapper>
|
||||||
|
#include <QCheckBox>
|
||||||
|
#include <QLineEdit>
|
||||||
|
#include <QPlainTextEdit>
|
||||||
|
#include <QComboBox>
|
||||||
|
|
||||||
#include "../../model/world/columnbase.hpp"
|
#include "../../model/world/columnbase.hpp"
|
||||||
#include "../../model/world/idtable.hpp"
|
#include "../../model/world/idtable.hpp"
|
||||||
|
@ -126,30 +130,46 @@ 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() ) ) );
|
|
||||||
QVariant variant = index.data();
|
QVariant variant = index.data();
|
||||||
if (!variant.isValid())
|
if (!variant.isValid())
|
||||||
{
|
{
|
||||||
variant = index.data(Qt::DisplayRole);
|
variant = index.data(Qt::DisplayRole);
|
||||||
if (!variant.isValid())
|
if (!variant.isValid())
|
||||||
{
|
{
|
||||||
return 0;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QWidget* editor = NULL;
|
QWidget* editor = NULL;
|
||||||
std::map<int, CommandDelegate*>::iterator delegateIt(mDelegates.find(display));
|
std::map<int, CommandDelegate*>::iterator delegateIt(mDelegates.find(display));
|
||||||
if (delegateIt != mDelegates.end())
|
if (delegateIt != mDelegates.end())
|
||||||
{
|
{
|
||||||
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 (hasEnums) //combox is used for all enums
|
|
||||||
{
|
bool skip = false;
|
||||||
connect(editor, SIGNAL(currentIndexChanged (int)), proxy, SLOT(editorDataCommited()));
|
if (qobject_cast<QLineEdit*>(editor))
|
||||||
} else
|
{
|
||||||
{
|
connect(editor, SIGNAL(editingFinished()), proxy, SLOT(editorDataCommited()));
|
||||||
connect(editor, SIGNAL(editingFinished()), proxy, SLOT(editorDataCommited()));
|
skip = true;
|
||||||
}
|
}
|
||||||
|
if(!skip && qobject_cast<QCheckBox*>(editor))
|
||||||
|
{
|
||||||
|
connect(editor, SIGNAL(stateChanged(int)), proxy, SLOT(editorDataCommited()));
|
||||||
|
skip = true;
|
||||||
|
}
|
||||||
|
if(!skip && qobject_cast<QPlainTextEdit*>(editor))
|
||||||
|
{
|
||||||
|
connect(editor, SIGNAL(textChanged()), proxy, SLOT(editorDataCommited()));
|
||||||
|
skip = true;
|
||||||
|
}
|
||||||
|
if(!skip && qobject_cast<QComboBox*>(editor))
|
||||||
|
{
|
||||||
|
connect(editor, SIGNAL(currentIndexChanged (int)), proxy, SLOT(editorDataCommited()));
|
||||||
|
skip = true;
|
||||||
|
}
|
||||||
|
|
||||||
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
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include <QUndoStack>
|
#include <QUndoStack>
|
||||||
|
|
||||||
#include "../../model/world/commands.hpp"
|
#include "../../model/world/commands.hpp"
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
void CSVWorld::EnumDelegate::setModelDataImp (QWidget *editor, QAbstractItemModel *model,
|
void CSVWorld::EnumDelegate::setModelDataImp (QWidget *editor, QAbstractItemModel *model,
|
||||||
const QModelIndex& index) const
|
const QModelIndex& index) const
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include <QDoubleSpinBox>
|
#include <QDoubleSpinBox>
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
|
#include <QPlainTextEdit>
|
||||||
|
|
||||||
#include "../../model/world/commands.hpp"
|
#include "../../model/world/commands.hpp"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
@ -155,7 +156,11 @@ QWidget *CSVWorld::CommandDelegate::createEditor (QWidget *parent, const QStyleO
|
||||||
{
|
{
|
||||||
return new QDoubleSpinBox(parent);
|
return new QDoubleSpinBox(parent);
|
||||||
}
|
}
|
||||||
if (display == CSMWorld::ColumnBase::Display_String)
|
if (display == CSMWorld::ColumnBase::Display_LongString)
|
||||||
|
{
|
||||||
|
return new QTextEdit(parent);
|
||||||
|
}
|
||||||
|
if (display == CSMWorld::ColumnBase::Display_String || display == CSMWorld::ColumnBase::Display_Skill)
|
||||||
{
|
{
|
||||||
return new QLineEdit(parent);
|
return new QLineEdit(parent);
|
||||||
}
|
}
|
||||||
|
@ -185,7 +190,7 @@ bool CSVWorld::CommandDelegate::updateEditorSetting (const QString &settingName,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVWorld::CommandDelegate::setEditorData (QWidget *editor, const QModelIndex& index, bool tryDisplay) const
|
void CSVWorld::CommandDelegate::setEditorData (QWidget *editor, const QModelIndex& index, bool tryDisplay)
|
||||||
{
|
{
|
||||||
QVariant v = index.data(Qt::EditRole);
|
QVariant v = index.data(Qt::EditRole);
|
||||||
if (tryDisplay)
|
if (tryDisplay)
|
||||||
|
@ -198,7 +203,16 @@ void CSVWorld::CommandDelegate::setEditorData (QWidget *editor, const QModelInde
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
QPlainTextEdit* plainTextEdit = qobject_cast<QPlainTextEdit*>(editor);
|
||||||
|
if(plainTextEdit)
|
||||||
|
{
|
||||||
|
if(plainTextEdit->toPlainText() == v.toString())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray n = editor->metaObject()->userProperty().name();
|
QByteArray n = editor->metaObject()->userProperty().name();
|
||||||
|
|
||||||
if (n == "dateTime") {
|
if (n == "dateTime") {
|
||||||
|
@ -213,4 +227,5 @@ void CSVWorld::CommandDelegate::setEditorData (QWidget *editor, const QModelInde
|
||||||
v = QVariant(editor->property(n).userType(), (const void *)0);
|
v = QVariant(editor->property(n).userType(), (const void *)0);
|
||||||
editor->setProperty(n, v);
|
editor->setProperty(n, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -113,7 +113,7 @@ namespace CSVWorld
|
||||||
virtual bool updateEditorSetting (const QString &settingName, const QString &settingValue);
|
virtual bool updateEditorSetting (const QString &settingName, const QString &settingValue);
|
||||||
///< \return Does column require update?
|
///< \return Does column require update?
|
||||||
|
|
||||||
virtual void setEditorData (QWidget *editor, const QModelIndex& index, bool tryDisplay = false) const;
|
virtual void setEditorData (QWidget *editor, const QModelIndex& index, bool tryDisplay = false);
|
||||||
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
Loading…
Reference in a new issue