forked from qt-creator/qt-creator
Utils: Introduce case friendly comparison function to stringutils
Use this operator in the miniprojecttargetselector as well as the projectconfigurationmodel. This should unify the sorting of build-/deploy- and runconfigurations in various places in Creator. Task-number: QTCREATORBUG-20023 Change-Id: I7aed2ebcb9d65244395d68b7dc5da599d6503962 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -367,4 +367,12 @@ QTCREATOR_UTILS_EXPORT int parseUsedPortFromNetstatOutput(const QByteArray &line
|
||||
return port;
|
||||
}
|
||||
|
||||
int caseFriendlyCompare(const QString &a, const QString &b)
|
||||
{
|
||||
int result = a.compare(b, Qt::CaseInsensitive);
|
||||
if (result != 0)
|
||||
return result;
|
||||
return a.compare(b, Qt::CaseSensitive);
|
||||
}
|
||||
|
||||
} // namespace Utils
|
||||
|
@@ -56,6 +56,9 @@ QTCREATOR_UTILS_EXPORT QString stripAccelerator(const QString &text);
|
||||
|
||||
QTCREATOR_UTILS_EXPORT bool readMultiLineString(const QJsonValue &value, QString *out);
|
||||
|
||||
// Compare case insensitive and use case sensitive comparison in case of that being equal.
|
||||
QTCREATOR_UTILS_EXPORT int caseFriendlyCompare(const QString &a, const QString &b);
|
||||
|
||||
class QTCREATOR_UTILS_EXPORT AbstractMacroExpander
|
||||
{
|
||||
public:
|
||||
|
@@ -39,6 +39,7 @@
|
||||
#include "target.h"
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/stringutils.h>
|
||||
#include <utils/styledbar.h>
|
||||
#include <utils/stylehelper.h>
|
||||
#include <utils/theme/theme.h>
|
||||
|
@@ -32,6 +32,7 @@
|
||||
#include "projectconfiguration.h"
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/stringutils.h>
|
||||
|
||||
using namespace ProjectExplorer;
|
||||
|
||||
@@ -51,7 +52,7 @@ namespace {
|
||||
|
||||
const auto ComparisonOperator =
|
||||
[](const ProjectConfiguration *a, const ProjectConfiguration *b) {
|
||||
return a->displayName() < b->displayName();
|
||||
return Utils::caseFriendlyCompare(a->displayName(), b->displayName()) < 0;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
@@ -35,6 +35,7 @@
|
||||
#include <utils/utilsicons.h>
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/dropsupport.h>
|
||||
#include <utils/stringutils.h>
|
||||
#include <utils/theme/theme.h>
|
||||
|
||||
#include <QFileInfo>
|
||||
@@ -451,17 +452,5 @@ const QLoggingCategory &FlatModel::logger()
|
||||
return logger;
|
||||
}
|
||||
|
||||
namespace Internal {
|
||||
|
||||
int caseFriendlyCompare(const QString &a, const QString &b)
|
||||
{
|
||||
int result = a.compare(b, Qt::CaseInsensitive);
|
||||
if (result != 0)
|
||||
return result;
|
||||
return a.compare(b, Qt::CaseSensitive);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} // namespace ProjectExplorer
|
||||
|
||||
|
@@ -111,7 +111,5 @@ private:
|
||||
QSet<ExpandData> m_toExpand;
|
||||
};
|
||||
|
||||
int caseFriendlyCompare(const QString &a, const QString &b);
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace ProjectExplorer
|
||||
|
Reference in New Issue
Block a user