From e945acef450c4fbf9b417a485b50a50a9c05c58b Mon Sep 17 00:00:00 2001
From: dt <qtc-committer@nokia.com>
Date: Mon, 28 Mar 2011 17:57:17 +0200
Subject: [PATCH] Environment Widget: Linkfy summary text

Jumps to the variable on clicking.

Task-Nr: QTCREATORBUG-3316
---
 src/libs/utils/detailswidget.cpp                  |  4 +++-
 src/libs/utils/detailswidget.h                    |  1 +
 src/plugins/projectexplorer/environmentwidget.cpp | 14 ++++++++++++--
 src/plugins/projectexplorer/environmentwidget.h   |  1 +
 4 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/src/libs/utils/detailswidget.cpp b/src/libs/utils/detailswidget.cpp
index adc0cc2262b..67b5954aaf3 100644
--- a/src/libs/utils/detailswidget.cpp
+++ b/src/libs/utils/detailswidget.cpp
@@ -104,7 +104,7 @@ namespace Utils {
             QWidget(parent),
             d(new DetailsWidgetPrivate(this))
     {
-        d->m_summaryLabel->setTextInteractionFlags(Qt::TextSelectableByMouse);
+        d->m_summaryLabel->setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::LinksAccessibleByMouse);
         d->m_summaryLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
         d->m_summaryLabel->setContentsMargins(MARGIN, MARGIN, MARGIN, MARGIN);
 
@@ -128,6 +128,8 @@ namespace Utils {
                 this, SLOT(setExpanded(bool)));
         connect(d->m_summaryCheckBox, SIGNAL(toggled(bool)),
                 this, SIGNAL(checked(bool)));
+        connect(d->m_summaryLabel, SIGNAL(linkActivated(QString)),
+                this, SIGNAL(linkActivated(QString)));
         updateControls();
     }
 
diff --git a/src/libs/utils/detailswidget.h b/src/libs/utils/detailswidget.h
index a34b82b88d0..7fb01bacfd2 100644
--- a/src/libs/utils/detailswidget.h
+++ b/src/libs/utils/detailswidget.h
@@ -94,6 +94,7 @@ public:
 
 signals:
     void checked(bool);
+    void linkActivated(const QString &link);
 private slots:
     void setExpanded(bool);
 
diff --git a/src/plugins/projectexplorer/environmentwidget.cpp b/src/plugins/projectexplorer/environmentwidget.cpp
index 7f6e597aef0..ade5dd3d2da 100644
--- a/src/plugins/projectexplorer/environmentwidget.cpp
+++ b/src/plugins/projectexplorer/environmentwidget.cpp
@@ -147,6 +147,9 @@ EnvironmentWidget::EnvironmentWidget(QWidget *parent, QWidget *additionalDetails
     connect(d->m_environmentView->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)),
             this, SLOT(environmentCurrentIndexChanged(QModelIndex)));
 
+    connect(d->m_detailsContainer, SIGNAL(linkActivated(QString)),
+            this, SLOT(linkActivated(QString)));
+
     connect(d->m_model, SIGNAL(userChangesChanged()), this, SLOT(updateSummaryText()));
 }
 
@@ -199,9 +202,9 @@ void EnvironmentWidget::updateSummaryText()
         if (item.name != Utils::EnvironmentModel::tr("<VARIABLE>")) {
             text.append("<br>");
             if (item.unset)
-                text.append(tr("Unset <b>%1</b>").arg(Qt::escape(item.name)));
+                text.append(tr("Unset <a href=\"%1\"><b>%1</b></a>").arg(Qt::escape(item.name)));
             else
-                text.append(tr("Set <b>%1</b> to <b>%2</b>").arg(Qt::escape(item.name), Qt::escape(item.value)));
+                text.append(tr("Set <a href=\"%1\"><b>%1</b></a> to <b>%2</b>").arg(Qt::escape(item.name), Qt::escape(item.value)));
         }
     }
 
@@ -213,6 +216,13 @@ void EnvironmentWidget::updateSummaryText()
     d->m_detailsContainer->setSummaryText(text);
 }
 
+void EnvironmentWidget::linkActivated(const QString &link)
+{
+    d->m_detailsContainer->setState(Utils::DetailsWidget::Expanded);
+    QModelIndex idx = d->m_model->variableToIndex(link);
+    focusIndex(idx);
+}
+
 void EnvironmentWidget::updateButtons()
 {
     environmentCurrentIndexChanged(d->m_environmentView->currentIndex());
diff --git a/src/plugins/projectexplorer/environmentwidget.h b/src/plugins/projectexplorer/environmentwidget.h
index c8efbed42ca..f00ad5ee17b 100644
--- a/src/plugins/projectexplorer/environmentwidget.h
+++ b/src/plugins/projectexplorer/environmentwidget.h
@@ -75,6 +75,7 @@ private slots:
     void updateSummaryText();
     void focusIndex(const QModelIndex &index);
     void updateButtons();
+    void linkActivated(const QString &link);
 
 private:
     QScopedPointer<EnvironmentWidgetPrivate> d;
-- 
GitLab