summaryrefslogtreecommitdiff
path: root/src/libs/utils/settingsselector.cpp
diff options
context:
space:
mode:
authorTobias Hunger <tobias.hunger@nokia.com>2011-11-22 13:04:49 +0000
committerTobias Hunger <tobias.hunger@nokia.com>2011-11-23 12:01:33 +0100
commit3029af276992d2a1b3018dd671703811e05210fa (patch)
treec3a18f0f5ca1c16ebbfca77696d70d03f2f795e3 /src/libs/utils/settingsselector.cpp
parentdf058c80273ed0881fff0c054aea6d7eaf4bf21d (diff)
downloadqt-creator-3029af276992d2a1b3018dd671703811e05210fa.tar.gz
SettingsSelector: Use Edit role when renaming
Also add a method to find the current index. Change-Id: I54074e7050200a77d35461c4f8064c1829b5927f Reviewed-by: Daniel Teske <daniel.teske@nokia.com>
Diffstat (limited to 'src/libs/utils/settingsselector.cpp')
-rw-r--r--src/libs/utils/settingsselector.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/libs/utils/settingsselector.cpp b/src/libs/utils/settingsselector.cpp
index fb4d1a06ed..66843e1db9 100644
--- a/src/libs/utils/settingsselector.cpp
+++ b/src/libs/utils/settingsselector.cpp
@@ -133,9 +133,14 @@ QMenu *SettingsSelector::addMenu() const
return m_addButton->menu();
}
+int SettingsSelector::currentIndex() const
+{
+ return m_configurationCombo->currentIndex();
+}
+
void SettingsSelector::removeButtonClicked()
{
- int pos = m_configurationCombo->currentIndex();
+ int pos = currentIndex();
if (pos < 0)
return;
const QString title = m_kindOfDisplayName.isEmpty() ? tr("Remove") :
@@ -157,19 +162,24 @@ void SettingsSelector::removeButtonClicked()
void SettingsSelector::renameButtonClicked()
{
- int pos = m_configurationCombo->currentIndex();
+ int pos = currentIndex();
if (pos < 0)
return;
+ QAbstractItemModel *model = m_configurationCombo->model();
+ int row = m_configurationCombo->currentIndex();
+ QModelIndex idx = model->index(row, 0);
+ QString baseName = model->data(idx, Qt::EditRole).toString();
+
bool ok;
const QString &message = m_kindOfDisplayName.isEmpty() ?
tr("New name for configuration <b>%1</b>:")
- .arg(m_configurationCombo->currentText()) :
+ .arg(baseName) :
tr("New name for %1: <b>%2</b>:")
- .arg(m_kindOfDisplayName).arg(m_configurationCombo->currentText());
+ .arg(m_kindOfDisplayName).arg(baseName);
QString name = QInputDialog::getText(this, tr("Rename..."), message,
- QLineEdit::Normal, m_configurationCombo->currentText(), &ok);
+ QLineEdit::Normal, baseName, &ok);
if (!ok)
return;