From 9daf63403a699747aee426962fc8ccd433633bf0 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sat, 3 Aug 2019 00:45:42 +0200 Subject: [PATCH] WIP: lib-browser - icons for lib cells. --- src/edt/edt/edtServiceImpl.cc | 16 ++++++++++------ src/laybasic/laybasic/layCellTreeModel.cc | 11 +++++++++++ src/laybasic/laybasic/layCellTreeModel.h | 3 ++- src/laybasic/laybasic/layLibrariesView.cc | 4 ++-- 4 files changed, 25 insertions(+), 9 deletions(-) diff --git a/src/edt/edt/edtServiceImpl.cc b/src/edt/edt/edtServiceImpl.cc index dbc806d7c..7394fb1c5 100644 --- a/src/edt/edt/edtServiceImpl.cc +++ b/src/edt/edt/edtServiceImpl.cc @@ -1535,12 +1535,16 @@ InstService::configure (const std::string &name, const std::string &value) m_pcell_parameters.clear (); m_is_pcell = ex.test ("!") || ! ex.at_end (); - while (! ex.at_end ()) { - std::string n; - ex.read_word_or_quoted (n); - ex.test (":"); - ex.read (m_pcell_parameters.insert (std::make_pair (n, tl::Variant ())).first->second); - ex.test (";"); + try { + while (! ex.at_end ()) { + std::string n; + ex.read_word_or_quoted (n); + ex.test (":"); + ex.read (m_pcell_parameters.insert (std::make_pair (n, tl::Variant ())).first->second); + ex.test (";"); + } + } catch (...) { + // ignore errors } m_needs_update = true; diff --git a/src/laybasic/laybasic/layCellTreeModel.cc b/src/laybasic/laybasic/layCellTreeModel.cc index 71d79ac8f..3f351af9b 100644 --- a/src/laybasic/laybasic/layCellTreeModel.cc +++ b/src/laybasic/laybasic/layCellTreeModel.cc @@ -737,6 +737,17 @@ CellTreeModel::data (const QModelIndex &index, int role) const return QVariant (); #endif + } else if (role == Qt::DecorationRole && (m_flags & WithIcons) != 0) { + + // TODO: icons for normal cells too? + if (item->is_pcell ()) { + QIcon icon (":/setup.png"); + return QVariant (icon); + } else { + QIcon icon (":/instance.png"); + return QVariant (icon); + } + } else { return QVariant (); diff --git a/src/laybasic/laybasic/layCellTreeModel.h b/src/laybasic/laybasic/layCellTreeModel.h index 97d2f738f..966693e43 100644 --- a/src/laybasic/laybasic/layCellTreeModel.h +++ b/src/laybasic/laybasic/layCellTreeModel.h @@ -67,7 +67,8 @@ public: TopCells = 8, // show top cells only BasicCells = 16, // show basic cells (PCells included, no proxies) WithVariants = 32, // show PCell variants below PCells - NoPadding = 64 // disable padding of display string with a blank at the beginning and end + WithIcons = 64, // show icons for the top level cell type + NoPadding = 128 // disable padding of display string with a blank at the beginning and end }; enum Sorting { diff --git a/src/laybasic/laybasic/layLibrariesView.cc b/src/laybasic/laybasic/layLibrariesView.cc index 77429e839..4b8602927 100644 --- a/src/laybasic/laybasic/layLibrariesView.cc +++ b/src/laybasic/laybasic/layLibrariesView.cc @@ -790,7 +790,7 @@ LibrariesView::do_update_content (int lib_index) LibraryTreeWidget *cell_list = new LibraryTreeWidget (cl_frame, "tree", mp_view->view_object_widget ()); cl_ly->addWidget (cell_list); - cell_list->setModel (new CellTreeModel (cell_list, m_libraries [i].get (), CellTreeModel::Flat | CellTreeModel::TopCells | CellTreeModel::BasicCells | CellTreeModel::WithVariants, 0)); + cell_list->setModel (new CellTreeModel (cell_list, m_libraries [i].get (), CellTreeModel::Flat | CellTreeModel::TopCells | CellTreeModel::BasicCells | CellTreeModel::WithVariants | CellTreeModel::WithIcons, 0)); cell_list->setUniformRowHeights (true); pl = cell_list->palette (); @@ -865,7 +865,7 @@ LibrariesView::do_update_content (int lib_index) CellTreeModel *model = dynamic_cast (mp_cell_lists [i]->model ()); if (model) { - model->configure (m_libraries [i].get (), CellTreeModel::Flat | CellTreeModel::TopCells | CellTreeModel::BasicCells | CellTreeModel::WithVariants, 0); + model->configure (m_libraries [i].get (), CellTreeModel::Flat | CellTreeModel::TopCells | CellTreeModel::BasicCells | CellTreeModel::WithVariants | CellTreeModel::WithIcons, 0); } }