From 7594bcf97aa0813d3517f2f53f2d1d633c22aee6 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Tue, 21 Jan 2014 08:27:29 +0100 Subject: [PATCH] Small refactoring. --- apps/opencs/view/world/genericcreator.cpp | 2 +- apps/opencs/view/world/table.cpp | 7 ++++--- apps/opencs/view/world/table.hpp | 2 +- apps/opencs/view/world/tablesubview.cpp | 10 +++------- apps/opencs/view/world/tablesubview.hpp | 8 ++++---- 5 files changed, 13 insertions(+), 16 deletions(-) diff --git a/apps/opencs/view/world/genericcreator.cpp b/apps/opencs/view/world/genericcreator.cpp index efdd9ecafb..163842ab81 100644 --- a/apps/opencs/view/world/genericcreator.cpp +++ b/apps/opencs/view/world/genericcreator.cpp @@ -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::ArgumentType argumentType) { diff --git a/apps/opencs/view/world/table.cpp b/apps/opencs/view/world/table.cpp index cc1f814ddf..d343f9986a 100644 --- a/apps/opencs/view/world/table.cpp +++ b/apps/opencs/view/world/table.cpp @@ -16,6 +16,7 @@ #include "recordstatusdelegate.hpp" #include "util.hpp" +#include void CSVWorld::Table::contextMenuEvent (QContextMenuEvent *event) { @@ -308,10 +309,10 @@ void CSVWorld::Table::cloneRecord() if (!mEditLock) { QModelIndexList selectedRows = selectionModel()->selectedRows(); - - if (selectedRows.size()==1) + const CSMWorld::UniversalId& toClone = getUniversalId(selectedRows.begin()->row()); + if (selectedRows.size()==1 && !mModel->getRecord(toClone.getId()).isDeleted()) { - emit cloneRequest (selectedRows.begin()->row(), mModel); + emit cloneRequest (toClone); } } } diff --git a/apps/opencs/view/world/table.hpp b/apps/opencs/view/world/table.hpp index af2d7877f7..d30083333f 100644 --- a/apps/opencs/view/world/table.hpp +++ b/apps/opencs/view/world/table.hpp @@ -74,7 +74,7 @@ namespace CSVWorld /// \param modified Number of added and modified records void createRequest(); - void cloneRequest(int row, const CSMWorld::IdTable*); + void cloneRequest(const CSMWorld::UniversalId&); private slots: diff --git a/apps/opencs/view/world/tablesubview.cpp b/apps/opencs/view/world/tablesubview.cpp index 7650556106..3c71d13708 100644 --- a/apps/opencs/view/world/tablesubview.cpp +++ b/apps/opencs/view/world/tablesubview.cpp @@ -49,7 +49,7 @@ CSVWorld::TableSubView::TableSubView (const CSMWorld::UniversalId& id, CSMDoc::D { 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)), 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); } -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)); - if (!(table->getRecord(toClone.getId()).isDeleted())) - { - emit cloneRequest(toClone.getId(), toClone.getType(), toClone.getArgumentType()); - } + emit cloneRequest(toClone.getId(), toClone.getType(), toClone.getArgumentType()); } diff --git a/apps/opencs/view/world/tablesubview.hpp b/apps/opencs/view/world/tablesubview.hpp index 650a098f6c..b3a0a51626 100644 --- a/apps/opencs/view/world/tablesubview.hpp +++ b/apps/opencs/view/world/tablesubview.hpp @@ -40,14 +40,14 @@ namespace CSVWorld virtual void setStatusBar (bool show); signals: - void cloneRequest(const std::string& id, - const CSMWorld::UniversalId::Type type, - const CSMWorld::UniversalId::ArgumentType argumentType); + void cloneRequest(const std::string&, + const CSMWorld::UniversalId::Type, + const CSMWorld::UniversalId::ArgumentType); private slots: void editRequest (int row); - void cloneRequest (int row, const CSMWorld::IdTable* table); + void cloneRequest (const CSMWorld::UniversalId& toClone); }; }