summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJanne Kangas <janne.kangas@qt.io>2019-01-07 12:00:21 +0200
committerJanne Kangas <janne.kangas@qt.io>2019-02-07 11:44:17 +0000
commit05ea7909ee2cdf611aa0e7bb98165e4aed55cf9c (patch)
tree7026048167e6c05102372f9b4d8aaec7f5451039
parent74b2def81b8f3f52406359b5f68eef4e440e053e (diff)
Add metadata field to datainput definition
Add a single key-value metadata to datainput item definition. Add editable field in datainput dialog for entering metadata. Metadata is provided as convenience for the user integrating Q3DSPresentation with external code. It can be used to better identify the intended use for a specific datainput, for example. Metadata is stored in UIA (project) file. Corresponding getter function will be implemented on Runtime side. Change-Id: I60d4f8318a7552bd82b41c857d4314be0828f013 Task-id: QT3DS-2992 Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io> Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
-rw-r--r--src/Authoring/Client/Code/Core/Doc/Doc.h5
-rw-r--r--src/Authoring/Studio/Application/DataInputDlg.cpp34
-rw-r--r--src/Authoring/Studio/Application/DataInputDlg.h4
-rw-r--r--src/Authoring/Studio/Application/DataInputDlg.ui42
-rw-r--r--src/Authoring/Studio/Application/ProjectFile.cpp2
-rw-r--r--src/Authoring/Studio/Application/StudioApp.cpp7
6 files changed, 93 insertions, 1 deletions
diff --git a/src/Authoring/Client/Code/Core/Doc/Doc.h b/src/Authoring/Client/Code/Core/Doc/Doc.h
index 29130a48..e66a2057 100644
--- a/src/Authoring/Client/Code/Core/Doc/Doc.h
+++ b/src/Authoring/Client/Code/Core/Doc/Doc.h
@@ -184,6 +184,11 @@ public:
QString name;
int type;
QVector<ControlledItem> ctrldElems;
+ // As per QT3DS-2992 we currently need only a single key-value pair per datainput.
+ // For efficiency we use separate QStrings for both, as there is no need for more
+ // elaborate containers.
+ QString metaDataKey;
+ QString metaData;
// Bindings in other subpresentations, of QMap format
// QMultiMap<subpresentation_id, QPair<datatype, strict>>.
diff --git a/src/Authoring/Studio/Application/DataInputDlg.cpp b/src/Authoring/Studio/Application/DataInputDlg.cpp
index 0a31424d..9bfec2a0 100644
--- a/src/Authoring/Studio/Application/DataInputDlg.cpp
+++ b/src/Authoring/Studio/Application/DataInputDlg.cpp
@@ -28,6 +28,7 @@
#include "DataInputDlg.h"
#include "ui_DataInputDlg.h"
+#include "Qt3DSMessageBox.h"
#include <QtWidgets/qabstractbutton.h>
#include <QtGui/qstandarditemmodel.h>
@@ -43,6 +44,8 @@ CDataInputDlg::CDataInputDlg(CDataInputDialogItem **datainput, QStandardItemMode
, m_type(0)
, m_min(0.0)
, m_max(10.0)
+ , m_metadataKey(m_dataInput->metaDataKey)
+ , m_metadata(m_dataInput->metaData)
, m_acceptedTypes(acceptedTypes)
{
m_ui->setupUi(this);
@@ -87,6 +90,10 @@ CDataInputDlg::CDataInputDlg(CDataInputDialogItem **datainput, QStandardItemMode
this, &CDataInputDlg::onMaxChanged);
connect(m_ui->lineEditInputName, &QLineEdit::textChanged, this, &CDataInputDlg::onNameChanged);
connect(m_ui->lineEditEvaluation, &QLineEdit::textChanged, this, &CDataInputDlg::onTextChanged);
+ connect(m_ui->lineEditMetadata, &QLineEdit::textChanged, this,
+ &CDataInputDlg::onMetadataChanged);
+ connect(m_ui->lineEditMetadataKey, &QLineEdit::textChanged, this,
+ &CDataInputDlg::onMetadataKeyChanged);
}
CDataInputDlg::~CDataInputDlg()
@@ -127,11 +134,20 @@ void CDataInputDlg::initDialog()
m_ui->doubleSpinBoxMax->setValue(m_dataInput->maxValue);
}
+ m_metadata = m_dataInput->metaData;
+ m_metadataKey = m_dataInput->metaDataKey;
+ m_ui->lineEditMetadata->setText(m_metadata);
+ m_ui->lineEditMetadataKey->setText(m_metadataKey);
updateVisibility(m_dataInput->type);
}
void CDataInputDlg::accept()
{
+ if (m_metadataKey.isEmpty() && !m_metadata.isEmpty()) {
+ Qt3DSMessageBox::Show(tr("Metadata Error"), tr("Metadata key cannot be empty."),
+ Qt3DSMessageBox::ICON_WARNING, false, this);
+ return;
+ }
if (m_dataInput->name != m_name)
m_dataInput->name = getUniqueId(m_name);
@@ -145,6 +161,8 @@ void CDataInputDlg::accept()
m_dataInput->valueString = m_text;
}
#endif
+ m_dataInput->metaData = m_metadata;
+ m_dataInput->metaDataKey = m_metadataKey;
QDialog::accept();
}
@@ -181,6 +199,22 @@ void CDataInputDlg::onTextChanged(const QString &text)
m_text = text;
}
+void CDataInputDlg::onMetadataChanged(const QString &metadata)
+{
+ int cursorPos = m_ui->lineEditMetadata->cursorPosition();
+ m_metadata = metadata;
+ m_ui->lineEditMetadata->setText(metadata);
+ m_ui->lineEditMetadata->setCursorPosition(cursorPos);
+}
+
+void CDataInputDlg::onMetadataKeyChanged(const QString &metadataKey)
+{
+ int cursorPos = m_ui->lineEditMetadataKey->cursorPosition();
+ m_metadataKey = metadataKey;
+ m_ui->lineEditMetadataKey->setText(metadataKey);
+ m_ui->lineEditMetadataKey->setCursorPosition(cursorPos);
+}
+
QString CDataInputDlg::getUniqueId(const QString &id)
{
QString retval = QStringLiteral("%1").arg(id);
diff --git a/src/Authoring/Studio/Application/DataInputDlg.h b/src/Authoring/Studio/Application/DataInputDlg.h
index b560c7cc..49593cd4 100644
--- a/src/Authoring/Studio/Application/DataInputDlg.h
+++ b/src/Authoring/Studio/Application/DataInputDlg.h
@@ -99,6 +99,8 @@ private Q_SLOTS:
void onMaxChanged(float max);
void onNameChanged(const QString &name);
void onTextChanged(const QString &text);
+ void onMetadataChanged(const QString &metadata);
+ void onMetadataKeyChanged(const QString &metadataKey);
private:
Ui::DataInputDlg *m_ui;
@@ -109,6 +111,8 @@ private:
float m_min;
int m_type;
QString m_text;
+ QString m_metadataKey;
+ QString m_metadata;
QVector<EDataType> m_acceptedTypes;
};
diff --git a/src/Authoring/Studio/Application/DataInputDlg.ui b/src/Authoring/Studio/Application/DataInputDlg.ui
index b27218c4..982e2d4f 100644
--- a/src/Authoring/Studio/Application/DataInputDlg.ui
+++ b/src/Authoring/Studio/Application/DataInputDlg.ui
@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>533</width>
- <height>244</height>
+ <height>300</height>
</rect>
</property>
<property name="windowTitle">
@@ -133,6 +133,32 @@
</spacer>
</item>
<item>
+ <widget class="QLabel" name="labelMetadataKey">
+ <property name="minimumSize">
+ <size>
+ <width>0</width>
+ <height>24</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>Metadata Key</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="labelMetadata">
+ <property name="minimumSize">
+ <size>
+ <width>0</width>
+ <height>24</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>Metadata</string>
+ </property>
+ </widget>
+ </item>
+ <item>
<widget class="QLabel" name="labelEvaluation">
<property name="minimumSize">
<size>
@@ -261,6 +287,20 @@
</spacer>
</item>
<item>
+ <widget class="QLineEdit" name="lineEditMetadataKey">
+ <property name="toolTip">
+ <string>Key for accessing the metadata for this Data Input</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="lineEditMetadata">
+ <property name="toolTip">
+ <string>Metadata associated with this Data Input</string>
+ </property>
+ </widget>
+ </item>
+ <item>
<widget class="QLineEdit" name="lineEditEvaluation">
<property name="toolTip">
<string/>
diff --git a/src/Authoring/Studio/Application/ProjectFile.cpp b/src/Authoring/Studio/Application/ProjectFile.cpp
index b4e4749a..ecf5a065 100644
--- a/src/Authoring/Studio/Application/ProjectFile.cpp
+++ b/src/Authoring/Studio/Application/ProjectFile.cpp
@@ -493,6 +493,8 @@ void ProjectFile::parseDataInputElem(const QDomElement &elem,
item->valueString = elem.attribute(QStringLiteral("evaluator"));
}
#endif
+ item->metaDataKey = elem.attribute((QStringLiteral("metadatakey")));
+ item->metaData = elem.attribute((QStringLiteral("metadata")));
dataInputs.insert(item->name, item);
}
}
diff --git a/src/Authoring/Studio/Application/StudioApp.cpp b/src/Authoring/Studio/Application/StudioApp.cpp
index 9452183d..8b58e4f5 100644
--- a/src/Authoring/Studio/Application/StudioApp.cpp
+++ b/src/Authoring/Studio/Application/StudioApp.cpp
@@ -1789,6 +1789,13 @@ void CStudioApp::saveDataInputsToProjectFile()
diNode.setAttribute(QStringLiteral("evaluator"), item->valueString);
}
#endif
+ // Let's allow storing key even if actual metadata is empty, as we
+ // do not know how the user code is going to interpret metadata contents.
+ if (!item->metaDataKey.isEmpty()) {
+ diNode.setAttribute(QStringLiteral("metadatakey"), item->metaDataKey);
+ if (!item->metaData.isEmpty())
+ diNode.setAttribute(QStringLiteral("metadata"), item->metaData);
+ }
assetsNode.appendChild(diNode);
}
StudioUtils::commitDomDocumentSave(file, doc);