comparison 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
comparison
equal deleted inserted replaced
426:2386582f67cd 427:72ec275e458b
48 48
49 bool 49 bool
50 ModelDataTableModel::setData(const QModelIndex &index, const QVariant &value, int role) 50 ModelDataTableModel::setData(const QModelIndex &index, const QVariant &value, int role)
51 { 51 {
52 if (!index.isValid()) return false; 52 if (!index.isValid()) return false;
53 std::cerr << "ModelDataTableModel::setData(" << index.row() << ", " << index.column() << ", " << value.toString().toStdString() << ", " << role << ")" << std::endl;
54 Command *command = m_model->getSetDataCommand(getUnsorted(index.row()), 53 Command *command = m_model->getSetDataCommand(getUnsorted(index.row()),
55 index.column(), 54 index.column(),
56 value, role); 55 value, role);
57 if (command) { 56 if (command) {
58 std::cerr << "emitting executeCommand" << std::endl; 57 emit addCommand(command);
59 emit executeCommand(command);
60 return true; 58 return true;
61 } else { 59 } else {
62 return false; 60 return false;
63 } 61 }
62 }
63
64 bool
65 ModelDataTableModel::insertRow(int row, const QModelIndex &parent)
66 {
67 if (parent.isValid()) return false;
68
69 emit beginInsertRows(parent, row, row);
70
71 Command *command = m_model->getInsertRowCommand(getUnsorted(row));
72
73 if (command) {
74 emit addCommand(command);
75 }
76
77 emit endInsertRows();
78
79 return (command ? true : false);
80 }
81
82 bool
83 ModelDataTableModel::removeRow(int row, const QModelIndex &parent)
84 {
85 if (parent.isValid()) return false;
86
87 emit beginRemoveRows(parent, row, row);
88
89 Command *command = m_model->getRemoveRowCommand(getUnsorted(row));
90
91 if (command) {
92 emit addCommand(command);
93 }
94
95 emit endRemoveRows();
96
97 return (command ? true : false);
64 } 98 }
65 99
66 Qt::ItemFlags 100 Qt::ItemFlags
67 ModelDataTableModel::flags(const QModelIndex &index) const 101 ModelDataTableModel::flags(const QModelIndex &index) const
68 { 102 {