File indexing completed on 2024-05-19 04:50:29
0001 /**************************************************************************************** 0002 * Copyright (c) 2012 Matěj Laitl <matej@laitl.cz> * 0003 * * 0004 * This program is free software; you can redistribute it and/or modify it under * 0005 * the terms of the GNU General Public License as published by the Free Software * 0006 * Foundation; either version 2 of the License, or (at your option) any later * 0007 * version. * 0008 * * 0009 * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 0010 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 0011 * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 0012 * * 0013 * You should have received a copy of the GNU General Public License along with * 0014 * this program. If not, see <http://www.gnu.org/licenses/>. * 0015 ****************************************************************************************/ 0016 0017 #ifndef STATSYNCING_PROVIDERSMODEL_H 0018 #define STATSYNCING_PROVIDERSMODEL_H 0019 0020 #include "statsyncing/Provider.h" 0021 0022 #include <QAbstractListModel> 0023 #include <QSet> 0024 #include <QSharedPointer> 0025 0026 class QItemSelectionModel; 0027 0028 namespace StatSyncing 0029 { 0030 class ProvidersModel : public QAbstractListModel 0031 { 0032 Q_OBJECT 0033 0034 public: 0035 explicit ProvidersModel( const ProviderPtrList &providers, 0036 const ProviderPtrSet &preSelectedProviders, QObject *parent = nullptr ); 0037 ~ProvidersModel() override; 0038 0039 // QAbstractItemModel methods: 0040 QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const override; 0041 int rowCount( const QModelIndex &parent = QModelIndex() ) const override; 0042 0043 // ProvidersModel methods: 0044 ProviderPtrList selectedProviders() const; 0045 0046 /** 0047 * Return binary OR of fields that are reliable for track matching across 0048 * selected providers. 0049 */ 0050 qint64 reliableTrackMetadataIntersection() const; 0051 0052 /** 0053 * Return binary OR of fields that at least one selected providers can write 0054 */ 0055 qint64 writableTrackStatsDataUnion() const; 0056 0057 /** 0058 * You must assign this selection model to your view so that selectedProviders 0059 * gives accurate results. ProvidersModel owns the selection model. 0060 */ 0061 QItemSelectionModel *selectionModel() const; 0062 0063 /** 0064 * Returns fields bit-field as i18n'ed string of comma separated field names. 0065 */ 0066 QString fieldsToString( qint64 fields ) const; 0067 0068 Q_SIGNALS: 0069 void selectedProvidersChanged(); 0070 0071 private: 0072 ProviderPtrList m_providers; 0073 QItemSelectionModel *m_selectionModel; 0074 }; 0075 } // namespace StatSyncing 0076 0077 #endif // STATSYNCING_PROVIDERSMODEL_H