Commit fd6f1b69 authored by kh1's avatar kh1
Browse files

Show user defined filters only, some more of information about the filter.

Reviewed-by: ck
parent 1bcdb33f
......@@ -110,22 +110,24 @@ void FilterSettingsPage::updateFilterPage()
manager->customValue(Help::Constants::PreviousFilterNameKey).toString();
}
QSet<QString> attributes;
const Core::HelpManager::Filters &filters = manager->filters();
Core::HelpManager::Filters filters = manager->userDefinedFilters();
Core::HelpManager::Filters::const_iterator it;
for (it = filters.constBegin(); it != filters.constEnd(); ++it) {
const QString &filter = it.key();
if (filter == trUnfiltered || filter == lastTrUnfiltered)
continue;
attributes += it.value().toSet();
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 = manager->filters();
for (it = filters.constBegin(); it != filters.constEnd(); ++it)
attributes += it.value().toSet();
foreach (const QString &attribute, attributes)
new QTreeWidgetItem(m_ui.attributeWidget, QStringList(attribute));
......@@ -148,6 +150,8 @@ void FilterSettingsPage::updateAttributes(QListWidgetItem *item)
else
itm->setCheckState(0, Qt::Unchecked);
}
updateFilterDescription(item ? item->text() : QString());
}
void FilterSettingsPage::updateFilterMap()
......@@ -166,6 +170,7 @@ void FilterSettingsPage::updateFilterMap()
newAtts.append(itm->text(0));
}
m_filterMap[filter] = newAtts;
updateFilterDescription(filter);
}
void FilterSettingsPage::addFilter()
......@@ -197,6 +202,9 @@ void FilterSettingsPage::removeFilter()
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()
......@@ -243,3 +251,24 @@ bool FilterSettingsPage::matches(const QString &s) const
{
return m_searchKeywords.contains(s, Qt::CaseInsensitive);
}
void FilterSettingsPage::updateFilterDescription(const QString &filter)
{
const QStringList &checkedList = m_filterMap.value(filter);
if (!m_filterMap.keys().isEmpty()) {
const QString prefix = tr("The filter \"%1\" will").arg(filter);
if (checkedList.isEmpty()) {
m_ui.label->setText(prefix + tr(" show every documentation file "
"available, as no attributes are specified."));
} else if (checkedList.count() == 1) {
m_ui.label->setText(prefix + tr(" only show documentation files that"
" have the attribute %2 specified.").arg(checkedList.first()));
} else {
m_ui.label->setText(prefix + tr(" only show documentation files that"
" have the attributes %2 specified.").arg(checkedList.join(", ")));
}
} else {
m_ui.label->setText(tr("No user defined filters available or no filter "
"selected."));
}
}
......@@ -65,6 +65,9 @@ private slots:
void addFilter();
void removeFilter();
private:
void updateFilterDescription(const QString &filter);
private:
Ui::FilterSettingsPage m_ui;
......
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
<width>419</width>
<height>313</height>
</rect>
</property>
<property name="toolTip">
......@@ -27,6 +27,18 @@ Add, modify, and remove document filters, which determine the documentation set
<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>
......@@ -43,6 +55,18 @@ Add, modify, and remove document filters, which determine the documentation set
<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>
......@@ -55,9 +79,6 @@ Add, modify, and remove document filters, which determine the documentation set
<attribute name="headerVisible">
<bool>false</bool>
</attribute>
<attribute name="headerVisible">
<bool>false</bool>
</attribute>
<column>
<property name="text">
<string>1</string>
......@@ -70,6 +91,25 @@ Add, modify, and remove document filters, which determine the documentation set
</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>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment