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>
This commit is contained in:
Casper van Donderen 2012-08-30 13:16:27 +02:00 committed by Qt by Nokia
parent 60783291ff
commit 0f409aca96
3 changed files with 18 additions and 1 deletions

View File

@ -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();
}

View File

@ -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);

View File

@ -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