Mercurial > hg > svcore
diff data/model/ModelDataTableModel.cpp @ 618:b1dc68507e46 sv-v1.7.1
* Layer data editor window: fix sorting for columns in region model,
add Find feature
* RDF import: assign names to layers based on event types, if no suitable
labels are found in the RDF
* Add label to status bar showing the last text that was passed in current
layer (so e.g. counting 1, 2, 3, 4 if that's what beats are labelled)
* Better layout of text labels for region layers in segmentation mode when
they are close together
* Give text layer the same method for finding "nearest point" as region and
note layers, should improve its editability
author | Chris Cannam |
---|---|
date | Thu, 22 Oct 2009 15:54:21 +0000 |
parents | ba7aaacb7211 |
children | b4a8d8221eaf |
line wrap: on
line diff
--- a/data/model/ModelDataTableModel.cpp Thu Oct 15 11:32:21 2009 +0000 +++ b/data/model/ModelDataTableModel.cpp Thu Oct 22 15:54:21 2009 +0000 @@ -169,6 +169,29 @@ return m_model->getFrameForRow(getUnsorted(index.row())); } +QModelIndex +ModelDataTableModel::findText(QString text) const +{ + if (text == "") return QModelIndex(); + int rows = rowCount(); + int cols = columnCount(); + int current = getCurrentRow(); + for (int row = 1; row <= rows; ++row) { + int wrapped = (row + current) % rows; + for (int col = 0; col < cols; ++col) { + if (m_model->getSortType(col) != TabularModel::SortAlphabetical) { + continue; + } + QString cell = m_model->getData(getUnsorted(wrapped), col, + Qt::DisplayRole).toString(); + if (cell.contains(text, Qt::CaseInsensitive)) { + return createIndex(wrapped, col); + } + } + } + return QModelIndex(); +} + void ModelDataTableModel::sort(int column, Qt::SortOrder sortOrder) { @@ -274,6 +297,8 @@ bool numeric = (m_model->getSortType(m_sortColumn) == TabularModel::SortNumeric); +// std::cerr << "resort: numeric == " << numeric << std::endl; + m_sort.clear(); m_rsort.clear(); @@ -313,6 +338,7 @@ } for (MapType::iterator i = rowMap.begin(); i != rowMap.end(); ++i) { +// std::cerr << "resortNumeric: " << i->second << ": " << i->first << std::endl; m_rsort.push_back(i->second); } @@ -336,6 +362,7 @@ } for (MapType::iterator i = rowMap.begin(); i != rowMap.end(); ++i) { +// std::cerr << "resortAlphabetical: " << i->second << ": " << i->first.toStdString() << std::endl; m_rsort.push_back(i->second); } @@ -343,7 +370,7 @@ } int -ModelDataTableModel::getCurrentRow() +ModelDataTableModel::getCurrentRow() const { return getSorted(m_currentRow); }