forked from qt-creator/qt-creator
Sort the possible import list.
Change-Id: Iaa77273ebaf0867119f06c6ee3c2d29a61168933 Reviewed-by: Thomas Hartmann <Thomas.Hartmann@digia.com>
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user