[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-pim
Subject:    Re: [Kde-pim] HTML Rendering of <img> tag takes 100% cpu
From:       André_Somers <a.t.somers () student ! utwente ! nl>
Date:       2004-12-01 12:44:54
Message-ID: 200412011345.04112.a.t.somers () student ! utwente ! nl
[Download RAW message or body]

[Attachment #2 (multipart/signed)]


On Wednesday 01 December 2004 00:41, Ingo Klöcker wrote:
> On Tuesday 30 November 2004 17:41, Stefan Bruens wrote:
> > Just noticed a somewhat strange behaviour of the tooltip (Subject is
> > to long to be shown in the listview): When I hover over the Subject,
> > the <img> gets replaced with a black box.
>
> That's a known problem. The code that draws the tooltips can render a
> subset of HTML.

I think that's a bug, so I tried to fix it. I have not managed to create a 
real patch, as somehow building kmail fails here. So, I created a test 
application and attacked the problem from there. Here's the result:

I created this custom QToolTip class. It is adapated from the Qt sourcecode. I 
suggest adding this code to either klistview.cpp (to fix this for all of KDE) 
or to kmheaders.cpp. 

====
class QListViewToolTip : public QToolTip
{
public:
    QListViewToolTip( QWidget *parent, QListView *lv );

    void maybeTip( const QPoint &pos );

private:
    QListView *view;

};

QListViewToolTip::QListViewToolTip( QWidget *parent, QListView *lv )
    : QToolTip( parent ), view( lv )
{
}

void QListViewToolTip::maybeTip( const QPoint &pos )
{
    if ( !parentWidget() || !view || !view->showToolTips() )
 return;

    QListViewItem *item = view->itemAt( pos );
    QPoint contentsPos = view->viewportToContents( pos );
    if ( !item || !item->columns )
 return;
    int col = view->header()->sectionAt( contentsPos.x() );

    if ( view->header()->sectionSize( col ) >= item->width 
( view->fontMetrics(), view, col ) ) 
        return;

    QRect r = view->itemRect( item );
    int headerPos = view->header()->sectionPos( col );
    r.setLeft( headerPos );
    r.setRight( headerPos + view->header()->sectionSize( col ) );
    tip( r, QStyleSheet::convertFromPlainText(item->text( col ) ));
    //tip( r, item->text( col ) );
}
===

Then, use QListViewToolTip as the tooltip provider, by setting it in the 
constructor:

    m_tooltip = new QListViewToolTip(viewport(), this);

Where m_tooltip is a member of KListView or KMHeaders. Don't forget to delete 
m_tooltip again in the destructor, as QListViewToolTip is not a QObject 
decendant and will not be deleted automaticly.

Sorry for not providing a real patch...

André

-- 
My opinions may have changed, but not the fact that I am right.
-- Ashleigh Brilliant

[Attachment #5 (application/pgp-signature)]

_______________________________________________
kde-pim mailing list
kde-pim@kde.org
https://mail.kde.org/mailman/listinfo/kde-pim
kde-pim home page at http://pim.kde.org/

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic