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 MUSICBRAINZTAGSITEM_H 0019 #define MUSICBRAINZTAGSITEM_H 0020 0021 #include "core/meta/forward_declarations.h" 0022 0023 #include <QReadWriteLock> 0024 #include <QVariant> 0025 0026 class MusicBrainzTagsItem 0027 { 0028 public: 0029 explicit MusicBrainzTagsItem( MusicBrainzTagsItem *parent = nullptr, 0030 const Meta::TrackPtr &track = Meta::TrackPtr(), 0031 const QVariantMap &tags = QVariantMap() ); 0032 ~MusicBrainzTagsItem(); 0033 0034 MusicBrainzTagsItem *parent() const; 0035 MusicBrainzTagsItem *child( const int row ) const; 0036 void appendChild( MusicBrainzTagsItem *child ); 0037 int childCount() const; 0038 int row() const; 0039 0040 Meta::TrackPtr track() const; 0041 float score() const; 0042 QVariantMap data() const; 0043 QVariant data( const int column ) const; 0044 void setData( const QVariantMap &tags ); 0045 void mergeData( const QVariantMap &tags ); 0046 bool dataContains( const QString &key ) const; 0047 QVariant dataValue( const QString &key ) const; 0048 0049 bool isChosen() const; 0050 void setChosen( bool chosen ); 0051 MusicBrainzTagsItem *chosenItem() const; 0052 bool chooseBestMatch(); 0053 bool chooseBestMatchFromRelease( const QStringList &releases ); 0054 void clearChoices(); 0055 0056 bool isSimilar( const QVariantMap &tags ) const; 0057 0058 bool operator==( const MusicBrainzTagsItem *item ) const; 0059 bool operator==( const Meta::TrackPtr &track) const; 0060 0061 private: 0062 void setParent( MusicBrainzTagsItem *parent ); 0063 void dataInsert( const QString &key, const QVariant &value ); 0064 void recalcSimilarityRate(); 0065 0066 MusicBrainzTagsItem *m_parent; 0067 QList<MusicBrainzTagsItem *> m_childItems; 0068 0069 Meta::TrackPtr m_track; 0070 QVariantMap m_data; 0071 0072 bool m_chosen; 0073 0074 mutable QReadWriteLock m_dataLock; 0075 mutable QReadWriteLock m_parentLock; 0076 mutable QReadWriteLock m_childrenLock; 0077 }; 0078 0079 #endif // MUSICBRAINZTAGSITEM_H