diff --git a/src/video/videodevicemodel.cpp b/src/video/videodevicemodel.cpp index ad170cb3b1f49bb1896712b527691ea88aef4afb..e31302e7ca0198d165925d4652f526a4c026bade 100644 --- a/src/video/videodevicemodel.cpp +++ b/src/video/videodevicemodel.cpp @@ -180,7 +180,8 @@ int VideoDeviceModel::activeIndex() const ExtendedVideoDeviceModel* ExtendedVideoDeviceModel::m_spInstance = nullptr; -ExtendedVideoDeviceModel::ExtendedVideoDeviceModel() : QAbstractListModel(QCoreApplication::instance()) +ExtendedVideoDeviceModel::ExtendedVideoDeviceModel() : QAbstractListModel(QCoreApplication::instance()), +m_CurrentSelection(-1) { m_Display.rect = QRect(0,0,0,0); } @@ -274,6 +275,7 @@ void ExtendedVideoDeviceModel::switchTo(const int idx) VideoDeviceModel::instance()->index(idx-ExtendedDeviceList::__COUNT,0).data(Qt::DisplayRole).toString()); break; }; + m_CurrentSelection = (ExtendedDeviceList) idx; } void ExtendedVideoDeviceModel::switchTo(VideoDevice* device) @@ -294,6 +296,14 @@ VideoDevice* ExtendedVideoDeviceModel::deviceAt(const QModelIndex& idx) const }; } +int ExtendedVideoDeviceModel::activeIndex() const +{ + if (m_CurrentSelection == -1) { + return ExtendedDeviceList::__COUNT + VideoDeviceModel::instance()->activeIndex(); + } + return m_CurrentSelection; +} + void ExtendedVideoDeviceModel::setFile(const QUrl& url) { m_CurrentFile = url; diff --git a/src/video/videodevicemodel.h b/src/video/videodevicemodel.h index 13bd1520b34c4a01aebfed783a9c632f602367ba..d50acff52da39c3ac9c7e757ee77f8cd6538cb87 100644 --- a/src/video/videodevicemodel.h +++ b/src/video/videodevicemodel.h @@ -46,6 +46,8 @@ public: VideoDevice* deviceAt(const QModelIndex& idx) const; + int activeIndex() const; + //Singleton static ExtendedVideoDeviceModel* instance(); private: @@ -67,6 +69,7 @@ private: static ExtendedVideoDeviceModel* m_spInstance; QUrl m_CurrentFile; Display m_Display; + int m_CurrentSelection; public Q_SLOTS: void switchTo(const QModelIndex& idx);