File: tooltip.cpp

package info (click to toggle)
doxygen 1.8.13-4
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 19,900 kB
  • ctags: 30,824
  • sloc: cpp: 238,031; lex: 36,069; xml: 8,294; python: 2,768; ansic: 630; tcl: 594; php: 446; perl: 370; makefile: 242; yacc: 237; objc: 14; sh: 11; java: 1
file content (132 lines) | stat: -rw-r--r-- 3,264 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/******************************************************************************
 *
 * Copyright (C) 1997-2015 by Dimitri van Heesch.
 *
 * Permission to use, copy, modify, and distribute this software and its
 * documentation under the terms of the GNU General Public License is hereby 
 * granted. No representations are made about the suitability of this software 
 * for any purpose. It is provided "as is" without express or implied warranty.
 * See the GNU General Public License for more details.
 *
 * Documents produced by Doxygen are derivative works derived from the
 * input used in their production; they are not affected by this license.
 *
 */

#include <qdict.h>

#include "tooltip.h"
#include "definition.h"
#include "outputgen.h"
#include "util.h"
#include "filedef.h"
#include "doxygen.h"
#include "config.h"

class TooltipManager::Private
{
  public:
    Private() : tooltipInfo(10007) {}
    QDict<Definition> tooltipInfo;
};

TooltipManager *TooltipManager::s_theInstance = 0;

TooltipManager::TooltipManager() 
{
  p = new Private;
}

TooltipManager::~TooltipManager()
{
  delete p;
}

TooltipManager *TooltipManager::instance()
{
  if (!s_theInstance)
  {
    s_theInstance = new TooltipManager;
  }
  return s_theInstance;
}

void TooltipManager::clearTooltips()
{
  p->tooltipInfo.clear();
}

static QCString escapeId(const char *s)
{
  QCString res=s;
  char *p=res.rawData();
  while (*p)
  {
    if (!isId(*p)) *p='_';
    p++;
  }
  return res;
}

void TooltipManager::addTooltip(Definition *d)
{
  static bool sourceTooltips = Config_getBool(SOURCE_TOOLTIPS);
  if (!sourceTooltips) return;
  QCString id = d->getOutputFileBase();
  int i=id.findRev('/');
  if (i!=-1)
  {
    id = id.right(id.length()-i-1); // strip path (for CREATE_SUBDIRS=YES)
  }
  id+=escapeId(Doxygen::htmlFileExtension);
  QCString anc = d->anchor();
  if (!anc.isEmpty())
  {
    id+="_"+anc;
  }
  if (p->tooltipInfo.find(id)==0)
  {
    p->tooltipInfo.insert(id,d);
  }
}

void TooltipManager::writeTooltips(CodeOutputInterface &ol)
{
  QDictIterator<Definition> di(p->tooltipInfo);
  Definition *d;
  for (di.toFirst();(d=di.current());++di)
  {
    DocLinkInfo docInfo;
    docInfo.name   = d->qualifiedName();
    docInfo.ref    = d->getReference();
    docInfo.url    = d->getOutputFileBase();
    docInfo.anchor = d->anchor();
    SourceLinkInfo defInfo;
    if (d->getBodyDef() && d->getStartBodyLine()!=-1)
    {
      defInfo.file    = d->getBodyDef()->name();
      defInfo.line    = d->getStartBodyLine();
      defInfo.url     = d->getSourceFileBase();
      defInfo.anchor  = d->getSourceAnchor();
    }
    SourceLinkInfo declInfo; // TODO: fill in...
    QCString decl;
    if (d->definitionType()==Definition::TypeMember)
    {
      MemberDef *md = (MemberDef*)d;
      decl = md->declaration();
      if (!decl.isEmpty() && decl.at(0)=='@') // hide enum values
      {
        decl.resize(0);
      }
    }
    ol.writeTooltip(di.currentKey(),                 // id
                    docInfo,                         // symName
                    decl,                            // decl
                    d->briefDescriptionAsTooltip(),  // desc
                    defInfo,
                    declInfo
                   );
  }
}