Esempio n. 1
0
bool UMLClipboard::checkPasteWidgets( UMLWidgetList & widgetList ) {
    bool retval = true;
    UMLWidget * p = 0;
    UMLWidgetListIt it( widgetList );
    while ( ( p = it.current()) != 0 ) {
        ++it;
        switch( p -> getBaseType() ) {
        case Uml::wt_Note:
            break;

        case Uml::wt_Text:
            {
                FloatingTextWidget *ft = static_cast<FloatingTextWidget*>(p);
                if (ft->getRole() != Uml::tr_Floating) {
                    widgetList.remove(p);
                    delete ft;
                    retval = false;
                }
            }
            break;

        default:
            widgetList.remove(p);
            delete p;
            retval = false;
            break;
        }
    }
    return retval;
}
Esempio n. 2
0
bool UMLWidget::activate(IDChangeLog* /*ChangeLog  = 0 */) {
    if (widgetHasUMLObject(m_Type) && m_pObject == NULL) {
        m_pObject = m_pDoc->findObjectById(m_nId);
        if (m_pObject == NULL) {
            kError() << "UMLWidget::activate: cannot find UMLObject with id="
                << ID2STR(m_nId) << endl;
            return false;
        }
    }
    setFont(m_Font);
    setSize(getWidth(), getHeight());
    m_bActivated = true;
    updateComponentSize();
    if (m_pView->getPaste()) {
        FloatingTextWidget * ft = 0;
        QPoint point = m_pView -> getPastePoint();
        int x = point.x() + getX();
        int y = point.y() + getY();
        x = x < 0?0:x;
        y = y < 0?0:y;
        if( m_pView -> getType() == dt_Sequence ) {
            switch( getBaseType() ) {
            case wt_Object:
            case wt_Message:
                setY( getY() );
                setX( x );
                break;

            case wt_Text:
                ft = static_cast<FloatingTextWidget *>( this );
                if (ft->getRole() == tr_Seq_Message) {
                    setX( x );
                    setY( getY() );
                } else {
                    setX( getX() );
                    setY( getY() );
                }
                break;

            default:
                setY( y );
                break;
            }//end switch base type
        }//end if sequence
        else {
            setX( x );
            setY( y );
        }
    }//end if pastepoint
    else {
        setX( getX() );
        setY( getY() );
    }
    if ( m_pView -> getPaste() )
        m_pView -> createAutoAssociations( this );
    updateComponentSize();
    return true;
}