Remove wxHeaderColumn::SetAsSortKey() and only use SetSortOrder().

The two member functions, SetAsSortKey() and SetSortOrder(), were doing almost
the same thing but differently and the former was only used in the generic
wxDataViewCtrl implementation and not implemented in the native GTK/OS X one.

Remove SetAsSortKey() entirely and only keep UnsetAsSortKey() which is still
needed by generic/MSW wxDataViewCtrl. But only SetSortOrder() should now be
called to indicate that the column is used for sorting.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@69174 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2011-09-21 15:07:46 +00:00
parent 8148ae02ef
commit aadbdd1699
10 changed files with 36 additions and 55 deletions

View File

@@ -68,10 +68,17 @@ public:
virtual void SetFlags(int flags) { m_flags = flags; UpdateDisplay(); } virtual void SetFlags(int flags) { m_flags = flags; UpdateDisplay(); }
virtual int GetFlags() const { return m_flags; } virtual int GetFlags() const { return m_flags; }
virtual void SetAsSortKey(bool sort = true) { m_sort = sort; UpdateDisplay(); }
virtual bool IsSortKey() const { return m_sort; } virtual bool IsSortKey() const { return m_sort; }
virtual void SetSortOrder(bool ascending) { m_sortAscending = ascending; UpdateDisplay(); } virtual void UnsetAsSortKey() { m_sort = false; UpdateDisplay(); }
virtual void SetSortOrder(bool ascending)
{
m_sort = true;
m_sortAscending = ascending;
UpdateDisplay();
}
virtual bool IsSortOrderAscending() const { return m_sortAscending; } virtual bool IsSortOrderAscending() const { return m_sortAscending; }
virtual void SetBitmap( const wxBitmap& bitmap ) { wxDataViewColumnBase::SetBitmap(bitmap); UpdateDisplay(); } virtual void SetBitmap( const wxBitmap& bitmap ) { wxDataViewColumnBase::SetBitmap(bitmap); UpdateDisplay(); }

View File

@@ -44,7 +44,6 @@ public:
virtual void SetSortable( bool sortable ); virtual void SetSortable( bool sortable );
virtual void SetSortOrder( bool ascending ); virtual void SetSortOrder( bool ascending );
virtual void SetAsSortKey(bool sort = true);
virtual void SetResizeable( bool resizable ); virtual void SetResizeable( bool resizable );
virtual void SetHidden( bool hidden ); virtual void SetHidden( bool hidden );

View File

@@ -186,8 +186,12 @@ public:
virtual void SetHidden(bool hidden) virtual void SetHidden(bool hidden)
{ ChangeFlag(wxCOL_HIDDEN, hidden); } { ChangeFlag(wxCOL_HIDDEN, hidden); }
virtual void SetAsSortKey(bool sort = true) = 0; // This function can be called to indicate that this column is not used for
void UnsetAsSortKey() { SetAsSortKey(false); } // sorting any more. Under some platforms it's not necessary to do anything
// in this case as just setting another column as a sort key takes care of
// everything but under MSW we currently need to call this explicitly to
// reset the sort indicator displayed on the column.
virtual void UnsetAsSortKey() { }
virtual void SetSortOrder(bool ascending) = 0; virtual void SetSortOrder(bool ascending) = 0;
void ToggleSortOrder() { SetSortOrder(!IsSortOrderAscending()); } void ToggleSortOrder() { SetSortOrder(!IsSortOrderAscending()); }
@@ -249,10 +253,15 @@ public:
virtual void SetFlags(int flags) { m_flags = flags; } virtual void SetFlags(int flags) { m_flags = flags; }
virtual int GetFlags() const { return m_flags; } virtual int GetFlags() const { return m_flags; }
virtual void SetAsSortKey(bool sort = true) { m_sort = sort; }
virtual bool IsSortKey() const { return m_sort; } virtual bool IsSortKey() const { return m_sort; }
virtual void UnsetAsSortKey() { m_sort = false; }
virtual void SetSortOrder(bool ascending)
{
m_sort = true;
m_sortAscending = ascending;
}
virtual void SetSortOrder(bool ascending) { m_sortAscending = ascending; }
virtual bool IsSortOrderAscending() const { return m_sortAscending; } virtual bool IsSortOrderAscending() const { return m_sortAscending; }
private: private:

View File

@@ -65,7 +65,6 @@ public:
virtual void SetSortOrder (bool ascending); virtual void SetSortOrder (bool ascending);
virtual void SetTitle (wxString const& title); virtual void SetTitle (wxString const& title);
virtual void SetWidth (int width); virtual void SetWidth (int width);
virtual void SetAsSortKey (bool sort = true);
// implementation only // implementation only
wxDataViewColumnNativeData* GetNativeData() const wxDataViewColumnNativeData* GetNativeData() const

View File

@@ -338,38 +338,26 @@ public:
virtual void SetHidden(bool hidden); virtual void SetHidden(bool hidden);
/**
Sets this column as the sort key for the associated control.
Calling this function with @true argument means that this column is
currently used for sorting the control contents and so should typically
display an arrow indicating it (the direction of the arrow depends on
IsSortOrderAscending() return value).
Don't confuse this function with SetSortable() which should be used to
indicate that the column @em may be used for sorting while this one is
used to indicate that it currently @em is used for sorting. Of course,
SetAsSortKey() can be only called for sortable columns.
@param sort
Sort (default) or don't sort the control contents by this column.
*/
virtual void SetAsSortKey(bool sort = true) = 0;
/** /**
Don't use this column for sorting. Don't use this column for sorting.
This is equivalent to calling SetAsSortKey() with @false argument. This is the reverse of SetSortOrder() and is called to indicate that
this column is not used for sorting any longer.
*/ */
void UnsetAsSortKey(); void UnsetAsSortKey();
/** /**
Sets the sort order for this column. Sets this column as the sort key for the associated control.
This only makes sense for sortable columns which are currently used as This function indicates that this column is currently used for sorting
sort key, i.e. for which IsSortKey() returns @true and is only taken the control and also sets the sorting direction. Notice that actual
into account by the control in which this column is inserted, this sorting is only done in the control associated with the header, this
function just stores the sort order in the wxHeaderColumn object. function doesn't do any sorting on its own.
Don't confuse this function with SetSortable() which should be used to
indicate that the column @em may be used for sorting while this one is
used to indicate that it currently @em is used for sorting. Of course,
SetSortOrder() can be only called for sortable columns.
@param ascending @param ascending
If @true, sort in ascending order, otherwise in descending order. If @true, sort in ascending order, otherwise in descending order.
@@ -444,7 +432,6 @@ public:
virtual wxAlignment GetAlignment() const; virtual wxAlignment GetAlignment() const;
virtual void SetFlags(int flags); virtual void SetFlags(int flags);
virtual int GetFlags() const; virtual int GetFlags() const;
virtual void SetAsSortKey(bool sort = true);
virtual bool IsSortKey() const; virtual bool IsSortKey() const;
virtual void SetSortOrder(bool ascending); virtual void SetSortOrder(bool ascending);
virtual bool IsSortOrderAscending() const; virtual bool IsSortOrderAscending() const;

View File

@@ -443,7 +443,7 @@ void wxHeaderCtrlSimple::DoShowSortIndicator(unsigned int idx, bool ascending)
{ {
RemoveSortIndicator(); RemoveSortIndicator();
m_cols[idx].SetAsSortKey(ascending); m_cols[idx].SetSortOrder(ascending);
m_sortKey = idx; m_sortKey = idx;
UpdateColumn(idx); UpdateColumn(idx);

View File

@@ -230,7 +230,7 @@ private:
} }
owner->SetSortingColumnIndex(idx); owner->SetSortingColumnIndex(idx);
col->SetAsSortKey(); col->SetSortOrder(true);
} }
wxDataViewModel * const model = owner->GetModel(); wxDataViewModel * const model = owner->GetModel();

View File

@@ -3286,14 +3286,6 @@ bool wxDataViewColumn::IsSortable() const
return gtk_tree_view_column_get_clickable( column ); return gtk_tree_view_column_get_clickable( column );
} }
void wxDataViewColumn::SetAsSortKey( bool WXUNUSED(sort) )
{
// it might not make sense to have this function in wxHeaderColumn at
// all in fact, changing of the sort order should only be done using the
// associated control API
wxFAIL_MSG( "not implemented" );
}
bool wxDataViewColumn::IsSortKey() const bool wxDataViewColumn::IsSortKey() const
{ {
GtkTreeViewColumn *column = GTK_TREE_VIEW_COLUMN(m_column); GtkTreeViewColumn *column = GTK_TREE_VIEW_COLUMN(m_column);

View File

@@ -2811,12 +2811,6 @@ bool wxDataViewColumn::IsHidden() const
} }
void wxDataViewColumn::SetAsSortKey(bool WXUNUSED(sort))
{
// see wxGTK native wxDataViewColumn implementation
wxFAIL_MSG( "not implemented" );
}
void wxDataViewColumn::SetNativeData(wxDataViewColumnNativeData* newNativeDataPtr) void wxDataViewColumn::SetNativeData(wxDataViewColumnNativeData* newNativeDataPtr)
{ {
delete m_NativeDataPtr; delete m_NativeDataPtr;

View File

@@ -3243,12 +3243,6 @@ void wxDataViewColumn::SetWidth(int width)
} }
} }
void wxDataViewColumn::SetAsSortKey(bool WXUNUSED(sort))
{
// see wxGTK native wxDataViewColumn implementation
wxFAIL_MSG("not implemented");
}
void wxDataViewColumn::SetNativeData(wxDataViewColumnNativeData* newNativeDataPtr) void wxDataViewColumn::SetNativeData(wxDataViewColumnNativeData* newNativeDataPtr)
{ {
delete m_NativeDataPtr; delete m_NativeDataPtr;