Ignore:
Timestamp:
May 5, 2011, 5:36:53 AM (14 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/tools/qdoc3/pagegenerator.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    4444*/
    4545
    46 #include <QtCore>
    4746#include <qfile.h>
    4847#include <qfileinfo.h>
    49 
     48#include <qdebug.h>
    5049#include "pagegenerator.h"
    5150#include "tree.h"
     
    7069}
    7170
     71static QRegExp linkTag("(<@link node=\"([^\"]+)\">).*(</@link>)");
     72static QRegExp funcTag("(<@func target=\"([^\"]*)\">)(.*)(</@func>)");
     73static QRegExp typeTag("(<@(type|headerfile|func)(?: +[^>]*)?>)(.*)(</@\\2>)");
     74static QRegExp spanTag("</@(?:comment|preprocessor|string|char)>");
     75static QRegExp unknownTag("</?@[^>]*>");
     76
     77bool PageGenerator::parseArg(const QString& src,
     78                             const QString& tag,
     79                             int* pos,
     80                             int n,
     81                             QStringRef* contents,
     82                             QStringRef* par1,
     83                             bool debug)
     84{
     85#define SKIP_CHAR(c) \
     86    if (debug) \
     87        qDebug() << "looking for " << c << " at " << QString(src.data() + i, n - i); \
     88    if (i >= n || src[i] != c) { \
     89        if (debug) \
     90            qDebug() << " char '" << c << "' not found"; \
     91        return false; \
     92    } \
     93    ++i;
     94
     95
     96#define SKIP_SPACE \
     97    while (i < n && src[i] == ' ') \
     98        ++i;
     99
     100    int i = *pos;
     101    int j = i;
     102
     103    // assume "<@" has been parsed outside
     104    //SKIP_CHAR('<');
     105    //SKIP_CHAR('@');
     106
     107    if (tag != QStringRef(&src, i, tag.length())) {
     108        if (0 && debug)
     109            qDebug() << "tag " << tag << " not found at " << i;
     110        return false;
     111    }
     112
     113    if (debug)
     114        qDebug() << "haystack:" << src << "needle:" << tag << "i:" <<i;
     115
     116    // skip tag
     117    i += tag.length();
     118
     119    // parse stuff like:  linkTag("(<@link node=\"([^\"]+)\">).*(</@link>)");
     120    if (par1) {
     121        SKIP_SPACE;
     122        // read parameter name
     123        j = i;
     124        while (i < n && src[i].isLetter())
     125            ++i;
     126        if (src[i] == '=') {
     127            if (debug)
     128                qDebug() << "read parameter" << QString(src.data() + j, i - j);
     129            SKIP_CHAR('=');
     130            SKIP_CHAR('"');
     131            // skip parameter name
     132            j = i;
     133            while (i < n && src[i] != '"')
     134                ++i;
     135            *par1 = QStringRef(&src, j, i - j);
     136            SKIP_CHAR('"');
     137            SKIP_SPACE;
     138        } else {
     139            if (debug)
     140                qDebug() << "no optional parameter found";
     141        }
     142    }
     143    SKIP_SPACE;
     144    SKIP_CHAR('>');
     145
     146    // find contents up to closing "</@tag>
     147    j = i;
     148    for (; true; ++i) {
     149        if (i + 4 + tag.length() > n)
     150            return false;
     151        if (src[i] != '<')
     152            continue;
     153        if (src[i + 1] != '/')
     154            continue;
     155        if (src[i + 2] != '@')
     156            continue;
     157        if (tag != QStringRef(&src, i + 3, tag.length()))
     158            continue;
     159        if (src[i + 3 + tag.length()] != '>')
     160            continue;
     161        break;
     162    }
     163
     164    *contents = QStringRef(&src, j, i - j);
     165
     166    i += tag.length() + 4;
     167
     168    *pos = i;
     169    if (debug)
     170        qDebug() << " tag " << tag << " found: pos now: " << i;
     171    return true;
     172#undef SKIP_CHAR
     173}
     174
    72175/*!
    73176  This function is recursive.
     
    78181}
    79182
    80 QString PageGenerator::fileBase(const Node *node)
     183QString PageGenerator::fileBase(const Node *node) const
    81184{
    82185    if (node->relates())
     
    105208          files.
    106209         */
    107         if (p->subType() == Node::QmlClass) {
    108             base.prepend("qml-");
     210        if ((p->subType() == Node::QmlClass) ||
     211            (p->subType() == Node::QmlBasicType)) {
     212            if (!base.startsWith(QLatin1String("QML:")))
     213                base.prepend("qml-");
    109214        }
    110215#endif       
     
    153258}
    154259
    155 QString PageGenerator::fileName(const Node *node)
     260QString PageGenerator::fileName(const Node *node) const
    156261{
    157262    if (!node->url().isEmpty())
     
    177282                        .arg(outFile->fileName()));
    178283    QTextStream *out = new QTextStream(outFile);
    179     out->setCodec("ISO-8859-1");
     284    out->setCodec(outputCodec);
    180285    outStreamStack.push(out);
    181286}
     
    196301  Recursive writing of html files from the root \a node.
    197302 */
    198 void PageGenerator::generateInnerNode(const InnerNode *node,
    199                                       CodeMarker *marker)
     303void
     304PageGenerator::generateInnerNode(const InnerNode* node, CodeMarker* marker)
    200305{
    201306    if (!node->url().isNull())
     
    206311        if (fakeNode->subType() == Node::ExternalPage)
    207312            return;
    208 #ifdef QDOC_QML           
     313        if (fakeNode->subType() == Node::Image)
     314            return;
    209315        if (fakeNode->subType() == Node::QmlPropertyGroup)
    210316            return;
    211 #endif           
     317        if (fakeNode->subType() == Node::Page) {
     318            if (node->count() > 0)
     319                qDebug("PAGE %s HAS CHILDREN", qPrintable(fakeNode->title()));
     320        }
    212321    }
    213322
Note: See TracChangeset for help on using the changeset viewer.