diff --git a/GUI/Models/InstrumentItems.cpp b/GUI/Models/InstrumentItems.cpp index cd1ed05e8db7c22ebc139e49f8e4e12bdb3cdd81..e7ddb6f55d145a3c07ba094e5d17d23beb7507bb 100644 --- a/GUI/Models/InstrumentItems.cpp +++ b/GUI/Models/InstrumentItems.cpp @@ -30,7 +30,7 @@ #include "GUI/Models/PointwiseAxisItem.h" #include "GUI/Models/RealDataItem.h" #include "GUI/Models/TransformToDomain.h" -#include "GUI/utils/GUIHelpers.h" +#include "GUI/utils/Helpers.h" namespace { @@ -114,7 +114,7 @@ std::unique_ptr<Instrument> InstrumentItem::createInstrument() const InstrumentItem::InstrumentItem(const QString& modelType) : SessionItem(modelType) { setItemName(modelType); - addProperty(P_IDENTIFIER, GUIHelpers::createUuid())->setVisible(false); + addProperty(P_IDENTIFIER, Helpers::createUuid())->setVisible(false); } void InstrumentItem::initBackgroundGroup() diff --git a/GUI/Models/ItemFileNameUtils.cpp b/GUI/Models/ItemFileNameUtils.cpp index 793079372d1b85f638eb11c7373eb4f616127928..fdfefd09c2b6e8ad14af6c0571f82662f3b391e9 100644 --- a/GUI/Models/ItemFileNameUtils.cpp +++ b/GUI/Models/ItemFileNameUtils.cpp @@ -16,7 +16,7 @@ #include "GUI/Models/InstrumentItems.h" #include "GUI/Models/JobItem.h" #include "GUI/Models/RealDataItem.h" -#include "GUI/utils/GUIHelpers.h" +#include "GUI/utils/Helpers.h" namespace { const QString jobdata_file_prefix = "jobdata"; @@ -81,7 +81,7 @@ QStringList ItemFileNameUtils::nonXMLFileNameFilters() namespace { QString intensityDataFileName(const QString& itemName, const QString& prefix) { - QString bodyName = GUIHelpers::getValidFileName(itemName); + QString bodyName = Helpers::getValidFileName(itemName); return QString("%1_%2_0.int.gz").arg(prefix).arg(bodyName); } } // namespace diff --git a/GUI/Models/JobModel.cpp b/GUI/Models/JobModel.cpp index f93e9a79fffbab01721816d7c4281ce3077a3107..4823526419d993861ca91f200c350fe52ca230ec 100644 --- a/GUI/Models/JobModel.cpp +++ b/GUI/Models/JobModel.cpp @@ -24,7 +24,7 @@ #include "GUI/Models/ParameterTreeUtils.h" #include "GUI/Models/PointwiseAxisItem.h" #include "GUI/Models/RealDataItem.h" -#include "GUI/utils/GUIHelpers.h" +#include "GUI/utils/Helpers.h" JobModel::JobModel(QObject* parent) : SessionModel(SessionXML::JobModelTag, parent), m_queue_data(nullptr) @@ -77,7 +77,7 @@ JobItem* JobModel::addJob(const MultiLayerItem* multiLayerItem, auto jobItem = insertItem<JobItem>(); jobItem->setItemName(generateJobName()); - jobItem->setIdentifier(GUIHelpers::createUuid()); + jobItem->setIdentifier(Helpers::createUuid()); JobModelFunctions::setupJobItemSampleData(jobItem, multiLayerItem); JobModelFunctions::setupJobItemInstrument(jobItem, instrumentItem); diff --git a/GUI/Models/JobModelFunctions.cpp b/GUI/Models/JobModelFunctions.cpp index 57c0c25fb2fde3ff6bb78d4212bc196665984358..66961122de07f05d33658f178c464cea759da3fc 100644 --- a/GUI/Models/JobModelFunctions.cpp +++ b/GUI/Models/JobModelFunctions.cpp @@ -32,7 +32,7 @@ #include "GUI/Models/PointwiseAxisItem.h" #include "GUI/Models/RealDataItem.h" #include "GUI/Models/SpecularDataItem.h" -#include "GUI/utils/GUIHelpers.h" +#include "GUI/utils/Helpers.h" #include <map> namespace { @@ -102,7 +102,7 @@ void JobModelFunctions::setupJobItemInstrument(JobItem* jobItem, const Instrumen { auto copiedInstrument = jobItem->copyInstrumentIntoJob(from); copiedInstrument->setItemName(from->modelType()); - copiedInstrument->setId(GUIHelpers::createUuid()); + copiedInstrument->setId(Helpers::createUuid()); jobItem->setInstrumentName(from->itemName()); auto spec_to = dynamic_cast<SpecularInstrumentItem*>(copiedInstrument); diff --git a/GUI/Models/JobQueueData.cpp b/GUI/Models/JobQueueData.cpp index 27bc1a92e2c8626f1cbdfb61ba7791681f683baa..75719176991f19a57c9658eb68576469f96d2e4c 100644 --- a/GUI/Models/JobQueueData.cpp +++ b/GUI/Models/JobQueueData.cpp @@ -19,7 +19,7 @@ #include "GUI/Models/JobItem.h" #include "GUI/Models/JobModel.h" #include "GUI/Models/JobWorker.h" -#include "GUI/utils/GUIHelpers.h" +#include "GUI/utils/Helpers.h" #include <QThread> namespace { @@ -107,7 +107,7 @@ void JobQueueData::onStartedJob() auto jobItem = m_jobModel->getJobItemForIdentifier(worker->identifier()); jobItem->setProgress(0); jobItem->setStatus("Running"); - jobItem->setBeginTime(GUIHelpers::currentDateTime()); + jobItem->setBeginTime(Helpers::currentDateTime()); jobItem->setEndTime(QString()); } @@ -223,7 +223,7 @@ void JobQueueData::clearSimulation(const QString& identifier) void JobQueueData::processFinishedJob(JobWorker* worker, JobItem* jobItem) { - jobItem->setEndTime(GUIHelpers::currentDateTime()); + jobItem->setEndTime(Helpers::currentDateTime()); jobItem->setDuration(worker->simulationDuration()); // propagating status of runner diff --git a/GUI/Models/MaterialItem.cpp b/GUI/Models/MaterialItem.cpp index 78f6814530526bd09618d3d9ff7008cace2cda1c..c8c74fa28993f6deebdaf46cfa2fca99c72b748c 100644 --- a/GUI/Models/MaterialItem.cpp +++ b/GUI/Models/MaterialItem.cpp @@ -17,7 +17,7 @@ #include "GUI/Models/MaterialDataItems.h" #include "GUI/Models/MaterialItemUtils.h" #include "GUI/Models/VectorItem.h" -#include "GUI/utils/GUIHelpers.h" +#include "GUI/utils/Helpers.h" #include "Sample/Material/MaterialFactoryFuncs.h" namespace { @@ -40,7 +40,7 @@ MaterialItem::MaterialItem() : SessionItem(M_TYPE) addGroupProperty(P_MATERIAL_DATA, "Material data group"); addProperty<VectorItem>(P_MAGNETIZATION)->setToolTip(magnetization_tooltip); - addProperty(P_IDENTIFIER, GUIHelpers::createUuid()); + addProperty(P_IDENTIFIER, Helpers::createUuid()); getItem(P_IDENTIFIER)->setVisible(false); } diff --git a/GUI/Models/MaterialItemContainer.cpp b/GUI/Models/MaterialItemContainer.cpp index 475f739edad5db2bf7c44c07a4acada0f9ab9030..cf1c92917ab341f91cde3102620873199ad9935f 100644 --- a/GUI/Models/MaterialItemContainer.cpp +++ b/GUI/Models/MaterialItemContainer.cpp @@ -15,7 +15,7 @@ #include "GUI/Models/MaterialItemContainer.h" #include "GUI/Models/MaterialItem.h" #include "GUI/Models/SessionModel.h" -#include "GUI/utils/GUIHelpers.h" +#include "GUI/utils/Helpers.h" const QString MaterialItemContainer::T_MATERIALS = "MaterialVector"; @@ -30,7 +30,7 @@ MaterialItemContainer::MaterialItemContainer() : SessionItem(M_TYPE) MaterialItem* MaterialItemContainer::insertCopy(MaterialItem* material_item) { MaterialItem* item_copy = model()->copyItem(material_item, this, T_MATERIALS); - item_copy->setIdentifier(GUIHelpers::createUuid()); + item_copy->setIdentifier(Helpers::createUuid()); return item_copy; } diff --git a/GUI/Models/MaterialModel.cpp b/GUI/Models/MaterialModel.cpp index 3069730c27872b5b93cc66b6879fc9e97cb01a7e..351cce21e4886edf7e347cd306e30b6df199ba2d 100644 --- a/GUI/Models/MaterialModel.cpp +++ b/GUI/Models/MaterialModel.cpp @@ -15,7 +15,7 @@ #include "GUI/Models/MaterialModel.h" #include "GUI/Models/MaterialItemUtils.h" #include "GUI/Models/MaterialModelStore.h" -#include "GUI/utils/GUIHelpers.h" +#include "GUI/utils/Helpers.h" MaterialModel::MaterialModel(QObject* parent) : SessionModel(SessionXML::MaterialModelTag, parent) { @@ -83,7 +83,7 @@ MaterialItem* MaterialModel::cloneMaterial(const QModelIndex& index) return nullptr; auto clonedMaterial = copyItem(origMaterial, nullptr); - clonedMaterial->setIdentifier(GUIHelpers::createUuid()); + clonedMaterial->setIdentifier(Helpers::createUuid()); clonedMaterial->setItemName(origMaterial->itemName() + " (clone)"); return dynamic_cast<MaterialItem*>(clonedMaterial); } diff --git a/GUI/Models/MinimizerItemCatalog.cpp b/GUI/Models/MinimizerItemCatalog.cpp index 0dde13183ce9ffcbd8a4bd7fb1a12f736b78d76f..51dbd3ae98af75408aa37972a6146d7c5134b4e7 100644 --- a/GUI/Models/MinimizerItemCatalog.cpp +++ b/GUI/Models/MinimizerItemCatalog.cpp @@ -14,7 +14,7 @@ #include "GUI/Models/MinimizerItemCatalog.h" #include "Fit/Kernel/MinimizerFactory.h" -#include "GUI/utils/GUIHelpers.h" +#include "GUI/utils/Helpers.h" //! Returns ComboProperty representing list of algorithms defined for given minimizerType. @@ -31,7 +31,7 @@ QStringList MinimizerItemCatalog::algorithmNames(const QString& minimizerType) { std::vector<std::string> algos = MinimizerFactory::catalog().algorithmNames(minimizerType.toStdString()); - return GUIHelpers::fromStdStrings(algos); + return Helpers::fromStdStrings(algos); } //! Returns list of algoritm descriptions defined for given minimizer. @@ -40,5 +40,5 @@ QStringList MinimizerItemCatalog::algorithmDescriptions(const QString& minimizer { std::vector<std::string> descr = MinimizerFactory::catalog().algorithmDescriptions(minimizerType.toStdString()); - return GUIHelpers::fromStdStrings(descr); + return Helpers::fromStdStrings(descr); } diff --git a/GUI/Models/SessionModel.cpp b/GUI/Models/SessionModel.cpp index b3c2c936276604ece380fc3eeebc6e1483788d42..7a6fa6d2723c3b1a072dbd88796fff8b75269f6a 100644 --- a/GUI/Models/SessionModel.cpp +++ b/GUI/Models/SessionModel.cpp @@ -17,7 +17,7 @@ #include "GUI/Models/ItemFactory.h" #include "GUI/Models/SessionItemTags.h" #include "GUI/Models/SessionItemUtils.h" -#include "GUI/utils/GUIHelpers.h" +#include "GUI/utils/Helpers.h" #include <QFile> #include <QMimeData> #include <QtCore/QXmlStreamWriter> @@ -339,7 +339,7 @@ void SessionModel::save(const QString& filename) writer.setAutoFormatting(true); writer.writeStartDocument(); writer.writeStartElement("BornAgain"); - writer.writeAttribute("Version", GUIHelpers::getBornAgainVersionString()); + writer.writeAttribute("Version", Helpers::getBornAgainVersionString()); SessionXML::writeItemAndChildItems(&writer, m_root_item); writer.writeEndElement(); // BornAgain writer.writeEndDocument(); diff --git a/GUI/Views/FitWidgets/FitObjectiveBuilder.cpp b/GUI/Views/FitWidgets/FitObjectiveBuilder.cpp index 53673b3d9292d6719a5d0e13864d893427f1de17..d3ca391d510a23af3caf50143a0574a4498404ad 100644 --- a/GUI/Views/FitWidgets/FitObjectiveBuilder.cpp +++ b/GUI/Views/FitWidgets/FitObjectiveBuilder.cpp @@ -27,7 +27,7 @@ #include "GUI/Models/MinimizerItem.h" #include "GUI/Models/RealDataItem.h" #include "GUI/Views/FitWidgets/GUIFitObserver.h" -#include "GUI/utils/GUIHelpers.h" +#include "GUI/utils/Helpers.h" FitObjectiveBuilder::FitObjectiveBuilder(JobItem* jobItem) : m_jobItem(jobItem) { @@ -126,7 +126,7 @@ std::unique_ptr<OutputData<double>> FitObjectiveBuilder::createOutputData() cons void FitObjectiveBuilder::update_fit_parameters(const mumufit::Parameters& params) const { - QVector<double> values = GUIHelpers::fromStdVector(params.values()); + QVector<double> values = Helpers::fromStdVector(params.values()); auto fitParContainer = m_jobItem->fitParameterContainerItem(); fitParContainer->setValuesInParameterContainer(values, m_jobItem->parameterContainerItem()); diff --git a/GUI/Views/FitWidgets/FitSessionController.cpp b/GUI/Views/FitWidgets/FitSessionController.cpp index 3cac1792bccf03ad42e7c2aec170a9ca968929ed..e38795cca5832b0b3c2690ee04f4a49aeb178a8c 100644 --- a/GUI/Views/FitWidgets/FitSessionController.cpp +++ b/GUI/Views/FitWidgets/FitSessionController.cpp @@ -22,7 +22,7 @@ #include "GUI/Views/FitWidgets/FitObjectiveBuilder.h" #include "GUI/Views/FitWidgets/FitWorkerLauncher.h" #include "GUI/Views/FitWidgets/GUIFitObserver.h" -#include "GUI/utils/GUIHelpers.h" +#include "GUI/utils/Helpers.h" namespace { const bool use_fit_objective = true; @@ -126,7 +126,7 @@ void FitSessionController::onFittingStarted() m_jobItem->setStatus("Fitting"); m_jobItem->setProgress(0); - m_jobItem->setBeginTime(GUIHelpers::currentDateTime()); + m_jobItem->setBeginTime(Helpers::currentDateTime()); m_jobItem->setEndTime(QString()); m_jobItem->setDuration(0); @@ -137,7 +137,7 @@ void FitSessionController::onFittingFinished() { if (m_jobItem->getStatus() != "Failed") m_jobItem->setStatus("Completed"); - m_jobItem->setEndTime(GUIHelpers::currentDateTime()); + m_jobItem->setEndTime(Helpers::currentDateTime()); m_jobItem->setProgress(100); m_jobItem->setDuration(m_runFitManager->getDuration()); @@ -168,7 +168,7 @@ void FitSessionController::updateIterationCount(const FitProgressInfo& info) void FitSessionController::updateFitParameterValues(const FitProgressInfo& info) { - QVector<double> values = GUIHelpers::fromStdVector(info.parValues()); + QVector<double> values = Helpers::fromStdVector(info.parValues()); FitParameterContainerItem* fitParContainer = m_jobItem->fitParameterContainerItem(); fitParContainer->setValuesInParameterContainer(values, m_jobItem->parameterContainerItem()); } @@ -178,7 +178,7 @@ void FitSessionController::updateLog(const FitProgressInfo& info) QString message = QString("NCalls:%1 chi2:%2 \n").arg(info.iterationCount()).arg(info.chi2()); FitParameterContainerItem* fitParContainer = m_jobItem->fitParameterContainerItem(); int index(0); - QVector<double> values = GUIHelpers::fromStdVector(info.parValues()); + QVector<double> values = Helpers::fromStdVector(info.parValues()); for (auto item : fitParContainer->getItems(FitParameterContainerItem::T_FIT_PARAMETERS)) { if (item->getItems(FitParameterItem::T_LINK).empty()) continue; diff --git a/GUI/Views/FitWidgets/GUIFitObserver.cpp b/GUI/Views/FitWidgets/GUIFitObserver.cpp index ede23f19f36c9360516f203b548f5eea0cd57832..eee9ed3870387a986d0718b7d06fcbde5d173fdc 100644 --- a/GUI/Views/FitWidgets/GUIFitObserver.cpp +++ b/GUI/Views/FitWidgets/GUIFitObserver.cpp @@ -15,7 +15,6 @@ #include "GUI/Views/FitWidgets/GUIFitObserver.h" #include "Core/Fitting/FitObjective.h" #include "Fit/Tools/MinimizerUtils.h" -#include "GUI/utils/GUIHelpers.h" GUIFitObserver::GUIFitObserver(QObject* parent) : QObject(parent), m_block_update_plots(false), m_update_interval(1) diff --git a/GUI/Views/GUIHelpers.cpp b/GUI/Views/GUIHelpers.cpp index 18b0d41746062b202464340a33d886196e388369..5c426bdc33657ed5ff7c543a70d9272ea7c18603 100644 --- a/GUI/Views/GUIHelpers.cpp +++ b/GUI/Views/GUIHelpers.cpp @@ -2,7 +2,7 @@ // // BornAgain: simulate and fit reflection and scattering // -//! @file GUI/utils/GUIHelpers.cpp +//! @file GUI/Views/GUIHelpers.cpp //! @brief Implements GUIHelpers functions //! //! @homepage http://www.bornagainproject.org @@ -12,33 +12,13 @@ // // ************************************************************************************************ -#include "GUI/utils/GUIHelpers.h" -#include "BAVersion.h" +#include "GUI/Views/GUIHelpers.h" #include "GUI/Models/Error.h" #include <QApplication> -#include <QDateTime> -#include <QDir> +#include <QFile> #include <QMessageBox> #include <QPushButton> #include <QTextStream> -#include <QUuid> - -namespace { -QMap<QString, QString> initializeCharacterMap() -{ - QMap<QString, QString> result; - result["\\"] = "_backslash_"; - result["/"] = "_slash_"; - result["\""] = "_quote_"; - result["<"] = "_lessthan_"; - result[">"] = "_greaterthan_"; - result["|"] = "_pipe_"; - result["?"] = "_questionmark_"; - return result; -} - -const QMap<QString, QString> invalidCharacterMap = initializeCharacterMap(); -} // Anonymous namespace namespace GUIHelpers { @@ -108,123 +88,6 @@ bool okToDelete(QWidget* parent, const QString& title, const QString& text, return messageBox->clickedButton() == deleteButton; } -QString getBornAgainVersionString() -{ - return QString::fromStdString(BornAgain::GetVersionNumber()); -} - -//! Returns valid file name to be saved on disk. This name is constructed from proposed_name -//! by replacing all special characters with text representation -//! \ backslash -//! / slash -//! " quote -//! < lessthan -//! > greaterthan -//! | pipe -//! ? questionmark -QString getValidFileName(const QString& proposed_name) -{ - QString result = proposed_name; - for (auto it = invalidCharacterMap.begin(); it != invalidCharacterMap.end(); ++it) { - result.replace(it.key(), it.value()); - } - return result; -} - -//! parses version string into 3 numbers, returns true in the case of success -bool parseVersion(const QString& version, int& major_num, int& minor_num, int& patch_num) -{ - major_num = minor_num = patch_num = 0; - bool success(true); - QStringList nums = version.split("."); - if (nums.size() != 3) - return false; - - bool ok(false); - major_num = nums.at(0).toInt(&ok); - success &= ok; - minor_num = nums.at(1).toInt(&ok); - success &= ok; - patch_num = nums.at(2).toInt(&ok); - success &= ok; - - return success; -} - -int versionCode(const QString& version) -{ - int result(-1); - - int ba_major(0), ba_minor(0), ba_patch(0); - if (!parseVersion(version, ba_major, ba_minor, ba_patch)) - return result; - - result = ba_major * 10000 + ba_minor * 100 + ba_patch; - - return result; -} - -//! returns true if current BornAgain version match minimal required version -bool isVersionMatchMinimal(const QString& version, const QString& minimal_version) -{ - return versionCode(version) >= versionCode(minimal_version); -} - -//! Returns file directory from the full file path -QString fileDir(const QString& fileName) -{ - QFileInfo info(fileName); - if (info.exists()) { - return info.dir().path(); - } - return ""; -} - -//! Returns base name of file. - -QString baseName(const QString& fileName) -{ - QFileInfo info(fileName); - return info.baseName(); -} - -QString currentDateTime() -{ - return QDateTime::currentDateTime().toString("yyyy.MM.dd hh:mm:ss"); - ; -} - -// QStringList fromStdList(const std::list<std::string> &string_list) -//{ -// QStringList result; -// for(std::string str : string_list) { -// result.append(QString::fromStdString(str)); -// } -// return result; -//} - -QVector<double> fromStdVector(const std::vector<double>& data) -{ - QVector<double> result; - result.reserve(int(data.size())); - std::copy(data.begin(), data.end(), std::back_inserter(result)); - return result; -} - -QStringList fromStdStrings(const std::vector<std::string>& container) -{ - QStringList result; - for (std::string str : container) { - result.append(QString::fromStdString(str)); - } - return result; -} - -QString createUuid() -{ - return QUuid::createUuid().toString(); -} - QString readTextFile(const QString& fileName) { QFile file(fileName); diff --git a/GUI/Views/GUIHelpers.h b/GUI/Views/GUIHelpers.h index 9b1f7829caa04954704302772b1290ec2ff7f066..aa4f88c300bd6bbc6d2149179e5fb326ef61cc17 100644 --- a/GUI/Views/GUIHelpers.h +++ b/GUI/Views/GUIHelpers.h @@ -2,7 +2,7 @@ // // BornAgain: simulate and fit reflection and scattering // -//! @file GUI/utils/GUIHelpers.h +//! @file GUI/Views/GUIHelpers.h //! @brief Defines class GUIHelpers functions //! //! @homepage http://www.bornagainproject.org @@ -12,16 +12,10 @@ // // ************************************************************************************************ -#ifndef BORNAGAIN_GUI_UTILS_GUIHELPERS_H -#define BORNAGAIN_GUI_UTILS_GUIHELPERS_H +#ifndef BORNAGAIN_GUI_VIEWS_GUIHELPERS_H +#define BORNAGAIN_GUI_VIEWS_GUIHELPERS_H -#include <QStringList> #include <QWidget> -#include <memory> -#include <sstream> - -class JobItem; -class RealDataItem; namespace GUIHelpers { @@ -38,35 +32,8 @@ bool question(QWidget* parent, const QString& title, const QString& text, bool okToDelete(QWidget* parent, const QString& title, const QString& text, const QString& detailedText = ""); -QString getBornAgainVersionString(); - -QString getValidFileName(const QString& proposed_name); - -QString fileDir(const QString& fileName); -QString baseName(const QString& fileName); - -bool parseVersion(const QString& version, int& major_num, int& minor_num, int& patch_num); - -int versionCode(const QString& version); - -bool isVersionMatchMinimal(const QString& version, const QString& minimal_version); - -QString currentDateTime(); - -QStringList fromStdStrings(const std::vector<std::string>& container); - -QVector<double> fromStdVector(const std::vector<double>& data); - -QString createUuid(); - QString readTextFile(const QString& fileName); } // namespace GUIHelpers -inline std::ostream& operator<<(std::ostream& stream, const QString& str) -{ - stream << str.toStdString(); - return stream; -} - -#endif // BORNAGAIN_GUI_UTILS_GUIHELPERS_H +#endif // BORNAGAIN_GUI_VIEWS_GUIHELPERS_H diff --git a/GUI/Views/ImportDataWidgets/RealDataSelectorWidget.cpp b/GUI/Views/ImportDataWidgets/RealDataSelectorWidget.cpp index fc376b484b76fa475878ecfc23142e8f64e6c544..bc512800d1fc90d9f3bb16e9391164f01d5411a4 100644 --- a/GUI/Views/ImportDataWidgets/RealDataSelectorWidget.cpp +++ b/GUI/Views/ImportDataWidgets/RealDataSelectorWidget.cpp @@ -18,6 +18,7 @@ #include "GUI/DataLoaders/DataLoaders1D.h" #include "GUI/Models/Error.h" #include "GUI/Models/RealDataItem.h" +#include "GUI/Views/GUIHelpers.h" #include "GUI/Views/ImportDataWidgets/ImportDataUtils.h" #include "GUI/Views/ImportDataWidgets/RealDataPropertiesWidget.h" #include "GUI/Views/ImportDataWidgets/RealDataTreeModel.h" @@ -25,7 +26,6 @@ #include "GUI/mainwindow/StyledToolBar.h" #include "GUI/mainwindow/mainwindow.h" #include "GUI/mainwindow/projectmanager.h" -#include "GUI/utils/GUIHelpers.h" #include <QApplication> #include <QFileDialog> #include <QItemSelectionModel> diff --git a/GUI/Views/InfoWidgets/ProjectLoadWarningDialog.cpp b/GUI/Views/InfoWidgets/ProjectLoadWarningDialog.cpp index 0241c7f657e5d9b9e8006ac87d13d6b27a03f06b..5210d4f2ab2ab9ee17675c86e921a84b24f6f728 100644 --- a/GUI/Views/InfoWidgets/ProjectLoadWarningDialog.cpp +++ b/GUI/Views/InfoWidgets/ProjectLoadWarningDialog.cpp @@ -14,8 +14,8 @@ #include "GUI/Views/InfoWidgets/ProjectLoadWarningDialog.h" #include "GUI/Views/SampleDesigner/DesignerHelper.h" -#include "GUI/utils/GUIHelpers.h" #include "GUI/utils/GUIMessage.h" +#include "GUI/utils/Helpers.h" #include "GUI/utils/MessageService.h" #include <QBoxLayout> #include <QGridLayout> @@ -248,13 +248,13 @@ QTableWidgetItem* ProjectLoadWarningDialog::createTableItem(const QString& name) QString ProjectLoadWarningDialog::explanationText() const { QString result; - if (m_projectDocumentVersion != GUIHelpers::getBornAgainVersionString()) { + if (m_projectDocumentVersion != Helpers::getBornAgainVersionString()) { result = QString("Given project was created using BornAgain version %1 " " which is different from version %2 you are currently using. " "At the moment we provide only limited support for import from older versions.") .arg(m_projectDocumentVersion) - .arg(GUIHelpers::getBornAgainVersionString()); + .arg(Helpers::getBornAgainVersionString()); } else { result = QString("Given project was created using BornAgain version %1 " diff --git a/GUI/main/appoptions.cpp b/GUI/main/appoptions.cpp index 32d0f6d1b889e1d481886c6fadcfb0c0e53a1142..c283c0c591d80d2c392c10ec47d6901da684f9e8 100644 --- a/GUI/main/appoptions.cpp +++ b/GUI/main/appoptions.cpp @@ -13,7 +13,7 @@ // ************************************************************************************************ #include "GUI/main/appoptions.h" -#include "GUI/utils/GUIHelpers.h" +#include "GUI/utils/Helpers.h" #include <QSize> #include <boost/program_options/config.hpp> #include <boost/program_options/parsers.hpp> @@ -122,7 +122,7 @@ void ApplicationOptions::processOptions() } else if (m_variables_map.count("version")) { - std::cout << "BornAgain-" << GUIHelpers::getBornAgainVersionString().toStdString() + std::cout << "BornAgain-" << Helpers::getBornAgainVersionString().toStdString() << std::endl; m_options_is_consistent = false; } diff --git a/GUI/mainwindow/PyImportAssistant.cpp b/GUI/mainwindow/PyImportAssistant.cpp index c679c4e1de7515e410fcc595ce2425e618b51015..e4d33454babf94edc2cc9ee472020cf5f9e104cc 100644 --- a/GUI/mainwindow/PyImportAssistant.cpp +++ b/GUI/mainwindow/PyImportAssistant.cpp @@ -19,13 +19,14 @@ #include "Base/Utils/SysUtils.h" #include "GUI/Application/Application.h" #include "GUI/Models/GUIObjectBuilder.h" +#include "GUI/Views/GUIHelpers.h" #include "GUI/Views/InfoWidgets/ComboSelectorDialog.h" #include "GUI/Views/InfoWidgets/DetailedMessageBox.h" #include "GUI/mainwindow/ProjectManagerStore.h" #include "GUI/mainwindow/ProjectUtils.h" #include "GUI/mainwindow/mainwindow.h" #include "GUI/mainwindow/projectmanager.h" -#include "GUI/utils/GUIHelpers.h" +#include "GUI/utils/Helpers.h" #include "Sample/Multilayer/MultiLayer.h" #include "Sample/Multilayer/PyImport.h" #include <QApplication> @@ -86,7 +87,7 @@ void PyImportAssistant::exec() if (!multilayer) return; - populateModels(*multilayer, GUIHelpers::baseName(fileName)); + populateModels(*multilayer, Helpers::baseName(fileName)); } //! Lets user to select Python file on disk. @@ -112,7 +113,7 @@ void PyImportAssistant::saveImportDir(const QString& fileName) if (fileName.isEmpty()) return; - ProjectManagerStore::projectManager()->setImportDir(GUIHelpers::fileDir(fileName)); + ProjectManagerStore::projectManager()->setImportDir(Helpers::fileDir(fileName)); } //! Read content of text file and returns it as a multi-line string. @@ -144,7 +145,7 @@ QString PyImportAssistant::getPySampleFunctionName(const QString& snippet) QApplication::setOverrideCursor(Qt::WaitCursor); try { auto funcs = PyImport::listOfFunctions(snippet.toStdString(), bornagainDir()); - funcList = GUIHelpers::fromStdStrings(funcs); + funcList = Helpers::fromStdStrings(funcs); } catch (const std::exception& ex) { QApplication::restoreOverrideCursor(); diff --git a/GUI/mainwindow/aboutapplicationdialog.cpp b/GUI/mainwindow/aboutapplicationdialog.cpp index d9658509abced836e1299416c4aa6d8cec7a6143..2c24f5835d1ac939c7cfde888affc62c32fe05e0 100644 --- a/GUI/mainwindow/aboutapplicationdialog.cpp +++ b/GUI/mainwindow/aboutapplicationdialog.cpp @@ -15,7 +15,7 @@ #include "GUI/mainwindow/aboutapplicationdialog.h" #include "GUI/Views/SampleDesigner/DesignerHelper.h" #include "GUI/utils/CustomEventFilters.h" -#include "GUI/utils/GUIHelpers.h" +#include "GUI/utils/Helpers.h" #include <QDate> #include <QLabel> #include <QPushButton> @@ -94,7 +94,7 @@ QBoxLayout* AboutApplicationDialog::createTextLayout() // title auto aboutTitleLabel = - new QLabel("BornAgain version " + GUIHelpers::getBornAgainVersionString()); + new QLabel("BornAgain version " + Helpers::getBornAgainVersionString()); aboutTitleLabel->setFont(titleFont); // description diff --git a/GUI/mainwindow/mainwindow.cpp b/GUI/mainwindow/mainwindow.cpp index 9d297d2ed952c9bf38a301bc2f603f8d65a0ea46..c2465440d8d064dae1c30bf47f392bafd4d2a0c3 100644 --- a/GUI/mainwindow/mainwindow.cpp +++ b/GUI/mainwindow/mainwindow.cpp @@ -27,7 +27,7 @@ #include "GUI/mainwindow/mainwindow_constants.h" #include "GUI/mainwindow/projectmanager.h" #include "GUI/mainwindow/tooltipdatabase.h" -#include "GUI/utils/GUIHelpers.h" +#include "GUI/utils/Helpers.h" #include "GUI/utils/hostosinfo.h" #include <QAction> #include <QApplication> @@ -249,7 +249,7 @@ void MainWindow::closeEvent(QCloseEvent* event) void MainWindow::initApplication() { QCoreApplication::setApplicationName("BornAgain"); - QCoreApplication::setApplicationVersion(GUIHelpers::getBornAgainVersionString()); + QCoreApplication::setApplicationVersion(Helpers::getBornAgainVersionString()); QCoreApplication::setOrganizationName( "Forschungszentrum Jülich, Scientific Computing Group at MLZ Garching"); diff --git a/GUI/mainwindow/projectdocument.cpp b/GUI/mainwindow/projectdocument.cpp index 41767d443e75490c33d09a7fcc2e610e17597c6b..009c3413a9ecaf65681c8ee92dcd3df3be5e0e70 100644 --- a/GUI/mainwindow/projectdocument.cpp +++ b/GUI/mainwindow/projectdocument.cpp @@ -18,7 +18,7 @@ #include "GUI/Models/JobModel.h" #include "GUI/mainwindow/OutputDataIOService.h" #include "GUI/mainwindow/ProjectUtils.h" -#include "GUI/utils/GUIHelpers.h" +#include "GUI/utils/Helpers.h" #include "GUI/utils/MessageService.h" #include <QDir> #include <QElapsedTimer> @@ -213,7 +213,7 @@ QString ProjectDocument::documentVersion() const { QString result(m_currentVersion); if (result.isEmpty()) - result = GUIHelpers::getBornAgainVersionString(); + result = Helpers::getBornAgainVersionString(); return result; } @@ -236,8 +236,8 @@ void ProjectDocument::readProject(QIODevice* device) .value(ProjectDocumentXML::BornAgainVersionAttribute) .toString(); - if (!GUIHelpers::isVersionMatchMinimal(m_currentVersion, - minimal_supported_version)) { + if (!Helpers::isVersionMatchMinimal(m_currentVersion, + minimal_supported_version)) { ProjectFlags::setFlag(m_documentStatus, ProjectFlags::STATUS_FAILED); QString message = QString("Can't open document version '%1', " "minimal supported version '%2'") @@ -273,7 +273,7 @@ void ProjectDocument::writeTo(QIODevice* device) writer.setAutoFormatting(true); writer.writeStartDocument(); writer.writeStartElement(ProjectDocumentXML::BornAgainTag); - QString version_string = GUIHelpers::getBornAgainVersionString(); + QString version_string = Helpers::getBornAgainVersionString(); writer.writeAttribute(ProjectDocumentXML::BornAgainVersionAttribute, version_string); writer.writeStartElement(ProjectDocumentXML::InfoTag); diff --git a/GUI/mainwindow/projectmanager.cpp b/GUI/mainwindow/projectmanager.cpp index 2ae011e3a9ecdb7dc420cbbe6f6eadf9f7cbb316..42817ba876eb1fdaab61ed36768b5923f112eb7e 100644 --- a/GUI/mainwindow/projectmanager.cpp +++ b/GUI/mainwindow/projectmanager.cpp @@ -17,6 +17,7 @@ #include "GUI/Application/Application.h" #include "GUI/Models/ApplicationModels.h" #include "GUI/Models/Error.h" +#include "GUI/Views/GUIHelpers.h" #include "GUI/Views/InfoWidgets/ProjectLoadWarningDialog.h" #include "GUI/mainwindow/ProjectManagerStore.h" #include "GUI/mainwindow/ProjectUtils.h" @@ -25,7 +26,6 @@ #include "GUI/mainwindow/mainwindow_constants.h" #include "GUI/mainwindow/newprojectdialog.h" #include "GUI/mainwindow/projectdocument.h" -#include "GUI/utils/GUIHelpers.h" #include "GUI/utils/MessageService.h" #include <QApplication> #include <QDateTime> diff --git a/GUI/utils/Helpers.cpp b/GUI/utils/Helpers.cpp index 18b0d41746062b202464340a33d886196e388369..e4324789b869535381cdce1f26a05dafabbb5948 100644 --- a/GUI/utils/Helpers.cpp +++ b/GUI/utils/Helpers.cpp @@ -2,8 +2,8 @@ // // BornAgain: simulate and fit reflection and scattering // -//! @file GUI/utils/GUIHelpers.cpp -//! @brief Implements GUIHelpers functions +//! @file GUI/utils/Helpers.cpp +//! @brief Implements Helpers functions //! //! @homepage http://www.bornagainproject.org //! @license GNU General Public License v3 or higher (see COPYING) @@ -12,16 +12,14 @@ // // ************************************************************************************************ -#include "GUI/utils/GUIHelpers.h" +#include "GUI/utils/Helpers.h" #include "BAVersion.h" -#include "GUI/Models/Error.h" -#include <QApplication> #include <QDateTime> #include <QDir> -#include <QMessageBox> -#include <QPushButton> -#include <QTextStream> +#include <QFileInfo> +#include <QMap> #include <QUuid> +#include <QVector> namespace { QMap<QString, QString> initializeCharacterMap() @@ -40,73 +38,7 @@ QMap<QString, QString> initializeCharacterMap() const QMap<QString, QString> invalidCharacterMap = initializeCharacterMap(); } // Anonymous namespace -namespace GUIHelpers { - -void information(QWidget* parent, const QString& title, const QString& text, - const QString& detailedText) -{ - QScopedPointer<QMessageBox> messageBox(new QMessageBox(parent)); - if (parent) - messageBox->setWindowModality(Qt::WindowModal); - messageBox->setWindowTitle(QString("%1 - %2").arg(QApplication::applicationName()).arg(title)); - messageBox->setText(text); - if (!detailedText.isEmpty()) - messageBox->setInformativeText(detailedText); - messageBox->setIcon(QMessageBox::Information); - messageBox->addButton(QMessageBox::Ok); - messageBox->exec(); -} - -void warning(QWidget* parent, const QString& title, const QString& text, - const QString& detailedText) -{ - QScopedPointer<QMessageBox> messageBox(new QMessageBox(parent)); - if (parent) - messageBox->setWindowModality(Qt::WindowModal); - messageBox->setWindowTitle(QString("%1 - %2").arg(QApplication::applicationName()).arg(title)); - messageBox->setText(text); - if (!detailedText.isEmpty()) - messageBox->setInformativeText(detailedText); - messageBox->setIcon(QMessageBox::Warning); - messageBox->addButton(QMessageBox::Ok); - messageBox->exec(); -} - -bool question(QWidget* parent, const QString& title, const QString& text, - const QString& detailedText, const QString& yesText, const QString& noText) -{ - QScopedPointer<QMessageBox> messageBox(new QMessageBox(parent)); - if (parent) - messageBox->setWindowModality(Qt::WindowModal); - messageBox->setWindowTitle(QString("%1 - %2").arg(QApplication::applicationName()).arg(title)); - messageBox->setText(text); - if (!detailedText.isEmpty()) - messageBox->setInformativeText(detailedText); - messageBox->setIcon(QMessageBox::Question); - QAbstractButton* yesButton = messageBox->addButton(yesText, QMessageBox::AcceptRole); - messageBox->addButton(noText, QMessageBox::RejectRole); - messageBox->setDefaultButton(qobject_cast<QPushButton*>(yesButton)); - messageBox->exec(); - return messageBox->clickedButton() == yesButton; -} - -bool okToDelete(QWidget* parent, const QString& title, const QString& text, - const QString& detailedText) -{ - QScopedPointer<QMessageBox> messageBox(new QMessageBox(parent)); - if (parent) - messageBox->setWindowModality(Qt::WindowModal); - messageBox->setIcon(QMessageBox::Question); - messageBox->setWindowTitle(QString("%1 - %2").arg(QApplication::applicationName()).arg(title)); - messageBox->setText(text); - if (!detailedText.isEmpty()) - messageBox->setInformativeText(detailedText); - QAbstractButton* deleteButton = messageBox->addButton("&Delete", QMessageBox::AcceptRole); - messageBox->addButton("Do &Not Delete", QMessageBox::RejectRole); - messageBox->setDefaultButton(qobject_cast<QPushButton*>(deleteButton)); - messageBox->exec(); - return messageBox->clickedButton() == deleteButton; -} +namespace Helpers { QString getBornAgainVersionString() { @@ -194,15 +126,6 @@ QString currentDateTime() ; } -// QStringList fromStdList(const std::list<std::string> &string_list) -//{ -// QStringList result; -// for(std::string str : string_list) { -// result.append(QString::fromStdString(str)); -// } -// return result; -//} - QVector<double> fromStdVector(const std::vector<double>& data) { QVector<double> result; @@ -225,13 +148,4 @@ QString createUuid() return QUuid::createUuid().toString(); } -QString readTextFile(const QString& fileName) -{ - QFile file(fileName); - if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) - throw Error("PyImportAssistant::readFile() -> Error. Can't read file '" + fileName + "'"); - QTextStream in(&file); - return in.readAll(); -} - } // namespace GUIHelpers diff --git a/GUI/utils/Helpers.h b/GUI/utils/Helpers.h index 9b1f7829caa04954704302772b1290ec2ff7f066..c2e60999ffeac0ef83896c5609cca07833ea44c0 100644 --- a/GUI/utils/Helpers.h +++ b/GUI/utils/Helpers.h @@ -2,8 +2,8 @@ // // BornAgain: simulate and fit reflection and scattering // -//! @file GUI/utils/GUIHelpers.h -//! @brief Defines class GUIHelpers functions +//! @file GUI/utils/Helpers.h +//! @brief Defines class Helpers functions //! //! @homepage http://www.bornagainproject.org //! @license GNU General Public License v3 or higher (see COPYING) @@ -12,31 +12,14 @@ // // ************************************************************************************************ -#ifndef BORNAGAIN_GUI_UTILS_GUIHELPERS_H -#define BORNAGAIN_GUI_UTILS_GUIHELPERS_H +#ifndef BORNAGAIN_GUI_UTILS_HELPERS_H +#define BORNAGAIN_GUI_UTILS_HELPERS_H #include <QStringList> -#include <QWidget> -#include <memory> -#include <sstream> +#include <vector> +#include <ostream> -class JobItem; -class RealDataItem; - -namespace GUIHelpers { - -void information(QWidget* parent, const QString& title, const QString& text, - const QString& detailedText = ""); - -void warning(QWidget* parent, const QString& title, const QString& text, - const QString& detailedText = ""); - -bool question(QWidget* parent, const QString& title, const QString& text, - const QString& detailedText = "", const QString& yesText = "&Yes", - const QString& noText = "&No"); - -bool okToDelete(QWidget* parent, const QString& title, const QString& text, - const QString& detailedText = ""); +namespace Helpers { QString getBornAgainVersionString(); @@ -59,8 +42,6 @@ QVector<double> fromStdVector(const std::vector<double>& data); QString createUuid(); -QString readTextFile(const QString& fileName); - } // namespace GUIHelpers inline std::ostream& operator<<(std::ostream& stream, const QString& str) diff --git a/Tests/Performance/GUI/GUIPerformanceTest.cpp b/Tests/Performance/GUI/GUIPerformanceTest.cpp index 14a920cb5ddf8aae5a897077c7f39fe6b401b684..aae607dbed20501c1cf2685850d4e4fcdb6e18f5 100644 --- a/Tests/Performance/GUI/GUIPerformanceTest.cpp +++ b/Tests/Performance/GUI/GUIPerformanceTest.cpp @@ -29,7 +29,6 @@ #include "GUI/Models/ParameterTreeItems.h" #include "GUI/Models/ParameterTreeUtils.h" #include "GUI/Models/SampleModel.h" -#include "GUI/utils/GUIHelpers.h" #include "Sample/Multilayer/MultiLayer.h" #include "Sample/StandardSamples/SampleBuilderFactory.h" #include "Tests/Performance/Benchmark.h" diff --git a/Tests/UnitTests/GUI/TestGUIHelpers.cpp b/Tests/UnitTests/GUI/TestGUIHelpers.cpp deleted file mode 100644 index c05ee441f30fd13992f5cb26f7bd90557e513ed2..0000000000000000000000000000000000000000 --- a/Tests/UnitTests/GUI/TestGUIHelpers.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include "GUI/utils/GUIHelpers.h" -#include "Tests/GTestWrapper/google_test.h" - -class TestGUIHelpers : public ::testing::Test { -}; - -TEST_F(TestGUIHelpers, test_VersionString) -{ - int vmajor(0), vminor(0), vpatch(0); - - EXPECT_EQ(true, GUIHelpers::parseVersion("1.5.0", vmajor, vminor, vpatch)); - EXPECT_EQ(1, vmajor); - EXPECT_EQ(5, vminor); - EXPECT_EQ(0, vpatch); - - EXPECT_FALSE(GUIHelpers::parseVersion("15.0", vmajor, vminor, vpatch)); - - QString min_version("1.5.0"); - EXPECT_EQ(GUIHelpers::isVersionMatchMinimal("1.5.0", min_version), true); - EXPECT_EQ(GUIHelpers::isVersionMatchMinimal("1.5.1", min_version), true); - EXPECT_EQ(GUIHelpers::isVersionMatchMinimal("1.6.0", min_version), true); - EXPECT_EQ(GUIHelpers::isVersionMatchMinimal("2.4.9", min_version), true); - - EXPECT_EQ(GUIHelpers::isVersionMatchMinimal("1.4.9", min_version), false); - EXPECT_EQ(GUIHelpers::isVersionMatchMinimal("0.6.9", min_version), false); -} diff --git a/Tests/UnitTests/GUI/TestHelpers.cpp b/Tests/UnitTests/GUI/TestHelpers.cpp new file mode 100644 index 0000000000000000000000000000000000000000..63884ab0de7eefef24381e08726f3e845fa0ecf8 --- /dev/null +++ b/Tests/UnitTests/GUI/TestHelpers.cpp @@ -0,0 +1,26 @@ +#include "GUI/utils/Helpers.h" +#include "Tests/GTestWrapper/google_test.h" + +class TestHelpers : public ::testing::Test { +}; + +TEST_F(TestHelpers, test_VersionString) +{ + int vmajor(0), vminor(0), vpatch(0); + + EXPECT_EQ(true, Helpers::parseVersion("1.5.0", vmajor, vminor, vpatch)); + EXPECT_EQ(1, vmajor); + EXPECT_EQ(5, vminor); + EXPECT_EQ(0, vpatch); + + EXPECT_FALSE(Helpers::parseVersion("15.0", vmajor, vminor, vpatch)); + + QString min_version("1.5.0"); + EXPECT_TRUE(Helpers::isVersionMatchMinimal("1.5.0", min_version)); + EXPECT_TRUE(Helpers::isVersionMatchMinimal("1.5.1", min_version)); + EXPECT_TRUE(Helpers::isVersionMatchMinimal("1.6.0", min_version)); + EXPECT_TRUE(Helpers::isVersionMatchMinimal("2.4.9", min_version)); + + EXPECT_FALSE(Helpers::isVersionMatchMinimal("1.4.9", min_version)); + EXPECT_FALSE(Helpers::isVersionMatchMinimal("0.6.9", min_version)); +} diff --git a/Tests/UnitTests/GUI/TestMessageService.cpp b/Tests/UnitTests/GUI/TestMessageService.cpp index b52afe2f8d02c4b97c443bc19f58ad6ed6e87523..1093cd4ca616bb8934483d1fa83c05353a2a926a 100644 --- a/Tests/UnitTests/GUI/TestMessageService.cpp +++ b/Tests/UnitTests/GUI/TestMessageService.cpp @@ -1,4 +1,3 @@ -#include "GUI/utils/GUIHelpers.h" #include "GUI/utils/GUIMessage.h" #include "GUI/utils/MessageService.h" #include "Tests/GTestWrapper/google_test.h" diff --git a/Tests/UnitTests/GUI/TestOutputDataIOService.cpp b/Tests/UnitTests/GUI/TestOutputDataIOService.cpp index 70f7eac636e0694f1ebb6c36dca05b7bea2d9272..19334417376ed83049d0b5de7c123246cf1f89b8 100644 --- a/Tests/UnitTests/GUI/TestOutputDataIOService.cpp +++ b/Tests/UnitTests/GUI/TestOutputDataIOService.cpp @@ -11,7 +11,7 @@ #include "GUI/Models/RealDataModel.h" #include "GUI/mainwindow/OutputDataIOService.h" #include "GUI/mainwindow/ProjectUtils.h" -#include "GUI/utils/GUIHelpers.h" +#include "GUI/utils/Helpers.h" #include "GUI/utils/ImportDataInfo.h" #include "Tests/GTestWrapper/google_test.h" #include "Tests/UnitTests/GUI/Utils.h" @@ -260,7 +260,7 @@ TEST_F(TestOutputDataIOService, test_RealDataItemWithNativeData) // adding JobItem auto jobItem = models.jobModel()->insertItem<JobItem>(); - jobItem->setIdentifier(GUIHelpers::createUuid()); + jobItem->setIdentifier(Helpers::createUuid()); jobItem->setDataType<IntensityDataItem>(); EXPECT_EQ(models.jobModel()->nonXMLItems().size(), 1); diff --git a/Tests/UnitTests/GUI/TestProjectDocument.cpp b/Tests/UnitTests/GUI/TestProjectDocument.cpp index eebb8c50c0af4c4f8917919469a637d1ef6f6437..fcde7b3d07a70a2b629490d4c463a92fcad821bf 100644 --- a/Tests/UnitTests/GUI/TestProjectDocument.cpp +++ b/Tests/UnitTests/GUI/TestProjectDocument.cpp @@ -7,7 +7,7 @@ #include "GUI/Models/RealDataModel.h" #include "GUI/mainwindow/ProjectUtils.h" #include "GUI/mainwindow/projectdocument.h" -#include "GUI/utils/GUIHelpers.h" +#include "GUI/utils/Helpers.h" #include "Tests/GTestWrapper/google_test.h" #include "Tests/UnitTests/GUI/Utils.h" #include <QFileInfo> @@ -19,7 +19,7 @@ protected: void modify_models(ApplicationModels* models) { auto instrument = models->instrumentModel()->instrumentItems().front(); - instrument->setId(GUIHelpers::createUuid()); + instrument->setId(Helpers::createUuid()); } }; diff --git a/Tests/UnitTests/GUI/TestSaveService.cpp b/Tests/UnitTests/GUI/TestSaveService.cpp index 2853462fa42195114cce17e280467cfcf41d397a..845d6ff639e724e7a90b2c44a484a10b78174523 100644 --- a/Tests/UnitTests/GUI/TestSaveService.cpp +++ b/Tests/UnitTests/GUI/TestSaveService.cpp @@ -10,7 +10,7 @@ #include "GUI/mainwindow/ProjectUtils.h" #include "GUI/mainwindow/SaveService.h" #include "GUI/mainwindow/projectdocument.h" -#include "GUI/utils/GUIHelpers.h" +#include "GUI/utils/Helpers.h" #include "Tests/GTestWrapper/google_test.h" #include "Tests/UnitTests/GUI/Utils.h" #include <QSignalSpy> @@ -21,7 +21,7 @@ protected: void modify_models(ApplicationModels* models) { auto instrument = models->instrumentModel()->instrumentItems().front(); - instrument->setId(GUIHelpers::createUuid()); + instrument->setId(Helpers::createUuid()); } const int m_save_wait = 10000; }; diff --git a/Tests/UnitTests/GUI/TestSessionItem.cpp b/Tests/UnitTests/GUI/TestSessionItem.cpp index 5f53437bf6eb700f3fad9fb95e974b1c27b756db..a1178cf782a4c3dd615602cb4fe90c8520168b3a 100644 --- a/Tests/UnitTests/GUI/TestSessionItem.cpp +++ b/Tests/UnitTests/GUI/TestSessionItem.cpp @@ -1,5 +1,4 @@ #include "GUI/Models/SessionModel.h" -#include "GUI/utils/GUIHelpers.h" #include "Tests/GTestWrapper/google_test.h" #define EXPECT_ASSERT_TRIGGERED(condition) EXPECT_THROW((condition), std::runtime_error)