More cool sorting code.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@37774
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
// return type as reported by wxVariant
virtual wxString GetColType( size_t col ) = 0;
// get value into a wxVariant
// return type as reported by wxVariant
virtual wxString GetColType( size_t col ) = 0;
// get value into a wxVariant
- virtual wxVariant GetValue( size_t col, size_t row ) = 0;
+ virtual void GetValue( wxVariant &variant, size_t col, size_t row ) = 0;
// set value, call ValueChanged() afterwards!
virtual bool SetValue( wxVariant &variant, size_t col, size_t row ) = 0;
// set value, call ValueChanged() afterwards!
virtual bool SetValue( wxVariant &variant, size_t col, size_t row ) = 0;
// return type as reported by wxVariant
virtual wxString GetColType( size_t col );
// get value into a wxVariant
// return type as reported by wxVariant
virtual wxString GetColType( size_t col );
// get value into a wxVariant
- virtual wxVariant GetValue( size_t col, size_t row );
+ virtual void GetValue( wxVariant &variant, size_t col, size_t row );
// set value, call ValueChanged() afterwards!
virtual bool SetValue( wxVariant &variant, size_t col, size_t row );
// set value, call ValueChanged() afterwards!
virtual bool SetValue( wxVariant &variant, size_t col, size_t row );
- virtual wxVariant GetValue( size_t col, size_t row )
+ virtual void GetValue( wxVariant &variant, size_t col, size_t row )
- return (wxDateTime) *m_dates[row];
+ variant = (wxDateTime) *m_dates[row];
- return (long) m_progress[row];
+ variant = (long) m_progress[row];
+ variant = m_colours[row];
- return (bool) m_bools[row];
+ variant = (bool) m_bools[row];
}
else
{
wxString tmp;
tmp.Printf( wxT("item(%d;%d)"), (int)row, (int)col );
}
else
{
wxString tmp;
tmp.Printf( wxT("item(%d;%d)"), (int)row, (int)col );
}
}
virtual bool SetValue( wxVariant &value, size_t col, size_t row )
}
}
virtual bool SetValue( wxVariant &value, size_t col, size_t row )
virtual size_t GetNumberOfRows() { return m_list.GetCount(); }
virtual size_t GetNumberOfCols() { return 2; }
virtual wxString GetColType( size_t col ) { return wxT("string"); }
virtual size_t GetNumberOfRows() { return m_list.GetCount(); }
virtual size_t GetNumberOfCols() { return 2; }
virtual wxString GetColType( size_t col ) { return wxT("string"); }
- virtual wxVariant GetValue( size_t col, size_t row )
+ virtual void GetValue( wxVariant &variant, size_t col, size_t row )
+ {
+ variant = m_list[row];
+ return;
+ }
wxString tmp;
tmp.Printf( wxT("item(%d;%d)"), (int)row, (int)col );
wxString tmp;
tmp.Printf( wxT("item(%d;%d)"), (int)row, (int)col );
}
virtual bool SetValue( wxVariant &variant, size_t col, size_t row )
{
}
virtual bool SetValue( wxVariant &variant, size_t col, size_t row )
{
int wxCALLBACK wxDataViewListModelSortedDefaultCompare
(size_t row1, size_t row2, size_t col, wxDataViewListModel* model )
{
int wxCALLBACK wxDataViewListModelSortedDefaultCompare
(size_t row1, size_t row2, size_t col, wxDataViewListModel* model )
{
- wxVariant value1 = model->GetValue( col, row1 );
- wxVariant value2 = model->GetValue( col, row2 );
+ wxVariant value1,value2;
+ model->GetValue( value1, col, row1 );
+ model->GetValue( value2, col, row2 );
if (value1.GetType() == wxT("string"))
{
wxString str1 = value1.GetString();
if (value1.GetType() == wxT("string"))
{
wxString str1 = value1.GetString();
+#if 0
+static void Dump( wxDataViewListModel *model, size_t col )
+{
+ size_t n = model->GetNumberOfRows();
+ size_t i;
+ for (i = 0; i < n; i++)
+ {
+ wxVariant variant;
+ model->GetValue( variant, col, i );
+ wxString tmp;
+ tmp = variant.GetString();
+ wxPrintf( wxT("%d: %s\n"), (int) i, tmp.c_str() );
+ }
+}
+#endif
+
bool wxDataViewSortedListModel::ChildValueChanged( size_t col, size_t row )
{
size_t i;
bool wxDataViewSortedListModel::ChildValueChanged( size_t col, size_t row )
{
size_t i;
+ m_array.RemoveAt( start_pos );
for (i = 0; i < len; i++)
if (m_array[i] == row)
{
end_pos = i;
break;
}
for (i = 0; i < len; i++)
if (m_array[i] == row)
{
end_pos = i;
break;
}
if (end_pos == start_pos)
return wxDataViewListModel::ValueChanged( col, start_pos );
if (end_pos == start_pos)
return wxDataViewListModel::ValueChanged( col, start_pos );
order[start_pos] = end_pos;
}
order[start_pos] = end_pos;
}
- RowsReordered( order );
+ wxDataViewListModel::RowsReordered( order );
size_t wxDataViewSortedListModel::GetNumberOfRows()
{
size_t wxDataViewSortedListModel::GetNumberOfRows()
{
- return m_child->GetNumberOfRows();
+ return m_array.GetCount();
}
size_t wxDataViewSortedListModel::GetNumberOfCols()
}
size_t wxDataViewSortedListModel::GetNumberOfCols()
return m_child->GetColType( col );
}
return m_child->GetColType( col );
}
-wxVariant wxDataViewSortedListModel::GetValue( size_t col, size_t row )
+void wxDataViewSortedListModel::GetValue( wxVariant &variant, size_t col, size_t row )
{
size_t child_row = m_array[row];
{
size_t child_row = m_array[row];
- return m_child->GetValue( col, child_row );
+ m_child->GetValue( variant, col, child_row );
}
bool wxDataViewSortedListModel::SetValue( wxVariant &variant, size_t col, size_t row )
}
bool wxDataViewSortedListModel::SetValue( wxVariant &variant, size_t col, size_t row )
#include "wx/calctrl.h"
#include "wx/popupwin.h"
#include "wx/sizer.h"
#include "wx/calctrl.h"
#include "wx/popupwin.h"
#include "wx/sizer.h"
#include "wx/gtk/private.h"
#include "wx/gtk/win_gtk.h"
#include "wx/gtk/private.h"
#include "wx/gtk/win_gtk.h"
wxString mtype = model->GetColType( (size_t) column );
if (mtype == wxT("string"))
{
wxString mtype = model->GetColType( (size_t) column );
if (mtype == wxT("string"))
{
g_value_init( value, G_TYPE_STRING );
g_value_init( value, G_TYPE_STRING );
- wxVariant variant = model->GetValue( (size_t) column, (size_t) iter->user_data );
+ model->GetValue( variant, (size_t) column, (size_t) iter->user_data );
g_value_set_string( value, wxGTK_CONV(variant.GetString()) );
}
else
g_value_set_string( value, wxGTK_CONV(variant.GetString()) );
}
else
node = node->GetNext();
}
node = node->GetNext();
}
bool wxDataViewDateCell::Activate( wxRect cell, wxDataViewListModel *model, size_t col, size_t row )
{
bool wxDataViewDateCell::Activate( wxRect cell, wxDataViewListModel *model, size_t col, size_t row )
{
- wxVariant variant = model->GetValue( col, row );
+ wxVariant variant;
+ model->GetValue( variant, col, row );
wxDateTime value = variant.GetDateTime();
wxDataViewDateCellPopupTransient *popup = new wxDataViewDateCellPopupTransient(
wxDateTime value = variant.GetDateTime();
wxDataViewDateCellPopupTransient *popup = new wxDataViewDateCellPopupTransient(
size_t model_row = (size_t) iter->user_data;
size_t model_row = (size_t) iter->user_data;
- wxVariant value = list_store->model->GetValue(
- cell->GetOwner()->GetModelColumn(), model_row );
+ wxVariant value;
+ list_store->model->GetValue( value, cell->GetOwner()->GetModelColumn(), model_row );
if (value.GetType() != cell->GetVariantType())
if (value.GetType() != cell->GetVariantType())
- wxPrintf( wxT("Wrong type\n") );
+ wxLogError( wxT("Wrong type\n") );
cell->SetValue( value );
}
cell->SetValue( value );
}