PCManFM-Qt
Main Page
Classes
Files
File List
libfm-qt
browsehistory.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_BROWSEHISTORY_H
22
#define FM_BROWSEHISTORY_H
23
24
#include "libfmqtglobals.h"
25
#include <QVector>
26
#include <libfm/fm.h>
27
28
namespace
Fm
{
29
30
// class used to story browsing history of folder views
31
// We use this class to replace FmNavHistory provided by libfm since
32
// the original Libfm API is hard to use and confusing.
33
34
class
LIBFM_QT_API
BrowseHistoryItem
{
35
public
:
36
37
BrowseHistoryItem
():
38
path_(NULL),
39
scrollPos_(0) {
40
}
41
42
BrowseHistoryItem
(FmPath* path,
int
scrollPos = 0):
43
path_(fm_path_ref(path)),
44
scrollPos_(scrollPos) {
45
}
46
47
BrowseHistoryItem
(
const
BrowseHistoryItem
& other):
48
path_(other.path_ ? fm_path_ref(other.path_) : NULL),
49
scrollPos_(other.scrollPos_) {
50
}
51
52
~
BrowseHistoryItem
() {
53
if
(path_)
54
fm_path_unref(path_);
55
}
56
57
BrowseHistoryItem
& operator=(
const
BrowseHistoryItem
& other) {
58
if
(path_)
59
fm_path_unref(path_);
60
path_ = other.path_ ? fm_path_ref(other.path_) : NULL;
61
scrollPos_ = other.scrollPos_;
62
return
*
this
;
63
}
64
65
FmPath* path()
const
{
66
return
path_;
67
}
68
69
int
scrollPos()
const
{
70
return
scrollPos_;
71
}
72
73
void
setScrollPos(
int
pos) {
74
scrollPos_ = pos;
75
}
76
77
private
:
78
FmPath* path_;
79
int
scrollPos_;
80
// TODO: we may need to store current selection as well. reserve room for furutre expansion.
81
// void* reserved1;
82
// void* reserved2;
83
};
84
85
class
LIBFM_QT_API
BrowseHistory
:
public
QVector<BrowseHistoryItem> {
86
87
public
:
88
BrowseHistory
();
89
virtual
~
BrowseHistory
();
90
91
int
currentIndex()
const
{
92
return
currentIndex_;
93
}
94
void
setCurrentIndex(
int
index);
95
96
FmPath* currentPath()
const
{
97
return
at(currentIndex_).path();
98
}
99
100
int
currentScrollPos()
const
{
101
return
at(currentIndex_).scrollPos();
102
}
103
104
BrowseHistoryItem
& currentItem() {
105
return
operator[](currentIndex_);
106
}
107
108
void
add(FmPath* path,
int
scrollPos = 0);
109
110
bool
canForward()
const
;
111
112
bool
canBackward()
const
;
113
114
int
backward();
115
116
int
forward();
117
118
int
maxCount()
const
{
119
return
maxCount_;
120
}
121
122
void
setMaxCount(
int
maxCount);
123
124
private
:
125
int
currentIndex_;
126
int
maxCount_;
127
};
128
129
}
130
131
#endif // FM_BROWSEHISTORY_H
Fm
Definition:
appchoosercombobox.cpp:26
Fm::BrowseHistory
Definition:
browsehistory.h:85
Fm::BrowseHistoryItem
Definition:
browsehistory.h:34
Generated on Tue Jul 26 2016 09:47:20 for PCManFM-Qt by
1.8.11