2018-02-27 18:06:05 +01:00
|
|
|
/*
|
|
|
|
* Strawberry Music Player
|
|
|
|
* This file was part of Clementine.
|
|
|
|
* Copyright 2010, David Sansome <me@davidsansome.com>
|
2021-03-20 21:14:47 +01:00
|
|
|
* Copyright 2018-2021, Jonas Kvinge <jonas@jkvinge.net>
|
2018-02-27 18:06:05 +01:00
|
|
|
*
|
|
|
|
* Strawberry is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Strawberry is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
2018-08-09 18:39:44 +02:00
|
|
|
*
|
2018-02-27 18:06:05 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef PLAYLISTLISTCONTAINER_H
|
|
|
|
#define PLAYLISTLISTCONTAINER_H
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2020-02-08 15:03:11 +01:00
|
|
|
#include <memory>
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2018-05-01 00:41:33 +02:00
|
|
|
#include <QObject>
|
2018-02-27 18:06:05 +01:00
|
|
|
#include <QWidget>
|
2018-05-01 00:41:33 +02:00
|
|
|
#include <QString>
|
|
|
|
#include <QIcon>
|
2020-10-01 19:49:06 +02:00
|
|
|
#include <QModelIndex>
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2020-02-08 15:03:11 +01:00
|
|
|
class QStandardItem;
|
|
|
|
class QSortFilterProxyModel;
|
|
|
|
class QMenu;
|
|
|
|
class QAction;
|
|
|
|
class QContextMenuEvent;
|
|
|
|
class QShowEvent;
|
2019-08-07 17:13:40 +02:00
|
|
|
|
2018-02-27 18:06:05 +01:00
|
|
|
class Application;
|
|
|
|
class Playlist;
|
|
|
|
class PlaylistListModel;
|
|
|
|
class Ui_PlaylistListContainer;
|
2020-08-04 21:18:14 +02:00
|
|
|
class OrganizeDialog;
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
class PlaylistListContainer : public QWidget {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2020-04-07 16:49:15 +02:00
|
|
|
explicit PlaylistListContainer(QWidget *parent = nullptr);
|
2020-06-15 21:55:05 +02:00
|
|
|
~PlaylistListContainer() override;
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
void SetApplication(Application *app);
|
2020-06-28 18:36:48 +02:00
|
|
|
void ReloadSettings();
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2020-06-15 21:55:05 +02:00
|
|
|
protected:
|
|
|
|
void showEvent(QShowEvent *e) override;
|
|
|
|
void contextMenuEvent(QContextMenuEvent *e) override;
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2020-06-15 21:55:05 +02:00
|
|
|
private slots:
|
2018-02-27 18:06:05 +01:00
|
|
|
// From the UI
|
|
|
|
void NewFolderClicked();
|
2021-06-20 19:04:08 +02:00
|
|
|
void ItemDoubleClicked(const QModelIndex &proxy_idx);
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
// From the model
|
2020-10-01 19:49:06 +02:00
|
|
|
void PlaylistPathChanged(const int id, const QString &new_path);
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
// From the PlaylistManager
|
2020-10-01 19:49:06 +02:00
|
|
|
void PlaylistRenamed(const int id, const QString &new_name);
|
2018-02-27 18:06:05 +01:00
|
|
|
// Add playlist if favorite == true
|
2020-10-01 19:49:06 +02:00
|
|
|
void AddPlaylist(const int id, const QString &name, const bool favorite);
|
|
|
|
void RemovePlaylist(const int id);
|
|
|
|
void PlaylistFavoriteStateChanged(const int id, const bool favorite);
|
2018-02-27 18:06:05 +01:00
|
|
|
void CurrentChanged(Playlist *new_playlist);
|
|
|
|
void ActiveChanged(Playlist *new_playlist);
|
|
|
|
|
|
|
|
// From the Player
|
|
|
|
void ActivePlaying();
|
|
|
|
void ActivePaused();
|
|
|
|
void ActiveStopped();
|
|
|
|
|
2020-08-06 16:00:03 +02:00
|
|
|
void ItemsSelectedChanged(const bool selected);
|
|
|
|
|
2020-10-01 19:49:06 +02:00
|
|
|
void SavePlaylist();
|
|
|
|
void Delete();
|
|
|
|
void CopyToDevice();
|
|
|
|
|
2020-08-06 16:00:03 +02:00
|
|
|
private:
|
2018-02-27 18:06:05 +01:00
|
|
|
QStandardItem *ItemForPlaylist(const QString &name, int id);
|
|
|
|
QStandardItem *ItemForFolder(const QString &name) const;
|
|
|
|
void RecursivelySetIcons(QStandardItem *parent) const;
|
|
|
|
|
|
|
|
void RecursivelyFindPlaylists(const QModelIndex &parent, QSet<int> *ids) const;
|
|
|
|
|
|
|
|
void UpdateActiveIcon(int id, const QIcon &icon);
|
|
|
|
|
|
|
|
Application *app_;
|
|
|
|
Ui_PlaylistListContainer *ui_;
|
|
|
|
QMenu *menu_;
|
|
|
|
|
|
|
|
QAction *action_new_folder_;
|
|
|
|
QAction *action_remove_;
|
|
|
|
QAction *action_save_playlist_;
|
2020-10-08 19:19:39 +02:00
|
|
|
#ifndef Q_OS_WIN
|
2019-08-07 17:13:40 +02:00
|
|
|
QAction *action_copy_to_device_;
|
2020-10-08 19:19:39 +02:00
|
|
|
#endif
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
PlaylistListModel *model_;
|
|
|
|
QSortFilterProxyModel *proxy_;
|
|
|
|
|
|
|
|
bool loaded_icons_;
|
|
|
|
QIcon padded_play_icon_;
|
|
|
|
|
|
|
|
int active_playlist_id_;
|
2019-08-07 17:13:40 +02:00
|
|
|
|
2020-08-04 21:18:14 +02:00
|
|
|
std::unique_ptr<OrganizeDialog> organize_dialog_;
|
2018-02-27 18:06:05 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // PLAYLISTLISTCONTAINER_H
|