diff --git a/YUViewLib/src/common/Formatting.h b/YUViewLib/src/common/Formatting.h index 427014c2d..6696de333 100644 --- a/YUViewLib/src/common/Formatting.h +++ b/YUViewLib/src/common/Formatting.h @@ -51,7 +51,7 @@ template std::string to_string(const std::pair &typePair) return stream.str(); } -template std::ostream &operator<<(std::ostream &stream, const std::vector vec) +template std::ostream &operator<<(std::ostream &stream, const std::vector &vec) { stream << "["; for (auto it = vec.begin(); it != vec.end(); it++) @@ -64,7 +64,7 @@ template std::ostream &operator<<(std::ostream &stream, const std:: return stream; } -template std::string to_string(const std::vector vec) +template std::string to_string(const std::vector &vec) { std::ostringstream stream; stream << vec; @@ -73,7 +73,7 @@ template std::string to_string(const std::vector vec) static std::ostream &operator<<(std::ostream &stream, const Size &size) { - stream << "(" << size.width << "x" << size.height << ")"; + stream << size.width << "x" << size.height; return stream; } @@ -89,13 +89,31 @@ inline std::string to_string(const bool b) return b ? "True" : "False"; } +template +static std::ostream &operator<<(std::ostream &stream, const std::optional &opt) +{ + if (opt) + stream << opt.value(); + else + stream << "NA"; + return stream; +} + +template inline std::string to_string(const std::optional &opt) +{ + std::ostringstream stream; + stream << opt; + return stream.str(); +} + inline std::string stringReplaceAll(std::string str, char value, char replacement) { std::replace(str.begin(), str.end(), value, replacement); return str; } -inline std::string stringReplaceAll(std::string str, std::initializer_list values, char replacement) +inline std::string +stringReplaceAll(std::string str, std::initializer_list values, char replacement) { std::replace_if( str.begin(), diff --git a/YUViewLib/src/common/FileInfo.h b/YUViewLib/src/common/InfoItemAndData.h similarity index 74% rename from YUViewLib/src/common/FileInfo.h rename to YUViewLib/src/common/InfoItemAndData.h index 49a7e924b..e50a291b0 100644 --- a/YUViewLib/src/common/FileInfo.h +++ b/YUViewLib/src/common/InfoItemAndData.h @@ -37,26 +37,25 @@ #include /* - * An info item has a name, a text and an optional toolTip. These are used to show them in the - * fileInfoWidget. For example: ["File Name", "file.yuv"] or ["Number Frames", "123"] Another option - * is to show a button. If the user clicks on it, the callback function infoListButtonPressed() for - * the corresponding playlist item is called. + * An info item has a name, a text and an optional description. These are used to show them in the + * fileInfoWidget. For example: ["File Name", "file.yuv"] or ["Number Frames", "123"]. */ struct InfoItem { - InfoItem(const QString &name, - const QString &text, - const QString &toolTip = QString(), - bool button = false, - int buttonID = -1) - : name(name), text(text), button(button), buttonID(buttonID), toolTip(toolTip) + std::string name{}; + std::string text{}; + std::string description{}; + + InfoItem(std::string &&name, std::string &&text) : name(std::move(name)), text(std::move(text)) {} + InfoItem(std::string &&name, std::string &&text, std::string &&description) + : name(std::move(name)), text(std::move(text)), description(std::move(description)) + { + } + InfoItem(std::string_view name, std::string_view text) : name(name), text(text) {} + InfoItem(std::string_view name, std::string_view text, std::string_view description) + : name(name), text(text), description(description) { } - QString name{}; - QString text{}; - bool button{}; - int buttonID{}; - QString toolTip{}; }; struct InfoData diff --git a/YUViewLib/src/common/Typedef.h b/YUViewLib/src/common/Typedef.h index 02bcc203e..211b8ab78 100644 --- a/YUViewLib/src/common/Typedef.h +++ b/YUViewLib/src/common/Typedef.h @@ -279,6 +279,7 @@ struct Size { return this->width != other.width || this->height != other.height; } + explicit operator bool() const { return this->isValid(); } constexpr bool isValid() const { return this->width > 0 && this->height > 0; } unsigned width{}; unsigned height{}; @@ -345,7 +346,7 @@ Q_DECLARE_METATYPE(recacheIndicator) template struct QNonConstOverload { template - Q_DECL_CONSTEXPR auto operator()(R (T::*ptr)(Args...)) const Q_DECL_NOTHROW -> decltype(ptr) + Q_DECL_CONSTEXPR auto operator()(R (T::*ptr)(Args...)) const Q_DECL_NOTHROW->decltype(ptr) { return ptr; } @@ -358,7 +359,7 @@ template struct QNonConstOverload template struct QConstOverload { template - Q_DECL_CONSTEXPR auto operator()(R (T::*ptr)(Args...) const) const Q_DECL_NOTHROW -> decltype(ptr) + Q_DECL_CONSTEXPR auto operator()(R (T::*ptr)(Args...) const) const Q_DECL_NOTHROW->decltype(ptr) { return ptr; } @@ -375,7 +376,7 @@ template struct QOverload : QConstOverload, QNonCons using QNonConstOverload::of; using QNonConstOverload::operator(); template - Q_DECL_CONSTEXPR auto operator()(R (*ptr)(Args...)) const Q_DECL_NOTHROW -> decltype(ptr) + Q_DECL_CONSTEXPR auto operator()(R (*ptr)(Args...)) const Q_DECL_NOTHROW->decltype(ptr) { return ptr; } diff --git a/YUViewLib/src/decoder/decoderHM.h b/YUViewLib/src/decoder/decoderHM.h index fb465f36a..88022d7ac 100644 --- a/YUViewLib/src/decoder/decoderHM.h +++ b/YUViewLib/src/decoder/decoderHM.h @@ -34,7 +34,7 @@ #include -#include +#include #include #include #include