File indexing completed on 2025-03-09 04:24:19

0001 /*
0002     Copyright (C) 2009 Dan Meltzer <parallelgrapefruit@gmail.com>
0003 
0004     This program is free software: you can redistribute it and/or modify
0005     it under the terms of the GNU General Public License as published by
0006     the Free Software Foundation, either version 2 of the License, or
0007     (at your option) any later version.
0008 
0009     This program is distributed in the hope that it will be useful,
0010     but WITHOUT ANY WARRANTY; without even the implied warranty of
0011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0012     GNU General Public License for more details.
0013 
0014     You should have received a copy of the GNU General Public License
0015     along with this program.  If not, see <http://www.gnu.org/licenses/>.
0016 
0017 */
0018 
0019 #ifndef SQLREADLABELCAPABILITY_H
0020 #define SQLREADLABELCAPABILITY_H
0021 
0022 #include "core/capabilities/ReadLabelCapability.h"
0023 #include "SqlMeta.h"
0024 
0025 #include <QSharedPointer>
0026 
0027 class SqlStorage;
0028 
0029 namespace Capabilities
0030 {
0031 
0032 class SqlReadLabelCapability : public Capabilities::ReadLabelCapability
0033 {
0034     Q_OBJECT
0035     public:
0036         SqlReadLabelCapability( Meta::SqlTrack *track, const QSharedPointer<SqlStorage> &storage );
0037 
0038         /**
0039         *   fetches a list of labels assigned to this track
0040         */
0041         void fetchLabels() override;
0042 
0043         /**
0044         *   fetches a list of all labels in the database
0045         */
0046         void fetchGlobalLabels() override;   //TODO: This shouldn't be in a Track capability
0047 
0048         /**
0049         *   @returns all labels assigned to this track
0050         */
0051         QStringList labels() override;
0052 
0053     private:
0054         QStringList m_labels;
0055         Meta::TrackPtr m_track;
0056         QSharedPointer<SqlStorage> m_storage;
0057         void fetch(const QString &uniqueURL );
0058 };
0059 
0060 }
0061 
0062 #endif // SQLREADLABELCAPABILITY_H