From b372f20e7ed8d5477b0b4ffa1449f86b29fa3c5b Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 24 Oct 2009 01:03:24 +0000 Subject: [PATCH] Add wxDataViewModel::HasValue(). This method allows to simply test whether we have a value at the given row and column or not (as it happens for container items unless they too have columns). Currently this method is not virtual and is not used by the implementations yet but it might make sense to make it virtual and allow overriding it in the future. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62492 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/dataview.h | 8 ++++++++ interface/wx/dataview.h | 14 ++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/include/wx/dataview.h b/include/wx/dataview.h index f02ad00a19..b2b9275d4f 100644 --- a/include/wx/dataview.h +++ b/include/wx/dataview.h @@ -186,6 +186,14 @@ public: virtual void GetValue( wxVariant &variant, const wxDataViewItem &item, unsigned int col ) const = 0; + // return true if the given item has a value to display in the given + // column: this is always true except for container items which by default + // only show their label in the first column (but see HasContainerColumns()) + bool HasValue(const wxDataViewItem& item, unsigned col) const + { + return col == 0 || !IsContainer(item) || HasContainerColumns(item); + } + // usually ValueChanged() should be called after changing the value in the // model to update the control, ChangeValue() does it on its own while // SetValue() does not -- so while you will override SetValue(), you should diff --git a/interface/wx/dataview.h b/interface/wx/dataview.h index debcecdb43..21f04a8472 100644 --- a/interface/wx/dataview.h +++ b/interface/wx/dataview.h @@ -193,6 +193,20 @@ public: */ virtual bool HasDefaultCompare() const; + /** + Return true if there is a value in the given column of this item. + + All normal items have values in all columns but the container items + only show their label in the first column (@a col == 0) by default (but + see HasContainerColumns()). So this function always returns true for + the first column while for the other ones it returns true only if the + item is not a container or HasContainerColumns() was overridden to + return true for it. + + @since 2.9.1 + */ + bool HasValue(const wxDataViewItem& item, unsigned col) const; + /** Override this to indicate of @a item is a container, i.e. if it can have child items.