Add context menu to delete all tags in Reference Browser
[TortoiseGit.git] / src / Utils / RegHistory.h
blob6b6d94ac017011265c7b0b356df515dc29147092
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2007 - TortoiseSVN
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
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.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #pragma once
22 /**
23 * \ingroup TortoiseProc
24 * Maintains a list of X string items in the registry and provides methods
25 * to add new items. The list can be used as a 'recently used' or 'recent items' list.
27 class CRegHistory
29 public:
30 CRegHistory();
31 virtual ~CRegHistory();
33 /// Loads the history
34 /// \param lpszSection the section in the registry, e.g., "Software\\CompanyName\\History"
35 /// \param lpszKeyPrefix the name of the registry values, e.g., "historyItem"
36 /// \return the number of history items loaded
37 size_t Load(LPCTSTR lpszSection, LPCTSTR lpszKeyPrefix);
38 /// Saves the history.
39 bool Save() const;
40 /// Adds a new string to the history list.
41 bool AddEntry(LPCTSTR szText);
42 /// Removes the entry at index \c pos.
43 void RemoveEntry(int pos);
44 /// Sets the maximum number of items in the history. Default is 25.
45 void SetMaxHistoryItems(int nMax) {m_nMaxHistoryItems = nMax;}
46 /// Returns the number of items in the history.
47 size_t GetCount() const {return m_arEntries.size(); }
48 /// Returns the entry at index \c pos
49 LPCTSTR GetEntry(size_t pos) {return m_arEntries[pos].c_str();}
51 private:
52 std::wstring m_sSection;
53 std::wstring m_sKeyPrefix;
54 std::vector<std::wstring> m_arEntries;
55 int m_nMaxHistoryItems;