blob: a0947cebd02316fb6f95d2938a1c2dedf36d93fc (
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
/***************************************************************************
begin : Tue Oct 5 1999
copyright : (C) 1999 by Peter Putzer
email : putzer@kde.org
***************************************************************************/
/***************************************************************************
* *
* 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; version 2. *
* *
***************************************************************************/
#include <qrect.h>
#include <qscrollbar.h>
#include <qheader.h>
#include <kdebug.h>
#include "ksvdraglist.h"
#include "kdltooltip.h"
KDLToolTip::KDLToolTip (KSVDragList *parent, QToolTipGroup* group)
: QToolTip(parent, group),
mParent (parent)
{
}
KDLToolTip::~KDLToolTip()
{
}
void KDLToolTip::maybeTip (const QPoint& p)
{
if (!mParent->displayToolTips())
return;
QString text;
QRect rect;
const QRect vert = mParent->verticalScrollBar()->geometry();
const QRect horiz = mParent->horizontalScrollBar()->geometry();
if (vert.contains(p))
{
rect = vert;
if (!mParent->commonToolTips())
text = mParent->verticalScrollBarTip();
else
text = mParent->tooltip();
}
else if (horiz.contains(p))
{
rect = horiz;
if (!mParent->commonToolTips())
text = mParent->horizontalScrollBarTip();
else
text = mParent->tooltip();
}
else
{
QPoint rp = mParent->viewport()->mapFromParent (p);
QListViewItem* i = mParent->itemAt (rp);
KSVItem* item = static_cast<KSVItem*> (i);
rect = mParent->header()->geometry();
if (rect.contains (p))
{
text = mParent->tooltip();
}
else if (item)
{
rect = mParent->itemRect (i);
rect.moveTopLeft (mParent->viewport()->mapToParent (rect.topLeft()));
text = item->tooltip();
}
else
{
rect = mParent->rect();
QListViewItem* last = mParent->lastItem();
if (last)
rect.setTop (mParent->viewport()->mapToParent (mParent->itemRect(last).bottomRight()).y());
text = mParent->tooltip();
}
}
if (!text.isEmpty())
tip (rect, text);
}
|