summaryrefslogtreecommitdiffstats
path: root/ksysv/kdltooltip.cpp
blob: 0260b5d7972495ee22104e19f6730afd636c1080 (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 <tqrect.h>
#include <tqscrollbar.h>
#include <tqheader.h>

#include <kdebug.h>

#include "ksvdraglist.h"
#include "kdltooltip.h"

KDLToolTip::KDLToolTip (KSVDragList *tqparent, TQToolTipGroup* group)
  : TQToolTip(tqparent, group),
	mParent (tqparent)
{
}

KDLToolTip::~KDLToolTip()
{
}

void KDLToolTip::maybeTip (const TQPoint& p)
{
  if (!mParent->displayToolTips())
	return;

  TQString text;
  TQRect rect;

  const TQRect vert = mParent->verticalScrollBar()->tqgeometry();
  const TQRect horiz = mParent->horizontalScrollBar()->tqgeometry();

  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
	{ 
	  TQPoint rp = mParent->viewport()->mapFromParent (p);
	  TQListViewItem* i = mParent->itemAt (rp);
	  KSVItem* item = static_cast<KSVItem*> (i);
	  	
	  rect = mParent->header()->tqgeometry();
      if (rect.contains (p))
        {
		  text = mParent->tooltip();
        }
      else if (item)
		{
		  rect = mParent->tqitemRect (i);
		  rect.moveTopLeft (mParent->viewport()->mapToParent (rect.topLeft()));

		  text = item->tooltip();
		}
	  else
		{
          rect = mParent->rect();

          TQListViewItem* last = mParent->lastItem();          
          if (last)
            rect.setTop (mParent->viewport()->mapToParent (mParent->tqitemRect(last).bottomRight()).y());
          
		  text = mParent->tooltip();
		}
	}
  
  if (!text.isEmpty())
	tip (rect, text);
}