From 0879cb7bf77c601d8ddc297ba26d24484b1e31bd Mon Sep 17 00:00:00 2001 From: Gennady Pospelov <g.pospelov@fz-juelich.de> Date: Thu, 29 Sep 2016 11:21:15 +0200 Subject: [PATCH] Generation of uuid identifier is moved to utils. --- GUI/coregui/Models/JobModel.cpp | 10 +--------- GUI/coregui/Models/JobModel.h | 1 - GUI/coregui/Models/MaterialItem.cpp | 3 +-- GUI/coregui/Models/MaterialModel.cpp | 4 ++-- .../Views/MaterialEditor/MaterialEditorToolBar.cpp | 1 - GUI/coregui/utils/GUIHelpers.cpp | 6 ++++++ GUI/coregui/utils/GUIHelpers.h | 2 ++ 7 files changed, 12 insertions(+), 15 deletions(-) diff --git a/GUI/coregui/Models/JobModel.cpp b/GUI/coregui/Models/JobModel.cpp index 1151e0d48ad..aa8f5ffc153 100644 --- a/GUI/coregui/Models/JobModel.cpp +++ b/GUI/coregui/Models/JobModel.cpp @@ -28,7 +28,6 @@ #include "RealDataItem.h" #include "SimulationOptionsItem.h" #include <QDebug> -#include <QUuid> JobModel::JobModel(QObject *parent) @@ -84,7 +83,7 @@ JobItem *JobModel::addJob(const MultiLayerItem *multiLayerItem, JobItem *jobItem = dynamic_cast<JobItem *>(insertNewItem(Constants::JobItemType)); jobItem->setItemName(generateJobName()); - jobItem->setIdentifier(generateJobIdentifier()); + jobItem->setIdentifier(GUIHelpers::createUuid()); SessionItem *multilayer = copyParameterizedItem(multiLayerItem, jobItem, JobItem::T_SAMPLE); multilayer->setItemName(Constants::MultiLayerType); @@ -195,13 +194,6 @@ QString JobModel::generateJobName() return QString("job")+QString::number(++glob_index); } - -//! generate unique job identifier -QString JobModel::generateJobIdentifier() -{ - return QUuid::createUuid().toString(); -} - void JobModel::restoreItem(SessionItem *item) { if (ParameterItem *parameter = dynamic_cast<ParameterItem*>(item)) { diff --git a/GUI/coregui/Models/JobModel.h b/GUI/coregui/Models/JobModel.h index a66c51b2e28..94b9c1f329c 100644 --- a/GUI/coregui/Models/JobModel.h +++ b/GUI/coregui/Models/JobModel.h @@ -64,7 +64,6 @@ public slots: private: QString generateJobName(); - QString generateJobIdentifier(); void restoreItem(SessionItem *item); void copyRealDataItem(JobItem *jobItem, const RealDataItem *realDataItem); void createFitContainers(JobItem *jobItem); diff --git a/GUI/coregui/Models/MaterialItem.cpp b/GUI/coregui/Models/MaterialItem.cpp index 393c0192c31..a101e7893c6 100644 --- a/GUI/coregui/Models/MaterialItem.cpp +++ b/GUI/coregui/Models/MaterialItem.cpp @@ -19,7 +19,6 @@ #include "HomogeneousMaterial.h" #include "MaterialUtils.h" #include "RefractiveIndexItem.h" -#include <QUuid> const QString MaterialItem::P_COLOR = "Color"; @@ -34,7 +33,7 @@ MaterialItem::MaterialItem() ColorProperty color; addProperty(P_COLOR, color.getVariant()); addGroupProperty(P_REFRACTIVE_INDEX, Constants::RefractiveIndexType); - addProperty(P_IDENTIFIER, QUuid::createUuid().toString()); + addProperty(P_IDENTIFIER, GUIHelpers::createUuid()); getItem(P_IDENTIFIER)->setVisible(false); } diff --git a/GUI/coregui/Models/MaterialModel.cpp b/GUI/coregui/Models/MaterialModel.cpp index fa4af2a8c2c..e24c132a2b6 100644 --- a/GUI/coregui/Models/MaterialModel.cpp +++ b/GUI/coregui/Models/MaterialModel.cpp @@ -18,8 +18,8 @@ #include "IconProvider.h" #include "MaterialUtils.h" #include "RefractiveIndexItem.h" +#include "GUIHelpers.h" #include <QDebug> -#include <QUuid> MaterialModel::MaterialModel(QObject *parent) : SessionModel(SessionXML::MaterialModelTag, parent) @@ -100,7 +100,7 @@ MaterialItem *MaterialModel::cloneMaterial(const QModelIndex &index) return nullptr; SessionItem *clonedMaterial = copyParameterizedItem(origMaterial, 0); - clonedMaterial->setItemValue(MaterialItem::P_IDENTIFIER, QUuid::createUuid().toString()); + clonedMaterial->setItemValue(MaterialItem::P_IDENTIFIER, GUIHelpers::createUuid()); clonedMaterial->setItemName(origMaterial->itemName()+" (clone)"); return dynamic_cast<MaterialItem *>(clonedMaterial); } diff --git a/GUI/coregui/Views/MaterialEditor/MaterialEditorToolBar.cpp b/GUI/coregui/Views/MaterialEditor/MaterialEditorToolBar.cpp index 99bc96f04cb..e28ca3f73ca 100644 --- a/GUI/coregui/Views/MaterialEditor/MaterialEditorToolBar.cpp +++ b/GUI/coregui/Views/MaterialEditor/MaterialEditorToolBar.cpp @@ -22,7 +22,6 @@ #include <QItemSelectionModel> #include <QListView> #include <QMenu> -#include <QUuid> #include <QVariant> namespace { diff --git a/GUI/coregui/utils/GUIHelpers.cpp b/GUI/coregui/utils/GUIHelpers.cpp index 6aafbf4bf76..513a97e9c29 100644 --- a/GUI/coregui/utils/GUIHelpers.cpp +++ b/GUI/coregui/utils/GUIHelpers.cpp @@ -23,6 +23,7 @@ #include <QDir> #include <QMessageBox> #include <QPushButton> +#include <QUuid> namespace { QMap<QString, QString> initializeCharacterMap() @@ -239,5 +240,10 @@ QStringList fromStdStrings(const std::vector<std::string> &container) return result; } +QString createUuid() +{ + return QUuid::createUuid().toString(); +} + } // namespace GUIHelpers diff --git a/GUI/coregui/utils/GUIHelpers.h b/GUI/coregui/utils/GUIHelpers.h index 3ae3cb38aea..0456704d569 100644 --- a/GUI/coregui/utils/GUIHelpers.h +++ b/GUI/coregui/utils/GUIHelpers.h @@ -78,6 +78,8 @@ template<class T, class... Ts> std::unique_ptr<T> make_unique(Ts&&... params) return std::unique_ptr<T>(new T(std::forward<Ts>(params)...)); } +BA_CORE_API_ QString createUuid(); + } // namespace GUIHelpers #endif // GUIHELPERS_H -- GitLab