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
This commit is contained in:
Matthias Koefferlein 2019-08-01 23:15:07 +02:00
parent 4428ef808b
commit a567002e6c
3 changed files with 30 additions and 16 deletions

View File

@ -526,6 +526,10 @@ HierarchyControlPanel::search_prev ()
void
HierarchyControlPanel::search_editing_finished ()
{
if (! mp_search_frame->isVisible ()) {
return;
}
for (std::vector <QTreeView *>::const_iterator v = mp_cell_lists.begin (); v != mp_cell_lists.end (); ++v) {
CellTreeModel *m = dynamic_cast<CellTreeModel *> ((*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 <QFrame *>::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;

View File

@ -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) {

View File

@ -413,7 +413,6 @@ void
LibrariesView::search_triggered (const QString &t)
{
mp_search_model = 0;
#if 0 // @@@
lay::LibraryTreeWidget *w = dynamic_cast<lay::LibraryTreeWidget *> (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 <QTreeView *>::const_iterator v = mp_cell_lists.begin (); v != mp_cell_lists.end (); ++v) {
CellTreeModel *m = dynamic_cast<CellTreeModel *> ((*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 <QFrame *>::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;