forked from qt-creator/qt-creator
Sort projects by displayName in ProjectListWidget.
Change-Id: I5dac445c8868125ec7773479726d065f47e3c48f Reviewed-by: Daniel Teske <daniel.teske@nokia.com>
This commit is contained in:
committed by
Daniel Teske
parent
06010713e2
commit
27809bd748
@@ -47,6 +47,7 @@
|
||||
#include <projectexplorer/project.h>
|
||||
#include <projectexplorer/buildconfiguration.h>
|
||||
#include <projectexplorer/deployconfiguration.h>
|
||||
#include <projectexplorer/projectmodels.h>
|
||||
#include <projectexplorer/runconfiguration.h>
|
||||
|
||||
#include <QTimer>
|
||||
@@ -82,6 +83,15 @@ static QIcon createCenteredIcon(const QIcon &icon, const QIcon &overlay)
|
||||
using namespace ProjectExplorer;
|
||||
using namespace ProjectExplorer::Internal;
|
||||
|
||||
static bool projectLesserThan(Project *p1, Project *p2)
|
||||
{
|
||||
int result = caseFriendlyCompare(p1->displayName(), p2->displayName());
|
||||
if (result != 0)
|
||||
return result < 0;
|
||||
else
|
||||
return p1 < p2;
|
||||
}
|
||||
|
||||
////////
|
||||
// TargetSelectorDelegate
|
||||
////////
|
||||
@@ -242,9 +252,10 @@ void ProjectListWidget::addProject(Project *project)
|
||||
int pos = 0;
|
||||
for (int i=0; i < count(); ++i) {
|
||||
Project *p = item(i)->data(Qt::UserRole).value<Project*>();
|
||||
QString itemSortName = fullName(p);
|
||||
if (itemSortName > sortName)
|
||||
if (projectLesserThan(project, p)) {
|
||||
pos = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool useFullName = false;
|
||||
@@ -319,8 +330,7 @@ void ProjectListWidget::projectDisplayNameChanged(Project *project)
|
||||
int pos = count();
|
||||
for (int i = 0; i < count(); ++i) {
|
||||
Project *p = item(i)->data(Qt::UserRole).value<Project*>();
|
||||
QString itemSortName = fullName(p);
|
||||
if (itemSortName > sortName) {
|
||||
if (projectLesserThan(project, p)) {
|
||||
pos = i;
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user