File indexing completed on 2024-05-19 04:45:53
0001 // SPDX-FileCopyrightText: Lukas Sommer <sommerluk@gmail.com> 0002 // SPDX-License-Identifier: BSD-2-Clause OR MIT 0003 0004 #ifndef MULTISPINBOXSECTION_H 0005 #define MULTISPINBOXSECTION_H 0006 0007 #include "constpropagatinguniquepointer.h" 0008 #include "importexport.h" 0009 #include <qdebug.h> 0010 #include <qmetatype.h> 0011 #include <qstring.h> 0012 0013 namespace PerceptualColor 0014 { 0015 class MultiSpinBoxSectionPrivate; 0016 0017 /** @brief The configuration of a single section 0018 * within a @ref MultiSpinBox. 0019 * 0020 * For a specific section within a @ref MultiSpinBox, this configuration 0021 * contains various settings. 0022 * 0023 * This data type can be passed to QDebug thanks to 0024 * @ref operator<<(QDebug dbg, const PerceptualColor::MultiSpinBoxSection &value) 0025 * 0026 * This type is declared as type to Qt’s type system via 0027 * <tt>Q_DECLARE_METATYPE</tt>. Depending on your use case (for 0028 * example if you want to use for <em>queued</em> signal-slot connections), 0029 * you might consider calling <tt>qRegisterMetaType()</tt> for 0030 * this type, once you have a QApplication object. 0031 * 0032 * @internal 0033 * 0034 * Also Qt itself uses this configuration-object-based approach with its 0035 * QNetworkConfiguration class (including @ref pimpl and 0036 * copy-constructors). */ 0037 class PERCEPTUALCOLOR_IMPORTEXPORT MultiSpinBoxSection 0038 { 0039 public: 0040 MultiSpinBoxSection(); 0041 MultiSpinBoxSection(const MultiSpinBoxSection &other); 0042 ~MultiSpinBoxSection() noexcept; 0043 MultiSpinBoxSection &operator=(const MultiSpinBoxSection &other); 0044 MultiSpinBoxSection(MultiSpinBoxSection &&other) noexcept; 0045 MultiSpinBoxSection &operator=(MultiSpinBoxSection &&other) noexcept; 0046 0047 [[nodiscard]] int decimals() const; 0048 [[nodiscard]] bool isWrapping() const; 0049 [[nodiscard]] double maximum() const; 0050 [[nodiscard]] double minimum() const; 0051 [[nodiscard]] QString prefix() const; 0052 void setDecimals(int newDecimals); 0053 void setMaximum(double newMaximum); 0054 void setMinimum(double newMinimum); 0055 void setPrefix(const QString &newPrefix); 0056 void setSingleStep(double newSingleStep); 0057 void setSuffix(const QString &newSuffix); 0058 void setWrapping(bool newIsWrapping); 0059 [[nodiscard]] double singleStep() const; 0060 [[nodiscard]] QString suffix() const; 0061 0062 private: 0063 /** @internal 0064 * 0065 * @brief Declare the private implementation as friend class. 0066 * 0067 * This allows the private class to access the protected members and 0068 * functions of instances of <em>this</em> class. */ 0069 friend class MultiSpinBoxSectionPrivate; 0070 /** @brief Pointer to implementation (pimpl) */ 0071 ConstPropagatingUniquePointer<MultiSpinBoxSectionPrivate> d_pointer; 0072 0073 /** @internal @brief Only for unit tests. */ 0074 friend class TestMultiSpinBoxSection; 0075 0076 /** @internal 0077 * @brief Internal friend declaration. 0078 * 0079 * This class is used as configuration for @ref MultiSpinBox. Thought 0080 * currently there is no need for this <tt>friend</tt> declaration, 0081 * it is done nevertheless. (If it would become necessary later, 0082 * adding it would break the binary API, which we want to avoid.) */ 0083 friend class MultiSpinBox; 0084 }; 0085 0086 PERCEPTUALCOLOR_IMPORTEXPORT QDebug operator<<(QDebug dbg, const PerceptualColor::MultiSpinBoxSection &value); 0087 0088 } // namespace PerceptualColor 0089 0090 Q_DECLARE_METATYPE(PerceptualColor::MultiSpinBoxSection) 0091 0092 #endif // MULTISPINBOXSECTION_H