2011-10-28 22:40:43 +02:00
|
|
|
// Copyright (c) 2011, Thomas Goyne <plorkyeran@aegisub.org>
|
|
|
|
//
|
|
|
|
// Permission to use, copy, modify, and distribute this software for any
|
|
|
|
// purpose with or without fee is hereby granted, provided that the above
|
|
|
|
// copyright notice and this permission notice appear in all copies.
|
|
|
|
//
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
|
|
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
|
|
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
//
|
|
|
|
// Aegisub Project http://www.aegisub.org/
|
|
|
|
|
2013-06-10 15:58:13 +02:00
|
|
|
#include <memory>
|
2011-10-28 22:40:43 +02:00
|
|
|
#include <wx/dataview.h>
|
|
|
|
|
|
|
|
class HotkeyModelItem;
|
|
|
|
class HotkeyModelRoot;
|
|
|
|
class Preferences;
|
|
|
|
|
|
|
|
/// @class HotkeyDataViewModel
|
|
|
|
/// @brief A wxDataViewModel for hotkeys
|
2014-03-13 02:39:07 +01:00
|
|
|
class HotkeyDataViewModel final : public wxDataViewModel {
|
2013-06-10 15:58:13 +02:00
|
|
|
std::unique_ptr<HotkeyModelRoot> root;
|
2011-10-28 22:40:43 +02:00
|
|
|
Preferences *parent;
|
2013-12-12 01:29:48 +01:00
|
|
|
bool has_pending_changes = false;
|
2011-10-28 22:40:43 +02:00
|
|
|
|
2012-11-13 17:51:01 +01:00
|
|
|
/// Get the real item from the wrapper, or root if it's wrapping nullptr
|
2011-10-28 22:40:43 +02:00
|
|
|
const HotkeyModelItem *get(wxDataViewItem const& item) const;
|
2012-11-13 17:51:01 +01:00
|
|
|
/// Get the real item from the wrapper, or root if it's wrapping nullptr
|
2011-10-28 22:40:43 +02:00
|
|
|
HotkeyModelItem *get(wxDataViewItem const& item);
|
|
|
|
public:
|
|
|
|
HotkeyDataViewModel(Preferences *parent);
|
|
|
|
|
|
|
|
/// Create a new hotkey in the current context
|
2012-02-01 19:47:00 +01:00
|
|
|
/// @param item A context or hotkey entry
|
|
|
|
/// @return The new hotkey
|
|
|
|
wxDataViewItem New(wxDataViewItem item);
|
2011-10-28 22:40:43 +02:00
|
|
|
/// Delete the currently selected hotkey
|
|
|
|
void Delete(wxDataViewItem const& item);
|
|
|
|
/// Update the hotkeys with changes made to the model
|
|
|
|
void Apply();
|
|
|
|
|
|
|
|
/// Only display hotkeys containing filter, or all if filter is empty
|
|
|
|
void SetFilter(wxString const& filter);
|
|
|
|
|
2013-11-21 18:13:36 +01:00
|
|
|
unsigned int GetColumnCount() const override { return 3; }
|
|
|
|
wxString GetColumnType(unsigned int) const override { return "string"; }
|
|
|
|
|
|
|
|
unsigned int GetChildren(wxDataViewItem const& item, wxDataViewItemArray &children) const override;
|
|
|
|
wxDataViewItem GetParent(wxDataViewItem const& item) const override;
|
|
|
|
void GetValue(wxVariant &variant, wxDataViewItem const& item, unsigned int col) const override;
|
|
|
|
bool IsContainer(wxDataViewItem const& item) const override;
|
|
|
|
bool SetValue(wxVariant const& variant, wxDataViewItem const& item, unsigned int col) override;
|
2011-10-28 22:40:43 +02:00
|
|
|
};
|