PCManFM-Qt
sidepane.h
1 /*
2 
3  Copyright (C) 2013 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_SIDEPANE_H
22 #define FM_SIDEPANE_H
23 
24 #include "libfmqtglobals.h"
25 #include <libfm/fm.h>
26 #include <QWidget>
27 
28 class QComboBox;
29 class QVBoxLayout;
30 class QWidget;
31 
32 namespace Fm {
33 
34 class FileMenu;
35 
36 class LIBFM_QT_API SidePane : public QWidget {
37  Q_OBJECT
38 
39 public:
40  enum Mode {
41  ModeNone = -1,
42  ModePlaces = 0,
43  ModeDirTree,
44  NumModes
45  };
46 
47 public:
48  explicit SidePane(QWidget* parent = 0);
49  virtual ~SidePane();
50 
51  QSize iconSize() {
52  return iconSize_;
53  }
54 
55  void setIconSize(QSize size);
56 
57  FmPath* currentPath() {
58  return currentPath_;
59  }
60 
61  void setCurrentPath(FmPath* path);
62 
63  void setMode(Mode mode);
64 
65  Mode mode() {
66  return mode_;
67  }
68 
69  QWidget* view() {
70  return view_;
71  }
72 
73  const char *modeName(Mode mode);
74 
75  Mode modeByName(const char *str);
76 
77 #if 0 // FIXME: are these APIs from libfm-qt needed?
78  int modeCount(void) {
79  return NumModes;
80  }
81 
82  QString modeLabel(Mode mode);
83 
84  QString modeTooltip(Mode mode);
85 #endif
86 
87  void setShowHidden(bool show_hidden);
88 
89  bool showHidden() {
90  return showHidden_;
91  }
92 
93  bool setHomeDir(const char *home_dir);
94 
95  // libfm-gtk compatible alias
96  FmPath* getCwd() {
97  return currentPath();
98  }
99 
100  void chdir(FmPath* path) {
101  setCurrentPath(path);
102  }
103 
104 Q_SIGNALS:
105  void chdirRequested(int type, FmPath* path);
106  void openFolderInNewWindowRequested(FmPath* path);
107  void openFolderInNewTabRequested(FmPath* path);
108  void openFolderInTerminalRequested(FmPath* path);
109  void createNewFolderRequested(FmPath* path);
110  void modeChanged(Fm::SidePane::Mode mode);
111 
112  void prepareFileMenu(Fm::FileMenu* menu); // emit before showing a Fm::FileMenu
113 
114 protected Q_SLOTS:
115  void onPlacesViewChdirRequested(int type, FmPath* path);
116  void onDirTreeViewChdirRequested(int type, FmPath* path);
117  void onComboCurrentIndexChanged(int current);
118 
119 private:
120  void initDirTree();
121 
122 private:
123  FmPath* currentPath_;
124  QWidget* view_;
125  QComboBox* combo_;
126  QVBoxLayout* verticalLayout;
127  QSize iconSize_;
128  Mode mode_;
129  bool showHidden_;
130 };
131 
132 }
133 
134 #endif // FM_SIDEPANE_H
Definition: appchoosercombobox.cpp:26
Definition: filemenu.h:37
Definition: sidepane.h:36