From 8f6b690442de3f6469cb1ec804be2ed5fbbba31f Mon Sep 17 00:00:00 2001 From: Alison Watson Date: Tue, 2 Jul 2019 19:23:09 -0400 Subject: [PATCH] tycho: use a variadic template for dbgPrint --- tycho/CMakeLists.txt | 38 +++++++++++++++++++------------------- tycho/cc/mapmodel.cc | 3 ++- tycho/cc/tycho.h | 36 +++++++++++++++++------------------- 3 files changed, 38 insertions(+), 39 deletions(-) diff --git a/tycho/CMakeLists.txt b/tycho/CMakeLists.txt index ee04853..91c34c2 100644 --- a/tycho/CMakeLists.txt +++ b/tycho/CMakeLists.txt @@ -21,23 +21,23 @@ find_package( add_library( maraiah-tycho-hermes SHARED - $ENV{OUT_DIR}/bindings.cc - $ENV{OUT_DIR}/bindings.h - cc/main.cc - cc/mapmodel.cc - cc/mapprops.cc - cc/mapview.cc - cc/menu.cc - cc/project.cc - cc/tycho.h - resources/resources.qrc - ui/about.ui - ui/license.ui - ui/mapprops.ui - ui/mapview.ui - ui/menu.ui - ui/points.ui - ui/project.ui + $ENV{OUT_DIR}/bindings.cc + $ENV{OUT_DIR}/bindings.h + cc/main.cc + cc/mapmodel.cc + cc/mapprops.cc + cc/mapview.cc + cc/menu.cc + cc/project.cc + cc/tycho.h + resources/resources.qrc + ui/about.ui + ui/license.ui + ui/mapprops.ui + ui/mapview.ui + ui/menu.ui + ui/points.ui + ui/project.ui ) set_target_properties( @@ -55,8 +55,8 @@ target_include_directories( target_link_libraries( maraiah-tycho-hermes - Qt5::Core - Qt5::Widgets + Qt5::Core + Qt5::Widgets ) target_compile_definitions( diff --git a/tycho/cc/mapmodel.cc b/tycho/cc/mapmodel.cc index 71c7f66..59a13e3 100644 --- a/tycho/cc/mapmodel.cc +++ b/tycho/cc/mapmodel.cc @@ -62,7 +62,8 @@ QVariant MapModel::data(const QModelIndex &index, int role) const switch(role) { case Qt::DecorationRole: { auto name = propIcon(index.row()); - auto icon = name.front() == ':' ? QIcon(name) : QIcon::fromTheme(name); + auto icon = name.front() == ':' ? QIcon(name) + : QIcon::fromTheme(name); return QVariant::fromValue(icon); } default: diff --git a/tycho/cc/tycho.h b/tycho/cc/tycho.h index f0db16b..65881bb 100644 --- a/tycho/cc/tycho.h +++ b/tycho/cc/tycho.h @@ -15,6 +15,8 @@ #include #include +#include "bindings.h" + #include "../ui/ui_about.h" #include "../ui/ui_license.h" #include "../ui/ui_mapprops.h" @@ -22,18 +24,6 @@ #include "../ui/ui_menu.h" #include "../ui/ui_project.h" -#include "bindings.h" - -#ifdef TYCHO_DEBUG_ASSERTIONS -#define dbgPrint(...) qDebug(__VA_ARGS__) -#else -#define dbgPrint(...) -#endif - -#define dbgPrintFunc() dbgPrint("%s", __func__) - -// TODO: namespace Tycho { - class MapModel; class MapProps; class MapView; @@ -81,7 +71,6 @@ class ProjectModel public: enum Type { - Invalid, Map, }; @@ -151,10 +140,21 @@ private: void addProject(Project *proj); }; -constexpr std::uint32_t fourCC(std::uint8_t a, - std::uint8_t b, - std::uint8_t c, - std::uint8_t d) +template +static inline void dbgPrint([[maybe_unused]] char const *fmt, + [[maybe_unused]] VA &&...va) +{ + #ifdef TYCHO_DEBUG_ASSERTIONS + qDebug(fmt, std::forward(va)...); + #endif +} + +#define dbgPrintFunc() dbgPrint("%s", __func__) + +static inline constexpr std::uint32_t fourCC(std::uint8_t a, + std::uint8_t b, + std::uint8_t c, + std::uint8_t d) { return (a << 24) | (b << 16) | (c << 8) | d; } @@ -167,6 +167,4 @@ extern "C" { char const *tychoVersion(); } -// } - // EOF