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 COLLECTIONVIEW_H
|
|
|
|
#define COLLECTIONVIEW_H
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2018-05-01 00:41:33 +02:00
|
|
|
#include <QObject>
|
|
|
|
#include <QAbstractItemModel>
|
|
|
|
#include <QAbstractItemView>
|
|
|
|
#include <QString>
|
|
|
|
#include <QPixmap>
|
|
|
|
#include <QSet>
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2023-07-21 05:55:24 +02:00
|
|
|
#include "core/scoped_ptr.h"
|
2018-02-27 18:06:05 +01:00
|
|
|
#include "core/song.h"
|
|
|
|
#include "widgets/autoexpandingtreeview.h"
|
|
|
|
|
2020-02-08 03:40:30 +01:00
|
|
|
class QWidget;
|
|
|
|
class QMenu;
|
|
|
|
class QAction;
|
2018-05-01 00:41:33 +02:00
|
|
|
class QContextMenuEvent;
|
|
|
|
class QMouseEvent;
|
|
|
|
class QPaintEvent;
|
|
|
|
|
2018-02-27 18:06:05 +01:00
|
|
|
class Application;
|
|
|
|
class CollectionFilterWidget;
|
2018-05-01 00:41:33 +02:00
|
|
|
class EditTagDialog;
|
2020-08-04 21:18:14 +02:00
|
|
|
class OrganizeDialog;
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
class CollectionView : public AutoExpandingTreeView {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2020-04-07 16:49:15 +02:00
|
|
|
explicit CollectionView(QWidget *parent = nullptr);
|
2020-06-15 21:55:05 +02:00
|
|
|
~CollectionView() override;
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2018-05-01 00:41:33 +02:00
|
|
|
// Returns Songs currently selected in the collection view.
|
|
|
|
// Please note that the selection is recursive meaning that if for example an album is selected this will return all of it's songs.
|
2018-02-27 18:06:05 +01:00
|
|
|
SongList GetSelectedSongs() const;
|
|
|
|
|
|
|
|
void SetApplication(Application *app);
|
|
|
|
void SetFilter(CollectionFilterWidget *filter);
|
|
|
|
|
|
|
|
// QTreeView
|
2020-06-15 21:55:05 +02:00
|
|
|
void keyboardSearch(const QString &search) override;
|
2021-01-26 16:48:04 +01:00
|
|
|
void scrollTo(const QModelIndex &idx, ScrollHint hint = EnsureVisible) override;
|
2018-10-02 00:38:52 +02:00
|
|
|
|
2021-06-22 13:45:29 +02:00
|
|
|
int TotalSongs() const;
|
|
|
|
int TotalArtists() const;
|
|
|
|
int TotalAlbums() const;
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
public slots:
|
2020-09-10 22:05:12 +02:00
|
|
|
void TotalSongCountUpdated(const int count);
|
|
|
|
void TotalArtistCountUpdated(const int count);
|
|
|
|
void TotalAlbumCountUpdated(const int count);
|
2018-02-27 18:06:05 +01:00
|
|
|
void ReloadSettings();
|
|
|
|
|
|
|
|
void FilterReturnPressed();
|
|
|
|
|
|
|
|
void SaveFocus();
|
|
|
|
void RestoreFocus();
|
|
|
|
|
2019-02-20 21:27:53 +01:00
|
|
|
void EditTagError(const QString &message);
|
|
|
|
|
|
|
|
signals:
|
2018-02-27 18:06:05 +01:00
|
|
|
void ShowConfigDialog();
|
|
|
|
|
|
|
|
void TotalSongCountUpdated_();
|
|
|
|
void TotalArtistCountUpdated_();
|
|
|
|
void TotalAlbumCountUpdated_();
|
2023-04-09 20:23:42 +02:00
|
|
|
void Error(const QString &error);
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
protected:
|
|
|
|
// QWidget
|
2020-06-15 21:55:05 +02:00
|
|
|
void paintEvent(QPaintEvent *event) override;
|
2024-01-19 23:04:03 +01:00
|
|
|
void keyPressEvent(QKeyEvent *e) override;
|
2020-06-15 21:55:05 +02:00
|
|
|
void mouseReleaseEvent(QMouseEvent *e) override;
|
|
|
|
void contextMenuEvent(QContextMenuEvent *e) override;
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
private slots:
|
|
|
|
void Load();
|
|
|
|
void AddToPlaylist();
|
|
|
|
void AddToPlaylistEnqueue();
|
2018-11-18 23:21:12 +01:00
|
|
|
void AddToPlaylistEnqueueNext();
|
2018-02-27 18:06:05 +01:00
|
|
|
void OpenInNewPlaylist();
|
2020-08-04 21:18:14 +02:00
|
|
|
void Organize();
|
2018-02-27 18:06:05 +01:00
|
|
|
void CopyToDevice();
|
|
|
|
void EditTracks();
|
2019-06-30 21:06:07 +02:00
|
|
|
void RescanSongs();
|
2021-06-22 13:45:29 +02:00
|
|
|
void ShowInBrowser() const;
|
2018-02-27 18:06:05 +01:00
|
|
|
void ShowInVarious();
|
|
|
|
void NoShowInVarious();
|
2020-08-19 22:02:35 +02:00
|
|
|
void Delete();
|
|
|
|
void DeleteFilesFinished(const SongList &songs_with_errors);
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
void RecheckIsEmpty();
|
2021-01-26 16:48:04 +01:00
|
|
|
void SetShowInVarious(const bool on);
|
2018-02-27 18:06:05 +01:00
|
|
|
bool RestoreLevelFocus(const QModelIndex &parent = QModelIndex());
|
|
|
|
void SaveContainerPath(const QModelIndex &child);
|
|
|
|
|
|
|
|
private:
|
|
|
|
Application *app_;
|
|
|
|
CollectionFilterWidget *filter_;
|
|
|
|
|
|
|
|
int total_song_count_;
|
|
|
|
int total_artist_count_;
|
|
|
|
int total_album_count_;
|
|
|
|
|
|
|
|
QPixmap nomusic_;
|
|
|
|
|
|
|
|
QMenu *context_menu_;
|
|
|
|
QModelIndex context_menu_index_;
|
2020-08-19 22:02:35 +02:00
|
|
|
QAction *action_load_;
|
|
|
|
QAction *action_add_to_playlist_;
|
|
|
|
QAction *action_add_to_playlist_enqueue_;
|
|
|
|
QAction *action_add_to_playlist_enqueue_next_;
|
|
|
|
QAction *action_open_in_new_playlist_;
|
|
|
|
QAction *action_organize_;
|
2018-09-20 17:36:23 +02:00
|
|
|
#ifndef Q_OS_WIN
|
2020-08-19 22:02:35 +02:00
|
|
|
QAction *action_copy_to_device_;
|
2018-02-27 18:06:05 +01:00
|
|
|
#endif
|
2020-08-19 22:02:35 +02:00
|
|
|
QAction *action_edit_track_;
|
|
|
|
QAction *action_edit_tracks_;
|
|
|
|
QAction *action_rescan_songs_;
|
|
|
|
QAction *action_show_in_browser_;
|
|
|
|
QAction *action_show_in_various_;
|
|
|
|
QAction *action_no_show_in_various_;
|
|
|
|
QAction *action_delete_files_;
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2023-07-21 05:55:24 +02:00
|
|
|
ScopedPtr<OrganizeDialog> organize_dialog_;
|
|
|
|
ScopedPtr<EditTagDialog> edit_tag_dialog_;
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
bool is_in_keyboard_search_;
|
2020-08-19 22:02:35 +02:00
|
|
|
bool delete_files_;
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
// Save focus
|
|
|
|
Song last_selected_song_;
|
|
|
|
QString last_selected_container_;
|
|
|
|
QSet<QString> last_selected_path_;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // COLLECTIONVIEW_H
|