feat(GODT-2782): Add category name in decribe issue view + apply review comments.

This commit is contained in:
Romain LE JEUNE
2023-08-03 09:25:00 +02:00
parent 1b95c290f1
commit cc33423c1f
15 changed files with 103 additions and 77 deletions

View File

@ -53,7 +53,7 @@ bool BugReportFlow::parse(const QString& filepath) {
//****************************************************************************************************************************************************
/// \return The value for the 'bugCategories' property.
//****************************************************************************************************************************************************
QStringList BugReportFlow::categories() const {
QVariantList BugReportFlow::categories() const {
return categories_;
}
@ -98,7 +98,7 @@ bool BugReportFlow::setAnswer(quint8 questionId, QString const &answer) {
QString BugReportFlow::getCategory(quint8 categoryId) const {
QString category;
if (categoryId <= categories_.count() - 1) {
category = categories_[categoryId];
category = categories_[categoryId].toMap()["name"].toString();
}
return category;
}
@ -131,7 +131,7 @@ QString BugReportFlow::collectAnswers(quint8 categoryId) const {
const QString& answer = getAnswer(var.toInt());
if (answer.isEmpty())
continue;
answers += " - " + questions_[var.toInt()].toMap()["text"].toString() + "\n\r";
answers += " > " + questions_[var.toInt()].toMap()["text"].toString() + "\n\r";
answers += answer + "\n\r";
}
return answers;
@ -155,7 +155,10 @@ bool BugReportFlow::parseFile() {
QJsonObject data = getJsonDataObj(getJsonRootObj());
QJsonArray categoriesJson = data.value("categories").toArray();
for (const QJsonValueRef &v : categoriesJson) {
categories_.append(v.toObject()["name"].toString());
QVariantMap cat;
cat["name"] = v.toObject()["name"].toString();
cat["hint"] = v.toObject()["hint"].toString();
categories_.append(cat);
questionsSet_.append(v.toObject()["questions"].toArray().toVariantList());
}
questions_ = data.value("questions").toArray().toVariantList();

View File

@ -35,7 +35,7 @@ public: // member functions.
[[nodiscard]] bool parse(const QString& filepath); ///< Initialize the Bug Report Flow.
[[nodiscard]] QStringList categories() const; ///< Getter for the 'bugCategories' property.
[[nodiscard]] QVariantList categories() const; ///< Getter for the 'bugCategories' property.
[[nodiscard]] QVariantList questions() const; ///< Getter for the 'bugQuestions' property.
[[nodiscard]] QVariantList questionSet(quint8 categoryId) const; ///< Retrieve the set of question for a given bug category.
[[nodiscard]] bool setAnswer(quint8 questionId, QString const &answer); ///< Feed an answer for a given question.
@ -55,7 +55,7 @@ private: // member functions
private: // data members
QString filepath_; ///< The file path of the BugReportFlow description file.
QStringList categories_; ///< The list of Bug Category parsed from the description file.
QVariantList categories_; ///< The list of Bug Category parsed from the description file.
QVariantList questions_; ///< The list of Questions parsed from the description file.
QList<QVariantList> questionsSet_; ///< Sets of questions per bug category.
QMap<quint8, QString> answers_; ///< Map of QuestionId/Answer for the bug form.