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_MATCHEDTRACKSPAGE_H 0018 #define STATSYNCING_MATCHEDTRACKSPAGE_H 0019 0020 #include "ui_MatchedTracksPage.h" 0021 #include "statsyncing/Provider.h" 0022 #include "statsyncing/ScrobblingService.h" 0023 0024 class QSortFilterProxyModel; 0025 0026 namespace StatSyncing 0027 { 0028 class MatchedTracksModel; 0029 class SortFilterProxyModel; 0030 0031 class MatchedTracksPage : public QWidget, private Ui::MatchedTracksPage 0032 { 0033 Q_OBJECT 0034 0035 public: 0036 explicit MatchedTracksPage( QWidget *parent = nullptr, Qt::WindowFlags f = {} ); 0037 ~MatchedTracksPage() override; 0038 0039 /** 0040 * Set provider, you must call this before showing the widget. 0041 */ 0042 void setProviders( const ProviderPtrList &providers ); 0043 0044 /** 0045 * Set matched tracks model. MatchedTracksPage does _not_ take ownership of 0046 * the pointer. 0047 */ 0048 void setMatchedTracksModel( MatchedTracksModel *model ); 0049 0050 /** 0051 * Add unique tracks model. MatchedTracksPage does _not_ take ownership of the 0052 * model pointer. 0053 */ 0054 void addUniqueTracksModel( ProviderPtr provider, QAbstractItemModel *model ); 0055 0056 /** 0057 * Add excluded tracks model. MatchedTracksPage does _not_ take ownership of 0058 * the model pointer. 0059 */ 0060 void addExcludedTracksModel( ProviderPtr provider, QAbstractItemModel *model ); 0061 0062 /** 0063 * Set a list of tracks that are going to be scrobbled 0064 */ 0065 void setTracksToScrobble( const TrackList &tracksToScrobble, const QList<ScrobblingServicePtr> &services ); 0066 0067 Q_SIGNALS: 0068 /** 0069 * Emitted when user pushes the Back button. 0070 */ 0071 void back(); 0072 0073 /** 0074 * Emitted when user clicks the Synchronize button. 0075 */ 0076 void accepted(); 0077 0078 /** 0079 * Emitted when user pushes the Cancel button. 0080 */ 0081 void rejected(); 0082 0083 private Q_SLOTS: 0084 void changeMatchedTracksFilter( int index ); 0085 0086 void changeUniqueTracksProvider( int index ); 0087 void changeExcludedTracksProvider( int index ); 0088 0089 void refreshMatchedStatusText(); 0090 void refreshUniqueStatusText(); 0091 void refreshExcludedStatusText(); 0092 0093 void rememberExpandedState( const QModelIndex &parent, int start, int end ); 0094 void restoreExpandedState( const QModelIndex &parent, int start, int end ); 0095 0096 void takeRatingsFrom(); 0097 void includeLabelsFrom(); 0098 void excludeLabelsFrom(); 0099 0100 void expand( int onlyWithTupleFlags = -1 ); 0101 void collapse(); 0102 0103 void openConfiguration(); 0104 0105 private: 0106 void refreshStatusTextHelper( QSortFilterProxyModel *topModel, QLabel *label ); 0107 static void setHeaderSizePoliciesFromModel( QHeaderView *header, QAbstractItemModel *model ); 0108 Q_DISABLE_COPY( MatchedTracksPage ) 0109 0110 QSet<int> m_expandedTuples; 0111 SortFilterProxyModel *m_matchedProxyModel; 0112 QSortFilterProxyModel *m_uniqueProxyModel; 0113 QSortFilterProxyModel *m_excludedProxyModel; 0114 MatchedTracksModel *m_matchedTracksModel; 0115 QMap<ProviderPtr, QAbstractItemModel *> m_uniqueTracksModels; 0116 QMap<ProviderPtr, QAbstractItemModel *> m_excludedTracksModels; 0117 }; 0118 0119 } // namespace StatSyncing 0120 0121 #endif // STATSYNCING_MATCHEDTRACKSPAGE_H