mirror of https://github.com/KLayout/klayout.git
Bug fixes on cell name search feature.
This commit is contained in:
parent
71a7326fe9
commit
423dddae62
|
|
@ -450,6 +450,8 @@ CellTreeModel::do_configure (db::Layout *layout, db::Library *library, lay::Layo
|
|||
|
||||
} else {
|
||||
|
||||
emit layoutAboutToBeChanged ();
|
||||
|
||||
// Translate persistent indexes: translation happens according to the path given by
|
||||
// a sequence of cell indexes.
|
||||
|
||||
|
|
@ -511,9 +513,9 @@ CellTreeModel::do_configure (db::Layout *layout, db::Library *library, lay::Layo
|
|||
|
||||
changePersistentIndexList (indexes, new_indexes);
|
||||
|
||||
}
|
||||
emit layoutChanged ();
|
||||
|
||||
signal_data_changed ();
|
||||
}
|
||||
|
||||
// TODO: harden against exceptions
|
||||
for (std::vector<lay::CellTreeItem *>::iterator t = old_toplevel_items.begin (); t != old_toplevel_items.end (); ++t) {
|
||||
|
|
@ -541,6 +543,7 @@ CellTreeModel::set_sorting (Sorting s)
|
|||
void
|
||||
CellTreeModel::signal_data_changed ()
|
||||
{
|
||||
emit layoutAboutToBeChanged ();
|
||||
emit layoutChanged ();
|
||||
}
|
||||
|
||||
|
|
@ -1043,7 +1046,22 @@ CellTreeModel::clear_locate ()
|
|||
m_current_index = m_selected_indexes.begin ();
|
||||
m_selected_indexes_set.clear ();
|
||||
|
||||
signal_data_changed ();
|
||||
emit layoutAboutToBeChanged ();
|
||||
|
||||
if (m_filter_mode) {
|
||||
|
||||
QModelIndexList indexes = persistentIndexList ();
|
||||
|
||||
QModelIndexList new_indexes;
|
||||
for (QModelIndexList::iterator i = indexes.begin (); i != indexes.end (); ++i) {
|
||||
new_indexes.push_back (model_index ((CellTreeItem *) i->internalPointer ()));
|
||||
}
|
||||
|
||||
changePersistentIndexList (indexes, new_indexes);
|
||||
|
||||
}
|
||||
|
||||
emit layoutChanged ();
|
||||
}
|
||||
|
||||
QModelIndex
|
||||
|
|
@ -1141,20 +1159,21 @@ CellTreeModel::search_children (const tl::GlobPattern &pattern, CellTreeItem *it
|
|||
|
||||
bool visible = false;
|
||||
|
||||
c->set_tree_index (std::numeric_limits<size_t>::max ());
|
||||
if (c->name_matches (pattern)) {
|
||||
c->set_tree_index (ti);
|
||||
m_selected_indexes.push_back (model_index (c));
|
||||
visible = true;
|
||||
}
|
||||
if (search_children (pattern, c)) {
|
||||
c->set_tree_index (ti);
|
||||
visible = true;
|
||||
}
|
||||
|
||||
if (visible) {
|
||||
c->set_tree_index (ti++);
|
||||
++ti;
|
||||
m_visible_cell_set.insert (c);
|
||||
any = true;
|
||||
} else {
|
||||
c->set_tree_index (std::numeric_limits<size_t>::max ());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1171,7 +1190,15 @@ CellTreeModel::locate (const char *name, bool glob_pattern, bool case_sensitive,
|
|||
return QModelIndex ();
|
||||
}
|
||||
|
||||
emit layoutAboutToBeChanged ();
|
||||
|
||||
QModelIndexList indexes = persistentIndexList ();
|
||||
std::vector<CellTreeItem *> persistent_index_cells;
|
||||
persistent_index_cells.reserve (indexes.size ());
|
||||
|
||||
for (QModelIndexList::iterator i = indexes.begin (); i != indexes.end (); ++i) {
|
||||
persistent_index_cells.push_back ((CellTreeItem *) i->internalPointer ());
|
||||
}
|
||||
|
||||
m_selected_indexes.clear ();
|
||||
m_visible_cell_set.clear ();
|
||||
|
|
@ -1187,19 +1214,20 @@ CellTreeModel::locate (const char *name, bool glob_pattern, bool case_sensitive,
|
|||
|
||||
bool visible = false;
|
||||
|
||||
(*lc)->set_tree_index (std::numeric_limits<size_t>::max ());
|
||||
if ((*lc)->name_matches (p)) {
|
||||
(*lc)->set_tree_index (ti);
|
||||
m_selected_indexes.push_back (model_index (*lc));
|
||||
visible = true;
|
||||
}
|
||||
if (! top_only && search_children (p, *lc)) {
|
||||
(*lc)->set_tree_index (ti);
|
||||
visible = true;
|
||||
}
|
||||
|
||||
if (visible) {
|
||||
(*lc)->set_tree_index (ti++);
|
||||
++ti;
|
||||
m_visible_cell_set.insert (*lc);
|
||||
} else {
|
||||
(*lc)->set_tree_index (std::numeric_limits<size_t>::max ());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1215,10 +1243,9 @@ CellTreeModel::locate (const char *name, bool glob_pattern, bool case_sensitive,
|
|||
|
||||
QModelIndexList new_indexes;
|
||||
|
||||
for (QModelIndexList::iterator i = indexes.begin (); i != indexes.end (); ++i) {
|
||||
CellTreeItem *item = (CellTreeItem *) i->internalPointer ();
|
||||
if (m_visible_cell_set.find (item) != m_visible_cell_set.end ()) {
|
||||
new_indexes.push_back (model_index (item));
|
||||
for (std::vector<CellTreeItem *>::const_iterator item = persistent_index_cells.begin (); item != persistent_index_cells.end (); ++item) {
|
||||
if (m_visible_cell_set.find (*item) != m_visible_cell_set.end ()) {
|
||||
new_indexes.push_back (model_index (*item));
|
||||
} else {
|
||||
new_indexes.push_back (QModelIndex ());
|
||||
}
|
||||
|
|
@ -1228,7 +1255,7 @@ CellTreeModel::locate (const char *name, bool glob_pattern, bool case_sensitive,
|
|||
|
||||
}
|
||||
|
||||
signal_data_changed ();
|
||||
emit layoutChanged ();
|
||||
|
||||
// make the first selected one current
|
||||
|
||||
|
|
|
|||
|
|
@ -240,10 +240,6 @@ public:
|
|||
|
||||
/**
|
||||
* @brief Signal to the owner of the model that the data has changed
|
||||
*
|
||||
* Basically, this signal should be emitted by the model, if it knew that
|
||||
* something changed. However, in our current architecture, it does not. So we
|
||||
* need to tell the model that something has changed.
|
||||
*/
|
||||
void signal_data_changed ();
|
||||
|
||||
|
|
|
|||
|
|
@ -79,6 +79,17 @@ HCPCellTreeWidget::HCPCellTreeWidget (QWidget *parent, const char *name, QWidget
|
|||
setObjectName (QString::fromUtf8 (name));
|
||||
}
|
||||
|
||||
HCPCellTreeWidget::~HCPCellTreeWidget ()
|
||||
{
|
||||
// NOTE: this should not be required, but I got a strange crash on closing the app with Qt 5.12.8
|
||||
// after using changePersistentIndex inside the model when ~QTreeWidget tried to clean up it's
|
||||
// persistent indexes and only found a model which was deleted already.
|
||||
QAbstractItemModel *m = model ();
|
||||
if (m) {
|
||||
setModel (0);
|
||||
delete m;
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
HCPCellTreeWidget::event (QEvent *event)
|
||||
|
|
|
|||
|
|
@ -66,6 +66,7 @@ Q_OBJECT
|
|||
|
||||
public:
|
||||
HCPCellTreeWidget (QWidget *parent, const char *name, QWidget *key_event_receiver);
|
||||
~HCPCellTreeWidget ();
|
||||
|
||||
signals:
|
||||
void cell_clicked (const QModelIndex &);
|
||||
|
|
|
|||
Loading…
Reference in New Issue