~lubuntu-dev/lxde/libfm-qt-debian-git

« back to all changes in this revision

Viewing changes to src/placesmodelitem.h

  • Committer: Alf Gaida
  • Date: 2015-12-17 15:45:00 UTC
  • Revision ID: git-v1:99d4cf5e0b3761023e2285ffb96a79d050f0bdf4
Tags: upstream/0.10.0+20151214
Adding upstream version 0.10.0+20151214.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2013 - 2015  Hong Jen Yee (PCMan) <pcman.tw@gmail.com>
 
3
 *
 
4
 * This library is free software; you can redistribute it and/or
 
5
 * modify it under the terms of the GNU Lesser General Public
 
6
 * License as published by the Free Software Foundation; either
 
7
 * version 2.1 of the License, or (at your option) any later version.
 
8
 *
 
9
 * This library is distributed in the hope that it will be useful,
 
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
12
 * Lesser General Public License for more details.
 
13
 *
 
14
 * You should have received a copy of the GNU Lesser General Public
 
15
 * License along with this library; if not, write to the Free Software
 
16
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 
17
 *
 
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:
 
44
  PlacesModelItem();
 
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