Editor: Add PathgridCreator to find duplicate IDs

pull/1/head
Rob Cutmore 9 years ago
parent c9ada852aa
commit b129ff9672

@ -67,7 +67,7 @@ opencs_hdrs_noqt (view/doc
opencs_units (view/world
table tablesubview scriptsubview util regionmapsubview tablebottombox creator genericcreator
cellcreator referenceablecreator startscriptcreator referencecreator scenesubview
cellcreator pathgridcreator referenceablecreator startscriptcreator referencecreator scenesubview
infocreator scriptedit dialoguesubview previewsubview regionmap dragrecordtable nestedtable
dialoguespinbox recordbuttonbar tableeditidaction scripterrortable extendedcommandconfigurator
)

@ -0,0 +1,29 @@
#include "pathgridcreator.hpp"
#include "../../model/world/data.hpp"
CSVWorld::PathgridCreator::PathgridCreator(
CSMWorld::Data& data,
QUndoStack& undoStack,
const CSMWorld::UniversalId& id,
bool relaxedIdRules
) : GenericCreator(data, undoStack, id, relaxedIdRules)
{}
std::string CSVWorld::PathgridCreator::getErrors() const
{
std::string pathgridId = getId();
// Check user input for any errors.
std::string errors;
if (pathgridId.empty())
{
errors = "No Pathgrid ID entered";
}
else if (getData().getPathgrids().searchId(pathgridId) > -1)
{
errors = "Pathgrid with this ID already exists";
}
return errors;
}

@ -0,0 +1,26 @@
#ifndef PATHGRIDCREATOR_HPP
#define PATHGRIDCREATOR_HPP
#include "genericcreator.hpp"
namespace CSVWorld
{
/// \brief Record creator for pathgrids.
class PathgridCreator : public GenericCreator
{
Q_OBJECT
public:
PathgridCreator(
CSMWorld::Data& data,
QUndoStack& undoStack,
const CSMWorld::UniversalId& id,
bool relaxedIdRules = false);
/// \return Error description for current user input.
virtual std::string getErrors() const;
};
}
#endif // PATHGRIDCREATOR_HPP

@ -14,6 +14,7 @@
#include "scenesubview.hpp"
#include "dialoguecreator.hpp"
#include "infocreator.hpp"
#include "pathgridcreator.hpp"
#include "previewsubview.hpp"
void CSVWorld::addSubViewFactories (CSVDoc::SubViewFactoryManager& manager)
@ -42,7 +43,6 @@ void CSVWorld::addSubViewFactories (CSVDoc::SubViewFactoryManager& manager)
CSMWorld::UniversalId::Type_Enchantments,
CSMWorld::UniversalId::Type_BodyParts,
CSMWorld::UniversalId::Type_SoundGens,
CSMWorld::UniversalId::Type_Pathgrids,
CSMWorld::UniversalId::Type_None // end marker
};
@ -75,6 +75,9 @@ void CSVWorld::addSubViewFactories (CSVDoc::SubViewFactoryManager& manager)
manager.add (CSMWorld::UniversalId::Type_JournalInfos,
new CSVDoc::SubViewFactoryWithCreator<TableSubView, InfoCreatorFactory>);
manager.add (CSMWorld::UniversalId::Type_Pathgrids,
new CSVDoc::SubViewFactoryWithCreator<TableSubView, CreatorFactory<PathgridCreator> >);
// Subviews for resources tables
manager.add (CSMWorld::UniversalId::Type_Meshes,
new CSVDoc::SubViewFactoryWithCreator<TableSubView, NullCreatorFactory>);
@ -125,7 +128,6 @@ void CSVWorld::addSubViewFactories (CSVDoc::SubViewFactoryManager& manager)
CSMWorld::UniversalId::Type_Enchantment,
CSMWorld::UniversalId::Type_BodyPart,
CSMWorld::UniversalId::Type_SoundGen,
CSMWorld::UniversalId::Type_Pathgrid,
CSMWorld::UniversalId::Type_None // end marker
};
@ -168,6 +170,9 @@ void CSVWorld::addSubViewFactories (CSVDoc::SubViewFactoryManager& manager)
manager.add (CSMWorld::UniversalId::Type_Journal,
new CSVDoc::SubViewFactoryWithCreator<DialogueSubView, JournalCreatorFactory> (false));
manager.add (CSMWorld::UniversalId::Type_Pathgrid,
new CSVDoc::SubViewFactoryWithCreator<DialogueSubView, CreatorFactory<PathgridCreator> > (false));
manager.add (CSMWorld::UniversalId::Type_DebugProfile,
new CSVDoc::SubViewFactoryWithCreator<DialogueSubView, CreatorFactory<GenericCreator, CSMWorld::Scope_Project | CSMWorld::Scope_Session> > (false));

Loading…
Cancel
Save