/** * Inserts @p type into the type-combobox as well as its completion object. */ void UMLEntityAttributeDialog::insertTypesSorted(const QString& type) { QStringList types; // add the data types UMLDoc * pDoc = UMLApp::app()->document(); UMLClassifierList dataTypes = pDoc->datatypes(); if (dataTypes.count() == 0) { // Switch to SQL as the active language if no datatypes are set. UMLApp::app()->setActiveLanguage(Uml::ProgrammingLanguage::SQL); pDoc->addDefaultDatatypes(); qApp->processEvents(); dataTypes = pDoc->datatypes(); } foreach (UMLClassifier* dat, dataTypes) { types << dat->name(); } // add the given parameter if (!types.contains(type)) { types << type; } types.sort(); m_pTypeCB->clear(); m_pTypeCB->insertItems(-1, types); // select the given parameter int currentIndex = m_pTypeCB->findText(type); if (currentIndex > -1) { m_pTypeCB->setCurrentIndex(currentIndex); } m_pTypeCB->completionObject()->addItem(type); }