PCManFM-Qt
placesmodelitem.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_PLACESMODELITEM_H
22 #define FM_PLACESMODELITEM_H
23 
24 #include "libfmqtglobals.h"
25 #include <QStandardItemModel>
26 #include <QStandardItem>
27 #include <QList>
28 #include <QAction>
29 #include <libfm/fm.h>
30 
31 namespace Fm {
32 
33 // model item
34 class LIBFM_QT_API PlacesModelItem : public QStandardItem {
35 public:
36  enum Type {
37  Places = QStandardItem::UserType + 1,
38  Volume,
39  Mount,
40  Bookmark
41  };
42 
43 public:
45  PlacesModelItem(QIcon icon, QString title, FmPath* path = NULL);
46  PlacesModelItem(const char* iconName, QString title, FmPath* path = NULL);
47  PlacesModelItem(FmIcon* icon, QString title, FmPath* path = NULL);
48  ~PlacesModelItem();
49 
50  FmFileInfo* fileInfo() {
51  return fileInfo_;
52  }
53  void setFileInfo(FmFileInfo* fileInfo);
54 
55  FmPath* path() {
56  return path_;
57  }
58  void setPath(FmPath* path);
59 
60  FmIcon* icon() {
61  return icon_;
62  }
63  void setIcon(FmIcon* icon);
64  void setIcon(GIcon* gicon);
65  void updateIcon();
66 
67  QVariant data(int role = Qt::UserRole + 1) const;
68 
69  virtual int type() const {
70  return Places;
71  }
72 
73 private:
74  FmPath* path_;
75  FmFileInfo* fileInfo_;
76  FmIcon* icon_;
77 };
78 
79 class LIBFM_QT_API PlacesModelVolumeItem : public PlacesModelItem {
80 public:
81  PlacesModelVolumeItem(GVolume* volume);
82  bool isMounted();
83  bool canEject() {
84  return g_volume_can_eject(volume_);
85  }
86  virtual int type() const {
87  return Volume;
88  }
89  GVolume* volume() {
90  return volume_;
91  }
92  void update();
93 private:
94  GVolume* volume_;
95 };
96 
97 class LIBFM_QT_API PlacesModelMountItem : public PlacesModelItem {
98 public:
99  PlacesModelMountItem(GMount* mount);
100  virtual int type() const {
101  return Mount;
102  }
103  GMount* mount() const {
104  return mount_;
105  }
106  void update();
107 private:
108  GMount* mount_;
109 };
110 
111 class LIBFM_QT_API PlacesModelBookmarkItem : public PlacesModelItem {
112 public:
113  virtual int type() const {
114  return Bookmark;
115  }
116  PlacesModelBookmarkItem(FmBookmarkItem* bm_item);
117  virtual ~PlacesModelBookmarkItem() {
118  if(bookmarkItem_)
119  fm_bookmark_item_unref(bookmarkItem_);
120  }
121  FmBookmarkItem* bookmark() const {
122  return bookmarkItem_;
123  }
124 private:
125  FmBookmarkItem* bookmarkItem_;
126 };
127 
128 }
129 
130 #endif // FM_PLACESMODELITEM_H
Definition: appchoosercombobox.cpp:26
Definition: placesmodelitem.h:111
Definition: placesmodelitem.h:34
Definition: placesmodelitem.h:79
Definition: placesmodelitem.h:97