mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 05:49:56 +00:00
refactoring dialogue subview
This commit is contained in:
parent
7eb82f74ae
commit
786c68f09a
2 changed files with 19 additions and 4 deletions
|
@ -448,7 +448,9 @@ CSVWorld::DialogueSubView::DialogueSubView (const CSMWorld::UniversalId& id, CSM
|
||||||
mCommandDispatcher (document, CSMWorld::UniversalId::getParentType (id.getType()))
|
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&)));
|
||||||
mCurrentId = id.getId();
|
|
||||||
|
changeCurrentId(id.getId());
|
||||||
|
|
||||||
QWidget *mainWidget = new QWidget(this);
|
QWidget *mainWidget = new QWidget(this);
|
||||||
|
|
||||||
QHBoxLayout *buttonsLayout = new QHBoxLayout;
|
QHBoxLayout *buttonsLayout = new QHBoxLayout;
|
||||||
|
@ -509,7 +511,9 @@ CSVWorld::DialogueSubView::DialogueSubView (const CSMWorld::UniversalId& id, CSM
|
||||||
new TableBottomBox (creatorFactory, document.getData(), document.getUndoStack(), id, this));
|
new TableBottomBox (creatorFactory, document.getData(), document.getUndoStack(), id, this));
|
||||||
|
|
||||||
mBottom->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed);
|
mBottom->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed);
|
||||||
|
|
||||||
connect(mBottom, SIGNAL(requestFocus(const std::string&)), this, SLOT(requestFocus(const std::string&)));
|
connect(mBottom, SIGNAL(requestFocus(const std::string&)), this, SLOT(requestFocus(const std::string&)));
|
||||||
|
|
||||||
connect(addButton, SIGNAL(clicked()), mBottom, SLOT(createRequest()));
|
connect(addButton, SIGNAL(clicked()), mBottom, SLOT(createRequest()));
|
||||||
|
|
||||||
if(!mBottom->canCreateAndDelete())
|
if(!mBottom->canCreateAndDelete())
|
||||||
|
@ -549,7 +553,7 @@ void CSVWorld::DialogueSubView::prevId()
|
||||||
setUniversalId(CSMWorld::UniversalId (static_cast<CSMWorld::UniversalId::Type> (mTable->data (mTable->index (newRow, 2)).toInt()),
|
setUniversalId(CSMWorld::UniversalId (static_cast<CSMWorld::UniversalId::Type> (mTable->data (mTable->index (newRow, 2)).toInt()),
|
||||||
mTable->data (mTable->index (newRow, 0)).toString().toUtf8().constData()));
|
mTable->data (mTable->index (newRow, 0)).toString().toUtf8().constData()));
|
||||||
|
|
||||||
mCurrentId = std::string(mTable->data (mTable->index (newRow, 0)).toString().toUtf8().constData());
|
changeCurrentId(std::string(mTable->data (mTable->index (newRow, 0)).toString().toUtf8().constData()));
|
||||||
|
|
||||||
mEditWidget->setDisabled(mLocked);
|
mEditWidget->setDisabled(mLocked);
|
||||||
|
|
||||||
|
@ -585,7 +589,7 @@ void CSVWorld::DialogueSubView::nextId()
|
||||||
setUniversalId(CSMWorld::UniversalId (static_cast<CSMWorld::UniversalId::Type> (mTable->data (mTable->index (newRow, 2)).toInt()),
|
setUniversalId(CSMWorld::UniversalId (static_cast<CSMWorld::UniversalId::Type> (mTable->data (mTable->index (newRow, 2)).toInt()),
|
||||||
mTable->data (mTable->index (newRow, 0)).toString().toUtf8().constData()));
|
mTable->data (mTable->index (newRow, 0)).toString().toUtf8().constData()));
|
||||||
|
|
||||||
mCurrentId = std::string(mTable->data (mTable->index (newRow, 0)).toString().toUtf8().constData());
|
changeCurrentId(std::string(mTable->data (mTable->index (newRow, 0)).toString().toUtf8().constData()));
|
||||||
|
|
||||||
mEditWidget->setDisabled(mLocked);
|
mEditWidget->setDisabled(mLocked);
|
||||||
|
|
||||||
|
@ -615,7 +619,6 @@ void CSVWorld::DialogueSubView::dataChanged(const QModelIndex & index)
|
||||||
{
|
{
|
||||||
QModelIndex currentIndex(mTable->getModelIndex(mCurrentId, 0));
|
QModelIndex currentIndex(mTable->getModelIndex(mCurrentId, 0));
|
||||||
|
|
||||||
|
|
||||||
if (currentIndex.isValid() && index.row() == currentIndex.row())
|
if (currentIndex.isValid() && index.row() == currentIndex.row())
|
||||||
{
|
{
|
||||||
CSMWorld::RecordBase::State state = static_cast<CSMWorld::RecordBase::State>(mTable->data (mTable->index (currentIndex.row(), 1)).toInt());
|
CSMWorld::RecordBase::State state = static_cast<CSMWorld::RecordBase::State>(mTable->data (mTable->index (currentIndex.row(), 1)).toInt());
|
||||||
|
@ -746,3 +749,12 @@ void CSVWorld::DialogueSubView::viewRecord()
|
||||||
emit focusId (params.first, params.second);
|
emit focusId (params.first, params.second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSVWorld::DialogueSubView::changeCurrentId(const std::string& newId)
|
||||||
|
{
|
||||||
|
std::vector<std::string> selection;
|
||||||
|
mCurrentId = std::string(newId);
|
||||||
|
|
||||||
|
selection.push_back(mCurrentId);
|
||||||
|
mCommandDispatcher.setSelection(selection);
|
||||||
|
}
|
||||||
|
|
|
@ -181,6 +181,9 @@ namespace CSVWorld
|
||||||
bool sorting = false);
|
bool sorting = false);
|
||||||
|
|
||||||
virtual void setEditLock (bool locked);
|
virtual void setEditLock (bool locked);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void changeCurrentId(const std::string& newCurrent);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue