Skip to main content

The TooltipManager Class Reference

Class that manages the tooltips for a source file. More...

Declaration

class TooltipManager { ... }

Included Headers

#include <src/tooltip.h>

Public Constructors Index

TooltipManager ()

Public Destructor Index

~TooltipManager ()

Public Member Functions Index

voidaddTooltip (const Definition *d)

add a tooltip for a given symbol definition More...

voidwriteTooltips (OutputCodeList &ol)

write the list of all collected tooltip to the given outputs More...

Private Member Attributes Index

std::unique_ptr< Private >p

Description

Class that manages the tooltips for a source file.

Definition at line 25 of file tooltip.h.

Public Constructors

TooltipManager()

TooltipManager::TooltipManager ()

Declaration at line 28 of file tooltip.h, definition at line 41 of file tooltip.cpp.

41TooltipManager::TooltipManager() : p(std::make_unique<Private>())
42{
43}

Reference p.

Public Destructor

~TooltipManager()

TooltipManager::~TooltipManager ()

Declaration at line 29 of file tooltip.h, definition at line 45 of file tooltip.cpp.

Public Member Functions

addTooltip()

void TooltipManager::addTooltip (const Definition * d)

add a tooltip for a given symbol definition

Declaration at line 33 of file tooltip.h, definition at line 56 of file tooltip.cpp.

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

References Definition::anchor, Config_getBool, escapeId, QCString::findRev, getFileNameExtension, Definition::getOutputFileBase, Doxygen::htmlFileExtension, QCString::isEmpty, p and stripExtensionGeneral.

writeTooltips()

void TooltipManager::writeTooltips (OutputCodeList & ol)

write the list of all collected tooltip to the given outputs

Declaration at line 36 of file tooltip.h, definition at line 89 of file tooltip.cpp.

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

References DocLinkInfo::anchor, SourceLinkInfo::anchor, MemberDef::declaration, SourceLinkInfo::file, g_tooltipsFileMutex, g_tooltipsTipMutex, g_tooltipsWrittenPerFile, OutputCodeList::id, Definition::isAnonymous, SourceLinkInfo::line, DocLinkInfo::name, p, DocLinkInfo::ref, toMemberDef, Definition::TypeMember, DocLinkInfo::url, SourceLinkInfo::url and OutputCodeList::writeTooltip.

Private Member Attributes

p

std::unique_ptr<Private> TooltipManager::p

Definition at line 40 of file tooltip.h.

40 std::unique_ptr<Private> p;

Referenced by addTooltip, TooltipManager and writeTooltips.


The documentation for this class was generated from the following files:


Generated via doxygen2docusaurus by Doxygen 1.14.0.