diff --git a/src/plugins/axivion/axivionoutputpane.cpp b/src/plugins/axivion/axivionoutputpane.cpp index 1f138cea0f3..560f80bfa46 100644 --- a/src/plugins/axivion/axivionoutputpane.cpp +++ b/src/plugins/axivion/axivionoutputpane.cpp @@ -200,7 +200,7 @@ IssuesWidget::IssuesWidget(QWidget *parent) m_currentPrefix.clear(); m_currentProject.clear(); m_issuesModel->clear(); - fetchProjectInfo(m_dashboardProjects->currentText()); + fetchDashboardAndProjectInfo({}, m_dashboardProjects->currentText()); }); // row with issue types (-> depending on choice, tables below change) // and a selectable range (start version, end version) @@ -388,10 +388,8 @@ void IssuesWidget::reinitProjectList(const QString ¤tProject) m_dashboardProjects->addItems(info->projects); if (!currentProject.isEmpty() && info->projects.contains(currentProject)) m_dashboardProjects->setCurrentText(currentProject); - // FIXME ugly.. any better solution? - QTimer::singleShot(0, this, [this]() { fetchProjectInfo(m_dashboardProjects->currentText()); }); }; - fetchDashboardInfo(onDashboardInfoFetched); + fetchDashboardAndProjectInfo(onDashboardInfoFetched, currentProject); } static Qt::Alignment alignmentFromString(const QString &str) diff --git a/src/plugins/axivion/axivionplugin.cpp b/src/plugins/axivion/axivionplugin.cpp index 125084fd7f0..b75c4bf0b3e 100644 --- a/src/plugins/axivion/axivionplugin.cpp +++ b/src/plugins/axivion/axivionplugin.cpp @@ -214,8 +214,8 @@ public: AxivionPluginPrivate(); void handleSslErrors(QNetworkReply *reply, const QList &errors); void onStartupProjectChanged(Project *project); - void fetchDashboardInfo(const DashboardInfoHandler &handler); - void fetchProjectInfo(const QString &projectName); + void fetchDashboardAndProjectInfo(const DashboardInfoHandler &handler, + const QString &projectName); void handleOpenedDocs(); void onDocumentOpened(IDocument *doc); void onDocumentClosed(IDocument * doc); @@ -283,16 +283,10 @@ public: } }; -void fetchDashboardInfo(const DashboardInfoHandler &handler) +void fetchDashboardAndProjectInfo(const DashboardInfoHandler &handler, const QString &projectName) { QTC_ASSERT(dd, return); - dd->fetchDashboardInfo(handler); -} - -void fetchProjectInfo(const QString &projectName) -{ - QTC_ASSERT(dd, return); - dd->fetchProjectInfo(projectName); + dd->fetchDashboardAndProjectInfo(handler, projectName); } std::optional projectInfo() @@ -798,7 +792,8 @@ Group dashboardInfoRecipe(const DashboardInfoHandler &handler) { const auto onSetup = [handler] { if (dd->m_dashboardInfo) { - handler(*dd->m_dashboardInfo); + if (handler) + handler(*dd->m_dashboardInfo); return SetupResult::StopWithSuccess; } return SetupResult::Continue; @@ -813,7 +808,7 @@ Group dashboardInfoRecipe(const DashboardInfoHandler &handler) const Group root { onGroupSetup(onSetup), // Stops if cache exists. authorizationRecipe(), - onGroupDone(onDone) + handler ? onGroupDone(onDone) : nullItem }; return root; } @@ -824,11 +819,6 @@ Group projectInfoRecipe(const QString &projectName) dd->clearAllMarks(); dd->m_currentProjectInfo = {}; dd->m_analysisVersion = {}; - if (!projectName.isEmpty()) - return SetupResult::Continue; - - updateDashboard(); - return SetupResult::StopWithSuccess; }; const auto onTaskTreeSetup = [projectName](TaskTree &taskTree) { @@ -838,10 +828,19 @@ Group projectInfoRecipe(const QString &projectName) return SetupResult::StopWithError; } - const auto it = dd->m_dashboardInfo->projectUrls.constFind(projectName); + const QString targetProjectName + = (projectName.isEmpty() && !dd->m_dashboardInfo->projects.isEmpty()) + ? dd->m_dashboardInfo->projects.first() : projectName; + + if (targetProjectName.isEmpty()) { + updateDashboard(); + return SetupResult::StopWithSuccess; + } + + const auto it = dd->m_dashboardInfo->projectUrls.constFind(targetProjectName); if (it == dd->m_dashboardInfo->projectUrls.constEnd()) { MessageManager::writeDisrupting(QString("Axivion: %1") - .arg(Tr::tr("The DashboardInfo doesn't contain project \"%1\".").arg(projectName))); + .arg(Tr::tr("The DashboardInfo doesn't contain project \"%1\".").arg(targetProjectName))); return SetupResult::StopWithError; } @@ -859,7 +858,6 @@ Group projectInfoRecipe(const QString &projectName) return { onGroupSetup(onSetup), - authorizationRecipe(), TaskTreeTask(onTaskTreeSetup) }; } @@ -912,14 +910,10 @@ Group issueHtmlRecipe(const QString &issueId, const HtmlHandler &handler) return fetchHtmlRecipe(url, handler); } -void AxivionPluginPrivate::fetchDashboardInfo(const DashboardInfoHandler &handler) +void AxivionPluginPrivate::fetchDashboardAndProjectInfo(const DashboardInfoHandler &handler, + const QString &projectName) { - m_taskTreeRunner.start(dashboardInfoRecipe(handler)); -} - -void AxivionPluginPrivate::fetchProjectInfo(const QString &projectName) -{ - m_taskTreeRunner.start(projectInfoRecipe(projectName)); + m_taskTreeRunner.start({dashboardInfoRecipe(handler), projectInfoRecipe(projectName)}); } Group tableInfoRecipe(const QString &prefix, const TableInfoHandler &handler) diff --git a/src/plugins/axivion/axivionplugin.h b/src/plugins/axivion/axivionplugin.h index ce1885f1435..950b3b47dd0 100644 --- a/src/plugins/axivion/axivionplugin.h +++ b/src/plugins/axivion/axivionplugin.h @@ -80,8 +80,7 @@ Tasking::Group lineMarkerRecipe(const Utils::FilePath &filePath, const LineMarke using HtmlHandler = std::function; Tasking::Group issueHtmlRecipe(const QString &issueId, const HtmlHandler &handler); -void fetchDashboardInfo(const DashboardInfoHandler &handler); -void fetchProjectInfo(const QString &projectName); +void fetchDashboardAndProjectInfo(const DashboardInfoHandler &handler, const QString &projectName); std::optional projectInfo(); bool handleCertificateIssue();