summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/assistant/assistant/helpenginewrapper.cpp1
-rw-r--r--src/assistant/assistant/main.cpp1
-rw-r--r--src/assistant/help/qhelpcollectionhandler_p.h2
-rw-r--r--src/assistant/help/qhelpcontentwidget.cpp1
-rw-r--r--src/assistant/help/qhelpengine_p.h1
-rw-r--r--src/assistant/help/qhelpenginecore.cpp39
-rw-r--r--src/assistant/help/qhelpenginecore.h4
-rw-r--r--src/assistant/help/qhelpindexwidget.cpp1
-rw-r--r--src/assistant/qhelpgenerator/main.cpp1
-rw-r--r--tests/auto/qhelpcontentmodel/tst_qhelpcontentmodel.cpp2
-rw-r--r--tests/auto/qhelpenginecore/tst_qhelpenginecore.cpp5
-rw-r--r--tests/auto/qhelpindexmodel/tst_qhelpindexmodel.cpp2
12 files changed, 55 insertions, 5 deletions
diff --git a/src/assistant/assistant/helpenginewrapper.cpp b/src/assistant/assistant/helpenginewrapper.cpp
index c927a2ef1..78bca7240 100644
--- a/src/assistant/assistant/helpenginewrapper.cpp
+++ b/src/assistant/assistant/helpenginewrapper.cpp
@@ -699,6 +699,7 @@ HelpEngineWrapperPrivate::HelpEngineWrapperPrivate(const QString &collectionFile
{
TRACE_OBJ
initFileSystemWatchers();
+ m_helpEngine->setReadOnly(false);
m_helpEngine->setUsesFilterEngine(true);
}
diff --git a/src/assistant/assistant/main.cpp b/src/assistant/assistant/main.cpp
index b89828ec3..7ace7b02a 100644
--- a/src/assistant/assistant/main.cpp
+++ b/src/assistant/assistant/main.cpp
@@ -274,7 +274,6 @@ static ExitStatus preliminarySetup(CmdLineParser *cmd)
QScopedPointer<QHelpEngineCore> collection;
if (collectionFileGiven) {
collection.reset(new QHelpEngineCore(collectionFile));
- collection->setProperty("_q_readonly", QVariant::fromValue<bool>(true));
if (!collection->setupData()) {
cmd->showMessage(QCoreApplication::translate("Assistant",
"Error reading collection file '%1': %2.")
diff --git a/src/assistant/help/qhelpcollectionhandler_p.h b/src/assistant/help/qhelpcollectionhandler_p.h
index 9a8cb1e9c..fb26aabb5 100644
--- a/src/assistant/help/qhelpcollectionhandler_p.h
+++ b/src/assistant/help/qhelpcollectionhandler_p.h
@@ -257,7 +257,7 @@ private:
QString m_connectionName;
QSqlQuery *m_query = nullptr;
bool m_vacuumScheduled = false;
- bool m_readOnly = false;
+ bool m_readOnly = true;
};
QT_END_NAMESPACE
diff --git a/src/assistant/help/qhelpcontentwidget.cpp b/src/assistant/help/qhelpcontentwidget.cpp
index 47f96732e..f0702602e 100644
--- a/src/assistant/help/qhelpcontentwidget.cpp
+++ b/src/assistant/help/qhelpcontentwidget.cpp
@@ -276,7 +276,6 @@ void QHelpContentProvider::run()
return;
QHelpCollectionHandler collectionHandler(collectionFile);
- collectionHandler.setReadOnly(true);
if (!collectionHandler.openCollectionFile())
return;
diff --git a/src/assistant/help/qhelpengine_p.h b/src/assistant/help/qhelpengine_p.h
index 4d2773b83..76bdbb421 100644
--- a/src/assistant/help/qhelpengine_p.h
+++ b/src/assistant/help/qhelpengine_p.h
@@ -89,6 +89,7 @@ public:
bool needsSetup = true;
bool autoSaveFilter = true;
bool usesFilterEngine = false;
+ bool readOnly = true;
protected:
QHelpEngineCore *q;
diff --git a/src/assistant/help/qhelpenginecore.cpp b/src/assistant/help/qhelpenginecore.cpp
index 56137d124..f9a3b7f53 100644
--- a/src/assistant/help/qhelpenginecore.cpp
+++ b/src/assistant/help/qhelpenginecore.cpp
@@ -81,7 +81,7 @@ bool QHelpEngineCorePrivate::setup()
const QVariant readOnlyVariant = q->property("_q_readonly");
const bool readOnly = readOnlyVariant.isValid()
- ? readOnlyVariant.toBool() : false;
+ ? readOnlyVariant.toBool() : q->isReadOnly();
collectionHandler->setReadOnly(readOnly);
const bool opened = collectionHandler->openCollectionFile();
if (opened)
@@ -125,6 +125,18 @@ void QHelpEngineCorePrivate::errorReceived(const QString &msg)
deprecated since Qt 5.13. Call setUsesFilterEngine() with \c true to
enable the new functionality.
+ The core help engine has two modes:
+ \list
+ \li Read-only mode, where the help collection file is not changed
+ unless explicitly requested. This also works if the
+ collection file is in a read-only location,
+ and is the default.
+ \li Fully writable mode, which requires the help collection
+ file to be writable.
+ \endlist
+ The mode can be changed by calling setReadOnly() method, prior to
+ calling setupData().
+
The help engine also offers the possibility to set and read values
in a persistent way comparable to ini files or Windows registry
entries. For more information see setValue() or value().
@@ -235,6 +247,31 @@ void QHelpEngineCore::setCollectionFile(const QString &fileName)
}
/*!
+ \property QHelpEngineCore::readOnly
+ \brief whether the help engine is read-only.
+ \since 6.0
+
+ In read-only mode, the user can use the help engine
+ with a collection file installed in a read-only location.
+ In this case, some functionality won't be accessible,
+ like registering additional documentation, filter editing,
+ or any action that would require changes to the
+ collection file. Setting it to \c false enables the full
+ functionality of the help engine.
+
+ By default, this property is \c true.
+*/
+bool QHelpEngineCore::isReadOnly() const
+{
+ return d->readOnly;
+}
+
+void QHelpEngineCore::setReadOnly(bool enable)
+{
+ d->readOnly = enable;
+}
+
+/*!
\since 5.13
Returns the filter engine associated with this help engine.
diff --git a/src/assistant/help/qhelpenginecore.h b/src/assistant/help/qhelpenginecore.h
index df95c512f..dc4cd7695 100644
--- a/src/assistant/help/qhelpenginecore.h
+++ b/src/assistant/help/qhelpenginecore.h
@@ -58,6 +58,7 @@ class QHELP_EXPORT QHelpEngineCore : public QObject
Q_OBJECT
Q_PROPERTY(bool autoSaveFilter READ autoSaveFilter WRITE setAutoSaveFilter)
Q_PROPERTY(QString collectionFile READ collectionFile WRITE setCollectionFile)
+ Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly)
#if QT_DEPRECATED_SINCE(5, 15)
Q_PROPERTY(QString currentFilter READ currentFilter WRITE setCurrentFilter)
#endif
@@ -66,6 +67,9 @@ public:
explicit QHelpEngineCore(const QString &collectionFile, QObject *parent = nullptr);
virtual ~QHelpEngineCore();
+ bool isReadOnly() const;
+ void setReadOnly(bool enable);
+
QHelpFilterEngine *filterEngine() const;
bool setupData();
diff --git a/src/assistant/help/qhelpindexwidget.cpp b/src/assistant/help/qhelpindexwidget.cpp
index 0e2287e56..acda393fb 100644
--- a/src/assistant/help/qhelpindexwidget.cpp
+++ b/src/assistant/help/qhelpindexwidget.cpp
@@ -135,7 +135,6 @@ void QHelpIndexProvider::run()
return;
QHelpCollectionHandler collectionHandler(collectionFile);
- collectionHandler.setReadOnly(true);
if (!collectionHandler.openCollectionFile())
return;
diff --git a/src/assistant/qhelpgenerator/main.cpp b/src/assistant/qhelpgenerator/main.cpp
index 3ec20da6f..c4fae724c 100644
--- a/src/assistant/qhelpgenerator/main.cpp
+++ b/src/assistant/qhelpgenerator/main.cpp
@@ -102,6 +102,7 @@ int generateCollectionFile(const QByteArray &data, const QString &basePath, cons
}
QHelpEngineCore helpEngine(outputFile);
+ helpEngine.setReadOnly(false);
if (!helpEngine.setupData()) {
fprintf(stderr, "%s\n", qPrintable(helpEngine.error()));
return 1;
diff --git a/tests/auto/qhelpcontentmodel/tst_qhelpcontentmodel.cpp b/tests/auto/qhelpcontentmodel/tst_qhelpcontentmodel.cpp
index 039ea2f9a..5480168d3 100644
--- a/tests/auto/qhelpcontentmodel/tst_qhelpcontentmodel.cpp
+++ b/tests/auto/qhelpcontentmodel/tst_qhelpcontentmodel.cpp
@@ -98,6 +98,7 @@ void tst_QHelpContentModel::init()
void tst_QHelpContentModel::setupContents()
{
QHelpEngine h(m_colFile, 0);
+ h.setReadOnly(false);
QHelpContentModel *m = h.contentModel();
SignalWaiter w;
connect(m, SIGNAL(contentsCreated()),
@@ -123,6 +124,7 @@ void tst_QHelpContentModel::setupContents()
void tst_QHelpContentModel::contentItemAt()
{
QHelpEngine h(m_colFile, 0);
+ h.setReadOnly(false);
QHelpContentModel *m = h.contentModel();
SignalWaiter w;
connect(m, SIGNAL(contentsCreated()),
diff --git a/tests/auto/qhelpenginecore/tst_qhelpenginecore.cpp b/tests/auto/qhelpenginecore/tst_qhelpenginecore.cpp
index 773a2bcfb..3ca299b26 100644
--- a/tests/auto/qhelpenginecore/tst_qhelpenginecore.cpp
+++ b/tests/auto/qhelpenginecore/tst_qhelpenginecore.cpp
@@ -204,6 +204,7 @@ void tst_QHelpEngineCore::registerDocumentation()
QDir::current().remove(m_colFile);
{
QHelpEngineCore c(m_colFile);
+ c.setReadOnly(false);
QCOMPARE(c.setupData(), true);
c.registerDocumentation(m_path + "/data/qmake-3.3.8.qch");
QCOMPARE(c.registeredDocumentations().count(), 1);
@@ -235,6 +236,7 @@ void tst_QHelpEngineCore::registerDocumentation()
void tst_QHelpEngineCore::unregisterDocumentation()
{
QHelpEngineCore c(m_colFile);
+ c.setReadOnly(false);
QCOMPARE(c.setupData(), true);
QCOMPARE(c.registeredDocumentations().count(), 3);
c.unregisterDocumentation("trolltech.com.3-3-8.qmake");
@@ -322,6 +324,7 @@ void tst_QHelpEngineCore::setCurrentFilter()
void tst_QHelpEngineCore::filterAttributeSets()
{
QHelpEngineCore help(m_colFile, 0);
+ help.setReadOnly(false);
QCOMPARE(help.setupData(), true);
QList<QStringList> lst = help.filterAttributeSets("trolltech.com.1.0.0.test");
QCOMPARE(lst.count(), 2);
@@ -333,6 +336,7 @@ void tst_QHelpEngineCore::filterAttributeSets()
void tst_QHelpEngineCore::files()
{
QHelpEngineCore help(m_colFile, 0);
+ help.setReadOnly(false);
QCOMPARE(help.setupData(), true);
QList<QUrl> lst = help.files("trolltech.com.4-3-0.qmake",
QStringList());
@@ -363,6 +367,7 @@ void tst_QHelpEngineCore::files()
void tst_QHelpEngineCore::fileData()
{
QHelpEngineCore help(m_colFile, 0);
+ help.setReadOnly(false);
QCOMPARE(help.setupData(), true);
QByteArray ba = help.fileData(QUrl("NotExisting"));
QCOMPARE(ba.size(), 0);
diff --git a/tests/auto/qhelpindexmodel/tst_qhelpindexmodel.cpp b/tests/auto/qhelpindexmodel/tst_qhelpindexmodel.cpp
index 358be9956..ce8889efe 100644
--- a/tests/auto/qhelpindexmodel/tst_qhelpindexmodel.cpp
+++ b/tests/auto/qhelpindexmodel/tst_qhelpindexmodel.cpp
@@ -97,6 +97,7 @@ void tst_QHelpIndexModel::init()
void tst_QHelpIndexModel::setupIndex()
{
QHelpEngine h(m_colFile, 0);
+ h.setReadOnly(false);
QHelpIndexModel *m = h.indexModel();
SignalWaiter w;
connect(m, SIGNAL(indexCreated()),
@@ -128,6 +129,7 @@ void tst_QHelpIndexModel::setupIndex()
void tst_QHelpIndexModel::filter()
{
QHelpEngine h(m_colFile, 0);
+ h.setReadOnly(false);
QHelpIndexModel *m = h.indexModel();
SignalWaiter w;
connect(m, SIGNAL(indexCreated()),