forked from qt-creator/qt-creator
Axivion: Store origin URL besides payload gotten from Dashboard
This prepares using (relative) URLs gotten from Dashboard instead of using hard-coded ones. Change-Id: Iea19c4010eac1e3f30a33d495a738d37738dc083 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -94,21 +94,22 @@ void DashboardWidget::updateUi()
|
|||||||
delete child->widget();
|
delete child->widget();
|
||||||
delete child;
|
delete child;
|
||||||
}
|
}
|
||||||
std::shared_ptr<const Dto::ProjectInfoDto> info = AxivionPlugin::projectInfo();
|
std::shared_ptr<const DashboardClient::ProjectInfo> projectInfo = AxivionPlugin::projectInfo();
|
||||||
if (!info)
|
if (!projectInfo)
|
||||||
return;
|
return;
|
||||||
m_project->setText(info->name);
|
const Dto::ProjectInfoDto &info = projectInfo->data;
|
||||||
if (info->versions.empty())
|
m_project->setText(info.name);
|
||||||
|
if (info.versions.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const Dto::AnalysisVersionDto &last = info->versions.back();
|
const Dto::AnalysisVersionDto &last = info.versions.back();
|
||||||
if (last.linesOfCode.has_value())
|
if (last.linesOfCode.has_value())
|
||||||
m_loc->setText(QString::number(last.linesOfCode.value()));
|
m_loc->setText(QString::number(last.linesOfCode.value()));
|
||||||
const QDateTime timeStamp = QDateTime::fromString(last.date, Qt::ISODate);
|
const QDateTime timeStamp = QDateTime::fromString(last.date, Qt::ISODate);
|
||||||
m_timestamp->setText(timeStamp.isValid() ? timeStamp.toString("yyyy-MM-dd HH:mm:ss t")
|
m_timestamp->setText(timeStamp.isValid() ? timeStamp.toString("yyyy-MM-dd HH:mm:ss t")
|
||||||
: Tr::tr("unknown"));
|
: Tr::tr("unknown"));
|
||||||
|
|
||||||
const std::vector<Dto::IssueKindInfoDto> &issueKinds = info->issueKinds;
|
const std::vector<Dto::IssueKindInfoDto> &issueKinds = info.issueKinds;
|
||||||
auto toolTip = [issueKinds](const QString &prefix){
|
auto toolTip = [issueKinds](const QString &prefix){
|
||||||
for (const Dto::IssueKindInfoDto &kind : issueKinds) {
|
for (const Dto::IssueKindInfoDto &kind : issueKinds) {
|
||||||
if (kind.prefix == prefix)
|
if (kind.prefix == prefix)
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ class AxivionPluginPrivate : public QObject
|
|||||||
public:
|
public:
|
||||||
void onStartupProjectChanged();
|
void onStartupProjectChanged();
|
||||||
void fetchProjectInfo(const QString &projectName);
|
void fetchProjectInfo(const QString &projectName);
|
||||||
void handleProjectInfo(Utils::expected_str<Dto::ProjectInfoDto> rawInfo);
|
void handleProjectInfo(DashboardClient::RawProjectInfo rawInfo);
|
||||||
void handleOpenedDocs(ProjectExplorer::Project *project);
|
void handleOpenedDocs(ProjectExplorer::Project *project);
|
||||||
void onDocumentOpened(Core::IDocument *doc);
|
void onDocumentOpened(Core::IDocument *doc);
|
||||||
void onDocumentClosed(Core::IDocument * doc);
|
void onDocumentClosed(Core::IDocument * doc);
|
||||||
@@ -57,7 +57,7 @@ public:
|
|||||||
|
|
||||||
Utils::NetworkAccessManager *m_networkAccessManager = Utils::NetworkAccessManager::instance();
|
Utils::NetworkAccessManager *m_networkAccessManager = Utils::NetworkAccessManager::instance();
|
||||||
AxivionOutputPane m_axivionOutputPane;
|
AxivionOutputPane m_axivionOutputPane;
|
||||||
std::shared_ptr<const Dto::ProjectInfoDto> m_currentProjectInfo;
|
std::shared_ptr<const DashboardClient::ProjectInfo> m_currentProjectInfo;
|
||||||
bool m_runningQuery = false;
|
bool m_runningQuery = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -122,7 +122,7 @@ void AxivionPlugin::fetchProjectInfo(const QString &projectName)
|
|||||||
dd->fetchProjectInfo(projectName);
|
dd->fetchProjectInfo(projectName);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<const Dto::ProjectInfoDto> AxivionPlugin::projectInfo()
|
std::shared_ptr<const DashboardClient::ProjectInfo> AxivionPlugin::projectInfo()
|
||||||
{
|
{
|
||||||
QTC_ASSERT(dd, return {});
|
QTC_ASSERT(dd, return {});
|
||||||
return dd->m_currentProjectInfo;
|
return dd->m_currentProjectInfo;
|
||||||
@@ -207,14 +207,14 @@ void AxivionPluginPrivate::clearAllMarks()
|
|||||||
onDocumentClosed(doc);
|
onDocumentClosed(doc);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AxivionPluginPrivate::handleProjectInfo(Utils::expected_str<Dto::ProjectInfoDto> rawInfo)
|
void AxivionPluginPrivate::handleProjectInfo(DashboardClient::RawProjectInfo rawInfo)
|
||||||
{
|
{
|
||||||
m_runningQuery = false;
|
m_runningQuery = false;
|
||||||
if (!rawInfo) {
|
if (!rawInfo) {
|
||||||
Core::MessageManager::writeFlashing(QStringLiteral(u"Axivion: ") + rawInfo.error());
|
Core::MessageManager::writeFlashing(QStringLiteral(u"Axivion: ") + rawInfo.error());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_currentProjectInfo = std::make_shared<const Dto::ProjectInfoDto>(std::move(rawInfo.value()));
|
m_currentProjectInfo = std::make_shared<const DashboardClient::ProjectInfo>(std::move(rawInfo.value()));
|
||||||
m_axivionOutputPane.updateDashboard();
|
m_axivionOutputPane.updateDashboard();
|
||||||
// handle already opened documents
|
// handle already opened documents
|
||||||
if (auto buildSystem = ProjectExplorer::ProjectManager::startupBuildSystem();
|
if (auto buildSystem = ProjectExplorer::ProjectManager::startupBuildSystem();
|
||||||
@@ -238,7 +238,7 @@ void AxivionPluginPrivate::onDocumentOpened(Core::IDocument *doc)
|
|||||||
|
|
||||||
Utils::FilePath relative = doc->filePath().relativeChildPath(project->projectDirectory());
|
Utils::FilePath relative = doc->filePath().relativeChildPath(project->projectDirectory());
|
||||||
// for now only style violations
|
// for now only style violations
|
||||||
AxivionQuery query(AxivionQuery::IssuesForFileList, {m_currentProjectInfo->name, "SV",
|
AxivionQuery query(AxivionQuery::IssuesForFileList, {m_currentProjectInfo->data.name, "SV",
|
||||||
relative.path() } );
|
relative.path() } );
|
||||||
AxivionQueryRunner *runner = new AxivionQueryRunner(query, this);
|
AxivionQueryRunner *runner = new AxivionQueryRunner(query, this);
|
||||||
connect(runner, &AxivionQueryRunner::resultRetrieved, this, [this](const QByteArray &result){
|
connect(runner, &AxivionQueryRunner::resultRetrieved, this, [this](const QByteArray &result){
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "dashboard/dto.h"
|
#include "dashboard/dashboardclient.h"
|
||||||
|
|
||||||
#include <extensionsystem/iplugin.h>
|
#include <extensionsystem/iplugin.h>
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@ public:
|
|||||||
~AxivionPlugin() final;
|
~AxivionPlugin() final;
|
||||||
|
|
||||||
static void fetchProjectInfo(const QString &projectName);
|
static void fetchProjectInfo(const QString &projectName);
|
||||||
static std::shared_ptr<const Dto::ProjectInfoDto> projectInfo();
|
static std::shared_ptr<const DashboardClient::ProjectInfo> projectInfo();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void initialize() final;
|
void initialize() final;
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ static void deleteLater(QObject *obj)
|
|||||||
obj->deleteLater();
|
obj->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
using RawBody = Utils::expected_str<QByteArray>;
|
using RawBody = Utils::expected_str<DataWithOrigin<QByteArray>>;
|
||||||
|
|
||||||
class RawBodyReader final
|
class RawBodyReader final
|
||||||
{
|
{
|
||||||
@@ -48,7 +48,7 @@ public:
|
|||||||
return tl::make_unexpected(QString::number(error)
|
return tl::make_unexpected(QString::number(error)
|
||||||
+ QLatin1String(": ")
|
+ QLatin1String(": ")
|
||||||
+ m_reply->errorString());
|
+ m_reply->errorString());
|
||||||
return m_reply->readAll();
|
return DataWithOrigin(m_reply->url(), m_reply->readAll());
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -56,12 +56,14 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static Utils::expected_str<T> RawBodyParser(RawBody rawBody)
|
static Utils::expected_str<DataWithOrigin<T>> RawBodyParser(RawBody rawBody)
|
||||||
{
|
{
|
||||||
if (!rawBody)
|
if (!rawBody)
|
||||||
return tl::make_unexpected(std::move(rawBody.error()));
|
return tl::make_unexpected(std::move(rawBody.error()));
|
||||||
try {
|
try {
|
||||||
return { T::deserialize(rawBody.value()) };
|
T data = T::deserialize(rawBody.value().data);
|
||||||
|
return DataWithOrigin(std::move(rawBody.value().origin),
|
||||||
|
std::move(data));
|
||||||
} catch (const Dto::invalid_dto_exception &e) {
|
} catch (const Dto::invalid_dto_exception &e) {
|
||||||
return tl::make_unexpected(QString::fromUtf8(e.what()));
|
return tl::make_unexpected(QString::fromUtf8(e.what()));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,14 +13,26 @@
|
|||||||
#include <utils/networkaccessmanager.h>
|
#include <utils/networkaccessmanager.h>
|
||||||
|
|
||||||
#include <QFuture>
|
#include <QFuture>
|
||||||
|
#include <QNetworkReply>
|
||||||
|
|
||||||
namespace Axivion::Internal
|
namespace Axivion::Internal
|
||||||
{
|
{
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
class DataWithOrigin
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
QUrl origin;
|
||||||
|
T data;
|
||||||
|
|
||||||
|
DataWithOrigin(QUrl origin, T data) : origin(std::move(origin)), data(std::move(data)) { }
|
||||||
|
};
|
||||||
|
|
||||||
class DashboardClient
|
class DashboardClient
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using RawProjectInfo = Utils::expected_str<Dto::ProjectInfoDto>;
|
using ProjectInfo = DataWithOrigin<Dto::ProjectInfoDto>;
|
||||||
|
using RawProjectInfo = Utils::expected_str<ProjectInfo>;
|
||||||
|
|
||||||
DashboardClient(Utils::NetworkAccessManager &networkAccessManager);
|
DashboardClient(Utils::NetworkAccessManager &networkAccessManager);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user