Группа :: Графические оболочки/KDE
Пакет: kde5-khelpcenter
Главная Изменения Спек Патчи Sources Загрузить Gear Bugs and FR Repocop
Патч: khelpcenter-alt-hide-links-on-contents-screen.patch
Скачать
Скачать
From 672515d40b53d67cde6be66e00934e4517c06cb8 Mon Sep 17 00:00:00 2001
From: Aleksei Nikiforov <darktemplar@altlinux.org>
Date: Tue, 9 Jun 2020 17:47:57 +0300
Subject: [PATCH] Hide links to empty pages from contents screen
---
khelpcenter/infotree.cpp | 14 ++++++++++++++
khelpcenter/navigator.cpp | 5 +++++
khelpcenter/navigatorappgroupitem.cpp | 5 +++++
khelpcenter/navigatorappgroupitem.h | 2 ++
khelpcenter/navigatorappitem.cpp | 5 +++++
khelpcenter/navigatorappitem.h | 2 ++
khelpcenter/navigatoritem.cpp | 5 +++++
khelpcenter/navigatoritem.h | 2 ++
khelpcenter/toc.cpp | 7 +++++++
9 files changed, 47 insertions(+)
diff --git a/khelpcenter/infotree.cpp b/khelpcenter/infotree.cpp
index 07af5bbd..dbe7fc30 100644
--- a/khelpcenter/infotree.cpp
+++ b/khelpcenter/infotree.cpp
@@ -40,12 +40,16 @@ class InfoCategoryItem : public NavigatorItem
InfoCategoryItem( NavigatorItem *parent, const QString &text );
void itemExpanded( bool open ) override;
+
+ virtual bool skipInContentsIfEmpty() const override;
};
class InfoNodeItem : public NavigatorItem
{
public:
InfoNodeItem( InfoCategoryItem *parent, const QString &text );
+
+ virtual bool skipInContentsIfEmpty() const override;
};
InfoCategoryItem::InfoCategoryItem( NavigatorItem *parent, const QString &text )
@@ -66,6 +70,11 @@ void InfoCategoryItem::itemExpanded( bool open )
else setIcon( 0, QIcon::fromTheme( QStringLiteral("help-contents") ) );
}
+bool InfoCategoryItem::skipInContentsIfEmpty() const
+{
+ return false;
+}
+
InfoNodeItem::InfoNodeItem( InfoCategoryItem *parent, const QString &text )
: NavigatorItem( new DocEntry( text ), parent )
{
@@ -73,6 +82,11 @@ InfoNodeItem::InfoNodeItem( InfoCategoryItem *parent, const QString &text )
// qCDebug(KHC_LOG) << "Created info node item: " << text;
}
+bool InfoNodeItem::skipInContentsIfEmpty() const
+{
+ return false;
+}
+
InfoTree::InfoTree( QObject *parent )
: TreeBuilder( parent ),
m_parentItem( nullptr )
diff --git a/khelpcenter/navigator.cpp b/khelpcenter/navigator.cpp
index 770ef3fc..4a0802e5 100644
--- a/khelpcenter/navigator.cpp
+++ b/khelpcenter/navigator.cpp
@@ -449,6 +449,11 @@ QString Navigator::createChildrenList( QTreeWidgetItem *child, int level )
for (int i=0;i<cc;i++)
{
NavigatorItem *childItem = static_cast<NavigatorItem *>( child->child(i) );
+ if ((childItem->childCount() == 0) && (childItem->skipInContentsIfEmpty()))
+ {
+ // skip items with no children if item allows it
+ continue;
+ }
DocEntry *e = childItem->entry();
diff --git a/khelpcenter/navigatorappgroupitem.cpp b/khelpcenter/navigatorappgroupitem.cpp
index f4139878..69b7cfce 100644
--- a/khelpcenter/navigatorappgroupitem.cpp
+++ b/khelpcenter/navigatorappgroupitem.cpp
@@ -145,4 +145,9 @@ QString NavigatorAppGroupItem::documentationURL( const KService *s )
return QStringLiteral( "help:/" ) + docPath;
}
+bool NavigatorAppGroupItem::skipInContentsIfEmpty() const
+{
+ return true;
+}
+
// vim:ts=2:sw=2:et
diff --git a/khelpcenter/navigatorappgroupitem.h b/khelpcenter/navigatorappgroupitem.h
index 55d4fe54..106fc983 100644
--- a/khelpcenter/navigatorappgroupitem.h
+++ b/khelpcenter/navigatorappgroupitem.h
@@ -45,6 +45,8 @@ class NavigatorAppGroupItem : public NavigatorItem
void itemExpanded(bool) override;
void populate( bool recursive = false );
+ virtual bool skipInContentsIfEmpty() const override;
+
protected:
static QString documentationURL( const KService *s );
diff --git a/khelpcenter/navigatorappitem.cpp b/khelpcenter/navigatorappitem.cpp
index 07297068..520bbbd3 100644
--- a/khelpcenter/navigatorappitem.cpp
+++ b/khelpcenter/navigatorappitem.cpp
@@ -124,4 +124,9 @@ void NavigatorAppItem::scheduleTOCBuild()
}
}
+bool NavigatorAppItem::skipInContentsIfEmpty() const
+{
+ return false;
+}
+
// vim:ts=2:sw=2:et
diff --git a/khelpcenter/navigatorappitem.h b/khelpcenter/navigatorappitem.h
index b9638b35..2b886231 100644
--- a/khelpcenter/navigatorappitem.h
+++ b/khelpcenter/navigatorappitem.h
@@ -41,6 +41,8 @@ class NavigatorAppItem : public NavigatorItem
void itemExpanded( bool open ) override;
+ virtual bool skipInContentsIfEmpty() const override;
+
private:
void scheduleTOCBuild();
diff --git a/khelpcenter/navigatoritem.cpp b/khelpcenter/navigatoritem.cpp
index 3ef3af16..42e07c5f 100644
--- a/khelpcenter/navigatoritem.cpp
+++ b/khelpcenter/navigatoritem.cpp
@@ -87,4 +87,9 @@ void NavigatorItem::itemExpanded( bool open )
Q_UNUSED( open );
}
+bool NavigatorItem::skipInContentsIfEmpty() const
+{
+ return true;
+}
+
// vim:ts=2:sw=2:et
diff --git a/khelpcenter/navigatoritem.h b/khelpcenter/navigatoritem.h
index 2906bd24..0de966df 100644
--- a/khelpcenter/navigatoritem.h
+++ b/khelpcenter/navigatoritem.h
@@ -47,6 +47,8 @@ class NavigatorItem : public QTreeWidgetItem
virtual void itemExpanded( bool open );
+ virtual bool skipInContentsIfEmpty() const;
+
private:
void init( DocEntry * );
diff --git a/khelpcenter/toc.cpp b/khelpcenter/toc.cpp
index 15b77b9b..942f8274 100644
--- a/khelpcenter/toc.cpp
+++ b/khelpcenter/toc.cpp
@@ -44,6 +44,8 @@ class TOCItem : public NavigatorItem
const TOC *toc() const { return m_toc; }
+ virtual bool skipInContentsIfEmpty() const override;
+
private:
TOC *m_toc = nullptr;
};
@@ -273,6 +275,11 @@ TOCItem::TOCItem( TOC *toc, QTreeWidgetItem *parentItem, QTreeWidgetItem *after,
m_toc = toc;
}
+bool TOCItem::skipInContentsIfEmpty() const
+{
+ return false;
+}
+
TOCChapterItem::TOCChapterItem( TOC *toc, NavigatorItem *parent, QTreeWidgetItem *after,
const QString &title, const QString &name )
: TOCItem( toc, parent, after, title ),
--
2.25.4