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 <QDebug>
#include "localprop.h"
CanvasTreeModel::CanvasTreeModel(FGCanvasGroup* root) :
@ -50,7 +52,7 @@ QVariant CanvasTreeModel::data(const QModelIndex &index, int role) const
return e->property()->value("id", QVariant("<noid>"));
case Qt::CheckStateRole:
return e->property()->value("visible", true);
return e->property()->value("visible", true).toBool() ? Qt::Checked : Qt::Unchecked;
default:
break;
@ -108,7 +110,7 @@ QModelIndex CanvasTreeModel::parent(const QModelIndex &child) 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)
@ -118,8 +120,9 @@ bool CanvasTreeModel::setData(const QModelIndex &index, const QVariant &value, i
return false;
}
qDebug() << Q_FUNC_INFO;
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);
return true;
}

View file

@ -60,8 +60,7 @@ void ElementDataModel::computeKeys()
"text" <<
"clip" << "file" << "src"
"font" << "character-size" <<
"z-index" << "visible" <<
"stroke";
"z-index" << "visible";
Q_FOREACH (QByteArray b, directProps) {
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;
}
void LocalProp::changeValue(const char *path, QVariant value)
{
LocalProp* p = getOrCreateWithPath(path);
p->_value = value;
p->valueChanged(value);
}
LocalProp *LocalProp::getOrCreateChildWithNameAndIndex(const NameIndexTuple& ni)
{

View file

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

View file

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