SchemaEditor::SchemaEditor(QWidget *parent, SchemaGui *schemaGui, Engine * engine, PanelScrollView *panelScrollView) : Q3CanvasView(schemaGui, parent, NAME.c_str(),0), _engine(engine), _schemaGui(schemaGui), _state(IDLE), _zoom(1), _activeConnection(0), _contextMenuPos(0,0), _contextGear(NULL), _panelScrollView(panelScrollView), _selectBox(NULL) { viewport()->setMouseTracking(TRUE); setAcceptDrops(TRUE); _contextMenu = new Q3PopupMenu(this); _gearListMenu = new GearListMenu(this); _gearListMenu->create(); _contextMenu->insertItem("Gears", _gearListMenu); QObject::connect(_gearListMenu, SIGNAL(gearSelected(QString)), this, SLOT(slotMenuGearSelected(QString))); _metaGearListMenu = new MetaGearListMenu(this); _metaGearListMenu->create(); _contextMenu->insertItem("MetaGears", _metaGearListMenu); QObject::connect(_metaGearListMenu, SIGNAL(metaGearSelected(QFileInfo*)), this, SLOT(slotMenuMetaGearSelected(QFileInfo*))); _contextMenu->insertItem("New MetaGear", this, SLOT(slotNewMetaGear())); _gearContextMenu = new Q3PopupMenu(this); _gearContextMenu->insertItem("delete", this, SLOT(slotGearDelete())); _gearContextMenu->insertItem("Properties", this, SLOT(slotGearProperties())); _gearContextMenu->insertItem("ZoomIn", this, SLOT(zoomIn())); _gearContextMenu->insertItem("ZoomOut", this, SLOT(zoomOut())); _gearContextMenu->insertItem("About"); _metaGearContextMenu = new Q3PopupMenu(this); _metaGearContextMenu->insertItem("delete", this, SLOT(slotGearDelete()),Qt::Key_Delete); _metaGearContextMenu->insertItem("Select All", this, SLOT(slotGearSelectAll()),Qt::CTRL + Qt::Key_A); _metaGearContextMenu->insertItem("Copy", this, SLOT(slotGearCopy()),Qt::CTRL + Qt::Key_C); _metaGearContextMenu->insertItem("Paste", this, SLOT(slotGearPaste()),Qt::CTRL + Qt::Key_V); _metaGearContextMenu->insertItem("Properties", this, SLOT(slotGearProperties())); _metaGearContextMenu->insertItem("About"); _metaGearContextMenu->insertSeparator(); _metaGearContextMenu->insertItem("Save MetaGear", this, SLOT(slotSaveMetaGear())); // plug context menu initialization _plugContextMenu = new Q3PopupMenu(this); _plugContextMenu->insertItem("expose", this, SLOT(slotPlugExpose()),0,EXPOSE); _plugContextMenu->insertItem("unexpose", this, SLOT(slotPlugUnexpose()),0,UNEXPOSE); }
void SchemaEditor::buildContextMenus() { _contextMenu = new QMenu(); _gearListMenu = new GearListMenu(_contextMenu); _gearListMenu->create(); MainWindow* mainWindow = MainWindow::getInstance(); QMenu* newGearMenu = _contextMenu->addMenu("Add gear"); QAction * sub = newGearMenu->addMenu(_gearListMenu); sub->setText("Gears"); QObject::connect(_gearListMenu, SIGNAL(gearSelected(QString)), this, SLOT(slotMenuGearSelected(QString))); _metaGearListMenu = new MetaGearListMenu(_contextMenu); _metaGearListMenu->create(); QAction* mgSubAction = newGearMenu->addMenu(_metaGearListMenu); mgSubAction->setText("MetaGears"); QObject::connect(_metaGearListMenu, SIGNAL(metaGearSelected(QFileInfo*)), this, SLOT(slotMenuMetaGearSelected(QFileInfo*))); _contextMenu->addAction("New MetaGear", this, SLOT(slotNewMetaGear())); _contextMenu->addAction(mainWindow->_actZoomIn); _contextMenu->addAction(mainWindow->_actZoomOut); _contextMenu->addAction(mainWindow->_actSelectAll); _contextMenu->addAction(mainWindow->_actDeleteSelected); _contextMenu->addAction(mainWindow->_actCopy); _contextMenu->addAction(mainWindow->_actPaste); _gearContextMenu = new QMenu(); _gearContextMenu->addAction("Properties", this, SLOT(slotGearProperties())); _gearContextMenu->addAction("About"); _metaGearContextMenu = new QMenu(); _metaGearContextMenu->addAction("Properties", this, SLOT(slotGearProperties())); _metaGearContextMenu->addAction("About"); _metaGearContextMenu->addSeparator(); _metaGearContextMenu->addAction("Save MetaGear", this, SLOT(slotSaveMetaGear())); // plug context menu initialization _plugContextMenu = new QMenu(); _exposePlugAction = _plugContextMenu->addAction("Expose", this, SLOT(slotPlugToggleExpose())); }