diff options
author | Casper van Donderen <casper.vandonderen@nokia.com> | 2012-08-30 13:16:27 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-08-31 21:23:38 +0200 |
commit | 0f409aca96a6b51271cf86edef948a7981195cf4 (patch) | |
tree | 8852590fc9af98b52046f72d833767685c622243 /src/tools | |
parent | 60783291ff967b1441518e749d2dcf4e7bc4b831 (diff) |
QDoc: Write SHA1 of .qhp to file.
QDoc should generate a SHA1 hash of the .qhp file to be able to use that
file as a search index. The idea is that we can use the hash as an
identifier to check if the search index was updated.
Change-Id: Ifd19571bcebf7d735ef452dca6c046a14fedc0e2
Reviewed-by: Martin Smith <martin.smith@nokia.com>
Diffstat (limited to 'src/tools')
-rw-r--r-- | src/tools/qdoc/helpprojectwriter.cpp | 17 | ||||
-rw-r--r-- | src/tools/qdoc/helpprojectwriter.h | 1 | ||||
-rw-r--r-- | src/tools/qdoc/qdoc.pro | 1 |
3 files changed, 18 insertions, 1 deletions
diff --git a/src/tools/qdoc/helpprojectwriter.cpp b/src/tools/qdoc/helpprojectwriter.cpp index e71ce5946b..98ebcd81c2 100644 --- a/src/tools/qdoc/helpprojectwriter.cpp +++ b/src/tools/qdoc/helpprojectwriter.cpp @@ -39,6 +39,8 @@ ** ****************************************************************************/ +#include <QCryptographicHash> +#include <QDebug> #include <QHash> #include <QMap> @@ -48,7 +50,6 @@ #include "config.h" #include "node.h" #include "tree.h" -#include <qdebug.h> QT_BEGIN_NAMESPACE @@ -461,6 +462,19 @@ void HelpProjectWriter::generate(const Tree *t) generateProject(projects[i]); } +void HelpProjectWriter::writeHashFile(QFile &file) +{ + QCryptographicHash hash(QCryptographicHash::Sha1); + hash.addData(&file); + + QFile hashFile(file.fileName() + ".sha1"); + if (!hashFile.open(QFile::WriteOnly | QFile::Text)) + return; + + hashFile.write(hash.result().toHex()); + hashFile.close(); +} + void HelpProjectWriter::writeNode(HelpProject &project, QXmlStreamWriter &writer, const Node *node) { @@ -751,6 +765,7 @@ void HelpProjectWriter::generateProject(HelpProject &project) writer.writeEndElement(); // filterSection writer.writeEndElement(); // QtHelpProject writer.writeEndDocument(); + writeHashFile(file); file.close(); } diff --git a/src/tools/qdoc/helpprojectwriter.h b/src/tools/qdoc/helpprojectwriter.h index ac813525e0..a628dbc016 100644 --- a/src/tools/qdoc/helpprojectwriter.h +++ b/src/tools/qdoc/helpprojectwriter.h @@ -101,6 +101,7 @@ private: bool generateSection(HelpProject &project, QXmlStreamWriter &writer, const Node *node); QStringList keywordDetails(const Node *node) const; + void writeHashFile(QFile &file); void writeNode(HelpProject &project, QXmlStreamWriter &writer, const Node *node); void readSelectors(SubProject &subproject, const QStringList &selectors); diff --git a/src/tools/qdoc/qdoc.pro b/src/tools/qdoc/qdoc.pro index abd256c60d..e05d9ea2af 100644 --- a/src/tools/qdoc/qdoc.pro +++ b/src/tools/qdoc/qdoc.pro @@ -73,6 +73,7 @@ SOURCES += atom.cpp \ tokenizer.cpp \ tree.cpp \ yyindent.cpp \ + ../../corelib/tools/qcryptographichash.cpp \ ../../xml/dom/qdom.cpp \ ../../xml/sax/qxml.cpp |