Mercurial > hg > svgui
comparison widgets/LayerTree.cpp @ 336:4a542ba875c2
* Improvements to layer summary dialog (LayerTree, LayerTreeDialog), & rename.
  It's still rather unstable though.
| author | Chris Cannam | 
|---|---|
| date | Wed, 28 Nov 2007 17:45:37 +0000 | 
| parents | 226cb289bdf4 | 
| children | 1d85aa5a49be | 
   comparison
  equal
  deleted
  inserted
  replaced
| 335:2f83b6e3b8ca | 336:4a542ba875c2 | 
|---|---|
| 19 | 19 | 
| 20 #include "base/PlayParameters.h" | 20 #include "base/PlayParameters.h" | 
| 21 #include "view/Pane.h" | 21 #include "view/Pane.h" | 
| 22 #include "layer/Layer.h" | 22 #include "layer/Layer.h" | 
| 23 #include "data/model/Model.h" | 23 #include "data/model/Model.h" | 
| 24 #include "data/model/WaveFileModel.h" | |
| 24 | 25 | 
| 25 #include <QIcon> | 26 #include <QIcon> | 
| 26 #include <iostream> | 27 #include <iostream> | 
| 27 | 28 | 
| 28 | 29 | 
| 29 LayerTreeModel::LayerTreeModel(PaneStack *stack, QObject *parent) : | 30 ModelDataModel::ModelDataModel(PaneStack *stack, bool waveModelsOnly, | 
| 31 QObject *parent) : | |
| 30 QAbstractItemModel(parent), | 32 QAbstractItemModel(parent), | 
| 31 m_stack(stack) | 33 m_stack(stack), | 
| 32 { | 34 m_waveModelsOnly(waveModelsOnly) | 
| 33 connect(stack, SIGNAL(paneAdded()), this, SIGNAL(layoutChanged())); | 35 { | 
| 34 connect(stack, SIGNAL(paneDeleted()), this, SIGNAL(layoutChanged())); | 36 if (m_waveModelsOnly) { | 
| 37 m_modelTypeColumn = -1; | |
| 38 m_modelNameColumn = 0; | |
| 39 m_modelMakerColumn = 1; | |
| 40 m_modelSourceColumn = 2; | |
| 41 m_columnCount = 3; | |
| 42 } else { | |
| 43 m_modelTypeColumn = 0; | |
| 44 m_modelNameColumn = 1; | |
| 45 m_modelMakerColumn = 2; | |
| 46 m_modelSourceColumn = 3; | |
| 47 m_columnCount = 4; | |
| 48 } | |
| 49 | |
| 50 connect(stack, SIGNAL(paneAdded()), this, SLOT(paneAdded())); | |
| 51 connect(stack, SIGNAL(paneDeleted()), this, SLOT(paneDeleted())); | |
| 35 | 52 | 
| 36 for (int i = 0; i < stack->getPaneCount(); ++i) { | 53 for (int i = 0; i < stack->getPaneCount(); ++i) { | 
| 37 Pane *pane = stack->getPane(i); | 54 Pane *pane = stack->getPane(i); | 
| 38 if (!pane) continue; | 55 if (!pane) continue; | 
| 39 connect(pane, SIGNAL(propertyContainerAdded(PropertyContainer *)), | 56 connect(pane, SIGNAL(propertyContainerAdded(PropertyContainer *)), | 
| 44 this, SLOT(propertyContainerSelected(PropertyContainer *))); | 61 this, SLOT(propertyContainerSelected(PropertyContainer *))); | 
| 45 connect(pane, SIGNAL(propertyContainerPropertyChanged(PropertyContainer *)), | 62 connect(pane, SIGNAL(propertyContainerPropertyChanged(PropertyContainer *)), | 
| 46 this, SLOT(propertyContainerPropertyChanged(PropertyContainer *))); | 63 this, SLOT(propertyContainerPropertyChanged(PropertyContainer *))); | 
| 47 connect(pane, SIGNAL(propertyContainerNameChanged(PropertyContainer *)), | 64 connect(pane, SIGNAL(propertyContainerNameChanged(PropertyContainer *)), | 
| 48 this, SLOT(propertyContainerPropertyChanged(PropertyContainer *))); | 65 this, SLOT(propertyContainerPropertyChanged(PropertyContainer *))); | 
| 66 connect(pane, SIGNAL(layerModelChanged()), | |
| 67 this, SLOT(paneLayerModelChanged())); | |
| 68 } | |
| 69 | |
| 70 rebuildModelSet(); | |
| 71 } | |
| 72 | |
| 73 ModelDataModel::~ModelDataModel() | |
| 74 { | |
| 75 } | |
| 76 | |
| 77 void | |
| 78 ModelDataModel::rebuildModelSet() | |
| 79 { | |
| 80 std::set<Model *> unfound = m_models; | |
| 81 | |
| 82 for (int i = 0; i < m_stack->getPaneCount(); ++i) { | |
| 83 | |
| 84 Pane *pane = m_stack->getPane(i); | |
| 85 if (!pane) continue; | |
| 86 | |
| 87 for (int j = 0; j < pane->getLayerCount(); ++j) { | |
| 88 | |
| 89 Layer *layer = pane->getLayer(j); | |
| 90 if (!layer) continue; | |
| 91 | |
| 92 Model *model = layer->getModel(); | |
| 93 if (!model) continue; | |
| 94 | |
| 95 if (m_waveModelsOnly) { | |
| 96 if (!dynamic_cast<WaveFileModel *>(model)) continue; | |
| 97 } | |
| 98 | |
| 99 if (m_models.find(model) == m_models.end()) { | |
| 100 connect(model, SIGNAL(aboutToBeDeleted()), | |
| 101 this, SLOT(rebuildModelSet())); | |
| 102 m_models.insert(model); | |
| 103 } else { | |
| 104 unfound.erase(model); | |
| 105 } | |
| 106 } | |
| 107 } | |
| 108 | |
| 109 for (std::set<Model *>::iterator i = unfound.begin(); | |
| 110 i != unfound.end(); ++i) { | |
| 111 m_models.erase(*i); | |
| 112 } | |
| 113 | |
| 114 std::cerr << "ModelDataModel::rebuildModelSet: " << m_models.size() << " models" << std::endl; | |
| 115 } | |
| 116 | |
| 117 void | |
| 118 ModelDataModel::paneAdded() | |
| 119 { | |
| 120 rebuildModelSet(); | |
| 121 emit layoutChanged(); | |
| 122 } | |
| 123 | |
| 124 void | |
| 125 ModelDataModel::paneDeleted() | |
| 126 { | |
| 127 rebuildModelSet(); | |
| 128 emit layoutChanged(); | |
| 129 } | |
| 130 | |
| 131 void | |
| 132 ModelDataModel::paneLayerModelChanged() | |
| 133 { | |
| 134 rebuildModelSet(); | |
| 135 emit layoutChanged(); | |
| 136 } | |
| 137 | |
| 138 void | |
| 139 ModelDataModel::propertyContainerAdded(PropertyContainer *) | |
| 140 { | |
| 141 rebuildModelSet(); | |
| 142 emit layoutChanged(); | |
| 143 } | |
| 144 | |
| 145 void | |
| 146 ModelDataModel::propertyContainerRemoved(PropertyContainer *) | |
| 147 { | |
| 148 rebuildModelSet(); | |
| 149 emit layoutChanged(); | |
| 150 } | |
| 151 | |
| 152 void | |
| 153 ModelDataModel::propertyContainerSelected(PropertyContainer *) | |
| 154 { | |
| 155 } | |
| 156 | |
| 157 void | |
| 158 ModelDataModel::propertyContainerPropertyChanged(PropertyContainer *pc) | |
| 159 { | |
| 160 } | |
| 161 | |
| 162 void | |
| 163 ModelDataModel::playParametersAudibilityChanged(bool a) | |
| 164 { | |
| 165 } | |
| 166 | |
| 167 QVariant | |
| 168 ModelDataModel::data(const QModelIndex &index, int role) const | |
| 169 { | |
| 170 if (!index.isValid()) return QVariant(); | |
| 171 | |
| 172 QObject *obj = static_cast<QObject *>(index.internalPointer()); | |
| 173 int row = index.row(), col = index.column(); | |
| 174 | |
| 175 //!!! not exactly the ideal use of a std::set | |
| 176 std::set<Model *>::iterator itr = m_models.begin(); | |
| 177 for (int i = 0; i < row && itr != m_models.end(); ++i, ++itr); | |
| 178 if (itr == m_models.end()) return QVariant(); | |
| 179 | |
| 180 Model *model = *itr; | |
| 181 | |
| 182 if (role != Qt::DisplayRole) { | |
| 183 if (m_waveModelsOnly && col == m_modelNameColumn && | |
| 184 role == Qt::DecorationRole) { | |
| 185 // There is no meaningful icon for a model, in general -- | |
| 186 // the icons we have represent layer types and it would be | |
| 187 // misleading to use them for models. However, if we're | |
| 188 // only showing wave models, we use the waveform icon just | |
| 189 // for decorative purposes. | |
| 190 return QVariant(QIcon(QString(":/icons/waveform.png"))); | |
| 191 } | |
| 192 return QVariant(); | |
| 193 } | |
| 194 | |
| 195 if (col == m_modelTypeColumn) { | |
| 196 return QVariant(model->getTypeName()); | |
| 197 } else if (col == m_modelNameColumn) { | |
| 198 return QVariant(model->objectName()); | |
| 199 } else if (col == m_modelMakerColumn) { | |
| 200 return QVariant(model->getMaker()); | |
| 201 } else if (col == m_modelSourceColumn) { | |
| 202 return QVariant(model->getLocation()); | |
| 203 } | |
| 204 | |
| 205 return QVariant(); | |
| 206 } | |
| 207 | |
| 208 bool | |
| 209 ModelDataModel::setData(const QModelIndex &index, const QVariant &value, int role) | |
| 210 { | |
| 211 return false; | |
| 212 } | |
| 213 | |
| 214 Qt::ItemFlags | |
| 215 ModelDataModel::flags(const QModelIndex &index) const | |
| 216 { | |
| 217 Qt::ItemFlags flags = Qt::ItemIsEnabled; | |
| 218 return flags; | |
| 219 } | |
| 220 | |
| 221 QVariant | |
| 222 ModelDataModel::headerData(int section, | |
| 223 Qt::Orientation orientation, | |
| 224 int role) const | |
| 225 { | |
| 226 if (orientation == Qt::Horizontal && role == Qt::DisplayRole) { | |
| 227 if (section == m_modelTypeColumn) return QVariant(tr("Type")); | |
| 228 else if (section == m_modelNameColumn) return QVariant(tr("Name")); | |
| 229 else if (section == m_modelMakerColumn) return QVariant(tr("Maker")); | |
| 230 else if (section == m_modelSourceColumn) return QVariant(tr("Source")); | |
| 231 } | |
| 232 | |
| 233 return QVariant(); | |
| 234 } | |
| 235 | |
| 236 QModelIndex | |
| 237 ModelDataModel::index(int row, int column, const QModelIndex &parent) const | |
| 238 { | |
| 239 if (!parent.isValid()) { | |
| 240 if (row >= m_models.size()) return QModelIndex(); | |
| 241 return createIndex(row, column, 0); | |
| 242 } | |
| 243 | |
| 244 return QModelIndex(); | |
| 245 } | |
| 246 | |
| 247 QModelIndex | |
| 248 ModelDataModel::parent(const QModelIndex &index) const | |
| 249 { | |
| 250 return QModelIndex(); | |
| 251 } | |
| 252 | |
| 253 int | |
| 254 ModelDataModel::rowCount(const QModelIndex &parent) const | |
| 255 { | |
| 256 if (!parent.isValid()) return m_models.size(); | |
| 257 return 0; | |
| 258 } | |
| 259 | |
| 260 int | |
| 261 ModelDataModel::columnCount(const QModelIndex &parent) const | |
| 262 { | |
| 263 return m_columnCount; | |
| 264 } | |
| 265 | |
| 266 | |
| 267 | |
| 268 LayerTreeModel::LayerTreeModel(PaneStack *stack, QObject *parent) : | |
| 269 QAbstractItemModel(parent), | |
| 270 m_stack(stack) | |
| 271 { | |
| 272 m_layerNameColumn = 0; | |
| 273 m_layerVisibleColumn = 1; | |
| 274 m_layerPlayedColumn = 2; | |
| 275 m_modelNameColumn = 3; | |
| 276 m_columnCount = 4; | |
| 277 | |
| 278 connect(stack, SIGNAL(paneAdded()), this, SLOT(paneAdded())); | |
| 279 connect(stack, SIGNAL(paneAboutToBeDeleted(Pane *)), | |
| 280 this, SLOT(paneAboutToBeDeleted(Pane *))); | |
| 281 | |
| 282 for (int i = 0; i < stack->getPaneCount(); ++i) { | |
| 283 Pane *pane = stack->getPane(i); | |
| 284 if (!pane) continue; | |
| 285 connect(pane, SIGNAL(propertyContainerAdded(PropertyContainer *)), | |
| 286 this, SLOT(propertyContainerAdded(PropertyContainer *))); | |
| 287 connect(pane, SIGNAL(propertyContainerRemoved(PropertyContainer *)), | |
| 288 this, SLOT(propertyContainerRemoved(PropertyContainer *))); | |
| 289 connect(pane, SIGNAL(propertyContainerSelected(PropertyContainer *)), | |
| 290 this, SLOT(propertyContainerSelected(PropertyContainer *))); | |
| 291 connect(pane, SIGNAL(propertyContainerPropertyChanged(PropertyContainer *)), | |
| 292 this, SLOT(propertyContainerPropertyChanged(PropertyContainer *))); | |
| 293 connect(pane, SIGNAL(propertyContainerNameChanged(PropertyContainer *)), | |
| 294 this, SLOT(propertyContainerPropertyChanged(PropertyContainer *))); | |
| 295 connect(pane, SIGNAL(layerModelChanged()), | |
| 296 this, SLOT(paneLayerModelChanged())); | |
| 297 | |
| 49 for (int j = 0; j < pane->getLayerCount(); ++j) { | 298 for (int j = 0; j < pane->getLayerCount(); ++j) { | 
| 50 Layer *layer = pane->getLayer(j); | 299 Layer *layer = pane->getLayer(j); | 
| 51 if (!layer) continue; | 300 if (!layer) continue; | 
| 52 PlayParameters *params = layer->getPlayParameters(); | 301 PlayParameters *params = layer->getPlayParameters(); | 
| 53 if (!params) continue; | 302 if (!params) continue; | 
| 60 LayerTreeModel::~LayerTreeModel() | 309 LayerTreeModel::~LayerTreeModel() | 
| 61 { | 310 { | 
| 62 } | 311 } | 
| 63 | 312 | 
| 64 void | 313 void | 
| 314 LayerTreeModel::paneAdded() | |
| 315 { | |
| 316 emit layoutChanged(); | |
| 317 } | |
| 318 | |
| 319 void | |
| 320 LayerTreeModel::paneAboutToBeDeleted(Pane *pane) | |
| 321 { | |
| 322 std::cerr << "paneDeleted: " << pane << std::endl; | |
| 323 m_deletedPanes.insert(pane); | |
| 324 emit layoutChanged(); | |
| 325 } | |
| 326 | |
| 327 void | |
| 65 LayerTreeModel::propertyContainerAdded(PropertyContainer *) | 328 LayerTreeModel::propertyContainerAdded(PropertyContainer *) | 
| 66 { | 329 { | 
| 67 emit layoutChanged(); | 330 emit layoutChanged(); | 
| 68 } | 331 } | 
| 69 | 332 | 
| 73 emit layoutChanged(); | 336 emit layoutChanged(); | 
| 74 } | 337 } | 
| 75 | 338 | 
| 76 void | 339 void | 
| 77 LayerTreeModel::propertyContainerSelected(PropertyContainer *) | 340 LayerTreeModel::propertyContainerSelected(PropertyContainer *) | 
| 341 { | |
| 342 emit layoutChanged(); | |
| 343 } | |
| 344 | |
| 345 void | |
| 346 LayerTreeModel::paneLayerModelChanged() | |
| 78 { | 347 { | 
| 79 emit layoutChanged(); | 348 emit layoutChanged(); | 
| 80 } | 349 } | 
| 81 | 350 | 
| 82 void | 351 void | 
| 86 Pane *pane = m_stack->getPane(i); | 355 Pane *pane = m_stack->getPane(i); | 
| 87 if (!pane) continue; | 356 if (!pane) continue; | 
| 88 for (int j = 0; j < pane->getLayerCount(); ++j) { | 357 for (int j = 0; j < pane->getLayerCount(); ++j) { | 
| 89 if (pane->getLayer(j) == pc) { | 358 if (pane->getLayer(j) == pc) { | 
| 90 emit dataChanged(createIndex(pane->getLayerCount() - j - 1, | 359 emit dataChanged(createIndex(pane->getLayerCount() - j - 1, | 
| 91 0, pane), | 360 m_layerNameColumn, pane), | 
| 92 createIndex(pane->getLayerCount() - j - 1, | 361 createIndex(pane->getLayerCount() - j - 1, | 
| 93 3, pane)); | 362 m_modelNameColumn, pane)); | 
| 94 } | 363 } | 
| 95 } | 364 } | 
| 96 } | 365 } | 
| 97 } | 366 } | 
| 98 | 367 | 
| 114 if (layer->getPlayParameters() == params) { | 383 if (layer->getPlayParameters() == params) { | 
| 115 std::cerr << "LayerTreeModel::playParametersAudibilityChanged(" | 384 std::cerr << "LayerTreeModel::playParametersAudibilityChanged(" | 
| 116 << params << "," << a << "): row " << pane->getLayerCount() - j - 1 << ", col " << 2 << std::endl; | 385 << params << "," << a << "): row " << pane->getLayerCount() - j - 1 << ", col " << 2 << std::endl; | 
| 117 | 386 | 
| 118 emit dataChanged(createIndex(pane->getLayerCount() - j - 1, | 387 emit dataChanged(createIndex(pane->getLayerCount() - j - 1, | 
| 119 2, pane), | 388 m_layerPlayedColumn, pane), | 
| 120 createIndex(pane->getLayerCount() - j - 1, | 389 createIndex(pane->getLayerCount() - j - 1, | 
| 121 2, pane)); | 390 m_layerPlayedColumn, pane)); | 
| 122 } | 391 } | 
| 123 } | 392 } | 
| 124 } | 393 } | 
| 125 } | 394 } | 
| 126 | 395 | 
| 146 } | 415 } | 
| 147 | 416 | 
| 148 if (pane && pane->getLayerCount() > row) { | 417 if (pane && pane->getLayerCount() > row) { | 
| 149 Layer *layer = pane->getLayer(pane->getLayerCount() - row - 1); | 418 Layer *layer = pane->getLayer(pane->getLayerCount() - row - 1); | 
| 150 if (layer) { | 419 if (layer) { | 
| 151 if (col == 0) { | 420 if (col == m_layerNameColumn) { | 
| 152 switch (role) { | 421 switch (role) { | 
| 153 case Qt::DisplayRole: | 422 case Qt::DisplayRole: | 
| 154 return QVariant(layer->objectName()); | 423 return QVariant(layer->objectName()); | 
| 155 case Qt::DecorationRole: | 424 case Qt::DecorationRole: | 
| 156 return QVariant | 425 return QVariant | 
| 157 (QIcon(QString(":/icons/%1.png") | 426 (QIcon(QString(":/icons/%1.png") | 
| 158 .arg(layer->getPropertyContainerIconName()))); | 427 .arg(layer->getPropertyContainerIconName()))); | 
| 159 default: break; | 428 default: break; | 
| 160 } | 429 } | 
| 161 } else if (col == 1) { | 430 } else if (col == m_layerVisibleColumn) { | 
| 162 if (role == Qt::CheckStateRole) { | 431 if (role == Qt::CheckStateRole) { | 
| 163 return QVariant(layer->isLayerDormant(pane) ? | 432 return QVariant(layer->isLayerDormant(pane) ? | 
| 164 Qt::Unchecked : Qt::Checked); | 433 Qt::Unchecked : Qt::Checked); | 
| 165 } else if (role == Qt::TextAlignmentRole) { | 434 } else if (role == Qt::TextAlignmentRole) { | 
| 166 return QVariant(Qt::AlignHCenter); | 435 return QVariant(Qt::AlignHCenter); | 
| 167 } | 436 } | 
| 168 } else if (col == 2) { | 437 } else if (col == m_layerPlayedColumn) { | 
| 169 if (role == Qt::CheckStateRole) { | 438 if (role == Qt::CheckStateRole) { | 
| 170 PlayParameters *params = layer->getPlayParameters(); | 439 PlayParameters *params = layer->getPlayParameters(); | 
| 171 if (params) return QVariant(params->isPlayMuted() ? | 440 if (params) return QVariant(params->isPlayMuted() ? | 
| 172 Qt::Unchecked : Qt::Checked); | 441 Qt::Unchecked : Qt::Checked); | 
| 173 else return QVariant(); | 442 else return QVariant(); | 
| 174 } else if (role == Qt::TextAlignmentRole) { | 443 } else if (role == Qt::TextAlignmentRole) { | 
| 175 return QVariant(Qt::AlignHCenter); | 444 return QVariant(Qt::AlignHCenter); | 
| 176 } | 445 } | 
| 177 } else if (col == 3) { | 446 } else if (col == m_modelNameColumn) { | 
| 178 Model *model = layer->getModel(); | 447 Model *model = layer->getModel(); | 
| 179 if (model && role == Qt::DisplayRole) { | 448 if (model && role == Qt::DisplayRole) { | 
| 180 return QVariant(model->objectName()); | 449 return QVariant(model->objectName()); | 
| 181 } | 450 } | 
| 182 } | 451 } | 
| 198 if (!pane || pane->getLayerCount() <= row) return false; | 467 if (!pane || pane->getLayerCount() <= row) return false; | 
| 199 | 468 | 
| 200 Layer *layer = pane->getLayer(pane->getLayerCount() - row - 1); | 469 Layer *layer = pane->getLayer(pane->getLayerCount() - row - 1); | 
| 201 if (!layer) return false; | 470 if (!layer) return false; | 
| 202 | 471 | 
| 203 if (col == 1) { | 472 if (col == m_layerVisibleColumn) { | 
| 204 if (role == Qt::CheckStateRole) { | 473 if (role == Qt::CheckStateRole) { | 
| 205 layer->showLayer(pane, value.toInt() == Qt::Checked); | 474 layer->showLayer(pane, value.toInt() == Qt::Checked); | 
| 206 emit dataChanged(index, index); | 475 emit dataChanged(index, index); | 
| 207 return true; | 476 return true; | 
| 208 } | 477 } | 
| 209 } else if (col == 2) { | 478 } else if (col == m_layerPlayedColumn) { | 
| 210 if (role == Qt::CheckStateRole) { | 479 if (role == Qt::CheckStateRole) { | 
| 211 PlayParameters *params = layer->getPlayParameters(); | 480 PlayParameters *params = layer->getPlayParameters(); | 
| 212 if (params) { | 481 if (params) { | 
| 213 params->setPlayMuted(value.toInt() == Qt::Unchecked); | 482 params->setPlayMuted(value.toInt() == Qt::Unchecked); | 
| 214 emit dataChanged(index, index); | 483 emit dataChanged(index, index); | 
| 224 LayerTreeModel::flags(const QModelIndex &index) const | 493 LayerTreeModel::flags(const QModelIndex &index) const | 
| 225 { | 494 { | 
| 226 Qt::ItemFlags flags = Qt::ItemIsEnabled; | 495 Qt::ItemFlags flags = Qt::ItemIsEnabled; | 
| 227 if (!index.isValid()) return flags; | 496 if (!index.isValid()) return flags; | 
| 228 | 497 | 
| 229 if (index.column() == 1 || index.column() == 2) { | 498 if (index.column() == m_layerVisibleColumn || | 
| 499 index.column() == m_layerPlayedColumn) { | |
| 230 flags |= Qt::ItemIsUserCheckable; | 500 flags |= Qt::ItemIsUserCheckable; | 
| 231 } else if (index.column() == 0) { | 501 } else if (index.column() == 0) { | 
| 232 flags |= Qt::ItemIsSelectable; | 502 flags |= Qt::ItemIsSelectable; | 
| 233 } | 503 } | 
| 234 | 504 | 
| 239 LayerTreeModel::headerData(int section, | 509 LayerTreeModel::headerData(int section, | 
| 240 Qt::Orientation orientation, | 510 Qt::Orientation orientation, | 
| 241 int role) const | 511 int role) const | 
| 242 { | 512 { | 
| 243 if (orientation == Qt::Horizontal && role == Qt::DisplayRole) { | 513 if (orientation == Qt::Horizontal && role == Qt::DisplayRole) { | 
| 244 if (section == 0) return QVariant(tr("Layer")); | 514 if (section == m_layerNameColumn) return QVariant(tr("Layer")); | 
| 245 else if (section == 1) return QVariant(tr("Shown")); | 515 else if (section == m_layerVisibleColumn) return QVariant(tr("Shown")); | 
| 246 else if (section == 2) return QVariant(tr("Played")); | 516 else if (section == m_layerPlayedColumn) return QVariant(tr("Played")); | 
| 247 else if (section == 3) return QVariant(tr("Model")); | 517 else if (section == m_modelNameColumn) return QVariant(tr("Model")); | 
| 248 } | 518 } | 
| 249 | 519 | 
| 250 return QVariant(); | 520 return QVariant(); | 
| 251 } | 521 } | 
| 252 | 522 | 
| 277 | 547 | 
| 278 QModelIndex | 548 QModelIndex | 
| 279 LayerTreeModel::parent(const QModelIndex &index) const | 549 LayerTreeModel::parent(const QModelIndex &index) const | 
| 280 { | 550 { | 
| 281 QObject *obj = static_cast<QObject *>(index.internalPointer()); | 551 QObject *obj = static_cast<QObject *>(index.internalPointer()); | 
| 552 | |
| 553 if (m_deletedPanes.find(obj) != m_deletedPanes.end()) { | |
| 554 // m_deletedPanes.erase(obj); | |
| 555 return QModelIndex(); | |
| 556 } | |
| 282 | 557 | 
| 283 Pane *pane = dynamic_cast<Pane *>(obj); | 558 Pane *pane = dynamic_cast<Pane *>(obj); | 
| 284 if (pane) { | 559 if (pane) { | 
| 285 int index = m_stack->getPaneIndex(pane); | 560 int index = m_stack->getPaneIndex(pane); | 
| 286 if (index >= 0) return createIndex(index, 0, m_stack); | 561 if (index >= 0) return createIndex(index, 0, m_stack); | 
| 306 } | 581 } | 
| 307 | 582 | 
| 308 int | 583 int | 
| 309 LayerTreeModel::columnCount(const QModelIndex &parent) const | 584 LayerTreeModel::columnCount(const QModelIndex &parent) const | 
| 310 { | 585 { | 
| 311 if (!parent.isValid()) return 4; | 586 if (!parent.isValid()) return m_columnCount; | 
| 312 | 587 | 
| 313 QObject *obj = static_cast<QObject *>(parent.internalPointer()); | 588 QObject *obj = static_cast<QObject *>(parent.internalPointer()); | 
| 314 if (obj == m_stack) return 4; // row for a layer | 589 if (obj == m_stack) return m_columnCount; // row for a layer | 
| 315 | 590 | 
| 316 return 1; | 591 return 1; | 
| 317 } | 592 } | 
| 318 | 593 | 
