[umbrello-devel] [umbrello] [Bug 366181] Template inserted by user isn't saved

Ralf Habacker via KDE Bugzilla bugzilla_noreply at kde.org
Mon Aug 1 11:32:59 UTC 2016


https://bugs.kde.org/show_bug.cgi?id=366181

--- Comment #4 from Ralf Habacker <ralf.habacker at freenet.de> ---
Classifier widget and tree view requires to have an UMLTemplate class instance
for showing the template datatype.  The recent code has two bugs, which
prevents adding of non pointer and non common data types as template datatype.

In bool UMLDatatypeWidget::applyTemplate(), which got the data type related
part of  UMLTemplateDialog::apply() there is the following code:

    QString typeName = m_datatypeWidget->currentText();
    UMLDoc *pDoc = UMLApp::app()->document();
    UMLClassifierList namesList(pDoc->concepts());
* get all  objects from logical root with type Class, Interface,  Datatype,
Enum, Entity, Package, Folder
    foreach (UMLClassifier* obj, namesList) {
        if (typeName == obj->name()) {
*  here a related classifier has been found and is set as template type. 
            m_pTemplate->setType(obj);
* because it does not return with TRUE the last occurence of the related type
is used 
        }
    }
* only if no global objects has been found  (which is never the case) the
template type name is used. 
    if (namesList.isEmpty()) { // not found.
        // FIXME: This implementation is not good yet.
        m_pTemplate->setTypeName(typeName);
    }

The second bug is located in UMLClassifierListItem::setTypeName(), which in the
recent state adds such an instance only for common data and pointer types [1],
not for classes.

void UMLClassifierListItem::setTypeName(const QString &type)
{
    if (type.isEmpty() || type == QLatin1String("void")) {
        m_pSecondary = NULL;
        m_SecondaryId.clear();
        return;
    }
    UMLDoc *pDoc = UMLApp::app()->document();
    m_pSecondary = pDoc->findUMLObject(type);
    if (m_pSecondary == NULL) {
        // Make data type for easily identified cases
[1]     if (Model_Utils::isCommonDataType(type) ||
type.contains(QLatin1Char('*'))) {
            m_pSecondary =
Object_Factory::createUMLObject(UMLObject::ot_Datatype, type);
            uDebug() << "created datatype for " << type;
        } else {
            m_SecondaryId = type;
        }
    }
    UMLObject::emitModified();
}

In all other cases it sets m_secondaryID with the template datatype as text,
which is not displayed in the tree view and classifier widget and not fetched
on initial setup of  UMLDataTypeWidget. 

/**
 * Overrides method from UMLClassifierListItem.
 * Returns the type name of the UMLTemplate.
 * If the template parameter is a class, there is no separate
 * type object. In this case, getTypeName() returns "class".
 *
 * @return  The type name of the UMLClassifierListItem.
 */
QString UMLTemplate::getTypeName() const
{
    if (m_pSecondary == NULL)
        return QLatin1String("class");
     return m_pSecondary->name();
}

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the umbrello-devel mailing list