mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-15 18:39:51 +00:00
some dialogue subview cleanup and start of command dispatching refactoring
This commit is contained in:
parent
7ede6573eb
commit
48468b7d0c
@ -332,6 +332,7 @@ void CSVWorld::EditWidget::remake(int row)
|
|||||||
if (mMainWidget)
|
if (mMainWidget)
|
||||||
{
|
{
|
||||||
delete mMainWidget;
|
delete mMainWidget;
|
||||||
|
mMainWidget = 0;
|
||||||
}
|
}
|
||||||
mMainWidget = new QWidget (this);
|
mMainWidget = new QWidget (this);
|
||||||
|
|
||||||
@ -339,6 +340,7 @@ void CSVWorld::EditWidget::remake(int row)
|
|||||||
if (mWidgetMapper)
|
if (mWidgetMapper)
|
||||||
{
|
{
|
||||||
delete mWidgetMapper;
|
delete mWidgetMapper;
|
||||||
|
mWidgetMapper = 0;
|
||||||
}
|
}
|
||||||
mWidgetMapper = new QDataWidgetMapper (this);
|
mWidgetMapper = new QDataWidgetMapper (this);
|
||||||
mWidgetMapper->setModel(mTable);
|
mWidgetMapper->setModel(mTable);
|
||||||
@ -396,7 +398,7 @@ void CSVWorld::EditWidget::remake(int row)
|
|||||||
|
|
||||||
mWidgetMapper->setCurrentModelIndex(mTable->index(row, 0));
|
mWidgetMapper->setCurrentModelIndex(mTable->index(row, 0));
|
||||||
|
|
||||||
this->setMinimumWidth(325); //TODO find better way to set the width or make it customizable
|
this->setMinimumWidth(325); /// \todo replace hardcoded value with a user setting
|
||||||
this->setWidget(mMainWidget);
|
this->setWidget(mMainWidget);
|
||||||
this->setWidgetResizable(true);
|
this->setWidgetResizable(true);
|
||||||
}
|
}
|
||||||
@ -407,7 +409,6 @@ void CSVWorld::EditWidget::remake(int row)
|
|||||||
|
|
||||||
CSVWorld::DialogueSubView::DialogueSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document,
|
CSVWorld::DialogueSubView::DialogueSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document,
|
||||||
const CreatorFactoryBase& creatorFactory, bool sorting) :
|
const CreatorFactoryBase& creatorFactory, bool sorting) :
|
||||||
|
|
||||||
SubView (id),
|
SubView (id),
|
||||||
mEditWidget(0),
|
mEditWidget(0),
|
||||||
mMainLayout(NULL),
|
mMainLayout(NULL),
|
||||||
@ -415,8 +416,8 @@ CSVWorld::DialogueSubView::DialogueSubView (const CSMWorld::UniversalId& id, CSM
|
|||||||
mTable(dynamic_cast<CSMWorld::IdTable*>(document.getData().getTableModel(id))),
|
mTable(dynamic_cast<CSMWorld::IdTable*>(document.getData().getTableModel(id))),
|
||||||
mRow (-1),
|
mRow (-1),
|
||||||
mLocked(false),
|
mLocked(false),
|
||||||
mDocument(document)
|
mDocument(document),
|
||||||
|
mCommandDispatcher (document, CSMWorld::UniversalId::getParentType (id.getType()))
|
||||||
{
|
{
|
||||||
connect(mTable, SIGNAL(dataChanged (const QModelIndex&, const QModelIndex&)), this, SLOT(dataChanged(const QModelIndex&)));
|
connect(mTable, SIGNAL(dataChanged (const QModelIndex&, const QModelIndex&)), this, SLOT(dataChanged(const QModelIndex&)));
|
||||||
mRow = mTable->getModelIndex (id.getId(), 0).row();
|
mRow = mTable->getModelIndex (id.getId(), 0).row();
|
||||||
@ -560,14 +561,12 @@ void CSVWorld::DialogueSubView::nextId()
|
|||||||
void CSVWorld::DialogueSubView::setEditLock (bool locked)
|
void CSVWorld::DialogueSubView::setEditLock (bool locked)
|
||||||
{
|
{
|
||||||
mLocked = locked;
|
mLocked = locked;
|
||||||
|
|
||||||
CSMWorld::RecordBase::State state = static_cast<CSMWorld::RecordBase::State>(mTable->data (mTable->index (mRow, 1)).toInt());
|
CSMWorld::RecordBase::State state = static_cast<CSMWorld::RecordBase::State>(mTable->data (mTable->index (mRow, 1)).toInt());
|
||||||
if (state == CSMWorld::RecordBase::State_Deleted || state == CSMWorld::RecordBase::State_Erased)
|
|
||||||
{
|
mEditWidget->setDisabled (state==CSMWorld::RecordBase::State_Deleted || locked);
|
||||||
mEditWidget->setDisabled(true);
|
|
||||||
} else
|
mCommandDispatcher.setEditLock (locked);
|
||||||
{
|
|
||||||
mEditWidget->setDisabled(mLocked);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVWorld::DialogueSubView::dataChanged(const QModelIndex & index)
|
void CSVWorld::DialogueSubView::dataChanged(const QModelIndex & index)
|
||||||
@ -575,13 +574,8 @@ void CSVWorld::DialogueSubView::dataChanged(const QModelIndex & index)
|
|||||||
if (index.row() == mRow)
|
if (index.row() == mRow)
|
||||||
{
|
{
|
||||||
CSMWorld::RecordBase::State state = static_cast<CSMWorld::RecordBase::State>(mTable->data (mTable->index (mRow, 1)).toInt());
|
CSMWorld::RecordBase::State state = static_cast<CSMWorld::RecordBase::State>(mTable->data (mTable->index (mRow, 1)).toInt());
|
||||||
if (state == CSMWorld::RecordBase::State_Deleted || state == CSMWorld::RecordBase::State_Erased)
|
|
||||||
{
|
mEditWidget->setDisabled (state==CSMWorld::RecordBase::State_Deleted || mLocked);
|
||||||
mEditWidget->setDisabled(true);
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
mEditWidget->setDisabled(mLocked);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,7 +8,9 @@
|
|||||||
#include <QScrollArea>
|
#include <QScrollArea>
|
||||||
|
|
||||||
#include "../doc/subview.hpp"
|
#include "../doc/subview.hpp"
|
||||||
|
|
||||||
#include "../../model/world/columnbase.hpp"
|
#include "../../model/world/columnbase.hpp"
|
||||||
|
#include "../../model/world/commanddispatcher.hpp"
|
||||||
|
|
||||||
class QDataWidgetMapper;
|
class QDataWidgetMapper;
|
||||||
class QSize;
|
class QSize;
|
||||||
@ -169,6 +171,7 @@ namespace CSVWorld
|
|||||||
bool mLocked;
|
bool mLocked;
|
||||||
const CSMDoc::Document& mDocument;
|
const CSMDoc::Document& mDocument;
|
||||||
TableBottomBox* mBottom;
|
TableBottomBox* mBottom;
|
||||||
|
CSMWorld::CommandDispatcher mCommandDispatcher;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user