From b022227ef98c6897f6d691ce6ab01df008c0e758 Mon Sep 17 00:00:00 2001
From: MattKC <34096995+itsmattkc@users.noreply.github.com>
Date: Fri, 25 Aug 2023 19:40:12 -0700
Subject: [PATCH] app: add ability to edit extra data

---
 app/mainwindow.cpp | 18 ++++++++++++++++++
 app/mainwindow.h   |  2 ++
 2 files changed, 20 insertions(+)

diff --git a/app/mainwindow.cpp b/app/mainwindow.cpp
index 21c1f8e..ada665c 100644
--- a/app/mainwindow.cpp
+++ b/app/mainwindow.cpp
@@ -2,6 +2,7 @@
 
 #include <iostream>
 #include <QFileDialog>
+#include <QLineEdit>
 #include <QMenuBar>
 #include <QMessageBox>
 #include <QSplitter>
@@ -66,6 +67,14 @@ MainWindow::MainWindow(QWidget *parent) :
   {
     int prow = 0;
 
+    properties_layout->addWidget(new QLabel(tr("Extra")), prow, 0);
+
+    m_extraEdit = new QLineEdit(this);
+    connect(m_extraEdit, &QLineEdit::textChanged, this, &MainWindow::ExtraChanged);
+    properties_layout->addWidget(m_extraEdit, prow, 1);
+
+    prow++;
+
     properties_layout->addWidget(new QLabel(tr("Location")), prow, 0);
 
     m_LocationEdit = new Vector3Edit();
@@ -149,6 +158,7 @@ void MainWindow::SetPanel(Panel *panel, si::Object *chunk)
   properties_group_->setEnabled(chunk);
 
   if (chunk) {
+    m_extraEdit->setText(QString::fromUtf8(chunk->extra_.data()));
     m_LocationEdit->SetValue(chunk->location_);
     m_UpEdit->SetValue(chunk->up_);
     start_time_edit_->setValue(chunk->time_offset_);
@@ -334,6 +344,14 @@ void MainWindow::ViewSIFile()
   }
 }
 
+void MainWindow::ExtraChanged(const QString &v)
+{
+  if (last_set_data_) {
+    last_set_data_->extra_ = bytearray(v.toUtf8(), v.size() + 1);
+    last_set_data_->extra_[v.size()] = 0;
+  }
+}
+
 void MainWindow::LocationChanged(const Vector3 &v)
 {
   if (last_set_data_) {
diff --git a/app/mainwindow.h b/app/mainwindow.h
index 5c3d6d5..014cc2a 100644
--- a/app/mainwindow.h
+++ b/app/mainwindow.h
@@ -55,6 +55,7 @@ private:
 
   QGroupBox *properties_group_;
 
+  QLineEdit *m_extraEdit;
   Vector3Edit *m_LocationEdit;
   Vector3Edit *m_UpEdit;
 
@@ -77,6 +78,7 @@ private slots:
 
   void ViewSIFile();
 
+  void ExtraChanged(const QString &v);
   void LocationChanged(const si::Vector3 &v);
   void UpChanged(const si::Vector3 &v);
   void StartTimeChanged(int t);