20 #include "base/PlayParameters.h" 23 #include "data/model/Model.h" 24 #include "data/model/WaveFileModel.h" 32 QAbstractItemModel(parent),
34 m_waveModelsOnly(waveModelsOnly)
64 connect(pane, SIGNAL(propertyContainerNameChanged(PropertyContainer *)),
66 connect(pane, SIGNAL(layerModelChanged()),
80 std::set<Model *> unfound =
m_models;
96 if (!dynamic_cast<WaveFileModel *>(model))
continue;
100 connect(model, SIGNAL(aboutToBeDeleted()),
104 unfound.erase(model);
109 for (std::set<Model *>::iterator i = unfound.begin();
110 i != unfound.end(); ++i) {
114 SVDEBUG <<
"ModelMetadataModel::rebuildModelSet: " <<
m_models.size() <<
" models" << endl;
121 emit layoutChanged();
128 emit layoutChanged();
135 emit layoutChanged();
142 emit layoutChanged();
149 emit layoutChanged();
170 if (!
index.isValid())
return QVariant();
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();
182 if (role != Qt::DisplayRole) {
184 role == Qt::DecorationRole) {
190 return QVariant(QIcon(QString(
":/icons/waveform.png")));
196 return QVariant(model->getTypeName());
198 return QVariant(model->objectName());
200 return QVariant(model->getMaker());
202 return QVariant(model->getLocation());
217 Qt::ItemFlags
flags = Qt::ItemIsEnabled;
223 Qt::Orientation orientation,
226 if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
240 if (row >= (
int)
m_models.size())
return QModelIndex();
241 return createIndex(row, column, (
void *)0);
244 return QModelIndex();
250 return QModelIndex();
269 QAbstractItemModel(parent),
293 connect(pane, SIGNAL(propertyContainerNameChanged(PropertyContainer *)),
295 connect(pane, SIGNAL(layerModelChanged()),
300 if (!layer)
continue;
302 if (!params)
continue;
303 connect(params, SIGNAL(playAudibleChanged(
bool)),
316 emit layoutChanged();
322 cerr <<
"paneDeleted: " << pane << endl;
324 emit layoutChanged();
330 emit layoutChanged();
336 emit layoutChanged();
342 emit layoutChanged();
348 emit layoutChanged();
371 PlayParameters *params = dynamic_cast<PlayParameters *>(sender());
374 SVDEBUG <<
"LayerTreeModel::playParametersAudibilityChanged(" 375 << params <<
"," << a <<
")" << endl;
382 if (!layer)
continue;
384 SVDEBUG <<
"LayerTreeModel::playParametersAudibilityChanged(" 385 << params <<
"," << a <<
"): row " << pane->
getLayerCount() - j - 1 <<
", col " << 2 << endl;
399 if (!
index.isValid())
return QVariant();
401 QObject *obj = static_cast<QObject *>(
index.internalPointer());
404 Pane *pane = dynamic_cast<Pane *>(obj);
406 if (col == 0 && row < m_stack->getPaneCount()) {
408 case Qt::DisplayRole:
409 return QVariant(QString(
"Pane %1").arg(row + 1));
410 case Qt::DecorationRole:
411 return QVariant(QIcon(QString(
":/icons/pane.png")));
422 case Qt::DisplayRole:
423 return QVariant(layer->objectName());
424 case Qt::DecorationRole:
426 (QIcon(QString(
":/icons/%1.png")
431 if (role == Qt::CheckStateRole) {
433 Qt::Unchecked : Qt::Checked);
434 }
else if (role == Qt::TextAlignmentRole) {
435 return QVariant(Qt::AlignHCenter);
438 if (role == Qt::CheckStateRole) {
440 if (params)
return QVariant(params->isPlayMuted() ?
441 Qt::Unchecked : Qt::Checked);
442 else return QVariant();
443 }
else if (role == Qt::TextAlignmentRole) {
444 return QVariant(Qt::AlignHCenter);
448 if (model && role == Qt::DisplayRole) {
449 return QVariant(model->objectName());
461 if (!
index.isValid())
return false;
463 QObject *obj = static_cast<QObject *>(
index.internalPointer());
466 Pane *pane = dynamic_cast<Pane *>(obj);
470 if (!layer)
return false;
473 if (role == Qt::CheckStateRole) {
474 layer->
showLayer(pane, value.toInt() == Qt::Checked);
479 if (role == Qt::CheckStateRole) {
482 params->setPlayMuted(value.toInt() == Qt::Unchecked);
495 Qt::ItemFlags
flags = Qt::ItemIsEnabled;
500 flags |= Qt::ItemIsUserCheckable;
501 }
else if (
index.column() == 0) {
502 flags |= Qt::ItemIsSelectable;
510 Qt::Orientation orientation,
513 if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
534 return createIndex(row, column,
m_stack);
537 QObject *obj = static_cast<QObject *>(
parent.internalPointer());
541 if (!pane ||
parent.column() > 0)
return QModelIndex();
542 return createIndex(row, column, pane);
545 return QModelIndex();
551 QObject *obj = static_cast<QObject *>(
index.internalPointer());
555 return QModelIndex();
558 Pane *pane = dynamic_cast<Pane *>(obj);
564 return QModelIndex();
572 QObject *obj = static_cast<QObject *>(
parent.internalPointer());
576 if (!pane ||
parent.column() > 0)
return 0;
588 QObject *obj = static_cast<QObject *>(
parent.internalPointer());
The base class for visual representations of the data found in a Model.
Qt::ItemFlags flags(const QModelIndex &index) const
std::set< QObject * > m_deletedPanes
void propertyContainerRemoved(PropertyContainer *)
void showLayer(View *, bool show)
virtual int getLayerCount() const
Return the number of layers, regardless of whether visible or dormant, i.e.
LayerTreeModel(PaneStack *stack, QObject *parent=0)
virtual ~LayerTreeModel()
void propertyContainerSelected(PropertyContainer *)
int columnCount(const QModelIndex &parent=QModelIndex()) const
int getPaneIndex(Pane *pane)
void propertyContainerPropertyChanged(PropertyContainer *)
void propertyContainerAdded(PropertyContainer *)
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
virtual QString getPropertyContainerIconName() const
virtual Layer * getLayer(int n)
Return the nth layer, counted in stacking order.
QVariant data(const QModelIndex &index, int role) const
virtual const Model * getModel() const =0
QModelIndex parent(const QModelIndex &index) const
void playParametersAudibilityChanged(bool)
void paneAboutToBeDeleted(Pane *)
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
virtual PlayParameters * getPlayParameters()
bool setData(const QModelIndex &index, const QVariant &value, int role)
virtual bool isLayerDormant(const View *v) const
Return whether the layer is dormant (i.e.
void paneLayerModelChanged()
int rowCount(const QModelIndex &parent=QModelIndex()) const