From edabd67a6e716b312fcd0750a5faacf313685485 Mon Sep 17 00:00:00 2001 From: Josh Klontz Date: Fri, 20 Dec 2013 10:50:19 -0500 Subject: [PATCH] improved br::File boolean logic --- openbr/openbr_plugin.h | 14 ++++++++++++++ openbr/plugins/gallery.cpp | 4 ++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/openbr/openbr_plugin.h b/openbr/openbr_plugin.h index 1d9f7cd..30f3799 100644 --- a/openbr/openbr_plugin.h +++ b/openbr/openbr_plugin.h @@ -239,6 +239,13 @@ struct BR_EXPORT File return variant.value(); } + /*!< \brief Specialization for boolean type. */ + template + bool get(const QString &key) const + { + return getBool(key); + } + /*!< \brief Returns a value for the key, returning \em defaultValue if the key does not exist or can't be converted. */ template T get(const QString &key, const T &defaultValue) const @@ -250,6 +257,13 @@ struct BR_EXPORT File } /*!< \brief Specialization for boolean type. */ + template + bool get(const QString &key, const bool &defaultValue) const + { + return getBool(key, defaultValue); + } + + /*!< \brief Specialization for boolean type. */ bool getBool(const QString &key, bool defaultValue = false) const; /*!< \brief Specialization for list type. Returns a list of type T for the key, throwing an error if the key does not exist or if the value cannot be converted to the specified type. */ diff --git a/openbr/plugins/gallery.cpp b/openbr/plugins/gallery.cpp index 6d02436..bb1b4f2 100644 --- a/openbr/plugins/gallery.cpp +++ b/openbr/plugins/gallery.cpp @@ -99,12 +99,12 @@ class galGallery : public Gallery void init() { gallery.setFileName(file); - if (file.get("remove", false)) + if (file.get("remove")) gallery.remove(); QtUtils::touchDir(gallery); QFile::OpenMode mode = QFile::ReadWrite; - if (file.contains("append")) + if (file.get("append")) mode |= QFile::Append; if (!gallery.open(mode)) -- libgit2 0.21.4