From 942611f6c91262e1694af9b67a9b6e23c69b4750 Mon Sep 17 00:00:00 2001
From: mae <qt-info@nokia.com>
Date: Fri, 21 May 2010 13:47:02 +0200
Subject: [PATCH] UI fix for renaming symbols

The change makes the "replace with" line edit for symbol
renaming wide enough.

The default QLineEdit has space for ca. 17 characters, we now
expand to the maximum of 25 and the space needed for the replacement
text.
---
 src/plugins/find/searchresultwindow.cpp | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/src/plugins/find/searchresultwindow.cpp b/src/plugins/find/searchresultwindow.cpp
index 0289b71e571..05f236b5dd9 100644
--- a/src/plugins/find/searchresultwindow.cpp
+++ b/src/plugins/find/searchresultwindow.cpp
@@ -52,6 +52,25 @@ static const char SETTINGSKEYEXPANDRESULTS[] = "ExpandResults";
 
 namespace Find {
 
+    class WideEnoughLineEdit : public QLineEdit {
+        Q_OBJECT
+    public:
+        WideEnoughLineEdit(QWidget *parent):QLineEdit(parent){
+            connect(this, SIGNAL(textChanged(QString)),
+                    this, SLOT(updateGeometry()));
+        }
+        ~WideEnoughLineEdit(){}
+        QSize sizeHint() const {
+            QSize sh = QLineEdit::minimumSizeHint();
+            sh.rwidth() += qMax(25 * fontMetrics().width(QLatin1Char('x')),
+                                fontMetrics().width(text()));
+            return sh;
+        }
+    public slots:
+        void updateGeometry() { QLineEdit::updateGeometry(); }
+    };
+
+
 struct SearchResultWindowPrivate {
     SearchResultWindowPrivate();
 
@@ -97,7 +116,7 @@ SearchResultWindow::SearchResultWindow() : d(new SearchResultWindowPrivate)
 
     d->m_replaceLabel = new QLabel(tr("Replace with:"), d->m_widget);
     d->m_replaceLabel->setContentsMargins(12, 0, 5, 0);
-    d->m_replaceTextEdit = new QLineEdit(d->m_widget);
+    d->m_replaceTextEdit = new WideEnoughLineEdit(d->m_widget);
     d->m_replaceButton = new QToolButton(d->m_widget);
     d->m_replaceButton->setToolTip(tr("Replace all occurrences"));
     d->m_replaceButton->setText(tr("Replace"));
@@ -371,3 +390,5 @@ bool SearchResultWindow::canNavigate()
 
 } // namespace Find
 
+
+#include "searchresultwindow.moc"
-- 
GitLab