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 
27 {
28  public:
29  Private() : tooltipInfo(10007) {}
30  QDict<Definition> tooltipInfo;
31 };
32 
34 
36 {
37  p = new Private;
38 }
39 
41 {
42  delete p;
43 }
44 
46 {
47  if (!s_theInstance)
48  {
50  }
51  return s_theInstance;
52 }
53 
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 
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  }
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 
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;
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 
bool resize(uint newlen)
Definition: qcstring.h:225
char * rawData() const
Definition: qcstring.h:216
QCString ref
Definition: outputgen.h:43
QCString file
Definition: outputgen.h:50
virtual QCString getReference() const
bool isEmpty() const
Definition: qcstring.h:189
QCString url
Definition: outputgen.h:53
void addTooltip(Definition *d)
Definition: tooltip.cpp:71
static QCString htmlFileExtension
Definition: doxygen.h:130
char & at(uint i) const
Definition: qcstring.h:326
FileDef * getBodyDef() const
QCString anchor
Definition: outputgen.h:54
void clearTooltips()
Definition: tooltip.cpp:54
Private * p
Definition: tooltip.h:30
virtual QCString getOutputFileBase() const =0
int findRev(char c, int index=-1, bool cs=TRUE) const
Definition: qcstring.cpp:95
virtual DefType definitionType() const =0
virtual void writeTooltip(const char *id, const DocLinkInfo &docInfo, const char *decl, const char *desc, const SourceLinkInfo &defInfo, const SourceLinkInfo &declInfo)=0
QCString name() const
Definition: filedef.cpp:1193
virtual QCString getSourceFileBase() const
Definition: definition.cpp:885
virtual QCString getSourceAnchor() const
Definition: definition.cpp:898
static QCString escapeId(const char *s)
Definition: tooltip.cpp:59
A bunch of utility functions.
#define Config_getBool(val)
Definition: config.cpp:664
QCString name
Definition: outputgen.h:42
virtual QCString qualifiedName() const
const char * declaration() const
Definition: memberdef.cpp:4020
void writeTooltips(CodeOutputInterface &ol)
Definition: tooltip.cpp:93
QCString anchor
Definition: outputgen.h:45
int getStartBodyLine() const
static TooltipManager * instance()
Definition: tooltip.cpp:45
static TooltipManager * s_theInstance
Definition: tooltip.h:34
QCString url
Definition: outputgen.h:44
QDict< Definition > tooltipInfo
Definition: tooltip.cpp:30
bool isId(int c)
Definition: util.h:224
QCString briefDescriptionAsTooltip() const
static QCString * s
Definition: config.cpp:1042
virtual QCString anchor() const =0