diff options
author | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:15:16 +0200 |
---|---|---|
committer | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:15:16 +0200 |
commit | bd6336c629841c6db3a6ca53a936d629d34db53b (patch) | |
tree | 3721ef997864108df175ce677a8a7d4342a6f1d2 /shared/folder_history_box.h | |
parent | 4.0 (diff) | |
download | FreeFileSync-bd6336c629841c6db3a6ca53a936d629d34db53b.tar.gz FreeFileSync-bd6336c629841c6db3a6ca53a936d629d34db53b.tar.bz2 FreeFileSync-bd6336c629841c6db3a6ca53a936d629d34db53b.zip |
4.1
Diffstat (limited to 'shared/folder_history_box.h')
-rw-r--r-- | shared/folder_history_box.h | 109 |
1 files changed, 0 insertions, 109 deletions
diff --git a/shared/folder_history_box.h b/shared/folder_history_box.h deleted file mode 100644 index 3b4fd57e..00000000 --- a/shared/folder_history_box.h +++ /dev/null @@ -1,109 +0,0 @@ -// ************************************************************************** -// * This file is part of the FreeFileSync project. It is distributed under * -// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * -// * Copyright (C) 2008-2011 ZenJu (zhnmju123 AT gmx.de) * -// ************************************************************************** - -#ifndef CUSTOMCOMBOBOX_H_INCLUDED -#define CUSTOMCOMBOBOX_H_INCLUDED - -#include <wx/combobox.h> -#include <memory> -#include "zstring.h" -#include "string_conv.h" -#include "stl_tools.h" - -//combobox with history function + functionality to delete items (DEL) -using namespace zen; - - -class FolderHistory -{ -public: - FolderHistory() : maxSize_(0) {} - - FolderHistory(const std::vector<Zstring>& dirnames, size_t maxSize) : - maxSize_(maxSize), - dirnames_(dirnames) - { - if (dirnames_.size() > maxSize_) //keep maximal size of history list - dirnames_.resize(maxSize_); - } - - const std::vector<Zstring>& getList() const { return dirnames_; } - - static const Zstring lineSeparator() { return Zstr("---------------------------------------------------------------------------------------------------------------"); } - - void addItem(const Zstring& dirname) - { - if (dirname.empty() || dirname == lineSeparator()) - return; - - Zstring nameTmp = dirname; - zen::trim(nameTmp); - - //insert new folder or put it to the front if already existing - auto iter = std::find_if(dirnames_.begin(), dirnames_.end(), - [&](const Zstring& entry) { return ::EqualFilename()(entry, nameTmp); }); - - if (iter != dirnames_.end()) - dirnames_.erase(iter); - dirnames_.insert(dirnames_.begin(), nameTmp); - - if (dirnames_.size() > maxSize_) //keep maximal size of history list - dirnames_.resize(maxSize_); - } - - void delItem(const Zstring& dirname) { vector_remove_if(dirnames_, [&](const Zstring& entry) { return ::EqualFilename()(entry, dirname); }); } - -private: - - size_t maxSize_; - std::vector<Zstring> dirnames_; -}; - - -class FolderHistoryBox : public wxComboBox -{ -public: - FolderHistoryBox(wxWindow* parent, - wxWindowID id, - const wxString& value = wxEmptyString, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - int n = 0, - const wxString choices[] = NULL, - long style = 0, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxComboBoxNameStr); - - void init(const std::shared_ptr<FolderHistory>& sharedHistory) { sharedHistory_ = sharedHistory; } - - void setValue(const wxString& dirname) - { - SetSelection(wxNOT_FOUND); - SetValue(dirname); - update(); //required for Linux to ensure the dropdown is shown as being populated - } - - // GetValue - -private: - void OnKeyEvent(wxKeyEvent& event); - void OnSelection(wxCommandEvent& event); - void OnUpdateList(wxEvent& event) { update(); event.Skip(); } - - void update(); - -#if wxCHECK_VERSION(2, 9, 1) - void OnShowDropDown(wxCommandEvent& event); - void OnHideDropDown(wxCommandEvent& event); - - bool dropDownShown; -#endif - - std::shared_ptr<FolderHistory> sharedHistory_; -}; - - -#endif // CUSTOMCOMBOBOX_H_INCLUDED |