Репозиторий Sisyphus
Последнее обновление: 1 октября 2023 | Пакетов: 18631 | Посещений: 37400803
en ru br
Репозитории ALT

Группа :: Графические оболочки/KDE
Пакет: kde5-khelpcenter

 Главная   Изменения   Спек   Патчи   Sources   Загрузить   Gear   Bugs and FR  Repocop 

Патч: khelpcenter-alt-contents-tree-synchronization.patch
Скачать


From 481a85141169819eb7b3b619e5c31b58a512328b Mon Sep 17 00:00:00 2001
From: Aleksei Nikiforov <darktemplar@altlinux.org>
Date: Fri, 28 Feb 2020 18:02:51 +0300
Subject: [PATCH] Contents tree: add fallback to URL without fragment
If URL has fragment, but no such URL with specified fragment
is present in contents tree, try to fallback to URL without any fragment
if such URL is present.
---
 khelpcenter/navigator.cpp | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/khelpcenter/navigator.cpp b/khelpcenter/navigator.cpp
index 770ef3fc..3debfcb9 100644
--- a/khelpcenter/navigator.cpp
+++ b/khelpcenter/navigator.cpp
@@ -291,10 +291,12 @@ void Navigator::selectItem( const QUrl &url )
   // Make sure that we match both the original URL as well as
   // its counterpart.
   QUrl alternativeURL = url;
+  QUrl contentsItemURL = url;
   if (url.hasFragment())
   {
      alternativeURL.setQuery(QStringLiteral("anchor=")+url.fragment());
      alternativeURL.setFragment(QString());
+     contentsItemURL.setFragment(QString());
   }
 
   // If the navigator already has the given URL selected, do nothing.
@@ -319,22 +321,32 @@ void Navigator::selectItem( const QUrl &url )
     }
   }
   
+  NavigatorItem *contentsItem = nullptr;
   QTreeWidgetItemIterator it( mContentsTree );
   while ( (*it) ) {
     NavigatorItem *item = static_cast<NavigatorItem *>( (*it) );
     QUrl itemUrl( item->entry()->url() );
     if ( (itemUrl == url) || (itemUrl == alternativeURL) ) {
-      mContentsTree->setCurrentItem( item );
       // If the current item was not selected and remained unchanged it
       // needs to be explicitly selected
       mContentsTree->setCurrentItem(item);
       item->setExpanded( true );
       break;
     }
+    if ( (contentsItem == nullptr) && (itemUrl == contentsItemURL) ) {
+      contentsItem = item;
+    }
     ++it;
   }
   if ( !(*it) ) {
-    clearSelection();
+    // if search with fragment didn't find anything, but item without fragment was found, use it
+    if ( contentsItem != nullptr ) {
+      mContentsTree->setCurrentItem(contentsItem);
+      item->setExpanded( true );
+      mSelected = true;
+    } else {
+      clearSelection();
+    }
   } else {
     mSelected = true;
   }
-- 
2.24.1
 
дизайн и разработка: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
текущий майнтейнер: Michael Shigorin