File indexing completed on 2025-01-05 04:25:40
0001 /* 0002 * Copyright (C) 2017 Malte Veerman <malte.veerman@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 along 0015 * with this program; if not, write to the Free Software Foundation, Inc., 0016 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 0017 */ 0018 0019 #ifndef ALBUMSENGINE_H 0020 #define ALBUMSENGINE_H 0021 0022 #include "AlbumsModel.h" 0023 #include "core/meta/Meta.h" 0024 0025 #include <QObject> 0026 0027 namespace Collections 0028 { 0029 class QueryMaker; 0030 } 0031 0032 class AlbumsEngine : public QObject 0033 { 0034 Q_OBJECT 0035 Q_PROPERTY( AlbumsProxyModel* model READ model CONSTANT ) 0036 Q_PROPERTY( QString filterPattern READ filterPattern WRITE setFilterPattern NOTIFY filterPatternChanged ) 0037 0038 public: 0039 explicit AlbumsEngine( QObject *parent = nullptr ); 0040 0041 AlbumsProxyModel * model() const { return m_proxyModel; } 0042 QString filterPattern() const; 0043 void setFilterPattern( const QString &pattern ); 0044 0045 Q_INVOKABLE void showContextMenu( const QModelIndexList &indexes, const QModelIndex &mouseOverIndex ) const; 0046 Q_INVOKABLE QString getSelectedUrlList(const QModelIndexList &indexes) const; 0047 0048 Q_SIGNALS: 0049 void lengthAlignmentChanged(); 0050 void filterPatternChanged(); 0051 0052 private Q_SLOTS: 0053 void slotTrackChanged( const Meta::TrackPtr &track ); 0054 void slotTrackMetadataChanged( Meta::TrackPtr track ); 0055 void stopped(); 0056 void resultReady( const Meta::AlbumList &albums ); 0057 0058 private: 0059 void update(); 0060 void clear(); 0061 void appendSelected( const QModelIndexList &indexes ) const; 0062 void replaceWithSelected( const QModelIndexList &indexes ) const; 0063 void queueSelected( const QModelIndexList &indexes ) const; 0064 void editSelected( const QModelIndexList &indexes ) const; 0065 Meta::TrackList getSelectedTracks( const QModelIndexList &indexes ) const; 0066 0067 Collections::QueryMaker *m_lastQueryMaker; 0068 Meta::TrackPtr m_currentTrack; 0069 Meta::ArtistPtr m_artist; 0070 0071 AlbumsModel *m_model; 0072 AlbumsProxyModel *m_proxyModel; 0073 }; 0074 0075 #endif // ALBUMSENGINE_H