Sayonara Player
DirectoryTreeView.h
1/* DirectoryTreeView.h */
2
3/* Copyright (C) 2011-2020 Michael Lugmair (Lucio Carreras)
4 *
5 * This file is part of sayonara player
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#ifndef DIRECTORYTREEVIEW_H
22#define DIRECTORYTREEVIEW_H
23
24#include "DirectoryModel.h"
25#include "Gui/InfoDialog/InfoDialogContainer.h"
26
27#include "Gui/Utils/SearchableWidget/SearchableView.h"
28#include "Gui/Utils/Widgets/WidgetTemplate.h"
29#include "Gui/Utils/Widgets/Dragable.h"
30#include "Utils/Pimpl.h"
31
32#include <QTreeView>
33#include <QModelIndexList>
34#include <QTreeView>
35
36class Model;
37class IconProvider;
38
39namespace Gui
40{
41 class LibraryContextMenu;
42 class CustomMimeData;
43}
44
45namespace Library
46{
47 class Info;
48}
49
51
52namespace Directory
53{
58 class TreeView :
59 public Gui::WidgetTemplate<QTreeView>,
61 protected Gui::Dragable
62 {
63 Q_OBJECT
64 PIMPL(TreeView)
65
67
68 signals:
69 void sigDeleteClicked();
70 void sigPlayClicked();
71 void sigPlayNewTabClicked();
72 void sigPlayNextClicked();
73 void sigAppendClicked();
74 void sigDirectoryLoaded(const QModelIndex& index);
75 void sigCurrentIndexChanged(const QModelIndex& index);
76
77 void sigEnterPressed();
78 void sigImportRequested(LibraryId libraryId, const QStringList& tracks, const QString& targetDirectory);
79
80 void sigCopyRequested(const QStringList& paths, const QString& target);
81 void sigMoveRequested(const QStringList& paths, const QString& target);
82 void sigRenameRequested(const QString& path, const QString& target);
83
84 void sigCopyToLibraryRequested(LibraryId libraryId);
85 void sigMoveToLibraryRequested(LibraryId libraryId);
86
87 public:
88 explicit TreeView(QWidget* parent = nullptr);
89 ~TreeView() override;
90
91 void init(LibraryInfoAccessor* libraryInfoAccessor, const Library::Info& info);
92
93 QString directoryName(const QModelIndex& index);
94
95 QModelIndexList selectedRows() const;
96 QStringList selectedPaths() const;
97
98 void setFilterTerm(const QString& filter);
99
100 public slots:
101 void setBusy(bool b);
102
103 private:
104 enum class DropAction
105 {
106 Copy,
107 Move,
108 Cancel
109 };
110
111 void initContextMenu();
112 DropAction showDropMenu(const QPoint& pos);
113 void handleSayonaraDrop(const Gui::CustomMimeData* mimedata, const QString& targetDirectory);
114
115 private slots:
116 void createDirectoryClicked();
117 void renameDirectoryClicked();
118 void viewInFileManagerClicked();
119 void dragTimerTimeout();
120
121 protected:
122 void skinChanged() override;
123
124 void keyPressEvent(QKeyEvent* event) override;
125 void contextMenuEvent(QContextMenuEvent* event) override;
126
127 void dragEnterEvent(QDragEnterEvent* event) override;
128 void dragLeaveEvent(QDragLeaveEvent* event) override;
129 void dragMoveEvent(QDragMoveEvent* event) override;
130 void dropEvent(QDropEvent* event) override;
131
132 void selectionChanged(const QItemSelection& selected, const QItemSelection& deselected) override;
133
134 // InfoDialogContainer interface
135 MD::Interpretation metadataInterpretation() const override;
136 MetaDataList infoDialogData() const override;
137 bool hasMetadata() const override;
138 QStringList pathlist() const override;
139 QWidget* getParentWidget() override;
140 };
141}
142
143#endif // DIRECTORYTREEVIEW_H
The DirectoryTreeView class.
Definition: DirectoryTreeView.h:62
MD::Interpretation metadataInterpretation() const override
get the interpretation for the metadata. Maybe a list of metadata should be intrepeted as albums whil...
bool hasMetadata() const override
returns, if the widget can provide metadata instantly If false, the info dialog will the pathlist
MetaDataList infoDialogData() const override
get the metadata that should be used for the info dialog So for lists, the selected tracks are used h...
QStringList pathlist() const override
Returns a list of paths. This is only used if has_metadata() returns false.
Definition: CustomMimeData.h:35
The Dragable class.
Definition: Dragable.h:61
Template for Sayonara Widgets. This template is responsible for holding a reference to the settings.
Definition: WidgetTemplate.h:87
An interface used to abstract the usage of the info dialog. An implementing class has to return the i...
Definition: InfoDialogContainer.h:64
Definition: LibraryInfoAccessor.h:36
The Info class.
Definition: LibraryInfo.h:38
The MetaDataList class.
Definition: MetaDataList.h:39
An interface class needed when implementing a library plugin.
Definition: LocalLibraryWatcher.h:31