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