From a567002e6c225f7bbc0e4b96a1bb2aad6ca65fed Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Thu, 1 Aug 2019 23:15:07 +0200 Subject: [PATCH] Search feature for library browser plus two bugfixes Bugfixes: 1.) A crash due to wrong key_event_handler pointer (relevant for hierarchy view) 2.) When switching cellview the focus wasn't changed and selection stayed in old cellview --- .../laybasic/layHierarchyControlPanel.cc | 9 ++++++++ src/laybasic/laybasic/layLayoutView.cc | 22 +++++++++---------- src/laybasic/laybasic/layLibrariesView.cc | 15 ++++++++----- 3 files changed, 30 insertions(+), 16 deletions(-) diff --git a/src/laybasic/laybasic/layHierarchyControlPanel.cc b/src/laybasic/laybasic/layHierarchyControlPanel.cc index f8e391e7e..5a239f8fa 100644 --- a/src/laybasic/laybasic/layHierarchyControlPanel.cc +++ b/src/laybasic/laybasic/layHierarchyControlPanel.cc @@ -526,6 +526,10 @@ HierarchyControlPanel::search_prev () void HierarchyControlPanel::search_editing_finished () { + if (! mp_search_frame->isVisible ()) { + return; + } + for (std::vector ::const_iterator v = mp_cell_lists.begin (); v != mp_cell_lists.end (); ++v) { CellTreeModel *m = dynamic_cast ((*v)->model ()); if (m) { @@ -733,6 +737,8 @@ HierarchyControlPanel::selection_changed (int index) { if (index != m_active_index) { + search_editing_finished (); + m_active_index = index; bool split_mode = m_split_mode; @@ -744,6 +750,9 @@ HierarchyControlPanel::selection_changed (int index) int i = 0; for (std::vector ::const_iterator f = mp_cell_list_frames.begin (); f != mp_cell_list_frames.end (); ++f, ++i) { (*f)->setVisible (i == index || split_mode); + if (i == index) { + mp_cell_lists [i]->setFocus (); + } } i = 0; diff --git a/src/laybasic/laybasic/layLayoutView.cc b/src/laybasic/laybasic/layLayoutView.cc index d4a17e0b7..d91e38439 100644 --- a/src/laybasic/laybasic/layLayoutView.cc +++ b/src/laybasic/laybasic/layLayoutView.cc @@ -449,6 +449,17 @@ LayoutView::init (db::Manager *mgr, lay::PluginRoot *root, QWidget * /*parent*/) vbl->setMargin (0); vbl->setSpacing (0); + mp_canvas = new lay::LayoutCanvas (this, this); + vbl->addWidget (mp_canvas); + connect (mp_canvas, SIGNAL (left_arrow_key_pressed ()), this, SLOT (pan_left ())); + connect (mp_canvas, SIGNAL (up_arrow_key_pressed ()), this, SLOT (pan_up ())); + connect (mp_canvas, SIGNAL (right_arrow_key_pressed ()), this, SLOT (pan_right ())); + connect (mp_canvas, SIGNAL (down_arrow_key_pressed ()), this, SLOT (pan_down ())); + connect (mp_canvas, SIGNAL (left_arrow_key_pressed_with_shift ()), this, SLOT (pan_left_fast ())); + connect (mp_canvas, SIGNAL (up_arrow_key_pressed_with_shift ()), this, SLOT (pan_up_fast ())); + connect (mp_canvas, SIGNAL (right_arrow_key_pressed_with_shift ()), this, SLOT (pan_right_fast ())); + connect (mp_canvas, SIGNAL (down_arrow_key_pressed_with_shift ()), this, SLOT (pan_down_fast ())); + if ((m_options & LV_NoHierarchyPanel) == 0 && (m_options & LV_Naked) == 0) { QFrame *hierarchy_frame = new QFrame (0); @@ -514,17 +525,6 @@ LayoutView::init (db::Manager *mgr, lay::PluginRoot *root, QWidget * /*parent*/) } - mp_canvas = new lay::LayoutCanvas (this, this); - vbl->addWidget (mp_canvas); - connect (mp_canvas, SIGNAL (left_arrow_key_pressed ()), this, SLOT (pan_left ())); - connect (mp_canvas, SIGNAL (up_arrow_key_pressed ()), this, SLOT (pan_up ())); - connect (mp_canvas, SIGNAL (right_arrow_key_pressed ()), this, SLOT (pan_right ())); - connect (mp_canvas, SIGNAL (down_arrow_key_pressed ()), this, SLOT (pan_down ())); - connect (mp_canvas, SIGNAL (left_arrow_key_pressed_with_shift ()), this, SLOT (pan_left_fast ())); - connect (mp_canvas, SIGNAL (up_arrow_key_pressed_with_shift ()), this, SLOT (pan_up_fast ())); - connect (mp_canvas, SIGNAL (right_arrow_key_pressed_with_shift ()), this, SLOT (pan_right_fast ())); - connect (mp_canvas, SIGNAL (down_arrow_key_pressed_with_shift ()), this, SLOT (pan_down_fast ())); - // occupy services and editables: // these services get deleted by the canvas destructor automatically: if ((m_options & LV_NoTracker) == 0) { diff --git a/src/laybasic/laybasic/layLibrariesView.cc b/src/laybasic/laybasic/layLibrariesView.cc index e43dc03a3..bd990e7eb 100644 --- a/src/laybasic/laybasic/layLibrariesView.cc +++ b/src/laybasic/laybasic/layLibrariesView.cc @@ -413,7 +413,6 @@ void LibrariesView::search_triggered (const QString &t) { mp_search_model = 0; -#if 0 // @@@ lay::LibraryTreeWidget *w = dynamic_cast (sender ()); if (w) { for (size_t i = 0; i < mp_cell_lists.size (); ++i) { @@ -425,7 +424,6 @@ LibrariesView::search_triggered (const QString &t) } } } -#endif // @@@ if (mp_search_model) { mp_search_close_cb->setChecked (true); @@ -491,6 +489,10 @@ LibrariesView::search_prev () void LibrariesView::search_editing_finished () { + if (! mp_search_frame->isVisible ()) { + return; + } + for (std::vector ::const_iterator v = mp_cell_lists.begin (); v != mp_cell_lists.end (); ++v) { CellTreeModel *m = dynamic_cast ((*v)->model ()); if (m) { @@ -498,7 +500,6 @@ LibrariesView::search_editing_finished () } } -#if 0 // @@@ // give back the focus to the cell list for (size_t i = 0; i < mp_cell_lists.size (); ++i) { if (mp_cell_lists [i]->model () == mp_search_model) { @@ -506,7 +507,6 @@ LibrariesView::search_editing_finished () break; } } -#endif mp_search_frame->hide (); mp_search_model = 0; @@ -816,8 +816,8 @@ LibrariesView::do_update_content (int lib_index) connect (cell_list, SIGNAL (cell_clicked (const QModelIndex &)), this, SLOT (clicked (const QModelIndex &))); connect (cell_list, SIGNAL (cell_double_clicked (const QModelIndex &)), this, SLOT (double_clicked (const QModelIndex &))); connect (cell_list, SIGNAL (cell_middle_clicked (const QModelIndex &)), this, SLOT (middle_clicked (const QModelIndex &))); - connect (cell_list, SIGNAL (search_triggered (const QString &)), this, SLOT (search_triggered (const QString &))); #endif + connect (cell_list, SIGNAL (search_triggered (const QString &)), this, SLOT (search_triggered (const QString &))); mp_cell_lists.push_back (cell_list); mp_cell_list_frames.push_back (cl_frame); @@ -920,6 +920,8 @@ LibrariesView::selection_changed (int index) { if (index != m_active_index) { + search_editing_finished (); + m_active_index = index; bool split_mode = m_split_mode; @@ -931,6 +933,9 @@ LibrariesView::selection_changed (int index) int i = 0; for (std::vector ::const_iterator f = mp_cell_list_frames.begin (); f != mp_cell_list_frames.end (); ++f, ++i) { (*f)->setVisible (i == index || split_mode); + if (i == index) { + mp_cell_lists [i]->setFocus (); + } } i = 0;