forked from qt-creator/qt-creator
Axivion: Improve handling for invalid filters
Change-Id: Ic18a3037e9225016ae73075ce089c21c2f8d2f89 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
@@ -14,6 +14,8 @@
|
|||||||
<file>images/button-MV@2x.png</file>
|
<file>images/button-MV@2x.png</file>
|
||||||
<file>images/button-SV.png</file>
|
<file>images/button-SV.png</file>
|
||||||
<file>images/button-SV@2x.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.png</file>
|
||||||
<file>images/nodata@2x.png</file>
|
<file>images/nodata@2x.png</file>
|
||||||
<file>images/sortAsc.png</file>
|
<file>images/sortAsc.png</file>
|
||||||
|
@@ -136,6 +136,8 @@ public:
|
|||||||
|
|
||||||
const std::optional<Dto::TableInfoDto> currentTableInfo() const { return m_currentTableInfo; }
|
const std::optional<Dto::TableInfoDto> currentTableInfo() const { return m_currentTableInfo; }
|
||||||
IssueListSearch searchFromUi() const;
|
IssueListSearch searchFromUi() const;
|
||||||
|
|
||||||
|
void showOverlay(const QString &errorMessage = {});
|
||||||
private:
|
private:
|
||||||
void updateTable();
|
void updateTable();
|
||||||
void addIssues(const Dto::IssueTableDto &dto, int startRow);
|
void addIssues(const Dto::IssueTableDto &dto, int startRow);
|
||||||
@@ -145,8 +147,7 @@ private:
|
|||||||
void fetchTable();
|
void fetchTable();
|
||||||
void fetchIssues(const IssueListSearch &search);
|
void fetchIssues(const IssueListSearch &search);
|
||||||
void onFetchRequested(int startRow, int limit);
|
void onFetchRequested(int startRow, int limit);
|
||||||
void showNoDataOverlay();
|
void hideOverlay();
|
||||||
void hideNoDataOverlay();
|
|
||||||
|
|
||||||
QString m_currentPrefix;
|
QString m_currentPrefix;
|
||||||
QString m_currentProject;
|
QString m_currentProject;
|
||||||
@@ -168,7 +169,7 @@ private:
|
|||||||
QStringList m_userNames;
|
QStringList m_userNames;
|
||||||
QStringList m_versionDates;
|
QStringList m_versionDates;
|
||||||
TaskTreeRunner m_taskTreeRunner;
|
TaskTreeRunner m_taskTreeRunner;
|
||||||
OverlayWidget *m_noDataOverlay = nullptr;
|
OverlayWidget *m_overlay = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
IssuesWidget::IssuesWidget(QWidget *parent)
|
IssuesWidget::IssuesWidget(QWidget *parent)
|
||||||
@@ -436,7 +437,7 @@ void IssuesWidget::addIssues(const Dto::IssueTableDto &dto, int startRow)
|
|||||||
}
|
}
|
||||||
m_issuesModel->setItems(items);
|
m_issuesModel->setItems(items);
|
||||||
if (items.isEmpty() && m_totalRowCount == 0)
|
if (items.isEmpty() && m_totalRowCount == 0)
|
||||||
showNoDataOverlay();
|
showOverlay();
|
||||||
}
|
}
|
||||||
|
|
||||||
void IssuesWidget::onSearchParameterChanged()
|
void IssuesWidget::onSearchParameterChanged()
|
||||||
@@ -611,7 +612,7 @@ void IssuesWidget::fetchTable()
|
|||||||
|
|
||||||
void IssuesWidget::fetchIssues(const IssueListSearch &search)
|
void IssuesWidget::fetchIssues(const IssueListSearch &search)
|
||||||
{
|
{
|
||||||
hideNoDataOverlay();
|
hideOverlay();
|
||||||
const auto issuesHandler = [this, startRow = search.offset](const Dto::IssueTableDto &dto) {
|
const auto issuesHandler = [this, startRow = search.offset](const Dto::IssueTableDto &dto) {
|
||||||
addIssues(dto, startRow);
|
addIssues(dto, startRow);
|
||||||
};
|
};
|
||||||
@@ -631,33 +632,40 @@ void IssuesWidget::onFetchRequested(int startRow, int limit)
|
|||||||
fetchIssues(search);
|
fetchIssues(search);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IssuesWidget::showNoDataOverlay()
|
void IssuesWidget::showOverlay(const QString &errorMessage)
|
||||||
{
|
{
|
||||||
if (!m_noDataOverlay) {
|
if (!m_overlay) {
|
||||||
QTC_ASSERT(m_issuesView, return);
|
QTC_ASSERT(m_issuesView, return);
|
||||||
m_noDataOverlay = new OverlayWidget(this);
|
m_overlay = new OverlayWidget(this);
|
||||||
m_noDataOverlay->setPaintFunction([](QWidget *that, QPainter &p, QPaintEvent *) {
|
m_overlay->attachToWidget(m_issuesView);
|
||||||
static const QIcon icon = Icon({{":/axivion/images/nodata.png",
|
}
|
||||||
Theme::IconsDisabledColor}},
|
|
||||||
|
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();
|
Utils::Icon::Tint).icon();
|
||||||
QRect iconRect(0, 0, 32, 32);
|
QRect iconRect(0, 0, 32, 32);
|
||||||
iconRect.moveCenter(that->rect().center());
|
iconRect.moveCenter(that->rect().center());
|
||||||
icon.paint(&p, iconRect);
|
if (errorMessage.isEmpty())
|
||||||
|
noData.paint(&p, iconRect);
|
||||||
|
else
|
||||||
|
error.paint(&p, iconRect);
|
||||||
p.save();
|
p.save();
|
||||||
p.setPen(Utils::creatorColor(Theme::TextColorDisabled));
|
p.setPen(Utils::creatorColor(Theme::TextColorDisabled));
|
||||||
p.drawText(iconRect.bottomRight() + QPoint{10, p.fontMetrics().height() / 2 - 16},
|
const QFontMetrics &fm = p.fontMetrics();
|
||||||
Tr::tr("No Data"));
|
p.drawText(iconRect.bottomRight() + QPoint{10, fm.height() / 2 - 16 - fm.descent()},
|
||||||
|
errorMessage.isEmpty() ? Tr::tr("No Data") : errorMessage);
|
||||||
p.restore();
|
p.restore();
|
||||||
});
|
});
|
||||||
m_noDataOverlay->attachToWidget(m_issuesView);
|
|
||||||
}
|
m_overlay->show();
|
||||||
m_noDataOverlay->show();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void IssuesWidget::hideNoDataOverlay()
|
void IssuesWidget::hideOverlay()
|
||||||
{
|
{
|
||||||
if (m_noDataOverlay)
|
if (m_overlay)
|
||||||
m_noDataOverlay->hide();
|
m_overlay->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
class AxivionOutputPane final : public IOutputPane
|
class AxivionOutputPane final : public IOutputPane
|
||||||
@@ -736,6 +744,13 @@ public:
|
|||||||
issues->updateUi(kind);
|
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)
|
bool handleContextMenu(const QString &issue, const ItemViewEvent &e)
|
||||||
{
|
{
|
||||||
auto issues = static_cast<IssuesWidget *>(m_outputWidget->widget(0));
|
auto issues = static_cast<IssuesWidget *>(m_outputWidget->widget(0));
|
||||||
@@ -810,4 +825,10 @@ static bool issueListContextMenuEvent(const ItemViewEvent &ev)
|
|||||||
return theAxivionOutputPane->handleContextMenu(issue, ev);
|
return theAxivionOutputPane->handleContextMenu(issue, ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void showFilterException(const QString &errorMessage)
|
||||||
|
{
|
||||||
|
QTC_ASSERT(theAxivionOutputPane, return);
|
||||||
|
theAxivionOutputPane->handleShowFilterException(errorMessage);
|
||||||
|
}
|
||||||
|
|
||||||
} // Axivion::Internal
|
} // Axivion::Internal
|
||||||
|
@@ -9,5 +9,6 @@ namespace Axivion::Internal {
|
|||||||
|
|
||||||
void setupAxivionOutputPane(QObject *guard);
|
void setupAxivionOutputPane(QObject *guard);
|
||||||
void updateDashboard();
|
void updateDashboard();
|
||||||
|
void showFilterException(const QString &errorMessage);
|
||||||
|
|
||||||
} // Axivion::Internal
|
} // Axivion::Internal
|
||||||
|
@@ -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,
|
errorString = Error(DashboardError(reply->url(), statusCode,
|
||||||
reply->attribute(QNetworkRequest::HttpReasonPhraseAttribute).toString(),
|
reply->attribute(QNetworkRequest::HttpReasonPhraseAttribute).toString(),
|
||||||
*error)).message();
|
*error)).message();
|
||||||
|
BIN
src/plugins/axivion/images/error.png
Normal file
BIN
src/plugins/axivion/images/error.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 234 B |
BIN
src/plugins/axivion/images/error@2x.png
Normal file
BIN
src/plugins/axivion/images/error@2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 427 B |
@@ -4130,6 +4130,27 @@
|
|||||||
sodipodi:nodetypes="ccccccc" />
|
sodipodi:nodetypes="ccccccc" />
|
||||||
</g>
|
</g>
|
||||||
</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>
|
||||||
<g
|
<g
|
||||||
inkscape:groupmode="layer"
|
inkscape:groupmode="layer"
|
||||||
|
Before Width: | Height: | Size: 377 KiB After Width: | Height: | Size: 377 KiB |
Reference in New Issue
Block a user