diff options
author | Miikka Heikkinen <miikka.heikkinen@qt.io> | 2018-06-12 14:36:18 +0300 |
---|---|---|
committer | Miikka Heikkinen <miikka.heikkinen@qt.io> | 2018-06-12 12:08:42 +0000 |
commit | c39d3e96e6e8725207eda830b9b5660bd2783a3e (patch) | |
tree | 0fea7da8d9fa1a43834eae0874f9935c3a390d24 /src/Authoring/Studio/Application/DataInputSelectView.cpp | |
parent | 29e1fcfba128b1af20a67a02148a34e163b2d5b9 (diff) |
Fix datainput type issuesv2.0.0-rc2v2.0.0
- When adding a new data input the type is set correctly even if you
don't touch the type combo.
- When adding a new data input from popup menu for property, timeline,
or slide panel, the corresponding data input is not changed if the
new data input is of unsuitable type.
- Correct default type is shown for each property when setting data
input from inspector panel.
Task-number: QT3DS-1913
Change-Id: I704cb704fb1ec9aca916ed7f7542ace404bba77c
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
Reviewed-by: Antti Määttä <antti.maatta@qt.io>
Diffstat (limited to 'src/Authoring/Studio/Application/DataInputSelectView.cpp')
-rw-r--r-- | src/Authoring/Studio/Application/DataInputSelectView.cpp | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/src/Authoring/Studio/Application/DataInputSelectView.cpp b/src/Authoring/Studio/Application/DataInputSelectView.cpp index 11c45e6e..40b8e0d8 100644 --- a/src/Authoring/Studio/Application/DataInputSelectView.cpp +++ b/src/Authoring/Studio/Application/DataInputSelectView.cpp @@ -38,12 +38,17 @@ #include "DataInputDlg.h" #include "StudioApp.h" -DataInputSelectView::DataInputSelectView(QWidget *parent, EDataType defaultType) +// Empty acceptedTypes vector means all types are accepted +DataInputSelectView::DataInputSelectView(const QVector<EDataType> &acceptedTypes, QWidget *parent) : QQuickWidget(parent) , m_model(new DataInputSelectModel(this)) - , m_defaultType(defaultType) + , m_defaultType(EDataType::DataTypeFloat) + , m_acceptedTypes(acceptedTypes) { + if (!m_acceptedTypes.isEmpty()) + m_defaultType = m_acceptedTypes[0]; + setWindowTitle(tr("Datainputs")); setWindowFlags(Qt::Tool | Qt::FramelessWindowHint); setResizeMode(QQuickWidget::SizeRootObjectToView); @@ -60,6 +65,13 @@ void DataInputSelectView::setData(const QVector<QPair<QString, int>> &dataInputL updateData(dataInputList); } +void DataInputSelectView::setAcceptedTypes(const QVector<EDataType> &acceptedTypes) +{ + m_acceptedTypes = acceptedTypes; + if (!m_acceptedTypes.isEmpty()) + m_defaultType = m_acceptedTypes[0]; +} + void DataInputSelectView::updateData(const QVector<QPair<QString, int>> &dataInputList) { m_selection = -1; @@ -139,8 +151,15 @@ void DataInputSelectView::setSelection(int index) if (dataInputDlg.result() == QDialog::Accepted) { m_mostRecentlyAdded = dataInputDlg.getAddedDataInput(); - if (m_mostRecentlyAdded.size()) - Q_EMIT dataInputChanged(m_handle, m_instance, m_mostRecentlyAdded); + if (m_mostRecentlyAdded.size()) { + CDataInputDialogItem *diItem = g_StudioApp.m_dataInputDialogItems.value( + m_mostRecentlyAdded); + if (m_acceptedTypes.isEmpty() + || (diItem && m_acceptedTypes.contains( + static_cast<EDataType>(diItem->type)))) { + Q_EMIT dataInputChanged(m_handle, m_instance, m_mostRecentlyAdded); + } + } g_StudioApp.SaveUIAFile(false); } } |