Make wxDataViewModel::GetAttr() and GetAttrByRow() const.

This is an incompatible change but having to use a non-const model pointer to
call a clearly logically const version was simply too ugly so change it while
we still can.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62500 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2009-10-24 21:42:04 +00:00
parent 2feacb6eb3
commit 7fadac8872
5 changed files with 39 additions and 8 deletions

View File

@@ -390,6 +390,10 @@ INCOMPATIBLE CHANGE SINCE 2.9.0
2.9.0. Please use UseAppInfo(AppInfo_AppName | AppInfo_VendorName) explicitly 2.9.0. Please use UseAppInfo(AppInfo_AppName | AppInfo_VendorName) explicitly
to use the vendor name in the paths returned by wxStandardPaths. to use the vendor name in the paths returned by wxStandardPaths.
- wxDataViewModel::GetAttr() is now const, as it should have been from the very
beginning. You will need to change it to be const in your derived model
class too if you override it.
All: All:

View File

@@ -210,8 +210,12 @@ public:
} }
// Get text attribute, return false of default attributes should be used // Get text attribute, return false of default attributes should be used
virtual bool GetAttr( const wxDataViewItem &WXUNUSED(item), unsigned int WXUNUSED(col), wxDataViewItemAttr &WXUNUSED(attr) ) virtual bool GetAttr(const wxDataViewItem &WXUNUSED(item),
{ return false; } unsigned int WXUNUSED(col),
wxDataViewItemAttr &WXUNUSED(attr)) const
{
return false;
}
// define hierachy // define hierachy
virtual wxDataViewItem GetParent( const wxDataViewItem &item ) const = 0; virtual wxDataViewItem GetParent( const wxDataViewItem &item ) const = 0;
@@ -272,7 +276,7 @@ public:
virtual bool virtual bool
GetAttrByRow(unsigned WXUNUSED(row), unsigned WXUNUSED(col), GetAttrByRow(unsigned WXUNUSED(row), unsigned WXUNUSED(col),
wxDataViewItemAttr &WXUNUSED(attr)) wxDataViewItemAttr &WXUNUSED(attr)) const
{ {
return false; return false;
} }
@@ -310,7 +314,7 @@ public:
} }
virtual bool GetAttr(const wxDataViewItem &item, unsigned int col, virtual bool GetAttr(const wxDataViewItem &item, unsigned int col,
wxDataViewItemAttr &attr) wxDataViewItemAttr &attr) const
{ {
return GetAttrByRow( GetRow(item), col, attr ); return GetAttrByRow( GetRow(item), col, attr );
} }

View File

@@ -135,10 +135,21 @@ public:
Override this to indicate that the item has special font attributes. Override this to indicate that the item has special font attributes.
This only affects the wxDataViewTextRendererText renderer. This only affects the wxDataViewTextRendererText renderer.
The base class version always simply returns @false.
@see wxDataViewItemAttr. @see wxDataViewItemAttr.
@param item
The item for which the attribute is requested.
@param col
The column of the item for which the attribute is requested.
@param attr
The attribute to be filled in if the function returns @true.
@return
@true if this item has an attribute or @false otherwise.
*/ */
virtual bool GetAttr(const wxDataViewItem& item, unsigned int col, virtual bool GetAttr(const wxDataViewItem& item, unsigned int col,
wxDataViewItemAttr& attr); wxDataViewItemAttr& attr) const;
/** /**
Override this so the control can query the child items of an item. Override this so the control can query the child items of an item.
@@ -339,10 +350,21 @@ public:
Override this to indicate that the row has special font attributes. Override this to indicate that the row has special font attributes.
This only affects the wxDataViewTextRendererText() renderer. This only affects the wxDataViewTextRendererText() renderer.
The base class version always simply returns @false.
@see wxDataViewItemAttr. @see wxDataViewItemAttr.
@param row
The row for which the attribute is requested.
@param col
The column for which the attribute is requested.
@param attr
The attribute to be filled in if the function returns @true.
@return
@true if this item has an attribute or @false otherwise.
*/ */
virtual bool GetAttrByRow(unsigned int row, unsigned int col, virtual bool GetAttrByRow(unsigned int row, unsigned int col,
wxDataViewItemAttr& attr); wxDataViewItemAttr& attr) const;
/** /**
Returns the wxDataViewItem at the given @e row. Returns the wxDataViewItem at the given @e row.

View File

@@ -433,7 +433,7 @@ void MyListModel::GetValueByRow( wxVariant &variant,
} }
bool MyListModel::GetAttrByRow( unsigned int row, unsigned int col, bool MyListModel::GetAttrByRow( unsigned int row, unsigned int col,
wxDataViewItemAttr &attr ) wxDataViewItemAttr &attr ) const
{ {
switch ( col ) switch ( col )
{ {

View File

@@ -220,7 +220,8 @@ public:
virtual void GetValueByRow( wxVariant &variant, virtual void GetValueByRow( wxVariant &variant,
unsigned int row, unsigned int col ) const; unsigned int row, unsigned int col ) const;
virtual bool GetAttrByRow( unsigned int row, unsigned int col, wxDataViewItemAttr &attr ); virtual bool GetAttrByRow( unsigned int row, unsigned int col,
wxDataViewItemAttr &attr ) const;
virtual bool SetValueByRow( const wxVariant &variant, virtual bool SetValueByRow( const wxVariant &variant,
unsigned int row, unsigned int col ); unsigned int row, unsigned int col );