From edabcb40faceca2b3dfd2ebc4e1ce5e6ac02c7c5 Mon Sep 17 00:00:00 2001
From: Sergey Shambir <sergey.shambir.auto@gmail.com>
Date: Tue, 10 Jul 2012 20:30:31 +0400
Subject: [PATCH] Added tooltips on completions proposals

Change-Id: Ic22b99e25159edfa4977e13c98f334ce75809af7
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Eike Ziller <eike.ziller@nokia.com>
---
 src/plugins/cpptools/cppcompletionassist.cpp    | 17 ++++++++++++++---
 .../codeassist/genericproposalwidget.cpp        |  3 ++-
 src/plugins/texteditor/texteditorconstants.h    |  5 +++++
 3 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/src/plugins/cpptools/cppcompletionassist.cpp b/src/plugins/cpptools/cppcompletionassist.cpp
index 5e4e3d1e86c..4eaafc6e30b 100644
--- a/src/plugins/cpptools/cppcompletionassist.cpp
+++ b/src/plugins/cpptools/cppcompletionassist.cpp
@@ -536,7 +536,10 @@ public:
     ConvertToCompletionItem()
         : _item(0)
         , _symbol(0)
-    { }
+    {
+        overview.setShowReturnTypes(true);
+        overview.setShowArgumentNames(true);
+    }
 
     BasicProposalItem *operator()(Symbol *symbol)
     {
@@ -575,7 +578,12 @@ protected:
     }
 
     virtual void visit(const Identifier *name)
-    { _item = newCompletionItem(name); }
+    {
+        _item = newCompletionItem(name);
+        if (!_symbol->isScope() || _symbol->isFunction()) {
+            _item->setDetail(overview.prettyType(_symbol->type(), name));
+        }
+    }
 
     virtual void visit(const TemplateNameId *name)
     {
@@ -587,7 +595,10 @@ protected:
     { _item = newCompletionItem(name); }
 
     virtual void visit(const OperatorNameId *name)
-    { _item = newCompletionItem(name); }
+    {
+        _item = newCompletionItem(name);
+        _item->setDetail(overview.prettyType(_symbol->type(), name));
+    }
 
     virtual void visit(const ConversionNameId *name)
     { _item = newCompletionItem(name); }
diff --git a/src/plugins/texteditor/codeassist/genericproposalwidget.cpp b/src/plugins/texteditor/codeassist/genericproposalwidget.cpp
index 324edea5b4c..d89c5864e57 100644
--- a/src/plugins/texteditor/codeassist/genericproposalwidget.cpp
+++ b/src/plugins/texteditor/codeassist/genericproposalwidget.cpp
@@ -39,6 +39,7 @@
 
 #include <texteditor/texteditorsettings.h>
 #include <texteditor/completionsettings.h>
+#include <texteditor/texteditorconstants.h>
 
 #include <utils/faketooltip.h>
 
@@ -264,7 +265,7 @@ GenericProposalWidgetPrivate::GenericProposalWidgetPrivate(QWidget *completionWi
     connect(m_completionListView, SIGNAL(activated(QModelIndex)),
             this, SLOT(handleActivation(QModelIndex)));
 
-    m_infoTimer.setInterval(1000);
+    m_infoTimer.setInterval(Constants::COMPLETION_ASSIST_TOOLTIP_DELAY);
     m_infoTimer.setSingleShot(true);
     connect(&m_infoTimer, SIGNAL(timeout()), SLOT(maybeShowInfoTip()));
 }
diff --git a/src/plugins/texteditor/texteditorconstants.h b/src/plugins/texteditor/texteditorconstants.h
index 7d23fb3d733..1231e598b1f 100644
--- a/src/plugins/texteditor/texteditorconstants.h
+++ b/src/plugins/texteditor/texteditorconstants.h
@@ -181,6 +181,11 @@ const char TEXT_SNIPPET_GROUP_ID[] = "Text";
 
 const char GLOBAL_SETTINGS_ID[]    = "Global";
 
+/**
+ * Delay before tooltip will be shown near completion assistant proposal
+ */
+const unsigned COMPLETION_ASSIST_TOOLTIP_DELAY = 100;
+
 } // namespace Constants
 } // namespace TextEditor
 
-- 
GitLab