Add edit locking to ExtendedCommandConfigurator

sceneinput
Stanislav Bas 10 years ago
parent 3c6bc74062
commit 47d21ff4b3

@ -20,7 +20,8 @@ CSVWorld::ExtendedCommandConfigurator::ExtendedCommandConfigurator(CSMDoc::Docum
mNumUsedCheckBoxes(0),
mNumChecked(0),
mMode(Mode_None),
mData(document.getData())
mData(document.getData()),
mEditLock(false)
{
mCommandDispatcher = new CSMWorld::CommandDispatcher(document, id, this);
@ -58,8 +59,19 @@ void CSVWorld::ExtendedCommandConfigurator::configure(CSVWorld::ExtendedCommandC
mPerformButton->setText((mMode == Mode_Delete) ? "Extended Delete" : "Extended Revert");
mSelectedIds = selectedIds;
mCommandDispatcher->setSelection(mSelectedIds);
setupCheckBoxes(mCommandDispatcher->getExtendedTypes());
setupGroupLayout();
lockWidgets(mEditLock);
}
}
void CSVWorld::ExtendedCommandConfigurator::setEditLock(bool locked)
{
if (mEditLock != locked)
{
mEditLock = locked;
lockWidgets(mEditLock);
}
}
@ -144,6 +156,18 @@ void CSVWorld::ExtendedCommandConfigurator::setupCheckBoxes(const std::vector<CS
mNumChecked = mNumUsedCheckBoxes = numTypes;
}
void CSVWorld::ExtendedCommandConfigurator::lockWidgets(bool locked)
{
mPerformButton->setEnabled(!mEditLock && mNumChecked > 0);
CheckBoxMap::const_iterator current = mTypeCheckBoxes.begin();
CheckBoxMap::const_iterator end = mTypeCheckBoxes.end();
for (int i = 0; current != end && i < mNumUsedCheckBoxes; ++current, ++i)
{
current->first->setEnabled(!mEditLock);
}
}
void CSVWorld::ExtendedCommandConfigurator::performExtendedCommand()
{
std::vector<CSMWorld::UniversalId> types;

@ -48,8 +48,11 @@ namespace CSVWorld
CSMWorld::Data &mData;
std::vector<std::string> mSelectedIds;
bool mEditLock;
void setupGroupLayout();
void setupCheckBoxes(const std::vector<CSMWorld::UniversalId> &types);
void lockWidgets(bool locked);
public:
ExtendedCommandConfigurator(CSMDoc::Document &document,
@ -57,6 +60,7 @@ namespace CSVWorld
QWidget *parent = 0);
void configure(Mode mode, const std::vector<std::string> &selectedIds);
void setEditLock(bool locked);
protected:
virtual void resizeEvent(QResizeEvent *event);

@ -115,6 +115,7 @@ void CSVWorld::TableBottomBox::setEditLock (bool locked)
{
if (mCreator)
mCreator->setEditLock (locked);
mExtendedConfigurator->setEditLock (locked);
}
CSVWorld::TableBottomBox::~TableBottomBox()

Loading…
Cancel
Save