summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJanne Kangas <janne.kangas@qt.io>2018-11-23 09:55:09 +0200
committerJanne Kangas <janne.kangas@qt.io>2018-12-03 05:13:04 +0000
commitc2ba9f691049a98d5612468bfd2a72a06bd89ee3 (patch)
tree6a441a08a5fef0f8ba943d4015200da555a31d31
parent9404c3d06f72001a257d07cd258aec50dd5b33ee (diff)
Check for datainput name uniqueness only at accept when adding new DI
Also, in the datainput management dialog select the newly added DI to draw user attention to potential silent renaming (instead of a pop-up). For the case where user adds a datainput directly from datainput selector, we cannot highlight the row as dialog is closed immediately, though. Change-Id: Id52151445847a43bfe3c158dc4dac44d7d3db0ba Task-id: QT3DS-2784 Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io> Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
-rw-r--r--src/Authoring/Studio/Application/DataInputDlg.cpp6
-rw-r--r--src/Authoring/Studio/Application/DataInputListDlg.cpp8
2 files changed, 12 insertions, 2 deletions
diff --git a/src/Authoring/Studio/Application/DataInputDlg.cpp b/src/Authoring/Studio/Application/DataInputDlg.cpp
index aa0551bf..0a31424d 100644
--- a/src/Authoring/Studio/Application/DataInputDlg.cpp
+++ b/src/Authoring/Studio/Application/DataInputDlg.cpp
@@ -132,7 +132,9 @@ void CDataInputDlg::initDialog()
void CDataInputDlg::accept()
{
- m_dataInput->name = m_name;
+ if (m_dataInput->name != m_name)
+ m_dataInput->name = getUniqueId(m_name);
+
m_dataInput->type = m_type;
if (m_type == DataTypeRangedNumber) {
m_dataInput->minValue = m_min;
@@ -169,7 +171,7 @@ void CDataInputDlg::onMaxChanged(float max)
void CDataInputDlg::onNameChanged(const QString &name)
{
int cursorPos = m_ui->lineEditInputName->cursorPosition();
- m_name = getUniqueId(name);
+ m_name = name;
m_ui->lineEditInputName->setText(m_name);
m_ui->lineEditInputName->setCursorPosition(cursorPos);
}
diff --git a/src/Authoring/Studio/Application/DataInputListDlg.cpp b/src/Authoring/Studio/Application/DataInputListDlg.cpp
index 3771d984..a03e9dcd 100644
--- a/src/Authoring/Studio/Application/DataInputListDlg.cpp
+++ b/src/Authoring/Studio/Application/DataInputListDlg.cpp
@@ -402,6 +402,14 @@ void CDataInputListDlg::onAddDataInput()
// dialog automatically
if (m_goToAdd)
accept();
+
+ // Otherwise find the new position of added DI and select it.
+ auto idxList = m_ui->tableView->selectionModel()->model()->match(
+ m_ui->tableView->selectionModel()->model()->index(
+ 0,0), Qt::EditRole, m_mostRecentlyAdded);
+
+ if (!idxList.empty())
+ m_ui->tableView->selectRow(idxList.first().row());
}
void CDataInputListDlg::onRemoveDataInput()