forked from mirror/openmw-tes3mp
progressing with the cloning
This commit is contained in:
parent
344cae8f99
commit
b3e45c55bc
7 changed files with 62 additions and 11 deletions
|
@ -2,6 +2,7 @@
|
||||||
#define CSV_WORLD_CREATOR_H
|
#define CSV_WORLD_CREATOR_H
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
#include "../../model/world/universalid.hpp"
|
||||||
|
|
||||||
class QUndoStack;
|
class QUndoStack;
|
||||||
|
|
||||||
|
@ -23,6 +24,8 @@ namespace CSVWorld
|
||||||
virtual ~Creator();
|
virtual ~Creator();
|
||||||
|
|
||||||
virtual void reset() = 0;
|
virtual void reset() = 0;
|
||||||
|
|
||||||
|
virtual void cloneMode(const std::string& originid, const CSMWorld::UniversalId::Type type) = 0;
|
||||||
|
|
||||||
virtual void setEditLock (bool locked) = 0;
|
virtual void setEditLock (bool locked) = 0;
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#include "genericcreator.hpp"
|
#include "genericcreator.hpp"
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <qt4/QtCore/QString>
|
||||||
|
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
@ -58,7 +59,7 @@ const CSMWorld::UniversalId& CSVWorld::GenericCreator::getCollectionId() const
|
||||||
|
|
||||||
CSVWorld::GenericCreator::GenericCreator (CSMWorld::Data& data, QUndoStack& undoStack,
|
CSVWorld::GenericCreator::GenericCreator (CSMWorld::Data& data, QUndoStack& undoStack,
|
||||||
const CSMWorld::UniversalId& id, bool relaxedIdRules)
|
const CSMWorld::UniversalId& id, bool relaxedIdRules)
|
||||||
: mData (data), mUndoStack (undoStack), mListId (id), mLocked (false)
|
: mData (data), mUndoStack (undoStack), mListId (id), mLocked (false), mCloneMode(false), mClonedType(CSMWorld::UniversalId::Type_None)
|
||||||
{
|
{
|
||||||
mLayout = new QHBoxLayout;
|
mLayout = new QHBoxLayout;
|
||||||
mLayout->setContentsMargins (0, 0, 0, 0);
|
mLayout->setContentsMargins (0, 0, 0, 0);
|
||||||
|
@ -89,6 +90,7 @@ void CSVWorld::GenericCreator::setEditLock (bool locked)
|
||||||
|
|
||||||
void CSVWorld::GenericCreator::reset()
|
void CSVWorld::GenericCreator::reset()
|
||||||
{
|
{
|
||||||
|
mCloneMode = false;
|
||||||
mId->setText ("");
|
mId->setText ("");
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
@ -120,16 +122,30 @@ void CSVWorld::GenericCreator::create()
|
||||||
{
|
{
|
||||||
if (!mLocked)
|
if (!mLocked)
|
||||||
{
|
{
|
||||||
std::string id = getId();
|
if (mCloneMode)
|
||||||
|
{
|
||||||
|
std::string id = getId();
|
||||||
|
} else {
|
||||||
|
std::string id = getId();
|
||||||
|
|
||||||
std::auto_ptr<CSMWorld::CreateCommand> command (new CSMWorld::CreateCommand (
|
std::auto_ptr<CSMWorld::CreateCommand> command (new CSMWorld::CreateCommand (
|
||||||
dynamic_cast<CSMWorld::IdTable&> (*mData.getTableModel (mListId)), id));
|
dynamic_cast<CSMWorld::IdTable&> (*mData.getTableModel (mListId)), id));
|
||||||
|
|
||||||
configureCreateCommand (*command);
|
configureCreateCommand (*command);
|
||||||
|
|
||||||
mUndoStack.push (command.release());
|
mUndoStack.push (command.release());
|
||||||
|
|
||||||
emit done();
|
emit done();
|
||||||
emit requestFocus (id);
|
emit requestFocus (id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSVWorld::GenericCreator::cloneMode(const std::string& originid, const CSMWorld::UniversalId::Type type)
|
||||||
|
{
|
||||||
|
mCloneMode = true;
|
||||||
|
mClonedId = originid;
|
||||||
|
mClonedType = type;
|
||||||
|
|
||||||
|
mId->setText(QString::fromStdString(mClonedId));
|
||||||
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#ifndef CSV_WORLD_GENERICCREATOR_H
|
#ifndef CSV_WORLD_GENERICCREATOR_H
|
||||||
#define CSV_WORLD_GENERICCREATOR_H
|
#define CSV_WORLD_GENERICCREATOR_H
|
||||||
|
|
||||||
|
class QString;
|
||||||
class QPushButton;
|
class QPushButton;
|
||||||
class QLineEdit;
|
class QLineEdit;
|
||||||
class QHBoxLayout;
|
class QHBoxLayout;
|
||||||
|
@ -28,6 +29,9 @@ namespace CSVWorld
|
||||||
std::string mErrors;
|
std::string mErrors;
|
||||||
QHBoxLayout *mLayout;
|
QHBoxLayout *mLayout;
|
||||||
bool mLocked;
|
bool mLocked;
|
||||||
|
bool mCloneMode;
|
||||||
|
std::string mClonedId;
|
||||||
|
CSMWorld::UniversalId::Type mClonedType;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
@ -57,6 +61,8 @@ namespace CSVWorld
|
||||||
|
|
||||||
virtual void reset();
|
virtual void reset();
|
||||||
|
|
||||||
|
virtual void cloneMode(const std::string& originid, const CSMWorld::UniversalId::Type type);
|
||||||
|
|
||||||
virtual std::string getErrors() const;
|
virtual std::string getErrors() const;
|
||||||
///< Return formatted error descriptions for the current state of the creator. if an empty
|
///< Return formatted error descriptions for the current state of the creator. if an empty
|
||||||
/// string is returned, there is no error.
|
/// string is returned, there is no error.
|
||||||
|
|
|
@ -156,4 +156,13 @@ void CSVWorld::TableBottomBox::createRequest()
|
||||||
mLayout->setCurrentWidget (mCreator);
|
mLayout->setCurrentWidget (mCreator);
|
||||||
setVisible (true);
|
setVisible (true);
|
||||||
mCreating = true;
|
mCreating = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSVWorld::TableBottomBox::cloneRequest(const std::string& id, const CSMWorld::UniversalId::Type type)
|
||||||
|
{
|
||||||
|
mCreator->reset();
|
||||||
|
mCreator->cloneMode(id, type);
|
||||||
|
mLayout->setCurrentWidget(mCreator);
|
||||||
|
setVisible (true);
|
||||||
|
mCreating = true;
|
||||||
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#define CSV_WORLD_BOTTOMBOX_H
|
#define CSV_WORLD_BOTTOMBOX_H
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
#include <apps/opencs/model/world/universalid.hpp>
|
||||||
|
|
||||||
class QLabel;
|
class QLabel;
|
||||||
class QStackedLayout;
|
class QStackedLayout;
|
||||||
|
@ -76,6 +77,7 @@ namespace CSVWorld
|
||||||
/// \param modified Number of added and modified records
|
/// \param modified Number of added and modified records
|
||||||
|
|
||||||
void createRequest();
|
void createRequest();
|
||||||
|
void cloneRequest(const std::string& id, const CSMWorld::UniversalId::Type type);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,8 +46,13 @@ CSVWorld::TableSubView::TableSubView (const CSMWorld::UniversalId& id, CSMDoc::D
|
||||||
mTable->selectionSizeUpdate();
|
mTable->selectionSizeUpdate();
|
||||||
|
|
||||||
if (mBottom->canCreateAndDelete())
|
if (mBottom->canCreateAndDelete())
|
||||||
|
{
|
||||||
connect (mTable, SIGNAL (createRequest()), mBottom, SLOT (createRequest()));
|
connect (mTable, SIGNAL (createRequest()), mBottom, SLOT (createRequest()));
|
||||||
|
|
||||||
|
connect (mTable, SIGNAL (cloneRequest(int)), this, SLOT(cloneRequest(int)));
|
||||||
|
connect (this, SIGNAL(cloneRequest(const std::string&, const CSMWorld::UniversalId::Type)),
|
||||||
|
mBottom, SLOT(cloneRequest(const std::string&, const CSMWorld::UniversalId::Type)));
|
||||||
|
}
|
||||||
connect (mBottom, SIGNAL (requestFocus (const std::string&)),
|
connect (mBottom, SIGNAL (requestFocus (const std::string&)),
|
||||||
mTable, SLOT (requestFocus (const std::string&)));
|
mTable, SLOT (requestFocus (const std::string&)));
|
||||||
|
|
||||||
|
@ -75,4 +80,10 @@ void CSVWorld::TableSubView::updateEditorSetting(const QString &settingName, con
|
||||||
void CSVWorld::TableSubView::setStatusBar (bool show)
|
void CSVWorld::TableSubView::setStatusBar (bool show)
|
||||||
{
|
{
|
||||||
mBottom->setStatusBar (show);
|
mBottom->setStatusBar (show);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSVWorld::TableSubView::cloneRequest(int row)
|
||||||
|
{
|
||||||
|
const CSMWorld::UniversalId& toClone(mTable->getUniversalId(row));
|
||||||
|
emit cloneRequest(toClone.getId(), toClone.getType());
|
||||||
|
}
|
||||||
|
|
|
@ -33,10 +33,14 @@ namespace CSVWorld
|
||||||
virtual void updateEditorSetting (const QString& key, const QString& value);
|
virtual void updateEditorSetting (const QString& key, const QString& value);
|
||||||
|
|
||||||
virtual void setStatusBar (bool show);
|
virtual void setStatusBar (bool show);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void cloneRequest(const std::string& id, const CSMWorld::UniversalId::Type type);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void editRequest (int row);
|
void editRequest (int row);
|
||||||
|
void cloneRequest (int row);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue