File indexing completed on 2025-01-05 04:59:43
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 PRESENTATION_AVAILABLESOURCESMODEL_H 0009 #define PRESENTATION_AVAILABLESOURCESMODEL_H 0010 0011 #include <QObject> 0012 0013 #include "domain/datasourcequeries.h" 0014 #include "domain/datasourcerepository.h" 0015 0016 #include "presentation/metatypes.h" 0017 #include "presentation/errorhandlingmodelbase.h" 0018 0019 class QModelIndex; 0020 0021 namespace Presentation { 0022 0023 class AvailableSourcesModel : public QObject, public ErrorHandlingModelBase 0024 { 0025 Q_OBJECT 0026 Q_PROPERTY(QAbstractItemModel* sourceListModel READ sourceListModel) 0027 public: 0028 explicit AvailableSourcesModel(const Domain::DataSourceQueries::Ptr &dataSourceQueries, 0029 const Domain::DataSourceRepository::Ptr &dataSourceRepository, 0030 QObject *parent = nullptr); 0031 0032 QAbstractItemModel *sourceListModel(); 0033 0034 public slots: 0035 void setDefaultItem(const QModelIndex &index); 0036 0037 void showConfigDialog(); 0038 0039 private slots: 0040 void onDefaultSourceChanged(); 0041 0042 private: 0043 void emitDefaultSourceChanged(const QModelIndex &root); 0044 0045 QAbstractItemModel *createSourceListModel(); 0046 0047 QAbstractItemModel *m_sourceListModel; 0048 0049 Domain::DataSourceQueries::Ptr m_dataSourceQueries; 0050 Domain::DataSourceRepository::Ptr m_dataSourceRepository; 0051 }; 0052 0053 } 0054 0055 #endif // PRESENTATION_AVAILABLESOURCESMODEL_H