forked from mirror/openmw-tes3mp
Close the extended configurator when all respective records were removed outside
This commit is contained in:
parent
ceb3dea55c
commit
3c6bc74062
2 changed files with 42 additions and 2 deletions
|
@ -1,12 +1,17 @@
|
|||
#include "extendedcommandconfigurator.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include <QPushButton>
|
||||
#include <QGroupBox>
|
||||
#include <QCheckBox>
|
||||
#include <QLabel>
|
||||
#include <QLayout>
|
||||
|
||||
#include "../../model/doc/document.hpp"
|
||||
|
||||
#include "../../model/world/commanddispatcher.hpp"
|
||||
#include "../../model/world/data.hpp"
|
||||
|
||||
CSVWorld::ExtendedCommandConfigurator::ExtendedCommandConfigurator(CSMDoc::Document &document,
|
||||
const CSMWorld::UniversalId &id,
|
||||
|
@ -14,10 +19,13 @@ CSVWorld::ExtendedCommandConfigurator::ExtendedCommandConfigurator(CSMDoc::Docum
|
|||
: QWidget(parent),
|
||||
mNumUsedCheckBoxes(0),
|
||||
mNumChecked(0),
|
||||
mMode(Mode_None)
|
||||
mMode(Mode_None),
|
||||
mData(document.getData())
|
||||
{
|
||||
mCommandDispatcher = new CSMWorld::CommandDispatcher(document, id, this);
|
||||
|
||||
connect(&mData, SIGNAL(idListChanged()), this, SLOT(dataIdListChanged()));
|
||||
|
||||
mPerformButton = new QPushButton(this);
|
||||
mPerformButton->setDefault(true);
|
||||
mPerformButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
|
@ -48,7 +56,8 @@ void CSVWorld::ExtendedCommandConfigurator::configure(CSVWorld::ExtendedCommandC
|
|||
if (mMode != Mode_None)
|
||||
{
|
||||
mPerformButton->setText((mMode == Mode_Delete) ? "Extended Delete" : "Extended Revert");
|
||||
mCommandDispatcher->setSelection(selectedIds);
|
||||
mSelectedIds = selectedIds;
|
||||
mCommandDispatcher->setSelection(mSelectedIds);
|
||||
setupCheckBoxes(mCommandDispatcher->getExtendedTypes());
|
||||
setupGroupLayout();
|
||||
}
|
||||
|
@ -177,3 +186,30 @@ void CSVWorld::ExtendedCommandConfigurator::checkBoxStateChanged(int state)
|
|||
|
||||
mPerformButton->setEnabled(mNumChecked > 0);
|
||||
}
|
||||
|
||||
void CSVWorld::ExtendedCommandConfigurator::dataIdListChanged()
|
||||
{
|
||||
bool idsRemoved = false;
|
||||
for (int i = 0; i < static_cast<int>(mSelectedIds.size()); ++i)
|
||||
{
|
||||
if (!mData.hasId(mSelectedIds[i]))
|
||||
{
|
||||
std::swap(mSelectedIds[i], mSelectedIds.back());
|
||||
mSelectedIds.pop_back();
|
||||
idsRemoved = true;
|
||||
--i;
|
||||
}
|
||||
}
|
||||
|
||||
// If all selected IDs were removed, cancel the configurator
|
||||
if (mSelectedIds.empty())
|
||||
{
|
||||
emit done();
|
||||
return;
|
||||
}
|
||||
|
||||
if (idsRemoved)
|
||||
{
|
||||
mCommandDispatcher->setSelection(mSelectedIds);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ namespace CSMDoc
|
|||
namespace CSMWorld
|
||||
{
|
||||
class CommandDispatcher;
|
||||
class Data;
|
||||
}
|
||||
|
||||
namespace CSVWorld
|
||||
|
@ -44,6 +45,8 @@ namespace CSVWorld
|
|||
|
||||
Mode mMode;
|
||||
CSMWorld::CommandDispatcher *mCommandDispatcher;
|
||||
CSMWorld::Data &mData;
|
||||
std::vector<std::string> mSelectedIds;
|
||||
|
||||
void setupGroupLayout();
|
||||
void setupCheckBoxes(const std::vector<CSMWorld::UniversalId> &types);
|
||||
|
@ -61,6 +64,7 @@ namespace CSVWorld
|
|||
private slots:
|
||||
void performExtendedCommand();
|
||||
void checkBoxStateChanged(int state);
|
||||
void dataIdListChanged();
|
||||
|
||||
signals:
|
||||
void done();
|
||||
|
|
Loading…
Reference in a new issue