#include <Iguana/Studio/interface/IgQtAppMenuService.h>
Public Member Functions | |
QPopupMenu * | findByName (QMenuData *menu, const char *itemName) |
IgQtAppMenuService (IgState *state, QWidget *mainWindow) | |
QMenuBar * | menuBar (void) |
QPopupMenu * | subMenu (int id1, int id2) |
QPopupMenu * | subMenu (int id) |
~IgQtAppMenuService (void) | |
Static Public Member Functions | |
static int | index (QMenuData *menu, int id) |
static void | insertItem (QMenuData *parentMenu, const QString &text, QObject *target, const char *slot, int id, IgState *state=0) |
static int | isIdThere (QMenuData *menu, int id) |
Static Public Attributes | |
static const int | MENU_GROUP_RANGE = 1000 |
static const int | MENU_ID_FILE = 0 |
static const int | MENU_ID_FILE_PRINT = 2 |
static const int | MENU_ID_FILE_QUIT |
static const int | MENU_ID_FILE_SAVE = 1 |
static const int | MENU_ID_HELP = 100 * MENU_GROUP_RANGE |
static const int | MENU_SUBGROUP_RANGE = 50 |
Private Member Functions | |
IG_DECLARE_STATE_ELEMENT (IgQtAppMenuService) | |
IgQtAppMenuService (const IgQtAppMenuService &) | |
IgQtAppMenuService & | operator= (const IgQtAppMenuService &) |
Private Attributes | |
QMainWindow * | m_mainWindow |
IgState * | m_state |
Definition at line 25 of file IgQtAppMenuService.h.
IgQtAppMenuService::IgQtAppMenuService | ( | IgState * | state, | |
QWidget * | mainWindow | |||
) |
Definition at line 31 of file IgQtAppMenuService.cc.
References ASSERT, index(), m_mainWindow, MENU_ID_FILE, MENU_ID_FILE_QUIT, and IgState::put().
00032 : m_state (state), 00033 m_mainWindow (dynamic_cast<QMainWindow *> (mainWindow)) 00034 { 00035 ASSERT (state); 00036 ASSERT (mainWindow); 00037 ASSERT (m_mainWindow); 00038 state->put (s_key, this); 00039 00040 QMenuBar *menubar = m_mainWindow->menuBar (); 00041 QPopupMenu *filemenu = new QPopupMenu (m_mainWindow); 00042 00043 menubar->insertItem ("&File", filemenu, MENU_ID_FILE, 00044 index (menubar, MENU_ID_FILE)); 00045 filemenu->setCaption ("File"); 00046 filemenu->insertTearOffHandle (); 00047 filemenu->insertItem ("&Quit", qApp, SLOT(quit()), 00048 Qt::CTRL+Qt::Key_Q, MENU_ID_FILE_QUIT, 00049 index (filemenu, MENU_ID_FILE_QUIT)); 00050 menubar->show (); 00051 }
IgQtAppMenuService::~IgQtAppMenuService | ( | void | ) |
Definition at line 53 of file IgQtAppMenuService.cc.
References ASSERT, IgState::detach(), m_mainWindow, and m_state.
00054 { 00055 ASSERT (m_state); 00056 ASSERT (m_mainWindow); 00057 00058 m_state->detach (s_key); 00059 m_mainWindow->menuBar ()->clear (); 00060 }
IgQtAppMenuService::IgQtAppMenuService | ( | const IgQtAppMenuService & | ) | [private] |
QPopupMenu * IgQtAppMenuService::findByName | ( | QMenuData * | menu, | |
const char * | itemName | |||
) |
Definition at line 94 of file IgQtAppMenuService.cc.
00095 { 00096 ASSERT (menu); 00097 00098 for (unsigned int i = 0; i < menu->count (); i++) 00099 { 00100 QMenuItem *item = menu->findItem (menu->idAt (i)); 00101 00102 if (item->text () == itemName) 00103 return item->popup (); 00104 } 00105 return 0; 00106 }
IgQtAppMenuService::IG_DECLARE_STATE_ELEMENT | ( | IgQtAppMenuService | ) | [private] |
Definition at line 109 of file IgQtAppMenuService.cc.
References ASSERT, i, and int.
Referenced by IgPage::IgPage(), IgQtAppDebugService::IgQtAppDebugService(), IgQtAppHelpService::IgQtAppHelpService(), IgQtAppMenuService(), IgStudioCentre::IgStudioCentre(), Ig2DWindow::initMenu(), IgRZWindow::initMenu(), Ig3DWindow::initMenu(), IgLegoWindow::initMenu(), IgRPhiWindow::initMenu(), Ig3DBaseWindow::initMenu(), IgSpareWindow::initMenu(), insertItem(), IgPage::registerView(), VisConfiguration::VisConfiguration(), and VisEventMenu::VisEventMenu().
00110 { 00111 ASSERT (menu); 00112 00113 for (int i = 0; i < (int) menu->count (); ++i) 00114 if (menu->idAt (i) >= id) 00115 return i; 00116 00117 return menu->count (); 00118 }
void IgQtAppMenuService::insertItem | ( | QMenuData * | parentMenu, | |
const QString & | text, | |||
QObject * | target, | |||
const char * | slot, | |||
int | id, | |||
IgState * | state = 0 | |||
) | [static] |
Definition at line 163 of file IgQtAppMenuService.cc.
References IgQtAppContextService::addOnFocusIn(), IgQtAppContextService::addOnFocusOut(), ASSERT, connectMenuItem(), lat::CreateCallback(), data, disconnectMenuItem(), DBSPlugin::get(), index(), isIdThere(), MenuConnection::m_id, MenuConnection::m_menu, MenuConnection::m_slot, and MenuConnection::m_target.
Referenced by Ig3DBaseWindow::initMenu().
00169 { 00170 if (isIdThere (parentMenu, id) == -1) 00171 { 00172 parentMenu->insertItem (text, 00173 target, 00174 slot, 00175 0, 00176 id, 00177 IgQtAppMenuService::index (parentMenu, id)); 00178 } 00179 00180 if (state) 00181 { 00182 00183 // if a state is passed, than the connection between the 00184 // target and the menuitem is context sensitive. 00185 IgQtAppContextService *cs = IgQtAppContextService::get (state); 00186 MenuConnection *data = new MenuConnection; 00187 ASSERT (cs); 00188 ASSERT (data); 00189 00190 data->m_menu = parentMenu; 00191 data->m_id = id; 00192 data->m_target = target; 00193 data->m_slot = slot ? slot : ""; 00194 00195 cs->addOnFocusIn (lat::CreateCallback (&connectMenuItem, 00196 data)); 00197 00198 cs->addOnFocusOut (lat::CreateCallback (&disconnectMenuItem, 00199 data)); 00200 disconnectMenuItem (data); 00201 } 00202 }
Definition at line 121 of file IgQtAppMenuService.cc.
References ASSERT, i, and int.
Referenced by Ig2DWindow::initMenu(), IgRZWindow::initMenu(), Ig3DWindow::initMenu(), IgLegoWindow::initMenu(), IgRPhiWindow::initMenu(), Ig3DBaseWindow::initMenu(), IgSpareWindow::initMenu(), and insertItem().
00122 { 00123 ASSERT (menu); 00124 00125 for (int i = 0; i < (int) menu->count (); ++i) 00126 if (menu->idAt (i) == id) 00127 return i; 00128 return -1; 00129 }
QMenuBar * IgQtAppMenuService::menuBar | ( | void | ) |
Definition at line 63 of file IgQtAppMenuService.cc.
References m_mainWindow.
Referenced by IgPage::IgPage(), and subMenu().
00064 { 00065 return m_mainWindow->menuBar (); 00066 }
IgQtAppMenuService& IgQtAppMenuService::operator= | ( | const IgQtAppMenuService & | ) | [private] |
Definition at line 78 of file IgQtAppMenuService.cc.
References subMenu().
00079 { 00080 QPopupMenu *item1 = subMenu (id1); 00081 if (item1) 00082 { 00083 QMenuItem *item2 = item1->findItem (id2); 00084 if (item2) 00085 { 00086 return item2->popup (); 00087 } 00088 } 00089 00090 return 0; 00091 }
QPopupMenu * IgQtAppMenuService::subMenu | ( | int | id | ) |
Definition at line 69 of file IgQtAppMenuService.cc.
References menuBar().
Referenced by IgPage::IgPage(), Ig3DBaseWindow::initMenu(), IgPage::registerView(), and subMenu().
00070 { 00071 QMenuItem *item = menuBar ()->findItem (id); 00072 if (item) 00073 return item->popup (); 00074 return 0; 00075 }
QMainWindow* IgQtAppMenuService::m_mainWindow [private] |
Definition at line 63 of file IgQtAppMenuService.h.
Referenced by IgQtAppMenuService(), menuBar(), and ~IgQtAppMenuService().
IgState* IgQtAppMenuService::m_state [private] |
const int IgQtAppMenuService::MENU_GROUP_RANGE = 1000 [static] |
Definition at line 29 of file IgQtAppMenuService.h.
const int IgQtAppMenuService::MENU_ID_FILE = 0 [static] |
Definition at line 32 of file IgQtAppMenuService.h.
Referenced by IgPage::IgPage(), IgQtAppMenuService(), IgStudioCentre::IgStudioCentre(), and Ig3DBaseWindow::initMenu().
const int IgQtAppMenuService::MENU_ID_FILE_PRINT = 2 [static] |
const int IgQtAppMenuService::MENU_ID_FILE_QUIT [static] |
Initial value:
(MENU_ID_FILE + 10 * MENU_SUBGROUP_RANGE)
Definition at line 35 of file IgQtAppMenuService.h.
Referenced by IgQtAppMenuService().
const int IgQtAppMenuService::MENU_ID_FILE_SAVE = 1 [static] |
const int IgQtAppMenuService::MENU_ID_HELP = 100 * MENU_GROUP_RANGE [static] |
Definition at line 37 of file IgQtAppMenuService.h.
const int IgQtAppMenuService::MENU_SUBGROUP_RANGE = 50 [static] |
Definition at line 30 of file IgQtAppMenuService.h.