mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-25 15:35:23 +00:00
moved most of the code for next/prev buttons from DialogueSubView to RecordBUttonBar
This commit is contained in:
parent
d5e6d8a58b
commit
a8c26ec0c1
@ -722,10 +722,10 @@ CSVWorld::DialogueSubView::DialogueSubView (const CSMWorld::UniversalId& id,
|
||||
getMainLayout().addWidget (mBottom);
|
||||
|
||||
// connections
|
||||
connect (mButtons, SIGNAL (nextId()), this, SLOT (nextId()));
|
||||
connect (mButtons, SIGNAL (prevId()), this, SLOT (prevId()));
|
||||
connect (mButtons, SIGNAL (showPreview()), this, SLOT (showPreview()));
|
||||
connect (mButtons, SIGNAL (viewRecord()), this, SLOT (viewRecord()));
|
||||
connect (mButtons, SIGNAL (switchToRow (int)), this, SLOT (switchToRow (int)));
|
||||
|
||||
connect (this, SIGNAL (universalIdChanged (const CSMWorld::UniversalId&)),
|
||||
mButtons, SLOT (universalIdChanged (const CSMWorld::UniversalId&)));
|
||||
}
|
||||
@ -736,78 +736,6 @@ void CSVWorld::DialogueSubView::setEditLock (bool locked)
|
||||
mButtons->setEditLock (locked);
|
||||
}
|
||||
|
||||
void CSVWorld::DialogueSubView::prevId()
|
||||
{
|
||||
int newRow = getTable().getModelIndex (getCurrentId(), 0).row() - 1;
|
||||
|
||||
if (newRow < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
while (newRow >= 0)
|
||||
{
|
||||
QModelIndex newIndex (getTable().index(newRow, 0));
|
||||
|
||||
if (!newIndex.isValid())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
CSMWorld::RecordBase::State state = static_cast<CSMWorld::RecordBase::State> (getTable().data (getTable().index (newRow, 1)).toInt());
|
||||
if (!(state == CSMWorld::RecordBase::State_Deleted || state == CSMWorld::RecordBase::State_Erased))
|
||||
{
|
||||
getEditWidget().remake (newRow);
|
||||
|
||||
setUniversalId(CSMWorld::UniversalId (static_cast<CSMWorld::UniversalId::Type> (getTable().data (getTable().index (newRow, 2)).toInt()),
|
||||
getTable().data (getTable().index (newRow, 0)).toString().toUtf8().constData()));
|
||||
|
||||
changeCurrentId(std::string (getTable().data (getTable().index (newRow, 0)).toString().toUtf8().constData()));
|
||||
|
||||
getEditWidget().setDisabled (isLocked());
|
||||
|
||||
return;
|
||||
}
|
||||
--newRow;
|
||||
}
|
||||
}
|
||||
|
||||
void CSVWorld::DialogueSubView::nextId ()
|
||||
{
|
||||
int newRow = getTable().getModelIndex (getCurrentId(), 0).row() + 1;
|
||||
|
||||
if (newRow >= getTable().rowCount())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
while (newRow < getTable().rowCount())
|
||||
{
|
||||
QModelIndex newIndex (getTable().index(newRow, 0));
|
||||
|
||||
if (!newIndex.isValid())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
CSMWorld::RecordBase::State state = static_cast<CSMWorld::RecordBase::State> (getTable().data (getTable().index (newRow, 1)).toInt());
|
||||
if (!(state == CSMWorld::RecordBase::State_Deleted))
|
||||
{
|
||||
getEditWidget().remake(newRow);
|
||||
|
||||
setUniversalId(CSMWorld::UniversalId (static_cast<CSMWorld::UniversalId::Type> (getTable().data (getTable().index (newRow, 2)).toInt()),
|
||||
getTable().data (getTable().index (newRow, 0)).toString().toUtf8().constData()));
|
||||
|
||||
changeCurrentId(std::string (getTable().data (getTable().index (newRow, 0)).toString().toUtf8().constData()));
|
||||
|
||||
getEditWidget().setDisabled (isLocked());
|
||||
|
||||
return;
|
||||
}
|
||||
++newRow;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CSVWorld::DialogueSubView::showPreview ()
|
||||
{
|
||||
QModelIndex currentIndex (getTable().getModelIndex (getCurrentId(), 0));
|
||||
@ -833,3 +761,15 @@ void CSVWorld::DialogueSubView::viewRecord ()
|
||||
emit focusId (params.first, params.second);
|
||||
}
|
||||
}
|
||||
|
||||
void CSVWorld::DialogueSubView::switchToRow (int row)
|
||||
{
|
||||
getEditWidget().remake (row);
|
||||
|
||||
setUniversalId (CSMWorld::UniversalId (static_cast<CSMWorld::UniversalId::Type> (getTable().data (getTable().index (row, 2)).toInt()),
|
||||
getTable().data (getTable().index (row, 0)).toString().toUtf8().constData()));
|
||||
|
||||
changeCurrentId(std::string (getTable().data (getTable().index (row, 0)).toString().toUtf8().constData()));
|
||||
|
||||
getEditWidget().setDisabled (isLocked());
|
||||
}
|
||||
|
@ -236,13 +236,11 @@ namespace CSVWorld
|
||||
|
||||
private slots:
|
||||
|
||||
void nextId();
|
||||
|
||||
void prevId();
|
||||
|
||||
void showPreview();
|
||||
|
||||
void viewRecord();
|
||||
|
||||
void switchToRow (int row);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -94,8 +94,8 @@ CSVWorld::RecordButtonBar::RecordButtonBar (const CSMWorld::UniversalId& id,
|
||||
connect (mCloneButton, SIGNAL (clicked()), this, SLOT (cloneRequest()));
|
||||
}
|
||||
|
||||
connect (nextButton, SIGNAL (clicked()), this, SIGNAL (nextId()));
|
||||
connect (prevButton, SIGNAL (clicked()), this, SIGNAL (prevId()));
|
||||
connect (nextButton, SIGNAL (clicked()), this, SLOT (nextId()));
|
||||
connect (prevButton, SIGNAL (clicked()), this, SLOT (prevId()));
|
||||
|
||||
if (mCommandDispatcher)
|
||||
{
|
||||
@ -133,3 +133,27 @@ void CSVWorld::RecordButtonBar::cloneRequest()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CSVWorld::RecordButtonBar::nextId()
|
||||
{
|
||||
int newRow = mTable.getModelIndex (mId.getId(), 0).row() + 1;
|
||||
|
||||
if (newRow >= mTable.rowCount())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
emit switchToRow (newRow);
|
||||
}
|
||||
|
||||
void CSVWorld::RecordButtonBar::prevId()
|
||||
{
|
||||
int newRow = mTable.getModelIndex (mId.getId(), 0).row() - 1;
|
||||
|
||||
if (newRow < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
emit switchToRow (newRow);
|
||||
}
|
||||
|
@ -60,6 +60,10 @@ namespace CSVWorld
|
||||
private slots:
|
||||
|
||||
void cloneRequest();
|
||||
|
||||
void nextId();
|
||||
|
||||
void prevId();
|
||||
|
||||
signals:
|
||||
|
||||
@ -67,9 +71,7 @@ namespace CSVWorld
|
||||
|
||||
void viewRecord();
|
||||
|
||||
void nextId();
|
||||
|
||||
void prevId();
|
||||
void switchToRow (int row);
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user