introduce longString

actorid
Marek Kochanowicz 11 years ago
parent cc96a38921
commit 089732419a

@ -28,6 +28,7 @@ namespace CSMWorld
{
Display_None, //Do not use
Display_String,
Display_LongString,
//CONCRETE TYPES STARTS HERE
Display_Skill,

@ -202,7 +202,7 @@ namespace CSMWorld
struct DescriptionColumn : public Column<ESXRecordT>
{
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
@ -1380,7 +1380,7 @@ namespace CSMWorld
template<typename 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
{

@ -13,6 +13,10 @@
#include <QLineEdit>
#include <QEvent>
#include <QDataWidgetMapper>
#include <QCheckBox>
#include <QLineEdit>
#include <QPlainTextEdit>
#include <QComboBox>
#include "../../model/world/columnbase.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)
{
bool hasEnums = CSMWorld::Columns::hasEnums(static_cast<CSMWorld::Columns::ColumnId>(mTable->getColumnId(index.column() ) ) );
QVariant variant = index.data();
if (!variant.isValid())
{
variant = index.data(Qt::DisplayRole);
if (!variant.isValid())
{
return 0;
return NULL;
}
}
QWidget* editor = NULL;
std::map<int, CommandDelegate*>::iterator delegateIt(mDelegates.find(display));
if (delegateIt != mDelegates.end())
{
editor = delegateIt->second->createEditor(dynamic_cast<QWidget*>(mParent), QStyleOptionViewItem(), index, display);
DialogueDelegateDispatcherProxy* proxy = new DialogueDelegateDispatcherProxy(editor, display);
if (hasEnums) //combox is used for all enums
{
connect(editor, SIGNAL(currentIndexChanged (int)), proxy, SLOT(editorDataCommited()));
} else
{
connect(editor, SIGNAL(editingFinished()), proxy, SLOT(editorDataCommited()));
}
bool skip = false;
if (qobject_cast<QLineEdit*>(editor))
{
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)));
mProxys.push_back(proxy); //deleted in the destructor
}

@ -9,6 +9,7 @@
#include <QUndoStack>
#include "../../model/world/commands.hpp"
#include <iostream>
void CSVWorld::EnumDelegate::setModelDataImp (QWidget *editor, QAbstractItemModel *model,
const QModelIndex& index) const

@ -11,6 +11,7 @@
#include <QDoubleSpinBox>
#include <QComboBox>
#include <QCheckBox>
#include <QPlainTextEdit>
#include "../../model/world/commands.hpp"
#include <iostream>
@ -155,7 +156,11 @@ QWidget *CSVWorld::CommandDelegate::createEditor (QWidget *parent, const QStyleO
{
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);
}
@ -185,7 +190,7 @@ bool CSVWorld::CommandDelegate::updateEditorSetting (const QString &settingName,
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);
if (tryDisplay)
@ -198,7 +203,16 @@ void CSVWorld::CommandDelegate::setEditorData (QWidget *editor, const QModelInde
return;
}
}
QPlainTextEdit* plainTextEdit = qobject_cast<QPlainTextEdit*>(editor);
if(plainTextEdit)
{
if(plainTextEdit->toPlainText() == v.toString())
{
return;
}
}
}
QByteArray n = editor->metaObject()->userProperty().name();
if (n == "dateTime") {
@ -213,4 +227,5 @@ void CSVWorld::CommandDelegate::setEditorData (QWidget *editor, const QModelInde
v = QVariant(editor->property(n).userType(), (const void *)0);
editor->setProperty(n, v);
}
}

@ -113,7 +113,7 @@ namespace CSVWorld
virtual bool updateEditorSetting (const QString &settingName, const QString &settingValue);
///< \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:

Loading…
Cancel
Save