Issue #77 toIcon returns a simple enum instead of a full object

This commit is contained in:
Mat Sutcliffe
2020-10-26 22:55:10 +00:00
parent 59bbac9a1f
commit b1185eb541
61 changed files with 157 additions and 171 deletions

View File

@@ -31,10 +31,7 @@ namespace BlackMisc
{
public:
//! As icon, not implemented by all classes
CIcon toIcon() const { return CIcon::iconByIndex(IconIndex); }
//! As pixmap, required for most GUI views
QPixmap toPixmap() const { return derived()->toIcon().toPixmap(); }
CIcons::IconIndex toIcon() const { return IconIndex; }
private:
const Derived *derived() const { return static_cast<const Derived *>(this); }
@@ -46,8 +43,7 @@ namespace BlackMisc
* the derived class uses this macro to disambiguate the inherited members.
*/
# define BLACKMISC_DECLARE_USING_MIXIN_ICON(DERIVED) \
using ::BlackMisc::Mixin::Icon<DERIVED>::toIcon; \
using ::BlackMisc::Mixin::Icon<DERIVED>::toPixmap;
using ::BlackMisc::Mixin::Icon<DERIVED>::toIcon;
}
} // namespace

View File

@@ -155,8 +155,8 @@ namespace BlackMisc
const auto i = index.frontCasted<ColumnIndex>(); // keep that "auto", otherwise I won's compile
switch (i)
{
case IndexIcon: return CVariant::from(derived()->toIcon());
case IndexPixmap: return CVariant::from(derived()->toPixmap());
case IndexIcon: return CVariant::from(CIcon(derived()->toIcon()));
case IndexPixmap: return CVariant::from(CIcon(derived()->toIcon()).toPixmap());
case IndexString: return CVariant(derived()->toQString());
default: return basePropertyByIndex(static_cast<const TIndexBaseOfT<Derived> *>(derived()), index);
}