Skip to content
Snippets Groups Projects
Commit ee1f6b09 authored by Andreas Traczyk's avatar Andreas Traczyk Committed by Kateryna Kostiuk
Browse files

video models: add a way to set resolution and rate simultaneously

Change-Id: I5c6e4e4733a452ff770c1ac4dbe997cb568c2b41
parent 1a5f54e9
Branches
No related tags found
No related merge requests found
......@@ -19,6 +19,7 @@
//Ring
#include "resolution.h"
#include "rate.h"
#include "device.h"
#include "../dbus/videomanager.h"
#include "../private/videochannel_p.h"
......@@ -81,7 +82,7 @@ bool Video::Channel::setActiveResolution(int idx)
bool Video::Channel::setActiveResolution(Video::Resolution* res) {
if ((!res) || d_ptr->m_lValidResolutions.indexOf(res) == -1 || res->name().isEmpty()) {
qWarning() << "Invalid active resolution" << (res?res->name():"NULL");
qWarning() << "Invalid active resolution: " << (res?res->name():"NULL");
return false;
}
......@@ -93,6 +94,23 @@ bool Video::Channel::setActiveResolution(Video::Resolution* res) {
return true;
}
bool Video::Channel::setActiveMode(int resIndex, int rateIndex) {
if (resIndex < 0 || resIndex >= d_ptr->m_lValidResolutions.size()) return false;
auto res = d_ptr->m_lValidResolutions[resIndex];
if (rateIndex < 0 || rateIndex >= res->validRates().size()) return false;
auto rate = res->validRates()[rateIndex];
if (d_ptr->m_pCurrentResolution == res &&
res->activeRate() == rate) {
qWarning() << "Mode already set: " << (res ? res->name() : "NULL") << (rate ? rate->name() : "NULL");
return false;
}
d_ptr->m_pCurrentResolution = res;
d_ptr->m_pCurrentResolution->setActiveRate(rate);
return true;
}
Video::Resolution* Video::Channel::activeResolution()
{
//If it is the current device, then there is "current" resolution
......
......@@ -25,6 +25,7 @@
//Ring
namespace Video {
class Resolution;
class Rate;
class Device;
}
class VideoChannelPrivate;
......@@ -46,6 +47,8 @@ public:
bool setActiveResolution(Video::Resolution* res);
bool setActiveResolution(int idx);
bool setActiveMode(int resIndex, int rateIndex);
//Model
virtual QVariant data ( const QModelIndex& index, int role = Qt::DisplayRole ) const override;
virtual int rowCount ( const QModelIndex& parent = QModelIndex() ) const override;
......
......@@ -89,7 +89,7 @@ const QList<Video::Rate*> Video::Resolution::validRates() const {
bool Video::Resolution::setActiveRate(Video::Rate* rate) {
if (!rate || (d_ptr->m_lValidRates.indexOf(rate) == -1)) {
qWarning() << "Trying to set an invalid rate" << rate;
qWarning() << "Trying to set an invalid rate: " << rate->name();
return false;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment