1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-16 02:49:55 +00:00

refactoring dialogue subview

This commit is contained in:
Marek Kochanowicz 2014-06-16 11:31:57 +02:00
parent 7eb82f74ae
commit 786c68f09a
2 changed files with 19 additions and 4 deletions

View file

@ -448,7 +448,9 @@ CSVWorld::DialogueSubView::DialogueSubView (const CSMWorld::UniversalId& id, CSM
mCommandDispatcher (document, CSMWorld::UniversalId::getParentType (id.getType()))
{
connect(mTable, SIGNAL(dataChanged (const QModelIndex&, const QModelIndex&)), this, SLOT(dataChanged(const QModelIndex&)));
mCurrentId = id.getId();
changeCurrentId(id.getId());
QWidget *mainWidget = new QWidget(this);
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));
mBottom->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed);
connect(mBottom, SIGNAL(requestFocus(const std::string&)), this, SLOT(requestFocus(const std::string&)));
connect(addButton, SIGNAL(clicked()), mBottom, SLOT(createRequest()));
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()),
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);
@ -585,7 +589,7 @@ void CSVWorld::DialogueSubView::nextId()
setUniversalId(CSMWorld::UniversalId (static_cast<CSMWorld::UniversalId::Type> (mTable->data (mTable->index (newRow, 2)).toInt()),
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);
@ -615,7 +619,6 @@ void CSVWorld::DialogueSubView::dataChanged(const QModelIndex & index)
{
QModelIndex currentIndex(mTable->getModelIndex(mCurrentId, 0));
if (currentIndex.isValid() && index.row() == currentIndex.row())
{
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);
}
}
void CSVWorld::DialogueSubView::changeCurrentId(const std::string& newId)
{
std::vector<std::string> selection;
mCurrentId = std::string(newId);
selection.push_back(mCurrentId);
mCommandDispatcher.setSelection(selection);
}

View file

@ -181,6 +181,9 @@ namespace CSVWorld
bool sorting = false);
virtual void setEditLock (bool locked);
private:
void changeCurrentId(const std::string& newCurrent);
private slots: