File indexing completed on 2025-01-19 04:56:40
0001 /* 0002 * SPDX-FileCopyrightText: 2014 Kevin Ottens <ervin@kde.org> 0003 * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0004 */ 0005 0006 0007 0008 #ifndef WIDGETS_APPLICATIONCOMPONENTS_H 0009 #define WIDGETS_APPLICATIONCOMPONENTS_H 0010 0011 #include <QHash> 0012 #include <QModelIndexList> 0013 #include <QObject> 0014 #include <QPointer> 0015 0016 #include <functional> 0017 0018 #include "domain/task.h" 0019 0020 #include "presentation/metatypes.h" 0021 0022 class QAction; 0023 class QWidget; 0024 0025 namespace Presentation { 0026 class ErrorHandler; 0027 } 0028 0029 namespace Widgets { 0030 0031 class AvailablePagesView; 0032 class AvailableSourcesView; 0033 class EditorView; 0034 class PageView; 0035 class PageViewErrorHandler; 0036 class RunningTaskWidget; 0037 0038 class QuickSelectDialogInterface; 0039 0040 class ApplicationComponents : public QObject 0041 { 0042 Q_OBJECT 0043 public: 0044 typedef QSharedPointer<QuickSelectDialogInterface> QuickSelectDialogPtr; 0045 typedef std::function<QuickSelectDialogPtr(QWidget*)> QuickSelectDialogFactory; 0046 0047 explicit ApplicationComponents(QWidget *parent = nullptr); 0048 ~ApplicationComponents(); 0049 0050 QHash<QString, QAction*> globalActions() const; 0051 0052 QObjectPtr model() const; 0053 0054 AvailableSourcesView *availableSourcesView() const; 0055 AvailablePagesView *availablePagesView() const; 0056 virtual PageView *pageView() const; 0057 EditorView *editorView() const; 0058 RunningTaskWidget *runningTaskView() const; 0059 0060 QuickSelectDialogFactory quickSelectDialogFactory() const; 0061 0062 public slots: 0063 virtual void setModel(const QObjectPtr &model); 0064 void setQuickSelectDialogFactory(const QuickSelectDialogFactory &factory); 0065 0066 private slots: 0067 void onCurrentPageChanged(QObject *page); 0068 void onCurrentTaskChanged(const Domain::Task::Ptr &task); 0069 void onMoveItemsRequested(); 0070 0071 private: 0072 Presentation::ErrorHandler *errorHandler() const; 0073 void moveItems(const QModelIndex &destination, const QModelIndexList &droppedItems); 0074 0075 QHash<QString, QAction*> m_actions; 0076 QObjectPtr m_model; 0077 0078 QWidget *m_parent; 0079 QPointer<AvailableSourcesView> m_availableSourcesView; 0080 QPointer<AvailablePagesView> m_availablePagesView; 0081 QPointer<PageView> m_pageView; 0082 QPointer<EditorView> m_editorView; 0083 QPointer<RunningTaskWidget> m_runningTaskView; 0084 0085 QScopedPointer<PageViewErrorHandler> m_errorHandler; 0086 QuickSelectDialogFactory m_quickSelectDialogFactory; 0087 }; 0088 0089 } 0090 0091 #endif // WIDGETS_APPLICATIONCOMPONENTS_H