mirror of
https://github.com/clementine-player/Clementine
synced 2025-01-18 20:40:43 +01:00
gstengine: Add PipelineView class
Add ListView derivative class for displaying GstPipelineModel data. A GetSelectedIds method provides the list of selected pipelie IDs.
This commit is contained in:
parent
8d11e9ffab
commit
7d061afdc3
@ -138,6 +138,7 @@ set(SOURCES
|
|||||||
engines/gstenginepipeline.cpp
|
engines/gstenginepipeline.cpp
|
||||||
engines/gstelementdeleter.cpp
|
engines/gstelementdeleter.cpp
|
||||||
engines/gstpipelinebase.cpp
|
engines/gstpipelinebase.cpp
|
||||||
|
engines/pipelineview.cpp
|
||||||
|
|
||||||
globalsearch/digitallyimportedsearchprovider.cpp
|
globalsearch/digitallyimportedsearchprovider.cpp
|
||||||
globalsearch/globalsearch.cpp
|
globalsearch/globalsearch.cpp
|
||||||
@ -461,6 +462,7 @@ set(HEADERS
|
|||||||
engines/gstenginepipeline.h
|
engines/gstenginepipeline.h
|
||||||
engines/gstelementdeleter.h
|
engines/gstelementdeleter.h
|
||||||
engines/gstpipelinebase.h
|
engines/gstpipelinebase.h
|
||||||
|
engines/pipelineview.h
|
||||||
|
|
||||||
globalsearch/globalsearch.h
|
globalsearch/globalsearch.h
|
||||||
globalsearch/globalsearchmodel.h
|
globalsearch/globalsearchmodel.h
|
||||||
|
@ -76,3 +76,11 @@ int GstPipelineModel::FindRowById(int id) const {
|
|||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int GstPipelineModel::GetPipelineId(const QModelIndex& index) const {
|
||||||
|
const QStandardItem* item = itemFromIndex(index);
|
||||||
|
if (item != nullptr)
|
||||||
|
return item->data(Role::Role_Id).toInt();
|
||||||
|
else
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
@ -56,6 +56,10 @@ class GstPipelineModel : public QStandardItemModel {
|
|||||||
void AddPipeline(int id, const QString& name);
|
void AddPipeline(int id, const QString& name);
|
||||||
void RemovePipeline(int id);
|
void RemovePipeline(int id);
|
||||||
|
|
||||||
|
private:
|
||||||
|
friend class PipelineView;
|
||||||
|
int GetPipelineId(const QModelIndex& index) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int FindRowById(int id) const;
|
int FindRowById(int id) const;
|
||||||
|
|
||||||
|
38
src/engines/pipelineview.cpp
Normal file
38
src/engines/pipelineview.cpp
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
/* This file is part of Clementine.
|
||||||
|
Copyright 2021, Jim Broadus <jbroadus@gmail.com>
|
||||||
|
|
||||||
|
Clementine is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
Clementine is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "pipelineview.h"
|
||||||
|
|
||||||
|
#include "gstpipelinebase.h"
|
||||||
|
|
||||||
|
void PipelineView::setPipelineModel(GstPipelineModel* model) {
|
||||||
|
QListView::setModel(model);
|
||||||
|
pipeline_model_ = model;
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<int> PipelineView::GetSelectedIds() const {
|
||||||
|
QList<int> selected;
|
||||||
|
if (pipeline_model_ != nullptr) {
|
||||||
|
for (const QModelIndex& index : selectedIndexes()) {
|
||||||
|
int id = pipeline_model_->GetPipelineId(index);
|
||||||
|
if (id >= 0) {
|
||||||
|
selected << id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return selected;
|
||||||
|
}
|
39
src/engines/pipelineview.h
Normal file
39
src/engines/pipelineview.h
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
/* This file is part of Clementine.
|
||||||
|
Copyright 2021, Jim Broadus <jbroadus@gmail.com>
|
||||||
|
|
||||||
|
Clementine is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
Clementine is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef PIPELINEVIEW_H
|
||||||
|
#define PIPELINEVIEW_H
|
||||||
|
|
||||||
|
#include <QList>
|
||||||
|
#include <QListView>
|
||||||
|
|
||||||
|
class GstPipelineModel;
|
||||||
|
|
||||||
|
class PipelineView : public QListView {
|
||||||
|
Q_OBJECT;
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit PipelineView(QWidget* parent) : QListView(parent) {}
|
||||||
|
|
||||||
|
void setPipelineModel(GstPipelineModel* model);
|
||||||
|
QList<int> GetSelectedIds() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
GstPipelineModel* pipeline_model_;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // PIPELINEVIEW_H
|
Loading…
Reference in New Issue
Block a user