My Project
Main Page
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
tooltip.cpp
Go to the documentation of this file.
1
/******************************************************************************
2
*
3
* Copyright (C) 1997-2015 by Dimitri van Heesch.
4
*
5
* Permission to use, copy, modify, and distribute this software and its
6
* documentation under the terms of the GNU General Public License is hereby
7
* granted. No representations are made about the suitability of this software
8
* for any purpose. It is provided "as is" without express or implied warranty.
9
* See the GNU General Public License for more details.
10
*
11
* Documents produced by Doxygen are derivative works derived from the
12
* input used in their production; they are not affected by this license.
13
*
14
*/
15
16
#include <qdict.h>
17
18
#include "
tooltip.h
"
19
#include "
definition.h
"
20
#include "
outputgen.h
"
21
#include "
util.h
"
22
#include "
filedef.h
"
23
#include "
doxygen.h
"
24
#include "
config.h
"
25
26
class
TooltipManager::Private
27
{
28
public
:
29
Private
() :
tooltipInfo
(10007) {}
30
QDict<Definition>
tooltipInfo
;
31
};
32
33
TooltipManager
*
TooltipManager::s_theInstance
= 0;
34
35
TooltipManager::TooltipManager
()
36
{
37
p
=
new
Private
;
38
}
39
40
TooltipManager::~TooltipManager
()
41
{
42
delete
p
;
43
}
44
45
TooltipManager
*
TooltipManager::instance
()
46
{
47
if
(!
s_theInstance
)
48
{
49
s_theInstance
=
new
TooltipManager
;
50
}
51
return
s_theInstance
;
52
}
53
54
void
TooltipManager::clearTooltips
()
55
{
56
p
->
tooltipInfo
.clear();
57
}
58
59
static
QCString
escapeId
(
const
char
*s)
60
{
61
QCString res=s;
62
char
*p=res.rawData();
63
while
(*p)
64
{
65
if
(!
isId
(*p)) *p=
'_'
;
66
p++;
67
}
68
return
res;
69
}
70
71
void
TooltipManager::addTooltip
(
Definition
*d)
72
{
73
static
bool
sourceTooltips =
Config_getBool
(SOURCE_TOOLTIPS);
74
if
(!sourceTooltips)
return
;
75
QCString
id
= d->
getOutputFileBase
();
76
int
i=
id
.findRev(
'/'
);
77
if
(i!=-1)
78
{
79
id
=
id
.right(
id
.length()-i-1);
// strip path (for CREATE_SUBDIRS=YES)
80
}
81
id
+=
escapeId
(
Doxygen::htmlFileExtension
);
82
QCString anc = d->
anchor
();
83
if
(!anc.isEmpty())
84
{
85
id
+=
"_"
+anc;
86
}
87
if
(
p
->
tooltipInfo
.find(
id
)==0)
88
{
89
p
->
tooltipInfo
.insert(
id
,d);
90
}
91
}
92
93
void
TooltipManager::writeTooltips
(
CodeOutputInterface
&ol)
94
{
95
QDictIterator<Definition> di(
p
->
tooltipInfo
);
96
Definition
*d;
97
for
(di.toFirst();(d=di.current());++di)
98
{
99
DocLinkInfo
docInfo;
100
docInfo.
name
= d->
qualifiedName
();
101
docInfo.
ref
= d->
getReference
();
102
docInfo.
url
= d->
getOutputFileBase
();
103
docInfo.
anchor
= d->
anchor
();
104
SourceLinkInfo
defInfo;
105
if
(d->
getBodyDef
() && d->
getStartBodyLine
()!=-1)
106
{
107
defInfo.
file
= d->
getBodyDef
()->
name
();
108
defInfo.
line
= d->
getStartBodyLine
();
109
defInfo.
url
= d->
getSourceFileBase
();
110
defInfo.
anchor
= d->
getSourceAnchor
();
111
}
112
SourceLinkInfo
declInfo;
// TODO: fill in...
113
QCString decl;
114
if
(d->
definitionType
()==
Definition::TypeMember
)
115
{
116
MemberDef
*md = (
MemberDef
*)d;
117
decl = md->
declaration
();
118
if
(!decl.isEmpty() && decl.at(0)==
'@'
)
// hide enum values
119
{
120
decl.resize(0);
121
}
122
}
123
ol.
writeTooltip
(di.currentKey(),
// id
124
docInfo,
// symName
125
decl,
// decl
126
d->
briefDescriptionAsTooltip
(),
// desc
127
defInfo,
128
declInfo
129
);
130
}
131
}
132