2010-03-24 00:11:46 +01:00
|
|
|
/* This file is part of Clementine.
|
2010-11-20 14:27:10 +01:00
|
|
|
Copyright 2010, David Sansome <me@davidsansome.com>
|
2010-03-24 00:11:46 +01:00
|
|
|
|
|
|
|
Clementine 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.
|
|
|
|
|
|
|
|
Clementine 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 Clementine. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2009-12-24 20:16:07 +01:00
|
|
|
#ifndef LIBRARYVIEW_H
|
|
|
|
#define LIBRARYVIEW_H
|
|
|
|
|
2014-02-06 14:48:00 +01:00
|
|
|
#include <memory>
|
2010-05-17 01:44:33 +02:00
|
|
|
|
2009-12-24 20:16:07 +01:00
|
|
|
#include <QStyledItemDelegate>
|
|
|
|
|
2014-02-06 14:48:00 +01:00
|
|
|
#include "core/song.h"
|
|
|
|
#include "ui/edittagdialog.h"
|
|
|
|
#include "widgets/autoexpandingtreeview.h"
|
2010-06-25 00:45:30 +02:00
|
|
|
|
2012-02-12 14:41:50 +01:00
|
|
|
class Application;
|
2011-11-05 20:09:02 +01:00
|
|
|
class LibraryFilterWidget;
|
2010-06-25 00:45:30 +02:00
|
|
|
class OrganiseDialog;
|
2009-12-24 20:16:07 +01:00
|
|
|
|
2011-01-10 23:26:13 +01:00
|
|
|
class QMimeData;
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
namespace smart_playlists {
|
|
|
|
class Wizard;
|
|
|
|
}
|
2010-11-18 21:19:33 +01:00
|
|
|
|
2009-12-24 20:16:07 +01:00
|
|
|
class LibraryItemDelegate : public QStyledItemDelegate {
|
2011-02-08 22:55:32 +01:00
|
|
|
Q_OBJECT
|
2011-02-26 15:27:57 +01:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
public:
|
2009-12-24 20:16:07 +01:00
|
|
|
LibraryItemDelegate(QObject* parent);
|
2014-02-07 16:34:20 +01:00
|
|
|
void paint(QPainter* painter, const QStyleOptionViewItem& option,
|
|
|
|
const QModelIndex& index) const;
|
2011-02-08 22:55:32 +01:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
public slots:
|
|
|
|
bool helpEvent(QHelpEvent* event, QAbstractItemView* view,
|
|
|
|
const QStyleOptionViewItem& option, const QModelIndex& index);
|
2009-12-24 20:16:07 +01:00
|
|
|
};
|
|
|
|
|
2010-05-17 01:44:33 +02:00
|
|
|
class LibraryView : public AutoExpandingTreeView {
|
2009-12-24 20:16:07 +01:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2014-02-10 16:03:54 +01:00
|
|
|
LibraryView(QWidget* parent = nullptr);
|
2010-06-25 00:45:30 +02:00
|
|
|
~LibraryView();
|
2009-12-24 20:16:07 +01:00
|
|
|
|
2010-04-01 02:12:25 +02:00
|
|
|
static const char* kSettingsGroup;
|
|
|
|
|
2011-01-18 17:34:43 +01:00
|
|
|
// Returns Songs currently selected in the library 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.
|
|
|
|
SongList GetSelectedSongs() const;
|
|
|
|
|
2012-02-12 14:41:50 +01:00
|
|
|
void SetApplication(Application* app);
|
2011-11-05 20:09:02 +01:00
|
|
|
void SetFilter(LibraryFilterWidget* filter);
|
2009-12-24 20:16:07 +01:00
|
|
|
|
2010-05-28 14:52:22 +02:00
|
|
|
// QTreeView
|
2014-02-07 16:34:20 +01:00
|
|
|
void keyboardSearch(const QString& search);
|
2010-08-30 12:31:44 +02:00
|
|
|
void scrollTo(const QModelIndex& index, ScrollHint hint = EnsureVisible);
|
2010-05-28 14:52:22 +02:00
|
|
|
|
2009-12-24 20:16:07 +01:00
|
|
|
public slots:
|
|
|
|
void TotalSongCountUpdated(int count);
|
2010-04-01 02:12:25 +02:00
|
|
|
void ReloadSettings();
|
2009-12-24 20:16:07 +01:00
|
|
|
|
2010-08-29 14:15:30 +02:00
|
|
|
void FilterReturnPressed();
|
|
|
|
|
2012-08-26 14:36:44 +02:00
|
|
|
void SaveFocus();
|
|
|
|
void RestoreFocus();
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
signals:
|
2009-12-24 20:16:07 +01:00
|
|
|
void ShowConfigDialog();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
// QWidget
|
|
|
|
void paintEvent(QPaintEvent* event);
|
|
|
|
void mouseReleaseEvent(QMouseEvent* e);
|
2010-03-21 00:59:39 +01:00
|
|
|
void contextMenuEvent(QContextMenuEvent* e);
|
2009-12-24 20:16:07 +01:00
|
|
|
|
2010-01-17 22:22:56 +01:00
|
|
|
private slots:
|
2010-05-15 19:45:04 +02:00
|
|
|
void Load();
|
2010-04-04 15:31:21 +02:00
|
|
|
void AddToPlaylist();
|
2010-12-29 16:08:43 +01:00
|
|
|
void AddToPlaylistEnqueue();
|
2011-02-09 18:51:59 +01:00
|
|
|
void OpenInNewPlaylist();
|
2010-06-25 00:45:30 +02:00
|
|
|
void Organise();
|
2010-07-19 23:16:22 +02:00
|
|
|
void CopyToDevice();
|
2010-06-25 00:45:30 +02:00
|
|
|
void Delete();
|
2010-12-06 22:16:04 +01:00
|
|
|
void EditTracks();
|
2011-03-17 20:52:21 +01:00
|
|
|
void ShowInBrowser();
|
2010-03-21 00:59:39 +01:00
|
|
|
void ShowInVarious();
|
|
|
|
void NoShowInVarious();
|
2010-01-17 22:22:56 +01:00
|
|
|
|
2010-11-18 20:34:04 +01:00
|
|
|
void NewSmartPlaylist();
|
|
|
|
void EditSmartPlaylist();
|
|
|
|
void DeleteSmartPlaylist();
|
|
|
|
|
2010-11-19 00:08:37 +01:00
|
|
|
void NewSmartPlaylistFinished();
|
|
|
|
void EditSmartPlaylistFinished();
|
|
|
|
|
2010-08-14 13:51:50 +02:00
|
|
|
void DeleteFinished(const SongList& songs_with_errors);
|
|
|
|
|
2009-12-24 20:16:07 +01:00
|
|
|
private:
|
|
|
|
void RecheckIsEmpty();
|
2010-03-21 00:59:39 +01:00
|
|
|
void ShowInVarious(bool on);
|
2012-08-26 14:36:44 +02:00
|
|
|
bool RestoreLevelFocus(const QModelIndex& parent = QModelIndex());
|
|
|
|
void SaveContainerPath(const QModelIndex& child);
|
2009-12-24 20:16:07 +01:00
|
|
|
|
|
|
|
private:
|
2012-02-12 14:41:50 +01:00
|
|
|
Application* app_;
|
2011-11-05 20:09:02 +01:00
|
|
|
LibraryFilterWidget* filter_;
|
2010-07-19 23:16:22 +02:00
|
|
|
|
2009-12-24 20:16:07 +01:00
|
|
|
int total_song_count_;
|
|
|
|
|
|
|
|
QPixmap nomusic_;
|
2010-03-21 00:59:39 +01:00
|
|
|
|
|
|
|
QMenu* context_menu_;
|
|
|
|
QModelIndex context_menu_index_;
|
2010-05-15 19:45:04 +02:00
|
|
|
QAction* load_;
|
2010-04-04 15:31:21 +02:00
|
|
|
QAction* add_to_playlist_;
|
2010-12-29 16:08:43 +01:00
|
|
|
QAction* add_to_playlist_enqueue_;
|
2011-02-09 18:51:59 +01:00
|
|
|
QAction* open_in_new_playlist_;
|
2010-06-25 00:45:30 +02:00
|
|
|
QAction* organise_;
|
2010-07-19 23:16:22 +02:00
|
|
|
QAction* copy_to_device_;
|
2010-06-25 00:45:30 +02:00
|
|
|
QAction* delete_;
|
2010-12-06 22:16:04 +01:00
|
|
|
QAction* edit_track_;
|
2010-12-21 01:20:36 +01:00
|
|
|
QAction* edit_tracks_;
|
2011-03-17 20:52:21 +01:00
|
|
|
QAction* show_in_browser_;
|
2010-03-21 00:59:39 +01:00
|
|
|
QAction* show_in_various_;
|
|
|
|
QAction* no_show_in_various_;
|
2010-05-28 14:52:22 +02:00
|
|
|
|
2010-11-18 20:34:04 +01:00
|
|
|
QAction* new_smart_playlist_;
|
|
|
|
QAction* edit_smart_playlist_;
|
|
|
|
QAction* delete_smart_playlist_;
|
|
|
|
|
2014-02-06 14:48:00 +01:00
|
|
|
std::unique_ptr<OrganiseDialog> organise_dialog_;
|
|
|
|
std::unique_ptr<EditTagDialog> edit_tag_dialog_;
|
2010-08-30 12:31:44 +02:00
|
|
|
|
|
|
|
bool is_in_keyboard_search_;
|
2012-08-26 14:36:44 +02:00
|
|
|
|
|
|
|
// Save focus
|
|
|
|
Song last_selected_song_;
|
|
|
|
QString last_selected_container_;
|
|
|
|
QSet<QString> last_selected_path_;
|
2009-12-24 20:16:07 +01:00
|
|
|
};
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
#endif // LIBRARYVIEW_H
|