mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-21 06:53:53 +00:00
added creator edit lock
This commit is contained in:
parent
32c697abc6
commit
124a70906f
6 changed files with 29 additions and 6 deletions
|
@ -24,6 +24,8 @@ namespace CSVWorld
|
|||
|
||||
virtual void reset() = 0;
|
||||
|
||||
virtual void setEditLock (bool locked) = 0;
|
||||
|
||||
signals:
|
||||
|
||||
void done();
|
||||
|
|
|
@ -18,12 +18,12 @@ void CSVWorld::GenericCreator::update()
|
|||
|
||||
mCreate->setToolTip (QString::fromUtf8 (mErrors.c_str()));
|
||||
|
||||
mCreate->setEnabled (mErrors.empty());
|
||||
mCreate->setEnabled (mErrors.empty() && !mLocked);
|
||||
}
|
||||
|
||||
CSVWorld::GenericCreator::GenericCreator (CSMWorld::Data& data, QUndoStack& undoStack,
|
||||
const CSMWorld::UniversalId& id)
|
||||
: mData (data), mUndoStack (undoStack), mListId (id)
|
||||
: mData (data), mUndoStack (undoStack), mListId (id), mLocked (false)
|
||||
{
|
||||
QHBoxLayout *layout = new QHBoxLayout;
|
||||
layout->setContentsMargins (0, 0, 0, 0);
|
||||
|
@ -46,6 +46,12 @@ CSVWorld::GenericCreator::GenericCreator (CSMWorld::Data& data, QUndoStack& undo
|
|||
connect (mId, SIGNAL (textChanged (const QString&)), this, SLOT (textChanged (const QString&)));
|
||||
}
|
||||
|
||||
void CSVWorld::GenericCreator::setEditLock (bool locked)
|
||||
{
|
||||
mLocked = locked;
|
||||
update();
|
||||
}
|
||||
|
||||
void CSVWorld::GenericCreator::reset()
|
||||
{
|
||||
mId->setText ("");
|
||||
|
@ -77,9 +83,12 @@ void CSVWorld::GenericCreator::textChanged (const QString& text)
|
|||
|
||||
void CSVWorld::GenericCreator::create()
|
||||
{
|
||||
mUndoStack.push (new CSMWorld::CreateCommand (
|
||||
dynamic_cast<CSMWorld::IdTable&> (*mData.getTableModel (mListId)),
|
||||
mId->text().toUtf8().constData()));
|
||||
if (!mLocked)
|
||||
{
|
||||
mUndoStack.push (new CSMWorld::CreateCommand (
|
||||
dynamic_cast<CSMWorld::IdTable&> (*mData.getTableModel (mListId)),
|
||||
mId->text().toUtf8().constData()));
|
||||
|
||||
emit done();
|
||||
emit done();
|
||||
}
|
||||
}
|
|
@ -20,6 +20,7 @@ namespace CSVWorld
|
|||
QPushButton *mCreate;
|
||||
QLineEdit *mId;
|
||||
std::string mErrors;
|
||||
bool mLocked;
|
||||
|
||||
private:
|
||||
|
||||
|
@ -30,6 +31,8 @@ namespace CSVWorld
|
|||
GenericCreator (CSMWorld::Data& data, QUndoStack& undoStack,
|
||||
const CSMWorld::UniversalId& id);
|
||||
|
||||
virtual void setEditLock (bool locked);
|
||||
|
||||
virtual void reset();
|
||||
|
||||
virtual std::string getErrors() const;
|
||||
|
|
|
@ -68,6 +68,12 @@ CSVWorld::TableBottomBox::TableBottomBox (const CreatorFactoryBase& creatorFacto
|
|||
connect (mCreator, SIGNAL (done()), this, SLOT (createRequestDone()));
|
||||
}
|
||||
|
||||
void CSVWorld::TableBottomBox::setEditLock (bool locked)
|
||||
{
|
||||
if (mCreator)
|
||||
mCreator->setEditLock (locked);
|
||||
}
|
||||
|
||||
CSVWorld::TableBottomBox::~TableBottomBox()
|
||||
{
|
||||
delete mCreator;
|
||||
|
|
|
@ -46,6 +46,8 @@ namespace CSVWorld
|
|||
|
||||
virtual ~TableBottomBox();
|
||||
|
||||
void setEditLock (bool locked);
|
||||
|
||||
void setStatusBar (bool show);
|
||||
|
||||
bool canCreateAndDelete() const;
|
||||
|
|
|
@ -46,6 +46,7 @@ CSVWorld::TableSubView::TableSubView (const CSMWorld::UniversalId& id, CSMDoc::D
|
|||
void CSVWorld::TableSubView::setEditLock (bool locked)
|
||||
{
|
||||
mTable->setEditLock (locked);
|
||||
mBottom->setEditLock (locked);
|
||||
}
|
||||
|
||||
void CSVWorld::TableSubView::editRequest (int row)
|
||||
|
|
Loading…
Reference in a new issue