コード例 #1
0
/**
 * Add a classifier to the data structure.
 * @param classifier   the classifier to add
 * @param parent       the tree item under which the classifier is placed
 * @param addSuper     add it to the base classifier folder
 * @param addSub       add it to the derived classifier folder
 * @param recurse      ...
 */
void RefactoringAssistant::addClassifier(UMLClassifier *classifier, QTreeWidgetItem *parent, bool addSuper, bool addSub, bool recurse)
{
    if (!classifier) {
        uWarning() << "No classifier given - do nothing!";
        return;
    }
    DEBUG(DBG_SRC) << classifier->name() << " added.";
    QTreeWidgetItem *classifierItem, *item;
    if (parent) {
        classifierItem = parent;
    }
    else {
        classifierItem = new QTreeWidgetItem(this, QStringList(classifier->name()));
        m_umlObjectMap[classifierItem] = classifier;
    }
    m_alreadySeen << classifier;

    connect(classifier, SIGNAL(modified()),
            this, SLOT(objectModified()));

    // add attributes
    connect(classifier, SIGNAL(attributeAdded(UMLClassifierListItem*)),
            this, SLOT(attributeAdded(UMLClassifierListItem*)));
    connect(classifier, SIGNAL(attributeRemoved(UMLClassifierListItem*)),
            this, SLOT(attributeRemoved(UMLClassifierListItem*)));

    QStringList itemTextAt;
    itemTextAt << i18n("Attributes") << QLatin1String("attributes");
    QTreeWidgetItem *attsFolder = new QTreeWidgetItem(classifierItem, itemTextAt);
    attsFolder->setIcon(0, Icon_Utils::SmallIcon(Icon_Utils::it_Folder_Orange));
    attsFolder->setExpanded(true);
    UMLAttributeList atts(classifier->getAttributeList());
    foreach(UMLAttribute* att, atts) {
        attributeAdded(att);
    }
コード例 #2
0
void TransitionAttributes::setAttributes(const IAttributeContainer& sourceAttrList)
{
    // if the dest container has a matching key,
    // update the value to be the source value.
    // else, add the source to the container
    //
    // remove from the dest list any attributes that are not in the souce list

    QMapIterator<QString,IAttribute*> i(sourceAttrList);

    while (i.hasNext())
    {
        QString key  = i.next().key();
        IAttribute* sourceAttr = sourceAttrList.value(key)  ;
        IAttribute* destAttr = this->value( key ) ;

        if ( destAttr )
        {
            destAttr->setValue( sourceAttr->asString());
        }
        else
        {
            IAttribute* newAttr=NULL;

            TransitionAttributes::TransitionPathAttribute *pt;
            TransitionAttributes::TransitionPositionAttribute *ps;
            TransitionAttributes::TransitionStringAttribute *str;

            if ( ( pt = dynamic_cast<TransitionAttributes::TransitionPathAttribute *>(sourceAttr)) != NULL)
            {
                TransitionAttributes::TransitionPathAttribute * newPt = new TransitionAttributes::TransitionPathAttribute (*pt);
                addItem(newPt);
                newAttr= newPt;
            }
            else if ( (  ps = dynamic_cast<TransitionAttributes::TransitionPositionAttribute *>(sourceAttr) ) != NULL )
            {
                TransitionAttributes::TransitionPositionAttribute * newPs = new TransitionAttributes::TransitionPositionAttribute (*ps);
                addItem(newPs);
                newAttr = newPs;
            }
            else if ( ( str = dynamic_cast<TransitionAttributes::TransitionStringAttribute *>(sourceAttr) ) != NULL )
            {
                TransitionAttributes::TransitionStringAttribute * newStr = new TransitionAttributes::TransitionStringAttribute (*str);
                addItem(newStr);
                newAttr = newStr;
            }

            if ( newAttr ) emit attributeAdded(newAttr);
        }
    }

    // now delete local attributes that are not contained in the source list

   QMapIterator<QString,IAttribute*> j(sourceAttrList);

    while (j.hasNext())
    {
        QString key  = j.next().key();

        if ( !sourceAttrList.contains(key) )
        {
            IAttribute* attr = this->value(key);
            this->remove(key);
            emit attributeDeleted(attr);
            delete attr;
        }
    }
}
コード例 #3
0
void TextBlockAttributes::setAttributes(const IAttributeContainer& sourceAttrList)
{
    // if the dest container has a matching key,
    // update the value to be the source value.
    // else, add the source to the container
    //
    // remove from the dest list any attributes that are not in the souce list

    QMapIterator<QString,IAttribute*> i(sourceAttrList);
    while (i.hasNext())
    {
        QString key  = i.next().key();
        IAttribute* sourceAttr = sourceAttrList.value(key)  ;
        IAttribute* destAttr = this->value( key ) ;
        if ( destAttr )
        {
            destAttr->setValue( sourceAttr->asString());
        }
        else
        {
            IAttribute* newAttr=NULL;

            PositionAttribute *ps=NULL;
            SizeAttribute *sz=NULL;
            FontFamilyAttribute *ff=NULL;
            FontSizeAttribute *fs=NULL;
            FontColorAttribute *fc=NULL;
            FontBoldAttribute *fb=NULL;
            FontUnderlineAttribute *fu=NULL;

            if ( ( ps = dynamic_cast<PositionAttribute *>(sourceAttr) ) != NULL )
            {
                PositionAttribute * newPs = new PositionAttribute (*ps);
                addItem(newPs);
                newAttr = newPs;
            }
            else if ( ( sz = dynamic_cast<SizeAttribute *>(sourceAttr) ) != NULL )
            {
                SizeAttribute * newSz = new SizeAttribute (*sz);
                addItem(newSz);
                newAttr = newSz;
            }
            else if ( (  ff = dynamic_cast<FontFamilyAttribute *>(sourceAttr) ) != NULL )
            {
                FontFamilyAttribute * f = new FontFamilyAttribute (*ff);
                addItem(f);
                newAttr = f;
            }
            else if ( (  fs = dynamic_cast<FontSizeAttribute *>(sourceAttr) ) != NULL )
            {
                FontSizeAttribute * f = new FontSizeAttribute (*fs);
                addItem(f);
                newAttr = f;
            }
            else if ( (  fc = dynamic_cast<FontColorAttribute *>(sourceAttr) ) != NULL )
            {
                FontColorAttribute * f = new FontColorAttribute (*fc);
                addItem(f);
                newAttr = f;
            }
            else if ( (  fb = dynamic_cast<FontBoldAttribute *>(sourceAttr) ) != NULL )
            {
                FontBoldAttribute * f = new FontBoldAttribute (*fb);
                addItem(f);
                newAttr = f;
            }
            else if ( (  fu = dynamic_cast<FontUnderlineAttribute *>(sourceAttr) ) != NULL )
            {
                FontUnderlineAttribute * f = new FontUnderlineAttribute (*fu);
                addItem(f);
                newAttr = f;
            }

            if ( newAttr ) emit attributeAdded(newAttr);
        }
    }

    // now delete local attributes that are not contained in the source list

   QMapIterator<QString,IAttribute*> j(sourceAttrList);

    while (j.hasNext())
    {
        QString key  = j.next().key();

        if ( !sourceAttrList.contains(key) )
        {
            IAttribute* attr = this->value(key);
            this->remove(key);
            emit attributeDeleted(attr);
            delete attr;
        }
    }
}