better compile time checks

This commit is contained in:
Uwe Rathmann 2018-11-03 17:14:09 +01:00
parent 8227d8446c
commit aeb29e855a
1 changed files with 72 additions and 38 deletions

View File

@ -31,30 +31,40 @@ class QSK_EXPORT QskShortcutMap
bool autoRepeat, const QObject* receiver, const char* method );
// functor based slots
template< typename T >
static int addShortcut( const QKeySequence&,
bool autoRepeat, T function );
template< typename T, QskMetaFunctionTraits::IsFunctorOrStaticFunction< T >* = nullptr >
static int addShortcut( const QKeySequence&, bool autoRepeat, T function );
template< typename T >
static int addShortcut( const QKeySequence&,
bool autoRepeat, const QObject* context, T function );
template< typename T, QskMetaFunctionTraits::IsFunctorOrStaticFunction< T >* = nullptr >
static int addShortcut( QQuickItem*, const QKeySequence&, bool autoRepeat, T function );
template< typename T >
static int addShortcut( QQuickItem*, const QKeySequence&,
bool autoRepeat, T function );
template< typename T, QskMetaFunctionTraits::IsFunctorOrStaticFunction< T >* = nullptr >
static int addShortcut( QQuickWindow*, const QKeySequence&, bool autoRepeat, T function );
template< typename T >
template< typename T, QskMetaFunctionTraits::IsFunctorOrStaticFunction< T >* = nullptr >
static int addShortcut( const QKeySequence&, bool autoRepeat,
const QObject* context, T function );
template< typename T, QskMetaFunctionTraits::IsFunctorOrStaticFunction< T >* = nullptr >
static int addShortcut( QQuickItem*, const QKeySequence&,
bool autoRepeat, const QObject* context, T function );
template< typename T >
static int addShortcut( QQuickWindow*, const QKeySequence&,
bool autoRepeat, T function );
template< typename T >
template< typename T, QskMetaFunctionTraits::IsFunctorOrStaticFunction< T >* = nullptr >
static int addShortcut( QQuickWindow*, const QKeySequence&,
bool autoRepeat, const QObject* context, T function );
template< typename T, QskMetaFunctionTraits::IsMemberFunction< T >* = nullptr >
static int addShortcut( const QKeySequence&, bool autoRepeat,
const typename QtPrivate::FunctionPointer< T >::Object* receiver, T function );
template< typename T, QskMetaFunctionTraits::IsMemberFunction< T >* = nullptr >
static int addShortcut( QQuickItem*, const QKeySequence&, bool autoRepeat,
const typename QtPrivate::FunctionPointer< T >::Object* receiver, T function );
template< typename T, QskMetaFunctionTraits::IsMemberFunction< T >* = nullptr >
static int addShortcut( QQuickWindow*, const QKeySequence&, bool autoRepeat,
const typename QtPrivate::FunctionPointer< T >::Object* receiver, T function );
static bool contextMatcher( const QQuickItem*, Qt::ShortcutContext );
private:
@ -90,14 +100,31 @@ inline int QskShortcutMap::addShortcut(
return addMethod( item, sequence, autoRepeat, receiver, method );
}
template< typename T >
template< typename T, QskMetaFunctionTraits::IsFunctorOrStaticFunction< T >* >
inline int QskShortcutMap::addShortcut(
const QKeySequence& sequence, bool autoRepeat, T function )
{
return addFunctionT( nullptr, sequence, autoRepeat, nullptr, function );
}
template< typename T >
template< typename T, QskMetaFunctionTraits::IsFunctorOrStaticFunction< T >* >
inline int QskShortcutMap::addShortcut(
QQuickItem* item, const QKeySequence& sequence,
bool autoRepeat, T function )
{
return addFunctionT( item, sequence, autoRepeat, nullptr, function );
}
template< typename T, QskMetaFunctionTraits::IsFunctorOrStaticFunction< T >* >
inline int QskShortcutMap::addShortcut(
QQuickWindow* window, const QKeySequence& sequence,
bool autoRepeat, T function )
{
auto item = window ? window->contentItem() : nullptr;
return addFunctionT( item, sequence, autoRepeat, nullptr, function );
}
template< typename T, QskMetaFunctionTraits::IsFunctorOrStaticFunction< T >* >
inline int QskShortcutMap::addShortcut(
const QKeySequence& sequence, bool autoRepeat,
const QObject* context, T function )
@ -105,33 +132,15 @@ inline int QskShortcutMap::addShortcut(
return addFunctionT( nullptr, sequence, autoRepeat, context, function );
}
template< typename T >
inline int QskShortcutMap::addShortcut(
QQuickItem* item, const QKeySequence& sequence,
bool autoRepeat, T function )
{
return addFunctionT( item, sequence, autoRepeat, nullptr, function );
}
template< typename T >
template< typename T, QskMetaFunctionTraits::IsFunctorOrStaticFunction< T >* >
inline int QskShortcutMap::addShortcut(
QQuickItem* item, const QKeySequence& sequence, bool autoRepeat,
const QObject* context, T function )
{
return addFunctionT( item, sequence, autoRepeat,
context, QskMetaFunction( function ) );
return addFunctionT( item, sequence, autoRepeat, context, function );
}
template< typename T >
inline int QskShortcutMap::addShortcut(
QQuickWindow* window, const QKeySequence& sequence,
bool autoRepeat, T function )
{
auto item = window ? window->contentItem() : nullptr;
return addFunctionT( item, sequence, autoRepeat, nullptr, function );
}
template< typename T >
template< typename T, QskMetaFunctionTraits::IsFunctorOrStaticFunction< T >* >
inline int QskShortcutMap::addShortcut(
QQuickWindow* window, const QKeySequence& sequence,
bool autoRepeat, const QObject* context, T function )
@ -140,6 +149,31 @@ inline int QskShortcutMap::addShortcut(
return addFunctionT( item, sequence, autoRepeat, context, function );
}
template< typename T, QskMetaFunctionTraits::IsMemberFunction< T >* >
inline int QskShortcutMap::addShortcut(
const QKeySequence& sequence, bool autoRepeat,
const typename QtPrivate::FunctionPointer< T >::Object* receiver, T function )
{
return addFunctionT( nullptr, sequence, autoRepeat, receiver, function );
}
template< typename T, QskMetaFunctionTraits::IsMemberFunction< T >* >
inline int QskShortcutMap::addShortcut(
QQuickItem* item, const QKeySequence& sequence, bool autoRepeat,
const typename QtPrivate::FunctionPointer< T >::Object* receiver, T function )
{
return addFunctionT( item, sequence, autoRepeat, receiver, function );
}
template< typename T, QskMetaFunctionTraits::IsMemberFunction< T >* >
inline int QskShortcutMap::addShortcut(
QQuickWindow* window, const QKeySequence& sequence, bool autoRepeat,
const typename QtPrivate::FunctionPointer< T >::Object* receiver, T function )
{
auto item = window ? window->contentItem() : nullptr;
return addFunctionT( item, sequence, autoRepeat, receiver, function );
}
template< typename T >
inline int QskShortcutMap::addFunctionT(
QQuickItem* item, const QKeySequence& sequence, bool autoRepeat,