Esempio n. 1
0
void UMLWidget::slotMenuSelection(int sel) {
    QFont font;
    QColor newColour;
    const Uml::Widget_Type wt = m_Type;
    UMLWidget* widget = 0; // use for select the first object properties (fill, line color)

    switch(sel) {
    case ListPopupMenu::mt_Rename:
        m_pDoc -> renameUMLObject(m_pObject);
        // adjustAssocs( getX(), getY() );//adjust assoc lines
        break;

    case ListPopupMenu::mt_Delete:
        //remove self from diagram
        m_pView -> removeWidget(this);
        break;

    //UMLWidgetController::doMouseDoubleClick relies on this implementation
    case ListPopupMenu::mt_Properties:
        if (wt == wt_Actor || wt == wt_UseCase ||
                wt == wt_Package || wt == wt_Interface || wt == wt_Datatype ||
                wt == wt_Component || wt == wt_Artifact ||
                wt == wt_Node || wt == wt_Enum || wt == wt_Entity ||
                (wt == wt_Class && m_pView -> getType() == dt_Class)) {
            showProperties();
        } else if (wt == wt_Object) {
            m_pObject->showProperties();
        } else {
            kWarning() << "making properties dialog for unknown widget type" << endl;
        }
        // adjustAssocs( getX(), getY() );//adjust assoc lines
        break;

    case ListPopupMenu::mt_Line_Color:
    case ListPopupMenu::mt_Line_Color_Selection:
        widget = m_pView->getFirstMultiSelectedWidget();
        if (widget) { newColour = widget->getLineColor(); }
        if( KColorDialog::getColor(newColour) ) {
            m_pView -> selectionSetLineColor( newColour );
            m_pDoc -> setModified(true);
        }
        break;

    case ListPopupMenu::mt_Fill_Color:
    case ListPopupMenu::mt_Fill_Color_Selection:
        widget = m_pView->getFirstMultiSelectedWidget();
        if (widget) { newColour = widget->getFillColour(); }
        if ( KColorDialog::getColor(newColour) ) {
            m_pView -> selectionSetFillColor( newColour );
            m_pDoc -> setModified(true);
        }
        break;

    case ListPopupMenu::mt_Use_Fill_Color:
        m_bUseFillColour = !m_bUseFillColour;
        m_bUsesDiagramUseFillColour = false;
        m_pView->selectionUseFillColor( m_bUseFillColour );
        break;
    case ListPopupMenu::mt_Show_Attributes_Selection:
    case ListPopupMenu::mt_Show_Operations_Selection:
    case ListPopupMenu::mt_Visibility_Selection:
    case ListPopupMenu::mt_DrawAsCircle_Selection:
    case ListPopupMenu::mt_Show_Operation_Signature_Selection:
    case ListPopupMenu::mt_Show_Attribute_Signature_Selection:
    case ListPopupMenu::mt_Show_Packages_Selection:
    case ListPopupMenu::mt_Show_Stereotypes_Selection:
    case ListPopupMenu::mt_Show_Public_Only_Selection:
        m_pView->selectionToggleShow(sel);
        m_pDoc->setModified(true);
        break;

    case ListPopupMenu::mt_ViewCode: {
            UMLClassifier *c = dynamic_cast<UMLClassifier*>(m_pObject);
            if(c)
            {
                UMLApp::app()->viewCodeDocument(c);
            }
            break;
        }

    case ListPopupMenu::mt_Delete_Selection:
        m_pView -> deleteSelection();
        break;

    case ListPopupMenu::mt_Change_Font:
        font = getFont();
        if( KFontDialog::getFont( font, false, m_pView ) )
        {
            setFont( font );
            m_pDoc->setModified(true);
        }
        break;

    case ListPopupMenu::mt_Change_Font_Selection:
        font = getFont();
        if( KFontDialog::getFont( font, false, m_pView ) )
        {
            m_pView -> selectionSetFont( font );
            m_pDoc->setModified(true);
        }
        break;

    case ListPopupMenu::mt_Cut:
        m_pView -> setStartedCut();
        UMLApp::app() -> slotEditCut();
        break;

    case ListPopupMenu::mt_Copy:
        UMLApp::app() -> slotEditCopy();
        break;

    case ListPopupMenu::mt_Paste:
        UMLApp::app() -> slotEditPaste();
        break;

    case ListPopupMenu::mt_Refactoring:
        //check if we are operating on a classifier, or some other kind of UMLObject
        if(dynamic_cast<UMLClassifier*>(m_pObject))
        {
            UMLApp::app()->refactor(static_cast<UMLClassifier*>(m_pObject));
        }
        break;

    case ListPopupMenu::mt_Clone:
        // In principle we clone all the uml objects.
        {
            UMLObject *pClone = m_pObject->clone();
            m_pView->addObject(pClone);
        }
        break;

    case ListPopupMenu::mt_Rename_MultiA:
    case ListPopupMenu::mt_Rename_MultiB:
    case ListPopupMenu::mt_Rename_Name:
    case ListPopupMenu::mt_Rename_RoleAName:
    case ListPopupMenu::mt_Rename_RoleBName:
        {
            FloatingTextWidget *ft = static_cast<FloatingTextWidget*>(this);
            ft->handleRename();
            break;
        }
    }
}
Esempio n. 2
0
/**
 * Captures any popup menu signals for menus it created.
 *
 * @param action The action which has to be executed.
 */
void UMLWidget::slotMenuSelection(QAction* action)
{
    QColor newColor;
    const WidgetBase::WidgetType wt = m_Type;
    UMLWidget* widget = 0; // use for select the first object properties (fill, line color)

    ListPopupMenu::MenuType sel = m_pMenu->getMenuType(action);
    switch (sel) {
    case ListPopupMenu::mt_Rename:
        m_doc->renameUMLObject(m_pObject);
        // adjustAssocs( getX(), getY() );//adjust assoc lines
        break;

    case ListPopupMenu::mt_Delete:
        //remove self from diagram
        m_scene->removeWidget(this);
        break;

        //UMLWidgetController::doMouseDoubleClick relies on this implementation
    case ListPopupMenu::mt_Properties:
        if (wt == WidgetBase::wt_Actor || wt == WidgetBase::wt_UseCase ||
                wt == WidgetBase::wt_Package || wt == WidgetBase::wt_Interface || wt == WidgetBase::wt_Datatype ||
                wt == WidgetBase::wt_Component || wt == WidgetBase::wt_Artifact ||
                wt == WidgetBase::wt_Node || wt == WidgetBase::wt_Enum || wt == WidgetBase::wt_Entity ||
                (wt == WidgetBase::wt_Class && m_scene->type() == Uml::DiagramType::Class)) {
            UMLApp::app()->beginMacro(i18n("Change Properties"));
            showPropertiesDialog();
            UMLApp::app()->endMacro();
        } else if (wt == wt_Object) {
            UMLApp::app()->beginMacro(i18n("Change Properties"));
            m_pObject->showPropertiesPagedDialog();
            UMLApp::app()->endMacro();
        } else {
            uWarning() << "making properties dialog for unknown widget type";
        }
        // adjustAssocs( getX(), getY() );//adjust assoc lines
        break;

    case ListPopupMenu::mt_Line_Color:
        widget = m_scene->getFirstMultiSelectedWidget();
        if (widget) {
            newColor = widget->lineColor();
        }
        if (KColorDialog::getColor(newColor)) {
            m_scene->selectionSetLineColor(newColor);
            m_doc->setModified(true);

        }
        break;

    case ListPopupMenu::mt_Fill_Color:
        widget = m_scene->getFirstMultiSelectedWidget();
        if (widget) {
            newColor = widget->fillColor();
        }
        if (KColorDialog::getColor(newColor)) {
            m_scene->selectionSetFillColor(newColor);
            m_doc->setModified(true);
        }
        break;

    case ListPopupMenu::mt_Use_Fill_Color:
        m_useFillColor = !m_useFillColor;
        m_usesDiagramUseFillColor = false;
        m_scene->selectionUseFillColor(m_useFillColor);
        break;
    case ListPopupMenu::mt_Show_Attributes_Selection:
    case ListPopupMenu::mt_Show_Operations_Selection:
    case ListPopupMenu::mt_Visibility_Selection:
    case ListPopupMenu::mt_DrawAsCircle_Selection:
    case ListPopupMenu::mt_Show_Operation_Signature_Selection:
    case ListPopupMenu::mt_Show_Attribute_Signature_Selection:
    case ListPopupMenu::mt_Show_Packages_Selection:
    case ListPopupMenu::mt_Show_Stereotypes_Selection:
    case ListPopupMenu::mt_Show_Public_Only_Selection:
        m_scene->selectionToggleShow(sel);
        m_doc->setModified(true);
        break;

    case ListPopupMenu::mt_ViewCode: {
        UMLClassifier *c = dynamic_cast<UMLClassifier*>(m_pObject);
        if (c) {
            UMLApp::app()->viewCodeDocument(c);
        }
        break;
    }

    case ListPopupMenu::mt_Delete_Selection:
        m_scene->deleteSelection();
        break;

    case ListPopupMenu::mt_Change_Font:
    case ListPopupMenu::mt_Change_Font_Selection: {
        QFont font = UMLWidget::font();
        if (KFontDialog::getFont(font, KFontChooser::NoDisplayFlags, m_scene)) {
            UMLApp::app()->executeCommand(new CmdChangeFontSelection(m_doc, m_scene, font));
        }
    }
    break;

    case ListPopupMenu::mt_Cut:
        m_scene->setStartedCut();
        UMLApp::app()->slotEditCut();
        break;

    case ListPopupMenu::mt_Copy:
        UMLApp::app()->slotEditCopy();
        break;

    case ListPopupMenu::mt_Paste:
        UMLApp::app()->slotEditPaste();
        break;

    case ListPopupMenu::mt_Refactoring:
        //check if we are operating on a classifier, or some other kind of UMLObject
        if (dynamic_cast<UMLClassifier*>(m_pObject)) {
            UMLApp::app()->refactor(static_cast<UMLClassifier*>(m_pObject));
        }
        break;

    case ListPopupMenu::mt_Clone:
        // In principle we clone all the uml objects.
    {
        UMLObject *pClone = m_pObject->clone();
        m_scene->addObject(pClone);
    }
    break;

    case ListPopupMenu::mt_Rename_MultiA:
    case ListPopupMenu::mt_Rename_MultiB:
    case ListPopupMenu::mt_Rename_Name:
    case ListPopupMenu::mt_Rename_RoleAName:
    case ListPopupMenu::mt_Rename_RoleBName: {
        FloatingTextWidget *ft = static_cast<FloatingTextWidget*>(this);
        ft->handleRename();
        break;
    }

    default:
        uDebug() << "MenuType " << ListPopupMenu::toString(sel) << " not implemented";
    }
}