diff --git a/Base/Types/CloneableVector.h b/Base/Types/CloneableVector.h index c6ffff8c48aa425a604c87a21189d6227dbc1792..2e747ea2bff16013b4fd7bba62d762fc9440a721 100644 --- a/Base/Types/CloneableVector.h +++ b/Base/Types/CloneableVector.h @@ -37,9 +37,7 @@ template <class T> class CloneableVector : public std::vector<std::unique_ptr<T> public: CloneableVector() {} - CloneableVector(const CloneableVector& other) - : super() - { copyOther(other); } + CloneableVector(const CloneableVector& other) : super() { copyOther(other); } CloneableVector& operator=(const CloneableVector& other) { if (this != &other) { diff --git a/Base/Utils/FileSystemUtils.cpp b/Base/Utils/FileSystemUtils.cpp index 405984a75d608b047f86983475e24d62cb6d9d9f..7b502099ae9e5102397531a5653a087baf2b4b60 100644 --- a/Base/Utils/FileSystemUtils.cpp +++ b/Base/Utils/FileSystemUtils.cpp @@ -34,7 +34,7 @@ std::string FileSystemUtils::extensions(const std::string& path) return {}; const auto pos = name.find_first_of('.', 1); // 1: ignore any file-is-hidden dot - return pos != std::string::npos ? name.substr(pos, name.size() - pos) : std::string(); + return pos != std::string::npos ? name.substr(pos, name.size() - pos) : ""; } bool FileSystemUtils::createDirectory(const std::string& dir_name) @@ -71,9 +71,11 @@ std::vector<std::string> FileSystemUtils::filesInDirectory(const std::string& di std::string FileSystemUtils::jointPath(const std::string& path1, const std::string& path2) { - ASSERT(path1 != ""); ASSERT(path2 != ""); + if (path1 == "") + return fs::path(path2).string(); + return (fs::path(path1) / fs::path(path2)).string(); } diff --git a/Base/Utils/FileSystemUtils.h b/Base/Utils/FileSystemUtils.h index 869e2494e9254fe53aea0105469a752b64713d07..832b6629484a7474b9ceb5d717d4b8a737e412b2 100644 --- a/Base/Utils/FileSystemUtils.h +++ b/Base/Utils/FileSystemUtils.h @@ -44,7 +44,7 @@ bool createDirectories(const std::string& dir_name); //! Returns filenames of files in directory std::vector<std::string> filesInDirectory(const std::string& dir_name); -//! Returns joint path name. +//! Returns joint path name. Argument path1 may be empty, argument path2 not. std::string jointPath(const std::string& path1, const std::string& path2); //! Returns path without directory part ("Foo/Bar/Doz.int.gz" -> "Doz.int.gz") diff --git a/Core/Export/SimulationToPython.cpp b/Core/Export/SimulationToPython.cpp index 57597df2fd7942fc77b5f3604e64e26104933bdb..5a37f9069122f645e8e1f874fac26904a7b7f2f8 100644 --- a/Core/Export/SimulationToPython.cpp +++ b/Core/Export/SimulationToPython.cpp @@ -27,8 +27,8 @@ #include "Device/Beam/FootprintGauss.h" #include "Device/Beam/FootprintSquare.h" #include "Device/Detector/RectangularDetector.h" -#include "Device/ProDetector/RegionOfInterest.h" #include "Device/Detector/SphericalDetector.h" +#include "Device/ProDetector/RegionOfInterest.h" #include "Device/Resolution/ConvolutionDetectorResolution.h" #include "Device/Resolution/ResolutionFunction2DGaussian.h" #include "Device/Resolution/ScanResolution.h" diff --git a/Core/Fitting/SimDataPair.cpp b/Core/Fitting/SimDataPair.cpp index 072445a7e585556556800806c568067bf3dc5af1..03db8dc1c8e676016a01d00ef654be75f064b944 100644 --- a/Core/Fitting/SimDataPair.cpp +++ b/Core/Fitting/SimDataPair.cpp @@ -15,8 +15,8 @@ #include "Core/Fitting/SimDataPair.h" #include "Base/Math/Numeric.h" #include "Core/Scan/UnitConverter1D.h" -#include "Core/Simulation/includeSimulations.h" #include "Core/Simulation/UnitConverterUtils.h" +#include "Core/Simulation/includeSimulations.h" #include "Device/Data/DataUtils.h" namespace { diff --git a/Core/Scan/UnitConverter1D.cpp b/Core/Scan/UnitConverter1D.cpp index ac1869fd115aa8c87ee6cdc86676991a29dc34ed..b214b42d4f1b580c80a1f4fe90d5dab65454ffad 100644 --- a/Core/Scan/UnitConverter1D.cpp +++ b/Core/Scan/UnitConverter1D.cpp @@ -69,7 +69,7 @@ size_t UnitConverter1D::dimension() const double UnitConverter1D::calculateMin(size_t i_axis, Axes::Units units_type) const { - ASSERT(i_axis==0); + ASSERT(i_axis == 0); units_type = substituteDefaultUnits(units_type); if (units_type == Axes::Units::NBINS) return 0.0; @@ -79,7 +79,7 @@ double UnitConverter1D::calculateMin(size_t i_axis, Axes::Units units_type) cons double UnitConverter1D::calculateMax(size_t i_axis, Axes::Units units_type) const { - ASSERT(i_axis==0); + ASSERT(i_axis == 0); units_type = substituteDefaultUnits(units_type); auto coordinate_axis = coordinateAxis(); if (units_type == Axes::Units::NBINS) @@ -90,7 +90,7 @@ double UnitConverter1D::calculateMax(size_t i_axis, Axes::Units units_type) cons std::unique_ptr<IAxis> UnitConverter1D::createConvertedAxis(size_t i_axis, Axes::Units units) const { - ASSERT(i_axis==0); + ASSERT(i_axis == 0); units = substituteDefaultUnits(units); if (units == Axes::Units::NBINS) return std::make_unique<FixedBinAxis>(axisName(0, units), coordinateAxis()->size(), @@ -145,7 +145,7 @@ UnitConverterConvSpec* UnitConverterConvSpec::clone() const size_t UnitConverterConvSpec::axisSize(size_t i_axis) const { - ASSERT(i_axis==0); + ASSERT(i_axis == 0); return m_axis->size(); } @@ -167,7 +167,7 @@ UnitConverterConvSpec::UnitConverterConvSpec(const UnitConverterConvSpec& other) std::vector<std::map<Axes::Units, std::string>> UnitConverterConvSpec::createNameMaps() const { - return { AxisNames::specAxis }; + return {AxisNames::specAxis}; } std::function<double(double)> UnitConverterConvSpec::getTraslatorFrom(Axes::Units units_type) const @@ -221,7 +221,7 @@ UnitConverterQSpec* UnitConverterQSpec::clone() const //! Returns the size of underlying axis. size_t UnitConverterQSpec::axisSize(size_t i_axis) const { - ASSERT(i_axis==0); + ASSERT(i_axis == 0); return m_axis->size(); } @@ -245,7 +245,7 @@ UnitConverterQSpec::UnitConverterQSpec(const UnitConverterQSpec& other) //! Creates name map for axis in various units std::vector<std::map<Axes::Units, std::string>> UnitConverterQSpec::createNameMaps() const { - return { AxisNames::specAxisQ }; + return {AxisNames::specAxisQ}; } //! Returns translating functional (inv. nm --> desired units) diff --git a/Core/Simulation/SimulationFactory.cpp b/Core/Simulation/SimulationFactory.cpp index 38b75eccf9a6ea901ae937daf16c0a3e83825a1f..35e123e35e037b72b6a09a043ea43b7053b77772 100644 --- a/Core/Simulation/SimulationFactory.cpp +++ b/Core/Simulation/SimulationFactory.cpp @@ -13,8 +13,8 @@ // ************************************************************************************************ #include "Core/Simulation/SimulationFactory.h" -#include "Core/Simulation/includeSimulations.h" #include "Core/Simulation/StandardSimulations.h" +#include "Core/Simulation/includeSimulations.h" #include "Param/Base/RealParameter.h" SimulationFactory::SimulationFactory() diff --git a/Device/Detector/IDetector.cpp b/Device/Detector/IDetector.cpp index ca05526b4fb4ac530fc5f29abbcb3e63033b391f..13f2d4ca02140531a2aae30be13567f2e3cf8096 100644 --- a/Device/Detector/IDetector.cpp +++ b/Device/Detector/IDetector.cpp @@ -14,9 +14,9 @@ #include "Device/Detector/IDetector.h" #include "Base/Pixel/SimulationElement.h" +#include "Device/Detector/SimulationArea.h" #include "Device/ProDetector/DetectorMask.h" #include "Device/ProDetector/RegionOfInterest.h" -#include "Device/Detector/SimulationArea.h" #include "Device/Resolution/ConvolutionDetectorResolution.h" IDetector::IDetector() diff --git a/Device/Detector/IDetector.h b/Device/Detector/IDetector.h index 0c9eb16b4794d7ce758334f3258d27c8f2664133..24d3d5d8df6a31fea0cf208455a214033f2e600f 100644 --- a/Device/Detector/IDetector.h +++ b/Device/Detector/IDetector.h @@ -18,8 +18,8 @@ #include "Base/Types/CloneableVector.h" #include "Base/Types/ICloneable.h" -#include "Device/ProDetector/DetectionProperties.h" #include "Device/Detector/SimulationAreaIterator.h" +#include "Device/ProDetector/DetectionProperties.h" #include "Device/Unit/Axes.h" class Beam; diff --git a/Device/Detector/IDetector2D.cpp b/Device/Detector/IDetector2D.cpp index 00033b54cd4516622713d3e56c230a6994dd43e7..f25e8e6a8c5576f8726ec177eb2e397702a1b2a3 100644 --- a/Device/Detector/IDetector2D.cpp +++ b/Device/Detector/IDetector2D.cpp @@ -17,9 +17,9 @@ #include "Base/Pixel/SimulationElement.h" #include "Device/Beam/Beam.h" #include "Device/Detector/DetectorContext.h" -#include "Device/ProDetector/RegionOfInterest.h" #include "Device/Detector/SimulationArea.h" #include "Device/Mask/InfinitePlane.h" +#include "Device/ProDetector/RegionOfInterest.h" IDetector2D::IDetector2D() = default; diff --git a/Device/Detector/IDetector2D.h b/Device/Detector/IDetector2D.h index 70c118a74b988f9b56dc0edc3440e18523dbdc27..2cd34becc32e6bfa0ec5a310ab502b96397eb986 100644 --- a/Device/Detector/IDetector2D.h +++ b/Device/Detector/IDetector2D.h @@ -16,8 +16,8 @@ #ifndef BORNAGAIN_DEVICE_DETECTOR_IDETECTOR2D_H #define BORNAGAIN_DEVICE_DETECTOR_IDETECTOR2D_H -#include "Device/ProDetector/DetectorMask.h" #include "Device/Detector/IDetector.h" +#include "Device/ProDetector/DetectorMask.h" #include <memory> class Beam; diff --git a/Device/Detector/SimpleUnitConverters.cpp b/Device/Detector/SimpleUnitConverters.cpp index 0b97329b03b15c20dfabfcf35a0b21bf14fe097a..7be4f59181d46eba84fb21ac70d2436cf7fba7fa 100644 --- a/Device/Detector/SimpleUnitConverters.cpp +++ b/Device/Detector/SimpleUnitConverters.cpp @@ -18,8 +18,8 @@ #include "Base/Pixel/RectangularPixel.h" #include "Device/Beam/Beam.h" #include "Device/Detector/RectangularDetector.h" -#include "Device/ProDetector/RegionOfInterest.h" #include "Device/Detector/SphericalDetector.h" +#include "Device/ProDetector/RegionOfInterest.h" #include "Device/Unit/AxisNames.h" #include <algorithm> #include <cmath> @@ -192,7 +192,7 @@ double SphericalConverter::calculateValue(size_t i_axis, Axes::Units units_type, std::vector<std::map<Axes::Units, std::string>> SphericalConverter::createNameMaps() const { - return { AxisNames::sphericalAxis0, AxisNames::sphericalAxis1 }; + return {AxisNames::sphericalAxis0, AxisNames::sphericalAxis1}; } // ************************************************************************************************ @@ -276,7 +276,7 @@ double RectangularConverter::calculateValue(size_t i_axis, Axes::Units units_typ std::vector<std::map<Axes::Units, std::string>> RectangularConverter::createNameMaps() const { - return { AxisNames::rectangularAxis0, AxisNames::rectangularAxis1 }; + return {AxisNames::rectangularAxis0, AxisNames::rectangularAxis1}; } kvector_t RectangularConverter::normalizeToWavelength(kvector_t vector) const @@ -342,7 +342,7 @@ double OffSpecularConverter::calculateValue(size_t, Axes::Units units_type, doub std::vector<std::map<Axes::Units, std::string>> OffSpecularConverter::createNameMaps() const { - return { AxisNames::offSpecularAxis0, AxisNames::offSpecularAxis1 }; + return {AxisNames::offSpecularAxis0, AxisNames::offSpecularAxis1}; } void OffSpecularConverter::addDetectorYAxis(const IDetector2D& detector) @@ -429,7 +429,7 @@ double DepthProbeConverter::calculateValue(size_t i_axis, Axes::Units units_type std::vector<std::map<Axes::Units, std::string>> DepthProbeConverter::createNameMaps() const { - return { AxisNames::specAxis, AxisNames::sampleDepthAxis }; + return {AxisNames::specAxis, AxisNames::sampleDepthAxis}; } void DepthProbeConverter::checkUnits(Axes::Units units_type) const diff --git a/Device/Detector/SimulationArea.cpp b/Device/Detector/SimulationArea.cpp index 62f229533929263beda3abf8eed489bca514b453..1ef1531316b1f78355b398a80ee062f2a533f2f6 100644 --- a/Device/Detector/SimulationArea.cpp +++ b/Device/Detector/SimulationArea.cpp @@ -13,10 +13,10 @@ // ************************************************************************************************ #include "Device/Detector/SimulationArea.h" -#include "Device/ProDetector/DetectorMask.h" #include "Device/Detector/IDetector.h" -#include "Device/ProDetector/RegionOfInterest.h" #include "Device/Mask/Rectangle.h" +#include "Device/ProDetector/DetectorMask.h" +#include "Device/ProDetector/RegionOfInterest.h" #include <sstream> SimulationArea::SimulationArea(const IDetector* detector) : m_detector(detector), m_max_index(0) diff --git a/Device/ProDetector/RegionOfInterest.cpp b/Device/ProDetector/RegionOfInterest.cpp index b8956d0ed1d6f67df50720082ce3feb2db74682c..a6837047bcdcde6e9aec6afd96383043938db31e 100644 --- a/Device/ProDetector/RegionOfInterest.cpp +++ b/Device/ProDetector/RegionOfInterest.cpp @@ -22,7 +22,7 @@ RegionOfInterest::RegionOfInterest(const CloneableVector<IAxis>& axes, double xl double xup, double yup) : RegionOfInterest(xlow, ylow, xup, yup) { - ASSERT(axes.size()==2); + ASSERT(axes.size() == 2); initFrom(*axes[0], *axes[1]); } diff --git a/Device/ProDetector/RegionOfInterest.h b/Device/ProDetector/RegionOfInterest.h index 19b269392ec1ffab8b7078c8ebf4d123149a30bc..bc382df11102588dbcda3fd558ce651c0ddb2ddb 100644 --- a/Device/ProDetector/RegionOfInterest.h +++ b/Device/ProDetector/RegionOfInterest.h @@ -34,8 +34,8 @@ template <class T> class OutputData; class RegionOfInterest : public ICloneable { public: - RegionOfInterest(const CloneableVector<IAxis>& axes, - double xlow, double ylow, double xup, double yup); + RegionOfInterest(const CloneableVector<IAxis>& axes, double xlow, double ylow, double xup, + double yup); RegionOfInterest& operator=(const RegionOfInterest& other) = delete; RegionOfInterest* clone() const; diff --git a/Device/Unit/AxisNames.cpp b/Device/Unit/AxisNames.cpp index d687f67b087638d0ba7e5d8db0b890d7b0efe687..17a0c53eecb04061012193e593aeddd12316e2d5 100644 --- a/Device/Unit/AxisNames.cpp +++ b/Device/Unit/AxisNames.cpp @@ -19,56 +19,50 @@ namespace AxisNames { // For spherical detectors in GISAS simulations BA_DEVICE_API_ const std::map<Axes::Units, std::string> sphericalAxis0 = { - { Axes::Units::NBINS, "X [nbins]" }, - { Axes::Units::RADIANS, "phi_f [rad]" }, - { Axes::Units::DEGREES, "phi_f [deg]" }, - { Axes::Units::QSPACE, "Qy [1/nm]" }, - { Axes::Units::QXQY, "Qx [1/nm]" } }; + {Axes::Units::NBINS, "X [nbins]"}, + {Axes::Units::RADIANS, "phi_f [rad]"}, + {Axes::Units::DEGREES, "phi_f [deg]"}, + {Axes::Units::QSPACE, "Qy [1/nm]"}, + {Axes::Units::QXQY, "Qx [1/nm]"}}; BA_DEVICE_API_ const std::map<Axes::Units, std::string> sphericalAxis1 = { - { Axes::Units::NBINS, "Y [nbins]" }, - { Axes::Units::RADIANS, "alpha_f [rad]" }, - { Axes::Units::DEGREES, "alpha_f [deg]" }, - { Axes::Units::QSPACE, "Qz [1/nm]" }, - { Axes::Units::QXQY, "Qy [1/nm]" } }; + {Axes::Units::NBINS, "Y [nbins]"}, + {Axes::Units::RADIANS, "alpha_f [rad]"}, + {Axes::Units::DEGREES, "alpha_f [deg]"}, + {Axes::Units::QSPACE, "Qz [1/nm]"}, + {Axes::Units::QXQY, "Qy [1/nm]"}}; // For rectangular detectors in GISAS simulations BA_DEVICE_API_ const std::map<Axes::Units, std::string> rectangularAxis0 = { - { Axes::Units::NBINS, "X [nbins]" }, - { Axes::Units::RADIANS, "phi_f [rad]" }, - { Axes::Units::DEGREES, "phi_f [deg]" }, - { Axes::Units::MM, "X [mm]" }, - { Axes::Units::QSPACE, "Qy [1/nm]" }, - { Axes::Units::QXQY, "Qx [1/nm]" } }; + {Axes::Units::NBINS, "X [nbins]"}, {Axes::Units::RADIANS, "phi_f [rad]"}, + {Axes::Units::DEGREES, "phi_f [deg]"}, {Axes::Units::MM, "X [mm]"}, + {Axes::Units::QSPACE, "Qy [1/nm]"}, {Axes::Units::QXQY, "Qx [1/nm]"}}; BA_DEVICE_API_ const std::map<Axes::Units, std::string> rectangularAxis1 = { - { Axes::Units::NBINS, "Y [nbins]" }, - { Axes::Units::RADIANS, "alpha_f [rad]" }, - { Axes::Units::DEGREES, "alpha_f [deg]" }, - { Axes::Units::MM, "Y [mm]" }, - { Axes::Units::QSPACE, "Qz [1/nm]" }, - { Axes::Units::QXQY, "Qy [1/nm]" } }; + {Axes::Units::NBINS, "Y [nbins]"}, {Axes::Units::RADIANS, "alpha_f [rad]"}, + {Axes::Units::DEGREES, "alpha_f [deg]"}, {Axes::Units::MM, "Y [mm]"}, + {Axes::Units::QSPACE, "Qz [1/nm]"}, {Axes::Units::QXQY, "Qy [1/nm]"}}; // For off-specular simulations (both spherical and rectangular detectors) // Currently 'mm' is not supported for the y-axis BA_DEVICE_API_ const std::map<Axes::Units, std::string> offSpecularAxis0 = { - { Axes::Units::NBINS, "X [nbins]" }, - { Axes::Units::RADIANS, "alpha_i [rad]" }, - { Axes::Units::DEGREES, "alpha_i [deg]" }}; + {Axes::Units::NBINS, "X [nbins]"}, + {Axes::Units::RADIANS, "alpha_i [rad]"}, + {Axes::Units::DEGREES, "alpha_i [deg]"}}; BA_DEVICE_API_ const std::map<Axes::Units, std::string> offSpecularAxis1 = { - { Axes::Units::NBINS, "Y [nbins]" }, - { Axes::Units::RADIANS, "alpha_f [rad]" }, - { Axes::Units::DEGREES, "alpha_f [deg]" }}; + {Axes::Units::NBINS, "Y [nbins]"}, + {Axes::Units::RADIANS, "alpha_f [rad]"}, + {Axes::Units::DEGREES, "alpha_f [deg]"}}; BA_DEVICE_API_ const std::map<Axes::Units, std::string> specAxis = { - { Axes::Units::NBINS, "X [nbins]" }, - { Axes::Units::RADIANS, "alpha_i [rad]" }, - { Axes::Units::DEGREES, "alpha_i [deg]" }, - { Axes::Units::QSPACE, "Q [1/nm]" }, - { Axes::Units::RQ4, "Q [1/nm]" } }; + {Axes::Units::NBINS, "X [nbins]"}, + {Axes::Units::RADIANS, "alpha_i [rad]"}, + {Axes::Units::DEGREES, "alpha_i [deg]"}, + {Axes::Units::QSPACE, "Q [1/nm]"}, + {Axes::Units::RQ4, "Q [1/nm]"}}; BA_DEVICE_API_ const std::map<Axes::Units, std::string> specAxisQ = { - { Axes::Units::NBINS, "X [nbins]" }, - { Axes::Units::QSPACE, "Q [1/nm]" }, - { Axes::Units::RQ4, "Q [1/nm]" } }; + {Axes::Units::NBINS, "X [nbins]"}, + {Axes::Units::QSPACE, "Q [1/nm]"}, + {Axes::Units::RQ4, "Q [1/nm]"}}; // corner case: axis corresponding to the position // across sample is accepts only bins and nanometers, @@ -78,9 +72,9 @@ BA_DEVICE_API_ const std::map<Axes::Units, std::string> specAxisQ = { // nanometers except for bins. BA_DEVICE_API_ const std::map<Axes::Units, std::string> sampleDepthAxis = { - { Axes::Units::NBINS, "Y [nbins]" }, - { Axes::Units::RADIANS, "Position [nm]" }, - { Axes::Units::DEGREES, "Position [nm]" }, - { Axes::Units::QSPACE, "Position [nm]" } }; + {Axes::Units::NBINS, "Y [nbins]"}, + {Axes::Units::RADIANS, "Position [nm]"}, + {Axes::Units::DEGREES, "Position [nm]"}, + {Axes::Units::QSPACE, "Position [nm]"}}; } // namespace AxisNames diff --git a/GUI/coregui/DataLoaders/QREDataLoader.cpp b/GUI/coregui/DataLoaders/QREDataLoader.cpp index c8738653f7179585799cad3ddbe11758b850d115..6a6ed28972c9cc84a0338dc6844c0599ff6dd4e6 100644 --- a/GUI/coregui/DataLoaders/QREDataLoader.cpp +++ b/GUI/coregui/DataLoaders/QREDataLoader.cpp @@ -333,9 +333,8 @@ void QREDataLoader::guessSettings() continue; int endOfGap = startOfGap; - while (endOfGap < line.size() && !belongsToNumber(line[endOfGap])) { + while (endOfGap < line.size() && !belongsToNumber(line[endOfGap])) endOfGap++; - } QStringRef gapContent(&line, startOfGap, endOfGap - startOfGap); if (gapContent.isEmpty()) diff --git a/GUI/coregui/DataLoaders/QREDataLoader.h b/GUI/coregui/DataLoaders/QREDataLoader.h index 112dab4c05a6d836e3019afba7042a977589db38..ce7aefd51365af894d55dd824d9e755c46dd8862 100644 --- a/GUI/coregui/DataLoaders/QREDataLoader.h +++ b/GUI/coregui/DataLoaders/QREDataLoader.h @@ -22,7 +22,9 @@ class QString; class QREDataLoaderProperties; -//! Real data loader for Q/R/E reflectometry CSV files +//! Loader for experimental reflectometry CSV files that contain +//! three columns with Q,R,E, namely +//! Q = wavenumber, R = reflectivity, E = error of R. class QREDataLoader : public AbstractDataLoader1D { public: @@ -53,10 +55,10 @@ private: enum class UnitInFile { none, perNanoMeter, perAngstrom, other }; struct ColumnDefinition { - bool enabled; //< shall data type be used - int column; //< read the value from this raw column - UnitInFile unit; //< the unit of the data in the file - double factor; //< in case the raw data shall be multiplied + bool enabled; //!< shall data type be used + int column; //!< read the value from this raw column + UnitInFile unit; //!< the unit of the data in the file + double factor; //!< in case the raw data shall be multiplied bool operator==(const ColumnDefinition& other) const; }; diff --git a/GUI/coregui/Models/DataItem.cpp b/GUI/coregui/Models/DataItem.cpp index 477c8359a65a8e7c685870c37c485f101983cefa..a8adfc09de47d03f8f30c59f5a76a9bd87f9c14f 100644 --- a/GUI/coregui/Models/DataItem.cpp +++ b/GUI/coregui/Models/DataItem.cpp @@ -57,7 +57,7 @@ bool DataItem::containsNonXMLData() const return static_cast<bool>(m_data); } -bool DataItem::load(const QString& projectDir) +bool DataItem::loadData(const QString& projectDir) { QString filename = fileName(projectDir); auto data = IntensityDataIOFactory::readOutputData(filename.toStdString()); @@ -67,7 +67,7 @@ bool DataItem::load(const QString& projectDir) return true; } -bool DataItem::save(const QString& projectDir) +bool DataItem::saveData(const QString& projectDir) { if (!containsNonXMLData()) return false; diff --git a/GUI/coregui/Models/DataItem.h b/GUI/coregui/Models/DataItem.h index 107f1014a7d3ceefa4baee4cc99529a344e6764c..2166def5a61b30509df90ef9217b5937ef996800 100644 --- a/GUI/coregui/Models/DataItem.h +++ b/GUI/coregui/Models/DataItem.h @@ -51,8 +51,8 @@ public: void setFileName(const QString& filename); QDateTime lastModified() const override; bool containsNonXMLData() const override; - bool load(const QString& projectDir) override; - bool save(const QString& projectDir) override; + bool loadData(const QString& projectDir) override; + bool saveData(const QString& projectDir) override; void setLastModified(const QDateTime& dtime); diff --git a/GUI/coregui/Models/DataProperties.cpp b/GUI/coregui/Models/DataProperties.cpp index 426810fd5e8945602d07c211c5c5e26855dedeb8..58e21b018fd8c8705957fc8a3baf2417d13173d1 100644 --- a/GUI/coregui/Models/DataProperties.cpp +++ b/GUI/coregui/Models/DataProperties.cpp @@ -43,7 +43,7 @@ const QString DataProperties::P_DATALINK = "data link"; DataProperties::DataProperties(const QString& model_type) : SessionItem(model_type) { - addProperty(P_DATALINK, ""); + addProperty(P_DATALINK, QString()); } void DataProperties::setDataItem(DataItem* item) diff --git a/GUI/coregui/Models/FitParameterItems.cpp b/GUI/coregui/Models/FitParameterItems.cpp index b16e65c9f6952b3354ff6e00ff5e361f1c4f065e..328ab0833cf36d1f7ff3b189bc665eb18bf2ccc7 100644 --- a/GUI/coregui/Models/FitParameterItems.cpp +++ b/GUI/coregui/Models/FitParameterItems.cpp @@ -52,8 +52,8 @@ const QString FitParameterLinkItem::P_DOMAIN = "Domain"; FitParameterLinkItem::FitParameterLinkItem() : SessionItem("FitParameterLink") { - addProperty(P_LINK, ""); - addProperty(P_DOMAIN, ""); + addProperty(P_LINK, QString()); + addProperty(P_DOMAIN, QString()); } // ---------------------------------------------------------------------------- diff --git a/GUI/coregui/Models/ParameterTreeItems.cpp b/GUI/coregui/Models/ParameterTreeItems.cpp index e59cc420606c9045b54f82d83a4ee217206fae69..1cb7f076e859bd3346f8658c67dc8497e4ef4372 100644 --- a/GUI/coregui/Models/ParameterTreeItems.cpp +++ b/GUI/coregui/Models/ParameterTreeItems.cpp @@ -34,11 +34,11 @@ const QString ParameterItem::P_DOMAIN = "Domain"; ParameterItem::ParameterItem() : SessionItem("Parameter") { // Link to original PropertyItem in one of components of MultiLayerItem or InstrumentItem - addProperty(P_LINK, ""); + addProperty(P_LINK, QString()); // The back up value of PropertyItem to be able to reset parameter tuning tree to initial state addProperty(P_BACKUP, 0.0); // The domain name of corresponding ISampleNode's registered parameter - addProperty(P_DOMAIN, ""); + addProperty(P_DOMAIN, QString()); } // ---------------------------------------------------------------------------- diff --git a/GUI/coregui/Models/PointwiseAxisItem.cpp b/GUI/coregui/Models/PointwiseAxisItem.cpp index 4804a9abbd0fa25b9c86d230c9c1164a654911fb..5f040fbc8e181c905750d2eb1275ef835fb01d9f 100644 --- a/GUI/coregui/Models/PointwiseAxisItem.cpp +++ b/GUI/coregui/Models/PointwiseAxisItem.cpp @@ -76,7 +76,7 @@ std::unique_ptr<IAxis> PointwiseAxisItem::createAxis(double scale) const return std::make_unique<PointwiseAxis>(converted_axis->getName(), std::move(centers)); } -bool PointwiseAxisItem::load(const QString& projectDir) +bool PointwiseAxisItem::loadData(const QString& projectDir) { QString filename = SaveLoadInterface::fileName(projectDir); auto data = IntensityDataIOFactory::readOutputData(filename.toStdString()); @@ -89,7 +89,7 @@ bool PointwiseAxisItem::load(const QString& projectDir) return true; } -bool PointwiseAxisItem::save(const QString& projectDir) +bool PointwiseAxisItem::saveData(const QString& projectDir) { if (!containsNonXMLData()) return false; diff --git a/GUI/coregui/Models/PointwiseAxisItem.h b/GUI/coregui/Models/PointwiseAxisItem.h index 878d7876b6057d35be478013048c41f644d76d91..0e9171ebefc73eab373a828fe3c2cb54c36d679b 100644 --- a/GUI/coregui/Models/PointwiseAxisItem.h +++ b/GUI/coregui/Models/PointwiseAxisItem.h @@ -45,8 +45,8 @@ public: void updateIndicators(); private: - bool load(const QString& projectDir) override; - bool save(const QString& projectDir) override; + bool loadData(const QString& projectDir) override; + bool saveData(const QString& projectDir) override; void setLastModified(const QDateTime& dtime); bool checkValidity() const; diff --git a/GUI/coregui/Models/RealDataItem.cpp b/GUI/coregui/Models/RealDataItem.cpp index 70a341f4d9b21d3a7145cde1947e01d963ed4e5e..67b9146d7ae54b59caa755080c83640ae6dfc06a 100644 --- a/GUI/coregui/Models/RealDataItem.cpp +++ b/GUI/coregui/Models/RealDataItem.cpp @@ -170,19 +170,18 @@ void RealDataItem::setNativeOutputData(OutputData<double>* data) nativeData()->setOutputData(data); // takes ownership of odata } -//! Creates data item if not existing so far. Checks for rank compatibility if already existing. No -//! further initialization like clearing the data etc. +//! Creates data item if not existing so far. +//! Checks for rank compatibility if already existing. +//! No further initialization (like clearing the data etc). void RealDataItem::initDataItem(size_t rank, const QString& tag) { ASSERT(rank <= 2 && rank > 0); - auto data_item = getItem(tag); + const SessionItem* data_item = getItem(tag); if (data_item != nullptr) { - const bool rankMismatch = (rank == 1 && !data_item->is<SpecularDataItem>()) - || (rank == 2 && !data_item->is<IntensityDataItem>()); - - if (rankMismatch) + if ((rank == 1 && !data_item->is<SpecularDataItem>()) + || (rank == 2 && !data_item->is<IntensityDataItem>())) throw GUIHelpers::Error("Error in RealDataItem::initDataItem: trying to set data " "incompatible with underlying data item"); } else { @@ -208,22 +207,21 @@ void RealDataItem::setOutputData(OutputData<double>* data) } //! Sets imported data to underlying item. Creates it if not existing. -//! This is used for 1-D import (2-D only using setOutputData). BUT: This last -//! statement seems wrong - in the unit tests it is used for 2D import +//! This is used for 1D import. For 2D import, use setOutputData. -void RealDataItem::setImportData(ImportDataInfo data) +void RealDataItem::setImportData(ImportDataInfo info) { - if (!data) + if (!info) return; - const size_t data_rank = data.dataRank(); + const size_t data_rank = info.dataRank(); initDataItem(data_rank, T_INTENSITY_DATA); initDataItem(data_rank, T_NATIVE_DATA); - QString units_name = data.unitsLabel(); - auto output_data = data.intensityData(); + QString units_name = info.unitsLabel(); + auto output_data = info.clonedData(); - dataItem()->reset(std::move(data)); + dataItem()->reset(std::move(info)); setNativeDataUnits(units_name); item<DataItem>(T_NATIVE_DATA)->setOutputData(output_data.release()); } diff --git a/GUI/coregui/Models/TransformFromDomain.cpp b/GUI/coregui/Models/TransformFromDomain.cpp index ac6fb583e852cc4594bf36466fc84319462f76f8..fbd3dbb7775be889e05788c24671ffc41f9dc752 100644 --- a/GUI/coregui/Models/TransformFromDomain.cpp +++ b/GUI/coregui/Models/TransformFromDomain.cpp @@ -22,13 +22,13 @@ #include "Device/Beam/FootprintGauss.h" #include "Device/Beam/FootprintSquare.h" #include "Device/Detector/RectangularDetector.h" -#include "Device/ProDetector/RegionOfInterest.h" #include "Device/Detector/SphericalDetector.h" #include "Device/Mask/Ellipse.h" #include "Device/Mask/InfinitePlane.h" #include "Device/Mask/Line.h" #include "Device/Mask/Polygon.h" #include "Device/Mask/Rectangle.h" +#include "Device/ProDetector/RegionOfInterest.h" #include "Device/Resolution/ConvolutionDetectorResolution.h" #include "Device/Resolution/ResolutionFunction2DGaussian.h" #include "Device/Resolution/ScanResolution.h" diff --git a/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvImportTable.h b/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvImportTable.h index e2358424f23a88c7ca5fe4831bdac7629649aa88..28ec4507d30191fcc87f9a501c8c3e8db19a2a23 100644 --- a/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvImportTable.h +++ b/GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvImportTable.h @@ -17,8 +17,8 @@ #include "GUI/coregui/Views/ImportDataWidgets/CsvImportAssistant/CsvDataColumn.h" #include <QTableWidget> -#include <set> #include <memory> +#include <set> class CsvImportData : public QObject { public: diff --git a/GUI/coregui/Views/ImportDataWidgets/ImportDataUtils.cpp b/GUI/coregui/Views/ImportDataWidgets/ImportDataUtils.cpp index 4e946d87de1250e146583a621618244d694db6f6..09233b697186fcccbf235b7ad8e75957d8f034a9 100644 --- a/GUI/coregui/Views/ImportDataWidgets/ImportDataUtils.cpp +++ b/GUI/coregui/Views/ImportDataWidgets/ImportDataUtils.cpp @@ -53,9 +53,9 @@ int rank(const InstrumentItem& item) //! Allocates OutputData, and returns owning pointer. //! Currently used for all 2D, and some 1D data files. -std::unique_ptr<OutputData<double>> ImportKnownData( - const QString& fileName, - IntensityDataIOFactory::LoaderSelector loader = IntensityDataIOFactory::automatic) +std::unique_ptr<OutputData<double>> +ImportKnownData(const QString& fileName, + IntensityDataIOFactory::LoaderSelector loader = IntensityDataIOFactory::automatic) { // Try to use the canonical tools for importing data std::unique_ptr<OutputData<double>> result; @@ -152,8 +152,7 @@ bool ImportDataUtils::Compatible(const InstrumentItem& instrumentItem, return rank(instrumentItem) == rank(realDataItem); } -std::unique_ptr<OutputData<double>> -ImportDataUtils::binifyAxes(const OutputData<double>& data) +std::unique_ptr<OutputData<double>> ImportDataUtils::binifyAxes(const OutputData<double>& data) { std::unique_ptr<OutputData<double>> result(new OutputData<double>); for (size_t i = 0; i < data.rank(); ++i) { diff --git a/GUI/coregui/Views/ImportDataWidgets/RealDataSelectorWidget.cpp b/GUI/coregui/Views/ImportDataWidgets/RealDataSelectorWidget.cpp index 44164eb00c027e2aed14847c724a65969cb9c024..4609c658e2bf960d4b8152a8a4825318119bd60c 100644 --- a/GUI/coregui/Views/ImportDataWidgets/RealDataSelectorWidget.cpp +++ b/GUI/coregui/Views/ImportDataWidgets/RealDataSelectorWidget.cpp @@ -230,7 +230,7 @@ void RealDataSelectorWidget::importData1D() const AbstractDataLoader* selectedLoader = loaderOfFilter.value(selectedFilter, nullptr); for (const auto& fileName : fileNames) { - auto realDataItem = m_itemTreeModel->insertSpecularDataItem(); + RealDataItem* realDataItem = m_itemTreeModel->insertSpecularDataItem(); realDataItem->setName(QFileInfo(fileName).baseName()); realDataItem->setNativeFileName(fileName); @@ -239,7 +239,6 @@ void RealDataSelectorWidget::importData1D() setCurrentItem(realDataItem); else { m_itemTreeModel->removeItem(realDataItem); - GUIHelpers::warning("File import", QString("The file '%1' could not be imported.") .arg(QDir::toNativeSeparators(fileName)), @@ -272,7 +271,6 @@ void RealDataSelectorWidget::importData2D() const QStringList fileNames = QFileDialog::getOpenFileNames(Q_NULLPTR, "Open Intensity Files", dirname, filters, &selectedFilter, QFileDialog::DontUseNativeDialog); - if (fileNames.isEmpty()) return; @@ -285,27 +283,25 @@ void RealDataSelectorWidget::importData2D() for (const auto& fileName : fileNames) { std::unique_ptr<OutputData<double>> data = ImportDataUtils::Import2dData(fileName, selectedLoader); + if (!data) + continue; + RealDataItem* realDataItem = m_itemTreeModel->insertIntensityDataItem(); + realDataItem->setName(QFileInfo(fileName).baseName()); - if (data) { - - auto realDataItem = m_itemTreeModel->insertIntensityDataItem(); - realDataItem->setName(QFileInfo(fileName).baseName()); - - try { - if (data->rank() != 2) - throw GUIHelpers::Error( - "The content could not be interpreted correctly as 2-dimensional."); + try { + if (data->rank() != 2) + throw GUIHelpers::Error( + "The content could not be interpreted correctly as 2-dimensional."); - realDataItem->setOutputData(data.release()); - setCurrentItem(realDataItem); - } catch (std::exception& ex) { - m_itemTreeModel->removeItem(realDataItem); + realDataItem->setOutputData(data.release()); + setCurrentItem(realDataItem); + } catch (std::exception& ex) { + m_itemTreeModel->removeItem(realDataItem); - const QString message = QString("Error while trying to read file\n\n'%1'\n\n%2") - .arg(fileName) - .arg(QString::fromStdString(std::string(ex.what()))); - GUIHelpers::warning("File import", message); - } + const QString message = QString("Error while trying to read file\n\n'%1'\n\n%2") + .arg(fileName) + .arg(QString::fromStdString(std::string(ex.what()))); + GUIHelpers::warning("File import", message); } } } diff --git a/GUI/coregui/Views/MaskWidgets/MaskResultsPresenter.cpp b/GUI/coregui/Views/MaskWidgets/MaskResultsPresenter.cpp index a3f62c9e815d00a4c423a8b1b346a867bf7c16e5..9a5214ba867b88ee1e712a45fc8a0f295fb235b0 100644 --- a/GUI/coregui/Views/MaskWidgets/MaskResultsPresenter.cpp +++ b/GUI/coregui/Views/MaskWidgets/MaskResultsPresenter.cpp @@ -99,8 +99,8 @@ OutputData<double>* MaskResultsPresenter::createMaskPresentation() const double ylow = maskItem->getItemValue(RectangleItem::P_YLOW).toDouble(); double xup = maskItem->getItemValue(RectangleItem::P_XUP).toDouble(); double yup = maskItem->getItemValue(RectangleItem::P_YUP).toDouble(); - roi.reset(new RegionOfInterest(m_intensityDataItem->getOutputData()->axes(), - xlow, ylow, xup, yup)); + roi.reset(new RegionOfInterest(m_intensityDataItem->getOutputData()->axes(), xlow, + ylow, xup, yup)); } else { std::unique_ptr<IShape2D> shape(maskItem->createShape()); bool mask_value = maskItem->getItemValue(MaskItem::P_MASK_VALUE).toBool(); diff --git a/GUI/coregui/mainwindow/OutputDataIOService.cpp b/GUI/coregui/mainwindow/OutputDataIOService.cpp index fbd7315866cd3aabde417d5d080c461e3ea5ff01..0010a582214fee80cf265d5c2e42184f90cf6b55 100644 --- a/GUI/coregui/mainwindow/OutputDataIOService.cpp +++ b/GUI/coregui/mainwindow/OutputDataIOService.cpp @@ -50,9 +50,9 @@ void OutputDataIOService::save(const QString& projectDir) OutputDataDirHistory newHistory; - for (auto item : nonXMLItems()) { + for (SaveLoadInterface* item : dataInterfaces()) { if (m_history.wasModifiedSinceLastSave(projectDir, item)) - item->save(projectDir); + item->saveData(projectDir); newHistory.markAsSaved(item); } @@ -65,13 +65,13 @@ void OutputDataIOService::save(const QString& projectDir) m_history.setHistory(projectDir, newHistory); } -void OutputDataIOService::load(const QString& projectDir, MessageService* messageService) +void OutputDataIOService::loadDataFiles(const QString& projectDir, MessageService* messageService) { OutputDataDirHistory newHistory; - for (auto item : nonXMLItems()) { + for (SaveLoadInterface* item : dataInterfaces()) { try { - item->load(projectDir); + item->loadData(projectDir); newHistory.markAsSaved(item); // handling crash of GUI during job run and non-existing file if (auto jobItem = parentJobItem(item)) { @@ -88,10 +88,9 @@ void OutputDataIOService::load(const QString& projectDir, MessageService* messag QString("Load of the data from disk failed with '%1'").arg(QString(ex.what()))); jobItem->setStatus("Failed"); } - if (messageService) - messageService->send_warning(this, QString(ex.what())); - else + if (!messageService) throw ex; + messageService->send_warning(this, QString(ex.what())); } } m_history.setHistory(projectDir, newHistory); @@ -99,7 +98,7 @@ void OutputDataIOService::load(const QString& projectDir, MessageService* messag //! Returns all non-XML items available for save/load. -QVector<SaveLoadInterface*> OutputDataIOService::nonXMLItems() const +QVector<SaveLoadInterface*> OutputDataIOService::dataInterfaces() const { QVector<SaveLoadInterface*> result; diff --git a/GUI/coregui/mainwindow/OutputDataIOService.h b/GUI/coregui/mainwindow/OutputDataIOService.h index 39bd9fe7f76f25bba60ec4d5a36922ff4cbd7c78..252816e74dc687fe9f739084a49d8d9139fca494 100644 --- a/GUI/coregui/mainwindow/OutputDataIOService.h +++ b/GUI/coregui/mainwindow/OutputDataIOService.h @@ -37,9 +37,9 @@ public: void save(const QString& projectDir); - void load(const QString& projectDir, MessageService* messageService = nullptr); + void loadDataFiles(const QString& projectDir, MessageService* messageService = nullptr); - QVector<SaveLoadInterface*> nonXMLItems() const; + QVector<SaveLoadInterface*> dataInterfaces() const; private: void cleanOldFiles(const QString& projectDir, const QStringList& oldSaves, diff --git a/GUI/coregui/mainwindow/PyImportAssistant.cpp b/GUI/coregui/mainwindow/PyImportAssistant.cpp index fcc45fe7a8d55434ac4161de6991e310ce89707b..d625859c1136b93a18fa158184cc7ada4a61c17b 100644 --- a/GUI/coregui/mainwindow/PyImportAssistant.cpp +++ b/GUI/coregui/mainwindow/PyImportAssistant.cpp @@ -40,7 +40,7 @@ namespace { std::string bornagainDir() { std::string pythonPath = SysUtils::getenv("PYTHONPATH"); - return pythonPath.empty() ? BABuild::buildLibDir() : std::string(); + return pythonPath.empty() ? BABuild::buildLibDir() : ""; } //! Returns a name from the list which looks like a function name intended for sample diff --git a/GUI/coregui/mainwindow/SaveLoadInterface.cpp b/GUI/coregui/mainwindow/SaveLoadInterface.cpp index 84531282ef7a5d01b035f7848b666f065acc1579..34d78ad8d48f6187d35dcae86eedc823ae9ee692 100644 --- a/GUI/coregui/mainwindow/SaveLoadInterface.cpp +++ b/GUI/coregui/mainwindow/SaveLoadInterface.cpp @@ -13,11 +13,10 @@ // ************************************************************************************************ #include "GUI/coregui/mainwindow/SaveLoadInterface.h" - -SaveLoadInterface::~SaveLoadInterface() = default; +#include "Base/Utils/FileSystemUtils.h" QString SaveLoadInterface::fileName(const QString& projectDir) const { - const auto filename = fileName(); - return projectDir.isEmpty() ? filename : projectDir + "/" + filename; + return QString::fromStdString( + FileSystemUtils::jointPath(projectDir.toStdString(), fileName().toStdString())); } diff --git a/GUI/coregui/mainwindow/SaveLoadInterface.h b/GUI/coregui/mainwindow/SaveLoadInterface.h index 795c4d445e0b6c9201f0018158a96aa97e60b847..a18f74ee0e360c36e2a2e7ed6c913c72095c8a00 100644 --- a/GUI/coregui/mainwindow/SaveLoadInterface.h +++ b/GUI/coregui/mainwindow/SaveLoadInterface.h @@ -18,20 +18,19 @@ #include <QDateTime> #include <QString> -//! Purely virtual interface to handle non-XML -//! data save and load. +//! Abstract base class to handle non-XML data save and load. + +//! Inherited (mix-in) by DataItem and PointwiseAxisItem. class SaveLoadInterface { public: - virtual ~SaveLoadInterface(); + virtual ~SaveLoadInterface() = default; - //! Loads non-XML data from _projectDir_ and returns - //! success flag. - virtual bool load(const QString& projectDir) = 0; + //! Loads non-XML data from _projectDir_ and returns success flag. + virtual bool loadData(const QString& projectDir) = 0; - //! Saves non-XML data in _projectDir_ and returns - //! success flag. - virtual bool save(const QString& projectDir) = 0; + //! Saves non-XML data in _projectDir_ and returns success flag. + virtual bool saveData(const QString& projectDir) = 0; //! Checks if object owns non-XML data virtual bool containsNonXMLData() const = 0; @@ -42,8 +41,7 @@ public: //! Reports file name to save/load non-XML data. virtual QString fileName() const = 0; - //! Reports file name to save/load non-XML data with directory - //! name attached. + //! Reports file name to save/load non-XML data with directory name attached. QString fileName(const QString& projectDir) const; }; diff --git a/GUI/coregui/mainwindow/SaveService.cpp b/GUI/coregui/mainwindow/SaveService.cpp index 2c8c14ac8e3537245dbef1de2618519f0c581e7c..14c9b4ff9c8d146fec0715fb0d20ac4e5b53c17f 100644 --- a/GUI/coregui/mainwindow/SaveService.cpp +++ b/GUI/coregui/mainwindow/SaveService.cpp @@ -148,7 +148,7 @@ void SaveService::process_queue() // saving project file in a main thread const bool isAutosave = project_file_name.contains(ProjectUtils::autosaveSubdir()); - m_document->save_project_file(project_file_name, isAutosave); + m_document->saveProjectFile(project_file_name, isAutosave); if (m_document->hasData()) { // saving heavy data in separate thread diff --git a/GUI/coregui/mainwindow/SaveThread.cpp b/GUI/coregui/mainwindow/SaveThread.cpp index 08fde575e3f234ebc82d11492b0069d6f74a3504..2e132a0af4503f0b2db451506ebe47b31a5f93ca 100644 --- a/GUI/coregui/mainwindow/SaveThread.cpp +++ b/GUI/coregui/mainwindow/SaveThread.cpp @@ -26,7 +26,7 @@ SaveThread::~SaveThread() void SaveThread::run() { ASSERT(m_document); - m_document->save_project_data(m_projectFile); + m_document->saveProjectData(m_projectFile); emit saveReady(); } diff --git a/GUI/coregui/mainwindow/projectdocument.cpp b/GUI/coregui/mainwindow/projectdocument.cpp index c1ca74073ba044e75d70278a59ec4d4ae7f88b7d..f88857df23efbd83e8cd88c75f7af93f17593292 100644 --- a/GUI/coregui/mainwindow/projectdocument.cpp +++ b/GUI/coregui/mainwindow/projectdocument.cpp @@ -93,11 +93,11 @@ void ProjectDocument::setApplicationModels(ApplicationModels* applicationModels) void ProjectDocument::save(const QString& project_file_name, bool autoSave) { - save_project_data(project_file_name); - save_project_file(project_file_name, autoSave); + saveProjectData(project_file_name); + saveProjectFile(project_file_name, autoSave); } -void ProjectDocument::save_project_file(const QString& project_file_name, bool autoSave) +void ProjectDocument::saveProjectFile(const QString& project_file_name, bool autoSave) { QElapsedTimer timer; timer.start(); @@ -118,7 +118,7 @@ void ProjectDocument::save_project_file(const QString& project_file_name, bool a } } -void ProjectDocument::save_project_data(const QString& project_file_name) +void ProjectDocument::saveProjectData(const QString& project_file_name) { QElapsedTimer timer; timer.start(); @@ -126,7 +126,7 @@ void ProjectDocument::save_project_data(const QString& project_file_name) m_dataService->save(ProjectUtils::projectDir(project_file_name)); } -void ProjectDocument::load(const QString& project_file_name) +void ProjectDocument::loadProjectFile(const QString& project_file_name) { QElapsedTimer timer1, timer2; timer1.start(); @@ -144,11 +144,11 @@ void ProjectDocument::load(const QString& project_file_name) try { disconnectModels(); - readFrom(&file); + readProject(&file); file.close(); timer2.start(); - m_dataService->load(projectDir(), m_messageService); + m_dataService->loadDataFiles(projectDir(), m_messageService); connectModels(); if (m_messageService->warningCount()) @@ -205,7 +205,7 @@ bool ProjectDocument::hasErrors() const bool ProjectDocument::hasData() const { - return !m_dataService->nonXMLItems().isEmpty(); + return !m_dataService->dataInterfaces().isEmpty(); } QString ProjectDocument::documentVersion() const @@ -222,7 +222,7 @@ void ProjectDocument::onModelChanged() emit modified(); } -void ProjectDocument::readFrom(QIODevice* device) +void ProjectDocument::readProject(QIODevice* device) { ASSERT(m_messageService); QXmlStreamReader reader(device); diff --git a/GUI/coregui/mainwindow/projectdocument.h b/GUI/coregui/mainwindow/projectdocument.h index d7d696c7dd16d6dba1754985b4fcd378a1709abc..e35924e39ef200e8c2b2375e3a60b9ae371b71a8 100644 --- a/GUI/coregui/mainwindow/projectdocument.h +++ b/GUI/coregui/mainwindow/projectdocument.h @@ -58,10 +58,10 @@ public: void save(const QString& project_file_name, bool autoSave = false); - void save_project_file(const QString& project_file_name, bool autoSave = false); - void save_project_data(const QString& project_file_name); + void saveProjectFile(const QString& project_file_name, bool autoSave = false); + void saveProjectData(const QString& project_file_name); - void load(const QString& project_file_name); + void loadProjectFile(const QString& project_file_name); bool hasValidNameAndPath(); @@ -89,7 +89,7 @@ public slots: void onModelChanged(); private: - void readFrom(QIODevice* device); + void readProject(QIODevice* device); void writeTo(QIODevice* device); void disconnectModels(); diff --git a/GUI/coregui/mainwindow/projectmanager.cpp b/GUI/coregui/mainwindow/projectmanager.cpp index 152fc581292cfd628bd0a8f85d69645b9c755ed0..482070506334b685571fdb0823631f89093a975a 100644 --- a/GUI/coregui/mainwindow/projectmanager.cpp +++ b/GUI/coregui/mainwindow/projectmanager.cpp @@ -380,12 +380,12 @@ void ProjectManager::loadProject(const QString& projectFileName) if (useAutosave && restoreProjectDialog(projectFileName)) { QApplication::setOverrideCursor(Qt::WaitCursor); - m_project_document->load(ProjectUtils::autosaveName(projectFileName)); + m_project_document->loadProjectFile(ProjectUtils::autosaveName(projectFileName)); m_project_document->setProjectFileName(projectFileName); m_project_document->setModified(true); } else { QApplication::setOverrideCursor(Qt::WaitCursor); - m_project_document->load(projectFileName); + m_project_document->loadProjectFile(projectFileName); } QApplication::restoreOverrideCursor(); } diff --git a/GUI/coregui/utils/ImportDataInfo.cpp b/GUI/coregui/utils/ImportDataInfo.cpp index 48e6342e440296521bfb78701be4f3a05fa215ed..d78fd812efab8ef66a3f56698d78bc49c88af04f 100644 --- a/GUI/coregui/utils/ImportDataInfo.cpp +++ b/GUI/coregui/utils/ImportDataInfo.cpp @@ -38,9 +38,8 @@ ImportDataInfo::ImportDataInfo(ImportDataInfo&& other) } ImportDataInfo::ImportDataInfo(std::unique_ptr<OutputData<double>> data, Axes::Units units) - : m_data(units == Axes::Units::NBINS && data - ? ImportDataUtils::binifyAxes(*data) - : std::move(data)) + : m_data(units == Axes::Units::NBINS && data ? ImportDataUtils::binifyAxes(*data) + : std::move(data)) , m_units(units) { checkValidity(); @@ -65,7 +64,7 @@ ImportDataInfo::operator bool() const return static_cast<bool>(m_data); } -std::unique_ptr<OutputData<double>> ImportDataInfo::intensityData() const& +std::unique_ptr<OutputData<double>> ImportDataInfo::clonedData() const& { if (!m_data) return nullptr; diff --git a/GUI/coregui/utils/ImportDataInfo.h b/GUI/coregui/utils/ImportDataInfo.h index d6242b7ad4bd0c5f9ef24214cd5adbd978563085..c7cf58952b07be3ffee4c33c2e6a72b06f798701 100644 --- a/GUI/coregui/utils/ImportDataInfo.h +++ b/GUI/coregui/utils/ImportDataInfo.h @@ -35,7 +35,7 @@ public: //! True if the contained data is not nullptr (no info about empty data) operator bool() const; - std::unique_ptr<OutputData<double>> intensityData() const&; + std::unique_ptr<OutputData<double>> clonedData() const&; std::unique_ptr<OutputData<double>> intensityData() &&; //! Returns number of dimensions. diff --git a/Tests/UnitTests/Core/Basics/FileSystemUtilsTest.cpp b/Tests/UnitTests/Core/Basics/FileSystemUtilsTest.cpp index 6640a4aee5bbcf08c0a88450b7a4d8a8f9093686..8b78a3b56904f8bf8b210a46dcb8bb65498967e1 100644 --- a/Tests/UnitTests/Core/Basics/FileSystemUtilsTest.cpp +++ b/Tests/UnitTests/Core/Basics/FileSystemUtilsTest.cpp @@ -153,7 +153,7 @@ TEST_F(FileSystemUtilsTest, jointPath) EXPECT_ANY_THROW(FileSystemUtils::jointPath("", "")); EXPECT_ANY_THROW(FileSystemUtils::jointPath("a", "")); - EXPECT_ANY_THROW(FileSystemUtils::jointPath("", "b")); + EXPECT_EQ(FileSystemUtils::jointPath("", "b"), "b"); } TEST_F(FileSystemUtilsTest, filesInDirectory_IsFileExists) @@ -182,4 +182,4 @@ TEST_F(FileSystemUtilsTest, filesInDirectory_IsFileExists) EXPECT_TRUE(FileSystemUtils::IsFileExists("file2.txt")); EXPECT_TRUE(FileSystemUtils::IsFileExists("file3.txt")); EXPECT_FALSE(FileSystemUtils::IsFileExists("nonexisting.txt")); -} \ No newline at end of file +} diff --git a/Tests/UnitTests/Core/Instrument/SphericalDetectorTest.cpp b/Tests/UnitTests/Core/Instrument/SphericalDetectorTest.cpp index 36bb82e502204f9051b8cf4353f97bcdf4d57148..c2e885652cb06277e13211545b08d43940602b65 100644 --- a/Tests/UnitTests/Core/Instrument/SphericalDetectorTest.cpp +++ b/Tests/UnitTests/Core/Instrument/SphericalDetectorTest.cpp @@ -1,10 +1,10 @@ #include "Device/Detector/SphericalDetector.h" #include "Base/Const/Units.h" #include "Device/Beam/Beam.h" -#include "Device/ProDetector/RegionOfInterest.h" #include "Device/Detector/SimulationArea.h" #include "Device/Mask/Polygon.h" #include "Device/Mask/Rectangle.h" +#include "Device/ProDetector/RegionOfInterest.h" #include "Device/Resolution/ConvolutionDetectorResolution.h" #include "Device/Resolution/ResolutionFunction2DGaussian.h" #include "Tests/GTestWrapper/google_test.h" diff --git a/Tests/UnitTests/Core/Parameters/RealParameterTest.cpp b/Tests/UnitTests/Core/Parameters/RealParameterTest.cpp index 48bce878a1d649b08ef6213c3ca36c969d0520e5..c23795bc494be7b85f5c0c553a5a5519aba905ba 100644 --- a/Tests/UnitTests/Core/Parameters/RealParameterTest.cpp +++ b/Tests/UnitTests/Core/Parameters/RealParameterTest.cpp @@ -13,7 +13,7 @@ TEST_F(RealParameterTest, simpleConstructor) std::unique_ptr<RealParameter> par(new RealParameter("name", &value)); EXPECT_EQ(par->value(), value); EXPECT_EQ(par->limits(), RealLimits::limitless()); - EXPECT_EQ(par->unit(), std::string()); + EXPECT_EQ(par->unit(), ""); EXPECT_EQ(&value, &par->getData()); EXPECT_FALSE(par->isNull()); } diff --git a/Tests/UnitTests/GUI/TestCsvImportData.cpp b/Tests/UnitTests/GUI/TestCsvImportData.cpp index 074e79252dd69b0bbf249119b0cdab328e85f13c..734864f8013a0545031306286b45271408794104 100644 --- a/Tests/UnitTests/GUI/TestCsvImportData.cpp +++ b/Tests/UnitTests/GUI/TestCsvImportData.cpp @@ -120,7 +120,7 @@ TEST_F(TestCsvImportData, test_labels) model.setColumnAs(0, csv::_intensity_); EXPECT_EQ(model.columnLabel(CsvImportData::Intensity).toStdString(), "Intensity"); - EXPECT_EQ(model.columnLabel(CsvImportData::Coordinate).toStdString(), std::string()); + EXPECT_EQ(model.columnLabel(CsvImportData::Coordinate).toStdString(), ""); } TEST_F(TestCsvImportData, test_format_check) diff --git a/Tests/UnitTests/GUI/TestDataItemViews.cpp b/Tests/UnitTests/GUI/TestDataItemViews.cpp index 311fb5b8ac7f8488978dd7bad5df954902932098..f49c9edbc16d6f3a7fa40ad77f84e73e0917a21b 100644 --- a/Tests/UnitTests/GUI/TestDataItemViews.cpp +++ b/Tests/UnitTests/GUI/TestDataItemViews.cpp @@ -147,7 +147,7 @@ TEST_F(TestDataItemViews, testSavingLinkedData) ProjectDocument document; document.setApplicationModels(&models); document.setLogger(&message_service); - document.load(projectFileName); + document.loadProjectFile(projectFileName); SessionModel* real_data_model = models.realDataModel(); auto view_item = real_data_model->topItem<DataPropertyContainer>(); diff --git a/Tests/UnitTests/GUI/TestOutputDataIOService.cpp b/Tests/UnitTests/GUI/TestOutputDataIOService.cpp index 8fe0b279d55f3ad75841410a89d0af275b376edd..45169ecae8ab9a285450350010bb0c2be42aaf7e 100644 --- a/Tests/UnitTests/GUI/TestOutputDataIOService.cpp +++ b/Tests/UnitTests/GUI/TestOutputDataIOService.cpp @@ -63,7 +63,7 @@ TEST_F(TestOutputDataIOService, test_nonXMLData) // checking data items of OutputDataIOService OutputDataIOService service(&models); - EXPECT_EQ(service.nonXMLItems().size(), 3); + EXPECT_EQ(service.dataInterfaces().size(), 3); // checking data items of ApplicationModels dataItems = models.nonXMLItems(); @@ -254,6 +254,7 @@ TEST_F(TestOutputDataIOService, test_RealDataItemWithNativeData) ImportDataInfo import_data(std::unique_ptr<OutputData<double>>(m_data.clone()), "nbins"); realData->setImportData(std::move(import_data)); + // TODO: setImportData tested here with 2D data while main code uses it for 1D only. EXPECT_TRUE(realData->isIntensityData()); EXPECT_EQ(models.realDataModel()->nonXMLItems().size(), 2); @@ -271,7 +272,7 @@ TEST_F(TestOutputDataIOService, test_RealDataItemWithNativeData) // checking data items of OutputDataIOService OutputDataIOService service(&models); - EXPECT_EQ(service.nonXMLItems().size(), 5); + EXPECT_EQ(service.dataInterfaces().size(), 5); const QString projectDir("test_NativeData"); GuiUnittestUtils::create_dir(projectDir); diff --git a/Tests/UnitTests/GUI/TestSavingSpecularData.cpp b/Tests/UnitTests/GUI/TestSavingSpecularData.cpp index 8adf5a8d981a613d105e3069476a6160782e20bb..8fd851afd25c1c0fd4225a6a9418d170d6eb32d9 100644 --- a/Tests/UnitTests/GUI/TestSavingSpecularData.cpp +++ b/Tests/UnitTests/GUI/TestSavingSpecularData.cpp @@ -91,7 +91,7 @@ TEST_F(TestSavingSpecularData, test_SpecularInsturment) // checking data items of OutputDataIOService OutputDataIOService service(&models); - EXPECT_EQ(service.nonXMLItems().size(), 1); + EXPECT_EQ(service.dataInterfaces().size(), 1); // checking data items of ApplicationModels dataItems = models.nonXMLItems(); @@ -120,7 +120,7 @@ TEST_F(TestSavingSpecularData, test_InstrumentInJobItem) EXPECT_EQ(models.jobModel()->nonXMLItems().size(), 2); OutputDataIOService service(&models); - EXPECT_EQ(service.nonXMLItems().size(), 2); + EXPECT_EQ(service.dataInterfaces().size(), 2); auto dataItems = models.nonXMLItems(); EXPECT_EQ(dataItems.size(), 2); @@ -129,7 +129,7 @@ TEST_F(TestSavingSpecularData, test_InstrumentInJobItem) // hiding pointwise axis, should be saved anyway axis_group->setCurrentType("BasicAxis"); EXPECT_EQ(models.jobModel()->nonXMLItems().size(), 2); - EXPECT_EQ(service.nonXMLItems().size(), 2); + EXPECT_EQ(service.dataInterfaces().size(), 2); dataItems = models.nonXMLItems(); EXPECT_EQ(dataItems.size(), 2); EXPECT_EQ(dataItems.indexOf(dataItem), 0); diff --git a/auto/Wrap/doxygenBase.i b/auto/Wrap/doxygenBase.i index d6d04bf493ffd83300b05db5862f57d712c65f2c..42a645956891be0c36cc336ed25f26fa5757b88a 100644 --- a/auto/Wrap/doxygenBase.i +++ b/auto/Wrap/doxygenBase.i @@ -1310,7 +1310,7 @@ Returns filenames of files in directory. %feature("docstring") FileSystemUtils::jointPath "std::string FileSystemUtils::jointPath(const std::string &path1, const std::string &path2) -Returns joint path name. +Returns joint path name. Argument path1 may be empty, argument path2 not. "; %feature("docstring") FileSystemUtils::filename "std::string FileSystemUtils::filename(const std::string &path) diff --git a/gui2/dataloader/parserpropertywidget.cpp b/gui2/dataloader/parserpropertywidget.cpp index 57058807708a906abda910f59229bacf42e9a078..18c39bf75ac31fc7a7bab37e3ef2ce4b11d213fe 100644 --- a/gui2/dataloader/parserpropertywidget.cpp +++ b/gui2/dataloader/parserpropertywidget.cpp @@ -251,8 +251,7 @@ void ParserPropertyWidget::addIgnoreStringPatternRow(QGridLayout* layout) startingWithRadio->setChecked(true); startingWithRadio->setToolTip("Ignore lines starting with a given character(s)"); auto on_startingfrom_radio = [this, startingFromLineEdit](auto checked) { - m_options.m_header_prefix = - checked ? startingFromLineEdit->text().toStdString() : std::string(); + m_options.m_header_prefix = checked ? startingFromLineEdit->text().toStdString() : ""; onParserPropertyChange(); }; connect(startingWithRadio, &QRadioButton::clicked, on_startingfrom_radio); @@ -286,8 +285,7 @@ void ParserPropertyWidget::addIgnoreNumbersPatternRow(QGridLayout* layout) lineNumbersRadio->setText("Line numbers"); lineNumbersRadio->setToolTip("Ignore lines with line numbers matching the pattern"); auto on_linenumbers_radio = [this, lineNumbersLineEdit](auto checked) { - m_options.m_skip_index_pattern = - checked ? lineNumbersLineEdit->text().toStdString() : std::string(); + m_options.m_skip_index_pattern = checked ? lineNumbersLineEdit->text().toStdString() : ""; onParserPropertyChange(); }; connect(lineNumbersRadio, &QRadioButton::clicked, on_linenumbers_radio); diff --git a/gui2/model/materialitems.cpp b/gui2/model/materialitems.cpp index d6a527b3e9634a00a9a8539e514b4517df85d0e4..aa2959953dd98dfb6d6b5f1f23df8bcd64786dc4 100644 --- a/gui2/model/materialitems.cpp +++ b/gui2/model/materialitems.cpp @@ -43,7 +43,7 @@ MaterialBaseItem::MaterialBaseItem(const std::string& model_type) ModelView::ExternalProperty MaterialBaseItem::external_property() const { QColor color = Utils::HasTag(*this, P_COLOR) ? property<QColor>(P_COLOR) : QColor(Qt::red); - std::string name = Utils::HasTag(*this, P_NAME) ? property<std::string>(P_NAME) : std::string(); + std::string name = Utils::HasTag(*this, P_NAME) ? property<std::string>(P_NAME) : ""; return ModelView::ExternalProperty(name, color, identifier()); } diff --git a/gui2/model/materialmodel.h b/gui2/model/materialmodel.h index 8e54481259530d37688ebf7566b1bed3f885f454..e3baab611d795baaee1413c778d7a087b6da046f 100644 --- a/gui2/model/materialmodel.h +++ b/gui2/model/materialmodel.h @@ -36,8 +36,7 @@ class DAREFLCORE_EXPORT MaterialModel : public ModelView::SessionModel { public: MaterialModel(std::shared_ptr<ModelView::ItemPool> pool = {}); - std::vector<ModelView::ExternalProperty> - material_data(std::string container_id = std::string()) const; + std::vector<ModelView::ExternalProperty> material_data(std::string container_id = "") const; ModelView::ExternalProperty material_property(const std::string& id); diff --git a/mvvm/model/mvvm/model/comboproperty.cpp b/mvvm/model/mvvm/model/comboproperty.cpp index f68601c752e0fa067198cc40c784855c54ec5698..33ee40a0e8208f553753a410dee3e28797a11d07 100644 --- a/mvvm/model/mvvm/model/comboproperty.cpp +++ b/mvvm/model/mvvm/model/comboproperty.cpp @@ -73,7 +73,7 @@ ComboProperty ComboProperty::createFrom(const std::vector<std::string>& values, std::string ComboProperty::value() const { - return currentIndex() < 0 ? std::string() : m_values.at(static_cast<size_t>(currentIndex())); + return currentIndex() < 0 ? "" : m_values.at(static_cast<size_t>(currentIndex())); } void ComboProperty::setValue(const std::string& name) diff --git a/mvvm/model/mvvm/model/path.cpp b/mvvm/model/mvvm/model/path.cpp index 4e284eb5939ad0fb590c9c3c7e3c8fe180ee8c02..71877a77d89dc8310e435c6146d339c0891cf563 100644 --- a/mvvm/model/mvvm/model/path.cpp +++ b/mvvm/model/mvvm/model/path.cpp @@ -49,7 +49,7 @@ Path Path::fromVector(const std::vector<int>& data) std::string Path::str() const { auto comma_fold = [](std::string a, int b) { return std::move(a) + ',' + std::to_string(b); }; - return m_data.empty() ? std::string() + return m_data.empty() ? "" : std::accumulate(std::next(m_data.begin()), m_data.end(), std::to_string(m_data[0]), comma_fold); } diff --git a/mvvm/model/mvvm/model/sessionitem.cpp b/mvvm/model/mvvm/model/sessionitem.cpp index 65c4fd39ca997363e76bc22711f9eff60171287b..46c8827eced92c2718d0f57f29e4fc22f27ef4f7 100644 --- a/mvvm/model/mvvm/model/sessionitem.cpp +++ b/mvvm/model/mvvm/model/sessionitem.cpp @@ -297,8 +297,7 @@ SessionItem* SessionItem::setEnabled(bool value) std::string SessionItem::toolTip() const { - return hasData(ItemDataRole::TOOLTIP) ? data<std::string>(ItemDataRole::TOOLTIP) - : std::string(); + return hasData(ItemDataRole::TOOLTIP) ? data<std::string>(ItemDataRole::TOOLTIP) : ""; } //! Sets item tooltip (fluent interface). @@ -313,8 +312,7 @@ SessionItem* SessionItem::setToolTip(const std::string& tooltip) std::string SessionItem::editorType() const { - return hasData(ItemDataRole::EDITORTYPE) ? data<std::string>(ItemDataRole::EDITORTYPE) - : std::string(); + return hasData(ItemDataRole::EDITORTYPE) ? data<std::string>(ItemDataRole::EDITORTYPE) : ""; } //! Sets editor type (fluent interface). diff --git a/mvvm/model/mvvm/project/project_types.h b/mvvm/model/mvvm/project/project_types.h index deded57d06f8457186516fe3d27b7646df77fa15..4f7f3bf0c53c932b8d08bd5813fadb497fb26b0c 100644 --- a/mvvm/model/mvvm/project/project_types.h +++ b/mvvm/model/mvvm/project/project_types.h @@ -47,10 +47,10 @@ struct MVVM_MODEL_EXPORT ProjectContext { struct MVVM_MODEL_EXPORT UserInteractionContext { //!< To ask the user to select existing directory, returns full path to the directory. - using select_dir_callback_t = std::function<std::string()>; + using select_dir_callback_t = std::function<"">; //!< To ask the user to create a new directory, returns full path to the directory. - using create_dir_callback_t = std::function<std::string()>; + using create_dir_callback_t = std::function<"">; //!< To ask the user what to do with modified project. using answer_callback_t = std::function<SaveChangesAnswer()>; diff --git a/mvvm/model/mvvm/project/projectmanager.cpp b/mvvm/model/mvvm/project/projectmanager.cpp index 5b126f7d06f128e2f6b0ea35bc661c156f8d89bc..6d841c4a7b1d9f12ffa7d606d6a1f954e983c51e 100644 --- a/mvvm/model/mvvm/project/projectmanager.cpp +++ b/mvvm/model/mvvm/project/projectmanager.cpp @@ -111,7 +111,7 @@ bool ProjectManager::openExistingProject(const std::string& dirname) std::string ProjectManager::currentProjectDir() const { - return p_impl->m_current_project ? p_impl->m_current_project->projectDir() : std::string(); + return p_impl->m_current_project ? p_impl->m_current_project->projectDir() : ""; } //! Returns true if project was modified since last save. diff --git a/mvvm/model/mvvm/standarditems/linkeditem.cpp b/mvvm/model/mvvm/standarditems/linkeditem.cpp index f6c9d76025b21e070979f4d9a39325e3312b9c24..a2644f944f5ec000e840e8301569136e5fcc34ed 100644 --- a/mvvm/model/mvvm/standarditems/linkeditem.cpp +++ b/mvvm/model/mvvm/standarditems/linkeditem.cpp @@ -18,7 +18,7 @@ using namespace ModelView; namespace { -const Variant empty_link = Variant::fromValue(std::string()); +const Variant empty_link = Variant::fromValue(""); } LinkedItem::LinkedItem() : SessionItem(Constants::LinkedItemType) diff --git a/mvvm/model/mvvm/standarditems/plottableitems.cpp b/mvvm/model/mvvm/standarditems/plottableitems.cpp index bfbb4bfbb04b76c18e0ae3c34bcc1e58d614d57a..6b82aa05f59265e46a56a3a7cd857155d9bee8da 100644 --- a/mvvm/model/mvvm/standarditems/plottableitems.cpp +++ b/mvvm/model/mvvm/standarditems/plottableitems.cpp @@ -36,7 +36,7 @@ const std::string default_title_family = "Noto Sans"; TextItem::TextItem() : CompoundItem(Constants::TextItemType) { - addProperty(P_TEXT, "")->setDisplayName("Text"); + addProperty(P_TEXT, QString())->setDisplayName("Text"); addProperty(P_FONT, default_title_family)->setDisplayName("Font"); addProperty(P_SIZE, default_title_size)->setDisplayName("Size"); } diff --git a/mvvm/tests/testmodel/fileutils.test.cpp b/mvvm/tests/testmodel/fileutils.test.cpp index 2ba7ccccc36bfe3692e4b5c9647af9008e5309c7..09e4fac3968aa7959b34306cd252a5454f758d66 100644 --- a/mvvm/tests/testmodel/fileutils.test.cpp +++ b/mvvm/tests/testmodel/fileutils.test.cpp @@ -33,7 +33,7 @@ FileUtilsTest::~FileUtilsTest() = default; TEST_F(FileUtilsTest, exists) { EXPECT_TRUE(Utils::exists(testPath())); - EXPECT_FALSE(Utils::exists(std::string())); + EXPECT_FALSE(Utils::exists("")); EXPECT_FALSE(Utils::exists(std::string("abc"))); } diff --git a/mvvm/tests/testmodel/itemconverterfactory.test.cpp b/mvvm/tests/testmodel/itemconverterfactory.test.cpp index cdb2f94884992f33a5936fc5dfef46d8e9c9ff22..51cfb4e6593c4e7ab8260c1558bd7e08951cd131 100644 --- a/mvvm/tests/testmodel/itemconverterfactory.test.cpp +++ b/mvvm/tests/testmodel/itemconverterfactory.test.cpp @@ -108,7 +108,7 @@ TEST_F(ItemConverterFactoryTest, propertyItemProjectConverter) EXPECT_EQ(reco->modelType(), item.modelType()); EXPECT_EQ(reco->displayName(), item.displayName()); - EXPECT_EQ(reco->toolTip(), std::string()); // tooltips are not preserved + EXPECT_EQ(reco->toolTip(), ""); // tooltips are not preserved EXPECT_TRUE(reco->identifier() == item.identifier()); // identifier preserved } diff --git a/mvvm/tests/testmodel/linkeditem.test.cpp b/mvvm/tests/testmodel/linkeditem.test.cpp index 45b7c490816ef6069dd556aa3f4529792014a348..3cfbaa8a34b4ddd242dda0538b983ce38240c010 100644 --- a/mvvm/tests/testmodel/linkeditem.test.cpp +++ b/mvvm/tests/testmodel/linkeditem.test.cpp @@ -37,7 +37,7 @@ TEST_F(LinkedItemTest, initialState) { LinkedItem item; EXPECT_EQ(item.get(), nullptr); - EXPECT_EQ(item.data<std::string>(), std::string()); + EXPECT_EQ(item.data<std::string>(), ""); } //! Link in single model context. @@ -124,5 +124,5 @@ TEST_F(LinkedItemTest, setNullAsLink) link->setLink(nullptr); EXPECT_EQ(link->get(), nullptr); EXPECT_TRUE(link->data<QVariant>().isValid()); - EXPECT_EQ(link->data<std::string>(), std::string()); + EXPECT_EQ(link->data<std::string>(), ""); } diff --git a/mvvm/tests/testmodel/sessionitem.test.cpp b/mvvm/tests/testmodel/sessionitem.test.cpp index 84ee22a14f24f4b02cda7af5f25f3f4e552b7468..8b909a685961cc617c275f91d879154a19a25afa 100644 --- a/mvvm/tests/testmodel/sessionitem.test.cpp +++ b/mvvm/tests/testmodel/sessionitem.test.cpp @@ -228,7 +228,7 @@ TEST_F(SessionItemTest, registerItem) TEST_F(SessionItemTest, defaultTag) { SessionItem item; - EXPECT_EQ(item.itemTags()->defaultTag(), std::string()); + EXPECT_EQ(item.itemTags()->defaultTag(), ""); EXPECT_FALSE(Utils::HasTag(item, "defaultTag")); } diff --git a/mvvm/tests/testmodel/stringutils.test.cpp b/mvvm/tests/testmodel/stringutils.test.cpp index 18dd6120e8176e767b4aebdad104e12d000f8336..e45ab06702e78656c22428776ffdd896dd7c3a85 100644 --- a/mvvm/tests/testmodel/stringutils.test.cpp +++ b/mvvm/tests/testmodel/stringutils.test.cpp @@ -51,8 +51,8 @@ TEST_F(StringUtilsTest, DoubleToString) TEST_F(StringUtilsTest, TrimWhiteSpace) { using Utils::TrimWhitespace; - EXPECT_EQ(TrimWhitespace(""), std::string()); - EXPECT_EQ(TrimWhitespace(" "), std::string()); + EXPECT_EQ(TrimWhitespace(""), ""); + EXPECT_EQ(TrimWhitespace(" "), ""); EXPECT_EQ(TrimWhitespace("abc"), std::string("abc")); EXPECT_EQ(TrimWhitespace(" \t\n abc cde\n"), std::string("abc cde")); } diff --git a/mvvm/tests/testmodel/taginfo.test.cpp b/mvvm/tests/testmodel/taginfo.test.cpp index a30cf0251aa9fa02deb663ee21d1bc11771080fc..5a530244f6a98bca581de9135b913cc6d9948784 100644 --- a/mvvm/tests/testmodel/taginfo.test.cpp +++ b/mvvm/tests/testmodel/taginfo.test.cpp @@ -29,7 +29,7 @@ TagInfoTest::~TagInfoTest() = default; TEST_F(TagInfoTest, initialState) { TagInfo tag; - EXPECT_EQ(tag.name(), std::string()); + EXPECT_EQ(tag.name(), ""); EXPECT_EQ(tag.min(), 0); EXPECT_EQ(tag.max(), -1); EXPECT_FALSE(tag.isSinglePropertyTag()); diff --git a/mvvm/viewmodel/mvvm/viewmodel/defaultcelldecorator.cpp b/mvvm/viewmodel/mvvm/viewmodel/defaultcelldecorator.cpp index 0ea47bd75127ec766ea18ef1b80377125e58a3b2..910ac78158cfd7ac9b003f1eb4d90d14784186bd 100644 --- a/mvvm/viewmodel/mvvm/viewmodel/defaultcelldecorator.cpp +++ b/mvvm/viewmodel/mvvm/viewmodel/defaultcelldecorator.cpp @@ -43,7 +43,7 @@ std::optional<std::string> DefaultCellDecorator::cellText(const QModelIndex& ind return std::optional<std::string>{variant.value<ExternalProperty>().text()}; else if (Utils::IsColorVariant(variant)) - return std::optional<std::string>{std::string()}; + return std::optional<std::string>{""}; else if (Utils::IsDoubleVariant(variant)) return std::optional<std::string>{