-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathhistorylist.h
100 lines (84 loc) · 2.41 KB
/
historylist.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
// (c) 2015 David Vyvlečka, AGPLv3
#ifndef HISTORYLIST_H
#define HISTORYLIST_H
#include <QList>
#include "data.h"
#include "meshobject.h"
using namespace std;
class historyList
{
public:
/*!
* \brief Default constructor.
*
* Pushes one emtpy item at index 0 - better further manipulation.
*/
historyList();
/*!
* \brief Destructor
*
* Cleans whole history.
*/
~historyList();
/*!
* \brief Set limit size of buffer.
*
* \param limit Limit size of buffer in bytes.
*/
void setLimitSize(int limit);
/*!
* \brief Add item into history
* \param item Objects in current state to add to history.
*/
void add(QList <MeshObject*> item, unsigned long size);
/*!
* \brief Delete history item given by index
* \param index Index of item to delete.
*/
void deleteRow(QList <QList <MeshObject*> >::size_type index);
/*!
* \brief Returns item under current_index
* \return Current item.
*/
QList <MeshObject*> current();
/*!
* \brief Returns item one position back in history.
* \return Previous item.
*/
QList <MeshObject*> undo();
/*!
* \brief Returns item one position further in history.
* \return Next item.
*/
QList <MeshObject*> redo();
/*!
* \brief Delete oldest entries in history.
*
* Counted references of MeshObjects taken into account.
*/
void cutOldest();
/*!
* \brief Delete "youngest" entries in history (which were undoed).
*
* Called during adding phase if current_index is not last. Newly added item replaces all items which were undoed.
* Counted references of MeshObjects taken into account.
*/
void cutRedos();
/*!
* \brief Returns whether it is possible to perform Undo.
* \return true if list has item to be undone.
*/
bool hasUndos();
/*!
* \brief Returns whether it is possible to perform Redo.
* \return true if list has item to be redone.
*/
bool hasRedos();
private:
QList <QList <MeshObject*> > history; ///< Editation history list
QList <QList <MeshObject*> >::size_type current_index; ///< Current index position
QList <QList <MeshObject*> >::size_type max_index; ///< Maximum index position
unsigned long long historySize;
unsigned long long sizeLimit;
};
#endif // HISTORYLIST_H