fixed sorted row idx

This commit is contained in:
Peter Schojer 2008-10-01 10:00:52 +00:00
parent 116da4bbd1
commit eb9727882f
3 changed files with 10 additions and 5 deletions

View File

@ -186,12 +186,14 @@ protected:
pTable->setValue(std::string("three"), 2,0);
pTable->setValue(std::string("four"), 3,0);
pTable->setValue(std::string("five"), 4,0);
pTable->setValue(std::string("12' 23''"), 5,0);
pTable->setValue(true, 0,1);
pTable->setValue(false, 1,1);
pTable->setValue(true, 2,1);
pTable->setValue(false, 3,1);
pTable->setValue(true, 4,1);
pTable->setValue(true, 5,1);
pTable->setWidth(310);
pTable->setHeight(200);
pTable->setPaging(2);

View File

@ -58,7 +58,7 @@ void ArrayTableSerializer::serialize(std::ostream& ostr, const Table* pTable, st
if (sortCol >= 0)
pSorted = pTable->getSortedModel(static_cast<std::size_t>(sortCol), sortAscending);
const TableModel& tm = ((sortCol >= 0)?*pSorted:pTable->getModel());
const TableModel& tm = (pSorted?*pSorted:pTable->getModel());
const Table::TableColumns& tc = pTable->getColumns();
if (rowCntUser == 0 && pTable->getPagingSize() > 0)
rowCntUser = pTable->getPagingSize();
@ -111,7 +111,11 @@ void ArrayTableSerializer::serialize(std::ostream& ostr, const Table* pTable, st
}
}
// the last column contains the rowIndx
ostr << "," << row;
// with a sorted tablemodel we want the original row value
if (pSorted)
ostr << "," << pSorted->mapping(row);
else
ostr << "," << row;
ostr << "]";
}
ostr << "]}";

View File

@ -86,12 +86,11 @@ public:
std::size_t getSortedColumn() const;
std::size_t mapping(std::size_t) const;
protected:
virtual ~SortedTableModel();
/// Destroys the SortedTableModel.
std::size_t mapping(std::size_t) const;
private:
TableModel& _unsorted;
const Table* _pTable;