progressing with the cloning

actorid
Marek Kochanowicz 11 years ago
parent 344cae8f99
commit b3e45c55bc

@ -2,6 +2,7 @@
#define CSV_WORLD_CREATOR_H
#include <QWidget>
#include "../../model/world/universalid.hpp"
class QUndoStack;
@ -23,6 +24,8 @@ namespace CSVWorld
virtual ~Creator();
virtual void reset() = 0;
virtual void cloneMode(const std::string& originid, const CSMWorld::UniversalId::Type type) = 0;
virtual void setEditLock (bool locked) = 0;

@ -2,6 +2,7 @@
#include "genericcreator.hpp"
#include <memory>
#include <qt4/QtCore/QString>
#include <QHBoxLayout>
#include <QPushButton>
@ -58,7 +59,7 @@ const CSMWorld::UniversalId& CSVWorld::GenericCreator::getCollectionId() const
CSVWorld::GenericCreator::GenericCreator (CSMWorld::Data& data, QUndoStack& undoStack,
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->setContentsMargins (0, 0, 0, 0);
@ -89,6 +90,7 @@ void CSVWorld::GenericCreator::setEditLock (bool locked)
void CSVWorld::GenericCreator::reset()
{
mCloneMode = false;
mId->setText ("");
update();
}
@ -120,16 +122,30 @@ void CSVWorld::GenericCreator::create()
{
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));
configureCreateCommand (*command);
configureCreateCommand (*command);
mUndoStack.push (command.release());
mUndoStack.push (command.release());
emit done();
emit requestFocus (id);
emit done();
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
#define CSV_WORLD_GENERICCREATOR_H
class QString;
class QPushButton;
class QLineEdit;
class QHBoxLayout;
@ -28,6 +29,9 @@ namespace CSVWorld
std::string mErrors;
QHBoxLayout *mLayout;
bool mLocked;
bool mCloneMode;
std::string mClonedId;
CSMWorld::UniversalId::Type mClonedType;
protected:
@ -57,6 +61,8 @@ namespace CSVWorld
virtual void reset();
virtual void cloneMode(const std::string& originid, const CSMWorld::UniversalId::Type type);
virtual std::string getErrors() const;
///< Return formatted error descriptions for the current state of the creator. if an empty
/// string is returned, there is no error.

@ -156,4 +156,13 @@ void CSVWorld::TableBottomBox::createRequest()
mLayout->setCurrentWidget (mCreator);
setVisible (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
#include <QWidget>
#include <apps/opencs/model/world/universalid.hpp>
class QLabel;
class QStackedLayout;
@ -76,6 +77,7 @@ namespace CSVWorld
/// \param modified Number of added and modified records
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();
if (mBottom->canCreateAndDelete())
{
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&)),
mTable, SLOT (requestFocus (const std::string&)));
@ -75,4 +80,10 @@ void CSVWorld::TableSubView::updateEditorSetting(const QString &settingName, con
void CSVWorld::TableSubView::setStatusBar (bool 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 setStatusBar (bool show);
signals:
void cloneRequest(const std::string& id, const CSMWorld::UniversalId::Type type);
private slots:
void editRequest (int row);
void cloneRequest (int row);
};
}

Loading…
Cancel
Save