[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [zanshin] /: ApplicationComponents install PageViewErrorHandler on the model
From: Kevin Ottens <ervin () kde ! org>
Date: 2016-11-23 8:23:15
Message-ID: E1c9Spn-00066t-7K () code ! kde ! org
[Download RAW message or body]
Git commit 5f82a14479c1a489277f6d2cc0de46c62a1bd85a by Kevin Ottens.
Committed on 23/11/2016 at 08:23.
Pushed by ervin into branch 'master'.
ApplicationComponents install PageViewErrorHandler on the model
Summary: Now we see the error messages coming back from the backend jobs.
Reviewers: bensi, dfaure, franckarrecot
Reviewed By: franckarrecot
Differential Revision: https://phabricator.kde.org/D2698
M +16 -3 src/widgets/applicationcomponents.cpp
M +7 -0 src/widgets/applicationcomponents.h
M +13 -1 tests/units/widgets/applicationcomponentstest.cpp
https://commits.kde.org/zanshin/5f82a14479c1a489277f6d2cc0de46c62a1bd85a
diff --git a/src/widgets/applicationcomponents.cpp \
b/src/widgets/applicationcomponents.cpp index 4db8a40..3c01ff7 100644
--- a/src/widgets/applicationcomponents.cpp
+++ b/src/widgets/applicationcomponents.cpp
@@ -37,6 +37,7 @@
#include "availablesourcesview.h"
#include "editorview.h"
#include "pageview.h"
+#include "pageviewerrorhandler.h"
#include "quickselectdialog.h"
using namespace Widgets;
@@ -47,7 +48,8 @@ ApplicationComponents::ApplicationComponents(QWidget \
*parent) m_availableSourcesView(Q_NULLPTR),
m_availablePagesView(Q_NULLPTR),
m_pageView(Q_NULLPTR),
- m_editorView(Q_NULLPTR)
+ m_editorView(Q_NULLPTR),
+ m_errorHandler(new PageViewErrorHandler)
{
m_quickSelectDialogFactory = [] (QWidget *parent) {
return QuickSelectDialogPtr(new QuickSelectDialog(parent));
@@ -130,6 +132,7 @@ PageView *ApplicationComponents::pageView() const
ApplicationComponents *self = \
const_cast<ApplicationComponents*>(this); self->m_pageView = pageView;
+ self->m_errorHandler->setPageView(pageView);
connect(self->m_pageView, &PageView::currentArtifactChanged, self, \
&ApplicationComponents::onCurrentArtifactChanged); }
@@ -162,8 +165,10 @@ void ApplicationComponents::setModel(const QObjectPtr \
&model) if (m_model == model)
return;
- if (m_model && m_pageView) {
- disconnect(m_model.data(), 0, m_pageView, 0);
+ if (m_model) {
+ if (m_pageView)
+ disconnect(m_model.data(), 0, m_pageView, 0);
+ m_model->setProperty("errorHandler", 0);
}
// Delay deletion of the old model until we're out of scope
@@ -172,6 +177,9 @@ void ApplicationComponents::setModel(const QObjectPtr \
&model)
m_model = model;
+ if (m_model)
+ m_model->setProperty("errorHandler", \
QVariant::fromValue(errorHandler())); +
if (m_availableSourcesView) {
m_availableSourcesView->setModel(m_model ? \
m_model->property("availableSources").value<QObject*>() : Q_NULLPTR);
@@ -243,6 +251,11 @@ void ApplicationComponents::onMoveItemsRequested()
moveItems(dlg->selectedIndex(), m_pageView->selectedIndexes());
}
+Presentation::ErrorHandler *ApplicationComponents::errorHandler() const
+{
+ return m_errorHandler.data();
+}
+
void ApplicationComponents::moveItems(const QModelIndex &destination, \
const QModelIndexList &droppedItems) {
Q_ASSERT(destination.isValid());
diff --git a/src/widgets/applicationcomponents.h \
b/src/widgets/applicationcomponents.h index 42b8e71..33323ab 100644
--- a/src/widgets/applicationcomponents.h
+++ b/src/widgets/applicationcomponents.h
@@ -39,12 +39,17 @@
class QAction;
class QWidget;
+namespace Presentation {
+class ErrorHandler;
+}
+
namespace Widgets {
class AvailablePagesView;
class AvailableSourcesView;
class EditorView;
class PageView;
+class PageViewErrorHandler;
class QuickSelectDialogInterface;
@@ -79,6 +84,7 @@ private slots:
void onMoveItemsRequested();
private:
+ Presentation::ErrorHandler *errorHandler() const;
void moveItems(const QModelIndex &destination, const QModelIndexList \
&droppedItems);
QHash<QString, QAction*> m_actions;
@@ -90,6 +96,7 @@ private:
PageView *m_pageView;
QPointer<EditorView> m_editorView;
+ QScopedPointer<PageViewErrorHandler> m_errorHandler;
QuickSelectDialogFactory m_quickSelectDialogFactory;
};
diff --git a/tests/units/widgets/applicationcomponentstest.cpp \
b/tests/units/widgets/applicationcomponentstest.cpp index e5d425a..cca8dce \
100644
--- a/tests/units/widgets/applicationcomponentstest.cpp
+++ b/tests/units/widgets/applicationcomponentstest.cpp
@@ -45,6 +45,7 @@
#include "widgets/editorview.h"
#include "widgets/filterwidget.h"
#include "widgets/pageview.h"
+#include "widgets/pageviewerrorhandler.h"
#include "widgets/quickselectdialog.h"
@@ -294,7 +295,7 @@ public:
}
private slots:
- void shouldHaveApplicationModel()
+ void shouldHaveApplicationModelAndSetErrorHandler()
{
// GIVEN
Widgets::ApplicationComponents components;
@@ -305,6 +306,17 @@ private slots:
// THEN
QCOMPARE(components.model(), model);
+ auto errorHandlerBase = \
model->property("errorHandler").value<Presentation::ErrorHandler*>(); + \
QVERIFY(errorHandlerBase); + auto errorHandler = \
static_cast<Widgets::PageViewErrorHandler*>(errorHandlerBase); + \
QVERIFY(errorHandler); + QVERIFY(!errorHandler->pageView());
+
+ // WHEN
+ auto pageView = components.pageView();
+
+ // THEN
+ QCOMPARE(errorHandler->pageView(), pageView);
}
void shouldApplyAvailableSourcesModelToAvailableSourcesView()
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic