Mercurial > hg > svgui
comparison widgets/LayerTree.cpp @ 392:1d85aa5a49be
* Start adding a spreadsheet-style editor window for model data
author | Chris Cannam |
---|---|
date | Fri, 06 Jun 2008 15:26:27 +0000 |
parents | 4a542ba875c2 |
children | f4960f8ce798 |
comparison
equal
deleted
inserted
replaced
391:4f0f273c8f82 | 392:1d85aa5a49be |
---|---|
25 | 25 |
26 #include <QIcon> | 26 #include <QIcon> |
27 #include <iostream> | 27 #include <iostream> |
28 | 28 |
29 | 29 |
30 ModelDataModel::ModelDataModel(PaneStack *stack, bool waveModelsOnly, | 30 ModelMetadataModel::ModelMetadataModel(PaneStack *stack, bool waveModelsOnly, |
31 QObject *parent) : | 31 QObject *parent) : |
32 QAbstractItemModel(parent), | 32 QAbstractItemModel(parent), |
33 m_stack(stack), | 33 m_stack(stack), |
34 m_waveModelsOnly(waveModelsOnly) | 34 m_waveModelsOnly(waveModelsOnly) |
35 { | 35 { |
68 } | 68 } |
69 | 69 |
70 rebuildModelSet(); | 70 rebuildModelSet(); |
71 } | 71 } |
72 | 72 |
73 ModelDataModel::~ModelDataModel() | 73 ModelMetadataModel::~ModelMetadataModel() |
74 { | 74 { |
75 } | 75 } |
76 | 76 |
77 void | 77 void |
78 ModelDataModel::rebuildModelSet() | 78 ModelMetadataModel::rebuildModelSet() |
79 { | 79 { |
80 std::set<Model *> unfound = m_models; | 80 std::set<Model *> unfound = m_models; |
81 | 81 |
82 for (int i = 0; i < m_stack->getPaneCount(); ++i) { | 82 for (int i = 0; i < m_stack->getPaneCount(); ++i) { |
83 | 83 |
109 for (std::set<Model *>::iterator i = unfound.begin(); | 109 for (std::set<Model *>::iterator i = unfound.begin(); |
110 i != unfound.end(); ++i) { | 110 i != unfound.end(); ++i) { |
111 m_models.erase(*i); | 111 m_models.erase(*i); |
112 } | 112 } |
113 | 113 |
114 std::cerr << "ModelDataModel::rebuildModelSet: " << m_models.size() << " models" << std::endl; | 114 std::cerr << "ModelMetadataModel::rebuildModelSet: " << m_models.size() << " models" << std::endl; |
115 } | 115 } |
116 | 116 |
117 void | 117 void |
118 ModelDataModel::paneAdded() | 118 ModelMetadataModel::paneAdded() |
119 { | 119 { |
120 rebuildModelSet(); | 120 rebuildModelSet(); |
121 emit layoutChanged(); | 121 emit layoutChanged(); |
122 } | 122 } |
123 | 123 |
124 void | 124 void |
125 ModelDataModel::paneDeleted() | 125 ModelMetadataModel::paneDeleted() |
126 { | 126 { |
127 rebuildModelSet(); | 127 rebuildModelSet(); |
128 emit layoutChanged(); | 128 emit layoutChanged(); |
129 } | 129 } |
130 | 130 |
131 void | 131 void |
132 ModelDataModel::paneLayerModelChanged() | 132 ModelMetadataModel::paneLayerModelChanged() |
133 { | 133 { |
134 rebuildModelSet(); | 134 rebuildModelSet(); |
135 emit layoutChanged(); | 135 emit layoutChanged(); |
136 } | 136 } |
137 | 137 |
138 void | 138 void |
139 ModelDataModel::propertyContainerAdded(PropertyContainer *) | 139 ModelMetadataModel::propertyContainerAdded(PropertyContainer *) |
140 { | 140 { |
141 rebuildModelSet(); | 141 rebuildModelSet(); |
142 emit layoutChanged(); | 142 emit layoutChanged(); |
143 } | 143 } |
144 | 144 |
145 void | 145 void |
146 ModelDataModel::propertyContainerRemoved(PropertyContainer *) | 146 ModelMetadataModel::propertyContainerRemoved(PropertyContainer *) |
147 { | 147 { |
148 rebuildModelSet(); | 148 rebuildModelSet(); |
149 emit layoutChanged(); | 149 emit layoutChanged(); |
150 } | 150 } |
151 | 151 |
152 void | 152 void |
153 ModelDataModel::propertyContainerSelected(PropertyContainer *) | 153 ModelMetadataModel::propertyContainerSelected(PropertyContainer *) |
154 { | 154 { |
155 } | 155 } |
156 | 156 |
157 void | 157 void |
158 ModelDataModel::propertyContainerPropertyChanged(PropertyContainer *pc) | 158 ModelMetadataModel::propertyContainerPropertyChanged(PropertyContainer *pc) |
159 { | 159 { |
160 } | 160 } |
161 | 161 |
162 void | 162 void |
163 ModelDataModel::playParametersAudibilityChanged(bool a) | 163 ModelMetadataModel::playParametersAudibilityChanged(bool a) |
164 { | 164 { |
165 } | 165 } |
166 | 166 |
167 QVariant | 167 QVariant |
168 ModelDataModel::data(const QModelIndex &index, int role) const | 168 ModelMetadataModel::data(const QModelIndex &index, int role) const |
169 { | 169 { |
170 if (!index.isValid()) return QVariant(); | 170 if (!index.isValid()) return QVariant(); |
171 | 171 |
172 QObject *obj = static_cast<QObject *>(index.internalPointer()); | 172 QObject *obj = static_cast<QObject *>(index.internalPointer()); |
173 int row = index.row(), col = index.column(); | 173 int row = index.row(), col = index.column(); |
204 | 204 |
205 return QVariant(); | 205 return QVariant(); |
206 } | 206 } |
207 | 207 |
208 bool | 208 bool |
209 ModelDataModel::setData(const QModelIndex &index, const QVariant &value, int role) | 209 ModelMetadataModel::setData(const QModelIndex &index, const QVariant &value, int role) |
210 { | 210 { |
211 return false; | 211 return false; |
212 } | 212 } |
213 | 213 |
214 Qt::ItemFlags | 214 Qt::ItemFlags |
215 ModelDataModel::flags(const QModelIndex &index) const | 215 ModelMetadataModel::flags(const QModelIndex &index) const |
216 { | 216 { |
217 Qt::ItemFlags flags = Qt::ItemIsEnabled; | 217 Qt::ItemFlags flags = Qt::ItemIsEnabled; |
218 return flags; | 218 return flags; |
219 } | 219 } |
220 | 220 |
221 QVariant | 221 QVariant |
222 ModelDataModel::headerData(int section, | 222 ModelMetadataModel::headerData(int section, |
223 Qt::Orientation orientation, | 223 Qt::Orientation orientation, |
224 int role) const | 224 int role) const |
225 { | 225 { |
226 if (orientation == Qt::Horizontal && role == Qt::DisplayRole) { | 226 if (orientation == Qt::Horizontal && role == Qt::DisplayRole) { |
227 if (section == m_modelTypeColumn) return QVariant(tr("Type")); | 227 if (section == m_modelTypeColumn) return QVariant(tr("Type")); |
232 | 232 |
233 return QVariant(); | 233 return QVariant(); |
234 } | 234 } |
235 | 235 |
236 QModelIndex | 236 QModelIndex |
237 ModelDataModel::index(int row, int column, const QModelIndex &parent) const | 237 ModelMetadataModel::index(int row, int column, const QModelIndex &parent) const |
238 { | 238 { |
239 if (!parent.isValid()) { | 239 if (!parent.isValid()) { |
240 if (row >= m_models.size()) return QModelIndex(); | 240 if (row >= m_models.size()) return QModelIndex(); |
241 return createIndex(row, column, 0); | 241 return createIndex(row, column, 0); |
242 } | 242 } |
243 | 243 |
244 return QModelIndex(); | 244 return QModelIndex(); |
245 } | 245 } |
246 | 246 |
247 QModelIndex | 247 QModelIndex |
248 ModelDataModel::parent(const QModelIndex &index) const | 248 ModelMetadataModel::parent(const QModelIndex &index) const |
249 { | 249 { |
250 return QModelIndex(); | 250 return QModelIndex(); |
251 } | 251 } |
252 | 252 |
253 int | 253 int |
254 ModelDataModel::rowCount(const QModelIndex &parent) const | 254 ModelMetadataModel::rowCount(const QModelIndex &parent) const |
255 { | 255 { |
256 if (!parent.isValid()) return m_models.size(); | 256 if (!parent.isValid()) return m_models.size(); |
257 return 0; | 257 return 0; |
258 } | 258 } |
259 | 259 |
260 int | 260 int |
261 ModelDataModel::columnCount(const QModelIndex &parent) const | 261 ModelMetadataModel::columnCount(const QModelIndex &parent) const |
262 { | 262 { |
263 return m_columnCount; | 263 return m_columnCount; |
264 } | 264 } |
265 | 265 |
266 | 266 |