2018-02-27 18:06:05 +01:00
|
|
|
/*
|
|
|
|
* Strawberry Music Player
|
|
|
|
* This file was part of Clementine.
|
|
|
|
* Copyright 2010, David Sansome <me@davidsansome.com>
|
|
|
|
*
|
|
|
|
* 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"
|
|
|
|
|
|
|
|
#include <memory>
|
2018-05-01 00:41:33 +02:00
|
|
|
#include <stdbool.h>
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QWidget>
|
|
|
|
#include <QAbstractItemModel>
|
|
|
|
#include <QAbstractItemView>
|
|
|
|
#include <QString>
|
|
|
|
#include <QPixmap>
|
|
|
|
#include <QPainter>
|
|
|
|
#include <QSet>
|
|
|
|
#include <QStyleOption>
|
2018-02-27 18:06:05 +01:00
|
|
|
#include <QStyledItemDelegate>
|
2018-05-01 00:41:33 +02:00
|
|
|
#include <QStyleOptionViewItem>
|
|
|
|
#include <QAction>
|
|
|
|
#include <QMenu>
|
|
|
|
#include <QtEvents>
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
#include "core/song.h"
|
|
|
|
#include "widgets/autoexpandingtreeview.h"
|
|
|
|
|
2018-05-01 00:41:33 +02:00
|
|
|
class QContextMenuEvent;
|
|
|
|
class QHelpEvent;
|
|
|
|
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;
|
2018-02-27 18:06:05 +01:00
|
|
|
#ifdef HAVE_GSTREAMER
|
|
|
|
class OrganiseDialog;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
class CollectionItemDelegate : public QStyledItemDelegate {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
CollectionItemDelegate(QObject *parent);
|
|
|
|
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
bool helpEvent(QHelpEvent *event, QAbstractItemView *view, const QStyleOptionViewItem &option, const QModelIndex &index);
|
|
|
|
};
|
|
|
|
|
|
|
|
class CollectionView : public AutoExpandingTreeView {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
CollectionView(QWidget *parent = nullptr);
|
|
|
|
~CollectionView();
|
|
|
|
|
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
|
|
|
|
void keyboardSearch(const QString &search);
|
|
|
|
void scrollTo(const QModelIndex &index, ScrollHint hint = EnsureVisible);
|
|
|
|
|
|
|
|
int TotalSongs();
|
|
|
|
int TotalArtists();
|
|
|
|
int TotalAlbums();
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
void TotalSongCountUpdated(int count);
|
|
|
|
void TotalArtistCountUpdated(int count);
|
|
|
|
void TotalAlbumCountUpdated(int count);
|
|
|
|
void ReloadSettings();
|
|
|
|
|
|
|
|
void FilterReturnPressed();
|
|
|
|
|
|
|
|
void SaveFocus();
|
|
|
|
void RestoreFocus();
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void ShowConfigDialog();
|
|
|
|
|
|
|
|
void TotalSongCountUpdated_();
|
|
|
|
void TotalArtistCountUpdated_();
|
|
|
|
void TotalAlbumCountUpdated_();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
// QWidget
|
|
|
|
void paintEvent(QPaintEvent *event);
|
|
|
|
void mouseReleaseEvent(QMouseEvent *e);
|
|
|
|
void contextMenuEvent(QContextMenuEvent *e);
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void Load();
|
|
|
|
void AddToPlaylist();
|
|
|
|
void AddToPlaylistEnqueue();
|
|
|
|
void OpenInNewPlaylist();
|
|
|
|
#ifdef HAVE_GSTREAMER
|
|
|
|
void Organise();
|
|
|
|
void CopyToDevice();
|
|
|
|
#endif
|
|
|
|
void EditTracks();
|
|
|
|
void ShowInBrowser();
|
|
|
|
void ShowInVarious();
|
|
|
|
void NoShowInVarious();
|
|
|
|
|
|
|
|
private:
|
|
|
|
void RecheckIsEmpty();
|
|
|
|
void ShowInVarious(bool on);
|
|
|
|
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_;
|
|
|
|
QAction *load_;
|
|
|
|
QAction *add_to_playlist_;
|
|
|
|
QAction *add_to_playlist_enqueue_;
|
|
|
|
QAction *open_in_new_playlist_;
|
|
|
|
#ifdef HAVE_GSTREAMER
|
|
|
|
QAction *organise_;
|
2018-09-20 17:36:23 +02:00
|
|
|
#ifndef Q_OS_WIN
|
2018-02-27 18:06:05 +01:00
|
|
|
QAction *copy_to_device_;
|
2018-09-20 17:36:23 +02:00
|
|
|
#endif
|
2018-02-27 18:06:05 +01:00
|
|
|
#endif
|
|
|
|
QAction *delete_;
|
|
|
|
QAction *edit_track_;
|
|
|
|
QAction *edit_tracks_;
|
|
|
|
QAction *show_in_browser_;
|
|
|
|
QAction *show_in_various_;
|
|
|
|
QAction *no_show_in_various_;
|
|
|
|
|
|
|
|
#ifdef HAVE_GSTREAMER
|
|
|
|
std::unique_ptr<OrganiseDialog> organise_dialog_;
|
|
|
|
#endif
|
|
|
|
std::unique_ptr<EditTagDialog> edit_tag_dialog_;
|
|
|
|
|
|
|
|
bool is_in_keyboard_search_;
|
|
|
|
|
|
|
|
// Save focus
|
|
|
|
Song last_selected_song_;
|
|
|
|
QString last_selected_container_;
|
|
|
|
QSet<QString> last_selected_path_;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // COLLECTIONVIEW_H
|
|
|
|
|