libqutim  0.3.3.0
qutim_sdk_0_3::MenuController Class Reference

#include <menucontroller.h>

+ Inheritance diagram for qutim_sdk_0_3::MenuController:

Public Types

enum  MenuFlag { ShowSelfActions = 0x01, ShowSuperActions = 0x02, ShowOwnerActions = 0x04 }
 

Public Slots

void showMenu (const QPoint &pos)
 

Public Member Functions

 MenuController (QObject *parent=0)
 
virtual ~MenuController ()
 
template<int N>
void addAction (const ActionGenerator *gen, const char(&menu)[N])
 
template<int N>
Q_INLINE_TEMPLATE void addAction (const ActionGenerator *gen, const char(&menu)[N])
 
template<typename T , int N>
Q_INLINE_TEMPLATE void addAction (const ActionGenerator *gen, const char(&menu)[N])
 
template<typename T >
Q_INLINE_TEMPLATE void addAction (const ActionGenerator *gen, const QList< QByteArray > &menu)
 
void addAction (const ActionGenerator *gen, const QList< QByteArray > &menu=QList< QByteArray >())
 
template<int N>
Q_INLINE_TEMPLATE void addAction (const ActionGenerator *gen, const QMetaObject *meta, const char(&menu)[N])
 
template<typename T >
Q_INLINE_TEMPLATE T get (QAction *action)
 
QMenu * menu (bool deleteOnClose=true) const
 
bool removeAction (const ActionGenerator *gen)
 

Static Public Member Functions

template<typename T , int N>
static void addAction (const ActionGenerator *gen, const char(&menu)[N])
 
template<typename T >
static void addAction (const ActionGenerator *gen, const QList< QByteArray > &menu=QList< QByteArray >())
 
template<int N>
static void addAction (const ActionGenerator *gen, const QMetaObject *meta, const char(&menu)[N])
 
static void addAction (const ActionGenerator *gen, const QMetaObject *meta, const QList< QByteArray > &menu=QList< QByteArray >())
 
static QObject * get (QAction *)
 
template<typename T >
static T get (QAction *)
 

Protected Member Functions

void setMenuFlags (const MenuFlags &flags)
 
void setMenuOwner (MenuController *controller)
 
virtual void virtual_hook (int id, void *data)
 

Detailed Description

MenuController is base type for objects which are able to have menu.

Example of how to register and use actions:

class MyObject : public QObject
{
Q_OBJECT
public:
MyObject(QObject *parent = 0);
void registerController(MenuController *);
public slots:
void onAction();
};
MyObject::MyObject(QObject *parent) : QObject(parent)
{
}
void MyObject::registerController(MenuController *controller)
{
ActionGenerator *gen = new ActionGenerator(..., this, SLOT(onAction());
controller->addAction(gen);
}
MyObject::onAction()
{
MenuController *controller = MenuController::getController(sender());
doSmth();
}

Member Enumeration Documentation

◆ MenuFlag

Enumerator
ShowSelfActions 
ShowSuperActions 
ShowOwnerActions 

Constructor & Destructor Documentation

◆ MenuController()

qutim_sdk_0_3::MenuController::MenuController ( QObject *  parent = 0)

Constructs MenuController with parent.

◆ ~MenuController()

virtual qutim_sdk_0_3::MenuController::~MenuController ( )
virtual

Destructor.

Member Function Documentation

◆ addAction() [1/10]

template<int N>
void qutim_sdk_0_3::MenuController::addAction ( const ActionGenerator gen,
const char(&)  menu[N] 
)

Add action gen to this object.

If menu is not empty action will be situated not in the root of menu, but in the submenu hierarchy; menu contains list of null-terminated strings, each of them is untranslated name of submenu.

◆ addAction() [2/10]

template<typename T , int N>
static void qutim_sdk_0_3::MenuController::addAction ( const ActionGenerator gen,
const char(&)  menu[N] 
)
static

Add action gen to every object of type T.

If menu is not empty action will be situated not in the root of menu, but in the submenu hierarchy; menu contains list of null-terminated strings, each of them is untranslated name of submenu.

◆ addAction() [3/10]

template<int N>
Q_INLINE_TEMPLATE void qutim_sdk_0_3::MenuController::addAction ( const ActionGenerator gen,
const char(&)  menu[N] 
)

◆ addAction() [4/10]

template<typename T , int N>
Q_INLINE_TEMPLATE void qutim_sdk_0_3::MenuController::addAction ( const ActionGenerator gen,
const char(&)  menu[N] 
)

◆ addAction() [5/10]

template<typename T >
Q_INLINE_TEMPLATE void qutim_sdk_0_3::MenuController::addAction ( const ActionGenerator gen,
const QList< QByteArray > &  menu 
)

◆ addAction() [6/10]

void qutim_sdk_0_3::MenuController::addAction ( const ActionGenerator gen,
const QList< QByteArray > &  menu = QList< QByteArray >() 
)

Add action gen to this object.

If menu is not empty action will be situated not in the root of menu, but in the submenu hierarchy; menu contains untranslated names of submenus in the tree. deleteOnClose

Deprecated:

◆ addAction() [7/10]

template<typename T >
static void qutim_sdk_0_3::MenuController::addAction ( const ActionGenerator gen,
const QList< QByteArray > &  menu = QList< QByteArray >() 
)
static

Add action gen to every object of type T.

If menu is not empty action will be situated not in the root of menu, but in the submenu hierarchy; menu contains untranslated names of submenus in the tree.

◆ addAction() [8/10]

template<int N>
static void qutim_sdk_0_3::MenuController::addAction ( const ActionGenerator gen,
const QMetaObject *  meta,
const char(&)  menu[N] 
)
static

Add action gen to every object with QMetaObject meta.

If menu is not empty action will be situated not in the root of menu, but in the submenu hierarchy; menu contains list of null-terminated strings, each of them is untranslated name of submenu.

◆ addAction() [9/10]

template<int N>
Q_INLINE_TEMPLATE void qutim_sdk_0_3::MenuController::addAction ( const ActionGenerator gen,
const QMetaObject *  meta,
const char(&)  menu[N] 
)

◆ addAction() [10/10]

static void qutim_sdk_0_3::MenuController::addAction ( const ActionGenerator gen,
const QMetaObject *  meta,
const QList< QByteArray > &  menu = QList< QByteArray >() 
)
static

Add action gen to every object with QMetaObject meta.

If menu is not empty action will be situated not in the root of menu, but in the submenu hierarchy; menu contains untranslated names of submenus in the tree.

◆ get() [1/3]

static QObject* qutim_sdk_0_3::MenuController::get ( QAction *  )
static
  Returns MenuController for action which has emitted signal
  connected to this slot. \a obj must be result of sender().

  Example of use inside slot method:
  \code

void MyObject::onAction() { Account *account = MenuController::get<Account>(sender()); doStuff(); }

◆ get() [2/3]

template<typename T >
static T qutim_sdk_0_3::MenuController::get ( QAction *  )
static

◆ get() [3/3]

template<typename T >
Q_INLINE_TEMPLATE T qutim_sdk_0_3::MenuController::get ( QAction *  action)

◆ menu()

QMenu* qutim_sdk_0_3::MenuController::menu ( bool  deleteOnClose = true) const

Generate menu for this object and return pointer to it.

Menu will be deleted after closing if deleteOnClose is true.

◆ removeAction()

bool qutim_sdk_0_3::MenuController::removeAction ( const ActionGenerator gen)

◆ setMenuFlags()

void qutim_sdk_0_3::MenuController::setMenuFlags ( const MenuFlags &  flags)
protected

◆ setMenuOwner()

void qutim_sdk_0_3::MenuController::setMenuOwner ( MenuController controller)
protected

Add to menu of this object also actions from another controller.

◆ showMenu

void qutim_sdk_0_3::MenuController::showMenu ( const QPoint &  pos)
slot

Show menu at position pos and delete it after closing.

It's equivalent for

menu(true)->popup(pos)

◆ virtual_hook()

virtual void qutim_sdk_0_3::MenuController::virtual_hook ( int  id,
void *  data 
)
protectedvirtual

The documentation for this class was generated from the following file:
qutim_sdk_0_3::MenuController::menu
QMenu * menu(bool deleteOnClose=true) const
Generate menu for this object and return pointer to it.
qutim_sdk_0_3::MenuController::MenuController
MenuController(QObject *parent=0)
Constructs MenuController with parent.

Generated by Doxygen