Skip to content
Snippets Groups Projects
Commit a92dd7fc authored by Emmanuel Lepage Vallee's avatar Emmanuel Lepage Vallee
Browse files

[ #51339 ] Correctly initialize the currentVideoDevice index

parent c7870ecd
Branches
Tags
No related merge requests found
...@@ -180,7 +180,8 @@ int VideoDeviceModel::activeIndex() const ...@@ -180,7 +180,8 @@ int VideoDeviceModel::activeIndex() const
ExtendedVideoDeviceModel* ExtendedVideoDeviceModel::m_spInstance = nullptr; 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); m_Display.rect = QRect(0,0,0,0);
} }
...@@ -274,6 +275,7 @@ void ExtendedVideoDeviceModel::switchTo(const int idx) ...@@ -274,6 +275,7 @@ void ExtendedVideoDeviceModel::switchTo(const int idx)
VideoDeviceModel::instance()->index(idx-ExtendedDeviceList::__COUNT,0).data(Qt::DisplayRole).toString()); VideoDeviceModel::instance()->index(idx-ExtendedDeviceList::__COUNT,0).data(Qt::DisplayRole).toString());
break; break;
}; };
m_CurrentSelection = (ExtendedDeviceList) idx;
} }
void ExtendedVideoDeviceModel::switchTo(VideoDevice* device) void ExtendedVideoDeviceModel::switchTo(VideoDevice* device)
...@@ -294,6 +296,14 @@ VideoDevice* ExtendedVideoDeviceModel::deviceAt(const QModelIndex& idx) const ...@@ -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) void ExtendedVideoDeviceModel::setFile(const QUrl& url)
{ {
m_CurrentFile = url; m_CurrentFile = url;
......
...@@ -46,6 +46,8 @@ public: ...@@ -46,6 +46,8 @@ public:
VideoDevice* deviceAt(const QModelIndex& idx) const; VideoDevice* deviceAt(const QModelIndex& idx) const;
int activeIndex() const;
//Singleton //Singleton
static ExtendedVideoDeviceModel* instance(); static ExtendedVideoDeviceModel* instance();
private: private:
...@@ -67,6 +69,7 @@ private: ...@@ -67,6 +69,7 @@ private:
static ExtendedVideoDeviceModel* m_spInstance; static ExtendedVideoDeviceModel* m_spInstance;
QUrl m_CurrentFile; QUrl m_CurrentFile;
Display m_Display; Display m_Display;
int m_CurrentSelection;
public Q_SLOTS: public Q_SLOTS:
void switchTo(const QModelIndex& idx); void switchTo(const QModelIndex& idx);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment