From 9a9de81e1c9fe77fae92cd8ec2c52e98448ba7b1 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Thu, 11 Jan 2024 16:42:54 -0500 Subject: [PATCH] Split custom attributes frame/table --- forms/customattributesframe.ui | 75 ++++++++++++ forms/mainwindow.ui | 6 +- include/ui/customattributesframe.h | 32 ++++++ include/ui/customattributestable.h | 15 +-- include/ui/eventframes.h | 2 +- porymap.pro | 7 +- src/editor.cpp | 4 +- src/mainwindow.cpp | 14 +-- src/ui/customattributesframe.cpp | 26 +++++ src/ui/customattributestable.cpp | 178 ++++++++++++----------------- src/ui/eventframes.cpp | 18 +-- 11 files changed, 239 insertions(+), 138 deletions(-) create mode 100644 forms/customattributesframe.ui create mode 100644 include/ui/customattributesframe.h create mode 100644 src/ui/customattributesframe.cpp diff --git a/forms/customattributesframe.ui b/forms/customattributesframe.ui new file mode 100644 index 00000000..7c8a1e70 --- /dev/null +++ b/forms/customattributesframe.ui @@ -0,0 +1,75 @@ + + + CustomAttributesFrame + + + + 0 + 0 + 400 + 300 + + + + + + + Delete + + + + + + + + + + Add + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Custom Attributes + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + CustomAttributesTable + QTableWidget +
customattributestable.h
+
+
+ + +
diff --git a/forms/mainwindow.ui b/forms/mainwindow.ui index fff61cd4..eeced86f 100644 --- a/forms/mainwindow.ui +++ b/forms/mainwindow.ui @@ -2383,7 +2383,7 @@ - + 0 @@ -3324,9 +3324,9 @@
mapview.h
- CustomAttributesTable + CustomAttributesFrame QFrame -
customattributestable.h
+
customattributesframe.h
1
diff --git a/include/ui/customattributesframe.h b/include/ui/customattributesframe.h new file mode 100644 index 00000000..bfc88c93 --- /dev/null +++ b/include/ui/customattributesframe.h @@ -0,0 +1,32 @@ +#ifndef CUSTOMATTRIBUTESFRAME_H +#define CUSTOMATTRIBUTESFRAME_H + +/* + The frame containing the Custom Attributes table and its Add/Delete buttons. + Shared by the map's Header tab and Events. +*/ + +#include "customattributestable.h" + +#include +#include + +namespace Ui { +class CustomAttributesFrame; +} + +class CustomAttributesFrame : public QFrame +{ + Q_OBJECT + +public: + explicit CustomAttributesFrame(QWidget *parent = nullptr); + ~CustomAttributesFrame() {}; + + CustomAttributesTable *table; + +private: + Ui::CustomAttributesFrame *ui; +}; + +#endif // CUSTOMATTRIBUTESFRAME_H diff --git a/include/ui/customattributestable.h b/include/ui/customattributestable.h index dfcce05c..4641e10d 100644 --- a/include/ui/customattributestable.h +++ b/include/ui/customattributestable.h @@ -1,22 +1,23 @@ #ifndef CUSTOMATTRIBUTESTABLE_H #define CUSTOMATTRIBUTESTABLE_H -#include "events.h" #include -#include +#include #include -class CustomAttributesTable : public QFrame +class CustomAttributesTable : public QTableWidget { Q_OBJECT public: explicit CustomAttributesTable(QWidget *parent = nullptr); - ~CustomAttributesTable(); + ~CustomAttributesTable() {}; QMap getAttributes() const; void setAttributes(const QMap attributes); + void addNewAttribute(const QString &key, QJsonValue value, bool setAsDefault); + bool deleteSelectedAttributes(); QSet keys() const; QSet defaultKeys() const; @@ -29,9 +30,10 @@ signals: void defaultSet(QString key, QJsonValue value); void defaultRemoved(QString key); -private: - QTableWidget *table; +protected: + void resizeEvent(QResizeEvent *event); +private: QSet m_keys; // All keys currently in the table QSet m_defaultKeys; // All keys that are in this table by default (whether or not they're present) QSet m_restrictedKeys; // All keys not allowed in the table @@ -39,7 +41,6 @@ private: QPair getAttribute(int row) const; int addAttribute(const QString &key, QJsonValue value); void removeAttribute(const QString &key); - bool deleteSelectedAttributes(); void setDefaultAttribute(const QString &key, QJsonValue value); void unsetDefaultAttribute(const QString &key); void resizeVertically(); diff --git a/include/ui/eventframes.h b/include/ui/eventframes.h index 8dbb76ea..ba102da9 100644 --- a/include/ui/eventframes.h +++ b/include/ui/eventframes.h @@ -50,7 +50,7 @@ public: QFrame *frame_contents; QVBoxLayout *layout_contents; - CustomAttributesTable *custom_attributes; + CustomAttributesFrame *custom_attributes; protected: bool populated = false; diff --git a/porymap.pro b/porymap.pro index 3ed1480f..dd46ccd8 100644 --- a/porymap.pro +++ b/porymap.pro @@ -44,6 +44,7 @@ SOURCES += src/core/block.cpp \ src/scriptapi/scripting.cpp \ src/ui/aboutporymap.cpp \ src/ui/customattributesdialog.cpp \ + src/ui/customattributestable.cpp \ src/ui/customscriptseditor.cpp \ src/ui/customscriptslistitem.cpp \ src/ui/draggablepixmapitem.cpp \ @@ -57,7 +58,7 @@ SOURCES += src/core/block.cpp \ src/ui/regionmaplayoutpixmapitem.cpp \ src/ui/regionmapentriespixmapitem.cpp \ src/ui/cursortilerect.cpp \ - src/ui/customattributestable.cpp \ + src/ui/customattributesframe.cpp \ src/ui/eventframes.cpp \ src/ui/filterchildrenproxymodel.cpp \ src/ui/graphicsview.cpp \ @@ -136,6 +137,7 @@ HEADERS += include/core/block.h \ include/lib/orderedjson.h \ include/ui/aboutporymap.h \ include/ui/customattributesdialog.h \ + include/ui/customattributestable.h \ include/ui/customscriptseditor.h \ include/ui/customscriptslistitem.h \ include/ui/draggablepixmapitem.h \ @@ -148,7 +150,7 @@ HEADERS += include/core/block.h \ include/ui/regionmaplayoutpixmapitem.h \ include/ui/regionmapentriespixmapitem.h \ include/ui/cursortilerect.h \ - include/ui/customattributestable.h \ + include/ui/customattributesframe.h \ include/ui/eventframes.h \ include/ui/filterchildrenproxymodel.h \ include/ui/graphicsview.h \ @@ -201,6 +203,7 @@ HEADERS += include/core/block.h \ include/ui/uintspinbox.h FORMS += forms/mainwindow.ui \ + forms/customattributesframe.ui \ forms/prefabcreationdialog.ui \ forms/prefabframe.ui \ forms/tileseteditor.ui \ diff --git a/src/editor.cpp b/src/editor.cpp index d9eea176..fe67bcb8 100644 --- a/src/editor.cpp +++ b/src/editor.cpp @@ -11,7 +11,7 @@ #include "editcommands.h" #include "config.h" #include "scripting.h" -#include "customattributestable.h" +#include "customattributesframe.h" #include #include #include @@ -1953,7 +1953,7 @@ void Editor::toggleBorderVisibility(bool visible, bool enableScriptCallback) void Editor::updateCustomMapHeaderValues() { - map->customHeaders = ui->mapCustomAttributesTable->getAttributes(); + map->customHeaders = ui->mapCustomAttributesFrame->table->getAttributes(); emit editedMapData(); } diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index e2f29b2d..728d68ca 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -8,7 +8,7 @@ #include "eventframes.h" #include "bordermetatilespixmapitem.h" #include "currentselectedmetatilespixmapitem.h" -#include "customattributestable.h" +#include "customattributesframe.h" #include "scripting.h" #include "adjustingstackedwidget.h" #include "draggablepixmapitem.h" @@ -303,22 +303,22 @@ void MainWindow::initEditor() { }); // Connect the Custom Attributes table on the Header tab - connect(ui->mapCustomAttributesTable, &CustomAttributesTable::edited, [this]() { + connect(ui->mapCustomAttributesFrame->table, &CustomAttributesTable::edited, [this]() { this->markMapEdited(); this->editor->updateCustomMapHeaderValues(); }); - connect(ui->mapCustomAttributesTable, &CustomAttributesTable::defaultSet, [](QString key, QJsonValue value) { + connect(ui->mapCustomAttributesFrame->table, &CustomAttributesTable::defaultSet, [](QString key, QJsonValue value) { projectConfig.insertDefaultMapCustomAttribute(key, value); }); - connect(ui->mapCustomAttributesTable, &CustomAttributesTable::defaultRemoved, [](QString key) { + connect(ui->mapCustomAttributesFrame->table, &CustomAttributesTable::defaultRemoved, [](QString key) { projectConfig.removeDefaultMapCustomAttribute(key); }); } void MainWindow::resetMapCustomAttributesTable() { QStringList keys = projectConfig.getDefaultMapCustomAttributes().keys(); - ui->mapCustomAttributesTable->setDefaultKeys(QSet(keys.begin(), keys.end())); - ui->mapCustomAttributesTable->setRestrictedKeys(Project::getTopLevelMapFields()); + ui->mapCustomAttributesFrame->table->setDefaultKeys(QSet(keys.begin(), keys.end())); + ui->mapCustomAttributesFrame->table->setRestrictedKeys(Project::getTopLevelMapFields()); } void MainWindow::initMiscHeapObjects() { @@ -867,7 +867,7 @@ void MainWindow::displayMapProperties() { ui->checkBox_AllowEscaping->setChecked(map->allowEscaping); ui->spinBox_FloorNumber->setValue(map->floorNumber); - ui->mapCustomAttributesTable->setAttributes(map->customHeaders); + ui->mapCustomAttributesFrame->table->setAttributes(map->customHeaders); } void MainWindow::on_comboBox_Song_currentTextChanged(const QString &song) diff --git a/src/ui/customattributesframe.cpp b/src/ui/customattributesframe.cpp new file mode 100644 index 00000000..8b28ad6b --- /dev/null +++ b/src/ui/customattributesframe.cpp @@ -0,0 +1,26 @@ +#include "customattributesframe.h" +#include "ui_customattributesframe.h" +#include "customattributesdialog.h" +#include +#include +#include + +CustomAttributesFrame::CustomAttributesFrame(QWidget *parent) : + QFrame(parent), + ui(new Ui::CustomAttributesFrame) +{ + ui->setupUi(this); + + this->table = ui->tableWidget; + + // Connect the "Add" button + connect(ui->button_Add, &QPushButton::clicked, [this]() { + CustomAttributesDialog dialog(this->table); + dialog.exec(); + }); + + // Connect the "Delete" button + connect(ui->button_Delete, &QPushButton::clicked, [this]() { + this->table->deleteSelectedAttributes(); + }); +} diff --git a/src/ui/customattributestable.cpp b/src/ui/customattributestable.cpp index d5591930..bd17b8c4 100644 --- a/src/ui/customattributestable.cpp +++ b/src/ui/customattributestable.cpp @@ -1,11 +1,7 @@ #include "customattributestable.h" #include "customattributesdialog.h" #include "parseutil.h" -#include #include -#include -#include -#include #include #include @@ -16,74 +12,37 @@ enum Column { }; CustomAttributesTable::CustomAttributesTable(QWidget *parent) : - QFrame(parent) + QTableWidget(parent) { - this->setAttribute(Qt::WA_DeleteOnClose); + this->setColumnCount(Column::Count); + this->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel); + this->setHorizontalHeaderLabels(QStringList({"Key", "Value"})); + this->horizontalHeader()->setStretchLastSection(true); + this->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive); + //this->horizontalHeader()->setMaximumSectionSize(this->horizontalHeader()->length()); // TODO + this->horizontalHeader()->setVisible(false); + this->verticalHeader()->setVisible(false); - QVBoxLayout *layout = new QVBoxLayout(this); - QLabel *label = new QLabel("Custom Attributes"); - layout->addWidget(label); - - QFrame *buttonsFrame = new QFrame(this); - buttonsFrame->setLayout(new QHBoxLayout()); - QPushButton *addButton = new QPushButton(this); - QPushButton *deleteButton = new QPushButton(this); - addButton->setText("Add"); - deleteButton->setText("Delete"); - buttonsFrame->layout()->addWidget(addButton); - buttonsFrame->layout()->addWidget(deleteButton); - buttonsFrame->layout()->addItem(new QSpacerItem(1, 1, QSizePolicy::Expanding, QSizePolicy::Fixed)); - buttonsFrame->layout()->setContentsMargins(0, 0, 0, 0); - layout->addWidget(buttonsFrame); - - this->table = new QTableWidget(this); - this->table->setColumnCount(Column::Count); - this->table->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel); - this->table->setHorizontalHeaderLabels(QStringList({"Key", "Value"})); - this->table->horizontalHeader()->setStretchLastSection(true); - this->table->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive); - //this->table->horizontalHeader()->setMaximumSectionSize(this->table->horizontalHeader()->length()); // TODO - this->table->horizontalHeader()->setVisible(false); - this->table->verticalHeader()->setVisible(false); - layout->addWidget(this->table); - layout->addStretch(1); - - // Connect the "Add" button - connect(addButton, &QPushButton::clicked, [this]() { - CustomAttributesDialog dialog(this); - if (dialog.exec() == QDialog::Accepted) { - emit this->edited(); - } - }); - - // Connect the "Delete" button - connect(deleteButton, &QPushButton::clicked, [this]() { - if (this->deleteSelectedAttributes()) { - emit this->edited(); - } - }); - - connect(this->table, &QTableWidget::cellChanged, [this]() { - emit this->edited(); - }); + connect(this, &QTableWidget::cellChanged, this, &CustomAttributesTable::edited); // Key cells are uneditable, but users should be allowed to select one and press delete to remove the row. // Adding the "Selectable" flag to the Key cell changes its appearance to match the Value cell, which // makes it confusing that you can't edit the Key cell. To keep the uneditable appearance and allow // deleting rows by selecting Key cells, we select the full row when a Key cell is selected. - connect(this->table, &QTableWidget::cellClicked, [this](int row, int column) { + connect(this, &QTableWidget::cellClicked, [this](int row, int column) { if (column == Column::Key) { - this->table->selectRow(row); + this->selectRow(row); } }); // Double clicking the Key cell will bring up the dialog window to edit all the attribute's properties - connect(this->table, &QTableWidget::cellDoubleClicked, [this](int row, int column) { + connect(this, &QTableWidget::cellDoubleClicked, [this](int row, int column) { if (column == Column::Key) { // Get cell data auto keyValuePair = this->getAttribute(row); auto key = keyValuePair.first; + // TODO: This dialog is confusing if the name is changed // Create dialog CustomAttributesDialog dialog(this); dialog.setInput(key, keyValuePair.second, this->m_defaultKeys.contains(key)); @@ -94,32 +53,9 @@ CustomAttributesTable::CustomAttributesTable(QWidget *parent) : }); } -CustomAttributesTable::~CustomAttributesTable() -{ -} - -void CustomAttributesTable::resizeVertically() { - int height = 0; - for (int i = 0; i < this->table->rowCount(); i++) { - height += this->table->rowHeight(i); - } - - // Header disappears if there are no entries - if (this->table->rowCount() == 0) { - this->table->horizontalHeader()->setVisible(false); - } else { - this->table->horizontalHeader()->setVisible(true); - height += this->table->horizontalHeader()->height() + 2; - } - - this->table->setMinimumHeight(height); - this->table->setMaximumHeight(height); - this->updateGeometry(); -} - QMap CustomAttributesTable::getAttributes() const { QMap fields; - for (int row = 0; row < this->table->rowCount(); row++) { + for (int row = 0; row < this->rowCount(); row++) { auto keyValuePair = this->getAttribute(row); if (!keyValuePair.first.isEmpty()) fields[keyValuePair.first] = keyValuePair.second; @@ -128,7 +64,7 @@ QMap CustomAttributesTable::getAttributes() const { } QPair CustomAttributesTable::getAttribute(int row) const { - auto keyItem = this->table->item(row, Column::Key); + auto keyItem = this->item(row, Column::Key); if (!keyItem) return QPair(); @@ -137,22 +73,22 @@ QPair CustomAttributesTable::getAttribute(int row) const { QJsonValue value; if (type == QJsonValue::String) { - value = QJsonValue(this->table->item(row, Column::Value)->text()); + value = QJsonValue(this->item(row, Column::Value)->text()); } else if (type == QJsonValue::Double) { - auto spinBox = static_cast(this->table->cellWidget(row, Column::Value)); + auto spinBox = static_cast(this->cellWidget(row, Column::Value)); value = QJsonValue(spinBox->value()); } else if (type == QJsonValue::Bool) { - value = QJsonValue(this->table->item(row, Column::Value)->checkState() == Qt::Checked); + value = QJsonValue(this->item(row, Column::Value)->checkState() == Qt::Checked); } else { // All other types will just be preserved - value = this->table->item(row, Column::Value)->data(Qt::UserRole).toJsonValue(); + value = this->item(row, Column::Value)->data(Qt::UserRole).toJsonValue(); } return QPair(keyItem->text(), value); } int CustomAttributesTable::addAttribute(const QString &key, QJsonValue value) { - const QSignalBlocker blocker(this->table); + const QSignalBlocker blocker(this); // Certain key names cannot be used (if they would overwrite a field used outside this table) if (this->m_restrictedKeys.contains(key)) @@ -163,8 +99,8 @@ int CustomAttributesTable::addAttribute(const QString &key, QJsonValue value) { this->removeAttribute(key); // Add new row - int rowIndex = this->table->rowCount(); - this->table->insertRow(rowIndex); + int rowIndex = this->rowCount(); + this->insertRow(rowIndex); QJsonValue::Type type = value.type(); @@ -174,37 +110,37 @@ int CustomAttributesTable::addAttribute(const QString &key, QJsonValue value) { keyItem->setData(Qt::UserRole, type); // Record the type for writing to the file keyItem->setTextAlignment(Qt::AlignCenter); keyItem->setToolTip(key); // Display name as tool tip in case it's too long to see in the cell - this->table->setItem(rowIndex, Column::Key, keyItem); + this->setItem(rowIndex, Column::Key, keyItem); // Add value to table switch (type) { case QJsonValue::String: { // Add a regular cell item for editing text - this->table->setItem(rowIndex, Column::Value, new QTableWidgetItem(ParseUtil::jsonToQString(value))); + this->setItem(rowIndex, Column::Value, new QTableWidgetItem(ParseUtil::jsonToQString(value))); break; } case QJsonValue::Double: { // Add a spin box for editing number values - auto spinBox = new QSpinBox(this->table); + auto spinBox = new QSpinBox(this); spinBox->setMinimum(INT_MIN); spinBox->setMaximum(INT_MAX); spinBox->setValue(ParseUtil::jsonToInt(value)); // This connection will be handled by QTableWidget::cellChanged for other cell types connect(spinBox, QOverload::of(&QSpinBox::valueChanged), [this]() { emit this->edited(); }); - this->table->setCellWidget(rowIndex, Column::Value, spinBox); + this->setCellWidget(rowIndex, Column::Value, spinBox); break; } case QJsonValue::Bool: { // Add a checkable cell item for editing bools auto valueItem = new QTableWidgetItem(""); valueItem->setCheckState(value.toBool() ? Qt::Checked : Qt::Unchecked); valueItem->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsSelectable); - this->table->setItem(rowIndex, Column::Value, valueItem); + this->setItem(rowIndex, Column::Value, valueItem); break; } default: { // Arrays, objects, or null/undefined values cannot be edited auto valueItem = new QTableWidgetItem("This value cannot be edited from this table"); valueItem->setFlags(Qt::NoItemFlags); valueItem->setData(Qt::UserRole, value); // Preserve the value for writing to the file - this->table->setItem(rowIndex, Column::Value, valueItem); + this->setItem(rowIndex, Column::Value, valueItem); break; }} this->m_keys.insert(key); @@ -217,13 +153,15 @@ void CustomAttributesTable::addNewAttribute(const QString &key, QJsonValue value int row = this->addAttribute(key, value); if (row < 0) return; if (setAsDefault) this->setDefaultAttribute(key, value); - this->table->selectRow(row); this->resizeVertically(); + this->selectRow(row); + emit this->edited(); } // For programmatically populating the table void CustomAttributesTable::setAttributes(const QMap attributes) { - this->table->setRowCount(0); // Clear old values + this->m_keys.clear(); + this->setRowCount(0); // Clear old values for (auto it = attributes.cbegin(); it != attributes.cend(); it++) this->addAttribute(it.key(), it.value()); this->resizeVertically(); @@ -240,23 +178,22 @@ void CustomAttributesTable::unsetDefaultAttribute(const QString &key) { } void CustomAttributesTable::removeAttribute(const QString &key) { - for (int row = 0; row < this->table->rowCount(); row++) { - auto keyItem = this->table->item(row, Column::Key); + for (int row = 0; row < this->rowCount(); row++) { + auto keyItem = this->item(row, Column::Key); if (keyItem && keyItem->text() == key) { this->m_keys.remove(key); - this->table->removeRow(row); + this->removeRow(row); break; } } - // No need to adjust size because this is (at the moment) only used for replacement } bool CustomAttributesTable::deleteSelectedAttributes() { - int rowCount = this->table->rowCount(); + int rowCount = this->rowCount(); if (rowCount <= 0) return false; - QModelIndexList indexList = this->table->selectionModel()->selectedIndexes(); + QModelIndexList indexList = this->selectionModel()->selectedIndexes(); QList persistentIndexes; for (QModelIndex index : indexList) { QPersistentModelIndex persistentIndex(index); @@ -268,18 +205,45 @@ bool CustomAttributesTable::deleteSelectedAttributes() { for (QPersistentModelIndex index : persistentIndexes) { auto row = index.row(); - auto item = this->table->item(row, Column::Key); + auto item = this->item(row, Column::Key); if (item) this->m_keys.remove(item->text()); - this->table->removeRow(row); - } - - if (this->table->rowCount() > 0) { - this->table->selectRow(0); + this->removeRow(row); } this->resizeVertically(); + + if (this->rowCount() > 0) { + this->selectRow(0); + } + emit this->edited(); return true; } +void CustomAttributesTable::resizeVertically() { + int height = 0; + if (this->rowCount() == 0) { + // Hide header when table is empty + this->horizontalHeader()->setVisible(false); + } else { + for (int i = 0; i < this->rowCount(); i++) + height += this->rowHeight(i); + + // Account for header and horizontal scroll bar + this->horizontalHeader()->setVisible(true); + height += this->horizontalHeader()->height(); + if (this->horizontalScrollBar()->isVisible()) + height += this->horizontalScrollBar()->height(); + height += 2; // Border + } + + this->setMinimumHeight(height); + this->setMaximumHeight(height); +} + +void CustomAttributesTable::resizeEvent(QResizeEvent *event) { + this->resizeVertically(); + QAbstractItemView::resizeEvent(event); +} + QSet CustomAttributesTable::keys() const { return this->m_keys; } diff --git a/src/ui/eventframes.cpp b/src/ui/eventframes.cpp index 2231d61f..cf3ab4d3 100644 --- a/src/ui/eventframes.cpp +++ b/src/ui/eventframes.cpp @@ -1,5 +1,5 @@ #include "eventframes.h" -#include "customattributestable.h" +#include "customattributesframe.h" #include "editcommands.h" #include "draggablepixmapitem.h" @@ -102,10 +102,10 @@ void EventFrame::setup() { } void EventFrame::initCustomAttributesTable() { - this->custom_attributes = new CustomAttributesTable(this); + this->custom_attributes = new CustomAttributesFrame(this); QStringList keys = projectConfig.getDefaultEventCustomAttributes(this->event->getEventType()).keys(); - this->custom_attributes->setDefaultKeys(QSet(keys.begin(), keys.end())); - this->custom_attributes->setRestrictedKeys(this->event->getExpectedFields()); + this->custom_attributes->table->setDefaultKeys(QSet(keys.begin(), keys.end())); + this->custom_attributes->table->setRestrictedKeys(this->event->getExpectedFields()); this->layout_contents->addWidget(this->custom_attributes); } @@ -138,14 +138,14 @@ void EventFrame::connectSignals(MainWindow *) { }); this->custom_attributes->disconnect(); - connect(this->custom_attributes, &CustomAttributesTable::edited, [this]() { - this->event->setCustomAttributes(this->custom_attributes->getAttributes()); + connect(this->custom_attributes->table, &CustomAttributesTable::edited, [this]() { + this->event->setCustomAttributes(this->custom_attributes->table->getAttributes()); this->event->modify(); }); - connect(this->custom_attributes, &CustomAttributesTable::defaultSet, [this](QString key, QJsonValue value) { + connect(this->custom_attributes->table, &CustomAttributesTable::defaultSet, [this](QString key, QJsonValue value) { projectConfig.insertDefaultEventCustomAttribute(this->event->getEventType(), key, value); }); - connect(this->custom_attributes, &CustomAttributesTable::defaultRemoved, [this](QString key) { + connect(this->custom_attributes->table, &CustomAttributesTable::defaultRemoved, [this](QString key) { projectConfig.removeDefaultEventCustomAttribute(this->event->getEventType(), key); }); } @@ -159,7 +159,7 @@ void EventFrame::initialize() { this->spinner_y->setValue(this->event->getY()); this->spinner_z->setValue(this->event->getZ()); - this->custom_attributes->setAttributes(this->event->getCustomAttributes()); + this->custom_attributes->table->setAttributes(this->event->getCustomAttributes()); this->label_icon->setPixmap(this->event->getPixmap()); }