Sayonara Player
DirectoryTreeView.h
1 /* DirectoryTreeView.h */
2 
3 /* Copyright (C) 2011-2017 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/Utils/SearchableWidget/SearchableView.h"
26 #include "GUI/Utils/Widgets/WidgetTemplate.h"
27 #include "GUI/Utils/Widgets/Dragable.h"
28 #include "Utils/Pimpl.h"
29 
30 #include <QTreeView>
31 #include <QModelIndexList>
32 #include <QTreeView>
33 
34 class LibraryContextMenu;
35 class DirectoryModel;
36 class MetaDataList;
37 class IconProvider;
38 class QStringList;
39 class CustomMimeData;
40 
41 namespace Library
42 {
43  class Info;
44 }
45 
48  public SearchableTreeView,
49  protected Dragable
50 {
51  Q_OBJECT
52  PIMPL(DirectoryTreeView)
53 
54 signals:
55  void sig_info_clicked();
56  void sig_edit_clicked();
57  void sig_lyrics_clicked();
58  void sig_delete_clicked();
59  void sig_play_clicked();
60  void sig_play_new_tab_clicked();
61  void sig_play_next_clicked();
62  void sig_append_clicked();
63  void sig_directory_loaded(const QModelIndex& index);
64  void sig_enter_pressed();
65  void sig_import_requested(LibraryId lib_id, const QStringList& v_md, const QString& target_dir);
66 
67  void sig_copy_started();
68  void sig_copy_finished();
69 
70 public:
71  explicit DirectoryTreeView(QWidget* parent=nullptr);
72  virtual ~DirectoryTreeView();
73 
74  QModelIndex search(const QString& search_term);
75  QString directory_name(const QModelIndex& index);
76  QString directory_name_origin(const QModelIndex& index);
77 
78  QModelIndexList selected_indexes() const;
79  MetaDataList selected_metadata() const;
80  QStringList selected_paths() const;
81 
82  QMimeData* dragable_mimedata() const override;
83  LibraryId library_id(const QModelIndex& index) const;
84 
85 private:
86  enum class DropAction
87  {
88  Copy,
89  Move,
90  Cancel
91  };
92 
93  void init_context_menu();
94  DropAction show_drop_menu(const QPoint& pos);
95 
96 private slots:
97  void drag_move_timer_finished();
98  void create_dir_clicked();
99  void rename_dir_clicked();
100  void copy_started();
101  void copy_finished();
102 
103 protected:
104  void keyPressEvent(QKeyEvent* event) override;
105  void mousePressEvent(QMouseEvent* event) override;
106  void mouseMoveEvent(QMouseEvent *event) override;
107 
108  void dragEnterEvent(QDragEnterEvent *event) override;
109  void dragLeaveEvent(QDragLeaveEvent* event) override;
110  void dragMoveEvent(QDragMoveEvent *event) override;
111  void dropEvent(QDropEvent *event) override;
112 
113 
114  // SayonaraSelectionView
115  int index_by_model_index(const QModelIndex& idx) const override;
116  ModelIndexRange model_indexrange_by_index(int idx) const override;
117 
118  void select_match(const QString& str, SearchDirection direction) override;
119 
120  // Dragable
121  bool has_drag_label() const override;
122  QString drag_label() const override;
123 
124  void skin_changed() override;
125  void language_changed() override;
126 
127  void handle_sayonara_drop(const CustomMimeData* mimedata, const QString& target_dir);
128 
129 
130 };
131 
132 #endif // DIRECTORYTREEVIEW_H
Definition: DirectoryTreeView.h:47
Definition: DirectoryIconProvider.h:27
The SearchableFileTreeModel class.
Definition: DirectoryModel.h:34
Template for Sayonara Widgets. This template is responsible for holding a reference to the settings.
Definition: WidgetTemplate.h:47
The MetaDataList class.
Definition: MetaDataList.h:38
Mimedata class for drag and dropping metadata.
Definition: CustomMimeData.h:33
Definition: typedefs.h:28
The Dragable class.
Definition: Dragable.h:37
An interface class needed when implementing a library plugin.
Definition: CachingThread.h:31
Context menu used for Library and playlist windows.
Definition: LibraryContextMenu.h:36