OSDN Git Service

Ver0.19
[gefu/Gefu.git] / history.cpp
1 #include "history.h"
2
3 History::History() :
4     m_list(),
5     m_pos(0)
6 {
7 }
8
9 void History::add(const QString &path)
10 {
11     // 現在位置より後ろのデータは削除する
12     if (!isEmpty() && !isEnd()) {
13         m_list.resize(m_pos + 1);
14     }
15     // 現在位置と異なるパスであれば追加する
16     if (isEmpty() || (m_list[m_pos] != path)) {
17         m_list << path;
18     }
19     m_pos = m_list.size() - 1;
20 }
21
22 const QString &History::back()
23 {
24     if (!isBegin()) {
25         m_pos--;
26     }
27     return m_list[m_pos];
28 }
29
30 const QString &History::forward()
31 {
32     if (!isEnd()) {
33         m_pos++;
34     }
35     return m_list[m_pos];
36 }