Merge pull request #435 from KLayout/issue-429

Issue 429
This commit is contained in:
Matthias Köfferlein
2019-12-02 21:15:05 +01:00
committed by GitHub
288 changed files with 67702 additions and 122 deletions
+17
View File
@@ -226,6 +226,9 @@ LayoutHandle::set_tech_name (const std::string &tn)
} else {
m_tech_name = std::string ();
}
if (mp_layout) {
mp_layout->add_meta_info (db::MetaInfo ("technology", tl::to_string (tr ("Technology name")), tn));
}
technology_changed_event ();
}
}
@@ -339,6 +342,14 @@ LayoutHandle::load (const db::LoadLayoutOptions &options, const std::string &tec
db::Reader reader (stream);
db::LayerMap new_lmap = reader.read (layout (), m_load_options);
// If there is no technology given and the reader reports one, use this one
if (technology.empty ()) {
std::string tech_from_reader = layout ().meta_info_value ("technology");
if (! tech_from_reader.empty ()) {
set_tech_name (tech_from_reader);
}
}
// Update the file's data:
file_watcher ().remove_file (filename ());
file_watcher ().add_file (filename ());
@@ -358,6 +369,12 @@ LayoutHandle::load ()
db::Reader reader (stream);
db::LayerMap new_lmap = reader.read (layout (), m_load_options);
// Attach the technology from the reader if it reports one
std::string tech_from_reader = layout ().meta_info_value ("technology");
if (! tech_from_reader.empty ()) {
set_tech_name (tech_from_reader);
}
// Update the file's data:
file_watcher ().remove_file (filename ());
file_watcher ().add_file (filename ());
+2 -2
View File
@@ -475,7 +475,7 @@ LibrariesView::search_editing_finished ()
}
void
LibrariesView::middle_clicked (const QModelIndex &index)
LibrariesView::middle_clicked (const QModelIndex & /*index*/)
{
// ... nothing yet ..
}
@@ -493,7 +493,7 @@ LibrariesView::clicked (const QModelIndex & /*index*/)
}
void
LibrariesView::double_clicked (const QModelIndex &index)
LibrariesView::double_clicked (const QModelIndex & /*index*/)
{
// ... nothing yet ..
}
+145
View File
@@ -1143,5 +1143,150 @@ void DecoratedLineEdit::resizeEvent (QResizeEvent * /*event*/)
}
}
// -------------------------------------------------------------
// InteractiveListWidget implementation
InteractiveListWidget::InteractiveListWidget (QWidget *parent)
: QListWidget (parent)
{
setSelectionMode (QAbstractItemView::ExtendedSelection);
setDragDropMode (QAbstractItemView::InternalMove);
}
void
InteractiveListWidget::set_values (const std::vector<std::string> &values)
{
clear ();
add_values (values);
}
std::vector<std::string>
InteractiveListWidget::get_values ()
{
std::vector<std::string> v;
v.reserve ((size_t) count ());
for (int i = 0; i < count (); ++i) {
v.push_back (tl::to_string (item (i)->text ()));
}
return v;
}
void
InteractiveListWidget::add_value (const std::string &value)
{
addItem (tl::to_qstring (value));
refresh_flags ();
clearSelection ();
setCurrentItem (item (count () - 1));
}
void
InteractiveListWidget::add_values (const std::vector<std::string> &values)
{
for (std::vector<std::string>::const_iterator i = values.begin (); i != values.end (); ++i) {
addItem (tl::to_qstring (*i));
}
refresh_flags ();
clearSelection ();
}
void
InteractiveListWidget::delete_selected_items ()
{
QStringList items;
for (int i = 0; i < count (); ++i) {
if (! item (i)->isSelected ()) {
items.push_back (item (i)->text ());
}
}
clear ();
for (QStringList::const_iterator f = items.begin (); f != items.end (); ++f) {
addItem (*f);
}
refresh_flags ();
}
void
InteractiveListWidget::move_selected_items_up ()
{
std::set<QString> selected;
for (int i = 0; i < count (); ++i) {
if (item (i)->isSelected ()) {
selected.insert (item (i)->text ());
}
}
QStringList items;
int j = -1;
for (int i = 0; i < count (); ++i) {
if (item (i)->isSelected ()) {
items.push_back (item (i)->text ());
} else {
if (j >= 0) {
items.push_back (item (j)->text ());
}
j = i;
}
}
if (j >= 0) {
items.push_back (item (j)->text ());
}
clear ();
for (QStringList::const_iterator f = items.begin (); f != items.end (); ++f) {
addItem (*f);
if (selected.find (*f) != selected.end ()) {
item (count () - 1)->setSelected (true);
}
}
refresh_flags ();
}
void
InteractiveListWidget::move_selected_items_down ()
{
std::set<QString> selected;
for (int i = 0; i < count (); ++i) {
if (item (i)->isSelected ()) {
selected.insert (item (i)->text ());
}
}
QStringList items;
int j = -1;
for (int i = count (); i > 0; ) {
--i;
if (item (i)->isSelected ()) {
items.push_back (item (i)->text ());
} else {
if (j >= 0) {
items.push_back (item (j)->text ());
}
j = i;
}
}
if (j >= 0) {
items.push_back (item (j)->text ());
}
clear ();
for (QStringList::const_iterator f = items.end (); f != items.begin (); ) {
--f;
addItem (*f);
if (selected.find (*f) != selected.end ()) {
item (count () - 1)->setSelected (true);
}
}
refresh_flags ();
}
void
InteractiveListWidget::refresh_flags ()
{
for (int i = 0; i < count (); ++i) {
item (i)->setFlags (Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsDragEnabled);
}
}
}
+57
View File
@@ -31,6 +31,7 @@
#include <QLabel>
#include <QLineEdit>
#include <QProxyStyle>
#include <QListWidget>
#include <string>
namespace db
@@ -460,6 +461,62 @@ private:
int m_default_left_margin, m_default_right_margin;
};
/**
* @brief An interactive liste widget which offers slots to delete and move items and interfaces to std::vector<std::string>
*/
class LAYBASIC_PUBLIC InteractiveListWidget
: public QListWidget
{
Q_OBJECT
public:
/**
* @brief Constructor
*/
InteractiveListWidget (QWidget *parent = 0);
/**
* @brief Sets the items in the widget
*/
void set_values (const std::vector<std::string> &values);
/**
* @brief Gets the items in the widget
*/
std::vector<std::string> get_values ();
/**
* @brief Adds a value
*/
void add_value (const std::string &value);
/**
* @brief Adds values
*/
void add_values (const std::vector<std::string> &values);
private slots:
/**
* @brief Deletes the selected items
*/
void delete_selected_items ();
/**
* @brief Moves the selected items up
*/
void move_selected_items_up ();
/**
* @brief Moves the selected items down
*/
void move_selected_items_down ();
private:
void refresh_flags ();
bool m_drag_and_drop_enabled;
};
} // namespace lay
#endif