summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomi Korpipaa <tomi.korpipaa@qt.io>2018-01-16 13:55:14 +0200
committerTomi Korpipää <tomi.korpipaa@qt.io>2018-01-18 10:38:56 +0000
commit849b12c5df97ec268c5efce27ea96daa7676e525 (patch)
treea6ab30214b7c46006085ccc8d5e2c0af3d317569
parent49cfa36e1e28ef9e742844973129d65a13a8d538 (diff)
Fix incorrect renaming when editing sub-presentations
Also unify the dialog functionality with data input dialog, so that double-clicking triggers editing of values. Task-number: QT3DS-812 Change-Id: I19548f3daeeb9ad11ef6a1868f7403bf76790362 Reviewed-by: Antti Määttä <antti.maatta@qt.io> Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
-rw-r--r--src/Authoring/Studio/_Win/Application/SubPresentationListDlg.cpp18
-rw-r--r--src/Authoring/Studio/_Win/Application/SubPresentationListDlg.h2
2 files changed, 15 insertions, 5 deletions
diff --git a/src/Authoring/Studio/_Win/Application/SubPresentationListDlg.cpp b/src/Authoring/Studio/_Win/Application/SubPresentationListDlg.cpp
index 2722fe2d..b104cde2 100644
--- a/src/Authoring/Studio/_Win/Application/SubPresentationListDlg.cpp
+++ b/src/Authoring/Studio/_Win/Application/SubPresentationListDlg.cpp
@@ -101,6 +101,10 @@ void CSubPresentationListDlg::initDialog()
// When clicking an item, select the whole row
connect(m_ui->tableView, &QTableView::clicked, this, &CSubPresentationListDlg::onSelected);
+
+ // Double-click opens the item in edit mode
+ connect(m_ui->tableView, &QTableView::doubleClicked,
+ this, &CSubPresentationListDlg::onEditSubPresentation);
}
void CSubPresentationListDlg::updateButtons()
@@ -191,14 +195,17 @@ void CSubPresentationListDlg::onEditSubPresentation()
if (subpresdialog.exec() == QDialog::Accepted) {
m_records[m_currentIndex] = subpresdialog.subpresentation();
+ // We need to update the table to be able to accurately find out if the id is unique
+ updateContents();
// Make sure that id is still unique
- m_records[m_currentIndex].m_id = getUniqueId(m_records[m_currentIndex].m_id);
+ m_records[m_currentIndex].m_id = getUniqueId(m_records[m_currentIndex].m_id, true);
+ // Update again, as the id might have been updated
+ updateContents();
}
m_currentIndex = -1;
updateButtons();
- updateContents();
}
void CSubPresentationListDlg::onSelected(const QModelIndex &index)
@@ -209,11 +216,14 @@ void CSubPresentationListDlg::onSelected(const QModelIndex &index)
updateButtons();
}
-QString CSubPresentationListDlg::getUniqueId(const QString &id)
+QString CSubPresentationListDlg::getUniqueId(const QString &id, bool editing)
{
QString retval = QStringLiteral("%1").arg(id);
int idx = 1;
- while (m_tableContents->findItems(retval, Qt::MatchExactly, 0).size() && idx < 1000) {
+ int limit = (editing == true) ? 1 : 0;
+ // When editing, ignore our own id (i.e. there is supposed to be one entry already)
+ while (m_tableContents->findItems(retval, Qt::MatchExactly, 0).size() > limit
+ && idx < 1000) {
retval = QStringLiteral("%1_%2").arg(id).arg(idx, 3, 10, QLatin1Char('0'));
++idx;
}
diff --git a/src/Authoring/Studio/_Win/Application/SubPresentationListDlg.h b/src/Authoring/Studio/_Win/Application/SubPresentationListDlg.h
index d877f625..0cfdd7c0 100644
--- a/src/Authoring/Studio/_Win/Application/SubPresentationListDlg.h
+++ b/src/Authoring/Studio/_Win/Application/SubPresentationListDlg.h
@@ -59,7 +59,7 @@ protected:
void initDialog();
void updateButtons();
void updateContents();
- QString getUniqueId(const QString &id);
+ QString getUniqueId(const QString &id, bool editing = false);
private Q_SLOTS:
void on_buttonBox_accepted();