[PATCH 5/8] SymbolView: Update current item and sorting after parsing

loh.tar loh.tar at googlemail.com
Sun Jul 22 14:05:16 BST 2018


This ensures that the view is always properly shown, also after switch
to tree view

- Remove "hack to get always apply sorting option to apply immediately"
- Remove unneeded update call in ctor "First Symbols parsing here..."
---
 .../symbolviewer/plugin_katesymbolviewer.cpp  | 21 ++++++-------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/addons/symbolviewer/plugin_katesymbolviewer.cpp b/addons/symbolviewer/plugin_katesymbolviewer.cpp
index bb75bb9ab..5db929b51 100644
--- a/addons/symbolviewer/plugin_katesymbolviewer.cpp
+++ b/addons/symbolviewer/plugin_katesymbolviewer.cpp
@@ -148,10 +148,6 @@ KatePluginSymbolViewerView::KatePluginSymbolViewerView(KTextEditor::Plugin *plug
   m_symbols->setIndentation(10);
 
   m_toolview->installEventFilter(this);
-
-  /* First Symbols parsing here...*/
-  QTimer::singleShot(10, this, SLOT(slotRefreshSymbol()));
-  if (m_plugin->sortOn == true) m_symbols->sortItems(0, Qt::AscendingOrder);
 }
 
 KatePluginSymbolViewerView::~KatePluginSymbolViewerView()
@@ -183,15 +179,8 @@ void KatePluginSymbolViewerView::slotRefreshSymbol()
 {
   if (!m_symbols)
     return;
-  
-  // hack to get always apply sorting option to apply immediately
-  if ((m_plugin->sortOn && !m_symbols->isSortingEnabled()) || (!m_plugin->sortOn && m_symbols->isSortingEnabled())) {
-    m_plugin->sortOn = !m_plugin->sortOn;
-    return slotEnableSorting();
-  }
-  
- parseSymbols();
- updateCurrTreeItem();
+
+  parseSymbols();
 }
 
 void KatePluginSymbolViewerView::slotChangeMode()
@@ -206,8 +195,6 @@ void KatePluginSymbolViewerView::slotEnableSorting()
   m_symbols->setSortingEnabled(m_sort->isChecked());
 
   parseSymbols();
-  if (m_sort->isChecked())
-    m_symbols->sortItems(0, Qt::AscendingOrder);
 }
 
 void KatePluginSymbolViewerView::slotDocChanged()
@@ -348,6 +335,10 @@ void KatePluginSymbolViewerView::parseSymbols(void)
      parseEcmaSymbols();
   else
     new QTreeWidgetItem(m_symbols,  QStringList(i18n("Sorry. Language not supported yet") ) );
+
+  updateCurrTreeItem();
+  if (m_sort->isChecked())
+    m_symbols->sortItems(0, Qt::AscendingOrder);
 }
 
 void KatePluginSymbolViewerView::goToSymbol(QTreeWidgetItem *it)
-- 
2.18.0



More information about the KWrite-Devel mailing list