From 1caff94ebabc97094e09a72c2bfc4af9bd363f32 Mon Sep 17 00:00:00 2001 From: Tats Date: Fri, 12 Feb 2016 11:19:47 -0500 Subject: [PATCH] Replaced ProjectAttributes with ProjectLabels. --- ProjectLabels.cpp | 31 +++++++++++++++++++++++++++++++ ProjectLabels.h | 37 +++++++++++++++++++++++++++++++++++++ ProjectReader.cpp | 20 ++++++++++---------- ProjectReader.h | 3 +-- ProjectWriter.cpp | 9 --------- ProjectWriter.h | 17 ++--------------- mapmap.pro | 2 ++ 7 files changed, 83 insertions(+), 36 deletions(-) create mode 100644 ProjectLabels.cpp create mode 100644 ProjectLabels.h diff --git a/ProjectLabels.cpp b/ProjectLabels.cpp new file mode 100644 index 0000000..94b352c --- /dev/null +++ b/ProjectLabels.cpp @@ -0,0 +1,31 @@ +/* + * ProjectLabels.cpp + * + * (c) 2016 Sofian Audry -- info(@)sofianaudry(.)com + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "ProjectLabels.h" + +const char* ProjectLabels::CLASS_NAME = "className"; +const char* ProjectLabels::PAINTS = "paints"; +const char* ProjectLabels::MAPPINGS = "mappings"; +const char* ProjectLabels::ID = "id"; +const char* ProjectLabels::PAINT_ID = "paintId"; +const char* ProjectLabels::NAME = "name"; +const char* ProjectLabels::SOURCE = "id"; +const char* ProjectLabels::DESTINATION = "name"; + + diff --git a/ProjectLabels.h b/ProjectLabels.h new file mode 100644 index 0000000..2b92212 --- /dev/null +++ b/ProjectLabels.h @@ -0,0 +1,37 @@ +/* + * ProjectLabels.h + * + * (c) 2016 Sofian Audry -- info(@)sofianaudry(.)com + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef PROJECTLABELS_H_ +#define PROJECTLABELS_H_ + +class ProjectLabels { +public: + static const char* CLASS_NAME; + static const char* PAINTS; + static const char* MAPPINGS; + + static const char* ID; + static const char* NAME; + static const char* PAINT_ID; + + static const char* DESTINATION; + static const char* SOURCE; +}; + +#endif /* PROJECTLABELS_H_ */ diff --git a/ProjectReader.cpp b/ProjectReader.cpp index dcbf764..9d89707 100644 --- a/ProjectReader.cpp +++ b/ProjectReader.cpp @@ -68,8 +68,8 @@ void ProjectReader::parseProject(const QDomElement& project) MappingManager& manager = _window->getMappingManager(); manager.clearAll(); - QDomElement paints = project.firstChildElement(ProjectAttributes::PAINTS); - QDomElement mappings = project.firstChildElement(ProjectAttributes::MAPPINGS); + QDomElement paints = project.firstChildElement(ProjectLabels::PAINTS); + QDomElement mappings = project.firstChildElement(ProjectLabels::MAPPINGS); // Parse paints. QDomNode paintNode = paints.firstChild(); @@ -110,8 +110,8 @@ void ProjectReader::parseProject(const QDomElement& project) Paint::ptr ProjectReader::parsePaint(const QDomElement& paintElem) { - QString className = paintElem.attribute(ProjectAttributes::CLASS_NAME); - int id = paintElem.attribute(ProjectAttributes::ID, QString::number(NULL_UID)).toInt(); + QString className = paintElem.attribute(ProjectLabels::CLASS_NAME); + int id = paintElem.attribute(ProjectLabels::ID, QString::number(NULL_UID)).toInt(); qDebug() << "Found paint with classname: " << className << endl; @@ -143,8 +143,8 @@ Paint::ptr ProjectReader::parsePaint(const QDomElement& paintElem) Mapping::ptr ProjectReader::parseMapping(const QDomElement& mappingElem) { // Get attributes. - QString className = mappingElem.attribute(ProjectAttributes::CLASS_NAME); - int id = mappingElem.attribute(ProjectAttributes::ID, QString::number(NULL_UID)).toInt(); + QString className = mappingElem.attribute(ProjectLabels::CLASS_NAME); + int id = mappingElem.attribute(ProjectLabels::ID, QString::number(NULL_UID)).toInt(); qDebug() << "Found mapping with classname: " << className << endl; @@ -176,10 +176,10 @@ Mapping::ptr ProjectReader::parseMapping(const QDomElement& mappingElem) // //Mapping::ptr ProjectReader::parseMapping(const QDomElement& mappingElem) //{ -// QString className = mappingElem.attribute(ProjectAttributes::CLASS_NAME); -// int id = mappingElem.attribute(ProjectAttributes::ID, QString::number(NULL_UID)).toInt(); -// int paintId = mappingElem.attribute(ProjectAttributes::PAINT_ID, QString::number(NULL_UID)).toInt(); -// QString name = mappingElem.attribute(ProjectAttributes::NAME, ""); +// QString className = mappingElem.attribute(ProjectLabels::CLASS_NAME); +// int id = mappingElem.attribute(ProjectLabels::ID, QString::number(NULL_UID)).toInt(); +// int paintId = mappingElem.attribute(ProjectLabels::PAINT_ID, QString::number(NULL_UID)).toInt(); +// QString name = mappingElem.attribute(ProjectLabels::NAME, ""); // // qDebug() << "Found mapping with classname: " << className << endl; // diff --git a/ProjectReader.h b/ProjectReader.h index aae2dc8..47df7a5 100644 --- a/ProjectReader.h +++ b/ProjectReader.h @@ -25,8 +25,7 @@ #include "Paint.h" #include "MetaObjectRegistry.h" -// TODO: replace with ProjectAttributes.h -#include "ProjectWriter.h" +#include "ProjectLabels.h" class ProjectReader { diff --git a/ProjectWriter.cpp b/ProjectWriter.cpp index fac1795..648c952 100644 --- a/ProjectWriter.cpp +++ b/ProjectWriter.cpp @@ -20,15 +20,6 @@ #include "ProjectWriter.h" #include -const char* ProjectAttributes::CLASS_NAME = "className"; -const char* ProjectAttributes::PAINTS = "paints"; -const char* ProjectAttributes::MAPPINGS = "mappings"; -const char* ProjectAttributes::ID = "id"; -const char* ProjectAttributes::PAINT_ID = "paintId"; -const char* ProjectAttributes::NAME = "name"; -const char* ProjectAttributes::SOURCE = "id"; -const char* ProjectAttributes::DESTINATION = "name"; - ProjectWriter::ProjectWriter(MainWindow *window) : _window(window) { diff --git a/ProjectWriter.h b/ProjectWriter.h index 5bb4ef5..a75a5df 100644 --- a/ProjectWriter.h +++ b/ProjectWriter.h @@ -26,23 +26,10 @@ #include "Paint.h" #include "MainWindow.h" +#include "ProjectLabels.h" + #include "Shapes.h" -class ProjectAttributes -{ -public: - static const char* CLASS_NAME; - static const char* PAINTS; - static const char* MAPPINGS; - - static const char* ID; - static const char* NAME; - static const char* PAINT_ID; - - static const char* DESTINATION; - static const char* SOURCE; -}; - class ProjectWriter { public: diff --git a/mapmap.pro b/mapmap.pro index 5918e8c..db3ba5b 100644 --- a/mapmap.pro +++ b/mapmap.pro @@ -30,6 +30,7 @@ HEADERS = \ PaintGui.h \ Polygon.h \ PreferencesDialog.h \ + ProjectLabels.h \ ProjectReader.h \ ProjectWriter.h \ Quad.h \ @@ -66,6 +67,7 @@ SOURCES = \ PaintGui.cpp \ Polygon.cpp \ PreferencesDialog.cpp \ + ProjectLabels.cpp \ ProjectReader.cpp \ ProjectWriter.cpp \ Serializable.cpp \