<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.kde.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugs.kde.org/"
          
          maintainer="sysadmin@kde.org"
>

    <bug>
          <bug_id>131361</bug_id>
          
          <creation_ts>2006-07-25 21:19:09 +0000</creation_ts>
          <short_desc>mouse hovering on an external link can produce a tooltip of the URI, as in acroread and evince</short_desc>
          <delta_ts>2007-03-30 23:34:42 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>10</classification_id>
          <classification>Unmaintained</classification>
          <product>kpdf</product>
          <component>general</component>
          <version>unspecified</version>
          <rep_platform>RedHat Enterprise Linux</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>NOR</priority>
          <bug_severity>wishlist</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>0</everconfirmed>
          <reporter name="Bob Tennent">rdtennent</reporter>
          <assigned_to name="Albert Astals Cid">aacid</assigned_to>
          <cc>bluedzins</cc>
          
          <cf_commitlink></cf_commitlink>
          <cf_versionfixedin></cf_versionfixedin>
          <cf_sentryurl></cf_sentryurl>
          <votes>1</votes>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>455850</commentid>
    <comment_count>0</comment_count>
    <who name="Bob Tennent">rdtennent</who>
    <bug_when>2006-07-25 21:19:09 +0000</bug_when>
    <thetext>Version:            (using KDE KDE 3.5.3)
Installed from:    RedHat RPMs

mouse hovering on an external link can produce a tooltip of the URI, as in acroread and evince:  easily implemented by the to-be-attached patch against ui/pageview.cpp.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>455851</commentid>
    <comment_count>1</comment_count>
      <attachid>17126</attachid>
    <who name="Bob Tennent">rdtennent</who>
    <bug_when>2006-07-25 21:20:59 +0000</bug_when>
    <thetext>Created attachment 17126
patch against ui/pageview.cpp to implement URI tooltips</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>455863</commentid>
    <comment_count>2</comment_count>
    <who name="Albert Astals Cid">aacid</who>
    <bug_when>2006-07-25 22:12:55 +0000</bug_when>
    <thetext>patch is wrong because noone guarantees you the KPDFLink is a KPDFLinkBrowse so instead of static_casting you should dynamic_cast and check for != 0, another option is introducing a virtual method on KPDFLink that returns the representation of the link in a QString form so for example links to pages inside the same file, etc also get the tooltip.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>455867</commentid>
    <comment_count>3</comment_count>
    <who name="Albert Astals Cid">aacid</who>
    <bug_when>2006-07-25 22:18:05 +0000</bug_when>
    <thetext>Pino Toscano just made me realize we already have that virtual funcion on KPDFLink that returns the representation of the link in a QString form in okular so we might really backport that to KDE 3.5.5 in case it is opened for new strings and features.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>473193</commentid>
    <comment_count>4</comment_count>
    <who name="Pino Toscano">pino</who>
    <bug_when>2006-09-27 13:24:33 +0000</bug_when>
    <thetext>*** Bug 127387 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>518156</commentid>
    <comment_count>5</comment_count>
    <who name="Pino Toscano">pino</who>
    <bug_when>2007-03-30 23:14:32 +0000</bug_when>
    <thetext>SVN commit 648272 by pino:

Add tooltips for links in presentation mode.
(Not yet in the contents area.)

CCBUGS: 131361
CCMAIL: kde-i18n-doc@kde.org


 M  +50 -0     core/link.cpp  
 M  +5 -0      core/link.h  
 M  +6 -0      ui/presentationwidget.cpp  


--- branches/KDE/3.5/kdegraphics/kpdf/core/link.cpp #648271:648272
@@ -10,6 +10,56 @@
 // local includes
 #include &quot;link.h&quot;
 
+#include &lt;klocale.h&gt;
+
 KPDFLink::~KPDFLink()
 {
 }
+
+QString KPDFLinkGoto::linkTip() const
+{
+    return m_extFileName.isEmpty() ? ( m_vp.pageNumber != -1 ? i18n( &quot;Go to page %1&quot; ).arg( m_vp.pageNumber + 1 ) : &quot;&quot; ) : i18n(&quot;Open external file&quot;);
+}
+
+QString KPDFLinkExecute::linkTip() const
+{
+    return i18n( &quot;Execute &apos;%1&apos;...&quot; ).arg( m_fileName );
+}
+
+QString KPDFLinkBrowse::linkTip() const
+{
+    return m_url;
+}
+
+QString KPDFLinkAction::linkTip() const
+{
+    switch ( m_type )
+    {
+        case PageFirst:
+            return i18n( &quot;First Page&quot; );
+        case PagePrev:
+            return i18n( &quot;Previous Page&quot; );
+        case PageNext:
+            return i18n( &quot;Next Page&quot; );
+        case PageLast:
+            return i18n( &quot;Last Page&quot; );
+        case HistoryBack:
+            return i18n( &quot;Back&quot; );
+        case HistoryForward:
+            return i18n( &quot;Forward&quot; );
+        case Quit:
+            return i18n( &quot;Quit&quot; );
+        case Presentation:
+            return i18n( &quot;Start Presentation&quot; );
+        case EndPresentation:
+            return i18n( &quot;End Presentation&quot; );
+        case Find:
+            return i18n( &quot;Find...&quot; );
+        case GoToPage:
+            return i18n( &quot;Go To Page...&quot; );
+        case Close:
+        default: ;
+    }
+
+    return QString::null;
+}
--- branches/KDE/3.5/kdegraphics/kpdf/core/link.h #648271:648272
@@ -27,6 +27,7 @@
         // get link type (inherited classes mustreturn an unique identifier)
         enum LinkType { Goto, Execute, Browse, Action, Movie };
         virtual LinkType linkType() const = 0;
+        virtual QString linkTip() const { return QString::null; }
 
         // virtual destructor (remove warnings)
         virtual ~KPDFLink();
@@ -45,6 +46,7 @@
         // create a KPDFLink_Goto
         KPDFLinkGoto( QString extFileName, const DocumentViewport &amp; vp ) { m_extFileName = extFileName; m_vp = vp; }
         LinkType linkType() const { return Goto; }
+        QString linkTip() const;
 
     private:
         QString m_extFileName;
@@ -62,6 +64,7 @@
         // create a KPDFLink_Execute
         KPDFLinkExecute( const QString &amp; file, const QString &amp; params ) { m_fileName = file; m_parameters = params; }
         LinkType linkType() const { return Execute; }
+        QString linkTip() const;
 
     private:
         QString m_fileName;
@@ -78,6 +81,7 @@
         // create a KPDFLink_Browse
         KPDFLinkBrowse( const QString &amp;url ) { m_url = url; }
         LinkType linkType() const { return Browse; }
+        QString linkTip() const;
 
     private:
         QString m_url;
@@ -96,6 +100,7 @@
         // create a KPDFLink_Action
         KPDFLinkAction( enum ActionType actionType ) { m_type = actionType; }
         LinkType linkType() const { return Action; }
+        QString linkTip() const;
 
     private:
         ActionType m_type;
--- branches/KDE/3.5/kdegraphics/kpdf/ui/presentationwidget.cpp #648271:648272
@@ -13,6 +13,7 @@
 #include &lt;qpainter.h&gt;
 #include &lt;qapplication.h&gt;
 #include &lt;qdesktopwidget.h&gt;
+#include &lt;qtooltip.h&gt;
 #include &lt;kapplication.h&gt;
 #include &lt;kcursor.h&gt;
 #include &lt;ktoolbar.h&gt;
@@ -406,6 +407,11 @@
         // change cursor shape
         m_handCursor = link != 0;
         setCursor( m_handCursor ? KCursor::handCursor() : KCursor::arrowCursor());
+
+        // set tooltip over link&apos;s rect
+        QString tip = link ? link-&gt;linkTip() : &quot;&quot;;
+        if ( m_handCursor &amp;&amp; !tip.isEmpty() )
+            QToolTip::add( this, linkRect, tip );
     }
 }
 
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>518158</commentid>
    <comment_count>6</comment_count>
    <who name="Nicolas Goutte">nicolasg</who>
    <bug_when>2007-03-30 23:29:30 +0000</bug_when>
    <thetext>On Friday 30 March 2007, Pino Toscano wrote:
&gt; SVN commit 648272 by pino:
&gt;
&gt; Add tooltips for links in presentation mode.
&gt; (Not yet in the contents area.)
&gt;
&gt; CCBUGS: 131361
&gt; CCMAIL: kde-i18n-doc@kde.org
&gt;
&gt;
&gt;  M  +50 -0     core/link.cpp
&gt;  M  +5 -0      core/link.h
&gt;  M  +6 -0      ui/presentationwidget.cpp
&gt;
&gt;
&gt; --- branches/KDE/3.5/kdegraphics/kpdf/core/link.cpp #648271:648272
&gt; @@ -10,6 +10,56 @@
&gt;  // local includes
&gt;  #include &quot;link.h&quot;
&gt;
&gt; +#include &lt;klocale.h&gt;
&gt; +
&gt;  KPDFLink::~KPDFLink()
&gt;  {
&gt;  }
&gt; +
&gt; +QString KPDFLinkGoto::linkTip() const
&gt; +{
&gt; +    return m_extFileName.isEmpty() ? ( m_vp.pageNumber != -1 ? i18n( &quot;Go
&gt; to page %1&quot; ).arg( m_vp.pageNumber + 1 ) : &quot;&quot; ) : i18n(&quot;Open external
&gt; file&quot;); +}


As i18n returns a QString, I suppose that using QString() (or QString::null ) 
instead of &quot;&quot; would be better to avoid potential compilation errors.

&gt; +

[...]
&gt; --- branches/KDE/3.5/kdegraphics/kpdf/ui/presentationwidget.cpp
&gt; #648271:648272 @@ -13,6 +13,7 @@
&gt;  #include &lt;qpainter.h&gt;
&gt;  #include &lt;qapplication.h&gt;
&gt;  #include &lt;qdesktopwidget.h&gt;
&gt; +#include &lt;qtooltip.h&gt;
&gt;  #include &lt;kapplication.h&gt;
&gt;  #include &lt;kcursor.h&gt;
&gt;  #include &lt;ktoolbar.h&gt;
&gt; @@ -406,6 +407,11 @@
&gt;          // change cursor shape
&gt;          m_handCursor = link != 0;
&gt;          setCursor( m_handCursor ? KCursor::handCursor() :
&gt; KCursor::arrowCursor()); +
&gt; +        // set tooltip over link&apos;s rect
&gt; +        QString tip = link ? link-&gt;linkTip() : &quot;&quot;;


And probably the same here.

&gt; +        if ( m_handCursor &amp;&amp; !tip.isEmpty() )
&gt; +            QToolTip::add( this, linkRect, tip );
&gt;      }
&gt;  }


Have a nice day!
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>518160</commentid>
    <comment_count>7</comment_count>
    <who name="Pino Toscano">pino</who>
    <bug_when>2007-03-30 23:34:41 +0000</bug_when>
    <thetext>SVN commit 648280 by pino:

Show a tooltip of the link under the mouse even in the content area.

BUG: 131361


 M  +52 -0     pageview.cpp  
 M  +3 -0      pageview.h  


--- branches/KDE/3.5/kdegraphics/kpdf/ui/pageview.cpp #648279:648280
@@ -22,6 +22,7 @@
 #include &lt;qtimer.h&gt;
 #include &lt;qdatetime.h&gt;
 #include &lt;qpushbutton.h&gt;
+#include &lt;qtooltip.h&gt;
 #include &lt;qapplication.h&gt;
 #include &lt;qclipboard.h&gt;
 #include &lt;dcopclient.h&gt;
@@ -58,6 +59,53 @@
 // definition of searchID for this class
 #define PAGEVIEW_SEARCH_ID 2
 
+class PageViewTip : public QToolTip
+{
+    public:
+        PageViewTip( PageView * view )
+            : QToolTip( view-&gt;viewport() ), m_view( view )
+        {
+        }
+
+        ~PageViewTip()
+        {
+            remove( m_view-&gt;viewport() );
+        }
+
+
+    protected:
+        void maybeTip( const QPoint &amp;p );
+
+    private:
+        PageView * m_view;
+};
+
+void PageViewTip::maybeTip( const QPoint &amp;_p )
+{
+    QPoint p( _p.x() + m_view-&gt;contentsX(), _p.y() + m_view-&gt;contentsY() );
+    PageViewItem * pageItem = m_view-&gt;pickItemOnPoint( p.x(), p.y() );
+    if ( pageItem )
+    {
+        double nX = (double)(p.x() - pageItem-&gt;geometry().left()) / (double)pageItem-&gt;width(),
+               nY = (double)(p.y() - pageItem-&gt;geometry().top()) / (double)pageItem-&gt;height();
+
+        // if over a ObjectRect (of type Link) change cursor to hand
+        const ObjectRect * object = pageItem-&gt;page()-&gt;hasObject( ObjectRect::Link, nX, nY );
+        if ( object )
+        {
+            // set tooltip over link&apos;s rect
+            KPDFLink *link = (KPDFLink *)object-&gt;pointer();
+            QString strtip = link-&gt;linkTip();
+            if ( !strtip.isEmpty() )
+            {
+                QRect linkRect = object-&gt;geometry( pageItem-&gt;width(), pageItem-&gt;height() );
+                linkRect.moveBy( - m_view-&gt;contentsX() + pageItem-&gt;geometry().left(), - m_view-&gt;contentsY() + pageItem-&gt;geometry().top() );
+                tip( linkRect, strtip );
+            }
+        }
+    }
+}
+
 // structure used internally by PageView for data storage
 class PageViewPrivate
 {
@@ -96,6 +144,7 @@
     bool blockViewport;                 // prevents changes to viewport
     bool blockPixmapsRequest;           // prevent pixmap requests
     PageViewMessage * messageWindow;    // in pageviewutils.h
+    PageViewTip * tip;
 
     // drag scroll
     QPoint dragScrollVector;
@@ -148,6 +197,7 @@
     d-&gt;blockViewport = false;
     d-&gt;blockPixmapsRequest = false;
     d-&gt;messageWindow = new PageViewMessage(this);
+    d-&gt;tip = new PageViewTip( this );
     d-&gt;aPrevAction = 0;
 
     // widget setup: setup focus, accept drops and track mouse
@@ -182,6 +232,8 @@
     QValueVector&lt; PageViewItem * &gt;::iterator dIt = d-&gt;items.begin(), dEnd = d-&gt;items.end();
     for ( ; dIt != dEnd; ++dIt )
         delete *dIt;
+    delete d-&gt;tip;
+    d-&gt;tip = 0;
     d-&gt;document-&gt;removeObserver( this );
     delete d;
 }
--- branches/KDE/3.5/kdegraphics/kpdf/ui/pageview.h #648279:648280
@@ -29,6 +29,7 @@
 class KPDFDocument;
 class PageViewItem;
 class PageViewPrivate;
+class PageViewTip;
 
 /**
  * @short The main view. Handles zoom and continuous mode.. oh, and page
@@ -39,6 +40,8 @@
 {
     Q_OBJECT
 
+        friend class PageViewTip;
+
     public:
         PageView( QWidget *parent, KPDFDocument *document );
         ~PageView();
</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>17126</attachid>
            <date>2006-07-25 21:20:59 +0000</date>
            <delta_ts>2006-07-25 21:20:59 +0000</delta_ts>
            <desc>patch against ui/pageview.cpp to implement URI tooltips</desc>
            <filename>tooltip.patch</filename>
            <type>text/plain</type>
            <size>1575</size>
            <attacher name="Bob Tennent">rdtennent</attacher>
            
              <data encoding="base64">KioqIHBhZ2V2aWV3LmNwcC5vcmlnCTIwMDYtMDctMjQgMjI6NDE6MTguMDAwMDAwMDAwIC0wNDAw
Ci0tLSBwYWdldmlldy5jcHAJMjAwNi0wNy0yNCAyMjoxODoyMy4wMDAwMDAwMDAgLTA0MDAKKioq
KioqKioqKioqKioqCioqKiAzOS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AgbGlua1JlY3QgPSBwYWdlSXRlbS0+cGFn
ZSgpLT5oYXNPYmplY3QoIE9iamVjdFJlY3Q6OkxpbmssIG5YLCBuWSApOworICAgICAgICAgICAg
aWYgKCBsaW5rUmVjdCApCisgICAgICAgICAgICAgICAgIHsKKyAgICAgICAgICAgICAgICAgICAg
IGNvbnN0IEtQREZMaW5rICogbGluayA9IHN0YXRpY19jYXN0PCBjb25zdCBLUERGTGluayAqID4o
IGxpbmtSZWN0LT5wb2ludGVyKCkgKTsKKyAgICAgICAgICAgICAgICAgICAgIGNvbnN0IEtQREZM
aW5rQnJvd3NlICogYnJvd3NlID0gc3RhdGljX2Nhc3Q8IGNvbnN0IEtQREZMaW5rQnJvd3NlICog
PiggbGluayApOworICAgICAgICAgICAgICAgICAgICAgUVRvb2xUaXA6OmFkZCggdGhpcywgcmVj
dCwgYnJvd3NlLT51cmwoKSApOworICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgc2V0
Q3Vyc29yKCBLQ3Vyc29yOjpoYW5kQ3Vyc29yKCkgKTsKKyAgICAgICAgIH0KICAgICAgICAgIGVs
c2UKKyAgICAgICAgIHsKKyAgICAgICAgICAgICBRVG9vbFRpcDo6cmVtb3ZlKCB0aGlzLCByZWN0
KTsKICAgICAgICAgICAgICBzZXRDdXJzb3IoIEtDdXJzb3I6OmFycm93Q3Vyc29yKCkgKTsKKyAg
ICAgICAgIH0KICAgICAgfQogICAgICBlbHNlCiAgICAgIHsK
</data>

          </attachment>
      

    </bug>

</bugzilla>