QDragObject *ActionListView::dragObject() { ActionItem *i = (ActionItem*)currentItem(); if ( !i ) return 0; QStoredDrag *drag = 0; if ( i->action() ) { drag = new ActionDrag( i->action(), viewport() ); drag->setPixmap( i->action()->iconSet().pixmap() ); } else { drag = new ActionDrag( i->actionGroup(), viewport() ); drag->setPixmap( i->actionGroup()->iconSet().pixmap() ); } return drag; }
QDragObject *ActionListView::dragObject() { ActionItem *i = (ActionItem*)currentItem(); if ( !i ) return 0; QStoredDrag *drag = 0; if ( i->action() ) { drag = new QStoredDrag( "application/x-designer-actions", viewport() ); QString s = QString::number( (long)i->action() ); // #### huha, that is evil drag->setEncodedData( QCString( s.latin1() ) ); drag->setPixmap( i->action()->iconSet().pixmap() ); } else { drag = new QStoredDrag( "application/x-designer-actiongroup", viewport() ); QString s = QString::number( (long)i->actionGroup() ); // #### huha, that is evil drag->setEncodedData( QCString( s.latin1() ) ); drag->setPixmap( i->actionGroup()->iconSet().pixmap() ); } return drag; }
void QDesignerToolBar::buttonMouseMoveEvent( QMouseEvent *e, QObject *o ) { if ( widgetInserting || ( e->state() & LeftButton ) == 0 ) return; if ( QABS( QPoint( dragStartPos - e->pos() ).manhattanLength() ) < QApplication::startDragDistance() ) return; QMap<QWidget*, QAction*>::Iterator it = actionMap.find( (QWidget*)o ); if ( it == actionMap.end() ) return; QAction *a = *it; if ( !a ) return; 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(); QApplication::sendPostedEvents(); adjustSize(); QString type = ::qt_cast<QActionGroup*>(a) ? QString( "application/x-designer-actiongroup" ) : ::qt_cast<QSeparatorAction*>(a) ? QString( "application/x-designer-separator" ) : QString( "application/x-designer-actions" ); QStoredDrag *drag = new QStoredDrag( type, this ); QString s = QString::number( (long)a ); // #### huha, that is evil drag->setEncodedData( QCString( s.latin1() ) ); drag->setPixmap( a->iconSet().pixmap() ); if ( ::qt_cast<QDesignerAction*>(a) ) { if ( formWindow->widgets()->find( ( (QDesignerAction*)a )->widget() ) ) formWindow->selectWidget( ( (QDesignerAction*)a )->widget(), FALSE ); } if ( !drag->drag() ) { AddActionToToolBarCommand *cmd = new AddActionToToolBarCommand( tr( "Add Action '%1' to Toolbar '%2'" ). arg( a->name() ).arg( caption() ), formWindow, a, this, index ); formWindow->commandHistory()->addCommand( cmd ); cmd->execute(); } lastIndicatorPos = QPoint( -1, -1 ); indicator->hide(); }