Technology specific libraries

Libraries now carry a technology association and
only libraries associated with the current technology
can be selected.

To enforce proper update, cancel() will be used upon
change of technology. This avoids side effects when
changing the technology without notifying the library
selection widgets.

The MainWindow::cancel method has been generalized to
cover the functionality of cm_cancel without the
exception handling.
This commit is contained in:
Matthias Koefferlein
2017-04-23 19:30:55 +02:00
parent 01e5c607fc
commit 1091ea6d5b
11 changed files with 161 additions and 57 deletions
+31 -7
View File
@@ -230,7 +230,8 @@ struct CellViewSelectionComboBoxPrivateData
const lay::LayoutView *layout_view;
};
CellViewSelectionComboBox::CellViewSelectionComboBox (QWidget * /*parent*/)
CellViewSelectionComboBox::CellViewSelectionComboBox (QWidget *parent)
: QComboBox (parent)
{
mp_private = new CellViewSelectionComboBoxPrivateData ();
mp_private->layout_view = 0;
@@ -299,7 +300,8 @@ struct LayerSelectionComboBoxPrivateData
int cv_index;
};
LayerSelectionComboBox::LayerSelectionComboBox (QWidget * /*parent*/)
LayerSelectionComboBox::LayerSelectionComboBox (QWidget *parent)
: QComboBox (parent)
{
mp_private = new LayerSelectionComboBoxPrivateData ();
mp_private->no_layer_available = false;
@@ -569,11 +571,22 @@ LayerSelectionComboBox::current_layer_props () const
// -------------------------------------------------------------
// LibrarySelectionComboBox implementation
LibrarySelectionComboBox::LibrarySelectionComboBox (QWidget * /*parent*/)
LibrarySelectionComboBox::LibrarySelectionComboBox (QWidget *parent)
: QComboBox (parent), m_tech_set (false)
{
update_list ();
}
void
LibrarySelectionComboBox::set_technology_filter (const std::string &tech, bool enabled)
{
if (m_tech != tech || m_tech_set != enabled) {
m_tech = tech;
m_tech_set = enabled;
update_list ();
}
}
void
LibrarySelectionComboBox::update_list ()
{
@@ -585,12 +598,23 @@ LibrarySelectionComboBox::update_list ()
addItem (QObject::tr ("Local (no library)"), QVariant ());
for (db::LibraryManager::iterator l = db::LibraryManager::instance ().begin (); l != db::LibraryManager::instance ().end (); ++l) {
db::Library *lib = db::LibraryManager::instance ().lib (l->second);
if (! lib->get_description ().empty ()) {
addItem (tl::to_qstring (lib->get_name () + " - " + lib->get_description ()), QVariant ((unsigned int) lib->get_id ()));
} else {
addItem (tl::to_qstring (lib->get_name ()), QVariant ((unsigned int) lib->get_id ()));
if (! m_tech_set || lib->get_technology ().empty () || m_tech == lib->get_technology ()) {
std::string item_text = lib->get_name ();
if (! lib->get_description ().empty ()) {
item_text += " - " + lib->get_description ();
}
if (m_tech_set && !lib->get_technology ().empty ()) {
item_text += " ";
item_text += tl::to_string (QObject::tr ("[Technology %1]").arg (tl::to_qstring (lib->get_technology ())));
}
addItem (tl::to_qstring (item_text), QVariant ((unsigned int) lib->get_id ()));
}
}
set_current_library (lib);
+13
View File
@@ -147,6 +147,19 @@ public:
* @brief Update the list of libraries
*/
void update_list ();
/**
* @brief Sets the technology filter
*
* If a technology filter is set, only the libraries associated with the given
* technology are shown. If enable is false, the technology name is ignored and
* all libraries are shown.
*/
void set_technology_filter (const std::string &tech, bool enable);
private:
std::string m_tech;
bool m_tech_set;
};
/**