Replace macros with wxVector<> for wxDataViewModelNotifiers
Don't use deprecated macro-based linked list class, use wxVector<> instead for m_notifiers. Also make it private, as it should have been from the beginning.
This commit is contained in:
@@ -27,6 +27,7 @@
|
|||||||
#include "wx/dataobj.h"
|
#include "wx/dataobj.h"
|
||||||
#include "wx/withimages.h"
|
#include "wx/withimages.h"
|
||||||
#include "wx/systhemectrl.h"
|
#include "wx/systhemectrl.h"
|
||||||
|
#include "wx/vector.h"
|
||||||
|
|
||||||
class WXDLLIMPEXP_FWD_CORE wxImageList;
|
class WXDLLIMPEXP_FWD_CORE wxImageList;
|
||||||
class wxItemAttr;
|
class wxItemAttr;
|
||||||
@@ -179,8 +180,7 @@ private:
|
|||||||
// wxDataViewModel
|
// wxDataViewModel
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
|
|
||||||
WX_DECLARE_LIST_WITH_DECL(wxDataViewModelNotifier, wxDataViewModelNotifiers,
|
typedef wxVector<wxDataViewModelNotifier*> wxDataViewModelNotifiers;
|
||||||
class WXDLLIMPEXP_ADV);
|
|
||||||
|
|
||||||
class WXDLLIMPEXP_ADV wxDataViewModel: public wxRefCounter
|
class WXDLLIMPEXP_ADV wxDataViewModel: public wxRefCounter
|
||||||
{
|
{
|
||||||
@@ -273,8 +273,9 @@ public:
|
|||||||
virtual bool IsVirtualListModel() const { return false; }
|
virtual bool IsVirtualListModel() const { return false; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// the user should not delete this class directly: he should use DecRef() instead!
|
// Dtor is protected because the objects of this class must not be deleted,
|
||||||
virtual ~wxDataViewModel() { }
|
// DecRef() must be used instead.
|
||||||
|
virtual ~wxDataViewModel();
|
||||||
|
|
||||||
// Helper function used by the default Compare() implementation to compare
|
// Helper function used by the default Compare() implementation to compare
|
||||||
// values of types it is not aware about. Can be overridden in the derived
|
// values of types it is not aware about. Can be overridden in the derived
|
||||||
@@ -285,7 +286,7 @@ protected:
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
wxDataViewModelNotifiers m_notifiers;
|
wxDataViewModelNotifiers m_notifiers;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -95,9 +95,6 @@ wxFont wxDataViewItemAttr::GetEffectiveFont(const wxFont& font) const
|
|||||||
// wxDataViewModelNotifier
|
// wxDataViewModelNotifier
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
|
|
||||||
#include "wx/listimpl.cpp"
|
|
||||||
WX_DEFINE_LIST(wxDataViewModelNotifiers)
|
|
||||||
|
|
||||||
bool wxDataViewModelNotifier::ItemsAdded( const wxDataViewItem &parent, const wxDataViewItemArray &items )
|
bool wxDataViewModelNotifier::ItemsAdded( const wxDataViewItem &parent, const wxDataViewItemArray &items )
|
||||||
{
|
{
|
||||||
size_t count = items.GetCount();
|
size_t count = items.GetCount();
|
||||||
@@ -134,7 +131,15 @@ bool wxDataViewModelNotifier::ItemsChanged( const wxDataViewItemArray &items )
|
|||||||
|
|
||||||
wxDataViewModel::wxDataViewModel()
|
wxDataViewModel::wxDataViewModel()
|
||||||
{
|
{
|
||||||
m_notifiers.DeleteContents( true );
|
}
|
||||||
|
|
||||||
|
wxDataViewModel::~wxDataViewModel()
|
||||||
|
{
|
||||||
|
wxDataViewModelNotifiers::const_iterator iter;
|
||||||
|
for (iter = m_notifiers.begin(); iter != m_notifiers.end(); ++iter)
|
||||||
|
{
|
||||||
|
delete *iter;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxDataViewModel::ItemAdded( const wxDataViewItem &parent, const wxDataViewItem &item )
|
bool wxDataViewModel::ItemAdded( const wxDataViewItem &parent, const wxDataViewItem &item )
|
||||||
@@ -305,7 +310,20 @@ void wxDataViewModel::AddNotifier( wxDataViewModelNotifier *notifier )
|
|||||||
|
|
||||||
void wxDataViewModel::RemoveNotifier( wxDataViewModelNotifier *notifier )
|
void wxDataViewModel::RemoveNotifier( wxDataViewModelNotifier *notifier )
|
||||||
{
|
{
|
||||||
m_notifiers.DeleteObject( notifier );
|
wxDataViewModelNotifiers::iterator iter;
|
||||||
|
for (iter = m_notifiers.begin(); iter != m_notifiers.end(); ++iter)
|
||||||
|
{
|
||||||
|
if ( *iter == notifier )
|
||||||
|
{
|
||||||
|
delete notifier;
|
||||||
|
m_notifiers.erase(iter);
|
||||||
|
|
||||||
|
// Skip the assert below.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
wxFAIL_MSG(wxS("Removing non-registered notifier"));
|
||||||
}
|
}
|
||||||
|
|
||||||
int wxDataViewModel::Compare( const wxDataViewItem &item1, const wxDataViewItem &item2,
|
int wxDataViewModel::Compare( const wxDataViewItem &item1, const wxDataViewItem &item2,
|
||||||
|
Reference in New Issue
Block a user