Commit 309d38c8 authored by BogDan Vatra's avatar BogDan Vatra

Sort the possible import list.

Change-Id: Iaa77273ebaf0867119f06c6ee3c2d29a61168933
Reviewed-by: default avatarThomas Hartmann <Thomas.Hartmann@digia.com>
parent 7af11eba
......@@ -64,33 +64,6 @@ static bool isImportAlreadyUsed(const Import &import, QList<ImportLabel*> import
return false;
}
void ImportsWidget::setPossibleImports(const QList<Import> &possibleImports)
{
m_addImportComboBox->clear();
foreach (const Import &possibleImport, possibleImports) {
if (!isImportAlreadyUsed(possibleImport, m_importLabels))
m_addImportComboBox->addItem(possibleImport.toString(true), QVariant::fromValue(possibleImport));
}
}
void ImportsWidget::removePossibleImports()
{
m_addImportComboBox->clear();
}
void ImportsWidget::setUsedImports(const QList<Import> &usedImports)
{
foreach (ImportLabel *importLabel, m_importLabels)
importLabel->setReadOnly(usedImports.contains(importLabel->import()));
}
void ImportsWidget::removeUsedImports()
{
foreach (ImportLabel *importLabel, m_importLabels)
importLabel->setEnabled(true);
}
static bool importLess(const Import &firstImport, const Import &secondImport)
{
if (firstImport.url() == secondImport.url())
......@@ -117,6 +90,34 @@ static bool importLess(const Import &firstImport, const Import &secondImport)
return false;
}
void ImportsWidget::setPossibleImports(QList<Import> possibleImports)
{
Utils::sort(possibleImports, importLess);
m_addImportComboBox->clear();
foreach (const Import &possibleImport, possibleImports) {
if (!isImportAlreadyUsed(possibleImport, m_importLabels))
m_addImportComboBox->addItem(possibleImport.toString(true), QVariant::fromValue(possibleImport));
}
}
void ImportsWidget::removePossibleImports()
{
m_addImportComboBox->clear();
}
void ImportsWidget::setUsedImports(const QList<Import> &usedImports)
{
foreach (ImportLabel *importLabel, m_importLabels)
importLabel->setReadOnly(usedImports.contains(importLabel->import()));
}
void ImportsWidget::removeUsedImports()
{
foreach (ImportLabel *importLabel, m_importLabels)
importLabel->setEnabled(true);
}
void ImportsWidget::setImports(const QList<Import> &imports)
{
qDeleteAll(m_importLabels);
......
......@@ -52,7 +52,7 @@ public:
void setImports(const QList<Import> &imports);
void removeImports();
void setPossibleImports(const QList<Import> &possibleImports);
void setPossibleImports(QList<Import> possibleImports);
void removePossibleImports();
void setUsedImports(const QList<Import> &possibleImports);
......
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