From c70a0e817aa771f8a6cf5d6e60ab40161382bdb3 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Fri, 15 Jul 2011 13:29:46 +0200 Subject: Phase 1 of QTBUG-20412, the XML manifest file --- doc/src/examples/addressbook.qdoc | 2 +- tools/qdoc3/codemarker.cpp | 2 +- tools/qdoc3/codeparser.cpp | 3 ++ tools/qdoc3/cppcodemarker.cpp | 2 + tools/qdoc3/cppcodeparser.cpp | 8 ++-- tools/qdoc3/doc.cpp | 4 +- tools/qdoc3/generator.h | 4 ++ tools/qdoc3/htmlgenerator.cpp | 96 +++++++++++++++++++++++++++++++++++---- tools/qdoc3/htmlgenerator.h | 1 + tools/qdoc3/node.cpp | 18 ++++++-- tools/qdoc3/node.h | 25 +++++++++- 11 files changed, 141 insertions(+), 24 deletions(-) diff --git a/doc/src/examples/addressbook.qdoc b/doc/src/examples/addressbook.qdoc index 114c22b..f19582d 100644 --- a/doc/src/examples/addressbook.qdoc +++ b/doc/src/examples/addressbook.qdoc @@ -29,7 +29,7 @@ \example itemviews/addressbook \title Address Book Example - The address book example shows how to use proxy models to display + \brief The address book example shows how to use proxy models to display different views onto data from a single model. \image addressbook-example.png Screenshot of the Address Book example diff --git a/tools/qdoc3/codemarker.cpp b/tools/qdoc3/codemarker.cpp index 614419e..705ef6c 100644 --- a/tools/qdoc3/codemarker.cpp +++ b/tools/qdoc3/codemarker.cpp @@ -76,7 +76,7 @@ CodeMarker::~CodeMarker() A code market performs no initialization by default. Marker-specific initialization is performed in subclasses. */ -void CodeMarker::initializeMarker(const Config &config) +void CodeMarker::initializeMarker(const Config& ) // config { } diff --git a/tools/qdoc3/codeparser.cpp b/tools/qdoc3/codeparser.cpp index c7a8912..9ab5f82 100644 --- a/tools/qdoc3/codeparser.cpp +++ b/tools/qdoc3/codeparser.cpp @@ -287,6 +287,9 @@ void CodeParser::processCommonMetaCommand(const Location &location, FakeNode *fake = static_cast(node); fake->setTitle(arg); nameToTitle.insert(fake->name(),arg); + if (fake->subType() == Node::Example) { + + } } else location.warning(tr("Ignored '\\%1'").arg(COMMAND_TITLE)); diff --git a/tools/qdoc3/cppcodemarker.cpp b/tools/qdoc3/cppcodemarker.cpp index 585d6ce..e439fff 100644 --- a/tools/qdoc3/cppcodemarker.cpp +++ b/tools/qdoc3/cppcodemarker.cpp @@ -878,6 +878,7 @@ static const char * const keywordTable[] = { "signals", "slots", "emit", 0 }; +#if 0 static QString untabified(const QString &in) { QString res; @@ -897,6 +898,7 @@ static QString untabified(const QString &in) return res; } +#endif /* @char diff --git a/tools/qdoc3/cppcodeparser.cpp b/tools/qdoc3/cppcodeparser.cpp index 6f5baa0..1536867 100644 --- a/tools/qdoc3/cppcodeparser.cpp +++ b/tools/qdoc3/cppcodeparser.cpp @@ -704,7 +704,7 @@ Node *CppCodeParser::processTopicCommand(const Doc& doc, if (command == COMMAND_CLASS) { if (paths.size() > 1) { if (!paths[1].endsWith(".h")) { - ClassNode*cnode = static_cast(node); + ClassNode* cnode = static_cast(node); cnode->setQmlElement(paths[1]); } } @@ -712,9 +712,9 @@ Node *CppCodeParser::processTopicCommand(const Doc& doc, return node; } else if (command == COMMAND_EXAMPLE) { - FakeNode *fake = new FakeNode(tre->root(), arg, Node::Example); - createExampleFileNodes(fake); - return fake; + ExampleNode* en = new ExampleNode(tre->root(), arg); + createExampleFileNodes(en); + return en; } else if (command == COMMAND_EXTERNALPAGE) { return new FakeNode(tre->root(), arg, Node::ExternalPage); diff --git a/tools/qdoc3/doc.cpp b/tools/qdoc3/doc.cpp index 479931d..f0c4264 100644 --- a/tools/qdoc3/doc.cpp +++ b/tools/qdoc3/doc.cpp @@ -62,7 +62,7 @@ QT_BEGIN_NAMESPACE Q_GLOBAL_STATIC(QSet, null_Set_QString) Q_GLOBAL_STATIC(QStringList, null_QStringList) Q_GLOBAL_STATIC(QList, null_QList_Text) -Q_GLOBAL_STATIC(QStringMap, null_QStringMap) +//Q_GLOBAL_STATIC(QStringMap, null_QStringMap) Q_GLOBAL_STATIC(QStringMultiMap, null_QStringMultiMap) struct Macro @@ -1861,7 +1861,7 @@ void DocParser::startSection(Doc::Sections unit, int cmd) } -void DocParser::endSection(int unit, int endCmd) +void DocParser::endSection(int , int) // (int unit, int endCmd) { leavePara(); append(Atom::SectionRight, QString::number(currentSection)); diff --git a/tools/qdoc3/generator.h b/tools/qdoc3/generator.h index e5e9747..d4fe76f 100644 --- a/tools/qdoc3/generator.h +++ b/tools/qdoc3/generator.h @@ -57,6 +57,10 @@ QT_BEGIN_NAMESPACE +typedef QMap NewSinceMaps; +typedef QMap ParentMaps; +typedef QMap NewClassMaps; + class ClassNode; class Config; class CodeMarker; diff --git a/tools/qdoc3/htmlgenerator.cpp b/tools/qdoc3/htmlgenerator.cpp index 52da178..a64518d 100644 --- a/tools/qdoc3/htmlgenerator.cpp +++ b/tools/qdoc3/htmlgenerator.cpp @@ -276,6 +276,7 @@ void HtmlGenerator::generateTree(const Tree *tree) generatePageIndex(outputDir() + "/" + fileBase + ".pageindex"); helpProjectWriter->generate(myTree); + generateManifestFile(); } void HtmlGenerator::startText(const Node * /* relative */, @@ -331,8 +332,10 @@ int HtmlGenerator::generateAtom(const Atom *atom, break; case Atom::BriefLeft: if (relative->type() == Node::Fake) { - skipAhead = skipAtoms(atom, Atom::BriefRight); - break; + if (relative->subType() != Node::Example) { + skipAhead = skipAtoms(atom, Atom::BriefRight); + break; + } } out() << "

"; @@ -765,6 +768,15 @@ int HtmlGenerator::generateAtom(const Atom *atom, out() << " alt=\"" << protectEnc(text) << "\""; out() << " />"; helpProjectWriter->addExtraFile(fileName); + if ((relative->type() == Node::Fake) && + (relative->subType() == Node::Example)) { + const ExampleNode* cen = static_cast(relative); + if (cen->imageFileName().isEmpty()) { + ExampleNode* en = const_cast(cen); + en->setImageFileName(fileName); + ExampleNode::exampleNodeMap.insert(en->title(),en); + } + } } if (atom->type() == Atom::Image) out() << "

"; @@ -1792,7 +1804,6 @@ void HtmlGenerator::generateTableOfContents(const Node *node, toc = node->doc().tableOfContents(); if (toc.isEmpty() && !sections && (node->subType() != Node::Module)) return; - bool debug = false; QStringList sectionNumber; int detailsBase = 0; @@ -3779,8 +3790,6 @@ void HtmlGenerator::endLink() inObsoleteLink = false; } -#ifdef QDOC_QML - /*! Generates the summary for the \a section. Only used for sections of QML element documentation. @@ -4266,7 +4275,6 @@ QString HtmlGenerator::fullDocumentLocation(const Node *node) return ""; } else if (node->type() == Node::Fake) { -#ifdef QDOC_QML if ((node->subType() == Node::QmlClass) || (node->subType() == Node::QmlBasicType)) { QString fb = node->fileBase(); @@ -4274,9 +4282,9 @@ QString HtmlGenerator::fullDocumentLocation(const Node *node) return fb + ".html"; else return Generator::outputPrefix(QLatin1String("QML")) + node->fileBase() + QLatin1String(".html"); - } else -#endif - parentName = node->fileBase() + ".html"; + } + else + parentName = node->fileBase() + ".html"; } else if (node->fileBase().isEmpty()) return ""; @@ -4387,6 +4395,74 @@ QString HtmlGenerator::fullDocumentLocation(const Node *node) return parentName.toLower() + anchorRef; } -#endif +void HtmlGenerator::generateManifestFile() +{ + if (ExampleNode::exampleNodeMap.isEmpty()) + return; + QString fileName = "examples-manifest.xml"; + QFile file(outputDir() + "/" + fileName); + if (!file.open(QFile::WriteOnly | QFile::Text)) + return ; + + QXmlStreamWriter writer(&file); + writer.setAutoFormatting(true); + writer.writeStartDocument(); + writer.writeStartElement("instructionals"); + writer.writeAttribute("module", project); + writer.writeStartElement("examples"); + + ExampleNodeMap::Iterator i = ExampleNode::exampleNodeMap.begin(); + while (i != ExampleNode::exampleNodeMap.end()) { + const ExampleNode* en = i.value(); + writer.writeStartElement("example"); + writer.writeAttribute("name", en->title()); + QString docUrl = projectUrl + "/" + en->fileBase() + ".html"; + writer.writeAttribute("docUrl", docUrl); + foreach (const Node* child, en->childNodes()) { + if (child->subType() == Node::File) { + QString file = child->name(); + if (file.endsWith(".pro")) + writer.writeAttribute("projectPath", "./" + file); + } + } + writer.writeAttribute("imageUrl", projectUrl + "/" + en->imageFileName()); + Text brief = en->doc().briefText(); + if (!brief.isEmpty()) { + writer.writeStartElement("description"); + writer.writeCharacters(brief.toString()); + writer.writeEndElement(); // description + } + QStringList tags = en->title().toLower().split(" "); + if (!tags.isEmpty()) { + writer.writeStartElement("tags"); + bool wrote_one = false; + for (int n=0; n0 && wrote_one) + writer.writeCharacters(","); + writer.writeCharacters(tag); + wrote_one = true; + } + writer.writeEndElement(); // tags + } + writer.writeEndElement(); // example + ++i; + } + + writer.writeEndElement(); // examples + writer.writeEndElement(); // instructionals + writer.writeEndDocument(); + file.close(); +} QT_END_NAMESPACE diff --git a/tools/qdoc3/htmlgenerator.h b/tools/qdoc3/htmlgenerator.h index 70ec0b7..153a9cf 100644 --- a/tools/qdoc3/htmlgenerator.h +++ b/tools/qdoc3/htmlgenerator.h @@ -93,6 +93,7 @@ class HtmlGenerator : public PageGenerator virtual void terminateGenerator(); virtual QString format(); virtual void generateTree(const Tree *tree); + void generateManifestFile(); QString protectEnc(const QString &string); static QString protect(const QString &string, const QString &encoding = "ISO-8859-1"); diff --git a/tools/qdoc3/node.cpp b/tools/qdoc3/node.cpp index 683c210..e14b08d 100644 --- a/tools/qdoc3/node.cpp +++ b/tools/qdoc3/node.cpp @@ -39,10 +39,6 @@ ** ****************************************************************************/ -/* - node.cpp -*/ - #include "node.h" #include "tree.h" #include "codemarker.h" @@ -51,6 +47,8 @@ QT_BEGIN_NAMESPACE +ExampleNodeMap ExampleNode::exampleNodeMap; + /*! \class Node \brief The Node class is a node in the Tree. @@ -1062,6 +1060,16 @@ QString FakeNode::subTitle() const } /*! + The constructor calls the FakeNode constructor with + \a parent, \a name, and Node::Example. + */ +ExampleNode::ExampleNode(InnerNode* parent, const QString& name) + : FakeNode(parent, name, Node::Example) +{ + // nothing +} + +/*! \class EnumNode */ @@ -1683,6 +1691,7 @@ bool QmlPropertyNode::fromTrool(Trool troolean, bool defaultValue) } } +#if 0 static QString valueType(const QString &n) { if (n == "QPoint") @@ -1713,6 +1722,7 @@ static QString valueType(const QString &n) return "QDeclarativeFontValueType"; return QString(); } +#endif /*! Returns true if a QML property or attached property is diff --git a/tools/qdoc3/node.h b/tools/qdoc3/node.h index e1e9440..2887923 100644 --- a/tools/qdoc3/node.h +++ b/tools/qdoc3/node.h @@ -58,7 +58,13 @@ QT_BEGIN_NAMESPACE +class Node; class InnerNode; +class ExampleNode; + +typedef QMap NodeMap; +typedef QMultiMap NodeMultiMap; +typedef QMap ExampleNodeMap; class Node { @@ -380,8 +386,10 @@ class FakeNode : public InnerNode virtual QString title() const; virtual QString fullTitle() const; virtual QString subTitle() const; + virtual QString imageFileName() const { return QString(); } const NodeList &groupMembers() const { return gr; } virtual QString nameForLists() const { return title(); } + virtual void setImageFileName(const QString& ) { } private: SubType sub; @@ -390,7 +398,21 @@ class FakeNode : public InnerNode NodeList gr; }; -#ifdef QDOC_QML +class ExampleNode : public FakeNode +{ + public: + ExampleNode(InnerNode* parent, const QString& name); + virtual ~ExampleNode() { } + virtual QString imageFileName() const { return imageFileName_; } + virtual void setImageFileName(const QString& ifn) { imageFileName_ = ifn; } + + public: + static ExampleNodeMap exampleNodeMap; + + private: + QString imageFileName_; +}; + class QmlClassNode : public FakeNode { public: @@ -482,7 +504,6 @@ class QmlPropertyNode : public LeafNode Trool wri; bool att; }; -#endif class EnumItem { -- cgit v0.12 From 54b7ff1f5aea6ea33dad98d7daf1a7bdc9da7eb7 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Thu, 21 Jul 2011 11:50:08 +0200 Subject: qdoc: Added HTML.nobreadcrumbs as a config variable. Task-numberr: QTBUG-20475 --- tools/qdoc3/htmlgenerator.cpp | 7 ++++++- tools/qdoc3/htmlgenerator.h | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/tools/qdoc3/htmlgenerator.cpp b/tools/qdoc3/htmlgenerator.cpp index a64518d..3263e9c 100644 --- a/tools/qdoc3/htmlgenerator.cpp +++ b/tools/qdoc3/htmlgenerator.cpp @@ -180,6 +180,9 @@ void HtmlGenerator::initializeGenerator(const Config &config) pleaseGenerateMacRef = config.getBool(HtmlGenerator::format() + Config::dot + HTMLGENERATOR_GENERATEMACREFS); + noBreadCrumbs = config.getBool(HtmlGenerator::format() + + Config::dot + + HTMLGENERATOR_NOBREADCRUMBS); project = config.getString(CONFIG_PROJECT); @@ -1516,8 +1519,10 @@ void HtmlGenerator::generateBreadCrumbs(const QString &title, const Node *node, CodeMarker *marker) { + if (noBreadCrumbs) + return; + Text breadcrumbs; - if (node->type() == Node::Class) { const ClassNode *cn = static_cast(node); QString name = node->moduleName(); diff --git a/tools/qdoc3/htmlgenerator.h b/tools/qdoc3/htmlgenerator.h index 153a9cf..d97d387 100644 --- a/tools/qdoc3/htmlgenerator.h +++ b/tools/qdoc3/htmlgenerator.h @@ -274,6 +274,7 @@ class HtmlGenerator : public PageGenerator QString footer; QString address; bool pleaseGenerateMacRef; + bool noBreadCrumbs; QString project; QString projectDescription; QString projectUrl; @@ -308,6 +309,7 @@ class HtmlGenerator : public PageGenerator #define HTMLGENERATOR_GENERATEMACREFS "generatemacrefs" // ### document me #define HTMLGENERATOR_POSTHEADER "postheader" #define HTMLGENERATOR_POSTPOSTHEADER "postpostheader" +#define HTMLGENERATOR_NOBREADCRUMBS "nobreadcrumbs" QT_END_NAMESPACE -- cgit v0.12 From b17ae5f8b26838288d7841b4b0651e435198396f Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Fri, 22 Jul 2011 13:33:48 +0200 Subject: qdoc: Fixed to remove extranious markup tags. Task-numberr: QTBUG-20474 --- tools/qdoc3/ditaxmlgenerator.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/qdoc3/ditaxmlgenerator.cpp b/tools/qdoc3/ditaxmlgenerator.cpp index b801e1e..6d74762 100644 --- a/tools/qdoc3/ditaxmlgenerator.cpp +++ b/tools/qdoc3/ditaxmlgenerator.cpp @@ -770,7 +770,7 @@ int DitaXmlGenerator::generateAtom(const Atom *atom, { writeStartTag(DT_codeblock); xmlWriter().writeAttribute("outputclass","cpp"); - QString chars = trimmedTrailing(atom->string()); + QString chars = trimmedTrailing(atom->string()); writeText(chars, marker, relative); writeEndTag(); // } @@ -3407,6 +3407,7 @@ void DitaXmlGenerator::writeText(const QString& markedCode, "<@type>", "<@type>", "<@headerfile>", "<@headerfile>", "<@func>", "<@func>", + "<@func ", "<@func ", "<@param>", "<@param>", "<@extra>", "<@extra>", "", "", @@ -3419,7 +3420,7 @@ void DitaXmlGenerator::writeText(const QString& markedCode, for (int i = 0, n = src.size(); i < n;) { if (src.at(i) == charLangle) { bool handled = false; - for (int k = 0; k != 12; ++k) { + for (int k = 0; k != 13; ++k) { const QString & tag = spanTags[2 * k]; if (tag == QStringRef(&src, i, tag.length())) { html += spanTags[2 * k + 1]; -- cgit v0.12 From 14a46c4e79dc07faf21f2c657cbdcf8f88607a92 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Tue, 2 Aug 2011 10:14:57 +0200 Subject: qdoc3: Write "Signal Handlers" instead of "Signals" as header Task-number: QTBUG-17072 --- tools/qdoc3/cppcodemarker.cpp | 20 ++++++++++---------- tools/qdoc3/ditaxmlgenerator.cpp | 2 +- tools/qdoc3/htmlgenerator.cpp | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/tools/qdoc3/cppcodemarker.cpp b/tools/qdoc3/cppcodemarker.cpp index e439fff..3e31cee 100644 --- a/tools/qdoc3/cppcodemarker.cpp +++ b/tools/qdoc3/cppcodemarker.cpp @@ -483,7 +483,7 @@ QList
CppCodeMarker::sections(const InnerNode *inner, "", "public function", "public functions"); - FastSection publicSignals(classe, "Signals", "", "signal", "signals"); + FastSection publicSignals(classe, "Signal Handlers", "", "signal handler", "signal handlers"); FastSection publicSlots(classe, "Public Slots", "", "public slot", "public slots"); FastSection publicTypes(classe, "Public Types", "", "public type", "public types"); FastSection publicVariables(classe, @@ -1159,15 +1159,15 @@ QList
CppCodeMarker::qmlSections(const QmlClassNode* qmlClassNode, "property", "properties"); FastSection qmlsignals(qmlClassNode, - "Signals", + "Signal Handlers", "", - "signal", - "signals"); + "signal handler", + "signal handlers"); FastSection qmlattachedsignals(qmlClassNode, - "Attached Signals", + "Attached Signal Handlers", "", - "signal", - "signals"); + "signal handler", + "signal handlers"); FastSection qmlmethods(qmlClassNode, "Methods", "", @@ -1222,9 +1222,9 @@ QList
CppCodeMarker::qmlSections(const QmlClassNode* qmlClassNode, FastSection qmlproperties(qmlClassNode, "Property Documentation","qmlprop","member","members"); FastSection qmlattachedproperties(qmlClassNode,"Attached Property Documentation","qmlattprop", "member","members"); - FastSection qmlsignals(qmlClassNode,"Signal Documentation","qmlsig","member","members"); - FastSection qmlattachedsignals(qmlClassNode,"Attached Signal Documentation","qmlattsig", - "member","members"); + FastSection qmlsignals(qmlClassNode,"Signal Handler Documentation","qmlsig","handler","handlers"); + FastSection qmlattachedsignals(qmlClassNode,"Attached Signal Handler Documentation","qmlattsig", + "handler","handlers"); FastSection qmlmethods(qmlClassNode,"Method Documentation","qmlmeth","member","members"); FastSection qmlattachedmethods(qmlClassNode,"Attached Method Documentation","qmlattmeth", "member","members"); diff --git a/tools/qdoc3/ditaxmlgenerator.cpp b/tools/qdoc3/ditaxmlgenerator.cpp index 6d74762..c05880f 100644 --- a/tools/qdoc3/ditaxmlgenerator.cpp +++ b/tools/qdoc3/ditaxmlgenerator.cpp @@ -76,7 +76,7 @@ QString DitaXmlGenerator::sinceTitles[] = " New Variables", " New QML Elements", " New Qml Properties", - " New Qml Signals", + " New Qml Signal Handlers", " New Qml Methods", "" }; diff --git a/tools/qdoc3/htmlgenerator.cpp b/tools/qdoc3/htmlgenerator.cpp index 3263e9c..bdb2e44 100644 --- a/tools/qdoc3/htmlgenerator.cpp +++ b/tools/qdoc3/htmlgenerator.cpp @@ -80,7 +80,7 @@ QString HtmlGenerator::sinceTitles[] = " New Variables", " New QML Elements", " New QML Properties", - " New QML Signals", + " New QML Signal Handlers", " New QML Methods", "" }; -- cgit v0.12 From eed8a63d17a7d324892f920b034db9e268f27685 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Tue, 2 Aug 2011 11:06:44 +0200 Subject: qdoc3: Reverting part of the change for QTBUG-17072 Task-number: QTBUG-17072 --- tools/qdoc3/cppcodemarker.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/qdoc3/cppcodemarker.cpp b/tools/qdoc3/cppcodemarker.cpp index 3e31cee..f3ec6fd 100644 --- a/tools/qdoc3/cppcodemarker.cpp +++ b/tools/qdoc3/cppcodemarker.cpp @@ -483,10 +483,10 @@ QList
CppCodeMarker::sections(const InnerNode *inner, "", "public function", "public functions"); - FastSection publicSignals(classe, "Signal Handlers", "", "signal handler", "signal handlers"); - FastSection publicSlots(classe, "Public Slots", "", "public slot", "public slots"); - FastSection publicTypes(classe, "Public Types", "", "public type", "public types"); - FastSection publicVariables(classe, + FastSection publicSignals(classe, "Signals", "", "signal", "signal"); + FastSection publicSlots(classe, "Public Slots", "", "public slot", "public slots"); + FastSection publicTypes(classe, "Public Types", "", "public type", "public types"); + FastSection publicVariables(classe, "Public Variables", "", "public variable", -- cgit v0.12 From 99048b2664bd5271810ed7cae1dc0fd44a14fdac Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Wed, 3 Aug 2011 13:21:07 +0200 Subject: qdoc: Check pointer for null before dereferencing. Task-number: QTBUG-20725 --- tools/qdoc3/ditaxmlgenerator.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/qdoc3/ditaxmlgenerator.cpp b/tools/qdoc3/ditaxmlgenerator.cpp index c05880f..43d92df 100644 --- a/tools/qdoc3/ditaxmlgenerator.cpp +++ b/tools/qdoc3/ditaxmlgenerator.cpp @@ -2117,9 +2117,10 @@ DitaXmlGenerator::generateClassLikeNode(const InnerNode* inner, CodeMarker* mark generateSince(qcn, marker); enterSection("h2","Detailed Description"); generateBody(qcn, marker); - if (cn) + if (cn) { generateQmlText(cn->doc().body(), cn, marker, qcn->name()); - generateAlsoList(cn, marker); + generateAlsoList(cn, marker); + } leaveSection(); leaveSection(); // -- cgit v0.12 From cc997e664ab6cd9e6551ec8228d1585d2a46a3d2 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Wed, 10 Aug 2011 12:28:04 +0200 Subject: qdoc3: Updates for QTBUG-20776 and QTBUG-20777 Task-number: QTBUG-20776, QTBUG-20777 --- tools/qdoc3/cppcodeparser.cpp | 5 +-- tools/qdoc3/htmlgenerator.cpp | 95 ++++++++++++++++++++++++++++++++++++------- tools/qdoc3/htmlgenerator.h | 4 +- 3 files changed, 86 insertions(+), 18 deletions(-) diff --git a/tools/qdoc3/cppcodeparser.cpp b/tools/qdoc3/cppcodeparser.cpp index 1536867..5efbcfd 100644 --- a/tools/qdoc3/cppcodeparser.cpp +++ b/tools/qdoc3/cppcodeparser.cpp @@ -47,7 +47,7 @@ #include #include - +#include #include "codechunk.h" #include "config.h" #include "cppcodeparser.h" @@ -2362,7 +2362,6 @@ void CppCodeParser::createExampleFileNodes(FakeNode *fake) QStringList exampleFiles = Config::getFilesHere(fullPath,exampleNameFilter); QString imagesPath = fullPath + "/images"; QStringList imageFiles = Config::getFilesHere(imagesPath,exampleImageFilter); - if (!exampleFiles.isEmpty()) { // move main.cpp and to the end, if it exists QString mainCpp; @@ -2382,7 +2381,7 @@ void CppCodeParser::createExampleFileNodes(FakeNode *fake) exampleFiles.append(mainCpp); // add any qmake Qt resource files and qmake project files - exampleFiles += Config::getFilesHere(fullPath, "*.qrc *.pro qmldir"); + exampleFiles += Config::getFilesHere(fullPath, "*.qrc *.pro *.qmlproject qmldir"); } foreach (const QString &exampleFile, exampleFiles) diff --git a/tools/qdoc3/htmlgenerator.cpp b/tools/qdoc3/htmlgenerator.cpp index bdb2e44..c7b6490 100644 --- a/tools/qdoc3/htmlgenerator.cpp +++ b/tools/qdoc3/htmlgenerator.cpp @@ -279,7 +279,7 @@ void HtmlGenerator::generateTree(const Tree *tree) generatePageIndex(outputDir() + "/" + fileBase + ".pageindex"); helpProjectWriter->generate(myTree); - generateManifestFile(); + generateManifestFiles(); } void HtmlGenerator::startText(const Node * /* relative */, @@ -4400,43 +4400,78 @@ QString HtmlGenerator::fullDocumentLocation(const Node *node) return parentName.toLower() + anchorRef; } -void HtmlGenerator::generateManifestFile() +/*! + This function outputs one or more manifest files in XML. + They are used by Creator. + */ +void HtmlGenerator::generateManifestFiles() +{ + generateManifestFile("examples", "example"); + generateManifestFile("demos", "demo"); +} + +/*! + This function is called by generaqteManiferstFile(), once + for each manifest file to be generated. \a manifest is the + type of manifest file. + */ +void HtmlGenerator::generateManifestFile(QString manifest, QString element) { if (ExampleNode::exampleNodeMap.isEmpty()) return; - QString fileName = "examples-manifest.xml"; + QString fileName = manifest +"-manifest.xml"; QFile file(outputDir() + "/" + fileName); if (!file.open(QFile::WriteOnly | QFile::Text)) return ; + bool demos = false; + if (manifest == "demos") + demos = true; QXmlStreamWriter writer(&file); writer.setAutoFormatting(true); writer.writeStartDocument(); writer.writeStartElement("instructionals"); writer.writeAttribute("module", project); - writer.writeStartElement("examples"); + writer.writeStartElement(manifest); ExampleNodeMap::Iterator i = ExampleNode::exampleNodeMap.begin(); while (i != ExampleNode::exampleNodeMap.end()) { const ExampleNode* en = i.value(); - writer.writeStartElement("example"); + if (demos) { + if (!en->name().startsWith("demos")) { + ++i; + continue; + } + } + else if (en->name().startsWith("demos")) { + ++i; + continue; + } + writer.writeStartElement(element); writer.writeAttribute("name", en->title()); - QString docUrl = projectUrl + "/" + en->fileBase() + ".html"; + //QString docUrl = projectUrl + "/" + en->fileBase() + ".html"; + QString docUrl = "%REPLACEME%/" + en->fileBase() + ".html"; writer.writeAttribute("docUrl", docUrl); foreach (const Node* child, en->childNodes()) { if (child->subType() == Node::File) { QString file = child->name(); - if (file.endsWith(".pro")) - writer.writeAttribute("projectPath", "./" + file); + if (file.endsWith(".pro") || file.endsWith(".qmlproject")) { + if (file.startsWith("demos/")) + file = file.mid(6); + writer.writeAttribute("projectPath", file); + break; + } } } - writer.writeAttribute("imageUrl", projectUrl + "/" + en->imageFileName()); + //writer.writeAttribute("imageUrl", projectUrl + "/" + en->imageFileName()); + writer.writeAttribute("imageUrl", "%REPLACEME%/" + en->imageFileName()); + writer.writeStartElement("description"); Text brief = en->doc().briefText(); - if (!brief.isEmpty()) { - writer.writeStartElement("description"); - writer.writeCharacters(brief.toString()); - writer.writeEndElement(); // description - } + if (!brief.isEmpty()) + writer.writeCDATA(brief.toString()); + else + writer.writeCDATA(QString("No description available")); + writer.writeEndElement(); // description QStringList tags = en->title().toLower().split(" "); if (!tags.isEmpty()) { writer.writeStartElement("tags"); @@ -4460,6 +4495,38 @@ void HtmlGenerator::generateManifestFile() } writer.writeEndElement(); // tags } + + QString ename = en->name().mid(en->name().lastIndexOf('/')+1); + QSet usedNames; + foreach (const Node* child, en->childNodes()) { + if (child->subType() == Node::File) { + QString file = child->name(); + QString fileName = file.mid(file.lastIndexOf('/')+1); + QString baseName = fileName; + if ((fileName.count(QChar('.')) > 0) && + (fileName.endsWith(".cpp") || + fileName.endsWith(".h") || + fileName.endsWith(".qml"))) + baseName.truncate(baseName.lastIndexOf(QChar('.'))); + if (baseName.toLower() == ename) { + if (!usedNames.contains(fileName)) { + writer.writeStartElement("fileToOpen"); + writer.writeCharacters(fileName); + writer.writeEndElement(); // fileToOpen + usedNames.insert(fileName); + } + } + else if (fileName.toLower().endsWith("main.cpp") || + fileName.toLower().endsWith("main.qml")) { + if (!usedNames.contains(fileName)) { + writer.writeStartElement("fileToOpen"); + writer.writeCharacters(fileName); + writer.writeEndElement(); // fileToOpen + usedNames.insert(fileName); + } + } + } + } writer.writeEndElement(); // example ++i; } diff --git a/tools/qdoc3/htmlgenerator.h b/tools/qdoc3/htmlgenerator.h index d97d387..70508a0 100644 --- a/tools/qdoc3/htmlgenerator.h +++ b/tools/qdoc3/htmlgenerator.h @@ -93,7 +93,7 @@ class HtmlGenerator : public PageGenerator virtual void terminateGenerator(); virtual QString format(); virtual void generateTree(const Tree *tree); - void generateManifestFile(); + void generateManifestFiles(); QString protectEnc(const QString &string); static QString protect(const QString &string, const QString &encoding = "ISO-8859-1"); @@ -113,6 +113,8 @@ class HtmlGenerator : public PageGenerator virtual QString linkForNode(const Node *node, const Node *relative); virtual QString refForAtom(Atom *atom, const Node *node); + void generateManifestFile(QString manifest, QString element); + private: enum SubTitleSize { SmallSubTitle, LargeSubTitle }; enum ExtractionMarkType { -- cgit v0.12 From a9b6b923ab870ece76891c5330fdba26ce1bf613 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Thu, 11 Aug 2011 11:42:27 +0200 Subject: qdoc3: Updates for QTBUG-20739 (no read-only for QML components) Task-number: QTBUG-20739 --- tools/qdoc3/ditaxmlgenerator.cpp | 3 ++- tools/qdoc3/htmlgenerator.cpp | 3 ++- tools/qdoc3/node.cpp | 32 ++++++++++++++++++++++++++++++++ tools/qdoc3/node.h | 4 ++++ 4 files changed, 40 insertions(+), 2 deletions(-) diff --git a/tools/qdoc3/ditaxmlgenerator.cpp b/tools/qdoc3/ditaxmlgenerator.cpp index 43d92df..4393e8d 100644 --- a/tools/qdoc3/ditaxmlgenerator.cpp +++ b/tools/qdoc3/ditaxmlgenerator.cpp @@ -4398,7 +4398,8 @@ void DitaXmlGenerator::generateDetailedQmlMember(const Node* node, writeStartTag(DT_li); writeGuidAttribute((Node*)qpn); QString attr; - if (!qpn->isWritable(myTree)) + const ClassNode* cn = qpn->declarativeCppNode(); + if (cn && !qpn->isWritable(myTree)) attr = "read-only"; if (qpgn->isDefault()) { if (!attr.isEmpty()) diff --git a/tools/qdoc3/htmlgenerator.cpp b/tools/qdoc3/htmlgenerator.cpp index c7b6490..c0a32d8 100644 --- a/tools/qdoc3/htmlgenerator.cpp +++ b/tools/qdoc3/htmlgenerator.cpp @@ -3851,7 +3851,8 @@ void HtmlGenerator::generateDetailedQmlMember(const Node *node, out() << ""; - if (!qpn->isWritable(myTree)) { + const ClassNode* cn = qpn->declarativeCppNode(); + if (cn && !qpn->isWritable(myTree)) { out() << "read-only"; } if (qpgn->isDefault()) diff --git a/tools/qdoc3/node.cpp b/tools/qdoc3/node.cpp index e14b08d..f6893fb 100644 --- a/tools/qdoc3/node.cpp +++ b/tools/qdoc3/node.cpp @@ -305,6 +305,38 @@ QString Node::ditaXmlHref() } /*! + If this node is a QML class node, return a pointer to it. + If it is a child of a QML class node, return a pointer to + the QML class node. Otherwise, return 0; + */ +const QmlClassNode* Node::qmlClassNode() const +{ + if (isQmlNode()) { + const Node* n = this; + while (n && n->subType() != Node::QmlClass) + n = n->parent(); + if (n && n->subType() == Node::QmlClass) + return static_cast(n); + } + return 0; +} + +/*! + If this node is a QML node, find its QML class node, + and return a pointer to the C++ class node from the + QML class node. That pointer will be null if the QML + class node is a component. It will be non-null if + the QML class node is a QML element. + */ +const ClassNode* Node::declarativeCppNode() const +{ + const QmlClassNode* qcn = qmlClassNode(); + if (qcn) + return qcn->classNode(); + return 0; +} + +/*! \class InnerNode */ diff --git a/tools/qdoc3/node.h b/tools/qdoc3/node.h index 2887923..3b031b6 100644 --- a/tools/qdoc3/node.h +++ b/tools/qdoc3/node.h @@ -59,8 +59,10 @@ QT_BEGIN_NAMESPACE class Node; +class ClassNode; class InnerNode; class ExampleNode; +class QmlClassNode; typedef QMap NodeMap; typedef QMultiMap NodeMultiMap; @@ -200,6 +202,8 @@ class Node QString guid() const; QString ditaXmlHref(); QString extractClassName(const QString &string) const; + const QmlClassNode* qmlClassNode() const; + const ClassNode* declarativeCppNode() const; protected: Node(Type type, InnerNode* parent, const QString& name); -- cgit v0.12 From 7ca3a7e431e53250446c1b3f95db344e6b183f89 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Thu, 18 Aug 2011 13:33:03 +0200 Subject: qdoc3: Updates for QTBUG-20776; clear map between runs. Task-number: QTBUG-20776 --- tools/qdoc3/htmlgenerator.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/tools/qdoc3/htmlgenerator.cpp b/tools/qdoc3/htmlgenerator.cpp index c0a32d8..9846eb9 100644 --- a/tools/qdoc3/htmlgenerator.cpp +++ b/tools/qdoc3/htmlgenerator.cpp @@ -4409,6 +4409,7 @@ void HtmlGenerator::generateManifestFiles() { generateManifestFile("examples", "example"); generateManifestFile("demos", "demo"); + ExampleNode::exampleNodeMap.clear(); } /*! @@ -4428,6 +4429,25 @@ void HtmlGenerator::generateManifestFile(QString manifest, QString element) if (manifest == "demos") demos = true; + bool proceed = false; + ExampleNodeMap::Iterator i = ExampleNode::exampleNodeMap.begin(); + while (i != ExampleNode::exampleNodeMap.end()) { + const ExampleNode* en = i.value(); + if (demos) { + if (en->name().startsWith("demos")) { + proceed = true; + break; + } + } + else if (!en->name().startsWith("demos")) { + proceed = true; + break; + } + ++i; + } + if (!proceed) + return; + QXmlStreamWriter writer(&file); writer.setAutoFormatting(true); writer.writeStartDocument(); @@ -4435,7 +4455,7 @@ void HtmlGenerator::generateManifestFile(QString manifest, QString element) writer.writeAttribute("module", project); writer.writeStartElement(manifest); - ExampleNodeMap::Iterator i = ExampleNode::exampleNodeMap.begin(); + i = ExampleNode::exampleNodeMap.begin(); while (i != ExampleNode::exampleNodeMap.end()) { const ExampleNode* en = i.value(); if (demos) { -- cgit v0.12 From bb4eea4f9d7dc66c87374dea3cdd5fcfd1b68bad Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Thu, 18 Aug 2011 15:18:38 +0200 Subject: qdoc3: Updates for QTBUG-20776; include fileToOpen path. Task-number: QTBUG-20776 --- tools/qdoc3/htmlgenerator.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tools/qdoc3/htmlgenerator.cpp b/tools/qdoc3/htmlgenerator.cpp index 9846eb9..e79e180 100644 --- a/tools/qdoc3/htmlgenerator.cpp +++ b/tools/qdoc3/htmlgenerator.cpp @@ -4532,7 +4532,9 @@ void HtmlGenerator::generateManifestFile(QString manifest, QString element) if (baseName.toLower() == ename) { if (!usedNames.contains(fileName)) { writer.writeStartElement("fileToOpen"); - writer.writeCharacters(fileName); + if (file.startsWith("demos/")) + file = file.mid(6); + writer.writeCharacters(file); writer.writeEndElement(); // fileToOpen usedNames.insert(fileName); } @@ -4541,7 +4543,9 @@ void HtmlGenerator::generateManifestFile(QString manifest, QString element) fileName.toLower().endsWith("main.qml")) { if (!usedNames.contains(fileName)) { writer.writeStartElement("fileToOpen"); - writer.writeCharacters(fileName); + if (file.startsWith("demos/")) + file = file.mid(6); + writer.writeCharacters(file); writer.writeEndElement(); // fileToOpen usedNames.insert(fileName); } -- cgit v0.12 From 656d914c4d777d47ac7dfbb76e0fc8a145e6e25c Mon Sep 17 00:00:00 2001 From: Geir Vattekar Date: Wed, 24 Aug 2011 12:58:20 +0200 Subject: Doc: Internalized QDeclarativeTypeLoader Task-number: QTBUG-21029 --- src/declarative/qml/qdeclarativetypeloader.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/declarative/qml/qdeclarativetypeloader.cpp b/src/declarative/qml/qdeclarativetypeloader.cpp index 168c151..82197dc 100644 --- a/src/declarative/qml/qdeclarativetypeloader.cpp +++ b/src/declarative/qml/qdeclarativetypeloader.cpp @@ -65,6 +65,11 @@ The QDeclarativeDataLoader invokes callbacks on the QDeclarativeDataBlob as data */ /*! + \class QDeclarativeTypeLoader + \internal +*/ + +/*! \enum QDeclarativeDataBlob::Status This enum describes the status of the data blob. -- cgit v0.12 From 0847f34c977635d7d39f6947ad910d2abb0bd0ce Mon Sep 17 00:00:00 2001 From: Geir Vattekar Date: Wed, 24 Aug 2011 14:50:12 +0200 Subject: Doc: Small addition to the QML anchor layout docs Task-number: QTBUG-15514 Reviewed-by: David Boddie --- doc/src/declarative/anchor-layout.qdoc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/doc/src/declarative/anchor-layout.qdoc b/doc/src/declarative/anchor-layout.qdoc index 41b04e8..e93e539 100644 --- a/doc/src/declarative/anchor-layout.qdoc +++ b/doc/src/declarative/anchor-layout.qdoc @@ -53,7 +53,12 @@ Rectangle { id: rect1; ... } Rectangle { id: rect2; anchors.left: rect1.right; ... } \endcode -In this case, the left edge of \e rect2 is bound to the right edge of \e rect1, producing the following: +Each Item has two properties for each anchor line: one to bind from and one to bind to. The properties to bind +from are contained in the \l{Item::}{anchors} attached property (seen as \c {anchors.left} above). +The properties to bind to are normal properties (seen as \c {rect1.right} above). +This way, each item can have several bindings to the same anchor line. Note that the properties to bind to are +not visible in the documentation for Item. +So in the example above, the left edge of \e rect2 is bound to the right edge of \e rect1, producing the following: \image edge1.png -- cgit v0.12 From b5379556beacdde7db9af561a294e8c8276e73e0 Mon Sep 17 00:00:00 2001 From: Geir Vattekar Date: Wed, 24 Aug 2011 14:59:41 +0200 Subject: Doc: Added info on ordered targets for VS to qmake manual Task-number: QTBUG-11988 Reviewed-by: David Boddie --- doc/src/development/qmake-manual.qdoc | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/doc/src/development/qmake-manual.qdoc b/doc/src/development/qmake-manual.qdoc index 184a881..3e52c03 100644 --- a/doc/src/development/qmake-manual.qdoc +++ b/doc/src/development/qmake-manual.qdoc @@ -3234,6 +3234,29 @@ \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 150 + \section2 Ordered Targets and Visual Studio Solution Files + + The \c ordered option is not supported for Visual Studio. The following list describes how + you can get around without it--dependencies are generated automatically if: + + \list + \o 1a) There is a Lib/DLL project of which TARGET (the .lib is used and not the .dll) + is used on the link line of another project in your solution (you can modify the link + line with LIBS). + + \o 1b) There is an Exe project of which TARGET is used in a custom + build-step of another project in your solution. + + \o 2) You don't use paths in the TARGET variable (use DESTDIR/DLLDESTDIR for that), + e.g, TARGET=$(SOME_VARIABLE)/myLib, won't work. + + \o 3) If you have a special location for your libs, you specify the -Lmy/library/path and + LIBS += mylib, instead of just using LIBS += my/library/path/mylib + + \o 4) The leaf projects are created before you generate the solution file. (You can use the + recursive flag for qmake to do this, like "qmake -tp vc -r [yourproject.pro]" + \endlist + \target SYMBIAN_VERSION \section1 SYMBIAN_VERSION -- cgit v0.12 From 9038a4ce14c58aebb04c38b3b8229d3be2021c81 Mon Sep 17 00:00:00 2001 From: Geir Vattekar Date: Wed, 24 Aug 2011 15:29:37 +0200 Subject: Doc: Added a link in Symbian Intro to Required Capabilities Task-number: QTBUG-8942 --- doc/src/platforms/symbian-introduction.qdoc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/src/platforms/symbian-introduction.qdoc b/doc/src/platforms/symbian-introduction.qdoc index d5d76bc..d9b60f6 100644 --- a/doc/src/platforms/symbian-introduction.qdoc +++ b/doc/src/platforms/symbian-introduction.qdoc @@ -74,6 +74,8 @@ Platform security capabilities are added via the \l{qmake-variable-reference.html#target-capability}{TARGET.CAPABILITY} qmake variable. + + \sa {platform-notes-symbian.html#required-capabilities}{Required Capabilities} */ /*! -- cgit v0.12 From 678a8a137b334e86a30ea3f8ed2334dbb4f92631 Mon Sep 17 00:00:00 2001 From: Geir Vattekar Date: Thu, 25 Aug 2011 15:18:57 +0200 Subject: Doc: QItemDelegate->QStyledItemDelegate in Star Delegate docs Task-number: QTBUG-9440 --- doc/src/examples/stardelegate.qdoc | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/doc/src/examples/stardelegate.qdoc b/doc/src/examples/stardelegate.qdoc index 3b009d5..ed3ae7e 100644 --- a/doc/src/examples/stardelegate.qdoc +++ b/doc/src/examples/stardelegate.qdoc @@ -42,12 +42,12 @@ editing takes place. Delegates are subclasses of QAbstractItemDelegate. Qt provides - QItemDelegate, which inherits QAbstractItemDelegate and handles - the most common data types (notably \c int and QString). If we - need to support custom data types, or want to customize the + QStyledItemDelegate, which inherits QAbstractItemDelegate and + handles the most common data types (notably \c int and QString). + If we need to support custom data types, or want to customize the rendering or the editing for existing data types, we can subclass - QAbstractItemDelegate or QItemDelegate. See \l{Delegate Classes} - for more information about delegates, and \l{Model/View + QAbstractItemDelegate or QStyledItemDelegate. See \l{Delegate + Classes} for more information about delegates, and \l{Model/View Programming} if you need a high-level introduction to Qt's model/view architecture (including delegates). @@ -62,9 +62,9 @@ expressed as stars, such as "2 out of 5 stars" or "5 out of 6 stars". - \o \c StarDelegate inherits QItemDelegate and provides support + \o \c StarDelegate inherits QStyledItemDelegate and provides support for \c StarRating (in addition to the data types already - handled by QItemDelegate). + handled by QStyledItemDelegate). \o \c StarEditor inherits QWidget and is used by \c StarDelegate to let the user edit a star rating using the mouse. @@ -80,20 +80,20 @@ \snippet examples/itemviews/stardelegate/stardelegate.h 0 All public functions are reimplemented virtual functions from - QItemDelegate to provide custom rendering and editing. + QStyledItemDelegate to provide custom rendering and editing. \section1 StarDelegate Class Implementation - The \l{QAbstractItemDelegate::}{paint()} function is - reimplemented from QItemDelegate and is called whenever the view - needs to repaint an item: + The \l{QAbstractItemDelegate::}{paint()} function is reimplemented + from QStyledItemDelegate and is called whenever the view needs to + repaint an item: \snippet examples/itemviews/stardelegate/stardelegate.cpp 0 The function is invoked once for each item, represented by a QModelIndex object from the model. If the data stored in the item is a \c StarRating, we paint it ourselves; otherwise, we let - QItemDelegate paint it for us. This ensures that the \c + QStyledItemDelegate paint it for us. This ensures that the \c StarDelegate can handle the most common data types. In the case where the item is a \c StarRating, we draw the -- cgit v0.12 From 516ffeecded9ed20ef309143b5f15bcce4abbe60 Mon Sep 17 00:00:00 2001 From: Geir Vattekar Date: Thu, 25 Aug 2011 15:28:43 +0200 Subject: Doc: Added a note to Code Editor example docs Task-number: QTBUG-9004 Reviewed-by: David Boddie --- doc/src/examples/codeeditor.qdoc | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/doc/src/examples/codeeditor.qdoc b/doc/src/examples/codeeditor.qdoc index 435f650..1718d52 100644 --- a/doc/src/examples/codeeditor.qdoc +++ b/doc/src/examples/codeeditor.qdoc @@ -194,4 +194,30 @@ with QSyntaxHighlighter" article in Qt Quarterly 31 implements this. You find it here: \l{http://doc.qt.nokia.com/qq/}. + The line number area is now painted every time the cursor blinks + (because we connect \l{QPlainTextEdit::}{updateRequest()} to + \c updateLineNumberArea()). We can avoid this by introducing a new + member variable to CodeEditor that keeps track of when the update + request comes from a cursor blink (in which case we do not + repaint). The code below requires the \c m_countCache variable, + which is a QPair initialized with \c -1 for both + \l{QPair::}{first} and \l{QPair::}{second}. + + \code + void CodeEditor::updateLineNumberArea(const QRect &rect, int dy) + { + if (dy) { + lineNumberArea->scroll(0, dy); + } else if (m_countCache.first != blockCount() + || m_countCache.second != textCursor().block().lineCount()) { + lineNumberArea->update(0, rect.y(), lineNumberArea->width(), rect.height()); + m_countCache.first = blockCount(); + m_countCache.second = textCursor().block().lineCount(); + } + + if (rect.contains(viewport()->rect())) + updateLineNumberAreaWidth(0); + } + \endcode */ + -- cgit v0.12