Commit 3a45009e authored by Ralf Habacker's avatar Ralf Habacker

Merge data type combo box setup into UMLDatatypeWidget::initTypesBox().

Add used type to the combo box completion in all cases.

CCBUG:60452
parent e8a33d33
......@@ -275,6 +275,28 @@ bool UMLDatatypeWidget::applyTemplate()
return true;
}
/**
* Initialize types combo box from a list of types and a selected type.
* @param types list of types to add to combo box
* @param type selected type
*/
void UMLDatatypeWidget::initTypesBox(QStringList &types, const QString& type)
{
if (!types.contains(type)) {
types << type;
}
types.sort();
m_comboBox->clear();
m_comboBox->insertItems(-1, types);
int currentIndex = m_comboBox->findText(type);
if (currentIndex > -1) {
m_comboBox->setCurrentIndex(currentIndex);
}
m_comboBox->completionObject()->addItem(type);
}
/**
* Add classes and interfaces from document instance to the given string list.
* @param types list to store the classes and interfaces
......@@ -319,19 +341,7 @@ void UMLDatatypeWidget::insertTypesSortedAttribute(const QString& type)
{
QStringList types;
insertTypesFromConcepts(types);
if (!types.contains(type)) {
types << type;
}
types.sort();
m_comboBox->clear();
m_comboBox->insertItems(-1, types);
int currentIndex = m_comboBox->findText(type);
if (currentIndex > -1) {
m_comboBox->setCurrentIndex(currentIndex);
}
m_comboBox->completionObject()->addItem(type);
initTypesBox(types, type);
}
/**
......@@ -341,21 +351,7 @@ void UMLDatatypeWidget::insertTypesSortedEntityAttribute(const QString& type)
{
QStringList types;
insertTypesFromDatatypes(types);
// add the given parameter
if (!types.contains(type)) {
types << type;
}
types.sort();
m_comboBox->clear();
m_comboBox->insertItems(-1, types);
// select the given parameter
int currentIndex = m_comboBox->findText(type);
if (currentIndex > -1) {
m_comboBox->setCurrentIndex(currentIndex);
}
m_comboBox->completionObject()->addItem(type);
initTypesBox(types, type);
}
/**
......@@ -382,20 +378,7 @@ void UMLDatatypeWidget::insertTypesSortedOperation(const QString& type)
}
}
insertTypesFromConcepts(types);
// add the given parameter
if (!types.contains(type)) {
types << type;
}
types.sort();
m_comboBox->clear();
m_comboBox->insertItems(-1, types);
// select the given parameter
int currentIndex = m_comboBox->findText(type);
if (currentIndex > -1) {
m_comboBox->setCurrentIndex(currentIndex);
}
initTypesBox(types, type);
}
/**
......@@ -419,20 +402,7 @@ void UMLDatatypeWidget::insertTypesSortedParameter(const QString& type)
}
}
insertTypesFromConcepts(types);
// add the given parameter
if (!types.contains(type)) {
types << type;
}
types.sort();
m_comboBox->clear();
m_comboBox->insertItems(-1, types);
// select the given parameter
int currentIndex = m_comboBox->findText(type);
if (currentIndex > -1) {
m_comboBox->setCurrentIndex(currentIndex);
}
initTypesBox(types, type);
}
/**
......@@ -447,20 +417,7 @@ void UMLDatatypeWidget::insertTypesSortedTemplate(const QString& type)
// "class" is the nominal type of template parameter
types << QLatin1String("class");
insertTypesFromConcepts(types, false);
// add the given parameter
if (!types.contains(type)) {
types << type;
}
types.sort();
m_comboBox->clear();
m_comboBox->insertItems(-1, types);
// select the given parameter
int currentIndex = m_comboBox->findText(type);
if (currentIndex > -1) {
m_comboBox->setCurrentIndex(currentIndex);
}
initTypesBox(types, type);
}
/**
......
......@@ -52,6 +52,7 @@ protected:
bool applyOperation();
bool applyParameter();
bool applyTemplate();
void initTypesBox(QStringList &types, const QString &type);
void insertTypesFromConcepts(QStringList &types, bool fullName = true);
void insertTypesFromDatatypes(QStringList &types);
void insertTypesSortedAttribute(const QString &type);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment