Use wxVector instead of wxList for wxDataViewCtrl columns storage
As wxDataViewColumnList was never public, it should be fine to not define it any more and use a vector instead. This makes the code more clear and also marginally more efficient.
This commit is contained in:
@@ -12,7 +12,6 @@
|
||||
|
||||
#include "wx/defs.h"
|
||||
#include "wx/object.h"
|
||||
#include "wx/list.h"
|
||||
#include "wx/control.h"
|
||||
#include "wx/scrolwin.h"
|
||||
#include "wx/icon.h"
|
||||
@@ -179,9 +178,6 @@ private:
|
||||
// wxDataViewCtrl
|
||||
// ---------------------------------------------------------
|
||||
|
||||
WX_DECLARE_LIST_WITH_DECL(wxDataViewColumn, wxDataViewColumnList,
|
||||
class WXDLLIMPEXP_CORE);
|
||||
|
||||
class WXDLLIMPEXP_CORE wxDataViewCtrl : public wxDataViewCtrlBase,
|
||||
public wxScrollHelper
|
||||
{
|
||||
@@ -366,7 +362,9 @@ private:
|
||||
void InvalidateColBestWidth(int idx);
|
||||
void UpdateColWidths();
|
||||
|
||||
wxDataViewColumnList m_cols;
|
||||
void DoClearColumns();
|
||||
|
||||
wxVector<wxDataViewColumn*> m_cols;
|
||||
// cached column best widths information, values are for
|
||||
// respective columns from m_cols and the arrays have same size
|
||||
struct CachedColWidthInfo
|
||||
|
@@ -5054,8 +5054,6 @@ void wxDataViewMainWindow::UpdateColumnSizes()
|
||||
// wxDataViewCtrl
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
WX_DEFINE_LIST(wxDataViewColumnList)
|
||||
|
||||
wxIMPLEMENT_DYNAMIC_CLASS(wxDataViewCtrl, wxDataViewCtrlBase);
|
||||
wxBEGIN_EVENT_TABLE(wxDataViewCtrl, wxDataViewCtrlBase)
|
||||
EVT_SIZE(wxDataViewCtrl::OnSize)
|
||||
@@ -5066,8 +5064,7 @@ wxDataViewCtrl::~wxDataViewCtrl()
|
||||
if (m_notifier)
|
||||
GetModel()->RemoveNotifier( m_notifier );
|
||||
|
||||
m_cols.Clear();
|
||||
m_colsBestWidths.clear();
|
||||
DoClearColumns();
|
||||
|
||||
#if wxUSE_ACCESSIBILITY
|
||||
SetAccessible(NULL);
|
||||
@@ -5077,7 +5074,6 @@ wxDataViewCtrl::~wxDataViewCtrl()
|
||||
|
||||
void wxDataViewCtrl::Init()
|
||||
{
|
||||
m_cols.DeleteContents(true);
|
||||
m_notifier = NULL;
|
||||
|
||||
m_headerArea = NULL;
|
||||
@@ -5329,7 +5325,7 @@ bool wxDataViewCtrl::AppendColumn( wxDataViewColumn *col )
|
||||
if (!wxDataViewCtrlBase::AppendColumn(col))
|
||||
return false;
|
||||
|
||||
m_cols.Append( col );
|
||||
m_cols.push_back( col );
|
||||
m_colsBestWidths.push_back(CachedColWidthInfo());
|
||||
OnColumnsCountChanged();
|
||||
return true;
|
||||
@@ -5340,7 +5336,7 @@ bool wxDataViewCtrl::PrependColumn( wxDataViewColumn *col )
|
||||
if (!wxDataViewCtrlBase::PrependColumn(col))
|
||||
return false;
|
||||
|
||||
m_cols.Insert( col );
|
||||
m_cols.insert(m_cols.begin(), col);
|
||||
m_colsBestWidths.insert(m_colsBestWidths.begin(), CachedColWidthInfo());
|
||||
OnColumnsCountChanged();
|
||||
return true;
|
||||
@@ -5351,7 +5347,7 @@ bool wxDataViewCtrl::InsertColumn( unsigned int pos, wxDataViewColumn *col )
|
||||
if (!wxDataViewCtrlBase::InsertColumn(pos,col))
|
||||
return false;
|
||||
|
||||
m_cols.Insert( pos, col );
|
||||
m_cols.insert(m_cols.begin() + pos, col);
|
||||
m_colsBestWidths.insert(m_colsBestWidths.begin() + pos, CachedColWidthInfo());
|
||||
OnColumnsCountChanged();
|
||||
return true;
|
||||
@@ -5400,7 +5396,7 @@ void wxDataViewCtrl::DoSetIndent()
|
||||
|
||||
unsigned int wxDataViewCtrl::GetColumnCount() const
|
||||
{
|
||||
return m_cols.GetCount();
|
||||
return m_cols.size();
|
||||
}
|
||||
|
||||
bool wxDataViewCtrl::SetRowHeight( int lineHeight )
|
||||
@@ -5552,12 +5548,12 @@ void wxDataViewCtrl::ColumnMoved(wxDataViewColumn *col, unsigned int new_pos)
|
||||
|
||||
bool wxDataViewCtrl::DeleteColumn( wxDataViewColumn *column )
|
||||
{
|
||||
wxDataViewColumnList::compatibility_iterator ret = m_cols.Find( column );
|
||||
if (!ret)
|
||||
const int idx = GetColumnIndex(column);
|
||||
if ( idx == wxNOT_FOUND )
|
||||
return false;
|
||||
|
||||
m_colsBestWidths.erase(m_colsBestWidths.begin() + GetColumnIndex(column));
|
||||
m_cols.Erase(ret);
|
||||
m_colsBestWidths.erase(m_colsBestWidths.begin() + idx);
|
||||
m_cols.erase(m_cols.begin() + idx);
|
||||
|
||||
if ( m_clientArea->GetCurrentColumn() == column )
|
||||
m_clientArea->ClearCurrentColumn();
|
||||
@@ -5567,10 +5563,20 @@ bool wxDataViewCtrl::DeleteColumn( wxDataViewColumn *column )
|
||||
return true;
|
||||
}
|
||||
|
||||
void wxDataViewCtrl::DoClearColumns()
|
||||
{
|
||||
typedef wxVector<wxDataViewColumn*>::const_iterator citer;
|
||||
for ( citer it = m_cols.begin(); it != m_cols.end(); ++it )
|
||||
delete *it;
|
||||
}
|
||||
|
||||
bool wxDataViewCtrl::ClearColumns()
|
||||
{
|
||||
SetExpanderColumn(NULL);
|
||||
m_cols.Clear();
|
||||
|
||||
DoClearColumns();
|
||||
|
||||
m_cols.clear();
|
||||
m_sortingColumnIdxs.clear();
|
||||
m_colsBestWidths.clear();
|
||||
|
||||
|
Reference in New Issue
Block a user