Use categories for Tutorials page

Instead of adding the category into the title with "Help: ..." etc, use
the actual categorized view that we already use for examples and
marketplace. Set the corresponding meta data in the manifest file and
read it also for tutorials.

Change-Id: Id9081518c1c0afee8d080af3ca8a5dca5cdde775
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
Eike Ziller
2023-07-13 16:23:53 +02:00
parent ed35f78197
commit c43a2ee1c4
5 changed files with 251 additions and 77 deletions

View File

@@ -140,6 +140,27 @@ void tst_Examples::parsing_data()
<< FilePath("examples") << QString() << FilePaths() << FilePath() << FilePaths() << Example
<< /*hasSourceCode=*/false << false << /*isHighlighted=*/true << ""
<< "" << QStringList() << MetaData() << QStringList{"Featured"};
QTest::addRow("tutorial with category")
<< QByteArray(R"raw(
<tutorials>
<tutorial imageUrl=":qtsupport/images/icons/tutorialicon.png" difficulty="" docUrl="qthelp://org.qt-project.qtcreator/doc/dummytutorial.html" projectPath="" name="A tutorial">
<description><![CDATA[A dummy tutorial.]]></description>
<tags>qt creator,build,compile,help</tags>
<meta>
<entry name="category">Help</entry>
</meta>
</tutorial>
</tutorials>
)raw") << /*isExamples=*/false
<< "A tutorial"
<< "A dummy tutorial."
<< ":qtsupport/images/icons/tutorialicon.png"
<< QStringList{"qt creator", "build", "compile", "help"} << FilePath()
<< "qthelp://org.qt-project.qtcreator/doc/dummytutorial.html" << FilePaths() << FilePath()
<< FilePaths() << Tutorial << /*hasSourceCode=*/false << /*isVideo=*/false
<< /*isHighlighted=*/false << QString() << QString() << QStringList()
<< MetaData({{"category", {"Help"}}}) << QStringList("Help");
}
void tst_Examples::parsing()
@@ -175,8 +196,8 @@ void tst_Examples::parsing()
QCOMPARE(item.platforms, expected.platforms);
QCOMPARE(item.metaData, expected.metaData);
const QList<std::pair<Section, QList<ExampleItem *>>> resultCategories = getCategories(*result,
true);
const QList<std::pair<Section, QList<ExampleItem *>>> resultCategories
= getCategories(*result, true, {}, true);
QCOMPARE(resultCategories.size(), categories.size());
for (int i = 0; i < resultCategories.size(); ++i) {
QCOMPARE(resultCategories.at(i).first.name, categories.at(i));