1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-20 16:53:55 +00:00

remove deleted debug profiles from run tool

This commit is contained in:
Marc Zinnschlag 2014-09-07 12:55:52 +02:00
parent 51128d2d57
commit f913d51e35
4 changed files with 82 additions and 0 deletions

View file

@ -42,6 +42,14 @@ CSVRender::WorldspaceWidget::WorldspaceWidget (CSMDoc::Document& document, QWidg
this, SLOT (referenceAboutToBeRemoved (const QModelIndex&, int, int)));
connect (references, SIGNAL (rowsInserted (const QModelIndex&, int, int)),
this, SLOT (referenceAdded (const QModelIndex&, int, int)));
QAbstractItemModel *debugProfiles =
document.getData().getTableModel (CSMWorld::UniversalId::Type_DebugProfiles);
connect (debugProfiles, SIGNAL (dataChanged (const QModelIndex&, const QModelIndex&)),
this, SLOT (debugProfileDataChanged (const QModelIndex&, const QModelIndex&)));
connect (debugProfiles, SIGNAL (rowsAboutToBeRemoved (const QModelIndex&, int, int)),
this, SLOT (debugProfileAboutToBeRemoved (const QModelIndex&, int, int)));
}
void CSVRender::WorldspaceWidget::selectNavigationMode (const std::string& mode)
@ -248,6 +256,53 @@ void CSVRender::WorldspaceWidget::runRequest (const std::string& profile)
mDocument.startRunning (profile, getStartupInstruction());
}
void CSVRender::WorldspaceWidget::debugProfileDataChanged (const QModelIndex& topLeft,
const QModelIndex& bottomRight)
{
if (!mRun)
return;
CSMWorld::IdTable& debugProfiles = dynamic_cast<CSMWorld::IdTable&> (
*mDocument.getData().getTableModel (CSMWorld::UniversalId::Type_DebugProfiles));
int idColumn = debugProfiles.findColumnIndex (CSMWorld::Columns::ColumnId_Id);
int stateColumn = debugProfiles.findColumnIndex (CSMWorld::Columns::ColumnId_Modification);
for (int i=topLeft.row(); i<=bottomRight.row(); ++i)
{
int state = debugProfiles.data (debugProfiles.index (i, stateColumn)).toInt();
// As of version 0.33 this case can not happen because debug profiles exist only in
// project or session scope, which means they will never be in deleted state. But we
// are adding the code for the sake of completeness and to avoid surprises if debug
// profile ever get extended to content scope.
if (state==CSMWorld::RecordBase::State_Deleted)
mRun->removeProfile (debugProfiles.data (
debugProfiles.index (i, idColumn)).toString().toUtf8().constData());
}
}
void CSVRender::WorldspaceWidget::debugProfileAboutToBeRemoved (const QModelIndex& parent,
int start, int end)
{
if (parent.isValid())
return;
if (!mRun)
return;
CSMWorld::IdTable& debugProfiles = dynamic_cast<CSMWorld::IdTable&> (
*mDocument.getData().getTableModel (CSMWorld::UniversalId::Type_DebugProfiles));
int idColumn = debugProfiles.findColumnIndex (CSMWorld::Columns::ColumnId_Id);
for (int i=start; i<=end; ++i)
{
mRun->removeProfile (debugProfiles.data (
debugProfiles.index (i, idColumn)).toString().toUtf8().constData());
}
}
void CSVRender::WorldspaceWidget::elementSelectionChanged()
{
setVisibilityMask (getElementMask());

View file

@ -113,6 +113,12 @@ namespace CSVRender
virtual void runRequest (const std::string& profile);
void debugProfileDataChanged (const QModelIndex& topLeft,
const QModelIndex& bottomRight);
void debugProfileAboutToBeRemoved (const QModelIndex& parent, int start, int end);
protected slots:
void elementSelectionChanged();

View file

@ -33,3 +33,22 @@ void CSVWidget::SceneToolRun::showPanel (const QPoint& position)
if (mCurrentIndex!=-1)
emit runRequest (mProfiles[mCurrentIndex]);
}
void CSVWidget::SceneToolRun::removeProfile (const std::string& profile)
{
std::pair<std::vector<std::string>::iterator, std::vector<std::string>::iterator>
result = std::equal_range (mProfiles.begin(), mProfiles.end(), profile);
if (result.first!=result.second)
{
mProfiles.erase (result.first);
if (mCurrentIndex>=static_cast<int> (mProfiles.size()))
--mCurrentIndex;
if (mCurrentIndex==-1)
updateIcon();
adjustToolTips();
}
}

View file

@ -31,6 +31,8 @@ namespace CSVWidget
virtual void showPanel (const QPoint& position);
void removeProfile (const std::string& profile);
signals:
void runRequest (const std::string& profile);