forked from qt-creator/qt-creator
Help: Remove code paths supporting old filter engine < Qt 5.15
Change-Id: Ie3008ac78294f8831c22e73aa325e1da3b4016f2 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
@@ -5,7 +5,7 @@ add_qtc_plugin(Help
|
|||||||
PLUGIN_RECOMMENDS TextEditor
|
PLUGIN_RECOMMENDS TextEditor
|
||||||
SOURCES
|
SOURCES
|
||||||
docsettingspage.cpp docsettingspage.h docsettingspage.ui
|
docsettingspage.cpp docsettingspage.h docsettingspage.ui
|
||||||
filtersettingspage.cpp filtersettingspage.h filtersettingspage.ui
|
filtersettingspage.cpp filtersettingspage.h
|
||||||
generalsettingspage.cpp generalsettingspage.h generalsettingspage.ui
|
generalsettingspage.cpp generalsettingspage.h generalsettingspage.ui
|
||||||
help.qrc
|
help.qrc
|
||||||
helpconstants.h
|
helpconstants.h
|
||||||
@@ -26,11 +26,6 @@ add_qtc_plugin(Help
|
|||||||
xbelsupport.cpp xbelsupport.h
|
xbelsupport.cpp xbelsupport.h
|
||||||
)
|
)
|
||||||
|
|
||||||
extend_qtc_plugin(Help
|
|
||||||
CONDITION Qt5_VERSION VERSION_GREATER_EQUAL 5.15.0
|
|
||||||
DEFINES HELP_NEW_FILTER_ENGINE
|
|
||||||
)
|
|
||||||
|
|
||||||
set(HELPVIEWER_DEFAULT_BACKEND "litehtml" CACHE STRING "Sets default help viewer backend")
|
set(HELPVIEWER_DEFAULT_BACKEND "litehtml" CACHE STRING "Sets default help viewer backend")
|
||||||
set_property(CACHE HELPVIEWER_DEFAULT_BACKEND PROPERTY STRINGS "litehtml;qtwebengine;textbrowser")
|
set_property(CACHE HELPVIEWER_DEFAULT_BACKEND PROPERTY STRINGS "litehtml;qtwebengine;textbrowser")
|
||||||
|
|
||||||
|
|||||||
@@ -26,29 +26,11 @@
|
|||||||
#include "filtersettingspage.h"
|
#include "filtersettingspage.h"
|
||||||
#include "helpconstants.h"
|
#include "helpconstants.h"
|
||||||
|
|
||||||
#ifndef HELP_NEW_FILTER_ENGINE
|
|
||||||
|
|
||||||
#include "helpmanager.h"
|
|
||||||
|
|
||||||
#include <filternamedialog.h>
|
|
||||||
|
|
||||||
#include <coreplugin/helpmanager.h>
|
|
||||||
|
|
||||||
#include <utils/algorithm.h>
|
|
||||||
|
|
||||||
#include <QCoreApplication>
|
|
||||||
#include <QFileDialog>
|
|
||||||
#include <QMessageBox>
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
#include <QtCore/QVersionNumber>
|
#include <QtCore/QVersionNumber>
|
||||||
#include <QtHelp/QHelpFilterEngine>
|
#include <QtHelp/QHelpFilterEngine>
|
||||||
#include <QtHelp/QHelpFilterSettingsWidget>
|
#include <QtHelp/QHelpFilterSettingsWidget>
|
||||||
#include "localhelpmanager.h"
|
#include "localhelpmanager.h"
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
using namespace Help::Internal;
|
using namespace Help::Internal;
|
||||||
|
|
||||||
FilterSettingsPage::FilterSettingsPage()
|
FilterSettingsPage::FilterSettingsPage()
|
||||||
@@ -58,218 +40,6 @@ FilterSettingsPage::FilterSettingsPage()
|
|||||||
setCategory(Help::Constants::HELP_CATEGORY);
|
setCategory(Help::Constants::HELP_CATEGORY);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef HELP_NEW_FILTER_ENGINE
|
|
||||||
|
|
||||||
QWidget *FilterSettingsPage::widget()
|
|
||||||
{
|
|
||||||
if (!m_widget) {
|
|
||||||
m_widget = new QWidget;
|
|
||||||
m_ui.setupUi(m_widget);
|
|
||||||
|
|
||||||
updateFilterPage();
|
|
||||||
|
|
||||||
connect(m_ui.attributeWidget, &QTreeWidget::itemChanged,
|
|
||||||
this, &FilterSettingsPage::updateFilterMap);
|
|
||||||
connect(m_ui.filterWidget, &QListWidget::currentItemChanged,
|
|
||||||
this, &FilterSettingsPage::updateAttributes);
|
|
||||||
connect(m_ui.filterAddButton, &QPushButton::clicked,
|
|
||||||
this, &FilterSettingsPage::addFilter);
|
|
||||||
connect(m_ui.filterRemoveButton, &QPushButton::clicked,
|
|
||||||
this, &FilterSettingsPage::removeFilter);
|
|
||||||
connect(Core::HelpManager::Signals::instance(),
|
|
||||||
&Core::HelpManager::Signals::documentationChanged,
|
|
||||||
this,
|
|
||||||
&FilterSettingsPage::updateFilterPage);
|
|
||||||
}
|
|
||||||
return m_widget;
|
|
||||||
}
|
|
||||||
|
|
||||||
void FilterSettingsPage::updateFilterPage()
|
|
||||||
{
|
|
||||||
m_ui.filterWidget->clear();
|
|
||||||
m_ui.attributeWidget->clear();
|
|
||||||
|
|
||||||
m_filterMapBackup.clear();
|
|
||||||
|
|
||||||
QString lastTrUnfiltered;
|
|
||||||
const QString trUnfiltered = tr("Unfiltered");
|
|
||||||
if (HelpManager::customValue(Help::Constants::WeAddedFilterKey).toInt() == 1) {
|
|
||||||
lastTrUnfiltered =
|
|
||||||
HelpManager::customValue(Help::Constants::PreviousFilterNameKey).toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
HelpManager::Filters filters = HelpManager::userDefinedFilters();
|
|
||||||
HelpManager::Filters::const_iterator it;
|
|
||||||
for (it = filters.constBegin(); it != filters.constEnd(); ++it) {
|
|
||||||
const QString &filter = it.key();
|
|
||||||
if (filter == trUnfiltered || filter == lastTrUnfiltered)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
m_filterMapBackup.insert(filter, it.value());
|
|
||||||
if (!m_filterMap.contains(filter))
|
|
||||||
m_filterMap.insert(filter, it.value());
|
|
||||||
}
|
|
||||||
m_ui.filterWidget->addItems(m_filterMap.keys());
|
|
||||||
|
|
||||||
QSet<QString> attributes;
|
|
||||||
filters = HelpManager::filters();
|
|
||||||
for (it = filters.constBegin(); it != filters.constEnd(); ++it)
|
|
||||||
attributes += Utils::toSet(it.value());
|
|
||||||
|
|
||||||
foreach (const QString &attribute, attributes)
|
|
||||||
new QTreeWidgetItem(m_ui.attributeWidget, QStringList(attribute));
|
|
||||||
|
|
||||||
if (!m_filterMap.isEmpty()) {
|
|
||||||
m_ui.filterWidget->setCurrentRow(0);
|
|
||||||
updateAttributes(m_ui.filterWidget->currentItem());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void FilterSettingsPage::updateAttributes(QListWidgetItem *item)
|
|
||||||
{
|
|
||||||
QStringList checkedList;
|
|
||||||
if (item)
|
|
||||||
checkedList = m_filterMap.value(item->text());
|
|
||||||
|
|
||||||
for (int i = 0; i < m_ui.attributeWidget->topLevelItemCount(); ++i) {
|
|
||||||
QTreeWidgetItem *itm = m_ui.attributeWidget->topLevelItem(i);
|
|
||||||
if (checkedList.contains(itm->text(0)))
|
|
||||||
itm->setCheckState(0, Qt::Checked);
|
|
||||||
else
|
|
||||||
itm->setCheckState(0, Qt::Unchecked);
|
|
||||||
}
|
|
||||||
|
|
||||||
updateFilterDescription(item ? item->text() : QString());
|
|
||||||
}
|
|
||||||
|
|
||||||
void FilterSettingsPage::updateFilterMap()
|
|
||||||
{
|
|
||||||
if (!m_ui.filterWidget->currentItem())
|
|
||||||
return;
|
|
||||||
|
|
||||||
const QString &filter = m_ui.filterWidget->currentItem()->text();
|
|
||||||
if (!m_filterMap.contains(filter))
|
|
||||||
return;
|
|
||||||
|
|
||||||
QStringList newAtts;
|
|
||||||
for (int i = 0; i < m_ui.attributeWidget->topLevelItemCount(); ++i) {
|
|
||||||
QTreeWidgetItem *itm = m_ui.attributeWidget->topLevelItem(i);
|
|
||||||
if (itm->checkState(0) == Qt::Checked)
|
|
||||||
newAtts.append(itm->text(0));
|
|
||||||
}
|
|
||||||
m_filterMap[filter] = newAtts;
|
|
||||||
updateFilterDescription(filter);
|
|
||||||
}
|
|
||||||
|
|
||||||
void FilterSettingsPage::addFilter()
|
|
||||||
{
|
|
||||||
FilterNameDialog dia(m_ui.filterWidget);
|
|
||||||
if (dia.exec() == QDialog::Rejected)
|
|
||||||
return;
|
|
||||||
|
|
||||||
const QString &filterName = dia.filterName();
|
|
||||||
if (!m_filterMap.contains(filterName)) {
|
|
||||||
m_filterMap.insert(filterName, QStringList());
|
|
||||||
m_ui.filterWidget->addItem(filterName);
|
|
||||||
}
|
|
||||||
|
|
||||||
const QList<QListWidgetItem*> &lst = m_ui.filterWidget->findItems(filterName,
|
|
||||||
Qt::MatchCaseSensitive);
|
|
||||||
m_ui.filterWidget->setCurrentItem(lst.first());
|
|
||||||
}
|
|
||||||
|
|
||||||
void FilterSettingsPage::removeFilter()
|
|
||||||
{
|
|
||||||
QListWidgetItem *item =
|
|
||||||
m_ui.filterWidget->takeItem(m_ui.filterWidget->currentRow());
|
|
||||||
if (!item)
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_filterMap.remove(item->text());
|
|
||||||
m_removedFilters.append(item->text());
|
|
||||||
delete item;
|
|
||||||
if (m_ui.filterWidget->count())
|
|
||||||
m_ui.filterWidget->setCurrentRow(0);
|
|
||||||
|
|
||||||
item = m_ui.filterWidget->item(m_ui.filterWidget->currentRow());
|
|
||||||
updateFilterDescription(item ? item->text() : QString());
|
|
||||||
}
|
|
||||||
|
|
||||||
void FilterSettingsPage::apply()
|
|
||||||
{
|
|
||||||
bool changed = m_filterMap.count() != m_filterMapBackup.count();
|
|
||||||
if (!changed) {
|
|
||||||
FilterMap::const_iterator it = m_filterMapBackup.constBegin();
|
|
||||||
for (; it != m_filterMapBackup.constEnd() && !changed; ++it) {
|
|
||||||
if (m_filterMap.contains(it.key())) {
|
|
||||||
const QStringList &a = it.value();
|
|
||||||
const QStringList &b = m_filterMap.value(it.key());
|
|
||||||
if (a.count() == b.count()) {
|
|
||||||
QStringList::const_iterator i = a.constBegin();
|
|
||||||
for (; i != a.constEnd() && !changed; ++i) {
|
|
||||||
if (b.contains(*i))
|
|
||||||
continue;
|
|
||||||
changed = true;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
changed = true;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
changed = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (changed) {
|
|
||||||
foreach (const QString &filter, m_removedFilters)
|
|
||||||
HelpManager::removeUserDefinedFilter(filter);
|
|
||||||
|
|
||||||
FilterMap::const_iterator it;
|
|
||||||
for (it = m_filterMap.constBegin(); it != m_filterMap.constEnd(); ++it)
|
|
||||||
HelpManager::addUserDefinedFilter(it.key(), it.value());
|
|
||||||
|
|
||||||
// emit this signal to the help plugin, since we don't want
|
|
||||||
// to force gui help engine setup if we are not in help mode
|
|
||||||
emit filtersChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void FilterSettingsPage::finish()
|
|
||||||
{
|
|
||||||
disconnect(Core::HelpManager::Signals::instance(),
|
|
||||||
&Core::HelpManager::Signals::documentationChanged,
|
|
||||||
this,
|
|
||||||
&FilterSettingsPage::updateFilterPage);
|
|
||||||
delete m_widget;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString FilterSettingsPage::msgFilterLabel(const QString &filter) const
|
|
||||||
{
|
|
||||||
if (m_filterMap.isEmpty())
|
|
||||||
return tr("No user defined filters available or no filter selected.");
|
|
||||||
|
|
||||||
const QStringList &checkedList = m_filterMap.value(filter);
|
|
||||||
if (checkedList.isEmpty())
|
|
||||||
return tr("The filter \"%1\" will show every documentation file"
|
|
||||||
" available, as no attributes are specified.").arg(filter);
|
|
||||||
|
|
||||||
if (checkedList.size() == 1)
|
|
||||||
return tr("The filter \"%1\" will only show documentation files that"
|
|
||||||
" have the attribute %2 specified.").
|
|
||||||
arg(filter, checkedList.first());
|
|
||||||
|
|
||||||
return tr("The filter \"%1\" will only show documentation files that"
|
|
||||||
" have the attributes %2 specified.").
|
|
||||||
arg(filter, checkedList.join(", "));
|
|
||||||
}
|
|
||||||
|
|
||||||
void FilterSettingsPage::updateFilterDescription(const QString &filter)
|
|
||||||
{
|
|
||||||
m_ui.label->setText(msgFilterLabel(filter));
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
QWidget *FilterSettingsPage::widget()
|
QWidget *FilterSettingsPage::widget()
|
||||||
{
|
{
|
||||||
if (!m_widget) {
|
if (!m_widget) {
|
||||||
@@ -310,5 +80,3 @@ void FilterSettingsPage::updateFilterPage()
|
|||||||
m_widget->setAvailableVersions(LocalHelpManager::filterEngine()->availableVersions());
|
m_widget->setAvailableVersions(LocalHelpManager::filterEngine()->availableVersions());
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|||||||
@@ -29,13 +29,9 @@
|
|||||||
|
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
|
|
||||||
#ifndef HELP_NEW_FILTER_ENGINE
|
|
||||||
#include "ui_filtersettingspage.h"
|
|
||||||
#else
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QHelpFilterSettingsWidget;
|
class QHelpFilterSettingsWidget;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace Help {
|
namespace Help {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
@@ -57,25 +53,7 @@ signals:
|
|||||||
private:
|
private:
|
||||||
|
|
||||||
void updateFilterPage();
|
void updateFilterPage();
|
||||||
#ifndef HELP_NEW_FILTER_ENGINE
|
|
||||||
void updateAttributes(QListWidgetItem *item);
|
|
||||||
void updateFilterMap();
|
|
||||||
void addFilter();
|
|
||||||
void removeFilter();
|
|
||||||
void updateFilterDescription(const QString &filter);
|
|
||||||
QString msgFilterLabel(const QString &filter) const;
|
|
||||||
|
|
||||||
Ui::FilterSettingsPage m_ui;
|
|
||||||
QPointer<QWidget> m_widget;
|
|
||||||
|
|
||||||
using FilterMap = QMap<QString, QStringList>;
|
|
||||||
FilterMap m_filterMap;
|
|
||||||
FilterMap m_filterMapBackup;
|
|
||||||
|
|
||||||
QStringList m_removedFilters;
|
|
||||||
#else
|
|
||||||
QPointer<QHelpFilterSettingsWidget> m_widget;
|
QPointer<QHelpFilterSettingsWidget> m_widget;
|
||||||
#endif
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,148 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>Help::Internal::FilterSettingsPage</class>
|
|
||||||
<widget class="QWidget" name="Help::Internal::FilterSettingsPage">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>419</width>
|
|
||||||
<height>313</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="toolTip">
|
|
||||||
<string><html><body>
|
|
||||||
<p>
|
|
||||||
Add, modify, and remove document filters, which determine the documentation set displayed in the Help mode. The attributes are defined in the documents. Select them to display a set of relevant documentation. Note that some attributes are defined in several documents.
|
|
||||||
</p></body></html></string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="mainHorizontalLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="QGroupBox" name="filterGroupBox">
|
|
||||||
<property name="title">
|
|
||||||
<string>Filters</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
|
||||||
<item>
|
|
||||||
<widget class="QListWidget" name="filterWidget">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
|
||||||
<horstretch>10</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>0</width>
|
|
||||||
<height>150</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="uniformItemSizes">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QGroupBox" name="attributesGroupBox">
|
|
||||||
<property name="title">
|
|
||||||
<string>Attributes</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="QTreeWidget" name="attributeWidget">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>0</width>
|
|
||||||
<height>150</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="showDropIndicator" stdset="0">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="rootIsDecorated">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="uniformRowHeights">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<attribute name="headerVisible">
|
|
||||||
<bool>false</bool>
|
|
||||||
</attribute>
|
|
||||||
<column>
|
|
||||||
<property name="text">
|
|
||||||
<string>1</string>
|
|
||||||
</property>
|
|
||||||
</column>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label">
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>0</width>
|
|
||||||
<height>50</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>No user defined filters available or no filter selected.</string>
|
|
||||||
</property>
|
|
||||||
<property name="alignment">
|
|
||||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
|
||||||
</property>
|
|
||||||
<property name="wordWrap">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="filterAddButton">
|
|
||||||
<property name="text">
|
|
||||||
<string>Add...</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="filterRemoveButton">
|
|
||||||
<property name="text">
|
|
||||||
<string>Remove</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="buttonHorizontalSpacer">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<resources/>
|
|
||||||
<connections/>
|
|
||||||
</ui>
|
|
||||||
@@ -26,8 +26,6 @@ Project {
|
|||||||
defines.push("QTC_WEBENGINE_HELPVIEWER");
|
defines.push("QTC_WEBENGINE_HELPVIEWER");
|
||||||
if (qlitehtml.present)
|
if (qlitehtml.present)
|
||||||
defines.push("QTC_LITEHTML_HELPVIEWER")
|
defines.push("QTC_LITEHTML_HELPVIEWER")
|
||||||
if (Utilities.versionCompare(Qt.core.version, "5.15") >= 0)
|
|
||||||
defines.push("HELP_NEW_FILTER_ENGINE");
|
|
||||||
return defines;
|
return defines;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,7 +36,7 @@ Project {
|
|||||||
name: "Sources"
|
name: "Sources"
|
||||||
files: [
|
files: [
|
||||||
"docsettingspage.cpp", "docsettingspage.h", "docsettingspage.ui",
|
"docsettingspage.cpp", "docsettingspage.h", "docsettingspage.ui",
|
||||||
"filtersettingspage.cpp", "filtersettingspage.h", "filtersettingspage.ui",
|
"filtersettingspage.cpp", "filtersettingspage.h",
|
||||||
"generalsettingspage.cpp", "generalsettingspage.h", "generalsettingspage.ui",
|
"generalsettingspage.cpp", "generalsettingspage.h", "generalsettingspage.ui",
|
||||||
"help.qrc",
|
"help.qrc",
|
||||||
"helpconstants.h",
|
"helpconstants.h",
|
||||||
|
|||||||
@@ -36,24 +36,11 @@
|
|||||||
|
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
|
|
||||||
#ifndef HELP_NEW_FILTER_ENGINE
|
|
||||||
|
|
||||||
#include <utils/algorithm.h>
|
|
||||||
|
|
||||||
#include <QSqlDatabase>
|
|
||||||
#include <QSqlDriver>
|
|
||||||
#include <QSqlError>
|
|
||||||
#include <QSqlQuery>
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
#include "localhelpmanager.h"
|
#include "localhelpmanager.h"
|
||||||
#include <QtHelp/QHelpEngine>
|
#include <QtHelp/QHelpEngine>
|
||||||
#include <QtHelp/QHelpFilterEngine>
|
#include <QtHelp/QHelpFilterEngine>
|
||||||
#include <QtHelp/QHelpLink>
|
#include <QtHelp/QHelpLink>
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
using namespace Help;
|
using namespace Help;
|
||||||
using namespace Help::Internal;
|
using namespace Help::Internal;
|
||||||
@@ -78,70 +65,6 @@ HelpIndexFilter::HelpIndexFilter()
|
|||||||
|
|
||||||
HelpIndexFilter::~HelpIndexFilter() = default;
|
HelpIndexFilter::~HelpIndexFilter() = default;
|
||||||
|
|
||||||
#ifndef HELP_NEW_FILTER_ENGINE
|
|
||||||
|
|
||||||
void HelpIndexFilter::prepareSearch(const QString &entry)
|
|
||||||
{
|
|
||||||
Q_UNUSED(entry)
|
|
||||||
QStringList namespaces = HelpManager::registeredNamespaces();
|
|
||||||
m_helpDatabases = Utils::transform(namespaces, &HelpManager::fileFromNamespace);
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<LocatorFilterEntry> HelpIndexFilter::matchesFor(QFutureInterface<LocatorFilterEntry> &future, const QString &entry)
|
|
||||||
{
|
|
||||||
if (m_needsUpdate.exchange(false) || m_searchTermCache.size() < 2
|
|
||||||
|| m_searchTermCache.isEmpty() || !entry.contains(m_searchTermCache)) {
|
|
||||||
int limit = entry.size() < 2 ? 200 : INT_MAX;
|
|
||||||
QSet<QString> results;
|
|
||||||
for (const QString &filePath : qAsConst(m_helpDatabases)) {
|
|
||||||
if (future.isCanceled())
|
|
||||||
return QList<LocatorFilterEntry>();
|
|
||||||
QSet<QString> result;
|
|
||||||
QMetaObject::invokeMethod(this, "searchMatches", Qt::BlockingQueuedConnection,
|
|
||||||
Q_RETURN_ARG(QSet<QString>, result),
|
|
||||||
Q_ARG(QString, filePath),
|
|
||||||
Q_ARG(QString, entry),
|
|
||||||
Q_ARG(int, limit));
|
|
||||||
results.unite(result);
|
|
||||||
}
|
|
||||||
m_keywordCache = results;
|
|
||||||
m_searchTermCache = entry;
|
|
||||||
}
|
|
||||||
|
|
||||||
Qt::CaseSensitivity cs = caseSensitivity(entry);
|
|
||||||
QList<LocatorFilterEntry> entries;
|
|
||||||
QStringList keywords;
|
|
||||||
QStringList unsortedKeywords;
|
|
||||||
keywords.reserve(m_keywordCache.size());
|
|
||||||
unsortedKeywords.reserve(m_keywordCache.size());
|
|
||||||
QSet<QString> allresults;
|
|
||||||
for (const QString &keyword : qAsConst(m_keywordCache)) {
|
|
||||||
if (future.isCanceled())
|
|
||||||
return QList<LocatorFilterEntry>();
|
|
||||||
if (keyword.startsWith(entry, cs)) {
|
|
||||||
keywords.append(keyword);
|
|
||||||
allresults.insert(keyword);
|
|
||||||
} else if (keyword.contains(entry, cs)) {
|
|
||||||
unsortedKeywords.append(keyword);
|
|
||||||
allresults.insert(keyword);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Utils::sort(keywords);
|
|
||||||
keywords << unsortedKeywords;
|
|
||||||
m_keywordCache = allresults;
|
|
||||||
m_searchTermCache = entry;
|
|
||||||
for (const QString &keyword : qAsConst(keywords)) {
|
|
||||||
const int index = keyword.indexOf(entry, 0, cs);
|
|
||||||
LocatorFilterEntry filterEntry(this, keyword, QVariant(), m_icon);
|
|
||||||
filterEntry.highlightInfo = {index, entry.length()};
|
|
||||||
entries.append(filterEntry);
|
|
||||||
}
|
|
||||||
|
|
||||||
return entries;
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
bool HelpIndexFilter::updateCache(QFutureInterface<LocatorFilterEntry> &future,
|
bool HelpIndexFilter::updateCache(QFutureInterface<LocatorFilterEntry> &future,
|
||||||
const QStringList &cache, const QString &entry)
|
const QStringList &cache, const QString &entry)
|
||||||
{
|
{
|
||||||
@@ -195,8 +118,6 @@ QList<LocatorFilterEntry> HelpIndexFilter::matchesFor(QFutureInterface<LocatorFi
|
|||||||
return entries;
|
return entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void HelpIndexFilter::accept(const LocatorFilterEntry &selection,
|
void HelpIndexFilter::accept(const LocatorFilterEntry &selection,
|
||||||
QString *newText, int *selectionStart, int *selectionLength) const
|
QString *newText, int *selectionStart, int *selectionLength) const
|
||||||
{
|
{
|
||||||
@@ -204,14 +125,10 @@ void HelpIndexFilter::accept(const LocatorFilterEntry &selection,
|
|||||||
Q_UNUSED(selectionStart)
|
Q_UNUSED(selectionStart)
|
||||||
Q_UNUSED(selectionLength)
|
Q_UNUSED(selectionLength)
|
||||||
const QString &key = selection.displayName;
|
const QString &key = selection.displayName;
|
||||||
#ifndef HELP_NEW_FILTER_ENGINE
|
|
||||||
const QMultiMap<QString, QUrl> &links = HelpManager::instance()->linksForKeyword(key);
|
|
||||||
#else
|
|
||||||
QMultiMap<QString, QUrl> links;
|
QMultiMap<QString, QUrl> links;
|
||||||
const QList<QHelpLink> docs = LocalHelpManager::helpEngine().documentsForKeyword(key, QString());
|
const QList<QHelpLink> docs = LocalHelpManager::helpEngine().documentsForKeyword(key, QString());
|
||||||
for (const auto &doc : docs)
|
for (const auto &doc : docs)
|
||||||
links.insert(doc.title, doc.url);
|
links.insert(doc.title, doc.url);
|
||||||
#endif
|
|
||||||
emit linksActivated(links, key);
|
emit linksActivated(links, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -221,48 +138,12 @@ void HelpIndexFilter::refresh(QFutureInterface<void> &future)
|
|||||||
invalidateCache();
|
invalidateCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef HELP_NEW_FILTER_ENGINE
|
|
||||||
|
|
||||||
QSet<QString> HelpIndexFilter::searchMatches(const QString &databaseFilePath,
|
|
||||||
const QString &term, int limit)
|
|
||||||
{
|
|
||||||
static const QLatin1String sqlite("QSQLITE");
|
|
||||||
static const QLatin1String name("HelpManager::findKeywords");
|
|
||||||
|
|
||||||
QSet<QString> keywords;
|
|
||||||
|
|
||||||
{ // make sure db is destroyed before removeDatabase call
|
|
||||||
QSqlDatabase db = QSqlDatabase::addDatabase(sqlite, name);
|
|
||||||
if (db.driver() && db.driver()->lastError().type() == QSqlError::NoError) {
|
|
||||||
db.setDatabaseName(databaseFilePath);
|
|
||||||
if (db.open()) {
|
|
||||||
QSqlQuery query = QSqlQuery(db);
|
|
||||||
query.setForwardOnly(true);
|
|
||||||
query.exec(QString::fromLatin1("SELECT DISTINCT Name FROM IndexTable WHERE Name LIKE "
|
|
||||||
"'%%1%' LIMIT %2").arg(term, QString::number(limit)));
|
|
||||||
while (query.next()) {
|
|
||||||
const QString &keyValue = query.value(0).toString();
|
|
||||||
if (!keyValue.isEmpty())
|
|
||||||
keywords.insert(keyValue);
|
|
||||||
}
|
|
||||||
db.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
QSqlDatabase::removeDatabase(name);
|
|
||||||
return keywords;
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
QStringList HelpIndexFilter::allIndices() const
|
QStringList HelpIndexFilter::allIndices() const
|
||||||
{
|
{
|
||||||
LocalHelpManager::setupGuiHelpEngine();
|
LocalHelpManager::setupGuiHelpEngine();
|
||||||
return LocalHelpManager::filterEngine()->indices(QString());
|
return LocalHelpManager::filterEngine()->indices(QString());
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void HelpIndexFilter::invalidateCache()
|
void HelpIndexFilter::invalidateCache()
|
||||||
{
|
{
|
||||||
m_needsUpdate = true;
|
m_needsUpdate = true;
|
||||||
|
|||||||
@@ -52,13 +52,7 @@ public:
|
|||||||
QString *newText, int *selectionStart, int *selectionLength) const override;
|
QString *newText, int *selectionStart, int *selectionLength) const override;
|
||||||
void refresh(QFutureInterface<void> &future) override;
|
void refresh(QFutureInterface<void> &future) override;
|
||||||
|
|
||||||
#ifndef HELP_NEW_FILTER_ENGINE
|
|
||||||
void prepareSearch(const QString &entry) override;
|
|
||||||
Q_INVOKABLE QSet<QString> searchMatches(const QString &databaseFilePath,
|
|
||||||
const QString &term, int limit);
|
|
||||||
#else
|
|
||||||
Q_INVOKABLE QStringList allIndices() const;
|
Q_INVOKABLE QStringList allIndices() const;
|
||||||
#endif
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void linksActivated(const QMultiMap<QString, QUrl> &links, const QString &key) const;
|
void linksActivated(const QMultiMap<QString, QUrl> &links, const QString &key) const;
|
||||||
@@ -66,18 +60,12 @@ signals:
|
|||||||
private:
|
private:
|
||||||
void invalidateCache();
|
void invalidateCache();
|
||||||
|
|
||||||
#ifndef HELP_NEW_FILTER_ENGINE
|
|
||||||
QStringList m_helpDatabases;
|
|
||||||
QSet<QString> m_keywordCache;
|
|
||||||
QString m_searchTermCache;
|
|
||||||
#else
|
|
||||||
bool updateCache(QFutureInterface<Core::LocatorFilterEntry> &future,
|
bool updateCache(QFutureInterface<Core::LocatorFilterEntry> &future,
|
||||||
const QStringList &cache, const QString &entry);
|
const QStringList &cache, const QString &entry);
|
||||||
|
|
||||||
QStringList m_allIndicesCache;
|
QStringList m_allIndicesCache;
|
||||||
QStringList m_lastIndicesCache;
|
QStringList m_lastIndicesCache;
|
||||||
QString m_lastEntry;
|
QString m_lastEntry;
|
||||||
#endif
|
|
||||||
std::atomic_bool m_needsUpdate = true;
|
std::atomic_bool m_needsUpdate = true;
|
||||||
QIcon m_icon;
|
QIcon m_icon;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -44,14 +44,7 @@
|
|||||||
|
|
||||||
#include <QMutexLocker>
|
#include <QMutexLocker>
|
||||||
|
|
||||||
#ifndef HELP_NEW_FILTER_ENGINE
|
|
||||||
#include <QSqlDatabase>
|
|
||||||
#include <QSqlDriver>
|
|
||||||
#include <QSqlError>
|
|
||||||
#include <QSqlQuery>
|
|
||||||
#else
|
|
||||||
#include <QtHelp/QHelpLink>
|
#include <QtHelp/QHelpLink>
|
||||||
#endif
|
|
||||||
|
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
|
|
||||||
@@ -89,19 +82,6 @@ struct HelpManagerPrivate
|
|||||||
static HelpManager *m_instance = nullptr;
|
static HelpManager *m_instance = nullptr;
|
||||||
static HelpManagerPrivate *d = nullptr;
|
static HelpManagerPrivate *d = nullptr;
|
||||||
|
|
||||||
#ifndef HELP_NEW_FILTER_ENGINE
|
|
||||||
|
|
||||||
// -- DbCleaner
|
|
||||||
|
|
||||||
struct DbCleaner
|
|
||||||
{
|
|
||||||
DbCleaner(const QString &dbName) : name(dbName) {}
|
|
||||||
~DbCleaner() { QSqlDatabase::removeDatabase(name); }
|
|
||||||
QString name;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// -- HelpManager
|
// -- HelpManager
|
||||||
|
|
||||||
HelpManager::HelpManager(QObject *parent) :
|
HelpManager::HelpManager(QObject *parent) :
|
||||||
@@ -243,15 +223,11 @@ QMultiMap<QString, QUrl> HelpManager::linksForKeyword(const QString &key)
|
|||||||
QTC_ASSERT(!d->m_needsSetup, return {});
|
QTC_ASSERT(!d->m_needsSetup, return {});
|
||||||
if (key.isEmpty())
|
if (key.isEmpty())
|
||||||
return {};
|
return {};
|
||||||
#ifndef HELP_NEW_FILTER_ENGINE
|
|
||||||
return d->m_helpEngine->linksForKeyword(key);
|
|
||||||
#else
|
|
||||||
QMultiMap<QString, QUrl> links;
|
QMultiMap<QString, QUrl> links;
|
||||||
const QList<QHelpLink> docs = d->m_helpEngine->documentsForKeyword(key, QString());
|
const QList<QHelpLink> docs = d->m_helpEngine->documentsForKeyword(key, QString());
|
||||||
for (const auto &doc : docs)
|
for (const auto &doc : docs)
|
||||||
links.insert(doc.title, doc.url);
|
links.insert(doc.title, doc.url);
|
||||||
return links;
|
return links;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QMultiMap<QString, QUrl> HelpManager::linksForIdentifier(const QString &id)
|
QMultiMap<QString, QUrl> HelpManager::linksForIdentifier(const QString &id)
|
||||||
@@ -259,15 +235,11 @@ QMultiMap<QString, QUrl> HelpManager::linksForIdentifier(const QString &id)
|
|||||||
QTC_ASSERT(!d->m_needsSetup, return {});
|
QTC_ASSERT(!d->m_needsSetup, return {});
|
||||||
if (id.isEmpty())
|
if (id.isEmpty())
|
||||||
return {};
|
return {};
|
||||||
#ifndef HELP_NEW_FILTER_ENGINE
|
|
||||||
return d->m_helpEngine->linksForIdentifier(id);
|
|
||||||
#else
|
|
||||||
QMultiMap<QString, QUrl> links;
|
QMultiMap<QString, QUrl> links;
|
||||||
const QList<QHelpLink> docs = d->m_helpEngine->documentsForIdentifier(id, QString());
|
const QList<QHelpLink> docs = d->m_helpEngine->documentsForIdentifier(id, QString());
|
||||||
for (const auto &doc : docs)
|
for (const auto &doc : docs)
|
||||||
links.insert(doc.title, doc.url);
|
links.insert(doc.title, doc.url);
|
||||||
return links;
|
return links;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QUrl HelpManager::findFile(const QUrl &url)
|
QUrl HelpManager::findFile(const QUrl &url)
|
||||||
@@ -321,76 +293,6 @@ QVariant HelpManager::customValue(const QString &key, const QVariant &value)
|
|||||||
return d->m_helpEngine->customValue(key, value);
|
return d->m_helpEngine->customValue(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef HELP_NEW_FILTER_ENGINE
|
|
||||||
|
|
||||||
HelpManager::Filters HelpManager::filters()
|
|
||||||
{
|
|
||||||
QTC_ASSERT(!d->m_needsSetup, return {});
|
|
||||||
|
|
||||||
Filters filters;
|
|
||||||
const QStringList &customFilters = d->m_helpEngine->customFilters();
|
|
||||||
for (const QString &filter : customFilters)
|
|
||||||
filters.insert(filter, d->m_helpEngine->filterAttributes(filter));
|
|
||||||
return filters;
|
|
||||||
}
|
|
||||||
|
|
||||||
HelpManager::Filters HelpManager::fixedFilters()
|
|
||||||
{
|
|
||||||
QTC_ASSERT(!d->m_needsSetup, return {});
|
|
||||||
|
|
||||||
const QLatin1String sqlite("QSQLITE");
|
|
||||||
const QLatin1String name("HelpManager::fixedCustomFilters");
|
|
||||||
|
|
||||||
Filters fixedFilters;
|
|
||||||
DbCleaner cleaner(name);
|
|
||||||
QSqlDatabase db = QSqlDatabase::addDatabase(sqlite, name);
|
|
||||||
if (db.driver() && db.driver()->lastError().type() == QSqlError::NoError) {
|
|
||||||
const QStringList ®isteredDocs = d->m_helpEngine->registeredDocumentations();
|
|
||||||
for (const QString &nameSpace : registeredDocs) {
|
|
||||||
db.setDatabaseName(d->m_helpEngine->documentationFileName(nameSpace));
|
|
||||||
if (db.open()) {
|
|
||||||
QSqlQuery query = QSqlQuery(db);
|
|
||||||
query.setForwardOnly(true);
|
|
||||||
query.exec(QLatin1String("SELECT Name FROM FilterNameTable"));
|
|
||||||
while (query.next()) {
|
|
||||||
const QString &filter = query.value(0).toString();
|
|
||||||
fixedFilters.insert(filter, d->m_helpEngine->filterAttributes(filter));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return fixedFilters;
|
|
||||||
}
|
|
||||||
|
|
||||||
HelpManager::Filters HelpManager::userDefinedFilters()
|
|
||||||
{
|
|
||||||
QTC_ASSERT(!d->m_needsSetup, return {});
|
|
||||||
|
|
||||||
Filters all = filters();
|
|
||||||
const Filters &fixed = fixedFilters();
|
|
||||||
for (Filters::const_iterator it = fixed.constBegin(); it != fixed.constEnd(); ++it)
|
|
||||||
all.remove(it.key());
|
|
||||||
return all;
|
|
||||||
}
|
|
||||||
|
|
||||||
void HelpManager::removeUserDefinedFilter(const QString &filter)
|
|
||||||
{
|
|
||||||
QTC_ASSERT(!d->m_needsSetup, return);
|
|
||||||
|
|
||||||
if (d->m_helpEngine->removeCustomFilter(filter))
|
|
||||||
emit m_instance->collectionFileChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
void HelpManager::addUserDefinedFilter(const QString &filter, const QStringList &attr)
|
|
||||||
{
|
|
||||||
QTC_ASSERT(!d->m_needsSetup, return);
|
|
||||||
|
|
||||||
if (d->m_helpEngine->addCustomFilter(filter, attr))
|
|
||||||
emit m_instance->collectionFileChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void HelpManager::aboutToShutdown()
|
void HelpManager::aboutToShutdown()
|
||||||
{
|
{
|
||||||
if (d && d->m_registerFuture.isRunning()) {
|
if (d && d->m_registerFuture.isRunning()) {
|
||||||
@@ -414,9 +316,7 @@ void HelpManager::setupHelpManager()
|
|||||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||||
d->m_helpEngine->setReadOnly(false);
|
d->m_helpEngine->setReadOnly(false);
|
||||||
#endif
|
#endif
|
||||||
#ifdef HELP_NEW_FILTER_ENGINE
|
|
||||||
d->m_helpEngine->setUsesFilterEngine(true);
|
d->m_helpEngine->setUsesFilterEngine(true);
|
||||||
#endif
|
|
||||||
d->m_helpEngine->setupData();
|
d->m_helpEngine->setupData();
|
||||||
|
|
||||||
for (const QString &filePath : d->documentationFromInstaller())
|
for (const QString &filePath : d->documentationFromInstaller())
|
||||||
|
|||||||
@@ -67,17 +67,6 @@ public:
|
|||||||
static void setCustomValue(const QString &key, const QVariant &value);
|
static void setCustomValue(const QString &key, const QVariant &value);
|
||||||
static QVariant customValue(const QString &key, const QVariant &value = QVariant());
|
static QVariant customValue(const QString &key, const QVariant &value = QVariant());
|
||||||
|
|
||||||
#ifndef HELP_NEW_FILTER_ENGINE
|
|
||||||
using Filters = QHash<QString, QStringList>;
|
|
||||||
|
|
||||||
static Filters filters();
|
|
||||||
static Filters fixedFilters();
|
|
||||||
|
|
||||||
static Filters userDefinedFilters();
|
|
||||||
static void removeUserDefinedFilter(const QString &filter);
|
|
||||||
static void addUserDefinedFilter(const QString &filter, const QStringList &attr);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static void aboutToShutdown();
|
static void aboutToShutdown();
|
||||||
|
|
||||||
Q_INVOKABLE void showHelpUrl(
|
Q_INVOKABLE void showHelpUrl(
|
||||||
|
|||||||
@@ -123,10 +123,6 @@ public:
|
|||||||
|
|
||||||
void slotSystemInformation();
|
void slotSystemInformation();
|
||||||
|
|
||||||
#ifndef HELP_NEW_FILTER_ENGINE
|
|
||||||
void resetFilter();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static void activateHelpMode() { ModeManager::activateMode(Constants::ID_MODE_HELP); }
|
static void activateHelpMode() { ModeManager::activateMode(Constants::ID_MODE_HELP); }
|
||||||
static bool canShowHelpSideBySide();
|
static bool canShowHelpSideBySide();
|
||||||
|
|
||||||
@@ -320,44 +316,6 @@ ExtensionSystem::IPlugin::ShutdownFlag HelpPlugin::aboutToShutdown()
|
|||||||
return SynchronousShutdown;
|
return SynchronousShutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef HELP_NEW_FILTER_ENGINE
|
|
||||||
|
|
||||||
void HelpPluginPrivate::resetFilter()
|
|
||||||
{
|
|
||||||
const QString &filterInternal = QString::fromLatin1("Qt Creator %1.%2.%3")
|
|
||||||
.arg(IDE_VERSION_MAJOR).arg(IDE_VERSION_MINOR).arg(IDE_VERSION_RELEASE);
|
|
||||||
const QRegularExpression filterRegExp("^Qt Creator \\d*\\.\\d*\\.\\d*$");
|
|
||||||
|
|
||||||
QHelpEngineCore *engine = &LocalHelpManager::helpEngine();
|
|
||||||
const QStringList &filters = engine->customFilters();
|
|
||||||
for (const QString &filter : filters) {
|
|
||||||
if (filterRegExp.match(filter).hasMatch() && filter != filterInternal)
|
|
||||||
engine->removeCustomFilter(filter);
|
|
||||||
}
|
|
||||||
|
|
||||||
// we added a filter at some point, remove previously added filter
|
|
||||||
if (engine->customValue(Help::Constants::WeAddedFilterKey).toInt() == 1) {
|
|
||||||
const QString &filter =
|
|
||||||
engine->customValue(Help::Constants::PreviousFilterNameKey).toString();
|
|
||||||
if (!filter.isEmpty())
|
|
||||||
engine->removeCustomFilter(filter);
|
|
||||||
}
|
|
||||||
|
|
||||||
// potentially remove a filter with new name
|
|
||||||
const QString filterName = HelpPlugin::tr("Unfiltered");
|
|
||||||
engine->removeCustomFilter(filterName);
|
|
||||||
engine->addCustomFilter(filterName, QStringList());
|
|
||||||
engine->setCustomValue(Help::Constants::WeAddedFilterKey, 1);
|
|
||||||
engine->setCustomValue(Help::Constants::PreviousFilterNameKey, filterName);
|
|
||||||
engine->setCurrentFilter(filterName);
|
|
||||||
|
|
||||||
LocalHelpManager::updateFilterModel();
|
|
||||||
connect(engine, &QHelpEngineCore::setupFinished,
|
|
||||||
LocalHelpManager::instance(), &LocalHelpManager::updateFilterModel);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void HelpPluginPrivate::saveExternalWindowSettings()
|
void HelpPluginPrivate::saveExternalWindowSettings()
|
||||||
{
|
{
|
||||||
if (!m_externalWindow)
|
if (!m_externalWindow)
|
||||||
@@ -698,9 +656,6 @@ void HelpPluginPrivate::doSetupIfNeeded()
|
|||||||
{
|
{
|
||||||
LocalHelpManager::setupGuiHelpEngine();
|
LocalHelpManager::setupGuiHelpEngine();
|
||||||
if (m_setupNeeded) {
|
if (m_setupNeeded) {
|
||||||
#ifndef HELP_NEW_FILTER_ENGINE
|
|
||||||
resetFilter();
|
|
||||||
#endif
|
|
||||||
m_setupNeeded = false;
|
m_setupNeeded = false;
|
||||||
m_centralWidget->openPagesManager()->setupInitialPages();
|
m_centralWidget->openPagesManager()->setupInitialPages();
|
||||||
LocalHelpManager::bookmarkManager().setupBookmarkModels();
|
LocalHelpManager::bookmarkManager().setupBookmarkModels();
|
||||||
|
|||||||
@@ -61,10 +61,8 @@
|
|||||||
#include <QStatusBar>
|
#include <QStatusBar>
|
||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
|
|
||||||
#ifdef HELP_NEW_FILTER_ENGINE
|
|
||||||
#include <QtHelp/QHelpEngine>
|
#include <QtHelp/QHelpEngine>
|
||||||
#include <QtHelp/QHelpFilterEngine>
|
#include <QtHelp/QHelpFilterEngine>
|
||||||
#endif
|
|
||||||
|
|
||||||
static const char kWindowSideBarSettingsKey[] = "Help/WindowSideBar";
|
static const char kWindowSideBarSettingsKey[] = "Help/WindowSideBar";
|
||||||
static const char kModeSideBarSettingsKey[] = "Help/ModeSideBar";
|
static const char kModeSideBarSettingsKey[] = "Help/ModeSideBar";
|
||||||
@@ -365,23 +363,12 @@ HelpWidget::HelpWidget(const Core::Context &context, WidgetStyle style, QWidget
|
|||||||
m_filterComboBox = new QComboBox;
|
m_filterComboBox = new QComboBox;
|
||||||
m_filterComboBox->setMinimumContentsLength(15);
|
m_filterComboBox->setMinimumContentsLength(15);
|
||||||
layout->addWidget(m_filterComboBox);
|
layout->addWidget(m_filterComboBox);
|
||||||
#ifndef HELP_NEW_FILTER_ENGINE
|
|
||||||
m_filterComboBox->setModel(LocalHelpManager::filterModel());
|
|
||||||
m_filterComboBox->setCurrentIndex(LocalHelpManager::filterIndex());
|
|
||||||
connect(m_filterComboBox, QOverload<int>::of(&QComboBox::activated),
|
|
||||||
LocalHelpManager::instance(), &LocalHelpManager::setFilterIndex);
|
|
||||||
connect(LocalHelpManager::instance(),
|
|
||||||
&LocalHelpManager::filterIndexChanged,
|
|
||||||
m_filterComboBox,
|
|
||||||
&QComboBox::setCurrentIndex);
|
|
||||||
#else
|
|
||||||
connect(&LocalHelpManager::helpEngine(), &QHelpEngine::setupFinished,
|
connect(&LocalHelpManager::helpEngine(), &QHelpEngine::setupFinished,
|
||||||
this, &HelpWidget::setupFilterCombo, Qt::QueuedConnection);
|
this, &HelpWidget::setupFilterCombo, Qt::QueuedConnection);
|
||||||
connect(m_filterComboBox, QOverload<int>::of(&QComboBox::activated),
|
connect(m_filterComboBox, QOverload<int>::of(&QComboBox::activated),
|
||||||
this, &HelpWidget::filterDocumentation);
|
this, &HelpWidget::filterDocumentation);
|
||||||
connect(LocalHelpManager::filterEngine(), &QHelpFilterEngine::filterActivated,
|
connect(LocalHelpManager::filterEngine(), &QHelpFilterEngine::filterActivated,
|
||||||
this, &HelpWidget::currentFilterChanged);
|
this, &HelpWidget::currentFilterChanged);
|
||||||
#endif
|
|
||||||
|
|
||||||
Core::ActionContainer *windowMenu = Core::ActionManager::actionContainer(
|
Core::ActionContainer *windowMenu = Core::ActionManager::actionContainer(
|
||||||
Core::Constants::M_WINDOW);
|
Core::Constants::M_WINDOW);
|
||||||
@@ -501,8 +488,6 @@ HelpWidget::HelpWidget(const Core::Context &context, WidgetStyle style, QWidget
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HELP_NEW_FILTER_ENGINE
|
|
||||||
|
|
||||||
void HelpWidget::setupFilterCombo()
|
void HelpWidget::setupFilterCombo()
|
||||||
{
|
{
|
||||||
const QString currentFilter = LocalHelpManager::filterEngine()->activeFilter();
|
const QString currentFilter = LocalHelpManager::filterEngine()->activeFilter();
|
||||||
@@ -534,8 +519,6 @@ void HelpWidget::currentFilterChanged(const QString &filter)
|
|||||||
m_filterComboBox->setCurrentIndex(index);
|
m_filterComboBox->setCurrentIndex(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
HelpWidget::~HelpWidget()
|
HelpWidget::~HelpWidget()
|
||||||
{
|
{
|
||||||
saveState();
|
saveState();
|
||||||
|
|||||||
@@ -142,11 +142,9 @@ private:
|
|||||||
void addSideBar();
|
void addSideBar();
|
||||||
QString sideBarSettingsKey() const;
|
QString sideBarSettingsKey() const;
|
||||||
|
|
||||||
#ifdef HELP_NEW_FILTER_ENGINE
|
|
||||||
void setupFilterCombo();
|
void setupFilterCombo();
|
||||||
void filterDocumentation(int filterIndex);
|
void filterDocumentation(int filterIndex);
|
||||||
void currentFilterChanged(const QString &filter);
|
void currentFilterChanged(const QString &filter);
|
||||||
#endif
|
|
||||||
|
|
||||||
OpenPagesModel m_model;
|
OpenPagesModel m_model;
|
||||||
OpenPagesManager *m_openPagesManager = nullptr;
|
OpenPagesManager *m_openPagesManager = nullptr;
|
||||||
|
|||||||
@@ -69,14 +69,6 @@ QHelpEngine* LocalHelpManager::m_guiEngine = nullptr;
|
|||||||
QMutex LocalHelpManager::m_bkmarkMutex;
|
QMutex LocalHelpManager::m_bkmarkMutex;
|
||||||
BookmarkManager* LocalHelpManager::m_bookmarkManager = nullptr;
|
BookmarkManager* LocalHelpManager::m_bookmarkManager = nullptr;
|
||||||
|
|
||||||
#ifndef HELP_NEW_FILTER_ENGINE
|
|
||||||
|
|
||||||
QStandardItemModel *LocalHelpManager::m_filterModel = nullptr;
|
|
||||||
QString LocalHelpManager::m_currentFilter = QString();
|
|
||||||
int LocalHelpManager::m_currentFilterIndex = -1;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static const char kHelpHomePageKey[] = "Help/HomePage";
|
static const char kHelpHomePageKey[] = "Help/HomePage";
|
||||||
static const char kFontFamilyKey[] = "Help/FallbackFontFamily";
|
static const char kFontFamilyKey[] = "Help/FallbackFontFamily";
|
||||||
static const char kFontStyleNameKey[] = "Help/FallbackFontStyleName";
|
static const char kFontStyleNameKey[] = "Help/FallbackFontStyleName";
|
||||||
@@ -118,9 +110,6 @@ LocalHelpManager::LocalHelpManager(QObject *parent)
|
|||||||
{
|
{
|
||||||
m_instance = this;
|
m_instance = this;
|
||||||
qRegisterMetaType<Help::Internal::LocalHelpManager::HelpData>("Help::Internal::LocalHelpManager::HelpData");
|
qRegisterMetaType<Help::Internal::LocalHelpManager::HelpData>("Help::Internal::LocalHelpManager::HelpData");
|
||||||
#ifndef HELP_NEW_FILTER_ENGINE
|
|
||||||
m_filterModel = new QStandardItemModel(this);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LocalHelpManager::~LocalHelpManager()
|
LocalHelpManager::~LocalHelpManager()
|
||||||
@@ -414,9 +403,7 @@ QHelpEngine &LocalHelpManager::helpEngine()
|
|||||||
m_guiEngine->setReadOnly(false);
|
m_guiEngine->setReadOnly(false);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HELP_NEW_FILTER_ENGINE
|
|
||||||
m_guiEngine->setUsesFilterEngine(true);
|
m_guiEngine->setUsesFilterEngine(true);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return *m_guiEngine;
|
return *m_guiEngine;
|
||||||
@@ -515,66 +502,11 @@ LocalHelpManager::HelpData LocalHelpManager::helpData(const QUrl &url)
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef HELP_NEW_FILTER_ENGINE
|
|
||||||
|
|
||||||
QAbstractItemModel *LocalHelpManager::filterModel()
|
|
||||||
{
|
|
||||||
return m_filterModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
void LocalHelpManager::setFilterIndex(int index)
|
|
||||||
{
|
|
||||||
if (index == m_currentFilterIndex)
|
|
||||||
return;
|
|
||||||
m_currentFilterIndex = index;
|
|
||||||
QStandardItem *item = m_filterModel->item(index);
|
|
||||||
if (!item) {
|
|
||||||
helpEngine().setCurrentFilter(QString());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
helpEngine().setCurrentFilter(item->text());
|
|
||||||
emit m_instance->filterIndexChanged(m_currentFilterIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
int LocalHelpManager::filterIndex()
|
|
||||||
{
|
|
||||||
return m_currentFilterIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
void LocalHelpManager::updateFilterModel()
|
|
||||||
{
|
|
||||||
const QHelpEngine &engine = helpEngine();
|
|
||||||
if (m_currentFilter.isEmpty())
|
|
||||||
m_currentFilter = engine.currentFilter();
|
|
||||||
m_filterModel->clear();
|
|
||||||
m_currentFilterIndex = -1;
|
|
||||||
int count = 0;
|
|
||||||
const QStringList &filters = engine.customFilters();
|
|
||||||
foreach (const QString &filterString, filters) {
|
|
||||||
m_filterModel->appendRow(new QStandardItem(filterString));
|
|
||||||
if (filterString == m_currentFilter)
|
|
||||||
m_currentFilterIndex = count;
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (filters.size() < 1)
|
|
||||||
return;
|
|
||||||
if (m_currentFilterIndex < 0) {
|
|
||||||
m_currentFilterIndex = 0;
|
|
||||||
m_currentFilter = filters.at(0);
|
|
||||||
}
|
|
||||||
emit m_instance->filterIndexChanged(m_currentFilterIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
QHelpFilterEngine *LocalHelpManager::filterEngine()
|
QHelpFilterEngine *LocalHelpManager::filterEngine()
|
||||||
{
|
{
|
||||||
return helpEngine().filterEngine();
|
return helpEngine().filterEngine();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
bool LocalHelpManager::canOpenOnlineHelp(const QUrl &url)
|
bool LocalHelpManager::canOpenOnlineHelp(const QUrl &url)
|
||||||
{
|
{
|
||||||
const QString address = url.toString();
|
const QString address = url.toString();
|
||||||
|
|||||||
@@ -31,13 +31,8 @@
|
|||||||
#include <QMutex>
|
#include <QMutex>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#ifndef HELP_NEW_FILTER_ENGINE
|
|
||||||
#include <QStandardItemModel>
|
|
||||||
#include <functional>
|
|
||||||
#else
|
|
||||||
QT_FORWARD_DECLARE_CLASS(QHelpFilterEngine)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
QT_FORWARD_DECLARE_CLASS(QHelpFilterEngine)
|
||||||
QT_FORWARD_DECLARE_CLASS(QHelpEngine)
|
QT_FORWARD_DECLARE_CLASS(QHelpEngine)
|
||||||
|
|
||||||
class BookmarkManager;
|
class BookmarkManager;
|
||||||
@@ -119,23 +114,12 @@ public:
|
|||||||
static QByteArray loadErrorMessage(const QUrl &url, const QString &errorString);
|
static QByteArray loadErrorMessage(const QUrl &url, const QString &errorString);
|
||||||
Q_INVOKABLE static Help::Internal::LocalHelpManager::HelpData helpData(const QUrl &url);
|
Q_INVOKABLE static Help::Internal::LocalHelpManager::HelpData helpData(const QUrl &url);
|
||||||
|
|
||||||
#ifndef HELP_NEW_FILTER_ENGINE
|
|
||||||
static QAbstractItemModel *filterModel();
|
|
||||||
static void setFilterIndex(int index);
|
|
||||||
static int filterIndex();
|
|
||||||
|
|
||||||
static void updateFilterModel();
|
|
||||||
#else
|
|
||||||
static QHelpFilterEngine *filterEngine();
|
static QHelpFilterEngine *filterEngine();
|
||||||
#endif
|
|
||||||
|
|
||||||
static bool canOpenOnlineHelp(const QUrl &url);
|
static bool canOpenOnlineHelp(const QUrl &url);
|
||||||
static bool openOnlineHelp(const QUrl &url);
|
static bool openOnlineHelp(const QUrl &url);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
#ifndef HELP_NEW_FILTER_ENGINE
|
|
||||||
void filterIndexChanged(int index);
|
|
||||||
#endif
|
|
||||||
void fallbackFontChanged(const QFont &font);
|
void fallbackFontChanged(const QFont &font);
|
||||||
void fontZoomChanged(int percentage);
|
void fontZoomChanged(int percentage);
|
||||||
void returnOnCloseChanged();
|
void returnOnCloseChanged();
|
||||||
@@ -146,12 +130,6 @@ private:
|
|||||||
static bool m_guiNeedsSetup;
|
static bool m_guiNeedsSetup;
|
||||||
static bool m_needsCollectionFile;
|
static bool m_needsCollectionFile;
|
||||||
|
|
||||||
#ifndef HELP_NEW_FILTER_ENGINE
|
|
||||||
static QStandardItemModel *m_filterModel;
|
|
||||||
static QString m_currentFilter;
|
|
||||||
static int m_currentFilterIndex;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static QMutex m_guiMutex;
|
static QMutex m_guiMutex;
|
||||||
static QHelpEngine *m_guiEngine;
|
static QHelpEngine *m_guiEngine;
|
||||||
|
|
||||||
|
|||||||
@@ -28,8 +28,3 @@ add_qtc_library(shared_help STATIC
|
|||||||
indexwindow.cpp indexwindow.h
|
indexwindow.cpp indexwindow.h
|
||||||
topicchooser.cpp topicchooser.h topicchooser.ui
|
topicchooser.cpp topicchooser.h topicchooser.ui
|
||||||
)
|
)
|
||||||
|
|
||||||
extend_qtc_library(shared_help
|
|
||||||
CONDITION Qt5_VERSION VERSION_GREATER_EQUAL 5.15.0
|
|
||||||
DEFINES HELP_NEW_FILTER_ENGINE
|
|
||||||
)
|
|
||||||
|
|||||||
@@ -48,9 +48,7 @@
|
|||||||
#include <QHelpEngine>
|
#include <QHelpEngine>
|
||||||
#include <QHelpIndexModel>
|
#include <QHelpIndexModel>
|
||||||
|
|
||||||
#ifdef HELP_NEW_FILTER_ENGINE
|
|
||||||
#include <QHelpLink>
|
#include <QHelpLink>
|
||||||
#endif
|
|
||||||
|
|
||||||
using namespace Help::Internal;
|
using namespace Help::Internal;
|
||||||
|
|
||||||
@@ -198,15 +196,11 @@ void IndexWindow::disableSearchLineEdit()
|
|||||||
void IndexWindow::open(const QModelIndex &index, bool newPage)
|
void IndexWindow::open(const QModelIndex &index, bool newPage)
|
||||||
{
|
{
|
||||||
const QString keyword = m_filteredIndexModel->data(index, Qt::DisplayRole).toString();
|
const QString keyword = m_filteredIndexModel->data(index, Qt::DisplayRole).toString();
|
||||||
#ifndef HELP_NEW_FILTER_ENGINE
|
|
||||||
QMultiMap<QString, QUrl> links = LocalHelpManager::helpEngine().linksForKeyword(keyword);
|
|
||||||
#else
|
|
||||||
QMultiMap<QString, QUrl> links;
|
QMultiMap<QString, QUrl> links;
|
||||||
const QList<QHelpLink> docs = LocalHelpManager::helpEngine().documentsForKeyword(keyword);
|
const QList<QHelpLink> docs = LocalHelpManager::helpEngine().documentsForKeyword(keyword);
|
||||||
for (const auto &doc : docs)
|
for (const auto &doc : docs)
|
||||||
links.insert(doc.title, doc.url);
|
links.insert(doc.title, doc.url);
|
||||||
|
|
||||||
#endif
|
|
||||||
emit linksActivated(links, keyword, newPage);
|
emit linksActivated(links, keyword, newPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user