Axivion: Improve handling for invalid filters

Change-Id: Ic18a3037e9225016ae73075ce089c21c2f8d2f89
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
Christian Stenger
2024-09-04 11:20:50 +02:00
parent fca6d1b920
commit d023afcb53
7 changed files with 77 additions and 26 deletions

View File

@@ -14,6 +14,8 @@
<file>images/button-MV@2x.png</file>
<file>images/button-SV.png</file>
<file>images/button-SV@2x.png</file>
<file>images/error.png</file>
<file>images/error@2x.png</file>
<file>images/nodata.png</file>
<file>images/nodata@2x.png</file>
<file>images/sortAsc.png</file>

View File

@@ -136,6 +136,8 @@ public:
const std::optional<Dto::TableInfoDto> currentTableInfo() const { return m_currentTableInfo; }
IssueListSearch searchFromUi() const;
void showOverlay(const QString &errorMessage = {});
private:
void updateTable();
void addIssues(const Dto::IssueTableDto &dto, int startRow);
@@ -145,8 +147,7 @@ private:
void fetchTable();
void fetchIssues(const IssueListSearch &search);
void onFetchRequested(int startRow, int limit);
void showNoDataOverlay();
void hideNoDataOverlay();
void hideOverlay();
QString m_currentPrefix;
QString m_currentProject;
@@ -168,7 +169,7 @@ private:
QStringList m_userNames;
QStringList m_versionDates;
TaskTreeRunner m_taskTreeRunner;
OverlayWidget *m_noDataOverlay = nullptr;
OverlayWidget *m_overlay = nullptr;
};
IssuesWidget::IssuesWidget(QWidget *parent)
@@ -436,7 +437,7 @@ void IssuesWidget::addIssues(const Dto::IssueTableDto &dto, int startRow)
}
m_issuesModel->setItems(items);
if (items.isEmpty() && m_totalRowCount == 0)
showNoDataOverlay();
showOverlay();
}
void IssuesWidget::onSearchParameterChanged()
@@ -611,7 +612,7 @@ void IssuesWidget::fetchTable()
void IssuesWidget::fetchIssues(const IssueListSearch &search)
{
hideNoDataOverlay();
hideOverlay();
const auto issuesHandler = [this, startRow = search.offset](const Dto::IssueTableDto &dto) {
addIssues(dto, startRow);
};
@@ -631,33 +632,40 @@ void IssuesWidget::onFetchRequested(int startRow, int limit)
fetchIssues(search);
}
void IssuesWidget::showNoDataOverlay()
void IssuesWidget::showOverlay(const QString &errorMessage)
{
if (!m_noDataOverlay) {
if (!m_overlay) {
QTC_ASSERT(m_issuesView, return);
m_noDataOverlay = new OverlayWidget(this);
m_noDataOverlay->setPaintFunction([](QWidget *that, QPainter &p, QPaintEvent *) {
static const QIcon icon = Icon({{":/axivion/images/nodata.png",
Theme::IconsDisabledColor}},
m_overlay = new OverlayWidget(this);
m_overlay->attachToWidget(m_issuesView);
}
m_overlay->setPaintFunction([errorMessage](QWidget *that, QPainter &p, QPaintEvent *) {
static const QIcon noData = Icon({{":/axivion/images/nodata.png", Theme::IconsDisabledColor}},
Utils::Icon::Tint).icon();
static const QIcon error = Icon({{":/axivion/images/error.png", Theme::IconsErrorColor}},
Utils::Icon::Tint).icon();
QRect iconRect(0, 0, 32, 32);
iconRect.moveCenter(that->rect().center());
icon.paint(&p, iconRect);
if (errorMessage.isEmpty())
noData.paint(&p, iconRect);
else
error.paint(&p, iconRect);
p.save();
p.setPen(Utils::creatorColor(Theme::TextColorDisabled));
p.drawText(iconRect.bottomRight() + QPoint{10, p.fontMetrics().height() / 2 - 16},
Tr::tr("No Data"));
const QFontMetrics &fm = p.fontMetrics();
p.drawText(iconRect.bottomRight() + QPoint{10, fm.height() / 2 - 16 - fm.descent()},
errorMessage.isEmpty() ? Tr::tr("No Data") : errorMessage);
p.restore();
});
m_noDataOverlay->attachToWidget(m_issuesView);
}
m_noDataOverlay->show();
m_overlay->show();
}
void IssuesWidget::hideNoDataOverlay()
void IssuesWidget::hideOverlay()
{
if (m_noDataOverlay)
m_noDataOverlay->hide();
if (m_overlay)
m_overlay->hide();
}
class AxivionOutputPane final : public IOutputPane
@@ -736,6 +744,13 @@ public:
issues->updateUi(kind);
}
void handleShowFilterException(const QString &errorMessage)
{
QTC_ASSERT(m_outputWidget, return);
if (auto issues = static_cast<IssuesWidget *>(m_outputWidget->widget(0)))
issues->showOverlay(errorMessage);
}
bool handleContextMenu(const QString &issue, const ItemViewEvent &e)
{
auto issues = static_cast<IssuesWidget *>(m_outputWidget->widget(0));
@@ -810,4 +825,10 @@ static bool issueListContextMenuEvent(const ItemViewEvent &ev)
return theAxivionOutputPane->handleContextMenu(issue, ev);
}
void showFilterException(const QString &errorMessage)
{
QTC_ASSERT(theAxivionOutputPane, return);
theAxivionOutputPane->handleShowFilterException(errorMessage);
}
} // Axivion::Internal

View File

@@ -9,5 +9,6 @@ namespace Axivion::Internal {
void setupAxivionOutputPane(QObject *guard);
void updateDashboard();
void showFilterException(const QString &errorMessage);
} // Axivion::Internal

View File

@@ -501,6 +501,12 @@ static Group dtoRecipe(const Storage<DtoStorageType<DtoType>> &dtoStorage)
}
}
if (statusCode == 400 && error->type == "InvalidFilterException"
&& !error->message.isEmpty()) {
// handle error..
showFilterException(error->message);
return DoneResult::Error;
}
errorString = Error(DashboardError(reply->url(), statusCode,
reply->attribute(QNetworkRequest::HttpReasonPhraseAttribute).toString(),
*error)).message();

Binary file not shown.

After

Width:  |  Height:  |  Size: 234 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 427 B

View File

@@ -4130,6 +4130,27 @@
sodipodi:nodetypes="ccccccc" />
</g>
</g>
<g
id="src/plugins/axivion/images/error"
transform="translate(33)">
<use
x="0"
y="0"
xlink:href="#backgroundRect_32"
id="use2674"
width="100%"
height="100%"
transform="translate(2168,172)" />
<use
x="0"
y="0"
xlink:href="#src/libs/utils/images/error"
id="use4537"
style="display:inline"
width="100%"
height="100%"
transform="matrix(2,0,0,2,2040,-520)" />
</g>
</g>
<g
inkscape:groupmode="layer"

Before

Width:  |  Height:  |  Size: 377 KiB

After

Width:  |  Height:  |  Size: 377 KiB