mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 23:53:52 +00:00
disable dialogue subview buttons while document is locked
This commit is contained in:
parent
6769479358
commit
d5e6d8a58b
4 changed files with 77 additions and 42 deletions
|
@ -714,20 +714,26 @@ CSVWorld::DialogueSubView::DialogueSubView (const CSMWorld::UniversalId& id,
|
||||||
this, SLOT (requestFocus (const std::string&)));
|
this, SLOT (requestFocus (const std::string&)));
|
||||||
|
|
||||||
// button bar
|
// button bar
|
||||||
RecordButtonBar *buttons = new RecordButtonBar (id, getTable(), mBottom,
|
mButtons = new RecordButtonBar (id, getTable(), mBottom,
|
||||||
&getCommandDispatcher(), this);
|
&getCommandDispatcher(), this);
|
||||||
|
|
||||||
// layout
|
// layout
|
||||||
getMainLayout().addWidget (buttons);
|
getMainLayout().addWidget (mButtons);
|
||||||
getMainLayout().addWidget (mBottom);
|
getMainLayout().addWidget (mBottom);
|
||||||
|
|
||||||
// connections
|
// connections
|
||||||
connect (buttons, SIGNAL (nextId()), this, SLOT (nextId()));
|
connect (mButtons, SIGNAL (nextId()), this, SLOT (nextId()));
|
||||||
connect (buttons, SIGNAL (prevId()), this, SLOT (prevId()));
|
connect (mButtons, SIGNAL (prevId()), this, SLOT (prevId()));
|
||||||
connect (buttons, SIGNAL (showPreview()), this, SLOT (showPreview()));
|
connect (mButtons, SIGNAL (showPreview()), this, SLOT (showPreview()));
|
||||||
connect (buttons, SIGNAL (viewRecord()), this, SLOT (viewRecord()));
|
connect (mButtons, SIGNAL (viewRecord()), this, SLOT (viewRecord()));
|
||||||
connect (this, SIGNAL (universalIdChanged (const CSMWorld::UniversalId&)),
|
connect (this, SIGNAL (universalIdChanged (const CSMWorld::UniversalId&)),
|
||||||
buttons, SLOT (universalIdChanged (const CSMWorld::UniversalId&)));
|
mButtons, SLOT (universalIdChanged (const CSMWorld::UniversalId&)));
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVWorld::DialogueSubView::setEditLock (bool locked)
|
||||||
|
{
|
||||||
|
SimpleDialogueSubView::setEditLock (locked);
|
||||||
|
mButtons->setEditLock (locked);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVWorld::DialogueSubView::prevId()
|
void CSVWorld::DialogueSubView::prevId()
|
||||||
|
|
|
@ -218,17 +218,22 @@ namespace CSVWorld
|
||||||
void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end);
|
void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class RecordButtonBar;
|
||||||
|
|
||||||
class DialogueSubView : public SimpleDialogueSubView
|
class DialogueSubView : public SimpleDialogueSubView
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
TableBottomBox* mBottom;
|
TableBottomBox* mBottom;
|
||||||
|
RecordButtonBar *mButtons;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
DialogueSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document,
|
DialogueSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document,
|
||||||
const CreatorFactoryBase& creatorFactory, bool sorting = false);
|
const CreatorFactoryBase& creatorFactory, bool sorting = false);
|
||||||
|
|
||||||
|
virtual void setEditLock (bool locked);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void nextId();
|
void nextId();
|
||||||
|
|
|
@ -9,11 +9,25 @@
|
||||||
|
|
||||||
#include "../world/tablebottombox.hpp"
|
#include "../world/tablebottombox.hpp"
|
||||||
|
|
||||||
|
void CSVWorld::RecordButtonBar::updateModificationButtons()
|
||||||
|
{
|
||||||
|
bool createAndDeleteDisabled = !mBottom || !mBottom->canCreateAndDelete() || mLocked;
|
||||||
|
|
||||||
|
mCloneButton->setDisabled (createAndDeleteDisabled);
|
||||||
|
mAddButton->setDisabled (createAndDeleteDisabled);
|
||||||
|
mDeleteButton->setDisabled (createAndDeleteDisabled);
|
||||||
|
|
||||||
|
bool commandDisabled = !mCommandDispatcher || mLocked;
|
||||||
|
|
||||||
|
mRevertButton->setDisabled (commandDisabled);
|
||||||
|
mDeleteButton->setDisabled (commandDisabled);
|
||||||
|
}
|
||||||
|
|
||||||
CSVWorld::RecordButtonBar::RecordButtonBar (const CSMWorld::UniversalId& id,
|
CSVWorld::RecordButtonBar::RecordButtonBar (const CSMWorld::UniversalId& id,
|
||||||
CSMWorld::IdTable& table, TableBottomBox *bottomBox,
|
CSMWorld::IdTable& table, TableBottomBox *bottomBox,
|
||||||
CSMWorld::CommandDispatcher *commandDispatcher, QWidget *parent)
|
CSMWorld::CommandDispatcher *commandDispatcher, QWidget *parent)
|
||||||
: QWidget (parent), mId (id), mTable (table), mBottom (bottomBox),
|
: QWidget (parent), mId (id), mTable (table), mBottom (bottomBox),
|
||||||
mCommandDispatcher (commandDispatcher)
|
mCommandDispatcher (commandDispatcher), mLocked (false)
|
||||||
{
|
{
|
||||||
QHBoxLayout *buttonsLayout = new QHBoxLayout;
|
QHBoxLayout *buttonsLayout = new QHBoxLayout;
|
||||||
buttonsLayout->setContentsMargins (0, 0, 0, 0);
|
buttonsLayout->setContentsMargins (0, 0, 0, 0);
|
||||||
|
@ -51,54 +65,51 @@ CSVWorld::RecordButtonBar::RecordButtonBar (const CSMWorld::UniversalId& id,
|
||||||
}
|
}
|
||||||
|
|
||||||
// right section
|
// right section
|
||||||
QToolButton* cloneButton = new QToolButton (this);
|
mCloneButton = new QToolButton (this);
|
||||||
cloneButton->setIcon(QIcon(":/edit-clone.png"));
|
mCloneButton->setIcon(QIcon(":/edit-clone.png"));
|
||||||
cloneButton->setToolTip ("Clone record");
|
mCloneButton->setToolTip ("Clone record");
|
||||||
buttonsLayout->addWidget(cloneButton);
|
buttonsLayout->addWidget(mCloneButton);
|
||||||
|
|
||||||
QToolButton* addButton = new QToolButton (this);
|
mAddButton = new QToolButton (this);
|
||||||
addButton->setIcon(QIcon(":/add.png"));
|
mAddButton->setIcon(QIcon(":/add.png"));
|
||||||
addButton->setToolTip ("Add new record");
|
mAddButton->setToolTip ("Add new record");
|
||||||
buttonsLayout->addWidget(addButton);
|
buttonsLayout->addWidget(mAddButton);
|
||||||
|
|
||||||
QToolButton* deleteButton = new QToolButton (this);
|
mDeleteButton = new QToolButton (this);
|
||||||
deleteButton->setIcon(QIcon(":/edit-delete.png"));
|
mDeleteButton->setIcon(QIcon(":/edit-delete.png"));
|
||||||
deleteButton->setToolTip ("Delete record");
|
mDeleteButton->setToolTip ("Delete record");
|
||||||
buttonsLayout->addWidget(deleteButton);
|
buttonsLayout->addWidget(mDeleteButton);
|
||||||
|
|
||||||
QToolButton* revertButton = new QToolButton (this);
|
mRevertButton = new QToolButton (this);
|
||||||
revertButton->setIcon(QIcon(":/edit-undo.png"));
|
mRevertButton->setIcon(QIcon(":/edit-undo.png"));
|
||||||
revertButton->setToolTip ("Revert record");
|
mRevertButton->setToolTip ("Revert record");
|
||||||
buttonsLayout->addWidget(revertButton);
|
buttonsLayout->addWidget(mRevertButton);
|
||||||
|
|
||||||
setLayout (buttonsLayout);
|
setLayout (buttonsLayout);
|
||||||
|
|
||||||
// disabling and connections
|
// connections
|
||||||
if(!mBottom || !mBottom->canCreateAndDelete())
|
if(mBottom && mBottom->canCreateAndDelete())
|
||||||
{
|
{
|
||||||
cloneButton->setDisabled (true);
|
connect (mAddButton, SIGNAL (clicked()), mBottom, SLOT (createRequest()));
|
||||||
addButton->setDisabled (true);
|
connect (mCloneButton, SIGNAL (clicked()), this, SLOT (cloneRequest()));
|
||||||
deleteButton->setDisabled (true);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
connect (addButton, SIGNAL (clicked()), mBottom, SLOT (createRequest()));
|
|
||||||
connect (cloneButton, SIGNAL (clicked()), this, SLOT (cloneRequest()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
connect (nextButton, SIGNAL (clicked()), this, SIGNAL (nextId()));
|
connect (nextButton, SIGNAL (clicked()), this, SIGNAL (nextId()));
|
||||||
connect (prevButton, SIGNAL (clicked()), this, SIGNAL (prevId()));
|
connect (prevButton, SIGNAL (clicked()), this, SIGNAL (prevId()));
|
||||||
|
|
||||||
if (!mCommandDispatcher)
|
if (mCommandDispatcher)
|
||||||
{
|
{
|
||||||
revertButton->setDisabled (true);
|
connect (mRevertButton, SIGNAL (clicked()), mCommandDispatcher, SLOT (executeRevert()));
|
||||||
deleteButton->setDisabled (true);
|
connect (mDeleteButton, SIGNAL (clicked()), mCommandDispatcher, SLOT (executeDelete()));
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
connect (revertButton, SIGNAL (clicked()), mCommandDispatcher, SLOT (executeRevert()));
|
|
||||||
connect (deleteButton, SIGNAL (clicked()), mCommandDispatcher, SLOT (executeDelete()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateModificationButtons();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVWorld::RecordButtonBar::setEditLock (bool locked)
|
||||||
|
{
|
||||||
|
mLocked = locked;
|
||||||
|
updateModificationButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVWorld::RecordButtonBar::universalIdChanged (const CSMWorld::UniversalId& id)
|
void CSVWorld::RecordButtonBar::universalIdChanged (const CSMWorld::UniversalId& id)
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
|
|
||||||
#include "../../model/world/universalid.hpp"
|
#include "../../model/world/universalid.hpp"
|
||||||
|
|
||||||
|
class QToolButton;
|
||||||
|
|
||||||
namespace CSMWorld
|
namespace CSMWorld
|
||||||
{
|
{
|
||||||
class IdTable;
|
class IdTable;
|
||||||
|
@ -33,6 +35,15 @@ namespace CSVWorld
|
||||||
CSMWorld::IdTable& mTable;
|
CSMWorld::IdTable& mTable;
|
||||||
TableBottomBox *mBottom;
|
TableBottomBox *mBottom;
|
||||||
CSMWorld::CommandDispatcher *mCommandDispatcher;
|
CSMWorld::CommandDispatcher *mCommandDispatcher;
|
||||||
|
QToolButton *mCloneButton;
|
||||||
|
QToolButton *mAddButton;
|
||||||
|
QToolButton *mDeleteButton;
|
||||||
|
QToolButton *mRevertButton;
|
||||||
|
bool mLocked;
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
void updateModificationButtons();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -40,6 +51,8 @@ namespace CSVWorld
|
||||||
CSMWorld::IdTable& table, TableBottomBox *bottomBox = 0,
|
CSMWorld::IdTable& table, TableBottomBox *bottomBox = 0,
|
||||||
CSMWorld::CommandDispatcher *commandDispatcher = 0, QWidget *parent = 0);
|
CSMWorld::CommandDispatcher *commandDispatcher = 0, QWidget *parent = 0);
|
||||||
|
|
||||||
|
void setEditLock (bool locked);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
void universalIdChanged (const CSMWorld::UniversalId& id);
|
void universalIdChanged (const CSMWorld::UniversalId& id);
|
||||||
|
|
Loading…
Reference in a new issue