Doxygen
TooltipManager类 参考

Class that manages the tooltips for a source file 更多...

#include <tooltip.h>

class  Private
 

Public 成员函数

 TooltipManager ()
 
 ~TooltipManager ()
 
void addTooltip (CodeOutputInterface &ol, const Definition *d)
 add a tooltip for a given symbol definition 更多...
 
void writeTooltips (CodeOutputInterface &ol)
 write the list of all collected tooltip to the given outputs 更多...
 

Private 属性

std::unique_ptr< Privatep
 

详细描述

Class that manages the tooltips for a source file

在文件 tooltip.h24 行定义.

构造及析构函数说明

◆ TooltipManager()

TooltipManager::TooltipManager ( )

在文件 tooltip.cpp39 行定义.

39  : p(std::make_unique<Private>())
40 {
41 }

◆ ~TooltipManager()

TooltipManager::~TooltipManager ( )

在文件 tooltip.cpp43 行定义.

44 {
45 }

成员函数说明

◆ addTooltip()

void TooltipManager::addTooltip ( CodeOutputInterface ol,
const Definition d 
)

add a tooltip for a given symbol definition

在文件 tooltip.cpp54 行定义.

55 {
56  bool sourceTooltips = Config_getBool(SOURCE_TOOLTIPS);
57  if (!sourceTooltips) return;
58 
59  QCString id = d->getOutputFileBase();
60  int i=id.findRev('/');
61  if (i!=-1)
62  {
63  id = id.right(id.length()-i-1); // strip path (for CREATE_SUBDIRS=YES)
64  }
65  // In case an extension is present translate this extension to something understood by the tooltip handler
66  // otherwise extend t with a translated htmlFileExtension.
67  QCString currentExtension = getFileNameExtension(id);
68  if (currentExtension.isEmpty())
69  {
71  }
72  else
73  {
74  id = stripExtensionGeneral(id,currentExtension) + escapeId(currentExtension);
75  }
76 
77  QCString anc = d->anchor();
78  if (!anc.isEmpty())
79  {
80  id+="_"+anc;
81  }
82  id = "a" + id;
83  p->tooltipInfo.insert(std::make_pair(id.str(),d));
84  //printf("%p: addTooltip(%s) ol=%d\n",this,id.data(),ol.id());
85 }

引用了 Definition::anchor(), Config_getBool, escapeId(), QCString::findRev(), getFileNameExtension(), Definition::getOutputFileBase(), Doxygen::htmlFileExtension, QCString::isEmpty(), p , 以及 stripExtensionGeneral().

◆ writeTooltips()

void TooltipManager::writeTooltips ( CodeOutputInterface ol)

write the list of all collected tooltip to the given outputs

在文件 tooltip.cpp87 行定义.

88 {
89  int id = ol.id();
90  std::unordered_map<int, std::set<std::string> >::iterator it;
91  // critical section
92  {
93  std::lock_guard<std::mutex> lock(g_tooltipsMutex);
94  it = g_tooltipsWrittenPerFile.find(id);
95  if (it==g_tooltipsWrittenPerFile.end()) // new file
96  {
97  it = g_tooltipsWrittenPerFile.insert(std::make_pair(id,std::set<std::string>())).first;
98  }
99  }
100 
101  for (const auto &kv : p->tooltipInfo)
102  {
103  bool written = it->second.find(kv.first)!=it->second.end();
104  if (!written) // only write tooltips once
105  {
106  //printf("%p: writeTooltips(%s) ol=%d\n",this,kv.first.c_str(),ol.id());
107  const Definition *d = kv.second;
108  DocLinkInfo docInfo;
109  docInfo.name = d->qualifiedName();
110  docInfo.ref = d->getReference();
111  docInfo.url = d->getOutputFileBase();
112  docInfo.anchor = d->anchor();
113  SourceLinkInfo defInfo;
114  if (d->getBodyDef() && d->getStartBodyLine()!=-1)
115  {
116  defInfo.file = d->getBodyDef()->name();
117  defInfo.line = d->getStartBodyLine();
118  defInfo.url = d->getSourceFileBase();
119  defInfo.anchor = d->getSourceAnchor();
120  }
121  SourceLinkInfo declInfo; // TODO: fill in...
122  QCString decl;
124  {
125  const MemberDef *md = toMemberDef(d);
126  if (!md->isAnonymous())
127  {
128  decl = md->declaration();
129  }
130  }
131  ol.writeTooltip(kv.first.c_str(), // id
132  docInfo, // symName
133  decl, // decl
134  d->briefDescriptionAsTooltip(), // desc
135  defInfo,
136  declInfo
137  );
138  it->second.insert(kv.first); // remember we wrote this tooltip for the given file id
139  }
140  }
141 }

引用了 DocLinkInfo::anchor, SourceLinkInfo::anchor, Definition::anchor(), Definition::briefDescriptionAsTooltip(), MemberDef::declaration(), Definition::definitionType(), SourceLinkInfo::file, g_tooltipsMutex, g_tooltipsWrittenPerFile, Definition::getBodyDef(), Definition::getOutputFileBase(), Definition::getReference(), Definition::getSourceAnchor(), Definition::getSourceFileBase(), Definition::getStartBodyLine(), CodeOutputInterface::id(), Definition::isAnonymous(), SourceLinkInfo::line, DocLinkInfo::name, FileDef::name(), p, Definition::qualifiedName(), DocLinkInfo::ref, toMemberDef(), Definition::TypeMember, DocLinkInfo::url, SourceLinkInfo::url , 以及 CodeOutputInterface::writeTooltip().

类成员变量说明

◆ p

std::unique_ptr<Private> TooltipManager::p
private

在文件 tooltip.h37 行定义.

被这些函数引用 addTooltip() , 以及 writeTooltips().


该类的文档由以下文件生成:
Definition::getSourceFileBase
virtual QCString getSourceFileBase() const =0
stripExtensionGeneral
QCString stripExtensionGeneral(const QCString &fName, const QCString &ext)
Definition: util.cpp:5285
Definition::TypeMember
@ TypeMember
Definition: definition.h:90
g_tooltipsWrittenPerFile
static std::unordered_map< int, std::set< std::string > > g_tooltipsWrittenPerFile
Definition: tooltip.cpp:31
Definition
The common base class of all entity definitions found in the sources.
Definition: definition.h:76
QCString::findRev
int findRev(char c, int index=-1, bool cs=TRUE) const
Definition: qcstring.cpp:86
QCString::isEmpty
bool isEmpty() const
Returns TRUE iff the string is empty
Definition: qcstring.h:144
toMemberDef
MemberDef * toMemberDef(Definition *d)
Definition: memberdef.cpp:6088
TooltipManager::p
std::unique_ptr< Private > p
Definition: tooltip.h:37
Definition::getBodyDef
virtual const FileDef * getBodyDef() const =0
Definition::qualifiedName
virtual QCString qualifiedName() const =0
MemberDef
A model of a class/file/namespace member symbol.
Definition: memberdef.h:45
g_tooltipsMutex
static std::mutex g_tooltipsMutex
Definition: tooltip.cpp:30
FileDef::name
virtual QCString name() const =0
Definition::isAnonymous
virtual bool isAnonymous() const =0
CodeOutputInterface::id
virtual int id() const
Identifier for the output file
Definition: outputgen.h:70
Definition::getOutputFileBase
virtual QCString getOutputFileBase() const =0
Definition::getStartBodyLine
virtual int getStartBodyLine() const =0
Definition::definitionType
virtual DefType definitionType() const =0
MemberDef::declaration
virtual QCString declaration() const =0
Definition::getReference
virtual QCString getReference() const =0
Definition::anchor
virtual QCString anchor() const =0
Config_getBool
#define Config_getBool(name)
Definition: config.h:33
Doxygen::htmlFileExtension
static QCString htmlFileExtension
Definition: doxygen.h:103
CodeOutputInterface::writeTooltip
virtual void writeTooltip(const QCString &id, const DocLinkInfo &docInfo, const QCString &decl, const QCString &desc, const SourceLinkInfo &defInfo, const SourceLinkInfo &declInfo)=0
getFileNameExtension
QCString getFileNameExtension(const QCString &fn)
Definition: util.cpp:5621
Definition::briefDescriptionAsTooltip
virtual QCString briefDescriptionAsTooltip() const =0
escapeId
static QCString escapeId(const QCString &s)
Definition: tooltip.cpp:47
Definition::getSourceAnchor
virtual QCString getSourceAnchor() const =0
QCString
This is an alternative implementation of QCString.
Definition: qcstring.h:108