summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Teske <daniel.teske@nokia.com>2012-01-23 12:26:59 +0100
committerDaniel Teske <daniel.teske@nokia.com>2012-01-24 14:21:22 +0100
commit951b1120d603892b910b90b4d375d58b39354703 (patch)
treecd634c0cd9a07dead19bd7ceef6197aa01da7f2f /src
parent50b1d6742ae58cb65cc6322d3a91b04f81f1f2bb (diff)
downloadqt-creator-951b1120d603892b910b90b4d375d58b39354703.tar.gz
Preserve user changes in custom wizard on back
Task-number: QTCREATORBUG-6774 Change-Id: I7c06f794f04b6e019a7d8b65d810096a1d9ebf82 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/projectexplorer/customwizard/customwizardpage.cpp35
-rw-r--r--src/plugins/projectexplorer/customwizard/customwizardpage.h3
2 files changed, 33 insertions, 5 deletions
diff --git a/src/plugins/projectexplorer/customwizard/customwizardpage.cpp b/src/plugins/projectexplorer/customwizard/customwizardpage.cpp
index 9b37c3950e..725bf4375c 100644
--- a/src/plugins/projectexplorer/customwizard/customwizardpage.cpp
+++ b/src/plugins/projectexplorer/customwizard/customwizardpage.cpp
@@ -356,18 +356,19 @@ void CustomWizardFieldPage::initializePage()
{
QWizardPage::initializePage();
clearError();
- // Note that the field mechanism will always restore the value
- // set on it when entering the page, so, there is no point in
- // trying to preserve user modifications of the text.
foreach(const LineEditData &led, m_lineEdits) {
- if (!led.defaultText.isEmpty()) {
+ if (!led.userChange.isNull()) {
+ led.lineEdit->setText(led.userChange);
+ } else if (!led.defaultText.isEmpty()) {
QString defaultText = led.defaultText;
CustomWizardContext::replaceFields(m_context->baseReplacements, &defaultText);
led.lineEdit->setText(defaultText);
}
}
foreach(const TextEditData &ted, m_textEdits) {
- if (!ted.defaultText.isEmpty()) {
+ if (!ted.userChange.isNull()) {
+ ted.textEdit->setText(ted.userChange);
+ } else if (!ted.defaultText.isEmpty()) {
QString defaultText = ted.defaultText;
CustomWizardContext::replaceFields(m_context->baseReplacements, &defaultText);
ted.textEdit->setText(defaultText);
@@ -375,6 +376,30 @@ void CustomWizardFieldPage::initializePage()
}
}
+void CustomWizardFieldPage::cleanupPage()
+{
+ for (int i = 0; i < m_lineEdits.count(); ++i) {
+ LineEditData &led = m_lineEdits[i];
+ QString defaultText = led.defaultText;
+ CustomWizardContext::replaceFields(m_context->baseReplacements, &defaultText);
+ if (led.lineEdit->text() != defaultText)
+ led.userChange = led.lineEdit->text();
+ else
+ led.userChange.clear();
+
+ }
+ for (int i= 0; i < m_textEdits.count(); ++i) {
+ TextEditData &ted = m_textEdits[i];
+ QString defaultText = ted.defaultText;
+ CustomWizardContext::replaceFields(m_context->baseReplacements, &defaultText);
+ if (ted.textEdit->toHtml() != ted.defaultText && ted.textEdit->toPlainText() != ted.defaultText)
+ ted.userChange = ted.textEdit->toHtml();
+ else
+ ted.userChange.clear();
+ }
+ QWizardPage::cleanupPage();
+}
+
bool CustomWizardFieldPage::validatePage()
{
clearError();
diff --git a/src/plugins/projectexplorer/customwizard/customwizardpage.h b/src/plugins/projectexplorer/customwizard/customwizardpage.h
index b17391db72..20221c3530 100644
--- a/src/plugins/projectexplorer/customwizard/customwizardpage.h
+++ b/src/plugins/projectexplorer/customwizard/customwizardpage.h
@@ -119,6 +119,7 @@ public:
virtual bool validatePage();
virtual void initializePage();
+ virtual void cleanupPage();
static QMap<QString, QString> replacementMap(const QWizard *w,
const QSharedPointer<CustomWizardContext> &ctx,
@@ -133,11 +134,13 @@ private:
explicit LineEditData(QLineEdit* le = 0, const QString &defText = QString());
QLineEdit* lineEdit;
QString defaultText;
+ QString userChange;
};
struct TextEditData {
explicit TextEditData(QTextEdit* le = 0, const QString &defText = QString());
QTextEdit* textEdit;
QString defaultText;
+ QString userChange;
};
typedef QList<LineEditData> LineEditDataList;
typedef QList<TextEditData> TextEditDataList;