summaryrefslogtreecommitdiffstats
path: root/konversation/src/linkaddressbook/nicklisttooltip.cpp
blob: 732b32e6b6762064116de4c4a3c39f9831aa07a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*
  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.
*/

/*
    The class that controls what the tooltip looks like when you hover over a person in the nicklistview.  This is used to show contact information about the person from the addressbook.
    begin:     Sun 25 July 2004
    copyright: (C) 2004 by John Tapsell
    email:     [email protected]
*/

#include "nicklisttooltip.h"
#include "../nick.h"
#include "../nicklistview.h"
#include "../nickinfo.h"
#include "../common.h"

#include <klocale.h>
#include <tqtooltip.h>
#include <tqlistview.h>


class NickListView;

namespace Konversation
{
    KonversationNickListViewToolTip::KonversationNickListViewToolTip(TQWidget *parent, NickListView *lv) : TQToolTip(parent)
    {
        m_listView = lv;
    }

    KonversationNickListViewToolTip::~KonversationNickListViewToolTip()
    {
    }

    void KonversationNickListViewToolTip::maybeTip( const TQPoint &pos )
    {
        if( !parentWidget() || !m_listView )
            return;

        TQListViewItem *item = m_listView->itemAt( pos );

        if( !item )
            return;

        Nick *nick = dynamic_cast<Nick*>( item );

        if(! nick )
            return;

        TQString toolTip;
        TQRect itemRect = m_listView->itemRect( item );

        uint leftMargin = m_listView->treeStepSize() *
            ( item->depth() + ( m_listView->rootIsDecorated() ? 1 : 0 ) ) +
            m_listView->itemMargin();
        uint xAdjust = itemRect.left() + leftMargin;
        uint yAdjust = itemRect.top();
        TQPoint relativePos( pos.x() - xAdjust, pos.y() - yAdjust );
        toolTip = Konversation::removeIrcMarkup(nick->getChannelNick()->tooltip());
        if(!toolTip.isEmpty())
            tip(itemRect, toolTip);
    }

}                                                 // namespace Konversation