diff --git a/utils/fgqcanvas/canvastreemodel.cpp b/utils/fgqcanvas/canvastreemodel.cpp index 077745685..7dd27728d 100644 --- a/utils/fgqcanvas/canvastreemodel.cpp +++ b/utils/fgqcanvas/canvastreemodel.cpp @@ -1,5 +1,7 @@ #include "canvastreemodel.h" +#include + #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("")); 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() << Qt::CheckStateRole); return true; } diff --git a/utils/fgqcanvas/elementdatamodel.cpp b/utils/fgqcanvas/elementdatamodel.cpp index 21d2a53d8..4627fbe6e 100644 --- a/utils/fgqcanvas/elementdatamodel.cpp +++ b/utils/fgqcanvas/elementdatamodel.cpp @@ -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)) { diff --git a/utils/fgqcanvas/localprop.cpp b/utils/fgqcanvas/localprop.cpp index a302d884f..88c5a40ff 100644 --- a/utils/fgqcanvas/localprop.cpp +++ b/utils/fgqcanvas/localprop.cpp @@ -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) { diff --git a/utils/fgqcanvas/localprop.h b/utils/fgqcanvas/localprop.h index 5096bb32a..0951c370a 100644 --- a/utils/fgqcanvas/localprop.h +++ b/utils/fgqcanvas/localprop.h @@ -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); diff --git a/utils/fgqcanvas/temporarywidget.cpp b/utils/fgqcanvas/temporarywidget.cpp index 55e73c19f..62e504ba4 100644 --- a/utils/fgqcanvas/temporarywidget.cpp +++ b/utils/fgqcanvas/temporarywidget.cpp @@ -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(),