gstengine: Add a model for pipelines
Provide GstPipelineModel for displaying lists of GstPipelineBase instances.
This commit is contained in:
parent
a7a32b08b6
commit
befaacebf9
|
@ -48,3 +48,31 @@ void GstPipelineBase::DumpGraph() {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GstPipelineModel::GstPipelineModel(QObject* parent)
|
||||||
|
: QStandardItemModel(parent) {}
|
||||||
|
|
||||||
|
void GstPipelineModel::AddPipeline(int id, const QString& name) {
|
||||||
|
QStandardItem* item = new QStandardItem();
|
||||||
|
item->setData(name, Qt::DisplayRole);
|
||||||
|
item->setData(id, Role::Role_Id);
|
||||||
|
item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
||||||
|
appendRow(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GstPipelineModel::RemovePipeline(int id) {
|
||||||
|
int row = FindRowById(id);
|
||||||
|
if (row < 0) {
|
||||||
|
qLog(Warning) << "Did not find pipeline" << id;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
removeRow(row);
|
||||||
|
}
|
||||||
|
|
||||||
|
int GstPipelineModel::FindRowById(int id) {
|
||||||
|
for (int i = 0; i < rowCount(); i++) {
|
||||||
|
if (item(i)->data(Role::Role_Id).toInt() == id) return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include <gst/gst.h>
|
#include <gst/gst.h>
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
#include <QStandardItemModel>
|
||||||
|
|
||||||
class GstPipelineBase : public QObject {
|
class GstPipelineBase : public QObject {
|
||||||
public:
|
public:
|
||||||
|
@ -47,4 +48,18 @@ class GstPipelineBase : public QObject {
|
||||||
const int id_;
|
const int id_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class GstPipelineModel : public QStandardItemModel {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit GstPipelineModel(QObject* parent = nullptr);
|
||||||
|
void AddPipeline(int id, const QString& name);
|
||||||
|
void RemovePipeline(int id);
|
||||||
|
|
||||||
|
private:
|
||||||
|
int FindRowById(int id) const;
|
||||||
|
|
||||||
|
enum Role { Role_Id = Qt::UserRole + 1 };
|
||||||
|
};
|
||||||
|
|
||||||
#endif // GSTPIPELINEBASE_H
|
#endif // GSTPIPELINEBASE_H
|
||||||
|
|
Loading…
Reference in New Issue