Skip to content

Commit

Permalink
#3250: Privatise Column member, used by friend ColumnRecord.
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Jan 10, 2021
1 parent 1ca4aa6 commit 22e321e
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions libs/wxutil/dataview/TreeModel.h
Expand Up @@ -21,6 +21,8 @@ class TreeModel :
/// Reference-counted smart pointer type
typedef wxObjectDataPtr<TreeModel> Ptr;

class ColumnRecord;

/**
* Represents a column in the wxutil::TreeModel
* Use the Type string to instantiate a Column and arrange
Expand Down Expand Up @@ -64,14 +66,17 @@ class TreeModel :
return _col;
}

// Only for internal use by the TreeModel - didn't want to use a friend declaration
void _setColumnIndex(int index)
// Returns the wxWidgets type string of this column
wxString getWxType() const;

private:
// Only for internal use by the ColumnRecord friend
void setColumnIndex(int index)
{
_col = index;
}

// Returns the wxWidgets type string of this column
wxString getWxType() const;
friend class ColumnRecord;
};

/**
Expand All @@ -95,10 +100,10 @@ class TreeModel :
public:
Column add(Column::Type type, const std::string& name = "")
{
_columns.push_back(Column(type, name));
_columns.back()._setColumnIndex(static_cast<int>(_columns.size()) - 1);
auto& column = _columns.emplace_back(type, name);
column.setColumnIndex(static_cast<int>(_columns.size()) - 1);

return _columns.back();
return column;
}

List::iterator begin()
Expand Down

0 comments on commit 22e321e

Please sign in to comment.