File indexing completed on 2024-05-05 04:48:34
0001 /**************************************************************************************** 0002 * Copyright (c) 2010 Sergey Ivanov <123kash@gmail.com> * 0003 * Copyright (c) 2013 Alberto Villa <avilla@FreeBSD.org> * 0004 * * 0005 * This program is free software; you can redistribute it and/or modify it under * 0006 * the terms of the GNU General Public License as published by the Free Software * 0007 * Foundation; either version 2 of the License, or (at your option) any later * 0008 * version. * 0009 * * 0010 * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 0011 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 0012 * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 0013 * * 0014 * You should have received a copy of the GNU General Public License along with * 0015 * this program. If not, see <http://www.gnu.org/licenses/>. * 0016 ****************************************************************************************/ 0017 0018 #ifndef MUSICBRAINZTAGSMODEL_H 0019 #define MUSICBRAINZTAGSMODEL_H 0020 0021 #include "core/meta/forward_declarations.h" 0022 0023 #include <QAbstractItemModel> 0024 #include <QMutex> 0025 0026 class MusicBrainzTagsItem; 0027 0028 class MusicBrainzTagsModel : public QAbstractItemModel 0029 { 0030 Q_OBJECT 0031 0032 public: 0033 enum { 0034 SortRole = Qt::UserRole, 0035 TracksRole, 0036 ArtistsRole, 0037 ReleasesRole, 0038 ChosenStateRole 0039 }; 0040 0041 enum ChosenState { 0042 Unchosen, 0043 Chosen 0044 }; 0045 0046 explicit MusicBrainzTagsModel( QObject *parent = nullptr ); 0047 ~MusicBrainzTagsModel() override; 0048 0049 QModelIndex index( int row, int column, 0050 const QModelIndex &parent = QModelIndex() ) const override; 0051 QModelIndex parent( const QModelIndex &index ) const override; 0052 0053 QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const override; 0054 bool setData( const QModelIndex &index, const QVariant &value, int role ) override; 0055 Qt::ItemFlags flags( const QModelIndex &index ) const override; 0056 QVariant headerData( int section, Qt::Orientation orientation, 0057 int role = Qt::DisplayRole ) const override; 0058 0059 int rowCount( const QModelIndex &parent = QModelIndex() ) const override; 0060 int columnCount( const QModelIndex &parent = QModelIndex() ) const override; 0061 0062 QMap<Meta::TrackPtr, QVariantMap> chosenItems() const; 0063 void chooseBestMatchesFromRelease( const QStringList &releases ); 0064 0065 public Q_SLOTS: 0066 void addTrack( const Meta::TrackPtr &track, const QVariantMap &tags ); 0067 0068 void chooseBestMatches(); 0069 void clearChoices(); 0070 0071 private: 0072 MusicBrainzTagsItem *m_rootItem; 0073 mutable QMutex m_modelLock; 0074 }; 0075 0076 #endif // MUSICBRAINZTAGSMDOEL_H