File indexing completed on 2025-03-09 04:56:49
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_AVAILABLEPAGESVIEW_H 0009 #define WIDGETS_AVAILABLEPAGESVIEW_H 0010 0011 #include <QWidget> 0012 0013 #include <QHash> 0014 #include <QSharedPointer> 0015 0016 #include <functional> 0017 0018 #include "domain/datasource.h" 0019 #include "messageboxinterface.h" 0020 0021 class QAbstractItemModel; 0022 class QModelIndex; 0023 class QTreeView; 0024 0025 namespace Widgets { 0026 0027 class NameAndDataSourceDialogInterface; 0028 class QuickSelectDialogInterface; 0029 0030 class AvailablePagesView : public QWidget 0031 { 0032 Q_OBJECT 0033 public: 0034 typedef QSharedPointer<NameAndDataSourceDialogInterface> NameAndDataSourceDialogPtr; 0035 typedef std::function<NameAndDataSourceDialogPtr(QWidget*)> ProjectDialogFactory; 0036 typedef QSharedPointer<QuickSelectDialogInterface> QuickSelectDialogPtr; 0037 typedef std::function<QuickSelectDialogPtr(QWidget*)> QuickSelectDialogFactory; 0038 0039 explicit AvailablePagesView(QWidget *parent = nullptr); 0040 0041 QHash<QString, QAction*> globalActions() const; 0042 0043 QObject *model() const; 0044 QAbstractItemModel *projectSourcesModel() const; 0045 Domain::DataSource::Ptr defaultProjectSource() const; 0046 ProjectDialogFactory projectDialogFactory() const; 0047 QuickSelectDialogFactory quickSelectDialogFactory() const; 0048 0049 public slots: 0050 void setModel(QObject *model); 0051 void setProjectSourcesModel(QAbstractItemModel *sources); 0052 void setDefaultProjectSource(const Domain::DataSource::Ptr &source); 0053 void setProjectDialogFactory(const ProjectDialogFactory &factory); 0054 void setQuickSelectDialogFactory(const QuickSelectDialogFactory &factory); 0055 void setMessageBoxInterface(const MessageBoxInterface::Ptr &interface); 0056 0057 signals: 0058 void currentPageChanged(QObject *page); 0059 0060 private slots: 0061 void onCurrentChanged(const QModelIndex ¤t); 0062 void onAddProjectTriggered(); 0063 void onAddContextTriggered(); 0064 void onRemoveTriggered(); 0065 void onGoPreviousTriggered(); 0066 void onGoNextTriggered(); 0067 void onGoToTriggered(); 0068 void onInitTimeout(); 0069 0070 private: 0071 QAction *m_addProjectAction; 0072 QAction *m_addContextAction; 0073 QAction *m_removeAction; 0074 QHash<QString, QAction*> m_actions; 0075 0076 QObject *m_model; 0077 QAbstractItemModel *m_sources; 0078 Domain::DataSource::Ptr m_defaultSource; 0079 QTreeView *m_pagesView; 0080 ProjectDialogFactory m_projectDialogFactory; 0081 QuickSelectDialogFactory m_quickSelectDialogFactory; 0082 MessageBoxInterface::Ptr m_messageBoxInterface; 0083 }; 0084 0085 } 0086 0087 #endif // WIDGETS_AVAILABLEPAGESVIEW_H