PCManFM-Qt
placesview.h
1 /*
2 
3  Copyright (C) 2012 Hong Jen Yee (PCMan) <pcman.tw@gmail.com>
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_PLACESVIEW_H
22 #define FM_PLACESVIEW_H
23 
24 #include "libfmqtglobals.h"
25 #include <QTreeView>
26 #include <libfm/fm.h>
27 
28 namespace Fm {
29 
30 class PlacesModel;
31 class PlacesModelItem;
32 
33 class LIBFM_QT_API PlacesView : public QTreeView {
34 Q_OBJECT
35 
36 public:
37  explicit PlacesView(QWidget* parent = 0);
38  virtual ~PlacesView();
39 
40  void setCurrentPath(FmPath* path);
41  FmPath* currentPath() {
42  return currentPath_;
43  }
44 
45  // libfm-gtk compatible alias
46  FmPath* getCwd() {
47  return currentPath();
48  }
49 
50  void chdir(FmPath* path) {
51  setCurrentPath(path);
52  }
53 
54 #if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
55  void setIconSize(const QSize &size) {
56  // The signal QAbstractItemView::iconSizeChanged is only available after Qt 5.5.
57  // To simulate the effect for older Qt versions, we override setIconSize().
58  QAbstractItemView::setIconSize(size);
59  onIconSizeChanged(size);
60  }
61 #endif
62 
63 Q_SIGNALS:
64  void chdirRequested(int type, FmPath* path);
65 
66 protected Q_SLOTS:
67  void onClicked(const QModelIndex & index);
68  void onPressed(const QModelIndex & index);
69  void onIconSizeChanged(const QSize & size);
70  // void onMountOperationFinished(GError* error);
71 
72  void onOpenNewTab();
73  void onOpenNewWindow();
74 
75  void onEmptyTrash();
76 
77  void onMountVolume();
78  void onUnmountVolume();
79  void onEjectVolume();
80  void onUnmountMount();
81 
82  void onMoveBookmarkUp();
83  void onMoveBookmarkDown();
84  void onDeleteBookmark();
85  void onRenameBookmark();
86 
87 protected:
88  void drawBranches ( QPainter * painter, const QRect & rect, const QModelIndex & index ) const {
89  // override this method to inhibit drawing of the branch grid lines by Qt.
90  }
91 
92  virtual void dragMoveEvent(QDragMoveEvent* event);
93  virtual void dropEvent(QDropEvent* event);
94  virtual void contextMenuEvent(QContextMenuEvent* event);
95 
96  virtual void commitData(QWidget * editor);
97 
98 private:
99  void onEjectButtonClicked(PlacesModelItem* item);
100  void activateRow(int type, const QModelIndex& index);
101 
102 private:
103  PlacesModel* model_;
104  FmPath* currentPath_;
105 };
106 
107 }
108 
109 #endif // FM_PLACESVIEW_H
Definition: placesmodel.h:38
Definition: appchoosercombobox.cpp:26
Definition: placesmodelitem.h:34
Definition: placesview.h:33