1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-04-01 12:06:41 +00:00

Small refactoring.

This commit is contained in:
Marek Kochanowicz 2014-01-21 08:27:29 +01:00
parent d0a52b7b24
commit 7594bcf97a
5 changed files with 13 additions and 16 deletions

View file

@ -149,7 +149,7 @@ void CSVWorld::GenericCreator::create()
} }
} }
void CSVWorld::GenericCreator::cloneMode(const std::string& originid, void CSVWorld::GenericCreator::cloneMode(const std::string& originid,
const CSMWorld::UniversalId::Type type, const CSMWorld::UniversalId::Type type,
const CSMWorld::UniversalId::ArgumentType argumentType) const CSMWorld::UniversalId::ArgumentType argumentType)
{ {

View file

@ -16,6 +16,7 @@
#include "recordstatusdelegate.hpp" #include "recordstatusdelegate.hpp"
#include "util.hpp" #include "util.hpp"
#include <qt4/QtCore/qabstractitemmodel.h>
void CSVWorld::Table::contextMenuEvent (QContextMenuEvent *event) void CSVWorld::Table::contextMenuEvent (QContextMenuEvent *event)
{ {
@ -308,10 +309,10 @@ void CSVWorld::Table::cloneRecord()
if (!mEditLock) if (!mEditLock)
{ {
QModelIndexList selectedRows = selectionModel()->selectedRows(); QModelIndexList selectedRows = selectionModel()->selectedRows();
const CSMWorld::UniversalId& toClone = getUniversalId(selectedRows.begin()->row());
if (selectedRows.size()==1) if (selectedRows.size()==1 && !mModel->getRecord(toClone.getId()).isDeleted())
{ {
emit cloneRequest (selectedRows.begin()->row(), mModel); emit cloneRequest (toClone);
} }
} }
} }

View file

@ -74,7 +74,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(int row, const CSMWorld::IdTable*); void cloneRequest(const CSMWorld::UniversalId&);
private slots: private slots:

View file

@ -49,7 +49,7 @@ CSVWorld::TableSubView::TableSubView (const CSMWorld::UniversalId& id, CSMDoc::D
{ {
connect (mTable, SIGNAL (createRequest()), mBottom, SLOT (createRequest())); connect (mTable, SIGNAL (createRequest()), mBottom, SLOT (createRequest()));
connect (mTable, SIGNAL (cloneRequest(int, const CSMWorld::IdTable*)), this, SLOT(cloneRequest(int, const CSMWorld::IdTable*))); connect (mTable, SIGNAL (cloneRequest(const CSMWorld::UniversalId&)), this, SLOT(cloneRequest(const CSMWorld::UniversalId&)));
connect (this, SIGNAL(cloneRequest(const std::string&, const CSMWorld::UniversalId::Type, const CSMWorld::UniversalId::ArgumentType)), connect (this, SIGNAL(cloneRequest(const std::string&, const CSMWorld::UniversalId::Type, const CSMWorld::UniversalId::ArgumentType)),
mBottom, SLOT(cloneRequest(const std::string&, const CSMWorld::UniversalId::Type, const CSMWorld::UniversalId::ArgumentType))); mBottom, SLOT(cloneRequest(const std::string&, const CSMWorld::UniversalId::Type, const CSMWorld::UniversalId::ArgumentType)));
} }
@ -82,11 +82,7 @@ void CSVWorld::TableSubView::setStatusBar (bool show)
mBottom->setStatusBar (show); mBottom->setStatusBar (show);
} }
void CSVWorld::TableSubView::cloneRequest(int row, const CSMWorld::IdTable* table) void CSVWorld::TableSubView::cloneRequest(const CSMWorld::UniversalId& toClone)
{ {
const CSMWorld::UniversalId& toClone(mTable->getUniversalId(row)); emit cloneRequest(toClone.getId(), toClone.getType(), toClone.getArgumentType());
if (!(table->getRecord(toClone.getId()).isDeleted()))
{
emit cloneRequest(toClone.getId(), toClone.getType(), toClone.getArgumentType());
}
} }

View file

@ -40,14 +40,14 @@ namespace CSVWorld
virtual void setStatusBar (bool show); virtual void setStatusBar (bool show);
signals: signals:
void cloneRequest(const std::string& id, void cloneRequest(const std::string&,
const CSMWorld::UniversalId::Type type, const CSMWorld::UniversalId::Type,
const CSMWorld::UniversalId::ArgumentType argumentType); const CSMWorld::UniversalId::ArgumentType);
private slots: private slots:
void editRequest (int row); void editRequest (int row);
void cloneRequest (int row, const CSMWorld::IdTable* table); void cloneRequest (const CSMWorld::UniversalId& toClone);
}; };
} }