From 35aaf63051436b7dba4ba51728a89ec646739e19 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sat, 24 Sep 2022 19:53:31 +0200 Subject: [PATCH] As suggested by Eugene: close left/close right added to macro editor's tab tab ... layout views will follow --- src/lay/lay/layMacroEditorDialog.cc | 33 +++++++++++++++++++++++++++-- src/lay/lay/layMacroEditorDialog.h | 3 +++ 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/src/lay/lay/layMacroEditorDialog.cc b/src/lay/lay/layMacroEditorDialog.cc index a09fef3d6..1a4934eb4 100644 --- a/src/lay/lay/layMacroEditorDialog.cc +++ b/src/lay/lay/layMacroEditorDialog.cc @@ -400,6 +400,12 @@ MacroEditorDialog::MacroEditorDialog (lay::Dispatcher *pr, lym::MacroCollection action = new QAction (tr ("Close All Except Current"), this); connect (action, SIGNAL (triggered ()), this, SLOT (close_all_but_current ())); tabWidget->addAction (action); + action = new QAction (tr ("Close All Left"), this); + connect (action, SIGNAL (triggered ()), this, SLOT (close_all_left ())); + tabWidget->addAction (action); + action = new QAction (tr ("Close All Right"), this); + connect (action, SIGNAL (triggered ()), this, SLOT (close_all_right ())); + tabWidget->addAction (action); dbgOn->setEnabled (true); runButton->setEnabled (true); @@ -2264,6 +2270,24 @@ END_PROTECTED void MacroEditorDialog::close_all_but_current () +{ + close_many (0); +} + +void +MacroEditorDialog::close_all_left () +{ + close_many (-1); +} + +void +MacroEditorDialog::close_all_right () +{ + close_many (1); +} + +void +MacroEditorDialog::close_many (int r2c) { if (m_in_exec) { return; @@ -2279,9 +2303,14 @@ BEGIN_PROTECTED return; } + std::set removed; + for (int i = tabWidget->count (); i > 0; ) { --i; - if (i != ci) { + if ((r2c == 0 && i != ci) || + (r2c < 0 && i < ci) || + (r2c > 0 && i > ci)) { + removed.insert (tabWidget->widget (i)); tabWidget->removeTab (i); } } @@ -2289,7 +2318,7 @@ BEGIN_PROTECTED std::map new_widgets; for (std::map ::iterator p = m_tab_widgets.begin (); p != m_tab_widgets.end (); ++p) { - if (cw && p->second == cw) { + if (removed.find (p->second) == removed.end ()) { new_widgets.insert (*p); } else { if (p->second) { diff --git a/src/lay/lay/layMacroEditorDialog.h b/src/lay/lay/layMacroEditorDialog.h index e3c14c68d..eec5e0f24 100644 --- a/src/lay/lay/layMacroEditorDialog.h +++ b/src/lay/lay/layMacroEditorDialog.h @@ -214,6 +214,8 @@ private slots: void tab_close_requested (int); void close_all (); void close_all_but_current (); + void close_all_left (); + void close_all_right (); void replace_mode_button_clicked (); void replace_next_button_clicked (); void replace_all_button_clicked (); @@ -264,6 +266,7 @@ private: void move_subfolder (lym::MacroCollection *source, lym::MacroCollection *target); lay::MacroEditorPage *create_page (lym::Macro *macro); void open_macro (lym::Macro *macro); + void close_many (int which_relative_to_current); void ensure_writeable_collection_selected (); void update_console_text (); void start_exec (gsi::Interpreter *interpreter);