| 1 | /* |
|---|---|
| 2 | SPDX-FileCopyrightText: KDE Developers |
| 3 | |
| 4 | SPDX-License-Identifier: LGPL-2.0-or-later |
| 5 | */ |
| 6 | |
| 7 | #include "history.h" |
| 8 | |
| 9 | using namespace KateVi; |
| 10 | |
| 11 | namespace |
| 12 | { |
| 13 | const int HISTORY_SIZE_LIMIT = 100; |
| 14 | } |
| 15 | |
| 16 | void History::append(const QString &historyItem) |
| 17 | { |
| 18 | if (historyItem.isEmpty()) { |
| 19 | return; |
| 20 | } |
| 21 | |
| 22 | m_items.removeAll(t: historyItem); |
| 23 | |
| 24 | if (m_items.size() == HISTORY_SIZE_LIMIT) { |
| 25 | m_items.removeFirst(); |
| 26 | } |
| 27 | |
| 28 | m_items.append(t: historyItem); |
| 29 | } |
| 30 | |
| 31 | void History::clear() |
| 32 | { |
| 33 | m_items.clear(); |
| 34 | } |
| 35 |
