libqutim  0.3.1.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 ()
 
void addAction (const ActionGenerator *gen, const QList< QByteArray > &menu=QList< QByteArray >())
 
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<int N>
Q_INLINE_TEMPLATE void addAction (const ActionGenerator *gen, const QMetaObject *meta, const char(&menu)[N])
 
QMenu * menu (bool deleteOnClose=true) const
 
bool removeAction (const ActionGenerator *gen)
 

Static Public Member Functions

static void addAction (const ActionGenerator *gen, const QMetaObject *meta, const QList< QByteArray > &menu=QList< QByteArray >())
 
template<typename T >
static void addAction (const ActionGenerator *gen, const QList< QByteArray > &menu=QList< QByteArray >())
 
template<typename T , int N>
static void addAction (const ActionGenerator *gen, const char(&menu)[N])
 
template<int N>
static void addAction (const ActionGenerator *gen, const QMetaObject *meta, const char(&menu)[N])
 
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

Enumerator
ShowSelfActions 
ShowSuperActions 
ShowOwnerActions 

Constructor & Destructor Documentation

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

Constructs MenuController with parent.

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

Destructor.

Member Function Documentation

Q_INLINE_TEMPLATE 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 1.

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.

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.

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.

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.

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.

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

Returns MenuController for action which has emitted signal connected to this slot.

obj must be result of sender().

 Example of use inside slot method:
void MyObject::onAction()
{
Account *account = MenuController::get<Account>(sender());
doStuff();
}
template<typename T >
static T qutim_sdk_0_3::MenuController::get ( QAction *  )
static
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.

bool qutim_sdk_0_3::MenuController::removeAction ( const ActionGenerator gen)
void qutim_sdk_0_3::MenuController::setMenuFlags ( const MenuFlags &  flags)
protected
void qutim_sdk_0_3::MenuController::setMenuOwner ( MenuController controller)
protected

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

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 void qutim_sdk_0_3::MenuController::virtual_hook ( int  id,
void *  data 
)
protectedvirtual

The documentation for this class was generated from the following file:

Generated by Doxygen