-
Notifications
You must be signed in to change notification settings - Fork 6
/
history.h
74 lines (59 loc) · 1.24 KB
/
history.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/**
* \file
* <!--
* Copyright 2015 Develer S.r.l. (http://www.develer.com/)
* -->
*
* \brief History class header
*
* \author Aurelien Rainone <aurelien@develer.com>
*/
#ifndef HISTORY_H
#define HISTORY_H
#include <QObject>
#include <QStringList>
/**
* \brief readline-like history
*
* manage a fixed-size list of unique strings
*/
class History : public QObject
{
Q_OBJECT
private:
/// full history
QStringList history;
/// maximum size
const int max_entries;
/// current element in history
int _current;
public:
explicit History(QObject *parent = 0);
public:
/**
* \brief append a new element to history
*/
void add(const QString &entry);
/**
* \brief get previous element (regarding current one)
*/
const QString previous();
/**
* \brief get next element (regarding current one)
*/
const QString next();
/**
* \brief get all history elements
*/
const QStringList& getHistory() const;
/**
* \brief get current history entry index
*/
int current() const;
/**
* \brief manually update current history entry
* \param index new index
*/
void setCurrent(int current_index);
};
#endif // HISTORY_H