36 Q_Q(HelpDocSettingsWidget);
38 const QStringList &fileNames =
39 QFileDialog::getOpenFileNames(q, HelpDocSettingsWidget::tr(
"Add Documentation"), {},
40 HelpDocSettingsWidget::tr(
"Qt Compressed Help Files (*.qch)"));
41 if (fileNames.isEmpty())
46 for (
const QString &fileName : fileNames) {
47 if (!m_settings.addDocumentation(fileName))
52 m_ui.registeredDocsListWidget->clearSelection();
55 const QString namespaceName = m_settings.namespaceName(fileName);
56 QListWidgetItem *item =
new QListWidgetItem(namespaceName);
57 m_namespaceToItem.insert(namespaceName, item);
58 m_itemToNamespace.insert(item, namespaceName);
59 m_ui.registeredDocsListWidget->insertItem(m_namespaceToItem.keys().indexOf(namespaceName), item);
61 item->setSelected(
true);
62 applyDocListFilter(item);
66 emit q->docSettingsChanged(m_settings);
71 Q_Q(HelpDocSettingsWidget);
73 const QList<QListWidgetItem *> selectedItems = m_ui.registeredDocsListWidget->selectedItems();
74 if (selectedItems.isEmpty())
77 for (QListWidgetItem *item : selectedItems) {
78 const QString namespaceName = m_itemToNamespace.value(item);
79 m_itemToNamespace.remove(item);
80 m_namespaceToItem.remove(namespaceName);
83 m_settings.removeDocumentation(namespaceName);
86 emit q->docSettingsChanged(m_settings);
103 , d_ptr(
new HelpDocSettingsWidgetPrivate())
105 Q_D(HelpDocSettingsWidget);
107 d->m_ui.setupUi(
this);
109 connect(d->m_ui.docAddButton, &QAbstractButton::clicked,
this,
111 Q_D(HelpDocSettingsWidget);
112 d->addDocumentation();
114 connect(d->m_ui.docRemoveButton, &QAbstractButton::clicked,
this,
116 Q_D(HelpDocSettingsWidget);
117 d->removeDocumentation();
119 connect(d->m_ui.registeredDocsFilterLineEdit, &QLineEdit::textChanged,
this,
120 [
this](
const QString &) {
121 Q_D(HelpDocSettingsWidget);
122 for (
const auto item : d->m_namespaceToItem)
123 d->applyDocListFilter(item);
125 connect(d->m_ui.registeredDocsListWidget, &QListWidget::itemSelectionChanged,
this,
127 Q_D(HelpDocSettingsWidget);
128 d->m_ui.docRemoveButton->setEnabled(
129 !d->m_ui.registeredDocsListWidget->selectedItems().isEmpty());
137 Q_D(HelpDocSettingsWidget);
138 d->m_settings = settings;
140 d->m_ui.registeredDocsListWidget->clear();
141 d->m_namespaceToItem.clear();
142 d->m_itemToNamespace.clear();
144 for (
const QString &namespaceName : d->m_settings.namespaces()) {
145 QListWidgetItem *item =
new QListWidgetItem(namespaceName);
146 d->m_namespaceToItem.insert(namespaceName, item);
147 d->m_itemToNamespace.insert(item, namespaceName);
148 d->m_ui.registeredDocsListWidget->addItem(item);
149 d->applyDocListFilter(item);
152 d->m_ui.docRemoveButton->setEnabled(
153 !d->m_ui.registeredDocsListWidget->selectedItems().isEmpty());