void QDesignerToolBar::dragMoveEvent( QDragMoveEvent *e ) { if (ActionDrag::canDecode(e)) { e->accept(); drawIndicator( calcIndicatorPos( e->pos() ) ); } }
void QDesignerToolBar::dragMoveEvent( QDragMoveEvent *e ) { if ( e->provides( "application/x-designer-actions" ) || e->provides( "application/x-designer-actiongroup" ) || e->provides( "application/x-designer-separator" ) ) e->accept(); else return; drawIndicator( calcIndicatorPos( e->pos() ) ); }
void QDesignerToolBar::buttonContextMenuEvent( QContextMenuEvent *e, QObject *o ) { e->accept(); QPopupMenu menu( 0 ); const int ID_DELETE = 1; const int ID_SEP = 2; const int ID_DELTOOLBAR = 3; QMap<QWidget*, QAction*>::Iterator it = actionMap.find( (QWidget*)o ); if ( it != actionMap.end() && ::qt_cast<QSeparatorAction*>(*it) ) menu.insertItem( tr( "Delete Separator" ), ID_DELETE ); else menu.insertItem( tr( "Delete Item" ), ID_DELETE ); menu.insertItem( tr( "Insert Separator" ), ID_SEP ); menu.insertSeparator(); menu.insertItem( tr( "Delete Toolbar" ), ID_DELTOOLBAR ); int res = menu.exec( e->globalPos() ); if ( res == ID_DELETE ) { QMap<QWidget*, QAction*>::Iterator it = actionMap.find( (QWidget*)o ); if ( it == actionMap.end() ) return; QAction *a = *it; int index = actionList.find( a ); RemoveActionFromToolBarCommand *cmd = new RemoveActionFromToolBarCommand( tr( "Delete Action '%1' from Toolbar '%2'" ). arg( a->name() ).arg( caption() ), formWindow, a, this, index ); formWindow->commandHistory()->addCommand( cmd ); cmd->execute(); } else if ( res == ID_SEP ) { calcIndicatorPos( mapFromGlobal( e->globalPos() ) ); QAction *a = new QSeparatorAction( 0 ); int index = actionList.findRef( *actionMap.find( insertAnchor ) ); if ( index != -1 && afterAnchor ) ++index; if ( !insertAnchor ) index = 0; AddActionToToolBarCommand *cmd = new AddActionToToolBarCommand( tr( "Add Separator to Toolbar '%1'" ). arg( a->name() ), formWindow, a, this, index ); formWindow->commandHistory()->addCommand( cmd ); cmd->execute(); } else if ( res == ID_DELTOOLBAR ) { RemoveToolBarCommand *cmd = new RemoveToolBarCommand( tr( "Delete Toolbar '%1'" ).arg( name() ), formWindow, 0, this ); formWindow->commandHistory()->addCommand( cmd ); cmd->execute(); } }
void QDesignerToolBar::doInsertWidget( const QPoint &p ) { if ( formWindow != MainWindow::self->formWindow() ) return; calcIndicatorPos( p ); QWidget *w = WidgetFactory::create( MainWindow::self->currentTool(), this, 0, TRUE ); installEventFilters( w ); MainWindow::self->formWindow()->insertWidget( w, TRUE ); QDesignerAction *a = new QDesignerAction( w, parent() ); int index = actionList.findRef( *actionMap.find( insertAnchor ) ); if ( index != -1 && afterAnchor ) ++index; if ( !insertAnchor ) index = 0; AddActionToToolBarCommand *cmd = new AddActionToToolBarCommand( tr( "Add Widget '%1' to Toolbar '%2'" ). arg( w->name() ).arg( caption() ), formWindow, a, this, index ); formWindow->commandHistory()->addCommand( cmd ); cmd->execute(); MainWindow::self->resetTool(); }