libqutim
0.3.1.0
|
#include <menucontroller.h>
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]) |
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) |
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(); }
qutim_sdk_0_3::MenuController::MenuController | ( | QObject * | parent = 0 | ) |
Constructs MenuController with parent.
virtual qutim_sdk_0_3::MenuController::~MenuController | ( | ) | [virtual] |
Destructor.
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.
Q_INLINE_TEMPLATE 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.
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.
Q_INLINE_TEMPLATE 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.
Q_INLINE_TEMPLATE 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.
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();
}
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] |
virtual void qutim_sdk_0_3::MenuController::virtual_hook | ( | int | id, |
void * | data | ||
) | [protected, virtual] |