PCManFM-Qt
 All Classes
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 DirTreeModelItem;
34 
35 class LIBFM_QT_API DirTreeView : public QTreeView {
36  Q_OBJECT
37 
38 public:
39  DirTreeView(QWidget* parent);
40  ~DirTreeView();
41 
42  FmPath* currentPath() {
43  return currentPath_;
44  }
45 
46  void setCurrentPath(FmPath* path);
47 
48  // libfm-gtk compatible alias
49  FmPath* getCwd() {
50  return currentPath();
51  }
52 
53  void chdir(FmPath* path) {
54  setCurrentPath(path);
55  }
56 
57  virtual void setModel(QAbstractItemModel* model);
58 
59 protected:
60  virtual void contextMenuEvent(QContextMenuEvent* event);
61 
62 private:
63  void cancelPendingChdir();
64  void expandPendingPath();
65 
66 Q_SIGNALS:
67  void chdirRequested(int type, FmPath* path);
68 
69 protected Q_SLOTS:
70  void onCollapsed(const QModelIndex & index);
71  void onExpanded(const QModelIndex & index);
72  void onRowLoaded(const QModelIndex& index);
73  void onSelectionChanged(const QItemSelection & selected, const QItemSelection & deselected);
74 
75 private:
76  FmPath* currentPath_;
77  QList<Path> pathsToExpand_;
78  DirTreeModelItem* currentExpandingItem_;
79 };
80 
81 }
82 
83 #endif // FM_DIRTREEVIEW_H
Definition: appchoosercombobox.cpp:26
Definition: dirtreeview.h:35
Definition: dirtreemodelitem.h:35