index.cpp 124 KB
Newer Older
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1 2
/******************************************************************************
 *
3
 * 
Dimitri van Heesch's avatar
Dimitri van Heesch committed
4
 *
Dimitri van Heesch's avatar
Dimitri van Heesch committed
5
 * Copyright (C) 1997-2013 by Dimitri van Heesch.
Dimitri van Heesch's avatar
Dimitri van Heesch committed
6 7 8 9 10 11 12
 *
 * 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.
 *
Dimitri van Heesch's avatar
Dimitri van Heesch committed
13 14
 * Documents produced by Doxygen are derivative works derived from the
 * input used in their production; they are not affected by this license.
Dimitri van Heesch's avatar
Dimitri van Heesch committed
15 16 17
 *
 */

18 19 20 21
/** @file
 *  @brief This file contains functions for the various index pages.
 */

Dimitri van Heesch's avatar
Dimitri van Heesch committed
22 23
#include <stdlib.h>

24 25 26
#include <qtextstream.h>
#include <qdatetime.h>
#include <qdir.h>
27
#include <qregexp.h>
28

Dimitri van Heesch's avatar
Dimitri van Heesch committed
29 30 31 32 33 34 35 36 37
#include "message.h"
#include "index.h"
#include "doxygen.h"
#include "config.h"
#include "filedef.h"
#include "outputlist.h"
#include "util.h"
#include "groupdef.h"
#include "language.h"
38
#include "htmlgen.h"
39
#include "htmlhelp.h"
40
#include "ftvhelp.h"
Dimitri van Heesch's avatar
Dimitri van Heesch committed
41
#include "dot.h"
42
#include "pagedef.h"
43
#include "dirdef.h"
44
#include "vhdldocgen.h"
45
#include "layout.h"
46 47 48 49
#include "memberlist.h"
#include "classlist.h"
#include "namespacedef.h"
#include "filename.h"
Dimitri van Heesch's avatar
Dimitri van Heesch committed
50

51 52 53
#define MAX_ITEMS_BEFORE_MULTIPAGE_INDEX 200
#define MAX_ITEMS_BEFORE_QUICK_INDEX 30

54

55
int annotatedClasses;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
56
int annotatedClassesPrinted;
57 58 59 60 61 62 63 64
int hierarchyClasses;
int documentedFiles;
int documentedGroups;
int documentedNamespaces;
int indexedPages;
int documentedClassMembers[CMHL_Total];
int documentedFileMembers[FMHL_Total];
int documentedNamespaceMembers[NMHL_Total];
65 66
int documentedHtmlFiles;
int documentedPages;
67
int documentedDirs;
68

69 70 71 72 73 74 75
static int countClassHierarchy();
static void countFiles(int &htmlFiles,int &files);
static int countGroups();
static int countDirs();
static int countNamespaces();
static int countAnnotatedClasses(int *cp);
static void countRelatedPages(int &docPages,int &indexPages);
76 77 78

void countDataStructures()
{
Dimitri van Heesch's avatar
Dimitri van Heesch committed
79
  annotatedClasses           = countAnnotatedClasses(&annotatedClassesPrinted); // "classes" + "annotated"
80 81 82 83 84 85 86 87 88
  hierarchyClasses           = countClassHierarchy();   // "hierarchy"
  countFiles(documentedHtmlFiles,documentedFiles);      // "files"
  countRelatedPages(documentedPages,indexedPages);      // "pages"
  documentedGroups           = countGroups();           // "modules"
  documentedNamespaces       = countNamespaces();       // "namespaces"
  documentedDirs             = countDirs();             // "dirs"
  // "globals"
  // "namespacemembers"
  // "functions"
89 90
}

Dimitri van Heesch's avatar
Dimitri van Heesch committed
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
static void startIndexHierarchy(OutputList &ol,int level)
{
  ol.pushGeneratorState();
  ol.disable(OutputGenerator::Man);
  ol.disable(OutputGenerator::Html);
  if (level<6) ol.startIndexList();
  ol.enableAll();
  ol.disable(OutputGenerator::Latex);
  ol.disable(OutputGenerator::RTF);
  ol.startItemList();
  ol.popGeneratorState();
}

static void endIndexHierarchy(OutputList &ol,int level)
{
  ol.pushGeneratorState();
  ol.disable(OutputGenerator::Man);
  ol.disable(OutputGenerator::Html);
  if (level<6) ol.endIndexList();
  ol.enableAll();
  ol.disable(OutputGenerator::Latex);
  ol.disable(OutputGenerator::RTF);
  ol.endItemList();
  ol.popGeneratorState();
}

Dimitri van Heesch's avatar
Dimitri van Heesch committed
117 118
//----------------------------------------------------------------------------

119 120 121
class MemberIndexList : public QList<MemberDef>
{
  public:
122 123
    typedef MemberDef ElementType;
    MemberIndexList(uint letter) : QList<MemberDef>(), m_letter(letter) {}
124
    ~MemberIndexList() {}
125
    int compareValues(const MemberDef *md1, const MemberDef *md2) const
126
    {
127 128 129 130 131 132
      int result = qstricmp(md1->name(),md2->name());
      if (result==0)
      {
        result = qstricmp(md1->qualifiedName(),md2->qualifiedName());
      }
      return result;
133
    }
134 135 136
    uint letter() const { return m_letter; }
  private:
    uint m_letter;
137 138
};

139 140 141
static LetterToIndexMap<MemberIndexList> g_memberIndexLetterUsed[CMHL_Total];
static LetterToIndexMap<MemberIndexList> g_fileIndexLetterUsed[FMHL_Total];
static LetterToIndexMap<MemberIndexList> g_namespaceIndexLetterUsed[NMHL_Total];
Dimitri van Heesch's avatar
Dimitri van Heesch committed
142

143
const int maxItemsBeforeQuickIndex = MAX_ITEMS_BEFORE_QUICK_INDEX;
144

145 146
//----------------------------------------------------------------------------

Dimitri van Heesch's avatar
Dimitri van Heesch committed
147 148
//----------------------------------------------------------------------------

149
static void startQuickIndexList(OutputList &ol,bool letterTabs=FALSE)
150 151 152 153
{
  bool fancyTabs = TRUE;
  if (fancyTabs)
  {
154 155
    if (letterTabs)
    {
156
      ol.writeString("  <div id=\"navrow4\" class=\"tabs3\">\n"); 
157 158 159
    }
    else
    {
160
      ol.writeString("  <div id=\"navrow3\" class=\"tabs2\">\n"); 
161 162
    }
    ol.writeString("    <ul class=\"tablist\">\n"); 
163 164 165
  }
  else
  {
166
    ol.writeString("  <div class=\"qindex\">"); 
167 168 169 170 171 172 173 174
  }
}

static void endQuickIndexList(OutputList &ol)
{
  bool fancyTabs = TRUE;
  if (fancyTabs)
  {
175
    ol.writeString("    </ul>\n");
176
  }
177
  ol.writeString("  </div>\n");
178 179
}

180
static void startQuickIndexItem(OutputList &ol,const char *l,
181
                                bool hl,bool compact,bool &first)
182
{
183 184
  bool fancyTabs = TRUE;
  if (!first && compact && !fancyTabs) ol.writeString(" | ");
185
  first=FALSE;
186
  if (fancyTabs)
187
  {
188
    ol.writeString("      <li"); 
189
    if (hl) ol.writeString(" class=\"current\"");
190
    ol.writeString("><a ");
191
  }
192
  else
193
  {
194 195 196 197 198 199 200 201 202
    if (!compact) ol.writeString("<li>");
    if (hl && compact)
    {
      ol.writeString("<a class=\"qindexHL\" ");
    }
    else
    {
      ol.writeString("<a class=\"qindex\" ");
    }
203 204 205 206
  }
  ol.writeString("href=\""); 
  ol.writeString(l);
  ol.writeString("\">");
207 208 209 210
  if (fancyTabs)
  {
    ol.writeString("<span>");
  }
211 212 213 214
}

static void endQuickIndexItem(OutputList &ol)
{
215 216
  bool fancyTabs=TRUE;
  if (fancyTabs) ol.writeString("</span>");
217
  ol.writeString("</a>");
218
  if (fancyTabs) ol.writeString("</li>\n");
219 220
}

221 222 223
// don't make this static as it is called from a template function and some
// old compilers don't support calls to static functions from a template.
QCString fixSpaces(const QCString &s)
224
{
225
  return substitute(s," ","&#160;");
226 227
}

228
void startTitle(OutputList &ol,const char *fileName,Definition *def)
229
{
230 231
  ol.startHeaderSection();
  if (def) def->writeSummaryLinks(ol);
232
  ol.startTitleHead(fileName);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
233 234
  ol.pushGeneratorState();
  ol.disable(OutputGenerator::Man);
235 236 237 238
}

void endTitle(OutputList &ol,const char *fileName,const char *name)
{
Dimitri van Heesch's avatar
Dimitri van Heesch committed
239
  ol.popGeneratorState();
240
  ol.endTitleHead(fileName,name);
241
  ol.endHeaderSection();
242 243
}

244
void startFile(OutputList &ol,const char *name,const char *manName,
245 246
               const char *title,HighlightedItem hli,bool additionalIndices,
               const char *altSidebarName)
247
{
248
  static bool disableIndex     = Config_getBool("DISABLE_INDEX");
249
  ol.startFile(name,manName,title);
250 251
  ol.startQuickIndices();
  if (!disableIndex)
252
  {
253
    ol.writeQuickLinks(TRUE,hli,name);
254
  }
255
  if (!additionalIndices)
256
  {
257 258
    ol.endQuickIndices();
  }
259 260
  ol.writeSplitBar(altSidebarName ? altSidebarName : name);
  ol.writeSearchInfo();
261 262
}

263 264
void endFile(OutputList &ol,bool skipNavIndex,bool skipEndContents,
             const QCString &navPath)
265
{
266
  static bool generateTreeView = Config_getBool("GENERATE_TREEVIEW");
267 268
  ol.pushGeneratorState();
  ol.disableAllBut(OutputGenerator::Html);
269 270
  if (!skipNavIndex)
  {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
271
    if (!skipEndContents) ol.endContents();
272 273
    if (generateTreeView)
    {
274
      ol.writeString("</div><!-- doc-content -->\n");
275 276
    }
  }
277
  ol.writeFooter(navPath); // write the footer
278 279 280 281
  ol.popGeneratorState();
  ol.endFile();
}

282 283 284
void endFileWithNavPath(Definition *d,OutputList &ol)
{
  static bool generateTreeView = Config_getBool("GENERATE_TREEVIEW");
285
  QCString navPath;
286 287
  if (generateTreeView)
  {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
288 289
    ol.pushGeneratorState();
    ol.disableAllBut(OutputGenerator::Html);
290
    ol.writeString("</div><!-- doc-content -->\n");
Dimitri van Heesch's avatar
Dimitri van Heesch committed
291
    ol.popGeneratorState();
292
    navPath = d->navigationPathAsString();
293
  }
294
  endFile(ol,generateTreeView,TRUE,navPath);
295 296
}

297
//----------------------------------------------------------------------
Dimitri van Heesch's avatar
Dimitri van Heesch committed
298 299 300 301
template<class T> 
void addMembersToIndex(T *def,LayoutDocManager::LayoutPart part,
                       const QCString &name,const QCString &anchor,
                       bool addToIndex=TRUE,bool preventSeparateIndex=FALSE)
302 303
{
  bool hasMembers = def->getMemberLists().count()>0 || def->getMemberGroupSDict()!=0;
304
  Doxygen::indexList->addContentsItem(hasMembers,name,
Dimitri van Heesch's avatar
Dimitri van Heesch committed
305 306
                                     def->getReference(),def->getOutputFileBase(),anchor,
                                     hasMembers && !preventSeparateIndex,
Dimitri van Heesch's avatar
Dimitri van Heesch committed
307 308
                                     addToIndex,
                                     def);
309 310 311 312 313 314 315 316 317 318 319
  int numClasses=0;
  ClassSDict *classes = def->getClassSDict();
  if (classes)
  {
     ClassDef *cd;
     ClassSDict::Iterator it(*classes);
     for (;(cd=it.current());++it)
     {
       if (cd->isLinkable()) numClasses++;
     }
  }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
320
  //printf("addMembersToIndex(def=%s hasMembers=%d numClasses=%d)\n",def->name().data(),hasMembers,numClasses);
321
  if (hasMembers || numClasses>0)
322
  {
323
    Doxygen::indexList->incContentsDepth();
324 325 326 327 328 329 330 331 332 333 334 335 336 337
    QListIterator<LayoutDocEntry> eli(LayoutDocManager::instance().docEntries(part));
    LayoutDocEntry *lde;
    for (eli.toFirst();(lde=eli.current());++eli)
    {
      if (lde->kind()==LayoutDocEntry::MemberDef)
      {
        LayoutDocEntryMemberDef *lmd = (LayoutDocEntryMemberDef*)lde;
        MemberList *ml = def->getMemberList(lmd->type);
        if (ml)
        {
          MemberListIterator mi(*ml);
          MemberDef *md;
          for (mi.toFirst();(md=mi.current());++mi)
          {
338
            MemberList *enumList = md->enumFieldList();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
339
            bool isDir = enumList!=0 && md->isEnumerate();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
340
            bool isAnonymous = md->name().find('@')!=-1;
341 342 343 344 345 346
            static bool hideUndocMembers = Config_getBool("HIDE_UNDOC_MEMBERS");
            static bool extractStatic = Config_getBool("EXTRACT_STATIC");
            if (!isAnonymous && 
                (!hideUndocMembers || md->hasDocumentation()) &&
                (!md->isStatic() || extractStatic)
               )
347
            {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
348 349
              if (md->getOuterScope()==def)
              {
350
                Doxygen::indexList->addContentsItem(isDir,
351
                  md->name(),md->getReference(),md->getOutputFileBase(),md->anchor(),FALSE,addToIndex);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
352 353 354
              }
              else // inherited member
              {
355
                Doxygen::indexList->addContentsItem(isDir,
Dimitri van Heesch's avatar
Dimitri van Heesch committed
356 357
                  md->name(),def->getReference(),def->getOutputFileBase(),md->anchor(),FALSE,addToIndex);
              }
358
            }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
359 360
            if (isDir)
            {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
361 362
              if (!isAnonymous)
              {
363
                Doxygen::indexList->incContentsDepth();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
364
              }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
365 366 367 368 369 370
              MemberListIterator emli(*enumList);
              MemberDef *emd;
              for (emli.toFirst();(emd=emli.current());++emli)
              {
                if (emd->getOuterScope()==def)
                {
371
                  Doxygen::indexList->addContentsItem(FALSE,
Dimitri van Heesch's avatar
Dimitri van Heesch committed
372 373 374 375
                      emd->name(),emd->getReference(),emd->getOutputFileBase(),emd->anchor(),FALSE,addToIndex);
                }
                else // inherited member
                {
376
                  Doxygen::indexList->addContentsItem(FALSE,
Dimitri van Heesch's avatar
Dimitri van Heesch committed
377 378 379
                      emd->name(),def->getReference(),def->getOutputFileBase(),emd->anchor(),FALSE,addToIndex);
                }
              }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
380 381
              if (!isAnonymous)
              {
382
                Doxygen::indexList->decContentsDepth();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
383
              }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
384
            }
385 386 387 388
          }
        }
      }
      else if (lde->kind()==LayoutDocEntry::NamespaceClasses || 
389 390 391
               lde->kind()==LayoutDocEntry::FileClasses || 
               lde->kind()==LayoutDocEntry::ClassNestedClasses
              )
392 393 394 395 396 397 398
      {
        if (classes)
        {
          ClassDef *cd;
          ClassSDict::Iterator it(*classes);
          for (;(cd=it.current());++it)
          {
399
            if (cd->isLinkable() && (cd->partOfGroups()==0 || def->definitionType()==Definition::TypeGroup))
400
            {
401
              bool isNestedClass = def->definitionType()==Definition::TypeClass;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
402
              addMembersToIndex(cd,LayoutDocManager::Class,cd->displayName(FALSE),cd->anchor(),
403 404
                                addToIndex && isNestedClass,
                                preventSeparateIndex || cd->isEmbeddedInOuterScope());
405 406 407 408 409 410
            }
          }
        }
      }
    }

411
    Doxygen::indexList->decContentsDepth();
412 413 414
  }
}

415

416 417 418
//----------------------------------------------------------------------------
/*! Generates HTML Help tree of classes */

419
static void writeClassTree(OutputList &ol,const BaseClassList *bcl,bool hideSuper,int level,FTVHelp* ftv,bool addToIndex)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
420
{
421
  if (bcl==0) return;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
422 423 424 425 426
  BaseClassListIterator bcli(*bcl);
  bool started=FALSE;
  for ( ; bcli.current() ; ++bcli)
  {
    ClassDef *cd=bcli.current()->classDef;
427 428 429 430 431
    if (cd->getLanguage()==SrcLangExt_VHDL && (VhdlDocGen::VhdlClasses)cd->protection()!=VhdlDocGen::ENTITYCLASS)
    {
      continue;
    }

Dimitri van Heesch's avatar
Dimitri van Heesch committed
432
    bool b;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
433
    if (cd->getLanguage()==SrcLangExt_VHDL)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
434 435 436 437 438 439 440 441 442
    {
      b=hasVisibleRoot(cd->subClasses());
    }
    else
    {
      b=hasVisibleRoot(cd->baseClasses());
    }

    if (cd->isVisibleInHierarchy() && b) // hasVisibleRoot(cd->baseClasses()))
Dimitri van Heesch's avatar
Dimitri van Heesch committed
443 444 445
    {
      if (!started)
      {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
446
        startIndexHierarchy(ol,level);
447 448
        if (addToIndex)
        {
449
          Doxygen::indexList->incContentsDepth();
450
        }
451
        if (ftv)
452
        {
453
          ftv->incContentsDepth();
454
        }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
455 456
        started=TRUE;
      }
457
      ol.startIndexListItem();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
458
      //printf("Passed...\n");
459 460
      bool hasChildren = !cd->visited && !hideSuper && classHasVisibleChildren(cd);
      //printf("tree4: Has children %s: %d\n",cd->name().data(),hasChildren);
461
      if (cd->isLinkable())
Dimitri van Heesch's avatar
Dimitri van Heesch committed
462
      {
463
        //printf("Writing class %s\n",cd->displayName().data());
464 465 466
        ol.startIndexItem(cd->getReference(),cd->getOutputFileBase());
        ol.parseText(cd->displayName());
        ol.endIndexItem(cd->getReference(),cd->getOutputFileBase());
Dimitri van Heesch's avatar
Dimitri van Heesch committed
467 468 469 470 471 472
        if (cd->isReference()) 
        { 
          ol.startTypewriter(); 
          ol.docify(" [external]");
          ol.endTypewriter();
        }
473 474
        if (addToIndex)
        {
475
          Doxygen::indexList->addContentsItem(hasChildren,cd->displayName(),cd->getReference(),cd->getOutputFileBase(),cd->anchor());
476
        }
477
        if (ftv)
478
        {
479 480 481 482 483 484 485 486
          if (cd->getLanguage()==SrcLangExt_VHDL)
          {
            ftv->addContentsItem(hasChildren,bcli.current()->usedName,cd->getReference(),cd->getOutputFileBase(),cd->anchor(),FALSE,FALSE,cd);
          }
          else
          {
            ftv->addContentsItem(hasChildren,cd->displayName(),cd->getReference(),cd->getOutputFileBase(),cd->anchor(),FALSE,FALSE,cd);
          }
487
        }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
488 489 490
      }
      else
      {
491 492 493
        ol.startIndexItem(0,0);
        ol.parseText(cd->name());
        ol.endIndexItem(0,0);
494 495
        if (addToIndex)
        {
496
          Doxygen::indexList->addContentsItem(hasChildren,cd->displayName(),0,0,0);
497
        }
498
        if (ftv)
499
        {
500
          ftv->addContentsItem(hasChildren,cd->displayName(),0,0,0,FALSE,FALSE,cd);
501
        }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
502
      }
503
      if (hasChildren)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
504
      {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
505 506
        //printf("Class %s at %p visited=%d\n",cd->name().data(),cd,cd->visited);
        bool wasVisited=cd->visited;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
507
        cd->visited=TRUE;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
508
        if (cd->getLanguage()==SrcLangExt_VHDL)	
Dimitri van Heesch's avatar
Dimitri van Heesch committed
509
        {
510
          writeClassTree(ol,cd->baseClasses(),wasVisited,level+1,ftv,addToIndex);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
511 512 513
        }
        else       
        {
514
          writeClassTree(ol,cd->subClasses(),wasVisited,level+1,ftv,addToIndex);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
515
        }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
516
      }
517
      ol.endIndexListItem();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
518 519
    }
  }
520 521
  if (started) 
  {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
522
    endIndexHierarchy(ol,level);
523 524
    if (addToIndex)
    {
525
      Doxygen::indexList->decContentsDepth();
526
    }
527
    if (ftv)
528
    {
529
      ftv->decContentsDepth();
530 531 532 533
    }
  }
}

Dimitri van Heesch's avatar
Dimitri van Heesch committed
534 535
//----------------------------------------------------------------------------

Dimitri van Heesch's avatar
Dimitri van Heesch committed
536
static bool dirHasVisibleChildren(DirDef *dd)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
537
{
Dimitri van Heesch's avatar
Dimitri van Heesch committed
538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564
  if (dd->hasDocumentation()) return TRUE;

  QListIterator<FileDef> fli(*dd->getFiles());
  FileDef *fd;
  for (fli.toFirst();(fd=fli.current());++fli)
  {
    bool genSourceFile;
    if (fileVisibleInIndex(fd,genSourceFile))
    {
      return TRUE;
    }
    if (genSourceFile)
    {
      return TRUE;
    }
  }

  QListIterator<DirDef> dli(dd->subDirs());
  DirDef *subdd;
  for (dli.toFirst();(subdd=dli.current());++dli)
  {
    if (dirHasVisibleChildren(subdd))
    {
      return TRUE;
    }
  }
  return FALSE;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
565 566
}

567 568 569 570 571 572
//----------------------------------------------------------------------------
static void writeDirTreeNode(OutputList &ol, DirDef *dd, int level, FTVHelp* ftv,bool addToIndex)
{
  if (level>20)
  {
    warn(dd->getDefFileName(),dd->getDefLine(),
573
        "maximum nesting level exceeded for directory %s: "
574 575 576 577 578
        "check for possible recursive directory relation!\n",dd->name().data()
        );
    return;
  }

Dimitri van Heesch's avatar
Dimitri van Heesch committed
579 580 581 582 583
  if (!dirHasVisibleChildren(dd))
  {
    return;
  }

584 585 586 587 588 589 590 591
  static bool tocExpand = TRUE; //Config_getBool("TOC_EXPAND");
  bool isDir = dd->subDirs().count()>0 || // there are subdirs
               (tocExpand &&              // or toc expand and
                dd->getFiles() && dd->getFiles()->count()>0 // there are files
               );
  //printf("gd=`%s': pageDict=%d\n",gd->name().data(),gd->pageDict->count());
  if (addToIndex)
  {
592 593
    Doxygen::indexList->addContentsItem(isDir,dd->shortName(),dd->getReference(),dd->getOutputFileBase(),0,TRUE,TRUE); 
    Doxygen::indexList->incContentsDepth();
594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628
  }
  if (ftv)
  {
    ftv->addContentsItem(isDir,dd->shortName(),dd->getReference(),
                         dd->getOutputFileBase(),0,FALSE,TRUE,dd); 
    ftv->incContentsDepth();
  }

  ol.startIndexListItem();
  ol.startIndexItem(dd->getReference(),dd->getOutputFileBase());
  ol.parseText(dd->shortName());
  ol.endIndexItem(dd->getReference(),dd->getOutputFileBase());
  if (dd->isReference()) 
  { 
    ol.startTypewriter(); 
    ol.docify(" [external]");
    ol.endTypewriter();
  }

  // write sub directories
  if (dd->subDirs().count()>0)
  {
    startIndexHierarchy(ol,level+1);
    QListIterator<DirDef> dli(dd->subDirs());
    DirDef *subdd = 0;
    for (dli.toFirst();(subdd=dli.current());++dli)
    {
      writeDirTreeNode(ol,subdd,level+1,ftv,addToIndex);
    }
    endIndexHierarchy(ol,level+1); 
  }

  FileList *fileList=dd->getFiles();
  int fileCount=0;
  if (fileList && fileList->count()>0)
629 630 631 632
  {
    QListIterator<FileDef> it(*fileList);
    FileDef *fd;
    for (;(fd=it.current());++it)
633
    {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
634 635 636 637 638 639 640 641 642 643 644
      //static bool allExternals = Config_getBool("ALLEXTERNALS");
      //if ((allExternals && fd->isLinkable()) || fd->isLinkableInProject())
      //{
      //  fileCount++;
      //}
      bool genSourceFile;
      if (fileVisibleInIndex(fd,genSourceFile))
      {
        fileCount++;
      }
      else if (genSourceFile)
645 646 647 648 649 650 651
      {
        fileCount++;
      }
    }
    if (fileCount>0)
    {
      startIndexHierarchy(ol,level+1);
652
      for (it.toFirst();(fd=it.current());++it)
653
      {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
654 655
        bool doc,src;
        doc = fileVisibleInIndex(fd,src);
656 657 658 659 660 661 662
        QCString reference;
        QCString outputBase;
        if (doc) 
        {
          reference  = fd->getReference();
          outputBase = fd->getOutputFileBase();
        }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
663
        if (doc || src)
664 665
        {
          ol.startIndexListItem();
666
          ol.startIndexItem(reference,outputBase);
667
          ol.parseText(fd->displayName());
668
          ol.endIndexItem(reference,outputBase);
669
          ol.endIndexListItem();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
670
          if (ftv && (src || doc))
Dimitri van Heesch's avatar
Dimitri van Heesch committed
671 672 673
          {
            ftv->addContentsItem(FALSE,
                fd->displayName(),
674 675
                reference,outputBase,
                0,FALSE,FALSE,fd); 
Dimitri van Heesch's avatar
Dimitri van Heesch committed
676
          }
677 678 679 680 681 682 683 684 685 686 687
        }
      }
      endIndexHierarchy(ol,level+1); 
    }
  }

  if (tocExpand && addToIndex)
  {
    // write files of this directory
    if (fileCount>0)
    {
688 689 690
      QListIterator<FileDef> it(*fileList);
      FileDef *fd;
      for (;(fd=it.current());++it)
691
      {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
692 693 694 695 696 697 698 699 700
        //static bool allExternals = Config_getBool("ALLEXTERNALS");
        //if ((allExternals && fd->isLinkable()) || fd->isLinkableInProject())
        bool doc,src;
        doc = fileVisibleInIndex(fd,src);
        if (doc)
        {
          addMembersToIndex(fd,LayoutDocManager::File,fd->displayName(),QCString(),TRUE);
        }
        else if (src)
701
        {
702
          Doxygen::indexList->addContentsItem(
Dimitri van Heesch's avatar
Dimitri van Heesch committed
703 704
               FALSE, convertToHtml(fd->name(),TRUE), 0, 
               fd->getSourceFileBase(), 0, FALSE, TRUE, fd);
705 706 707 708 709 710 711 712
        }
      }
    }
  }
  ol.endIndexListItem();

  if (addToIndex)
  {
713
    Doxygen::indexList->decContentsDepth();
714 715 716 717 718 719 720 721 722 723 724 725 726 727
  }
  if (ftv)
  {
    ftv->decContentsDepth();
  }
}

static void writeDirHierarchy(OutputList &ol, FTVHelp* ftv,bool addToIndex)
{
  if (ftv)
  {
    ol.pushGeneratorState(); 
    ol.disable(OutputGenerator::Html);
  }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
728
  static bool fullPathNames = Config_getBool("FULL_PATH_NAMES");
729
  startIndexHierarchy(ol,0);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
730
  if (fullPathNames)
731
  {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
732 733 734
    SDict<DirDef>::Iterator dli(*Doxygen::directories);
    DirDef *dd;
    for (dli.toFirst();(dd=dli.current());++dli)
735
    {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
736 737 738 739
      if (dd->getOuterScope()==Doxygen::globalScope) 
      {
        writeDirTreeNode(ol,dd,0,ftv,addToIndex);
      }
740 741 742 743 744 745 746 747 748 749 750 751
    }
  }
  if (ftv)
  {
    FileNameListIterator fnli(*Doxygen::inputNameList); 
    FileName *fn;
    for (fnli.toFirst();(fn=fnli.current());++fnli)
    {
      FileNameIterator fni(*fn);
      FileDef *fd;
      for (;(fd=fni.current());++fni)
      {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
752
        static bool fullPathNames = Config_getBool("FULL_PATH_NAMES");
Dimitri van Heesch's avatar
Dimitri van Heesch committed
753
        if (!fullPathNames || fd->getDirDef()==0) // top level file
754
        {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
755 756
          bool doc,src;
          doc = fileVisibleInIndex(fd,src);
757
          QCString reference, outputBase;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
758
          if (doc)
759
          {
760 761
            reference = fd->getReference();
            outputBase = fd->getOutputFileBase();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
762
          }
763 764 765 766 767 768
          if (doc || src)
          {
            ftv->addContentsItem(FALSE,fd->displayName(),          
                                 reference, outputBase, 0,         
                                 FALSE,FALSE,fd);
          }
769
          if (addToIndex)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
770
          {
771 772 773 774 775 776
            if (doc)
            {
              addMembersToIndex(fd,LayoutDocManager::File,fd->displayName(),QCString(),TRUE);
            }
            else if (src)
            {
777
              Doxygen::indexList->addContentsItem(
778 779 780
                  FALSE, convertToHtml(fd->name(),TRUE), 0, 
                  fd->getSourceFileBase(), 0, FALSE, TRUE, fd);
            }
781 782 783 784 785 786 787 788 789 790 791 792 793
          }
        }
      }
    }
  }
  endIndexHierarchy(ol,0); 
  if (ftv)
  {
    ol.popGeneratorState(); 
  }
}


Dimitri van Heesch's avatar
Dimitri van Heesch committed
794 795
//----------------------------------------------------------------------------

796
static void writeClassTreeForList(OutputList &ol,ClassSDict *cl,bool &started,FTVHelp* ftv,bool addToIndex)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
797
{
798
  ClassSDict::Iterator cli(*cl);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
799 800 801
  for (;cli.current(); ++cli)
  {
    ClassDef *cd=cli.current();
802 803 804 805 806
    //printf("class %s hasVisibleRoot=%d isVisibleInHierarchy=%d\n",
    //             cd->name().data(),
    //              hasVisibleRoot(cd->baseClasses()),
    //              cd->isVisibleInHierarchy()
    //      );
Dimitri van Heesch's avatar
Dimitri van Heesch committed
807
    bool b;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
808
    if (cd->getLanguage()==SrcLangExt_VHDL)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
809
    {
810
      if (!(VhdlDocGen::VhdlClasses)cd->protection()==VhdlDocGen::ENTITYCLASS)      
Dimitri van Heesch's avatar
Dimitri van Heesch committed
811 812 813 814 815 816 817 818 819 820 821
      {
        continue;
      }
      b=!hasVisibleRoot(cd->subClasses());
    }
    else
    {
      b=!hasVisibleRoot(cd->baseClasses());
    }

    if (b)  //filter on root classes
Dimitri van Heesch's avatar
Dimitri van Heesch committed
822
    {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
823
      if (cd->isVisibleInHierarchy()) // should it be visible
Dimitri van Heesch's avatar
Dimitri van Heesch committed
824 825 826
      {
        if (!started)
        {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
827
          startIndexHierarchy(ol,0);
828 829
          if (addToIndex)
          {
830
            Doxygen::indexList->incContentsDepth();
831
          }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
832 833
          started=TRUE;
        }
834
        ol.startIndexListItem();
835 836
        bool hasChildren = !cd->visited && classHasVisibleChildren(cd); 
        //printf("list: Has children %s: %d\n",cd->name().data(),hasChildren);
837
        if (cd->isLinkable())
Dimitri van Heesch's avatar
Dimitri van Heesch committed
838
        {
839 840
          //printf("Writing class %s isLinkable()=%d isLinkableInProject()=%d cd->templateMaster()=%p\n",
          //    cd->displayName().data(),cd->isLinkable(),cd->isLinkableInProject(),cd->templateMaster());
841 842 843
          ol.startIndexItem(cd->getReference(),cd->getOutputFileBase());
          ol.parseText(cd->displayName());
          ol.endIndexItem(cd->getReference(),cd->getOutputFileBase());
Dimitri van Heesch's avatar
Dimitri van Heesch committed
844 845 846 847 848 849
          if (cd->isReference()) 
          {
            ol.startTypewriter(); 
            ol.docify(" [external]");
            ol.endTypewriter();
          }
850 851
          if (addToIndex)
          {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
852
            if (cd->getLanguage()!=SrcLangExt_VHDL) // prevents double insertion in Design Unit List
853
            	  Doxygen::indexList->addContentsItem(hasChildren,cd->displayName(),cd->getReference(),cd->getOutputFileBase(),cd->anchor(),FALSE,FALSE);
854
          }
855
          if (ftv)
856
          {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
857
            ftv->addContentsItem(hasChildren,cd->displayName(),cd->getReference(),cd->getOutputFileBase(),cd->anchor(),FALSE,FALSE,cd); 
858
          }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
859 860 861
        }
        else
        {
862 863 864
          ol.startIndexItem(0,0);
          ol.parseText(cd->displayName());
          ol.endIndexItem(0,0);
865 866
          if (addToIndex)
          {
867
            Doxygen::indexList->addContentsItem(hasChildren,cd->displayName(),0,0,0,FALSE,FALSE);
868
          }
869
          if (ftv)
870
          {
871
            ftv->addContentsItem(hasChildren,cd->displayName(),0,0,0,FALSE,FALSE,cd); 
872
          }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
873
        }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
874
        if (cd->getLanguage()==SrcLangExt_VHDL && hasChildren) 
Dimitri van Heesch's avatar
Dimitri van Heesch committed
875
        {
876
          writeClassTree(ol,cd->baseClasses(),cd->visited,1,ftv,addToIndex);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
877 878 879
          cd->visited=TRUE;
        }
        else if (hasChildren)
880
        {
881
          writeClassTree(ol,cd->subClasses(),cd->visited,1,ftv,addToIndex);
882 883
          cd->visited=TRUE;
        }
884
        ol.endIndexListItem();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
885 886 887
      }
    }
  }
888 889
}

890
static void writeClassHierarchy(OutputList &ol, FTVHelp* ftv,bool addToIndex)
891
{
892 893
  initClassHierarchy(Doxygen::classSDict);
  initClassHierarchy(Doxygen::hiddenClasses);
894 895 896 897 898
  if (ftv)
  {
    ol.pushGeneratorState(); 
    ol.disable(OutputGenerator::Html);
  }
899
  bool started=FALSE;
900 901
  writeClassTreeForList(ol,Doxygen::classSDict,started,ftv,addToIndex);
  writeClassTreeForList(ol,Doxygen::hiddenClasses,started,ftv,addToIndex);
902 903
  if (started) 
  {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
904
    endIndexHierarchy(ol,0);
905 906
    if (addToIndex)
    {
907
      Doxygen::indexList->decContentsDepth();
908
    }
909
  }
910
  if (ftv)
911
  {
912
    ol.popGeneratorState(); 
913
  }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
914 915 916 917
}

//----------------------------------------------------------------------------

918 919 920 921 922 923 924 925 926 927 928
static int countClassesInTreeList(const ClassSDict &cl)
{
  int count=0;
  ClassSDict::Iterator cli(cl);
  for (;cli.current(); ++cli)
  {
    ClassDef *cd=cli.current();
    if (!hasVisibleRoot(cd->baseClasses())) // filter on root classes
    {
      if (cd->isVisibleInHierarchy()) // should it be visible
      {
929
        if (cd->subClasses()) // should have sub classes
Dimitri van Heesch's avatar
Dimitri van Heesch committed
930 931 932
        {
          count++;
        }
933 934 935 936 937 938
      }
    }
  }
  return count;
}

939
static int countClassHierarchy()
Dimitri van Heesch's avatar
Dimitri van Heesch committed
940
{
941
  int count=0;
942 943 944 945
  initClassHierarchy(Doxygen::classSDict);
  initClassHierarchy(Doxygen::hiddenClasses);
  count+=countClassesInTreeList(*Doxygen::classSDict);
  count+=countClassesInTreeList(*Doxygen::hiddenClasses);
946
  return count;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
947 948 949 950
}

//----------------------------------------------------------------------------

951
static void writeHierarchicalIndex(OutputList &ol)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
952 953
{
  if (hierarchyClasses==0) return;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
954
  ol.pushGeneratorState();
955
  //1.{
Dimitri van Heesch's avatar
Dimitri van Heesch committed
956
  ol.disable(OutputGenerator::Man);
957

958
  LayoutNavEntry *lne = LayoutDocManager::instance().rootNavEntry()->find(LayoutNavEntry::ClassHierarchy);
959
  QCString title = lne ? lne->title() : theTranslator->trClassHierarchy();
960 961
  bool addToIndex = lne==0 || lne->visible();

962
  startFile(ol,"hierarchy",0, title, HLI_Hierarchy);
963
  startTitle(ol,0);
964
  ol.parseText(title);
965
  endTitle(ol,0,0);
966
  ol.startContents();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
967
  ol.startTextBlock();
968

969
  if (Config_getBool("HAVE_DOT") && Config_getBool("GRAPHICAL_HIERARCHY"))
Dimitri van Heesch's avatar
Dimitri van Heesch committed
970 971 972
  {
    ol.disable(OutputGenerator::Latex);
    ol.disable(OutputGenerator::RTF);
973
    ol.startParagraph();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
974
    ol.startTextLink("inherits",0);
975
    ol.parseText(theTranslator->trGotoGraphicalHierarchy());
Dimitri van Heesch's avatar
Dimitri van Heesch committed
976
    ol.endTextLink();
977
    ol.endParagraph();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
978 979 980
    ol.enable(OutputGenerator::Latex);
    ol.enable(OutputGenerator::RTF);
  }
981
  ol.parseText(lne ? lne->intro() : theTranslator->trClassHierarchyDescription());
Dimitri van Heesch's avatar
Dimitri van Heesch committed
982
  ol.endTextBlock();
983

984 985 986 987 988 989
  // ---------------
  // Static class hierarchy for Latex/RTF
  // ---------------
  ol.pushGeneratorState();
  //2.{
  ol.disable(OutputGenerator::Html);
990
  Doxygen::indexList->disable();
991

992 993
  writeClassHierarchy(ol,0,addToIndex);

994
  Doxygen::indexList->enable();
995 996 997 998 999 1000 1001 1002 1003
  ol.popGeneratorState();
  //2.}

  // ---------------
  // Dynamic class hierarchical index for HTML
  // ---------------
  ol.pushGeneratorState(); 
  //2.{
  ol.disableAllBut(OutputGenerator::Html);
1004 1005

  {
1006 1007
    if (addToIndex)
    {
1008
      Doxygen::indexList->addContentsItem(TRUE,title,0,"hierarchy",0,TRUE,TRUE); 
1009 1010 1011
    }
    FTVHelp* ftv = new FTVHelp(FALSE);
    writeClassHierarchy(ol,ftv,addToIndex);
1012 1013 1014
    QGString outStr;
    FTextStream t(&outStr);
    ftv->generateTreeViewInline(t);
1015 1016
    ol.pushGeneratorState(); 
    ol.disableAllBut(OutputGenerator::Html);
1017
    ol.writeString(outStr);
1018 1019 1020
    ol.popGeneratorState();
    delete ftv;
  }
1021 1022 1023 1024
  ol.popGeneratorState();
  //2.}
  // ------

Dimitri van Heesch's avatar
Dimitri van Heesch committed
1025
  endFile(ol);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1026
  ol.popGeneratorState();
1027
  //1.}
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1028 1029 1030 1031
}

//----------------------------------------------------------------------------

1032
static void writeGraphicalClassHierarchy(OutputList &ol)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1033 1034 1035
{
  if (hierarchyClasses==0) return;
  ol.disableAllBut(OutputGenerator::Html);
1036
  LayoutNavEntry *lne = LayoutDocManager::instance().rootNavEntry()->find(LayoutNavEntry::ClassHierarchy);
1037
  QCString title = lne ? lne->title() : theTranslator->trClassHierarchy();
1038
  startFile(ol,"inherits",0,title,HLI_Hierarchy,FALSE,"hierarchy");
1039
  startTitle(ol,0);
1040
  ol.parseText(title);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1041
  endTitle(ol,0,0);
1042
  ol.startContents();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1043
  ol.startTextBlock();
1044
  ol.startParagraph();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1045
  ol.startTextLink("hierarchy",0);
1046
  ol.parseText(theTranslator->trGotoTextualHierarchy());
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1047
  ol.endTextLink();
1048
  ol.endParagraph();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1049 1050 1051 1052 1053
  ol.endTextBlock();
  DotGfxHierarchyTable g;
  ol.writeGraphicalHierarchy(g);
  endFile(ol);
  ol.enableAll();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1054 1055 1056 1057
}

//----------------------------------------------------------------------------

1058
static void countFiles(int &htmlFiles,int &files)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1059
{
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1060 1061
  htmlFiles=0;
  files=0;
1062
  FileNameListIterator fnli(*Doxygen::inputNameList);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1063 1064 1065 1066 1067 1068 1069
  FileName *fn;
  for (;(fn=fnli.current());++fnli)
  {
    FileNameIterator fni(*fn);
    FileDef *fd;
    for (;(fd=fni.current());++fni)
    {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1070 1071 1072
      bool doc,src;
      doc = fileVisibleInIndex(fd,src);
      if (doc || src)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1073
      {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1074 1075 1076 1077 1078
        htmlFiles++;
      }
      if (doc)
      {
        files++;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1079
      }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1080 1081 1082 1083
    }
  }
}

1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159
static void writeSingleFileIndex(OutputList &ol,FileDef *fd)
{
  //printf("Found filedef %s\n",fd->name().data());
  bool doc = fd->isLinkableInProject();
  bool src = fd->generateSourceFile();
  bool nameOk = !fd->isDocumentationFile();
  if (nameOk && (doc || src) && !fd->isReference())
  {
    QCString path;
    if (Config_getBool("FULL_PATH_NAMES"))
    {
      path=stripFromPath(fd->getPath().copy());
    }
    QCString fullName=fd->name();
    if (!path.isEmpty())
    {
      if (path.at(path.length()-1)!='/') fullName.prepend("/");
      fullName.prepend(path);
    }

    ol.startIndexKey();
    ol.docify(path);
    if (doc)
    {
      ol.writeObjectLink(0,fd->getOutputFileBase(),0,fd->name());
      //if (addToIndex)
      //{
      //  addMembersToIndex(fd,LayoutDocManager::File,fullName,QCString());
      //}
    }
    else
    {
      ol.startBold();
      ol.docify(fd->name());
      ol.endBold();
      //if (addToIndex)
      //{
      //  Doxygen::indexList->addContentsItem(FALSE,fullName,0,0,0);
      //}
    }
    if (src)
    {
      ol.pushGeneratorState();
      ol.disableAllBut(OutputGenerator::Html);
      ol.docify(" ");
      ol.startTextLink(fd->includeName(),0);
      ol.docify("[");
      ol.parseText(theTranslator->trCode());
      ol.docify("]");
      ol.endTextLink();
      ol.popGeneratorState();
    }
    ol.endIndexKey();
    bool hasBrief = !fd->briefDescription().isEmpty();
    ol.startIndexValue(hasBrief);
    if (hasBrief)
    {
      //ol.docify(" (");
      ol.generateDoc(
          fd->briefFile(),fd->briefLine(),
          fd,0,
          fd->briefDescription(TRUE),
          FALSE, // index words
          FALSE, // isExample
          0,     // example name
          TRUE,  // single line
          TRUE   // link from index
          );
      //ol.docify(")");
    }
    ol.endIndexValue(fd->getOutputFileBase(),hasBrief);
    //ol.popGeneratorState();
    // --------------------------------------------------------
  }
}

Dimitri van Heesch's avatar
Dimitri van Heesch committed
1160 1161
//----------------------------------------------------------------------------

1162
static void writeFileIndex(OutputList &ol)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1163
{
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1164
  if (documentedHtmlFiles==0) return;
1165

Dimitri van Heesch's avatar
Dimitri van Heesch committed
1166
  ol.pushGeneratorState();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1167
  ol.disable(OutputGenerator::Man);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1168
  if (documentedFiles==0) ol.disableAllBut(OutputGenerator::Html);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1169

1170 1171 1172
  LayoutNavEntry *lne = LayoutDocManager::instance().rootNavEntry()->find(LayoutNavEntry::FileList);
  if (lne==0) lne = LayoutDocManager::instance().rootNavEntry()->find(LayoutNavEntry::Files); // fall back
  QCString title = lne ? lne->title() : theTranslator->trFileList();
1173 1174
  bool addToIndex = lne==0 || lne->visible();

1175
  startFile(ol,"files",0,title,HLI_Files);
1176
  startTitle(ol,0);
1177 1178 1179 1180
  //if (!Config_getString("PROJECT_NAME").isEmpty()) 
  //{
  //  title.prepend(Config_getString("PROJECT_NAME")+" ");
  //}
1181
  ol.parseText(title);
1182
  endTitle(ol,0,0);
1183
  ol.startContents();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1184
  ol.startTextBlock();
1185 1186 1187

  if (addToIndex)
  {
1188 1189
    Doxygen::indexList->addContentsItem(TRUE,title,0,"files",0,TRUE,TRUE); 
    Doxygen::indexList->incContentsDepth();
1190 1191
  }

1192
  ol.parseText(lne ? lne->intro() : theTranslator->trFileListDescription(Config_getBool("EXTRACT_ALL")));
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1193
  ol.endTextBlock();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1194

1195 1196 1197 1198 1199 1200 1201 1202
  // ---------------
  // Flat file index
  // ---------------

  // 1. {
  ol.pushGeneratorState();
  ol.disable(OutputGenerator::Html);

1203 1204 1205
  OutputNameDict outputNameDict(1009);
  OutputNameList outputNameList;
  outputNameList.setAutoDelete(TRUE);
1206

1207
  if (Config_getBool("FULL_PATH_NAMES"))
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1208
  {
1209
    // re-sort input files in (dir,file) output order instead of (file,dir) input order 
1210 1211 1212
    FileNameListIterator fnli(*Doxygen::inputNameList);
    FileName *fn;
    for (fnli.toFirst();(fn=fnli.current());++fnli)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1213
    {
1214 1215 1216
      FileNameIterator fni(*fn);
      FileDef *fd;
      for (;(fd=fni.current());++fni)
1217
      {
1218 1219 1220 1221 1222
        QCString path=fd->getPath();
        if (path.isEmpty()) path="[external]";
        FileList *fl = outputNameDict.find(path);
        if (fl)
        {
1223
          fl->append(fd);
1224 1225 1226 1227 1228 1229
          //printf("+ inserting %s---%s\n",fd->getPath().data(),fd->name().data());
        }
        else
        {
          //printf("o inserting %s---%s\n",fd->getPath().data(),fd->name().data());
          fl = new FileList(path);
1230 1231
          fl->append(fd);
          outputNameList.append(fl);
1232 1233
          outputNameDict.insert(path,fl);
        }
1234 1235 1236
      }
    }
  }
1237

1238
  ol.startIndexList();
1239
  if (Config_getBool("FULL_PATH_NAMES"))
1240
  {
1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253
    outputNameList.sort();
    QListIterator<FileList> fnli(outputNameList);
    FileList *fl;
    for (fnli.toFirst();(fl=fnli.current());++fnli)
    {
      fl->sort();
      QListIterator<FileDef> it(*fl);
      FileDef *fd;
      for (;(fd=it.current());++it)
      {
        writeSingleFileIndex(ol,fd);
      }
    }
1254 1255 1256
  }
  else
  {
1257 1258 1259
    FileNameListIterator fnli(*Doxygen::inputNameList);
    FileName *fn;
    for (fnli.toFirst();(fn=fnli.current());++fnli)
1260
    {
1261 1262 1263
      FileNameIterator fni(*fn);
      FileDef *fd;
      for (;(fd=fni.current());++fni)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1264
      {
1265
        writeSingleFileIndex(ol,fd);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1266
      }
1267
    }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1268 1269
  }
  ol.endIndexList();
1270

1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290
  // 1. }
  ol.popGeneratorState();

  // ---------------
  // Hierarchical file index for HTML
  // ---------------
  ol.pushGeneratorState(); 
  ol.disableAllBut(OutputGenerator::Html);

  FTVHelp* ftv = new FTVHelp(FALSE);
  writeDirHierarchy(ol,ftv,addToIndex);
  QGString outStr;
  FTextStream t(&outStr);
  ftv->generateTreeViewInline(t);
  ol.writeString(outStr);
  delete ftv;

  ol.popGeneratorState();
  // ------

1291 1292
  if (addToIndex)
  {
1293
    Doxygen::indexList->decContentsDepth();
1294 1295
  }

1296
  endFile(ol);
1297
  ol.popGeneratorState();
1298 1299
}

Dimitri van Heesch's avatar
Dimitri van Heesch committed
1300
//----------------------------------------------------------------------------
1301
static int countNamespaces()
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1302 1303
{
  int count=0;
1304
  NamespaceSDict::Iterator nli(*Doxygen::namespaceSDict);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1305 1306 1307
  NamespaceDef *nd;
  for (;(nd=nli.current());++nli)
  {
1308
    if (nd->isLinkableInProject()) count++;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1309 1310 1311 1312 1313 1314
  }
  return count;
}

//----------------------------------------------------------------------------

1315 1316 1317 1318 1319 1320 1321 1322
void writeClassTree(ClassSDict *clDict,FTVHelp *ftv,bool addToIndex,bool globalOnly)
{
  if (clDict)
  {
    ClassSDict::Iterator cli(*clDict);
    ClassDef *cd;
    for (;(cd=cli.current());++cli)
    {
1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337
      if (cd->getLanguage()==SrcLangExt_VHDL) 
      {
        if ((VhdlDocGen::VhdlClasses)cd->protection()==VhdlDocGen::PACKAGECLASS || 
            (VhdlDocGen::VhdlClasses)cd->protection()==VhdlDocGen::PACKBODYCLASS
           )// no architecture
        {
          continue;
        }
        if ((VhdlDocGen::VhdlClasses)cd->protection()==VhdlDocGen::ARCHITECTURECLASS)
        {
          QCString n=cd->name();
          cd->setClassName(n.data());
        }         
      }

1338
      if (!globalOnly || 
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1339 1340 1341
           cd->getOuterScope()==0 || 
           cd->getOuterScope()==Doxygen::globalScope 
         ) 
1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355
      {
        int count=0;
        if (cd->getClassSDict())
        {
          ClassSDict::Iterator ccit(*cd->getClassSDict());
          ClassDef *ccd;
          for (;(ccd=ccit.current());++ccit)
          {
            if (ccd->isLinkableInProject() && ccd->templateMaster()==0) 
            {
              count++;
            }
          }
        }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1356
        if (classVisibleInIndex(cd) && cd->templateMaster()==0) 
1357
        { 
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1358 1359
          ftv->addContentsItem(count>0,cd->displayName(FALSE),cd->getReference(),
              cd->getOutputFileBase(),cd->anchor(),FALSE,TRUE,cd); 
1360
          if (addToIndex && 
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1361
              /*cd->partOfGroups()==0 &&*/
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1362 1363 1364 1365
              (cd->getOuterScope()==0 || 
               cd->getOuterScope()->definitionType()!=Definition::TypeClass
              )
             )
1366
          {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1367
            addMembersToIndex(cd,LayoutDocManager::Class,cd->displayName(FALSE),cd->anchor(),cd->partOfGroups()==0);
1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389
          }
          if (count>0)
          {
            ftv->incContentsDepth();
            writeClassTree(cd->getClassSDict(),ftv,addToIndex,FALSE);
            ftv->decContentsDepth();
          }
        }
      }
    }
  }
}

static void writeNamespaceTree(NamespaceSDict *nsDict,FTVHelp *ftv,
                               bool rootOnly,bool showClasses,bool addToIndex)
{
  if (nsDict)
  {
    NamespaceSDict::Iterator nli(*nsDict);
    NamespaceDef *nd;
    for (nli.toFirst();(nd=nli.current());++nli)
    {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1390
      if (nd->localName().find('@')==-1 && 
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1391
          (!rootOnly || nd->getOuterScope()==Doxygen::globalScope))
1392 1393
      {

1394
        bool hasChildren = namespaceHasVisibleChild(nd,showClasses);
1395 1396
        bool isLinkable  = nd->isLinkableInProject();

Dimitri van Heesch's avatar
Dimitri van Heesch committed
1397 1398
        QCString ref; 
        QCString file; 
1399
        if (isLinkable)
1400
        {
1401
          ref  = nd->getReference();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1402 1403 1404
          file = nd->getOutputFileBase();
          if (nd->getLanguage()==SrcLangExt_VHDL) // UGLY HACK
          {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1405
            file=file.replace(0,qstrlen("namespace"),"class");
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1406
          }
1407
        }
1408

1409
        if (isLinkable || hasChildren)
1410
        {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1411
          ftv->addContentsItem(hasChildren,nd->localName(),ref,file,0,FALSE,TRUE,nd); 
1412

Dimitri van Heesch's avatar
Dimitri van Heesch committed
1413
          if (addToIndex)
1414
          {
1415
            Doxygen::indexList->addContentsItem(hasChildren,nd->localName(),ref,file,QCString(),
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1416 1417 1418 1419 1420 1421 1422
                hasChildren && !file.isEmpty(),addToIndex);
          }

          //printf("*** writeNamespaceTree count=%d addToIndex=%d showClasses=%d classCount=%d\n",
          //    count,addToIndex,showClasses,classCount);
          if (hasChildren)
          {
1423
            if (addToIndex) Doxygen::indexList->incContentsDepth();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1424 1425 1426 1427 1428 1429 1430
            ftv->incContentsDepth();
            writeNamespaceTree(nd->getNamespaceSDict(),ftv,FALSE,showClasses,addToIndex);
            if (showClasses) 
            {
              writeClassTree(nd->getClassSDict(),ftv,addToIndex,FALSE);
            }
            ftv->decContentsDepth();
1431
            if (addToIndex) Doxygen::indexList->decContentsDepth();
1432 1433 1434 1435 1436 1437 1438 1439
          }
        }
      }
    }
  }
}


1440
static void writeNamespaceIndex(OutputList &ol)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1441 1442
{
  if (documentedNamespaces==0) return;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1443
  ol.pushGeneratorState();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1444
  ol.disable(OutputGenerator::Man);
1445 1446 1447
  LayoutNavEntry *lne = LayoutDocManager::instance().rootNavEntry()->find(LayoutNavEntry::NamespaceList);
  if (lne==0) lne = LayoutDocManager::instance().rootNavEntry()->find(LayoutNavEntry::Namespaces); // fall back
  QCString title = lne ? lne->title() : theTranslator->trNamespaceList();
1448
  bool addToIndex = lne==0 || lne->visible();
1449
  startFile(ol,"namespaces",0,title,HLI_Namespaces);
1450
  startTitle(ol,0);
1451
  ol.parseText(title);
1452
  endTitle(ol,0,0);
1453
  ol.startContents();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1454
  ol.startTextBlock();
1455
  ol.parseText(lne ? lne->intro() : theTranslator->trNamespaceListDescription(Config_getBool("EXTRACT_ALL")));
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1456
  ol.endTextBlock();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1457

Dimitri van Heesch's avatar
Dimitri van Heesch committed
1458
  bool first=TRUE;
1459

1460 1461 1462 1463 1464 1465
  // ---------------
  // Linear namespace index for Latex/RTF
  // ---------------
  ol.pushGeneratorState();
  ol.disable(OutputGenerator::Html);
  
1466
  NamespaceSDict::Iterator nli(*Doxygen::namespaceSDict);
1467 1468
  NamespaceDef *nd;
  for (nli.toFirst();(nd=nli.current());++nli)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1469
  {
1470
    if (nd->isLinkableInProject())
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1471
    {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1472 1473 1474 1475 1476
      if (first)
      {
        ol.startIndexList();
        first=FALSE;
      }
1477 1478
      //ol.writeStartAnnoItem("namespace",nd->getOutputFileBase(),0,nd->name());
      ol.startIndexKey();
1479 1480
      if (nd->getLanguage()==SrcLangExt_VHDL)
      {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1481
        ol.writeObjectLink(0, nd->getOutputFileBase().replace(0,qstrlen("namespace"),"class"),0,nd->displayName());
1482 1483 1484 1485 1486
      }
      else
      {
        ol.writeObjectLink(0,nd->getOutputFileBase(),0,nd->displayName());
      }
1487
      ol.endIndexKey();
1488

1489 1490 1491
      bool hasBrief = !nd->briefDescription().isEmpty();
      ol.startIndexValue(hasBrief);
      if (hasBrief)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1492
      {
1493
        //ol.docify(" (");
1494
        ol.generateDoc(
1495
                 nd->briefFile(),nd->briefLine(),
1496
                 nd,0,
1497
                 nd->briefDescription(TRUE),
1498
                 FALSE, // index words
1499 1500 1501 1502
                 FALSE, // isExample
                 0,     // example name
                 TRUE,  // single line
                 TRUE   // link from index
1503
                );
1504
        //ol.docify(")");
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1505
      }
1506
      ol.endIndexValue(nd->getOutputFileBase(),hasBrief);
1507

Dimitri van Heesch's avatar
Dimitri van Heesch committed
1508 1509
    }
  }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1510
  if (!first) ol.endIndexList();
1511 1512 1513 1514 1515 1516 1517 1518 1519

  ol.popGeneratorState();

  // ---------------
  // Hierarchical namespace index for HTML
  // ---------------
  ol.pushGeneratorState(); 
  ol.disableAllBut(OutputGenerator::Html);

1520
  {
1521 1522
    if (addToIndex)
    {
1523 1524
      Doxygen::indexList->addContentsItem(TRUE,title,0,"namespaces",0,TRUE,TRUE); 
      Doxygen::indexList->incContentsDepth();
1525 1526
    }
    FTVHelp* ftv = new FTVHelp(FALSE);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1527
    writeNamespaceTree(Doxygen::namespaceSDict,ftv,TRUE,FALSE,addToIndex);
1528 1529 1530 1531 1532 1533 1534
    QGString outStr;
    FTextStream t(&outStr);
    ftv->generateTreeViewInline(t);
    ol.writeString(outStr);
    delete ftv;
    if (addToIndex)
    {
1535
      Doxygen::indexList->decContentsDepth();
1536
    }
1537
  }
1538 1539 1540 1541

  ol.popGeneratorState();
  // ------

Dimitri van Heesch's avatar
Dimitri van Heesch committed
1542
  endFile(ol);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1543
  ol.popGeneratorState();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1544 1545 1546 1547
}

//----------------------------------------------------------------------------

1548
static int countAnnotatedClasses(int *cp)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1549 1550
{
  int count=0;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1551
  int countPrinted=0;
1552
  ClassSDict::Iterator cli(*Doxygen::classSDict);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1553 1554 1555
  ClassDef *cd;
  for (;(cd=cli.current());++cli)
  {
1556
    if (cd->isLinkableInProject() && cd->templateMaster()==0) 
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1557
    { 
1558
      if (!cd->isEmbeddedInOuterScope())
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1559 1560 1561
      {
        countPrinted++;
      }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1562 1563 1564
      count++; 
    }
  }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1565
  *cp = countPrinted;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1566 1567 1568
  return count;
}

Dimitri van Heesch's avatar
Dimitri van Heesch committed
1569

1570
static void writeAnnotatedClassList(OutputList &ol)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1571
{
1572 1573
  //LayoutNavEntry *lne = LayoutDocManager::instance().rootNavEntry()->find(LayoutNavEntry::ClassList);
  //bool addToIndex = lne==0 || lne->visible();
1574

Dimitri van Heesch's avatar
Dimitri van Heesch committed
1575
  ol.startIndexList(); 
1576
  ClassSDict::Iterator cli(*Doxygen::classSDict);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1577
  ClassDef *cd;
1578 1579 1580
  
  for (cli.toFirst();(cd=cli.current());++cli)
  {
1581 1582 1583 1584 1585
    if (cd->getLanguage()==SrcLangExt_VHDL && 
        ((VhdlDocGen::VhdlClasses)cd->protection()==VhdlDocGen::PACKAGECLASS || 
         (VhdlDocGen::VhdlClasses)cd->protection()==VhdlDocGen::PACKBODYCLASS)
       ) // no architecture
    {
1586
      continue;
1587
    }
1588
 
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1589
    ol.pushGeneratorState();
1590
    if (cd->isEmbeddedInOuterScope())
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1591 1592 1593 1594
    {
      ol.disable(OutputGenerator::Latex);
      ol.disable(OutputGenerator::RTF);
    }
1595
    if (cd->isLinkableInProject() && cd->templateMaster()==0)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1596
    {
1597
      QCString type=cd->compoundTypeString();
1598
      ol.startIndexKey();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1599
      if (cd->getLanguage()==SrcLangExt_VHDL)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1600 1601 1602
      {
        QCString prot= VhdlDocGen::getProtectionName((VhdlDocGen::VhdlClasses)cd->protection());
        ol.docify(prot.data());
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1603
        ol.writeString(" ");
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1604
      }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1605
      ol.writeObjectLink(0,cd->getOutputFileBase(),cd->anchor(),cd->displayName());
1606
      ol.endIndexKey();
1607 1608 1609
      bool hasBrief = !cd->briefDescription().isEmpty();
      ol.startIndexValue(hasBrief);
      if (hasBrief)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1610
      {
1611
        ol.generateDoc(
1612
                 cd->briefFile(),cd->briefLine(),
1613
                 cd,0,
1614
                 cd->briefDescription(TRUE),
1615
                 FALSE,  // indexWords
1616 1617 1618 1619
                 FALSE,  // isExample
                 0,     // example name
                 TRUE,  // single line
                 TRUE   // link from index
1620
                );
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1621
      }
1622
      ol.endIndexValue(cd->getOutputFileBase(),hasBrief);
1623

1624 1625 1626 1627
      //if (addToIndex)
      //{
      //  addMembersToIndex(cd,LayoutDocManager::Class,cd->displayName(),cd->anchor());
      //}
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1628
    }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1629
    ol.popGeneratorState();
1630 1631 1632 1633
  }
  ol.endIndexList();
}

1634
static QCString letterToLabel(uint startLetter)
1635
{
1636 1637
  char s[10];
  if (startLetter>0x20 && startLetter<=0x7f) // printable ASCII character
1638
  {
1639 1640
    s[0]=(char)startLetter;
    s[1]=0;
1641 1642 1643 1644
  }
  else
  {
    const char hex[]="0123456789abcdef";
1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666
    int i=0;
    s[i++]='0';
    s[i++]='x';
    if (startLetter>(1<<24)) // 4 byte character
    {
      s[i++]=hex[(startLetter>>28)&0xf];
      s[i++]=hex[(startLetter>>24)&0xf];
    }
    if (startLetter>(1<<16)) // 3 byte character
    {
      s[i++]=hex[(startLetter>>20)&0xf];
      s[i++]=hex[(startLetter>>16)&0xf];
    }
    if (startLetter>(1<<8)) // 2 byte character
    {
      s[i++]=hex[(startLetter>>12)&0xf];
      s[i++]=hex[(startLetter>>8)&0xf];
    }
    // one byte character
    s[i++]=hex[(startLetter>>4)&0xf];
    s[i++]=hex[(startLetter>>0)&0xf];
    s[i++]=0;
1667 1668 1669 1670
  }
  return s;
}

1671 1672
//----------------------------------------------------------------------------

Dimitri van Heesch's avatar
Dimitri van Heesch committed
1673
/** Special class list where sorting takes IGNORE_PREFIX into account. */
1674 1675
class PrefixIgnoreClassList : public ClassList
{
1676 1677 1678
  public:
    typedef ClassDef ElementType;
    PrefixIgnoreClassList(uint letter) : m_letter(letter) {}
1679 1680 1681
    uint letter() const { return m_letter; }
  private:
    virtual int compareValue(const ClassDef *c1, const ClassDef *c2) const
1682 1683 1684 1685 1686 1687
    {
      QCString n1 = c1->className();
      QCString n2 = c2->className();
      return qstricmp (n1.data()+getPrefixIndex(n1), n2.data()+getPrefixIndex(n2));
    }
    uint m_letter;
1688 1689
};

Dimitri van Heesch's avatar
Dimitri van Heesch committed
1690
/** Class representing a cell in the alphabetical class index. */
1691 1692 1693
class AlphaIndexTableCell
{
  public:
1694
    AlphaIndexTableCell(int row,int col,uint letter,ClassDef *cd) : 
1695 1696 1697 1698 1699 1700
      m_letter(letter), m_class(cd), m_row(row), m_col(col) 
    { //printf("AlphaIndexTableCell(%d,%d,%c,%s)\n",row,col,letter!=0 ? letter: '-',
      //       cd!=(ClassDef*)0x8 ? cd->name().data() : "<null>"); 
    }

    ClassDef *classDef() const { return m_class; }
1701
    uint letter()        const { return m_letter; }
1702 1703 1704 1705
    int row()            const { return m_row; }
    int column()         const { return m_col; }

  private:
1706
    uint m_letter;
1707 1708 1709 1710 1711
    ClassDef *m_class;
    int m_row;
    int m_col;
};

Dimitri van Heesch's avatar
Dimitri van Heesch committed
1712
/** Class representing a row in the alphabetical class index. */
1713 1714 1715 1716 1717 1718
class AlphaIndexTableRows : public QList<AlphaIndexTableCell>
{
  public:
    AlphaIndexTableRows() { setAutoDelete(TRUE); }
};

Dimitri van Heesch's avatar
Dimitri van Heesch committed
1719
/** Iterator for the cells in a row of the alphabetical class index. */
1720 1721 1722 1723 1724 1725 1726
class AlphaIndexTableRowsIterator : public QListIterator<AlphaIndexTableCell>
{
  public:
    AlphaIndexTableRowsIterator(const AlphaIndexTableRows &list) : 
      QListIterator<AlphaIndexTableCell>(list) {}
};

Dimitri van Heesch's avatar
Dimitri van Heesch committed
1727
/** Class representing the columns in the alphabetical class index. */
1728 1729 1730 1731 1732 1733
class AlphaIndexTableColumns : public QList<AlphaIndexTableRows>
{
  public:
    AlphaIndexTableColumns() { setAutoDelete(TRUE); }
};

1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745
class UsedIndexLetters : public SIntDict<uint>
{
  public:
    UsedIndexLetters() : SIntDict<uint>(257) { setAutoDelete(TRUE); }
    void add(uint letter)
    {
      uint *v = find(letter);
      if (v==0)
      {
        append(letter,new uint(letter));
      }
    }
1746 1747 1748 1749 1750
  private:
    int compareValues( const uint *p1, const uint *p2) const
    {
      return (int)*p1 - (int)*p2; // subtracting is done by int not uint.
    }
1751 1752
};

1753
// write an alphabetical index of all class with a header for each letter
1754
static void writeAlphabeticalClassList(OutputList &ol)
1755
{
1756
  // What starting letters are used
1757
  UsedIndexLetters indexLettersUsed;
1758 1759

  // first count the number of headers
1760
  ClassSDict::Iterator cli(*Doxygen::classSDict);
1761
  ClassDef *cd;
1762
  uint startLetter=0;
1763
  int headerItems=0;
1764
  for (;(cd=cli.current());++cli)
1765
  {
1766
    if (cd->isLinkableInProject() && cd->templateMaster()==0)
1767
    {
1768 1769 1770
      if (cd->getLanguage()==SrcLangExt_VHDL && !((VhdlDocGen::VhdlClasses)cd->protection()==VhdlDocGen::ENTITYCLASS ))// no architecture
        continue;
	     
1771
      int index = getPrefixIndex(cd->className());
1772
      //printf("name=%s index=%d %d\n",cd->className().data(),index,cd->protection());
1773 1774
      startLetter=getUtf8CodeToUpper(cd->className(),index);
      indexLettersUsed.add(startLetter);
1775 1776
    }
  }
1777
  indexLettersUsed.sort();
1778

1779
  // write quick link index (row of letters)
1780
  QCString alphaLinks = "<div class=\"qindex\">";
1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791
  SIntDict<uint>::Iterator it(indexLettersUsed);
  uint *pLetter;
  for (it.toFirst();(pLetter=it.current());++it)
  {
    if (headerItems) alphaLinks += "&#160;|&#160;";
    headerItems++;
    QCString li = letterToLabel(*pLetter);
    QCString ls = QString(QChar(*pLetter)).utf8();
    alphaLinks += (QCString)"<a class=\"qindex\" href=\"#letter_" + 
                  li + "\">" + 
                  ls + "</a>";
1792
  }
1793
  alphaLinks += "</div>\n";
1794 1795
  ol.writeString(alphaLinks);

1796 1797

  // the number of columns in the table
1798
  const int columns = Config_getInt("COLS_IN_ALPHA_INDEX");
1799 1800

  int i,j;
1801
  int totalItems = headerItems*2 + annotatedClasses;      // number of items in the table (headers span 2 items)
1802
  int rows = (totalItems + columns - 1)/columns;          // number of rows in the table
1803 1804 1805 1806

  //printf("headerItems=%d totalItems=%d columns=%d rows=%d itemsInLastRow=%d\n",
  //    headerItems,totalItems,columns,rows,itemsInLastRow);

1807
  // Keep a list of classes for each starting letter
1808
  LetterToIndexMap<PrefixIgnoreClassList> classesByLetter;
1809
  AlphaIndexTableColumns tableColumns;
1810 1811

  // fill the columns with the class list (row elements in each column,
1812
  // expect for the columns with number >= itemsInLastRow, which get one
1813 1814 1815 1816
  // item less.
  //int icount=0;
  startLetter=0;
  for (cli.toFirst();(cd=cli.current());++cli)
1817
  {
1818 1819 1820
    if (cd->getLanguage()==SrcLangExt_VHDL && !((VhdlDocGen::VhdlClasses)cd->protection()==VhdlDocGen::ENTITYCLASS ))// no architecture
      continue;
    
1821
    if (cd->isLinkableInProject() && cd->templateMaster()==0)
1822
    {
1823
      int index = getPrefixIndex(cd->className());
1824
      startLetter=getUtf8Code(cd->className(),index);
1825 1826
      // Do some sorting again, since the classes are sorted by name with 
      // prefix, which should be ignored really.
1827 1828 1829
      if (cd->getLanguage()==SrcLangExt_VHDL)
      {
        if ((VhdlDocGen::VhdlClasses)cd->protection()==VhdlDocGen::ENTITYCLASS )// no architecture
1830 1831 1832
        {
          classesByLetter.append(startLetter,cd);
        }
1833 1834
      }
      else
1835 1836 1837
      {
        classesByLetter.append(startLetter,cd);
      }
1838 1839 1840
    }
  }

1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857
  #define NEXT_ROW()                           \
    do                                         \
    {                                          \
      if (row>maxRows) maxRows=row;            \
      if (row>=rows && col<columns)            \
      {                                        \
        col++;                                 \
        row=0;                                 \
        tableRows = new AlphaIndexTableRows;   \
        tableColumns.append(tableRows);        \
      }                                        \
    }                                          \
    while(0)                                   \

  AlphaIndexTableRows *tableRows = new AlphaIndexTableRows;
  tableColumns.append(tableRows);
  int col=0,row=0,maxRows=0;
1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878
  PrefixIgnoreClassList *cl;
  SIntDict<PrefixIgnoreClassList>::Iterator lit(classesByLetter);
  for (lit.toFirst();(cl=lit.current());++lit)
  {
    uint l = cl->letter();
    // add special header cell
    tableRows->append(new AlphaIndexTableCell(row,col,l,(ClassDef*)0x8));
    row++;
    tableRows->append(new AlphaIndexTableCell(row,col,0,(ClassDef*)0x8));
    row++;
    ClassListIterator cit(*cl);
    cit.toFirst();
    ClassDef *cd = cit.current();
    ++cit;
    tableRows->append(new AlphaIndexTableCell(row,col,0,cd));
    row++; 
    NEXT_ROW();
    for (;(cd=cit.current()); ++cit)
    {
      // add normal cell
      tableRows->append(new AlphaIndexTableCell(row,col,0,cd));
1879
      row++;
1880
      NEXT_ROW();
1881 1882
    }
  }
1883

1884 1885
  // create row iterators for each column
  AlphaIndexTableRowsIterator **colIterators = new AlphaIndexTableRowsIterator*[columns];
1886 1887
  for (i=0;i<columns;i++)
  {
1888 1889 1890 1891 1892 1893 1894 1895
    if (i<(int)tableColumns.count())
    {
      colIterators[i] = new AlphaIndexTableRowsIterator(*tableColumns.at(i));
    }
    else // empty column
    {
      colIterators[i] = 0;
    }
1896 1897
  }

1898
  ol.writeString("<table style=\"margin: 10px; white-space: nowrap;\" align=\"center\" width=\"95%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n");
1899
  // generate table
1900
  for (i=0;i<=maxRows;i++) // foreach table row
1901
  {
1902
    //printf("writing row %d\n",i);
1903 1904
    //ol.nextTableRow();
    ol.writeString("<tr>");
1905
    // the last column may contain less items then the others
1906
    //int colsInRow = (i<rows-1) ? columns : itemsInLastRow; 
1907
    //printf("row [%d]\n",i);
1908
    for (j=0;j<columns;j++) // foreach table column
1909
    {
1910
      if (colIterators[j])
1911
      {
1912 1913
        AlphaIndexTableCell *cell = colIterators[j]->current();
        if (cell)
1914
        {
1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926
          if (cell->row()==i)
          {
            if (cell->letter()!=0)
            {
              QCString s = letterToLabel(cell->letter());
              ol.writeString("<td rowspan=\"2\" valign=\"bottom\">");
              ol.writeString("<a name=\"letter_");
              ol.writeString(s);
              ol.writeString("\"></a>");
              ol.writeString("<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"
                  "<tr>"
                  "<td><div class=\"ah\">&#160;&#160;"); 
1927
              ol.writeString(QString(QChar(cell->letter())).utf8());
1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941
              ol.writeString(         "&#160;&#160;</div>"
                  "</td>"
                  "</tr>"
                  "</table>\n");
            }
            else if (cell->classDef()!=(ClassDef*)0x8)
            {
              cd = cell->classDef();
              ol.writeString("<td valign=\"top\">");
              QCString namesp,cname;
              //if (cd->getNamespaceDef()) namesp=cd->getNamespaceDef()->displayName();
              //QCString cname=cd->className();
              extractNamespaceName(cd->name(),cname,namesp);
              QCString nsDispName;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1942 1943 1944
              SrcLangExt lang = cd->getLanguage();
              QCString sep = getLanguageSpecificSeparator(lang);
              if (sep!="::")
1945
              {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1946
                nsDispName=substitute(namesp,"::",sep);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1947
                cname=substitute(cname,"::",sep);
1948 1949 1950
              }
              else
              {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1951
                nsDispName=namesp;
1952
              }
1953

1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978
              ol.writeObjectLink(cd->getReference(),
                  cd->getOutputFileBase(),cd->anchor(),cname);
              if (!namesp.isEmpty())
              {
                ol.docify(" (");
                NamespaceDef *nd = getResolvedNamespace(namesp);
                if (nd && nd->isLinkable())
                {
                  ol.writeObjectLink(nd->getReference(),
                      nd->getOutputFileBase(),0,nsDispName);
                }
                else
                {
                  ol.docify(nsDispName);
                }
                ol.docify(")");
              }
              ol.writeNonBreakableSpace(3);
            }
            ++(*colIterators[j]);
            if (cell->letter()!=0 || cell->classDef()!=(ClassDef*)0x8)
            {
              ol.writeString("</td>");
            }
          }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1979 1980 1981
        }
        else
        {
1982
          ol.writeString("<td></td>");
1983
        }
1984 1985
      }
    }
1986
    ol.writeString("</tr>\n");
1987
  }
1988
  ol.writeString("</table>\n");
1989 1990
  
  ol.writeString(alphaLinks);
1991 1992 1993 1994 1995 1996 1997

  // release the temporary memory
  for (i=0;i<columns;i++)
  {
    delete colIterators[i];
  }
  delete[] colIterators;
1998 1999 2000 2001
}

//----------------------------------------------------------------------------

2002
static void writeAlphabeticalIndex(OutputList &ol)
2003 2004
{
  if (annotatedClasses==0) return;
2005 2006
  ol.pushGeneratorState();
  ol.disableAllBut(OutputGenerator::Html);
2007 2008
  LayoutNavEntry *lne = LayoutDocManager::instance().rootNavEntry()->find(LayoutNavEntry::ClassIndex);
  QCString title = lne ? lne->title() : theTranslator->trCompoundIndex();
2009 2010
  bool addToIndex = lne==0 || lne->visible();

2011
  startFile(ol,"classes",0,title,HLI_Classes); 
2012

2013
  startTitle(ol,0);
2014
  ol.parseText(title);
2015
  endTitle(ol,0,0);
2016

2017 2018
  if (addToIndex)
  {
2019
    Doxygen::indexList->addContentsItem(FALSE,title,0,"classes",0,FALSE,TRUE); 
2020 2021
  }

2022
  ol.startContents();
2023
  writeAlphabeticalClassList(ol);
2024
  endFile(ol); // contains ol.endContents()
2025

2026
  ol.popGeneratorState();
2027 2028 2029 2030
}

//----------------------------------------------------------------------------

2031
static void writeAnnotatedIndex(OutputList &ol)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
2032
{
Dimitri van Heesch's avatar
Dimitri van Heesch committed
2033 2034
  //printf("writeAnnotatedIndex: count=%d printed=%d\n",
  //    annotatedClasses,annotatedClassesPrinted);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
2035 2036
  if (annotatedClasses==0) return;
  
Dimitri van Heesch's avatar
Dimitri van Heesch committed
2037
  ol.pushGeneratorState();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
2038
  ol.disable(OutputGenerator::Man);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
2039 2040 2041 2042 2043
  if (annotatedClassesPrinted==0)
  {
    ol.disable(OutputGenerator::Latex);
    ol.disable(OutputGenerator::RTF);
  }
2044 2045 2046
  LayoutNavEntry *lne = LayoutDocManager::instance().rootNavEntry()->find(LayoutNavEntry::ClassList);
  if (lne==0) lne = LayoutDocManager::instance().rootNavEntry()->find(LayoutNavEntry::Classes); // fall back
  QCString title = lne ? lne->title() : theTranslator->trCompoundList();
2047 2048 2049 2050 2051 2052 2053
  bool addToIndex = lne==0 || lne->visible();

  if (Config_getBool("OPTIMIZE_OUTPUT_VHDL")) 
  {
    VhdlDocGen::findConstraintFile(lne);
  }
  
2054
  startFile(ol,"annotated",0,title,HLI_Annotated);
2055

2056
  startTitle(ol,0);
2057
  ol.parseText(title);
2058
  endTitle(ol,0,0);
2059

2060
  ol.startContents();
2061

Dimitri van Heesch's avatar
Dimitri van Heesch committed
2062
  ol.startTextBlock();
2063
  ol.parseText(lne ? lne->intro() : theTranslator->trCompoundListDescription());
Dimitri van Heesch's avatar
Dimitri van Heesch committed
2064
  ol.endTextBlock();
2065

2066 2067 2068 2069 2070
  // ---------------
  // Linear class index for Latex/RTF
  // ---------------
  ol.pushGeneratorState();
  ol.disable(OutputGenerator::Html);
2071
  Doxygen::indexList->disable();
2072

Dimitri van Heesch's avatar
Dimitri van Heesch committed
2073
  writeAnnotatedClassList(ol);
2074

2075
  Doxygen::indexList->enable();
2076 2077 2078 2079 2080 2081 2082 2083
  ol.popGeneratorState();

  // ---------------
  // Hierarchical class index for HTML
  // ---------------
  ol.pushGeneratorState(); 
  ol.disableAllBut(OutputGenerator::Html);

2084
  {
2085 2086
    if (addToIndex)
    {
2087 2088
      Doxygen::indexList->addContentsItem(TRUE,title,0,"annotated",0,TRUE,TRUE); 
      Doxygen::indexList->incContentsDepth();
2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099
    }
    FTVHelp* ftv = new FTVHelp(FALSE);
    writeNamespaceTree(Doxygen::namespaceSDict,ftv,TRUE,TRUE,addToIndex);
    writeClassTree(Doxygen::classSDict,ftv,addToIndex,TRUE);
    QGString outStr;
    FTextStream t(&outStr);
    ftv->generateTreeViewInline(t);
    ol.writeString(outStr);
    delete ftv;
    if (addToIndex)
    {
2100
      Doxygen::indexList->decContentsDepth();
2101
    }
2102
  }
2103 2104 2105

  ol.popGeneratorState();
  // ------
2106
  
2107
  endFile(ol); // contains ol.endContents()
2108 2109 2110 2111
  ol.popGeneratorState();
}

//----------------------------------------------------------------------------
2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124
static void writeClassLinkForMember(OutputList &ol,MemberDef *md,const char *separator,
                             QCString &prevClassName)
{
  ClassDef *cd=md->getClassDef();
  if ( cd && prevClassName!=cd->displayName())
  {
    ol.docify(separator);
    ol.writeObjectLink(md->getReference(),md->getOutputFileBase(),md->anchor(),
        cd->displayName());
    ol.writeString("\n");
    prevClassName = cd->displayName();
  }
}
2125

2126 2127
static void writeFileLinkForMember(OutputList &ol,MemberDef *md,const char *separator,
                             QCString &prevFileName)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
2128
{
2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154
  FileDef *fd=md->getFileDef();
  if (fd && prevFileName!=fd->name())
  {
    ol.docify(separator);
    ol.writeObjectLink(md->getReference(),md->getOutputFileBase(),md->anchor(),
        fd->name());
    ol.writeString("\n");
    prevFileName = fd->name();
  }
}

static void writeNamespaceLinkForMember(OutputList &ol,MemberDef *md,const char *separator,
                             QCString &prevNamespaceName)
{
  NamespaceDef *nd=md->getNamespaceDef();
  if (nd && prevNamespaceName!=nd->name())
  {
    ol.docify(separator);
    ol.writeObjectLink(md->getReference(),md->getOutputFileBase(),md->anchor(),
        nd->name());
    ol.writeString("\n");
    prevNamespaceName = nd->name();
  }
}

static void writeMemberList(OutputList &ol,bool useSections,int page,
2155
                            const LetterToIndexMap<MemberIndexList> &memberLists,
2156 2157 2158
                            DefinitionIntf::DefType type)
{
  ASSERT((int)type<3);
2159 2160 2161 2162 2163

  typedef void (*writeLinkForMember_t)(OutputList &ol,MemberDef *md,const char *separator,
                                   QCString &prevNamespaceName);

  // each index tab has its own write function
2164 2165 2166 2167 2168 2169 2170 2171 2172 2173
  static writeLinkForMember_t writeLinkForMemberMap[3] = 
  { 
    &writeClassLinkForMember, 
    &writeFileLinkForMember,
    &writeNamespaceLinkForMember
  };
  QCString prevName;
  QCString prevDefName;
  bool first=TRUE;
  bool firstSection=TRUE;
2174
  bool firstItem=TRUE;
2175 2176 2177
  MemberIndexList *ml;
  SIntDict<MemberIndexList>::Iterator it(memberLists);
  for (it.toFirst();(ml=it.current());++it)
2178
  {
2179 2180 2181 2182 2183 2184
    if (page!=-1)
    {
      ml = memberLists[page];
      it.toLast();
    }
    if (ml==0 || ml->count()==0) continue;
2185 2186 2187 2188 2189
    ml->sort();
    QListIterator<MemberDef> mli(*ml);
    MemberDef *md;
    for (mli.toFirst();(md=mli.current());++mli)
    {
2190
      const char *sep;
2191 2192 2193
      bool isFunc=!md->isObjCMethod() && 
        (md->isFunction() || md->isSlot() || md->isSignal()); 
      QCString name=md->name();
2194 2195
      int startIndex = getPrefixIndex(name);
      if (QCString(name.data()+startIndex)!=prevName) // new entry
2196
      {
2197 2198 2199
        if ((prevName.isEmpty() || 
            tolower(name.at(startIndex))!=tolower(prevName.at(0))) && 
            useSections) // new section
2200
        {
2201
          if (!firstItem)    ol.endItemListItem();
2202
          if (!firstSection) ol.endItemList();
2203 2204
          QCString cs = letterToLabel(ml->letter());
          QCString cl = QString(QChar(ml->letter())).utf8();
2205
          QCString anchor=(QCString)"index_"+cs;
2206
          QCString title=(QCString)"- "+cl+" -";
2207 2208 2209 2210 2211
          ol.startSection(anchor,title,SectionInfo::Subsection);
          ol.docify(title);
          ol.endSection(anchor,SectionInfo::Subsection);
          ol.startItemList();
          firstSection=FALSE;
2212
          firstItem=TRUE;
2213 2214 2215 2216 2217 2218 2219 2220
        }
        else if (!useSections && first)
        {
          ol.startItemList();
          first=FALSE;
        }

        // member name
2221 2222 2223
        if (!firstItem) ol.endItemListItem();
        ol.startItemListItem();
        firstItem=FALSE;
2224 2225 2226 2227 2228 2229 2230
        ol.docify(name);
        if (isFunc) ol.docify("()");
        ol.writeString("\n");

        // link to class
        prevDefName="";
        sep = ": ";
2231
        prevName = name.data()+startIndex;
2232 2233 2234 2235 2236 2237
      }
      else // same entry
      {
        sep = ", ";
        // link to class for other members with the same name
      }
2238
      // write the link for the specific list type
2239 2240 2241
      writeLinkForMemberMap[(int)type](ol,md,sep,prevDefName);
    }
  }
2242
  if (!firstItem) ol.endItemListItem();
2243
  ol.endItemList();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
2244 2245 2246 2247
}

//----------------------------------------------------------------------------

2248 2249 2250 2251 2252 2253
void initClassMemberIndices()
{
  int j=0;
  for (j=0;j<CMHL_Total;j++)
  {
    documentedClassMembers[j]=0;
2254
    g_memberIndexLetterUsed[j].clear();
2255 2256 2257 2258 2259 2260
  }
}

void addClassMemberNameToIndex(MemberDef *md)
{
  static bool hideFriendCompounds = Config_getBool("HIDE_FRIEND_COMPOUNDS");
2261 2262
  ClassDef *cd=0;

Dimitri van Heesch's avatar
Dimitri van Heesch committed
2263
 
2264
  
2265
  if (md->isLinkableInProject() && 
2266
      (cd=md->getClassDef())    && 
2267 2268 2269 2270
      cd->isLinkableInProject() &&
      cd->templateMaster()==0)
  {
    QCString n = md->name();
2271
    int index = getPrefixIndex(n);
2272
    uint letter = getUtf8CodeToLower(n,index);
2273 2274 2275 2276 2277 2278 2279 2280
    if (!n.isEmpty()) 
    {
      bool isFriendToHide = hideFriendCompounds &&
        (QCString(md->typeString())=="friend class" || 
         QCString(md->typeString())=="friend struct" ||
         QCString(md->typeString())=="friend union");
      if (!(md->isFriend() && isFriendToHide))
      {
2281
        g_memberIndexLetterUsed[CMHL_All].append(letter,md);
2282 2283 2284 2285
        documentedClassMembers[CMHL_All]++;
      }
      if (md->isFunction()  || md->isSlot() || md->isSignal())
      {
2286
        g_memberIndexLetterUsed[CMHL_Functions].append(letter,md);
2287 2288 2289 2290
        documentedClassMembers[CMHL_Functions]++;
      } 
      else if (md->isVariable())
      {
2291
        g_memberIndexLetterUsed[CMHL_Variables].append(letter,md);
2292 2293 2294 2295
        documentedClassMembers[CMHL_Variables]++;
      }
      else if (md->isTypedef())
      {
2296
        g_memberIndexLetterUsed[CMHL_Typedefs].append(letter,md);
2297 2298 2299 2300
        documentedClassMembers[CMHL_Typedefs]++;
      }
      else if (md->isEnumerate())
      {
2301
        g_memberIndexLetterUsed[CMHL_Enums].append(letter,md);
2302 2303 2304 2305
        documentedClassMembers[CMHL_Enums]++;
      }
      else if (md->isEnumValue())
      {
2306
        g_memberIndexLetterUsed[CMHL_EnumValues].append(letter,md);
2307 2308 2309 2310
        documentedClassMembers[CMHL_EnumValues]++;
      }
      else if (md->isProperty())
      {
2311
        g_memberIndexLetterUsed[CMHL_Properties].append(letter,md);
2312 2313 2314 2315
        documentedClassMembers[CMHL_Properties]++;
      }
      else if (md->isEvent())
      {
2316
        g_memberIndexLetterUsed[CMHL_Events].append(letter,md);
2317 2318
        documentedClassMembers[CMHL_Events]++;
      }
2319 2320
      else if (md->isRelated() || md->isForeign() ||
               (md->isFriend() && !isFriendToHide))
2321
      {
2322
        g_memberIndexLetterUsed[CMHL_Related].append(letter,md);
2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336
        documentedClassMembers[CMHL_Related]++;
      }
    }
  }
}

//----------------------------------------------------------------------------

void initNamespaceMemberIndices()
{
  int j=0;
  for (j=0;j<NMHL_Total;j++)
  {
    documentedNamespaceMembers[j]=0;
2337
    g_namespaceIndexLetterUsed[j].clear();
2338 2339 2340 2341 2342 2343 2344 2345 2346
  }
}

void addNamespaceMemberNameToIndex(MemberDef *md)
{
  NamespaceDef *nd=md->getNamespaceDef();
  if (nd && nd->isLinkableInProject() && md->isLinkableInProject())
  {
    QCString n = md->name();
2347
    int index = getPrefixIndex(n);
2348
    uint letter = getUtf8CodeToLower(n,index);
2349 2350
    if (!n.isEmpty()) 
    {
2351
      g_namespaceIndexLetterUsed[NMHL_All].append(letter,md);
2352 2353 2354 2355
      documentedNamespaceMembers[NMHL_All]++;

      if (md->isFunction()) 
      {
2356
        g_namespaceIndexLetterUsed[NMHL_Functions].append(letter,md);
2357 2358 2359 2360
        documentedNamespaceMembers[NMHL_Functions]++;
      }
      else if (md->isVariable()) 
      {
2361
        g_namespaceIndexLetterUsed[NMHL_Variables].append(letter,md);
2362 2363 2364 2365
        documentedNamespaceMembers[NMHL_Variables]++;
      }
      else if (md->isTypedef())
      {
2366
        g_namespaceIndexLetterUsed[NMHL_Typedefs].append(letter,md);
2367 2368 2369 2370
        documentedNamespaceMembers[NMHL_Typedefs]++;
      }
      else if (md->isEnumerate())
      {
2371
        g_namespaceIndexLetterUsed[NMHL_Enums].append(letter,md);
2372 2373 2374 2375
        documentedNamespaceMembers[NMHL_Enums]++;
      }
      else if (md->isEnumValue())
      {
2376
        g_namespaceIndexLetterUsed[NMHL_EnumValues].append(letter,md);
2377 2378 2379 2380 2381 2382
        documentedNamespaceMembers[NMHL_EnumValues]++;
      }
    }
  }
}

Dimitri van Heesch's avatar
Dimitri van Heesch committed
2383 2384
//----------------------------------------------------------------------------

2385 2386 2387 2388 2389 2390
void initFileMemberIndices()
{
  int j=0;
  for (j=0;j<NMHL_Total;j++)
  {
    documentedFileMembers[j]=0;
2391
    g_fileIndexLetterUsed[j].clear();
2392 2393 2394 2395 2396 2397 2398 2399 2400
  }
}

void addFileMemberNameToIndex(MemberDef *md)
{
  FileDef *fd=md->getFileDef();
  if (fd && fd->isLinkableInProject() && md->isLinkableInProject())
  {
    QCString n = md->name();
2401
    int index = getPrefixIndex(n);
2402
    uint letter = getUtf8CodeToLower(n,index);
2403 2404
    if (!n.isEmpty()) 
    {
2405
      g_fileIndexLetterUsed[FMHL_All].append(letter,md);
2406 2407 2408 2409
      documentedFileMembers[FMHL_All]++;

      if (md->isFunction()) 
      {
2410
        g_fileIndexLetterUsed[FMHL_Functions].append(letter,md);
2411 2412 2413 2414
        documentedFileMembers[FMHL_Functions]++;
      }
      else if (md->isVariable()) 
      {
2415
        g_fileIndexLetterUsed[FMHL_Variables].append(letter,md);
2416 2417 2418 2419
        documentedFileMembers[FMHL_Variables]++;
      }
      else if (md->isTypedef())
      {
2420
        g_fileIndexLetterUsed[FMHL_Typedefs].append(letter,md);
2421 2422 2423 2424
        documentedFileMembers[FMHL_Typedefs]++;
      }
      else if (md->isEnumerate())
      {
2425
        g_fileIndexLetterUsed[FMHL_Enums].append(letter,md);
2426 2427 2428 2429
        documentedFileMembers[FMHL_Enums]++;
      }
      else if (md->isEnumValue())
      {
2430
        g_fileIndexLetterUsed[FMHL_EnumValues].append(letter,md);
2431 2432 2433 2434
        documentedFileMembers[FMHL_EnumValues]++;
      }
      else if (md->isDefine())
      {
2435
        g_fileIndexLetterUsed[FMHL_Defines].append(letter,md);
2436 2437 2438 2439 2440 2441 2442 2443
        documentedFileMembers[FMHL_Defines]++;
      }
    }
  }
}

//----------------------------------------------------------------------------

2444
static void writeQuickMemberIndex(OutputList &ol,
2445
    const LetterToIndexMap<MemberIndexList> &charUsed,uint page,
2446
    QCString fullName,bool multiPage)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
2447 2448
{
  bool first=TRUE;
2449
  startQuickIndexList(ol,TRUE);
2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468
  SIntDict<MemberIndexList>::Iterator it(charUsed);
  MemberIndexList *ml;
  for (it.toFirst();(ml=it.current());++it)
  {
    uint i = ml->letter();
    QCString is = letterToLabel(i);
    QCString ci = QString(QChar(i)).utf8();
    QCString anchor;
    QCString extension=Doxygen::htmlFileExtension;
    if (!multiPage)
      anchor="#index_";
    else if (first) 
      anchor=fullName+extension+"#index_";
    else 
      anchor=fullName+"_"+letterToLabel(i)+extension+"#index_";
    startQuickIndexItem(ol,anchor+ci,i==page,TRUE,first);
    ol.writeString(is);
    endQuickIndexItem(ol);
    first=FALSE;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
2469
  }
2470
  endQuickIndexList(ol);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
2471 2472 2473 2474
}

//----------------------------------------------------------------------------

Dimitri van Heesch's avatar
Dimitri van Heesch committed
2475
/** Helper class representing a class member in the navigation menu. */
2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504
struct CmhlInfo
{
  CmhlInfo(const char *fn,const char *t) : fname(fn), title(t) {}
  const char *fname;
  QCString title;
};

static const CmhlInfo *getCmhlInfo(int hl)
{
  static bool fortranOpt = Config_getBool("OPTIMIZE_FOR_FORTRAN");
  static bool vhdlOpt    = Config_getBool("OPTIMIZE_OUTPUT_VHDL");
  static CmhlInfo cmhlInfo[] = 
  {
    CmhlInfo("functions",     theTranslator->trAll()),
    CmhlInfo("functions_func",
        fortranOpt ? theTranslator->trSubprograms() : 
        vhdlOpt    ? VhdlDocGen::trFunctionAndProc() :
                     theTranslator->trFunctions()),
    CmhlInfo("functions_vars",theTranslator->trVariables()),
    CmhlInfo("functions_type",theTranslator->trTypedefs()),
    CmhlInfo("functions_enum",theTranslator->trEnumerations()),
    CmhlInfo("functions_eval",theTranslator->trEnumerationValues()),
    CmhlInfo("functions_prop",theTranslator->trProperties()),
    CmhlInfo("functions_evnt",theTranslator->trEvents()),
    CmhlInfo("functions_rela",theTranslator->trRelatedFunctions())
  };
  return &cmhlInfo[hl];
}

Dimitri van Heesch's avatar
Dimitri van Heesch committed
2505
static void writeClassMemberIndexFiltered(OutputList &ol, ClassMemberHighlight hl)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
2506
{
2507
  if (documentedClassMembers[hl]==0) return;
2508

2509
  static bool disableIndex     = Config_getBool("DISABLE_INDEX");
2510 2511 2512 2513 2514 2515 2516

  bool multiPageIndex=FALSE;
  if (documentedClassMembers[hl]>MAX_ITEMS_BEFORE_MULTIPAGE_INDEX)
  {
    multiPageIndex=TRUE;
  }

Dimitri van Heesch's avatar
Dimitri van Heesch committed
2517 2518
  ol.pushGeneratorState();
  ol.disableAllBut(OutputGenerator::Html);
2519

2520
  QCString extension=Doxygen::htmlFileExtension;
2521
  LayoutNavEntry *lne = LayoutDocManager::instance().rootNavEntry()->find(LayoutNavEntry::ClassMembers);
2522
  QCString title = lne ? lne->title() : theTranslator->trCompoundMembers();
2523
  if (hl!=CMHL_All) title+=(QCString)" - "+getCmhlInfo(hl)->title;
2524
  bool addToIndex = lne==0 || lne->visible();
2525

2526 2527
  if (addToIndex)
  {
2528
    Doxygen::indexList->addContentsItem(multiPageIndex,getCmhlInfo(hl)->title,0,
2529
        getCmhlInfo(hl)->fname,0,multiPageIndex,TRUE);
2530
    if (multiPageIndex) Doxygen::indexList->incContentsDepth();
2531
  }
2532

2533
  bool first=TRUE;
2534 2535 2536
  SIntDict<MemberIndexList>::Iterator it(g_memberIndexLetterUsed[hl]);
  MemberIndexList *ml;
  for (it.toFirst();(ml=it.current());++it)
2537
  {
2538 2539 2540 2541 2542 2543 2544
    uint page = ml->letter();
    QCString fileName = getCmhlInfo(hl)->fname;
    if (multiPageIndex)
    { 
      if (!first)
      {
        fileName+="_"+letterToLabel(page);
2545
      }
2546 2547
      QCString cs = QString(QChar(page)).utf8();
      if (addToIndex)
2548
      {
2549 2550 2551 2552
        Doxygen::indexList->addContentsItem(FALSE,cs,0,fileName,0,FALSE,TRUE);
      }
    }
    bool quickIndex = documentedClassMembers[hl]>maxItemsBeforeQuickIndex;
2553

2554 2555 2556 2557 2558 2559
    ol.startFile(fileName+extension,0,title);
    ol.startQuickIndices();
    if (!disableIndex)
    {
      ol.writeQuickLinks(TRUE,HLI_Functions,0);
      startQuickIndexList(ol);
2560

2561 2562 2563 2564 2565
      // index item for global member list
      startQuickIndexItem(ol,
          getCmhlInfo(0)->fname+Doxygen::htmlFileExtension,hl==CMHL_All,TRUE,first);
      ol.writeString(fixSpaces(getCmhlInfo(0)->title));
      endQuickIndexItem(ol);
2566

2567 2568 2569 2570 2571
      int i;
      // index items per category member lists
      for (i=1;i<CMHL_Total;i++)
      {
        if (documentedClassMembers[i]>0)
2572
        {
2573 2574 2575 2576 2577
          startQuickIndexItem(ol,getCmhlInfo(i)->fname+Doxygen::htmlFileExtension,hl==i,TRUE,first);
          ol.writeString(fixSpaces(getCmhlInfo(i)->title));
          //printf("multiPageIndex=%d first=%d fileName=%s file=%s title=%s\n",
          //    multiPageIndex,first,fileName.data(),getCmhlInfo(i)->fname,getCmhlInfo(i)->title.data());
          endQuickIndexItem(ol);
2578
        }
2579
      }
2580

2581
      endQuickIndexList(ol);
2582

2583 2584
      // quick alphabetical index
      if (quickIndex)
2585
      {
2586 2587
        writeQuickMemberIndex(ol,g_memberIndexLetterUsed[hl],page,
            getCmhlInfo(hl)->fname,multiPageIndex);
2588
      }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
2589
    }
2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614
    ol.endQuickIndices();
    ol.writeSplitBar(fileName);
    ol.writeSearchInfo();

    ol.startContents();

    if (hl==CMHL_All)
    {
      ol.startTextBlock();
      ol.parseText(lne ? lne->intro() : theTranslator->trCompoundMembersDescription(Config_getBool("EXTRACT_ALL")));
      ol.endTextBlock();
    }
    else
    {
      // hack to work around a mozilla bug, which refuses to switch to
      // normal lists otherwise
      ol.writeString("&#160;");
    }

    writeMemberList(ol,quickIndex,
        multiPageIndex?page:-1,
        g_memberIndexLetterUsed[hl],
        Definition::TypeClass);
    endFile(ol);
    first=FALSE;
2615
  }
2616

2617
  if (multiPageIndex && addToIndex) Doxygen::indexList->decContentsDepth();
2618

Dimitri van Heesch's avatar
Dimitri van Heesch committed
2619
  ol.popGeneratorState();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
2620 2621
}

2622
static void writeClassMemberIndex(OutputList &ol)
2623
{
2624 2625 2626 2627
  LayoutNavEntry *lne = LayoutDocManager::instance().rootNavEntry()->find(LayoutNavEntry::ClassMembers);
  bool addToIndex = lne==0 || lne->visible();

  if (documentedClassMembers[CMHL_All]>0 && addToIndex)
2628
  {
2629 2630
    Doxygen::indexList->addContentsItem(TRUE,lne ? lne->title() : theTranslator->trCompoundMembers(),0,"functions",0); 
    Doxygen::indexList->incContentsDepth();
2631
  }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
2632 2633 2634 2635 2636 2637 2638 2639 2640
  writeClassMemberIndexFiltered(ol,CMHL_All);
  writeClassMemberIndexFiltered(ol,CMHL_Functions);
  writeClassMemberIndexFiltered(ol,CMHL_Variables);
  writeClassMemberIndexFiltered(ol,CMHL_Typedefs);
  writeClassMemberIndexFiltered(ol,CMHL_Enums);
  writeClassMemberIndexFiltered(ol,CMHL_EnumValues);
  writeClassMemberIndexFiltered(ol,CMHL_Properties);
  writeClassMemberIndexFiltered(ol,CMHL_Events);
  writeClassMemberIndexFiltered(ol,CMHL_Related);
2641
  if (documentedClassMembers[CMHL_All]>0 && addToIndex)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
2642
  {
2643
    Doxygen::indexList->decContentsDepth();
2644
  }
2645

2646 2647
}

Dimitri van Heesch's avatar
Dimitri van Heesch committed
2648 2649
//----------------------------------------------------------------------------

Dimitri van Heesch's avatar
Dimitri van Heesch committed
2650
/** Helper class representing a file member in the navigation menu. */
2651
struct FmhlInfo 
Dimitri van Heesch's avatar
Dimitri van Heesch committed
2652
{
2653 2654 2655 2656
  FmhlInfo(const char *fn,const char *t) : fname(fn), title(t) {}
  const char *fname;
  QCString title;
};
2657

2658 2659 2660 2661 2662
static const FmhlInfo *getFmhlInfo(int hl)
{
  static bool fortranOpt = Config_getBool("OPTIMIZE_FOR_FORTRAN");
  static bool vhdlOpt    = Config_getBool("OPTIMIZE_OUTPUT_VHDL");
  static FmhlInfo fmhlInfo[] = 
2663
  {
2664
    FmhlInfo("globals",     theTranslator->trAll()),
2665 2666 2667 2668
    FmhlInfo("globals_func",
         fortranOpt ? theTranslator->trSubprograms()  : 
         vhdlOpt    ? VhdlDocGen::trFunctionAndProc() : 
                      theTranslator->trFunctions()),
2669 2670 2671 2672 2673
    FmhlInfo("globals_vars",theTranslator->trVariables()),
    FmhlInfo("globals_type",theTranslator->trTypedefs()),
    FmhlInfo("globals_enum",theTranslator->trEnumerations()),
    FmhlInfo("globals_eval",theTranslator->trEnumerationValues()),
    FmhlInfo("globals_defs",theTranslator->trDefines())
2674
  };
2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688
  return &fmhlInfo[hl];
}

static void writeFileMemberIndexFiltered(OutputList &ol, FileMemberHighlight hl)
{
  if (documentedFileMembers[hl]==0) return;

  static bool disableIndex     = Config_getBool("DISABLE_INDEX");

  bool multiPageIndex=FALSE;
  if (documentedFileMembers[hl]>MAX_ITEMS_BEFORE_MULTIPAGE_INDEX)
  {
    multiPageIndex=TRUE;
  }
2689

2690 2691 2692 2693
  ol.pushGeneratorState();
  ol.disableAllBut(OutputGenerator::Html);

  QCString extension=Doxygen::htmlFileExtension;
2694
  LayoutNavEntry *lne = LayoutDocManager::instance().rootNavEntry()->find(LayoutNavEntry::FileGlobals);
2695
  QCString title = lne ? lne->title() : theTranslator->trFileMembers();
2696
  bool addToIndex = lne==0 || lne->visible();
2697

2698 2699
  if (addToIndex)
  {
2700
    Doxygen::indexList->addContentsItem(multiPageIndex,getFmhlInfo(hl)->title,0,
2701
        getFmhlInfo(hl)->fname,0,multiPageIndex,TRUE);
2702
    if (multiPageIndex) Doxygen::indexList->incContentsDepth();
2703
  }
2704 2705

  bool first=TRUE;
2706 2707 2708
  SIntDict<MemberIndexList>::Iterator it(g_fileIndexLetterUsed[hl]);
  MemberIndexList *ml;
  for (it.toFirst();(ml=it.current());++it)
2709
  {
2710 2711 2712
    uint page = ml->letter();
    QCString fileName = getFmhlInfo(hl)->fname;
    if (multiPageIndex)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
2713
    {
2714
      if (!first)
2715
      {
2716
        fileName+="_"+letterToLabel(page);
2717
      }
2718 2719
      QCString cs = QString(QChar(page)).utf8();
      if (addToIndex)
2720
      {
2721 2722 2723 2724
        Doxygen::indexList->addContentsItem(FALSE,cs,0,fileName,0,FALSE,TRUE);
      }
    }
    bool quickIndex = documentedFileMembers[hl]>maxItemsBeforeQuickIndex;
2725

2726 2727 2728 2729 2730 2731
    ol.startFile(fileName+extension,0,title);
    ol.startQuickIndices();
    if (!disableIndex)
    {
      ol.writeQuickLinks(TRUE,HLI_Globals,0);
      startQuickIndexList(ol);
2732

2733 2734 2735 2736 2737
      // index item for all file member lists
      startQuickIndexItem(ol,
          getFmhlInfo(0)->fname+Doxygen::htmlFileExtension,hl==FMHL_All,TRUE,first);
      ol.writeString(fixSpaces(getFmhlInfo(0)->title));
      endQuickIndexItem(ol);
2738

2739 2740 2741 2742 2743
      int i;
      // index items for per category member lists
      for (i=1;i<FMHL_Total;i++)
      {
        if (documentedFileMembers[i]>0)
2744
        {
2745 2746 2747 2748
          startQuickIndexItem(ol,
              getFmhlInfo(i)->fname+Doxygen::htmlFileExtension,hl==i,TRUE,first);
          ol.writeString(fixSpaces(getFmhlInfo(i)->title));
          endQuickIndexItem(ol);
2749
        }
2750
      }
2751

2752
      endQuickIndexList(ol);
2753

2754
      if (quickIndex)
2755
      {
2756 2757
        writeQuickMemberIndex(ol,g_fileIndexLetterUsed[hl],page,
            getFmhlInfo(hl)->fname,multiPageIndex);
2758
      }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
2759
    }
2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784
    ol.endQuickIndices();
    ol.writeSplitBar(fileName);
    ol.writeSearchInfo();

    ol.startContents();

    if (hl==FMHL_All)
    {
      ol.startTextBlock();
      ol.parseText(lne ? lne->intro() : theTranslator->trFileMembersDescription(Config_getBool("EXTRACT_ALL")));
      ol.endTextBlock();
    }
    else
    {
      // hack to work around a mozilla bug, which refuses to switch to
      // normal lists otherwise
      ol.writeString("&#160;");
    }

    writeMemberList(ol,quickIndex,
        multiPageIndex?page:-1,
        g_fileIndexLetterUsed[hl],
        Definition::TypeFile);
    endFile(ol);
    first=FALSE;
2785
  }
2786
  if (multiPageIndex && addToIndex) Doxygen::indexList->decContentsDepth();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
2787
  ol.popGeneratorState();
2788 2789
}

2790
static void writeFileMemberIndex(OutputList &ol)
2791
{
2792 2793 2794
  LayoutNavEntry *lne = LayoutDocManager::instance().rootNavEntry()->find(LayoutNavEntry::FileGlobals);
  bool addToIndex = lne==0 || lne->visible();
  if (documentedFileMembers[FMHL_All]>0 && addToIndex)
2795
  {
2796 2797
    Doxygen::indexList->addContentsItem(FALSE,lne ? lne->title() : theTranslator->trFileMembers(),0,"globals",0); 
    Doxygen::indexList->incContentsDepth();
2798
  }
2799 2800 2801 2802 2803 2804 2805
  writeFileMemberIndexFiltered(ol,FMHL_All);
  writeFileMemberIndexFiltered(ol,FMHL_Functions);
  writeFileMemberIndexFiltered(ol,FMHL_Variables);
  writeFileMemberIndexFiltered(ol,FMHL_Typedefs);
  writeFileMemberIndexFiltered(ol,FMHL_Enums);
  writeFileMemberIndexFiltered(ol,FMHL_EnumValues);
  writeFileMemberIndexFiltered(ol,FMHL_Defines);
2806
  if (documentedFileMembers[FMHL_All]>0 && addToIndex)
2807
  {
2808
    Doxygen::indexList->decContentsDepth();
2809
  }
2810

2811 2812
}

2813 2814
//----------------------------------------------------------------------------

Dimitri van Heesch's avatar
Dimitri van Heesch committed
2815
/** Helper class representing a namespace member in the navigation menu. */
2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840
struct NmhlInfo
{
  NmhlInfo(const char *fn,const char *t) : fname(fn), title(t) {}
  const char *fname;
  QCString title;
};

static const NmhlInfo *getNmhlInfo(int hl)
{
  static bool fortranOpt = Config_getBool("OPTIMIZE_FOR_FORTRAN");
  static bool vhdlOpt    = Config_getBool("OPTIMIZE_OUTPUT_VHDL");
  static NmhlInfo nmhlInfo[] = 
  {
    NmhlInfo("namespacemembers",     theTranslator->trAll()),
    NmhlInfo("namespacemembers_func",
        fortranOpt ? theTranslator->trSubprograms()  :
        vhdlOpt    ? VhdlDocGen::trFunctionAndProc() :
                     theTranslator->trFunctions()),
    NmhlInfo("namespacemembers_vars",theTranslator->trVariables()),
    NmhlInfo("namespacemembers_type",theTranslator->trTypedefs()),
    NmhlInfo("namespacemembers_enum",theTranslator->trEnumerations()),
    NmhlInfo("namespacemembers_eval",theTranslator->trEnumerationValues())
  };
  return &nmhlInfo[hl];
}
2841

2842 2843
//----------------------------------------------------------------------------

2844
static void writeNamespaceMemberIndexFiltered(OutputList &ol,
2845
                                        NamespaceMemberHighlight hl)
2846
{
2847 2848
  if (documentedNamespaceMembers[hl]==0) return;

2849
  static bool disableIndex     = Config_getBool("DISABLE_INDEX");
2850

2851

2852 2853
  bool multiPageIndex=FALSE;
  if (documentedNamespaceMembers[hl]>MAX_ITEMS_BEFORE_MULTIPAGE_INDEX)
2854
  {
2855
    multiPageIndex=TRUE;
2856
  }
2857 2858 2859 2860 2861

  ol.pushGeneratorState();
  ol.disableAllBut(OutputGenerator::Html);

  QCString extension=Doxygen::htmlFileExtension;
2862
  LayoutNavEntry *lne = LayoutDocManager::instance().rootNavEntry()->find(LayoutNavEntry::NamespaceMembers);
2863
  QCString title = lne ? lne->title() : theTranslator->trNamespaceMembers();
2864
  bool addToIndex = lne==0 || lne->visible();
2865

2866 2867
  if (addToIndex)
  {
2868
    Doxygen::indexList->addContentsItem(multiPageIndex,getNmhlInfo(hl)->title,0,
2869
        getNmhlInfo(hl)->fname,0,multiPageIndex,TRUE);
2870
    if (multiPageIndex) Doxygen::indexList->incContentsDepth();
2871
  }
2872 2873

  bool first=TRUE;
2874 2875 2876
  SIntDict<MemberIndexList>::Iterator it(g_namespaceIndexLetterUsed[hl]);
  MemberIndexList *ml;
  for (it.toFirst();(ml=it.current());++it)
2877
  {
2878 2879 2880
    uint page = ml->letter();
    QCString fileName = getNmhlInfo(hl)->fname;
    if (multiPageIndex)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
2881
    {
2882
      if (!first)
2883
      {
2884
        fileName+="_"+letterToLabel(page);
2885
      }
2886 2887
      QCString cs = QString(QChar(page)).utf8();
      if (addToIndex)
2888
      {
2889 2890 2891 2892
        Doxygen::indexList->addContentsItem(FALSE,cs,0,fileName,0,FALSE,TRUE);
      }
    }
    bool quickIndex = documentedNamespaceMembers[hl]>maxItemsBeforeQuickIndex;
2893

2894 2895 2896 2897 2898 2899
    ol.startFile(fileName+extension,0,title);
    ol.startQuickIndices();
    if (!disableIndex)
    {
      ol.writeQuickLinks(TRUE,HLI_NamespaceMembers,0);
      startQuickIndexList(ol);
2900

2901 2902 2903 2904 2905
      // index item for all namespace member lists
      startQuickIndexItem(ol,
          getNmhlInfo(0)->fname+Doxygen::htmlFileExtension,hl==NMHL_All,TRUE,first);
      ol.writeString(fixSpaces(getNmhlInfo(0)->title));
      endQuickIndexItem(ol);
2906

2907 2908 2909 2910 2911
      int i;
      // index items per category member lists
      for (i=1;i<NMHL_Total;i++)
      {
        if (documentedNamespaceMembers[i]>0)
2912
        {
2913 2914 2915 2916
          startQuickIndexItem(ol,
              getNmhlInfo(i)->fname+Doxygen::htmlFileExtension,hl==i,TRUE,first);
          ol.writeString(fixSpaces(getNmhlInfo(i)->title));
          endQuickIndexItem(ol);
2917 2918
        }
      }
2919

2920
      endQuickIndexList(ol);
2921

2922
      if (quickIndex)
2923
      {
2924 2925
        writeQuickMemberIndex(ol,g_namespaceIndexLetterUsed[hl],page,
            getNmhlInfo(hl)->fname,multiPageIndex);
2926
      }
2927

Dimitri van Heesch's avatar
Dimitri van Heesch committed
2928
    }
2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952
    ol.endQuickIndices();
    ol.writeSplitBar(fileName);
    ol.writeSearchInfo();

    ol.startContents();

    if (hl==NMHL_All)
    {
      ol.startTextBlock();
      ol.parseText(lne ? lne->intro() : theTranslator->trNamespaceMemberDescription(Config_getBool("EXTRACT_ALL")));
      ol.endTextBlock();
    }
    else
    {
      // hack to work around a mozilla bug, which refuses to switch to
      // normal lists otherwise
      ol.writeString("&#160;");
    }

    writeMemberList(ol,quickIndex,
        multiPageIndex?page:-1,
        g_namespaceIndexLetterUsed[hl],
        Definition::TypeNamespace);
    endFile(ol);
2953
  }
2954
  if (multiPageIndex && addToIndex) Doxygen::indexList->decContentsDepth();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
2955
  ol.popGeneratorState();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
2956 2957
}

2958
static void writeNamespaceMemberIndex(OutputList &ol)
2959
{
2960 2961 2962
  LayoutNavEntry *lne = LayoutDocManager::instance().rootNavEntry()->find(LayoutNavEntry::NamespaceMembers);
  bool addToIndex = lne==0 || lne->visible();
  if (documentedNamespaceMembers[NMHL_All]>0 && addToIndex)
2963
  {
2964 2965
    Doxygen::indexList->addContentsItem(FALSE,lne ? lne->title() : theTranslator->trNamespaceMembers(),0,"namespacemembers",0); 
    Doxygen::indexList->incContentsDepth();
2966
  }
2967
  //bool fortranOpt = Config_getBool("OPTIMIZE_FOR_FORTRAN");
2968 2969 2970 2971 2972 2973
  writeNamespaceMemberIndexFiltered(ol,NMHL_All);
  writeNamespaceMemberIndexFiltered(ol,NMHL_Functions);
  writeNamespaceMemberIndexFiltered(ol,NMHL_Variables);
  writeNamespaceMemberIndexFiltered(ol,NMHL_Typedefs);
  writeNamespaceMemberIndexFiltered(ol,NMHL_Enums);
  writeNamespaceMemberIndexFiltered(ol,NMHL_EnumValues);
2974
  if (documentedNamespaceMembers[NMHL_All]>0 && addToIndex)
2975
  {
2976
    Doxygen::indexList->decContentsDepth();
2977
  }
2978

2979 2980
}

Dimitri van Heesch's avatar
Dimitri van Heesch committed
2981 2982
//----------------------------------------------------------------------------

2983 2984
//----------------------------------------------------------------------------

2985
static void writeExampleIndex(OutputList &ol)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
2986
{
2987
  if (Doxygen::exampleSDict->count()==0) return;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
2988
  ol.pushGeneratorState();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
2989
  ol.disable(OutputGenerator::Man);
2990
  LayoutNavEntry *lne = LayoutDocManager::instance().rootNavEntry()->find(LayoutNavEntry::Examples);
2991
  QCString title = lne ? lne->title() : theTranslator->trExamples();
2992 2993
  bool addToIndex = lne==0 || lne->visible();

2994
  startFile(ol,"examples",0,title,HLI_Examples);
2995

2996
  startTitle(ol,0);
2997
  ol.parseText(title);
2998
  endTitle(ol,0,0);
2999

3000
  ol.startContents();
3001 3002 3003

  if (addToIndex)
  {
3004 3005
    Doxygen::indexList->addContentsItem(TRUE,title,0,"examples",0,TRUE,TRUE); 
    Doxygen::indexList->incContentsDepth();
3006 3007
  }

Dimitri van Heesch's avatar
Dimitri van Heesch committed
3008
  ol.startTextBlock();
3009
  ol.parseText(lne ? lne->intro() : theTranslator->trExamplesDescription());
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3010
  ol.endTextBlock();
3011

3012
  ol.startItemList();
3013
  PageSDict::Iterator pdi(*Doxygen::exampleSDict);
3014 3015
  PageDef *pd=0;
  for (pdi.toFirst();(pd=pdi.current());++pdi)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3016
  {
3017
    ol.startItemListItem();
3018 3019
    QCString n=pd->getOutputFileBase();
    if (!pd->title().isEmpty())
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3020
    {
3021
      ol.writeObjectLink(0,n,0,pd->title());
3022 3023
      if (addToIndex)
      {
3024
        Doxygen::indexList->addContentsItem(FALSE,filterTitle(pd->title()),pd->getReference(),n,0,FALSE,TRUE);
3025
      }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3026 3027 3028
    }
    else
    {
3029
      ol.writeObjectLink(0,n,0,pd->name());
3030 3031
      if (addToIndex)
      {
3032
        Doxygen::indexList->addContentsItem(FALSE,pd->name(),pd->getReference(),n,0,FALSE,TRUE);
3033
      }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3034
    }
3035
    ol.endItemListItem();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3036 3037
    ol.writeString("\n");
  }
3038
  ol.endItemList();
3039 3040 3041

  if (addToIndex)
  {
3042
    Doxygen::indexList->decContentsDepth();
3043
  }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3044
  endFile(ol);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3045
  ol.popGeneratorState();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3046 3047
}

3048

Dimitri van Heesch's avatar
Dimitri van Heesch committed
3049 3050
//----------------------------------------------------------------------------

3051
static void countRelatedPages(int &docPages,int &indexPages)
3052
{
3053
  docPages=indexPages=0;
3054
  PageSDict::Iterator pdi(*Doxygen::pageSDict);
3055 3056
  PageDef *pd=0;
  for (pdi.toFirst();(pd=pdi.current());++pdi)
3057
  {
3058
    if ( pd->visibleInIndex())
3059
    {
3060
      indexPages++; 
3061 3062 3063 3064
    }
    if ( pd->documentedPage())
    {
      docPages++;
3065
    }
3066 3067 3068 3069 3070
  }
}

//----------------------------------------------------------------------------

3071 3072 3073 3074 3075 3076 3077 3078 3079 3080
static bool mainPageHasTitle()
{
  if (Doxygen::mainPage==0) return FALSE;
  if (Doxygen::mainPage->title().isEmpty()) return FALSE;
  if (Doxygen::mainPage->title().lower()=="notitle") return FALSE;
  return TRUE;
}

//----------------------------------------------------------------------------

Dimitri van Heesch's avatar
Dimitri van Heesch committed
3081
static void writePages(PageDef *pd,FTVHelp *ftv)
3082
{
3083
  //printf("writePages()=%s pd=%p mainpage=%p\n",pd->name().data(),pd,Doxygen::mainPage);
3084 3085
  LayoutNavEntry *lne = LayoutDocManager::instance().rootNavEntry()->find(LayoutNavEntry::Pages);
  bool addToIndex = lne==0 || lne->visible();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107
  if (!addToIndex) return;

  bool hasSubPages = pd->hasSubPages();
  bool hasSections = pd->hasSections();

  if (pd->visibleInIndex())
  {
    QCString pageTitle;

    if (pd->title().isEmpty())
      pageTitle=pd->name();
    else
      pageTitle=pd->title();

    if (ftv)
    {
      //printf("*** adding %s\n",pageTitle.data());
      ftv->addContentsItem(
          hasSubPages,pageTitle,
          pd->getReference(),pd->getOutputFileBase(),
          0,hasSubPages,TRUE,pd); 
    }
3108
    if (addToIndex && pd!=Doxygen::mainPage)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3109
    {
3110
      Doxygen::indexList->addContentsItem(
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3111 3112 3113 3114 3115 3116
          hasSubPages,pageTitle,
          pd->getReference(),pd->getOutputFileBase(),
          0,hasSubPages,TRUE);
    }
  }
  if (hasSubPages && ftv) ftv->incContentsDepth();
3117 3118 3119
  bool doIndent = (hasSections || hasSubPages) &&  
                  (pd!=Doxygen::mainPage || mainPageHasTitle());
  if (doIndent)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3120
  {
3121
    Doxygen::indexList->incContentsDepth();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3122 3123 3124 3125 3126
  }
  if (hasSections)
  {
    pd->addSectionsToIndex();
  }
3127 3128 3129 3130 3131 3132 3133
  PageSDict *subPages = pd->getSubPages();
  if (subPages)
  {
    PageSDict::Iterator pi(*subPages);
    PageDef *subPage;
    for (pi.toFirst();(subPage=pi.current());++pi)
    {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3134
      writePages(subPage,ftv);
3135 3136
    }
  }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3137
  if (hasSubPages && ftv) ftv->decContentsDepth();
3138
  if (doIndent)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3139
  {
3140
    Doxygen::indexList->decContentsDepth();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3141 3142
  }
  //printf("end writePages()=%s\n",pd->title().data());
3143
}
3144

3145
//----------------------------------------------------------------------------
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3146

3147
static void writePageIndex(OutputList &ol)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3148
{
3149
  if (indexedPages==0) return;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3150
  ol.pushGeneratorState();
3151
  ol.disableAllBut(OutputGenerator::Html);
3152
  LayoutNavEntry *lne = LayoutDocManager::instance().rootNavEntry()->find(LayoutNavEntry::Pages);
3153
  QCString title = lne ? lne->title() : theTranslator->trRelatedPages();
3154
  startFile(ol,"pages",0,title,HLI_Pages);
3155
  startTitle(ol,0);
3156
  ol.parseText(title);
3157
  endTitle(ol,0,0);
3158
  ol.startContents();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3159
  ol.startTextBlock();
3160
  ol.parseText(lne ? lne->intro() : theTranslator->trRelatedPagesDescription());
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3161
  ol.endTextBlock();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3162

Dimitri van Heesch's avatar
Dimitri van Heesch committed
3163
  {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3164 3165 3166 3167
    FTVHelp* ftv = new FTVHelp(FALSE);
    PageSDict::Iterator pdi(*Doxygen::pageSDict);
    PageDef *pd=0;
    for (pdi.toFirst();(pd=pdi.current());++pdi)
3168
    {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3169 3170 3171
      if (pd->getOuterScope()==0 || 
          pd->getOuterScope()->definitionType()!=Definition::TypePage
         )  // not a sub page
3172
      {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3173
        writePages(pd,ftv);
3174
      }
3175
    }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3176 3177 3178 3179 3180
    QGString outStr;
    FTextStream t(&outStr);
    ftv->generateTreeViewInline(t);
    ol.writeString(outStr);
    delete ftv;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3181
  }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3182 3183 3184 3185

//  ol.popGeneratorState();
  // ------

Dimitri van Heesch's avatar
Dimitri van Heesch committed
3186
  endFile(ol);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3187
  ol.popGeneratorState();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3188 3189 3190 3191
}

//----------------------------------------------------------------------------

3192
static int countGroups()
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3193 3194
{
  int count=0;
3195
  GroupSDict::Iterator gli(*Doxygen::groupSDict);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3196
  GroupDef *gd;
3197
  for (gli.toFirst();(gd=gli.current());++gli)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3198
  {
3199 3200 3201 3202 3203
    if (!gd->isReference())
    {
      gd->visited=FALSE;
      count++;
    }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3204 3205 3206 3207
  }
  return count;
}

3208 3209
//----------------------------------------------------------------------------

3210
static int countDirs()
3211 3212
{
  int count=0;
3213
  SDict<DirDef>::Iterator dli(*Doxygen::directories);
3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225
  DirDef *dd;
  for (dli.toFirst();(dd=dli.current());++dli)
  {
    if (dd->isLinkableInProject())
    {
      dd->visited=FALSE;
      count++;
    }
  }
  return count;
}

3226 3227 3228 3229 3230

//----------------------------------------------------------------------------

void writeGraphInfo(OutputList &ol)
{
3231
  if (!Config_getBool("HAVE_DOT") || !Config_getBool("GENERATE_HTML")) return;
3232 3233
  ol.pushGeneratorState();
  ol.disableAllBut(OutputGenerator::Html);
3234
  generateGraphLegend(Config_getString("HTML_OUTPUT"));
3235 3236 3237 3238 3239 3240 3241 3242 3243 3244

  bool &stripCommentsStateRef = Config_getBool("STRIP_CODE_COMMENTS");
  bool oldStripCommentsState = stripCommentsStateRef;
  bool &createSubdirs = Config_getBool("CREATE_SUBDIRS");
  bool oldCreateSubdirs = createSubdirs;
  // temporarily disable the stripping of comments for our own code example!
  stripCommentsStateRef = FALSE;
  // temporarily disable create subdirs for linking to our example
  createSubdirs = FALSE;

3245
  startFile(ol,"graph_legend",0,theTranslator->trLegendTitle().data());
3246
  startTitle(ol,0);
3247
  ol.parseText(theTranslator->trLegendTitle());
3248
  endTitle(ol,0,0);
3249
  ol.startContents();
3250 3251 3252 3253 3254 3255 3256 3257
  QCString legendDocs = theTranslator->trLegendDocs();
  int s = legendDocs.find("<center>");
  int e = legendDocs.find("</center>");
  if (Config_getEnum("DOT_IMAGE_FORMAT")=="svg" && s!=-1 && e!=-1)
  {
    legendDocs = legendDocs.left(s+8) + "[!-- SVG 0 --]\n" + legendDocs.mid(e); 
    //printf("legendDocs=%s\n",legendDocs.data());
  }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3258
  FileDef fd("","graph_legend");
3259
  ol.generateDoc("graph_legend",1,&fd,0,legendDocs,FALSE,FALSE);
3260 3261

  // restore config settings
3262
  stripCommentsStateRef = oldStripCommentsState;
3263 3264
  createSubdirs = oldCreateSubdirs;

3265 3266 3267 3268
  endFile(ol);
  ol.popGeneratorState();
}

3269 3270


3271 3272
//----------------------------------------------------------------------------
/*!
3273
 * write groups as hierarchical trees
3274
 */
3275
static void writeGroupTreeNode(OutputList &ol, GroupDef *gd, int level, FTVHelp* ftv, bool addToIndex)
3276
{
3277 3278
  //bool fortranOpt = Config_getBool("OPTIMIZE_FOR_FORTRAN");
  //bool vhdlOpt    = Config_getBool("OPTIMIZE_OUTPUT_VHDL");  
3279 3280 3281
  if (level>20)
  {
    warn(gd->getDefFileName(),gd->getDefLine(),
3282
        "maximum nesting level exceeded for group %s: check for possible recursive group relation!\n",gd->name().data()
3283 3284 3285
        );
    return;
  }
3286

3287 3288 3289
  /* Some groups should appear twice under different parent-groups.
   * That is why we should not check if it was visited 
   */
3290
  if (/*!gd->visited &&*/ (!gd->isASubGroup() || level>0) &&
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3291
      gd->isVisible() &&
3292 3293
      (!gd->isReference() || Config_getBool("EXTERNAL_GROUPS")) // hide external groups by default
     )
3294 3295 3296
  {
    //printf("gd->name()=%s #members=%d\n",gd->name().data(),gd->countMembers());
    // write group info
3297 3298
    bool hasSubGroups = gd->getSubGroups()->count()>0;
    bool hasSubPages = gd->getPages()->count()>0;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3299
    int numSubItems = 0;
3300
    if (1 /*Config_getBool("TOC_EXPAND")*/)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3301
    {
3302 3303 3304 3305
      QListIterator<MemberList> mli(gd->getMemberLists());
      MemberList *ml;
      for (mli.toFirst();(ml=mli.current());++mli)
      {
3306
        if (ml->listType()&MemberListType_documentationLists)
3307 3308 3309 3310
        {
          numSubItems += ml->count();
        }
      }
3311 3312 3313
      numSubItems += gd->getNamespaces()->count();
      numSubItems += gd->getClasses()->count();
      numSubItems += gd->getFiles()->count();
3314 3315
      numSubItems += gd->getDirs()->count();
      numSubItems += gd->getPages()->count();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3316 3317 3318
    }

    bool isDir = hasSubGroups || hasSubPages || numSubItems>0;
3319
    //printf("gd=`%s': pageDict=%d\n",gd->name().data(),gd->pageDict->count());
3320 3321
    if (addToIndex)
    {
3322 3323
      Doxygen::indexList->addContentsItem(isDir,gd->groupTitle(),gd->getReference(),gd->getOutputFileBase(),0,isDir,TRUE); 
      Doxygen::indexList->incContentsDepth();
3324
    }
3325 3326
    if (ftv)
    {
3327 3328 3329
      ftv->addContentsItem(hasSubGroups,gd->groupTitle(),
                           gd->getReference(),gd->getOutputFileBase(),0,
                           FALSE,FALSE,gd); 
3330 3331 3332
      ftv->incContentsDepth();
    }
    
3333 3334 3335 3336
    //ol.writeListItem();
    //ol.startTextLink(gd->getOutputFileBase(),0);
    //parseText(ol,gd->groupTitle());
    //ol.endTextLink();
3337

3338
    ol.startIndexListItem();
3339 3340 3341
    ol.startIndexItem(gd->getReference(),gd->getOutputFileBase());
    ol.parseText(gd->groupTitle());
    ol.endIndexItem(gd->getReference(),gd->getOutputFileBase());
3342 3343 3344 3345 3346 3347
    if (gd->isReference()) 
    { 
      ol.startTypewriter(); 
      ol.docify(" [external]");
      ol.endTypewriter();
    }
3348

3349 3350 3351
    QListIterator<LayoutDocEntry> eli(LayoutDocManager::instance().docEntries(LayoutDocManager::Group));
    LayoutDocEntry *lde;
    for (eli.toFirst();(lde=eli.current());++eli)
3352
    {
3353
      if (lde->kind()==LayoutDocEntry::MemberDef && addToIndex)
3354
      {
3355 3356 3357
        LayoutDocEntryMemberDef *lmd = (LayoutDocEntryMemberDef*)lde;
        MemberList *ml = gd->getMemberList(lmd->type);
        if (ml)
3358
        {
3359 3360 3361 3362
          MemberListIterator mi(*ml);
          MemberDef *md;
          for (mi.toFirst();(md=mi.current());++mi)
          {
3363
            MemberList *enumList = md->enumFieldList();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3364
            bool isDir = enumList!=0 && md->isEnumerate();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3365
            if (md->isVisible() && md->name().find('@')==-1)
3366
            {
3367
              Doxygen::indexList->addContentsItem(isDir,
3368
                  md->name(),md->getReference(),
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3369 3370 3371 3372
                  md->getOutputFileBase(),md->anchor(),FALSE,addToIndex);
            }
            if (isDir)
            {
3373
              Doxygen::indexList->incContentsDepth();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3374 3375 3376 3377 3378 3379
              MemberListIterator emli(*enumList);
              MemberDef *emd;
              for (emli.toFirst();(emd=emli.current());++emli)
              {
                if (emd->isVisible())
                {
3380
                  Doxygen::indexList->addContentsItem(FALSE,
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3381 3382 3383 3384
                      emd->name(),emd->getReference(),emd->getOutputFileBase(),
                      emd->anchor(),FALSE,addToIndex);
                }
              }
3385
              Doxygen::indexList->decContentsDepth();
3386 3387
            }
          }
3388 3389
        }
      }
3390
      else if (lde->kind()==LayoutDocEntry::GroupClasses && addToIndex)
3391
      {
3392
        ClassSDict::Iterator it(*gd->getClasses());
3393
        ClassDef *cd;
3394 3395
        for (;(cd=it.current());++it)
        {
3396 3397 3398 3399 3400
          //bool nestedClassInSameGroup = 
          //    cd->getOuterScope() && cd->getOuterScope()->definitionType()==Definition::TypeClass &&
          //    cd->getOuterScope()->partOfGroups()!=0 && cd->getOuterScope()->partOfGroups()->contains(gd);
          //printf("===== GroupClasses: %s visible=%d nestedClassInSameGroup=%d\n",cd->name().data(),cd->isVisible(),nestedClassInSameGroup);
          if (cd->isVisible() /*&& !nestedClassInSameGroup*/)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3401
          {
3402 3403 3404
            //if (cd->isEmbeddedInOuterScope())
            //{
              //printf("add class & members %d\n",addToIndex);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3405
              addMembersToIndex(cd,LayoutDocManager::Class,cd->displayName(FALSE),cd->anchor(),addToIndex,TRUE);
3406 3407 3408 3409
            //}
            //else // only index the class, not its members
            //{
            //  printf("%s: add class only\n",cd->name().data());
3410
            //  Doxygen::indexList->addContentsItem(FALSE,
3411 3412 3413
            //    cd->displayName(TRUE),cd->getReference(),
            //    cd->getOutputFileBase(),cd->anchor(),addToIndex,TRUE);
            //}
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3414
          }
3415 3416 3417 3418 3419 3420 3421 3422
        }
      }
      else if (lde->kind()==LayoutDocEntry::GroupNamespaces && addToIndex)
      {
        NamespaceSDict::Iterator it(*gd->getNamespaces());
        NamespaceDef *nd;
        for (;(nd=it.current());++it)
        {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3423 3424
          if (nd->isVisible())
          {
3425
            Doxygen::indexList->addContentsItem(FALSE,
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3426 3427 3428
                nd->localName(),nd->getReference(),
                nd->getOutputFileBase(),0,FALSE,FALSE);
          }
3429 3430 3431 3432 3433 3434 3435 3436
        }
      }
      else if (lde->kind()==LayoutDocEntry::GroupFiles && addToIndex)
      {
        QListIterator<FileDef> it(*gd->getFiles());
        FileDef *fd;
        for (;(fd=it.current());++it)
        {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3437 3438
          if (fd->isVisible())
          {
3439
            Doxygen::indexList->addContentsItem(FALSE,
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3440 3441 3442
                fd->displayName(),fd->getReference(),
                fd->getOutputFileBase(),0,FALSE,FALSE);
          }
3443 3444 3445 3446
        }
      }
      else if (lde->kind()==LayoutDocEntry::GroupDirs && addToIndex)
      {
3447 3448 3449
        QListIterator<DirDef> it(*gd->getDirs());
        DirDef *dd;
        for (;(dd=it.current());++it)
3450
        {
3451
          if (dd->isVisible())
3452
          {
3453
            Doxygen::indexList->addContentsItem(FALSE,
3454 3455
                dd->shortName(),dd->getReference(),
                dd->getOutputFileBase(),0,FALSE,FALSE);
3456 3457
          }
        }
3458
      }
3459
      else if (lde->kind()==LayoutDocEntry::GroupPageDocs && addToIndex)
3460
      {
3461 3462 3463
        SDict<PageDef>::Iterator it(*gd->getPages());
        PageDef *pd;
        for (;(pd=it.current());++it)
3464
        {
3465
          SectionInfo *si=0;
3466
          if (!pd->name().isEmpty()) si=Doxygen::sectionDict->find(pd->name());
3467 3468
          bool hasSubPages = pd->hasSubPages();
          bool hasSections = pd->hasSections();
3469
          Doxygen::indexList->addContentsItem(
3470 3471 3472 3473 3474 3475 3476 3477 3478
              hasSubPages || hasSections,
              convertToHtml(pd->title(),TRUE),
              gd->getReference(),
              gd->getOutputFileBase(),
              si ? si->label.data() : 0,
              hasSubPages || hasSections,
              TRUE); // addToNavIndex
          if (hasSections || hasSubPages)
          {
3479
            Doxygen::indexList->incContentsDepth();
3480 3481 3482 3483 3484
          }
          if (hasSections)
          {
            pd->addSectionsToIndex();
          }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3485
          writePages(pd,0);
3486 3487
          if (hasSections || hasSubPages)
          {
3488
            Doxygen::indexList->decContentsDepth();
3489
          }
3490
        }
3491
      }
3492
      else if (lde->kind()==LayoutDocEntry::GroupNestedGroups)
3493
      {
3494
        if (gd->getSubGroups()->count()>0)
3495
        {
3496 3497 3498 3499 3500 3501 3502 3503
          startIndexHierarchy(ol,level+1);
          QListIterator<GroupDef> gli(*gd->getSubGroups());
          GroupDef *subgd = 0;
          for (gli.toFirst();(subgd=gli.current());++gli)
          {
            writeGroupTreeNode(ol,subgd,level+1,ftv,addToIndex);
          }
          endIndexHierarchy(ol,level+1); 
3504
        }
3505 3506
      }
    }
3507

3508
    ol.endIndexListItem();
3509
    
3510 3511
    if (addToIndex)
    {
3512
      Doxygen::indexList->decContentsDepth();
3513
    }
3514
    if (ftv)
3515
    {
3516
      ftv->decContentsDepth();
3517
    }
3518
    //gd->visited=TRUE;
3519 3520 3521
  }
}

3522
static void writeGroupHierarchy(OutputList &ol, FTVHelp* ftv,bool addToIndex)
3523
{
3524 3525 3526 3527 3528
  if (ftv)
  {
    ol.pushGeneratorState(); 
    ol.disable(OutputGenerator::Html);
  }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3529
  startIndexHierarchy(ol,0);
3530
  GroupSDict::Iterator gli(*Doxygen::groupSDict);
3531
  GroupDef *gd;
3532
  for (gli.toFirst();(gd=gli.current());++gli)
3533
  {
3534
    writeGroupTreeNode(ol,gd,0,ftv,addToIndex);
3535
  }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3536
  endIndexHierarchy(ol,0); 
3537
  if (ftv)
3538
  {
3539
    ol.popGeneratorState(); 
3540
  }
3541 3542
}

3543 3544
#if 0
static void writeGroupTree(GroupDef *gd,FTVHelp *ftv,int level,bool addToIndex)
3545
{
3546 3547 3548 3549 3550 3551 3552 3553
  static bool externalGroups = Config_getBool("EXTERNAL_GROUPS");
  /* Some groups should appear twice under different parent-groups.
   * That is why we should not check if it was visited 
   */
  if ((!gd->isASubGroup() || level>0) &&
      gd->isVisible() &&
      (!gd->isReference() || externalGroups) // hide external groups by default
     )
3554
  {
3555
    if (ftv)
3556
    {
3557 3558
      ftv->addContentsItem(hasSubGroups,gd->groupTitle(),gd->getReference(),gd->getOutputFileBase(),0); 
      ftv->incContentsDepth();
3559
    }
3560
    if (ftv)
3561
    {
3562
      ftv->decContentsDepth();
3563 3564 3565 3566
    }
  }
}

3567
static void writeGroupTree(FTVHelp *ftv,bool addToIndex)
3568
{
3569 3570 3571
  GroupSDict::Iterator gli(*Doxygen::groupSDict);
  GroupDef *gd;
  for (gli.toFirst();(gd=gli.current());++gli)
3572
  {
3573
    writeGroupTree(gd,ftv,0,addToIndex);
3574
  }
3575
}
3576
#endif
3577

Dimitri van Heesch's avatar
Dimitri van Heesch committed
3578 3579
//----------------------------------------------------------------------------

3580
static void writeGroupIndex(OutputList &ol)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3581 3582
{
  if (documentedGroups==0) return; 
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3583
  ol.pushGeneratorState(); 
3584
  // 1.{
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3585
  ol.disable(OutputGenerator::Man);
3586
  LayoutNavEntry *lne = LayoutDocManager::instance().rootNavEntry()->find(LayoutNavEntry::Modules);
3587
  QCString title = lne ? lne->title() : theTranslator->trModules();
3588 3589
  bool addToIndex = lne==0 || lne->visible();

3590
  startFile(ol,"modules",0,title,HLI_Modules);
3591
  startTitle(ol,0);
3592
  ol.parseText(title);
3593
  endTitle(ol,0,0);
3594
  ol.startContents();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3595
  ol.startTextBlock();
3596
  ol.parseText(lne ? lne->intro() : theTranslator->trModulesDescription());
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3597
  ol.endTextBlock();
3598

3599 3600 3601 3602 3603 3604
  // ---------------
  // Normal group index for Latex/RTF
  // ---------------
  // 2.{
  ol.pushGeneratorState();
  ol.disable(OutputGenerator::Html);
3605
  Doxygen::indexList->disable();
3606

3607 3608
  writeGroupHierarchy(ol,0,FALSE);

3609
  Doxygen::indexList->enable();
3610 3611 3612 3613 3614 3615 3616 3617 3618
  ol.popGeneratorState();
  // 2.}

  // ---------------
  // interactive group index for HTML
  // ---------------
  // 2.{
  ol.pushGeneratorState(); 
  ol.disableAllBut(OutputGenerator::Html);
3619 3620

  {
3621 3622
    if (addToIndex)
    {
3623 3624
      Doxygen::indexList->addContentsItem(TRUE,title,0,"modules",0,TRUE,TRUE); 
      Doxygen::indexList->incContentsDepth();
3625 3626 3627
    }
    FTVHelp* ftv = new FTVHelp(FALSE);
    writeGroupHierarchy(ol,ftv,addToIndex);
3628 3629 3630
    QGString outStr;
    FTextStream t(&outStr);
    ftv->generateTreeViewInline(t);
3631
    ol.disableAllBut(OutputGenerator::Html);
3632
    ol.writeString(outStr);
3633
    delete ftv;
3634 3635
    if (addToIndex)
    {
3636
      Doxygen::indexList->decContentsDepth();
3637
    }
3638
  }
3639 3640 3641
  ol.popGeneratorState();
  // 2.}

Dimitri van Heesch's avatar
Dimitri van Heesch committed
3642
  endFile(ol);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3643
  ol.popGeneratorState();
3644
  // 1.}
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3645 3646
}

3647 3648
//----------------------------------------------------------------------------

3649
#if 0
3650
static void writeDirIndex(OutputList &ol)
3651 3652 3653 3654
{
  if (documentedDirs==0) return; 
  ol.pushGeneratorState(); 
  ol.disable(OutputGenerator::Man);
3655
  LayoutNavEntry *lne = LayoutDocManager::instance().rootNavEntry()->find(LayoutNavEntry::Dirs);
3656
  QCString title = lne ? lne->title() : theTranslator->trDirectories();
3657
  bool addToIndex=FALSE; //lne==0 || lne->visible();
3658

3659
  startFile(ol,"dirs",0,title,HLI_Directories);
3660 3661 3662
  startTitle(ol,0);
  ol.parseText(title);
  endTitle(ol,0,0);
3663
  ol.startContents();
3664
  ol.startTextBlock();
3665 3666 3667

  if (addToIndex)
  {
3668 3669
    Doxygen::indexList->addContentsItem(TRUE,title,0,"dirs",0,TRUE,TRUE); 
    Doxygen::indexList->incContentsDepth();
3670
  }
3671
  ol.parseText(lne ? lne->intro() : theTranslator->trDirDescription());
3672 3673
  ol.endTextBlock();

3674 3675 3676
  FTVHelp* ftv = 0;
  bool treeView=Config_getBool("USE_INLINE_TREES");
  if (treeView)
3677 3678 3679
  {
    ftv = new FTVHelp(FALSE);
  }
3680

3681
  writeDirHierarchy(ol,ftv,addToIndex);
3682 3683 3684

  if (ftv)
  {
3685 3686 3687
    QGString outStr;
    FTextStream t(&outStr);
    ftv->generateTreeViewInline(t);
3688 3689
    ol.pushGeneratorState(); 
    ol.disableAllBut(OutputGenerator::Html);
3690
    ol.writeString(outStr);
3691 3692 3693
    ol.popGeneratorState();
    delete ftv;
  }
3694 3695
  if (addToIndex)
  {
3696
    Doxygen::indexList->decContentsDepth();
3697 3698 3699 3700
  }
  endFile(ol);
  ol.popGeneratorState();
}
3701
#endif
3702 3703 3704 3705 3706

//----------------------------------------------------------------------------

static void writeUserGroupStubPage(OutputList &ol,LayoutNavEntry *lne)
{
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3707
  if (lne->baseFile().left(9)=="usergroup")
3708
  {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3709 3710 3711 3712 3713 3714 3715 3716 3717 3718
    ol.pushGeneratorState();
    ol.disableAllBut(OutputGenerator::Html);
    startFile(ol,lne->baseFile(),0,lne->title(),HLI_UserGroup);
    startTitle(ol,0);
    ol.parseText(lne->title());
    endTitle(ol,0,0);
    ol.startContents();
    QListIterator<LayoutNavEntry> li(lne->children());
    LayoutNavEntry *entry;
    int count=0;
3719 3720
    for (li.toFirst();(entry=li.current());++li)
    {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3721 3722 3723 3724 3725 3726
      if (entry->visible()) count++;
    }
    if (count>0)
    {
      ol.writeString("<ul>\n");
      for (li.toFirst();(entry=li.current());++li)
3727
      {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3728 3729 3730 3731 3732
        if (entry->visible())
        {
          ol.writeString("<li><a href=\""+entry->url()+"\"><span>"+
              fixSpaces(entry->title())+"</span></a></li>\n");
        }
3733
      }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3734
      ol.writeString("</ul>\n");
3735
    }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3736 3737
    endFile(ol);
    ol.popGeneratorState();
3738
  }
3739 3740 3741 3742
}

//----------------------------------------------------------------------------

3743

3744
static void writeIndex(OutputList &ol)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3745
{
3746 3747
  static bool fortranOpt = Config_getBool("OPTIMIZE_FOR_FORTRAN");
  static bool vhdlOpt    = Config_getBool("OPTIMIZE_OUTPUT_VHDL");
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3748
  static QCString projectName = Config_getString("PROJECT_NAME");
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3749
  // save old generator state
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3750
  ol.pushGeneratorState();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3751

3752
  QCString projPrefix;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3753
  if (!projectName.isEmpty())
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3754
  {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3755
    projPrefix=projectName+" ";
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3756
  }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3757 3758

  //--------------------------------------------------------------------
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3759
  // write HTML index
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3760
  //--------------------------------------------------------------------
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3761
  ol.disableAllBut(OutputGenerator::Html);
3762

3763
  QCString defFileName = 
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3764
    Doxygen::mainPage ? Doxygen::mainPage->docFile().data() : "[generated]";
3765
  int defLine =
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3766
    Doxygen::mainPage ? Doxygen::mainPage->docLine() : -1;
3767

Dimitri van Heesch's avatar
Dimitri van Heesch committed
3768
  QCString title;
3769
  if (!mainPageHasTitle())
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3770
  {
3771
    title = theTranslator->trMainPage();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3772
  }
3773
  else 
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3774
  {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3775
    title = filterTitle(Doxygen::mainPage->title());
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3776 3777
  }

3778
  QCString indexName="index";
3779
  ol.startFile(indexName,0,title);
3780
  
3781
  if (Doxygen::mainPage)
3782
  {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3783 3784
    if (
        (!projectName.isEmpty() && mainPageHasTitle() && qstricmp(title,projectName)!=0)
3785 3786
       ) // to avoid duplicate entries in the treeview
    {
3787
      Doxygen::indexList->addContentsItem(Doxygen::mainPage->hasSubPages(),title,0,indexName,0,Doxygen::mainPage->hasSubPages(),TRUE); 
3788
    }
3789
    if (Doxygen::mainPage->hasSubPages() || Doxygen::mainPage->hasSections())
3790
    {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3791
      writePages(Doxygen::mainPage,0);
3792
    }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3793
  }
3794

3795
  ol.startQuickIndices();
3796 3797
  if (!Config_getBool("DISABLE_INDEX")) 
  {
3798
    ol.writeQuickLinks(TRUE,HLI_Main,0);
3799 3800
  }
  ol.endQuickIndices();
3801 3802
  ol.writeSplitBar(indexName);
  ol.writeSearchInfo();
3803
  bool headerWritten=FALSE;
3804
  if (Doxygen::mainPage && !Doxygen::mainPage->title().isEmpty())
3805
  {
3806 3807
    if (Doxygen::mainPage->title().lower()!="notitle")
    {
3808 3809
      ol.startHeaderSection();
      ol.startTitleHead(0);
3810
      ol.generateDoc(Doxygen::mainPage->docFile(),Doxygen::mainPage->docLine(),
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3811 3812
                  Doxygen::mainPage,0,Doxygen::mainPage->title(),
                  TRUE,FALSE,0,TRUE,FALSE);
3813
      headerWritten = TRUE;
3814
    }
3815 3816 3817
  }
  else
  {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3818
    if (!projectName.isEmpty())
3819
    {
3820 3821
      ol.startHeaderSection();
      ol.startTitleHead(0);
3822
      ol.parseText(projPrefix+theTranslator->trDocumentation());
3823
      headerWritten = TRUE;
3824
    }
3825
  }
3826 3827 3828 3829 3830
  if (headerWritten)
  {
    ol.endTitleHead(0,0);
    ol.endHeaderSection();
  }
3831

3832
  ol.startContents();
3833 3834
  if (Config_getBool("DISABLE_INDEX") && Doxygen::mainPage==0) 
  {
3835
    ol.writeQuickLinks(FALSE,HLI_Main,0);
3836
  }
3837

3838
  if (Doxygen::mainPage)
3839
  {
3840
    Doxygen::insideMainPage=TRUE;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3841 3842 3843 3844 3845
    if (Doxygen::mainPage->showToc() && Doxygen::mainPage->hasSections())
    {
      Doxygen::mainPage->writeToc(ol);
    }

Dimitri van Heesch's avatar
Dimitri van Heesch committed
3846
    ol.startTextBlock();
3847
    ol.generateDoc(defFileName,defLine,Doxygen::mainPage,0,
3848
                Doxygen::mainPage->documentation(),TRUE,FALSE
3849
                /*,Doxygen::mainPage->sectionDict*/);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3850
    ol.endTextBlock();
3851

3852
    Doxygen::insideMainPage=FALSE;
3853 3854
  }
  
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3855 3856 3857
  endFile(ol);
  ol.disable(OutputGenerator::Html);
  
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3858
  //--------------------------------------------------------------------
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3859
  // write LaTeX/RTF index
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3860
  //--------------------------------------------------------------------
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3861
  ol.enable(OutputGenerator::Latex);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3862 3863
  ol.enable(OutputGenerator::RTF);

3864
  ol.startFile("refman",0,0);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3865
  ol.startIndexSection(isTitlePageStart);
3866
  if (!Config_getString("LATEX_HEADER").isEmpty()) 
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3867 3868 3869 3870
  {
    ol.disable(OutputGenerator::Latex);
  }

3871 3872 3873 3874 3875 3876 3877 3878 3879
  if (projPrefix.isEmpty())
  {
    ol.parseText(theTranslator->trReferenceManual());
  }
  else
  {
    ol.parseText(projPrefix);
  }

3880
  if (!Config_getString("PROJECT_NUMBER").isEmpty())
3881
  {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3882
    ol.startProjectNumber(); 
3883
    ol.generateDoc(defFileName,defLine,Doxygen::mainPage,0,Config_getString("PROJECT_NUMBER"),FALSE,FALSE);
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3884 3885 3886 3887
    ol.endProjectNumber();
  }
  ol.endIndexSection(isTitlePageStart);
  ol.startIndexSection(isTitlePageAuthor);
3888
  ol.parseText(theTranslator->trGeneratedBy());
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3889
  ol.endIndexSection(isTitlePageAuthor);
3890 3891
  ol.enable(OutputGenerator::Latex);

3892
  ol.lastIndexPage();
3893
  if (Doxygen::mainPage)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3894 3895
  {
    ol.startIndexSection(isMainPage);
3896
    if (mainPageHasTitle())
3897
    {
3898
      ol.parseText(Doxygen::mainPage->title());
3899
    }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3900
    else
3901
    {
3902
      ol.parseText(/*projPrefix+*/theTranslator->trMainPage());
3903
    }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3904
    ol.endIndexSection(isMainPage);
3905
  }
3906 3907 3908 3909 3910 3911 3912 3913 3914
  if (documentedPages>0)
  {
    //ol.parseText(projPrefix+theTranslator->trPageDocumentation());
    //ol.endIndexSection(isPageDocumentation);
    PageSDict::Iterator pdi(*Doxygen::pageSDict);
    PageDef *pd=pdi.toFirst();
    bool first=Doxygen::mainPage==0;
    for (pdi.toFirst();(pd=pdi.current());++pdi)
    {
3915
      if (!pd->getGroupDef() && !pd->isReference() && 
3916 3917
          (!pd->hasParentPage() ||                    // not inside other page
           (Doxygen::mainPage==pd->getOuterScope()))  // or inside main page
3918
         )
3919
      {
3920 3921 3922 3923 3924 3925 3926
        bool isCitationPage = pd->name()=="citelist";
        if (isCitationPage)
        {
          // For LaTeX the bibliograph is already written by \bibliography
          ol.pushGeneratorState();
          ol.disable(OutputGenerator::Latex);
        }
3927 3928
        QCString title = pd->title();
        if (title.isEmpty()) title=pd->name();
3929

3930 3931 3932
        ol.startIndexSection(isPageDocumentation);
        ol.parseText(title);
        ol.endIndexSection(isPageDocumentation);
3933

3934 3935 3936 3937 3938
        ol.pushGeneratorState(); // write TOC title (RTF only)
          ol.disableAllBut(OutputGenerator::RTF);
          ol.startIndexSection(isPageDocumentation2);
          ol.parseText(title);
          ol.endIndexSection(isPageDocumentation2);
3939 3940 3941
        ol.popGeneratorState();

        ol.writeAnchor(0,pd->getOutputFileBase());
3942 3943 3944

        ol.writePageLink(pd->getOutputFileBase(),first);
        first=FALSE;
3945 3946 3947 3948 3949

        if (isCitationPage)
        {
          ol.popGeneratorState();
        }
3950 3951 3952
      }
    }
  }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3953

3954
  if (!Config_getBool("LATEX_HIDE_INDICES"))
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3955
  {
3956 3957 3958 3959 3960 3961
    //if (indexedPages>0)
    //{
    //  ol.startIndexSection(isPageIndex);
    //  ol.parseText(/*projPrefix+*/ theTranslator->trPageIndex());
    //  ol.endIndexSection(isPageIndex);
    //}
3962 3963 3964
    if (documentedGroups>0)
    {
      ol.startIndexSection(isModuleIndex);
3965
      ol.parseText(/*projPrefix+*/ theTranslator->trModuleIndex());
3966 3967 3968 3969 3970
      ol.endIndexSection(isModuleIndex);
    }
    if (documentedNamespaces>0)
    {
      ol.startIndexSection(isNamespaceIndex);
3971
      ol.parseText(/*projPrefix+*/(fortranOpt?theTranslator->trModulesIndex():theTranslator->trNamespaceIndex()));
3972 3973 3974 3975 3976
      ol.endIndexSection(isNamespaceIndex);
    }
    if (hierarchyClasses>0)
    {
      ol.startIndexSection(isClassHierarchyIndex);
3977 3978
      ol.parseText(/*projPrefix+*/
          (fortranOpt ? theTranslator->trCompoundIndexFortran() : 
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3979
           vhdlOpt    ? VhdlDocGen::trDesignUnitIndex()         :
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3980
                        theTranslator->trHierarchicalIndex()
3981
          ));
3982 3983
      ol.endIndexSection(isClassHierarchyIndex);
    }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3984
    if (annotatedClassesPrinted>0)
3985 3986
    {
      ol.startIndexSection(isCompoundIndex);
3987
      ol.parseText(/*projPrefix+*/
3988
          (fortranOpt ? theTranslator->trCompoundIndexFortran() :
Dimitri van Heesch's avatar
Dimitri van Heesch committed
3989 3990
              vhdlOpt ? VhdlDocGen::trDesignUnitIndex()         : 
                        theTranslator->trCompoundIndex()
3991
          ));
3992 3993 3994 3995 3996
      ol.endIndexSection(isCompoundIndex);
    }
    if (documentedFiles>0)
    {
      ol.startIndexSection(isFileIndex);
3997
      ol.parseText(/*projPrefix+*/theTranslator->trFileIndex());
3998 3999
      ol.endIndexSection(isFileIndex);
    }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
4000
  }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
4001 4002 4003
  if (documentedGroups>0)
  {
    ol.startIndexSection(isModuleDocumentation);
4004
    ol.parseText(/*projPrefix+*/theTranslator->trModuleDocumentation());
Dimitri van Heesch's avatar
Dimitri van Heesch committed
4005 4006
    ol.endIndexSection(isModuleDocumentation);
  }
4007 4008 4009
  if (documentedNamespaces>0)
  {
    ol.startIndexSection(isNamespaceDocumentation);
4010
    ol.parseText(/*projPrefix+*/(fortranOpt?theTranslator->trModuleDocumentation():theTranslator->trNamespaceDocumentation()));
4011 4012
    ol.endIndexSection(isNamespaceDocumentation);
  }
4013
  if (annotatedClassesPrinted>0)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
4014 4015
  {
    ol.startIndexSection(isClassDocumentation);
4016
    ol.parseText(/*projPrefix+*/(fortranOpt?theTranslator->trTypeDocumentation():theTranslator->trClassDocumentation()));
Dimitri van Heesch's avatar
Dimitri van Heesch committed
4017 4018 4019 4020 4021
    ol.endIndexSection(isClassDocumentation);
  }
  if (documentedFiles>0)
  {
    ol.startIndexSection(isFileDocumentation);
4022
    ol.parseText(/*projPrefix+*/theTranslator->trFileDocumentation());
Dimitri van Heesch's avatar
Dimitri van Heesch committed
4023 4024
    ol.endIndexSection(isFileDocumentation);
  }
4025
  if (Doxygen::exampleSDict->count()>0)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
4026 4027
  {
    ol.startIndexSection(isExampleDocumentation);
4028
    ol.parseText(/*projPrefix+*/theTranslator->trExampleDocumentation());
Dimitri van Heesch's avatar
Dimitri van Heesch committed
4029 4030 4031 4032 4033
    ol.endIndexSection(isExampleDocumentation);
  }
  ol.endIndexSection(isEndIndex);
  endFile(ol);

4034
  if (Doxygen::mainPage)
4035
  {
4036
    Doxygen::insideMainPage=TRUE;
4037
    ol.disable(OutputGenerator::Man);
4038
    startFile(ol,Doxygen::mainPage->name(),0,Doxygen::mainPage->title());
4039
    ol.startContents();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
4040
    ol.startTextBlock();
4041
    ol.generateDoc(defFileName,defLine,Doxygen::mainPage,0,
4042
                Doxygen::mainPage->documentation(),FALSE,FALSE
4043
               );
Dimitri van Heesch's avatar
Dimitri van Heesch committed
4044
    ol.endTextBlock();
4045 4046
    endFile(ol);
    ol.enable(OutputGenerator::Man);
4047
    Doxygen::insideMainPage=FALSE;
4048 4049
  }

Dimitri van Heesch's avatar
Dimitri van Heesch committed
4050
  ol.popGeneratorState();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
4051
}
4052

4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071
static QArray<bool> indexWritten;

static void writeIndexHierarchyEntries(OutputList &ol,const QList<LayoutNavEntry> &entries)
{
  QListIterator<LayoutNavEntry> li(entries);
  LayoutNavEntry *lne;
  for (li.toFirst();(lne=li.current());++li)
  {
    LayoutNavEntry::Kind kind = lne->kind();
    uint index = (uint)kind;
    if (index>=indexWritten.size())
    {
      uint i;
      uint oldSize = indexWritten.size();
      uint newSize = index+1;
      indexWritten.resize(newSize);
      for (i=oldSize;i<newSize;i++) indexWritten.at(i)=FALSE;
    }
    //printf("starting %s kind=%d\n",lne->title().data(),lne->kind());
4072
    bool addToIndex=lne==0 || lne->visible();
4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091
    bool needsClosing=FALSE;
    if (!indexWritten.at(index))
    {
      switch(kind)
      {
        case LayoutNavEntry::MainPage: 
          msg("Generating index page...\n");
          writeIndex(ol); 
          break;
        case LayoutNavEntry::Pages: 
          msg("Generating page index...\n");
          writePageIndex(ol);
          break;
        case LayoutNavEntry::Modules: 
          msg("Generating module index...\n");
          writeGroupIndex(ol);
          break;
        case LayoutNavEntry::Namespaces: 
          {
4092 4093
            static bool showNamespaces = Config_getBool("SHOW_NAMESPACES");
            if (showNamespaces)
4094
            {
4095 4096
              if (documentedNamespaces>0 && addToIndex)
              {
4097 4098
                Doxygen::indexList->addContentsItem(TRUE,lne->title(),0,0,0); 
                Doxygen::indexList->incContentsDepth();
4099 4100 4101 4102 4103 4104 4105
                needsClosing=TRUE;
              }
              if (LayoutDocManager::instance().rootNavEntry()->find(LayoutNavEntry::Namespaces)!=lne) // for backward compatibility with old layout file
              {
                msg("Generating namespace index...\n");
                writeNamespaceIndex(ol);
              }
4106
            }
4107 4108 4109 4110 4111 4112
          }
          break;
        case LayoutNavEntry::NamespaceList: 
          {
            static bool showNamespaces = Config_getBool("SHOW_NAMESPACES");
            if (showNamespaces)
4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123
            {
              msg("Generating namespace index...\n");
              writeNamespaceIndex(ol);
            }
          }
          break;
        case LayoutNavEntry::NamespaceMembers: 
          msg("Generating namespace member index...\n");
          writeNamespaceMemberIndex(ol);
          break;
        case LayoutNavEntry::Classes: 
4124
          if (annotatedClasses>0 && addToIndex)
4125
          {
4126 4127
            Doxygen::indexList->addContentsItem(TRUE,lne->title(),0,0,0); 
            Doxygen::indexList->incContentsDepth();
4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158
            needsClosing=TRUE;
          }
          if (LayoutDocManager::instance().rootNavEntry()->find(LayoutNavEntry::Classes)!=lne) // for backward compatibility with old layout file
          {
            msg("Generating annotated compound index...\n");
            writeAnnotatedIndex(ol);
          }
          break;
        case LayoutNavEntry::ClassList: 
          msg("Generating annotated compound index...\n");
          writeAnnotatedIndex(ol);
          break;
        case LayoutNavEntry::ClassIndex:
          msg("Generating alphabetical compound index...\n");
          writeAlphabeticalIndex(ol);
          break;
        case LayoutNavEntry::ClassHierarchy: 
          msg("Generating hierarchical class index...\n");
          writeHierarchicalIndex(ol);
          if (Config_getBool("HAVE_DOT") && Config_getBool("GRAPHICAL_HIERARCHY"))
          {
            msg("Generating graphical class hierarchy...\n");
            writeGraphicalClassHierarchy(ol);
          }
          break;
        case LayoutNavEntry::ClassMembers: 
          msg("Generating member index...\n");
          writeClassMemberIndex(ol);
          break;
        case LayoutNavEntry::Files: 
          {
4159 4160 4161 4162 4163
            static bool showFiles = Config_getBool("SHOW_FILES");
            if (showFiles)
            {
              if (documentedHtmlFiles>0 && addToIndex)
              {
4164 4165
                Doxygen::indexList->addContentsItem(TRUE,lne->title(),0,0,0); 
                Doxygen::indexList->incContentsDepth();
4166 4167 4168 4169 4170 4171 4172 4173
                needsClosing=TRUE;
              }
              if (LayoutDocManager::instance().rootNavEntry()->find(LayoutNavEntry::Files)!=lne) // for backward compatibility with old layout file
              {
                msg("Generating file index...\n");
                writeFileIndex(ol);
              }
            }
4174 4175 4176
          }
          break;
        case LayoutNavEntry::FileList: 
4177 4178 4179 4180 4181 4182 4183 4184
          {
            static bool showFiles = Config_getBool("SHOW_FILES");
            if (showFiles)
            {
              msg("Generating file index...\n");
              writeFileIndex(ol);
            }
          }
4185 4186 4187 4188 4189 4190 4191 4192 4193 4194
          break;
        case LayoutNavEntry::FileGlobals: 
          msg("Generating file member index...\n");
          writeFileMemberIndex(ol);
          break;
        case LayoutNavEntry::Examples: 
          msg("Generating example index...\n");
          writeExampleIndex(ol);
          break;
        case LayoutNavEntry::User: 
4195 4196 4197
          {
            // prepend a ! or ^ marker to the URL to avoid tampering with it
            QCString url = correctURL(lne->url(),"!"); // add ! to relative URL
Dimitri van Heesch's avatar
Dimitri van Heesch committed
4198 4199
            bool isRelative=url.at(0)=='!';
            if (!url.isEmpty() && !isRelative) // absolute URL
4200 4201 4202 4203
            {
              url.prepend("^"); // prepend ^ to absolute URL
            }
            bool isRef = lne->baseFile().left(4)=="@ref" || lne->baseFile().left(4)=="\\ref";
Dimitri van Heesch's avatar
Dimitri van Heesch committed
4204
            Doxygen::indexList->addContentsItem(TRUE,lne->title(),0,url,0,FALSE,isRef || isRelative); 
4205
          }
4206
          break;
4207 4208 4209
        case LayoutNavEntry::UserGroup:
          if (addToIndex)
          {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231
            QCString url = correctURL(lne->url(),"!"); // add ! to relative URL
            if (!url.isEmpty())
            {
              if (url=="![none]")
              {
                Doxygen::indexList->addContentsItem(TRUE,lne->title(),0,0,0,FALSE,FALSE); 
              }
              else
              {
                bool isRelative=url.at(0)=='!';
                if (!isRelative) // absolute URL
                {
                  url.prepend("^"); // prepend ^ to absolute URL
                }
                bool isRef = lne->baseFile().left(4)=="@ref" || lne->baseFile().left(4)=="\\ref";
                Doxygen::indexList->addContentsItem(TRUE,lne->title(),0,url,0,FALSE,isRef || isRelative); 
              }
            }
            else 
            {
              Doxygen::indexList->addContentsItem(TRUE,lne->title(),0,lne->baseFile(),0,TRUE,TRUE); 
            }
4232
            Doxygen::indexList->incContentsDepth();
4233 4234 4235 4236 4237 4238 4239 4240
            needsClosing=TRUE;
          }
          writeUserGroupStubPage(ol,lne);
          break;
      }
      if (kind!=LayoutNavEntry::User && kind!=LayoutNavEntry::UserGroup) // User entry may appear multiple times
      {
        indexWritten.at(index)=TRUE;
4241 4242 4243 4244 4245 4246 4247 4248 4249 4250
      }
    }
    writeIndexHierarchyEntries(ol,lne->children());
    if (needsClosing)
    {
      switch(kind)
      {
        case LayoutNavEntry::Namespaces: 
        case LayoutNavEntry::Classes: 
        case LayoutNavEntry::Files: 
4251
        case LayoutNavEntry::UserGroup: 
4252
          Doxygen::indexList->decContentsDepth();
4253 4254 4255 4256 4257 4258 4259 4260
          break;
        default:
          break;
      }
    }
    //printf("ending %s kind=%d\n",lne->title().data(),lne->kind());
  }
}
4261

4262 4263 4264 4265 4266 4267 4268 4269
void writeIndexHierarchy(OutputList &ol)
{
  LayoutNavEntry *lne = LayoutDocManager::instance().rootNavEntry();
  if (lne)
  {
    writeIndexHierarchyEntries(ol,lne->children());
  }
}
4270