1
0
Fork 0

Work on Remote-Canvas

This commit is contained in:
James Turner 2016-12-27 08:56:35 +00:00
parent a42900bef5
commit 90d6911d68
5 changed files with 18 additions and 7 deletions

View file

@ -1,5 +1,7 @@
#include "canvastreemodel.h" #include "canvastreemodel.h"
#include <QDebug>
#include "localprop.h" #include "localprop.h"
CanvasTreeModel::CanvasTreeModel(FGCanvasGroup* root) : CanvasTreeModel::CanvasTreeModel(FGCanvasGroup* root) :
@ -50,7 +52,7 @@ QVariant CanvasTreeModel::data(const QModelIndex &index, int role) const
return e->property()->value("id", QVariant("<noid>")); return e->property()->value("id", QVariant("<noid>"));
case Qt::CheckStateRole: case Qt::CheckStateRole:
return e->property()->value("visible", true); return e->property()->value("visible", true).toBool() ? Qt::Checked : Qt::Unchecked;
default: default:
break; break;
@ -108,7 +110,7 @@ QModelIndex CanvasTreeModel::parent(const QModelIndex &child) const
Qt::ItemFlags CanvasTreeModel::flags(const QModelIndex &index) const Qt::ItemFlags CanvasTreeModel::flags(const QModelIndex &index) const
{ {
return QAbstractItemModel::flags(index) | Qt::ItemIsUserCheckable; return QAbstractItemModel::flags(index) | Qt::ItemIsUserCheckable | Qt::ItemIsEditable;
} }
bool CanvasTreeModel::setData(const QModelIndex &index, const QVariant &value, int role) bool CanvasTreeModel::setData(const QModelIndex &index, const QVariant &value, int role)
@ -118,8 +120,9 @@ bool CanvasTreeModel::setData(const QModelIndex &index, const QVariant &value, i
return false; return false;
} }
qDebug() << Q_FUNC_INFO;
if (role == Qt::CheckStateRole) { if (role == Qt::CheckStateRole) {
e->property()->setProperty("visible", value); e->property()->changeValue("visible", (value.toInt() == Qt::Checked));
emit dataChanged(index, index, QVector<int>() << Qt::CheckStateRole); emit dataChanged(index, index, QVector<int>() << Qt::CheckStateRole);
return true; return true;
} }

View file

@ -60,8 +60,7 @@ void ElementDataModel::computeKeys()
"text" << "text" <<
"clip" << "file" << "src" "clip" << "file" << "src"
"font" << "character-size" << "font" << "character-size" <<
"z-index" << "visible" << "z-index" << "visible";
"stroke";
Q_FOREACH (QByteArray b, directProps) { Q_FOREACH (QByteArray b, directProps) {
if (prop->hasChild(b)) { if (prop->hasChild(b)) {

View file

@ -91,6 +91,13 @@ bool LocalProp::hasChild(const char* name) const
return childWithNameAndIndex(QByteArray::fromRawData(name, strlen(name))) != nullptr; return childWithNameAndIndex(QByteArray::fromRawData(name, strlen(name))) != nullptr;
} }
void LocalProp::changeValue(const char *path, QVariant value)
{
LocalProp* p = getOrCreateWithPath(path);
p->_value = value;
p->valueChanged(value);
}
LocalProp *LocalProp::getOrCreateChildWithNameAndIndex(const NameIndexTuple& ni) LocalProp *LocalProp::getOrCreateChildWithNameAndIndex(const NameIndexTuple& ni)
{ {

View file

@ -95,6 +95,8 @@ public:
void removeChild(LocalProp* prop); void removeChild(LocalProp* prop);
bool hasChild(const char* name) const; bool hasChild(const char* name) const;
void changeValue(const char* path, QVariant value);
signals: signals:
void valueChanged(QVariant val); void valueChanged(QVariant val);

View file

@ -21,8 +21,6 @@ TemporaryWidget::TemporaryWidget(QWidget *parent) :
ui->setupUi(this); ui->setupUi(this);
connect(ui->connectButton, &QPushButton::clicked, this, &TemporaryWidget::onStartConnect); connect(ui->connectButton, &QPushButton::clicked, this, &TemporaryWidget::onStartConnect);
restoreSettings(); restoreSettings();
connect(ui->treeView->selectionModel(), &QItemSelectionModel::currentChanged, this, &TemporaryWidget::onTreeCurrentChanged);
} }
TemporaryWidget::~TemporaryWidget() TemporaryWidget::~TemporaryWidget()
@ -81,6 +79,8 @@ void TemporaryWidget::onConnected()
m_elementModel = new ElementDataModel(this); m_elementModel = new ElementDataModel(this);
ui->elementData->setModel(m_elementModel); ui->elementData->setModel(m_elementModel);
connect(ui->treeView->selectionModel(), &QItemSelectionModel::currentChanged, this, &TemporaryWidget::onTreeCurrentChanged);
FGQCanvasFontCache::instance()->setHost(ui->hostName->text(), FGQCanvasFontCache::instance()->setHost(ui->hostName->text(),
ui->portEdit->text().toInt()); ui->portEdit->text().toInt());
FGQCanvasImageLoader::instance()->setHost(ui->hostName->text(), FGQCanvasImageLoader::instance()->setHost(ui->hostName->text(),