Audacity 3.2.0
PluginDataModel.h
Go to the documentation of this file.
1/*!*********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 @file PluginDataModel.h
6
7 @author Vitaly Sverchinsky
8
9**********************************************************************/
10#pragma once
11
12#include <wx/dataview.h>
13
14#include "PluginDescriptor.h"
15
17
19class PluginDataModel final : public wxDataViewModel
20{
21 static const void* RowIdRoot;
22
23 std::vector<std::pair<PluginDescriptor*, bool>> mPluginStateModel;
24 std::vector<void*> mIndexFilterMap;
25
26 wxString mFilterType;
27 wxString mFilterExpr;
28 int mFilterState{-1};
30
31public:
32
33 enum Column
34 {
40 };
41
42 PluginDataModel(int filterEffectCategory = -1,
43 int filterState = -1,
44 const wxString& filterType = {},
45 const wxString& filterExpr = {});
46
47 wxDataViewItem GetItemForRow(uint32_t row) const;
48 bool GetRowForItem(const wxDataViewItem& item, uint32_t& row) const;
49 uint32_t GetRowCount() const;
50
51 bool IsEnabled(const wxDataViewItem&, unsigned) const override;
52 bool HasContainerColumns(const wxDataViewItem& item) const override;
53
54 void SetFilterType(const wxString& type);
55 wxString GetFilterType() const;
56 void SetFilterState(int state);
57 int GetFilterState() const;
58 void SetFilterExpr(const wxString& expr);
59 wxString GetFilterExpr() const;
60 void SetFilterCategory(int category);
61 int GetFilterCategory() const;
62
63 int Compare(const wxDataViewItem& item1, const wxDataViewItem& item2, unsigned column, bool ascending) const override;
64
65 void ApplyChanges(const std::function<bool(int, int, const wxString&)>& progressUpdateFn,
66 const std::function<void(const TranslatableString&)>& errorFn);
67
68 unsigned GetColumnCount() const override;
69 wxString GetColumnType(unsigned col) const override;
70 void GetValue(wxVariant& variant, const wxDataViewItem& item, unsigned col) const override;
71 bool SetValue(const wxVariant& variant, const wxDataViewItem& item, unsigned col) override;
72 wxDataViewItem GetParent(const wxDataViewItem& item) const override;
73 bool IsContainer(const wxDataViewItem& item) const override;
74 unsigned GetChildren(const wxDataViewItem& item, wxDataViewItemArray& children) const override;
75
76 PluginDescriptor* GetPlugin(wxDataViewItem item);
77
78 bool IsListModel() const override { return false; }
79private:
80 void UpdateFilter();
81 bool IsFilterEmpty() const;
82};
!brief A plugins list model that can be attached to wxDataViewCtrl
void SetFilterState(int state)
wxString GetColumnType(unsigned col) const override
std::vector< void * > mIndexFilterMap
int GetFilterCategory() const
wxDataViewItem GetParent(const wxDataViewItem &item) const override
wxDataViewItem GetItemForRow(uint32_t row) const
void SetFilterType(const wxString &type)
static const void * RowIdRoot
wxString mFilterExpr
bool IsEnabled(const wxDataViewItem &, unsigned) const override
wxString GetFilterExpr() const
bool IsListModel() const override
PluginDataModel(int filterEffectCategory=-1, int filterState=-1, const wxString &filterType={}, const wxString &filterExpr={})
bool GetRowForItem(const wxDataViewItem &item, uint32_t &row) const
int GetFilterState() const
PluginDescriptor * GetPlugin(wxDataViewItem item)
bool SetValue(const wxVariant &variant, const wxDataViewItem &item, unsigned col) override
wxString GetFilterType() const
bool HasContainerColumns(const wxDataViewItem &item) const override
unsigned GetChildren(const wxDataViewItem &item, wxDataViewItemArray &children) const override
void SetFilterExpr(const wxString &expr)
void ApplyChanges(const std::function< bool(int, int, const wxString &)> &progressUpdateFn, const std::function< void(const TranslatableString &)> &errorFn)
unsigned GetColumnCount() const override
uint32_t GetRowCount() const
wxString mFilterType
bool IsFilterEmpty() const
void GetValue(wxVariant &variant, const wxDataViewItem &item, unsigned col) const override
void SetFilterCategory(int category)
bool IsContainer(const wxDataViewItem &item) const override
std::vector< std::pair< PluginDescriptor *, bool > > mPluginStateModel
int Compare(const wxDataViewItem &item1, const wxDataViewItem &item2, unsigned column, bool ascending) const override
Holds a msgid for the translation catalog; may also bind format arguments.