PCManFM-Qt
dirtreeview.h
1 /*
2  * <one line to give the program's name and a brief idea of what it does.>
3  * Copyright (C) 2014 <copyright holder> <email>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  *
19  */
20 
21 #ifndef FM_DIRTREEVIEW_H
22 #define FM_DIRTREEVIEW_H
23 
24 #include "libfmqtglobals.h"
25 #include <QTreeView>
26 #include <libfm/fm.h>
27 #include "path.h"
28 
29 class QItemSelection;
30 
31 namespace Fm {
32 
33 class FileMenu;
34 class DirTreeModelItem;
35 
36 class LIBFM_QT_API DirTreeView : public QTreeView {
37  Q_OBJECT
38 
39 public:
40  DirTreeView(QWidget* parent);
41  ~DirTreeView();
42 
43  FmPath* currentPath() {
44  return currentPath_;
45  }
46 
47  void setCurrentPath(FmPath* path);
48 
49  // libfm-gtk compatible alias
50  FmPath* getCwd() {
51  return currentPath();
52  }
53 
54  void chdir(FmPath* path) {
55  setCurrentPath(path);
56  }
57 
58  virtual void setModel(QAbstractItemModel* model);
59 
60 protected:
61  virtual void mousePressEvent(QMouseEvent* event);
62 
63 private:
64  void cancelPendingChdir();
65  void expandPendingPath();
66 
67 Q_SIGNALS:
68  void chdirRequested(int type, FmPath* path);
69  void openFolderInNewWindowRequested(FmPath* path);
70  void openFolderInNewTabRequested(FmPath* path);
71  void openFolderInTerminalRequested(FmPath* path);
72  void createNewFolderRequested(FmPath* path);
73  void prepareFileMenu(Fm::FileMenu* menu); // emit before showing a Fm::FileMenu
74 
75 protected Q_SLOTS:
76  void onCollapsed(const QModelIndex & index);
77  void onExpanded(const QModelIndex & index);
78  void onRowLoaded(const QModelIndex& index);
79  void onSelectionChanged(const QItemSelection & selected, const QItemSelection & deselected);
80  void onCustomContextMenuRequested(const QPoint& pos);
81  void onOpen();
82  void onNewWindow();
83  void onNewTab();
84  void onOpenInTerminal();
85  void onNewFolder();
86 
87 private:
88  FmPath* currentPath_;
89  QList<Path> pathsToExpand_;
90  DirTreeModelItem* currentExpandingItem_;
91 };
92 
93 }
94 
95 #endif // FM_DIRTREEVIEW_H
Definition: appchoosercombobox.cpp:26
Definition: filemenu.h:37
Definition: dirtreeview.h:36
Definition: dirtreemodelitem.h:35