comparison data/model/ModelDataTableModel.cpp @ 424:eafef13bb0b3

* Add more data-editor support to various models
author Chris Cannam
date Thu, 12 Jun 2008 14:33:45 +0000
parents 4caa28a0a8a2
children f5e8f12d2e58
comparison
equal deleted inserted replaced
423:6a96bff0bd59 424:eafef13bb0b3
39 } 39 }
40 40
41 QVariant 41 QVariant
42 ModelDataTableModel::data(const QModelIndex &index, int role) const 42 ModelDataTableModel::data(const QModelIndex &index, int role) const
43 { 43 {
44 if (role != Qt::EditRole && role != Qt::DisplayRole) return QVariant();
44 if (!index.isValid()) return QVariant(); 45 if (!index.isValid()) return QVariant();
45 return m_model->getData(getUnsorted(index.row()), index.column(), role); 46 return m_model->getData(getUnsorted(index.row()), index.column(), role);
46 } 47 }
47 48
48 bool 49 bool
234 235
235 MapType rowMap; 236 MapType rowMap;
236 int rows = m_model->getRowCount(); 237 int rows = m_model->getRowCount();
237 238
238 for (int i = 0; i < rows; ++i) { 239 for (int i = 0; i < rows; ++i) {
239 QVariant value = 240 QVariant value = m_model->getData(i, m_sortColumn, TabularModel::SortRole);
240 m_model->getData(i, m_sortColumn, TabularModel::SortRole);
241 rowMap.insert(MapType::value_type(value.toDouble(), i)); 241 rowMap.insert(MapType::value_type(value.toDouble(), i));
242 } 242 }
243 243
244 for (MapType::iterator i = rowMap.begin(); i != rowMap.end(); ++i) { 244 for (MapType::iterator i = rowMap.begin(); i != rowMap.end(); ++i) {
245 m_rsort.push_back(i->second); 245 m_rsort.push_back(i->second);