Mercurial > hg > svcore
diff data/model/ModelDataTableModel.cpp @ 427:72ec275e458b
* Basic implementation of add and remove point in data editor
* Improve resilience of frame - real-time - frame round-trip conversions
author | Chris Cannam |
---|---|
date | Mon, 16 Jun 2008 14:48:42 +0000 |
parents | 2386582f67cd |
children | 3e1d190048f4 |
line wrap: on
line diff
--- a/data/model/ModelDataTableModel.cpp Mon Jun 16 07:55:35 2008 +0000 +++ b/data/model/ModelDataTableModel.cpp Mon Jun 16 14:48:42 2008 +0000 @@ -50,19 +50,53 @@ ModelDataTableModel::setData(const QModelIndex &index, const QVariant &value, int role) { if (!index.isValid()) return false; - std::cerr << "ModelDataTableModel::setData(" << index.row() << ", " << index.column() << ", " << value.toString().toStdString() << ", " << role << ")" << std::endl; Command *command = m_model->getSetDataCommand(getUnsorted(index.row()), index.column(), value, role); if (command) { - std::cerr << "emitting executeCommand" << std::endl; - emit executeCommand(command); + emit addCommand(command); return true; } else { return false; } } +bool +ModelDataTableModel::insertRow(int row, const QModelIndex &parent) +{ + if (parent.isValid()) return false; + + emit beginInsertRows(parent, row, row); + + Command *command = m_model->getInsertRowCommand(getUnsorted(row)); + + if (command) { + emit addCommand(command); + } + + emit endInsertRows(); + + return (command ? true : false); +} + +bool +ModelDataTableModel::removeRow(int row, const QModelIndex &parent) +{ + if (parent.isValid()) return false; + + emit beginRemoveRows(parent, row, row); + + Command *command = m_model->getRemoveRowCommand(getUnsorted(row)); + + if (command) { + emit addCommand(command); + } + + emit endRemoveRows(); + + return (command ? true : false); +} + Qt::ItemFlags ModelDataTableModel::flags(const QModelIndex &index) const {