summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJarek Kobus <jaroslaw.kobus@qt.io>2020-08-31 15:22:37 +0200
committerJarek Kobus <jaroslaw.kobus@qt.io>2020-09-16 14:14:33 +0200
commit15d7a30d41b423846fc74d9dd252c1e2a84769e2 (patch)
tree0f7c41b68e047c022d4ca73c73615d67f618adae /src
parent377a9f64b0aa2d4ed4609e91aac731651bd47d65 (diff)
downloadqttools-15d7a30d41b423846fc74d9dd252c1e2a84769e2.tar.gz
QtHelp: Reverse the default state for readonly property for help engine
From now the read only property is true by default. The old workaround with setting the dynamic property '_q_readonly' to true for the help engine should still work, so the change shouldn't break the user code with the workaround. This fixes the most common usage of QtHelp, when help engine is used for read only help collection files. Task-number: QTBUG-83268 Task-number: QTBUG-82126 Task-number: QTBUG-84745 Change-Id: Iee6fd18269d68f43633a5fecbb65abc60c99091a Reviewed-by: Kai Koehne <kai.koehne@qt.io>
Diffstat (limited to 'src')
-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
9 files changed, 46 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;