[PATCH 1/8] SymbolView: Fix broken toggle actions

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


- Add checkboxes to the toggle actions. This does not only help to fix the
  broken behavior but also give the user a hint of current setting
- Reorder actions in the menu just because I think it's better

It looks to me the variables macro_on, struct_on, func_on are obsolete
and could be removed, but that would need to review all parsers
---
 .../symbolviewer/plugin_katesymbolviewer.cpp  | 43 ++++++++-----------
 1 file changed, 19 insertions(+), 24 deletions(-)

diff --git a/addons/symbolviewer/plugin_katesymbolviewer.cpp b/addons/symbolviewer/plugin_katesymbolviewer.cpp
index 7beb935d8..309086486 100644
--- a/addons/symbolviewer/plugin_katesymbolviewer.cpp
+++ b/addons/symbolviewer/plugin_katesymbolviewer.cpp
@@ -82,14 +82,18 @@ KatePluginSymbolViewerView::KatePluginSymbolViewerView(KTextEditor::Plugin *plug
   m_symbols = nullptr;
 
   m_popup = new QMenu(m_symbols);
-  m_popup->addAction(i18n("Refresh List"), this, SLOT(slotRefreshSymbol()));
+  m_popup->addAction(i18n("List/Tree Mode"), this, SLOT(slotChangeMode()));
+  m_sort = m_popup->addAction(i18n("Show Sorted"), this, SLOT(slotEnableSorting()));
+  m_sort->setCheckable(true);
   m_popup->addSeparator();
   m_macro = m_popup->addAction(i18n("Show Macros"), this, SLOT(toggleShowMacros()));
+  m_macro->setCheckable(true);
   m_struct = m_popup->addAction(i18n("Show Structures"), this, SLOT(toggleShowStructures()));
+  m_struct->setCheckable(true);
   m_func = m_popup->addAction(i18n("Show Functions"), this, SLOT(toggleShowFunctions()));
+  m_func->setCheckable(true);
   m_popup->addSeparator();
-  m_popup->addAction(i18n("List/Tree Mode"), this, SLOT(slotChangeMode()));
-  m_sort = m_popup->addAction(i18n("Enable Sorting"), this, SLOT(slotEnableSorting()));
+  m_popup->addAction(i18n("Refresh List"), this, SLOT(slotRefreshSymbol()));
 
   KConfigGroup config(KSharedConfig::openConfig(), "PluginSymbolViewer");
   m_plugin->typesOn = config.readEntry(QLatin1String("ViewTypes"), false);
@@ -159,26 +163,20 @@ KatePluginSymbolViewerView::~KatePluginSymbolViewerView()
 
 void KatePluginSymbolViewerView::toggleShowMacros(void)
 {
- bool s = !m_macro->isChecked();
- m_macro->setChecked(s);
- macro_on = s;
- slotRefreshSymbol();
+  macro_on = m_macro->isChecked();
+  slotRefreshSymbol();
 }
 
 void KatePluginSymbolViewerView::toggleShowStructures(void)
 {
- bool s = !m_struct->isChecked();
- m_struct->setChecked(s);
- struct_on = s;
- slotRefreshSymbol();
+  struct_on = m_struct->isChecked();
+  slotRefreshSymbol();
 }
 
 void KatePluginSymbolViewerView::toggleShowFunctions(void)
 {
- bool s = !m_func->isChecked();
- m_func->setChecked(s);
- func_on = s;
- slotRefreshSymbol();
+  func_on = m_func->isChecked();
+  slotRefreshSymbol();
 }
 
 void KatePluginSymbolViewerView::slotRefreshSymbol()
@@ -206,16 +204,13 @@ void KatePluginSymbolViewerView::slotChangeMode()
 
 void KatePluginSymbolViewerView::slotEnableSorting()
 {
- m_plugin->sortOn = !m_plugin->sortOn;
- m_sort->setChecked(m_plugin->sortOn);
- m_symbols->clear();
- if (m_plugin->sortOn == true)
-     m_symbols->setSortingEnabled(true);
- else
-     m_symbols->setSortingEnabled(false);
+  m_plugin->sortOn = m_sort->isChecked();
+  m_symbols->clear();
+  m_symbols->setSortingEnabled(m_sort->isChecked());
 
- parseSymbols();
- if (m_plugin->sortOn == true) m_symbols->sortItems(0, Qt::AscendingOrder);
+  parseSymbols();
+  if (m_sort->isChecked())
+    m_symbols->sortItems(0, Qt::AscendingOrder);
 }
 
 void KatePluginSymbolViewerView::slotDocChanged()
-- 
2.18.0



More information about the KWrite-Devel mailing list