aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/qtsupport/exampleslistmodel.cpp
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@qt.io>2023-05-25 15:49:57 +0200
committerEike Ziller <eike.ziller@qt.io>2023-05-25 15:49:57 +0200
commit90a6faed4e59c9968a2602b32498bc750a92e62b (patch)
tree04d8d1f4cc488ecefb0d260777cbf16ae0803143 /src/plugins/qtsupport/exampleslistmodel.cpp
parentf4b02be1fa5f4bedbfa8a8ec256cadc0cea5c8fb (diff)
parent50f277ef8ac4edb944f7a26d25f5fb7dcefd050d (diff)
Merge remote-tracking branch 'origin/10.0' into 11.0
Conflicts: src/plugins/qtsupport/exampleslistmodel.cpp Change-Id: Idbe0117ce810b4ab180a7c4f9b7b35c9c4b988e5
Diffstat (limited to 'src/plugins/qtsupport/exampleslistmodel.cpp')
-rw-r--r--src/plugins/qtsupport/exampleslistmodel.cpp56
1 files changed, 0 insertions, 56 deletions
diff --git a/src/plugins/qtsupport/exampleslistmodel.cpp b/src/plugins/qtsupport/exampleslistmodel.cpp
index 84e1b57ab1..5beb9c80a3 100644
--- a/src/plugins/qtsupport/exampleslistmodel.cpp
+++ b/src/plugins/qtsupport/exampleslistmodel.cpp
@@ -4,7 +4,6 @@
#include "exampleslistmodel.h"
#include "examplesparser.h"
-#include "qtsupporttr.h"
#include <QBuffer>
#include <QApplication>
@@ -326,61 +325,6 @@ static bool isValidExampleOrDemo(ExampleItem *item)
return ok || debugExamples();
}
-static bool sortByHighlightedAndName(ExampleItem *first, ExampleItem *second)
-{
- if (first->isHighlighted && !second->isHighlighted)
- return true;
- if (!first->isHighlighted && second->isHighlighted)
- return false;
- return first->name.compare(second->name, Qt::CaseInsensitive) < 0;
-}
-
-static QList<std::pair<Section, QList<ExampleItem *>>> getCategories(
- const QList<ExampleItem *> &items, bool sortIntoCategories)
-{
- static const QString otherDisplayName = Tr::tr("Other", "Category for all other examples");
- const bool useCategories = sortIntoCategories
- || qtcEnvironmentVariableIsSet("QTC_USE_EXAMPLE_CATEGORIES");
- QList<ExampleItem *> other;
- QMap<QString, QList<ExampleItem *>> categoryMap;
- if (useCategories) {
- for (ExampleItem *item : items) {
- const QStringList itemCategories = item->metaData.value("category");
- for (const QString &category : itemCategories)
- categoryMap[category].append(item);
- if (itemCategories.isEmpty())
- other.append(item);
- }
- }
- QList<std::pair<Section, QList<ExampleItem *>>> categories;
- if (categoryMap.isEmpty()) {
- // The example set doesn't define categories. Consider the "highlighted" ones as "featured"
- QList<ExampleItem *> featured;
- QList<ExampleItem *> allOther;
- std::tie(featured, allOther) = Utils::partition(items, [](ExampleItem *i) {
- return i->isHighlighted;
- });
- if (!featured.isEmpty())
- categories.append(
- {{Tr::tr("Featured", "Category for highlighted examples"), 0}, featured});
- if (!allOther.isEmpty())
- categories.append({{otherDisplayName, 1}, allOther});
- } else {
- int index = 0;
- const auto end = categoryMap.constKeyValueEnd();
- for (auto it = categoryMap.constKeyValueBegin(); it != end; ++it) {
- categories.append({{it->first, index, /*maxRows=*/index == 0 ? 2 : 1}, it->second});
- ++index;
- }
- if (!other.isEmpty())
- categories.append({{otherDisplayName, index, /*maxRows=*/1}, other});
- }
- const auto end = categories.end();
- for (auto it = categories.begin(); it != end; ++it)
- sort(it->second, sortByHighlightedAndName);
- return categories;
-}
-
void ExamplesViewController::updateExamples()
{
QString examplesInstallPath;