diff --git a/internal/frontend/bridge-gui/bridge-gui/QMLBackend.cpp b/internal/frontend/bridge-gui/bridge-gui/QMLBackend.cpp index 69b8cc96..38902bec 100644 --- a/internal/frontend/bridge-gui/bridge-gui/QMLBackend.cpp +++ b/internal/frontend/bridge-gui/bridge-gui/QMLBackend.cpp @@ -304,11 +304,11 @@ void QMLBackend::openExternalLink(QString const &url) { //**************************************************************************************************************************************************** -// +/// \param[in] categoryID The ID of the bug report category. //**************************************************************************************************************************************************** -void QMLBackend::requestKnowledgeBaseSuggestions() const { +void QMLBackend::requestKnowledgeBaseSuggestions(qint8 categoryID) const { HANDLE_EXCEPTION( - app().grpc().requestKnowledgeBaseSuggestions("Test"); + app().grpc().requestKnowledgeBaseSuggestions(reportFlow_.collectUserInput(categoryID)); ) } diff --git a/internal/frontend/bridge-gui/bridge-gui/QMLBackend.h b/internal/frontend/bridge-gui/bridge-gui/QMLBackend.h index 5e22e990..42a86108 100644 --- a/internal/frontend/bridge-gui/bridge-gui/QMLBackend.h +++ b/internal/frontend/bridge-gui/bridge-gui/QMLBackend.h @@ -66,7 +66,7 @@ public: // member functions. Q_INVOKABLE void clearAnswers(); ///< Clear all collected answers. Q_INVOKABLE bool isTLSCertificateInstalled(); ///< Check if the bridge certificate is installed in the OS keychain. Q_INVOKABLE void openExternalLink(QString const & url = QString()); ///< Open a knowledge base article. - Q_INVOKABLE void requestKnowledgeBaseSuggestions() const; ///< Request knowledgebase article suggestions. + Q_INVOKABLE void requestKnowledgeBaseSuggestions(qint8 categoryID) const; ///< Request knowledgebase article suggestions. public: // Qt/QML properties. Note that the NOTIFY-er signal is required even for read-only properties (QML warning otherwise) Q_PROPERTY(bool showOnStartup READ showOnStartup NOTIFY showOnStartupChanged) diff --git a/internal/frontend/bridge-gui/bridge-gui/qml/BugReport/BugReportFlow.qml b/internal/frontend/bridge-gui/bridge-gui/qml/BugReport/BugReportFlow.qml index 28385283..5bac66cb 100644 --- a/internal/frontend/bridge-gui/bridge-gui/qml/BugReport/BugReportFlow.qml +++ b/internal/frontend/bridge-gui/bridge-gui/qml/BugReport/BugReportFlow.qml @@ -78,7 +78,7 @@ Item { root.showBugCategory(); } onQuestionAnswered: { - Backend.requestKnowledgeBaseSuggestions(); + Backend.requestKnowledgeBaseSuggestions(categoryId); root.showBugReport(); } } diff --git a/internal/frontend/bridge-gui/bridgepp/bridgepp/BugReportFlow/BugReportFlow.cpp b/internal/frontend/bridge-gui/bridgepp/bridgepp/BugReportFlow/BugReportFlow.cpp index d7205bfa..f4f59cfa 100644 --- a/internal/frontend/bridge-gui/bridgepp/bridgepp/BugReportFlow/BugReportFlow.cpp +++ b/internal/frontend/bridge-gui/bridgepp/bridgepp/BugReportFlow/BugReportFlow.cpp @@ -30,13 +30,6 @@ namespace { namespace bridgepp { -//**************************************************************************************************************************************************** -// -//**************************************************************************************************************************************************** -BugReportFlow::BugReportFlow() { -} - - //**************************************************************************************************************************************************** /// \param[in] filepath The path of the file to parse. /// \return True iff the file can be properly parsed. @@ -92,7 +85,7 @@ bool BugReportFlow::setAnswer(quint8 questionId, QString const &answer) { //**************************************************************************************************************************************************** -/// \param[in] questionId The id of the question. +/// \param[in] categoryId The id of the question. /// \return answer the given question. //**************************************************************************************************************************************************** QString BugReportFlow::getCategory(quint8 categoryId) const { @@ -128,7 +121,7 @@ QString BugReportFlow::collectAnswers(quint8 categoryId) const { QVariantList sets = this->questionSet(categoryId); for (QVariant const &var: sets) { - const QString& answer = getAnswer(var.toInt()); + const QString answer = getAnswer(var.toInt()); if (answer.isEmpty()) continue; answers += "#### " + questions_[var.toInt()].toMap()["text"].toString() + "\n\r"; @@ -139,6 +132,24 @@ QString BugReportFlow::collectAnswers(quint8 categoryId) const { } +//**************************************************************************************************************************************************** +/// \param[in] categoryId The id of the question set. +//**************************************************************************************************************************************************** +QString BugReportFlow::collectUserInput(quint8 categoryId) const { + if (categoryId > categories_.count() - 1) + return {}; + + QString input = this->getCategory(categoryId); + for (QVariant const &var: this->questionSet(categoryId)) { + QString const answer = getAnswer(var.toInt()); + if (!answer.isEmpty()) + input += " " + answer; + } + + return input; +} + + //**************************************************************************************************************************************************** // //**************************************************************************************************************************************************** diff --git a/internal/frontend/bridge-gui/bridgepp/bridgepp/BugReportFlow/BugReportFlow.h b/internal/frontend/bridge-gui/bridgepp/bridgepp/BugReportFlow/BugReportFlow.h index c114b62c..c02a076c 100644 --- a/internal/frontend/bridge-gui/bridgepp/bridgepp/BugReportFlow/BugReportFlow.h +++ b/internal/frontend/bridge-gui/bridgepp/bridgepp/BugReportFlow/BugReportFlow.h @@ -28,7 +28,7 @@ namespace bridgepp { class BugReportFlow { public: // member functions. - BugReportFlow(); ///< Default constructor. + BugReportFlow() = default; ///< Default constructor. BugReportFlow(BugReportFlow const &) = delete; ///< Disabled copy-constructor. BugReportFlow(BugReportFlow &&) = delete; ///< Disabled assignment copy-constructor. ~BugReportFlow() = default; ///< Destructor. @@ -42,6 +42,7 @@ public: // member functions. [[nodiscard]] QString getCategory(quint8 categoryId) const; ///< Get category name. [[nodiscard]] QString getAnswer(quint8 questionId) const; ///< Get answer for a given question. [[nodiscard]] QString collectAnswers(quint8 categoryId) const; ///< Collect answer for a given set of questions. + [[nodiscard]] QString collectUserInput(quint8 categoryId) const; ///< Collect the user input (user answers without quesitons) for a given set of questions. void clearAnswers(); ///< Clear all collected answers.