Skip to content

Commit

Permalink
Remove from filter model directly rather than through signals
Browse files Browse the repository at this point in the history
  • Loading branch information
bmatherly committed Oct 25, 2014
1 parent 87d8150 commit a9e2a8c
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 14 deletions.
16 changes: 8 additions & 8 deletions src/controllers/filtercontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ FilterController::FilterController(QObject* parent) : QObject(parent),
m_future = QtConcurrent::run(this, &FilterController::loadFilterMetadata);

connect(&m_attachedModel, SIGNAL(changed()), this, SLOT(handleAttachedModelChange()));
connect(&m_attachedModel, SIGNAL(rowsAboutToBeRemoved(const QModelIndex&,int,int)), this, SLOT(handleAttachedRowsAboutToBeRemoved(const QModelIndex&,int,int)));
}

void FilterController::loadFilterMetadata() {
Expand Down Expand Up @@ -122,14 +123,6 @@ void FilterController::attachFilter(int metadataIndex)
m_currentFilter.reset(filter);
}

void FilterController::removeFilter(int attachedIndex)
{
QModelIndex index = m_attachedModel.index(attachedIndex);
if (index.isValid()) {
m_attachedModel.remove(index.row());
}
}

void FilterController::setCurrentFilter(int attachedIndex)
{
if( attachedIndex == m_currentFilterIndex ) {
Expand Down Expand Up @@ -191,6 +184,13 @@ void FilterController::handleAttachedModelChange()
MLT.refreshConsumer();
}

void FilterController::handleAttachedRowsAboutToBeRemoved(const QModelIndex&, int first, int)
{
if (m_currentFilterIndex >= first) {
setCurrentFilter(-1);
}
}

void FilterController::addMetadata(QmlMetadata* meta)
{
m_metadataModel.add(meta);
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/filtercontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ class FilterController : public QObject
public slots:
void setProducer(Mlt::Producer *producer = 0);
void attachFilter(int metadataIndex);
void removeFilter(int attachedIndex);
void setCurrentFilter(int attachedIndex);
void setFadeInDuration(int duration);
void setFadeOutDuration(int duration);

private slots:
void handleAttachedModelChange();
void addMetadata(QmlMetadata*);
void handleAttachedRowsAboutToBeRemoved(const QModelIndex & parent, int first, int last);

private:
void loadFilterMetadata();
Expand Down
2 changes: 0 additions & 2 deletions src/docks/filtersdock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ FiltersDock::FiltersDock(MetadataModel* metadataModel, AttachedFiltersModel* att
QObject* root = m_qview.rootObject();
QObject::connect(root, SIGNAL(attachFilterRequested(int)),
this, SIGNAL(attachFilterRequested(int)));
QObject::connect(root, SIGNAL(removeFilterRequested(int)),
this, SIGNAL(removeFilterRequested(int)));
QObject::connect(root, SIGNAL(currentFilterRequested(int)),
this, SIGNAL(currentFilterRequested(int)));

Expand Down
1 change: 0 additions & 1 deletion src/docks/filtersdock.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ class FiltersDock : public QDockWidget

signals:
void attachFilterRequested(int metadataIndex);
void removeFilterRequested(int attachedIndex);
void currentFilterRequested(int attachedIndex);

public slots:
Expand Down
1 change: 0 additions & 1 deletion src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,6 @@ MainWindow::MainWindow()
addDockWidget(Qt::LeftDockWidgetArea, m_filtersDock);
ui->menuView->addAction(m_filtersDock->toggleViewAction());
connect(m_filtersDock, SIGNAL(attachFilterRequested(int)), m_filterController, SLOT(attachFilter(int)));
connect(m_filtersDock, SIGNAL(removeFilterRequested(int)), m_filterController, SLOT(removeFilter(int)));
connect(m_filtersDock, SIGNAL(currentFilterRequested(int)), m_filterController, SLOT(setCurrentFilter(int)));
connect(m_filtersDock->toggleViewAction(), SIGNAL(triggered(bool)), this, SLOT(onFiltersDockTriggered(bool)));
connect(ui->actionFilters, SIGNAL(triggered()), this, SLOT(onFiltersDockTriggered()));
Expand Down
4 changes: 3 additions & 1 deletion src/qml/views/filter/filterview.qml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ Rectangle {
tooltip: qsTr('Remove Selected Filter')
onClicked: {
filterConfig.source = ""
root.removeFilterRequested(attachedFilters.selectedIndex)
attachedfiltersmodel.remove(attachedFilters.selectedIndex)
root.currentFilterRequested(attachedFilters.selectedIndex)
filterConfig.source = metadata ? metadata.qmlFilePath : ""
}
}
Item {
Expand Down

0 comments on commit a9e2a8c

Please sign in to comment.