Doxygen
Loading...
Searching...
No Matches
TooltipManager Class Reference

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

#include <src/tooltip.h>

Classes

class  Private
 

Public Member Functions

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

Private Attributes

std::unique_ptr< Privatep
 

Detailed Description

Class that manages the tooltips for a source file.

Definition at line 25 of file tooltip.h.

Constructor & Destructor Documentation

◆ TooltipManager()

TooltipManager::TooltipManager ( )

Definition at line 41 of file tooltip.cpp.

41 : p(std::make_unique<Private>())
42{
43}
std::unique_ptr< Private > p
Definition tooltip.h:40

References p.

◆ ~TooltipManager()

TooltipManager::~TooltipManager ( )

Definition at line 45 of file tooltip.cpp.

46{
47}

Member Function Documentation

◆ addTooltip()

void TooltipManager::addTooltip ( const Definition * d)

add a tooltip for a given symbol definition

Definition at line 56 of file tooltip.cpp.

57{
58 bool sourceTooltips = Config_getBool(SOURCE_TOOLTIPS);
59 if (!sourceTooltips) return;
60
61 QCString id = d->getOutputFileBase();
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}
virtual QCString anchor() const =0
virtual QCString getOutputFileBase() const =0
static QCString htmlFileExtension
Definition doxygen.h:122
bool isEmpty() const
Returns TRUE iff the string is empty.
Definition qcstring.h:150
int findRev(char c, int index=-1, bool cs=TRUE) const
Definition qcstring.cpp:91
#define Config_getBool(name)
Definition config.h:33
static QCString escapeId(const QCString &s)
Definition tooltip.cpp:49
QCString stripExtensionGeneral(const QCString &fName, const QCString &ext)
Definition util.cpp:5255
QCString getFileNameExtension(const QCString &fn)
Definition util.cpp:5591

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

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}
virtual bool isAnonymous() const =0
virtual QCString declaration() const =0
int id() const
Definition outputlist.h:191
void writeTooltip(const QCString &id, const DocLinkInfo &docInfo, const QCString &decl, const QCString &desc, const SourceLinkInfo &defInfo, const SourceLinkInfo &declInfo)
Definition outputlist.h:259
MemberDef * toMemberDef(Definition *d)
static std::mutex g_tooltipsFileMutex
Definition tooltip.cpp:31
static std::mutex g_tooltipsTipMutex
Definition tooltip.cpp:32
static std::unordered_map< int, std::unordered_set< std::string > > g_tooltipsWrittenPerFile
Definition tooltip.cpp:33

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().

Member Data Documentation

◆ p

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

Definition at line 40 of file tooltip.h.

Referenced by addTooltip(), TooltipManager(), and writeTooltips().


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