From a92dd7fc0c24b593f49638dffa1ffe1e44c60434 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee <emmanuel.lepage@savoirfairelinux.com> Date: Sat, 12 Jul 2014 00:45:35 +0200 Subject: [PATCH] [ #51339 ] Correctly initialize the currentVideoDevice index --- src/video/videodevicemodel.cpp | 12 +++++++++++- src/video/videodevicemodel.h | 3 +++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/video/videodevicemodel.cpp b/src/video/videodevicemodel.cpp index ad170cb3..e31302e7 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 13bd1520..d50acff5 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); -- GitLab