mirror of https://github.com/KLayout/klayout.git
Bugfix: new package is selected after it is created
This commit is contained in:
parent
edf7caa2fb
commit
2f82a8d853
|
|
@ -556,6 +556,25 @@ SaltManagerDialog::edit_properties ()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
SaltManagerDialog::set_current_grain_by_name (const std::string ¤t)
|
||||||
|
{
|
||||||
|
SaltModel *model = dynamic_cast <SaltModel *> (salt_view->model ());
|
||||||
|
if (!model) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = model->rowCount (QModelIndex ()); i > 0; ) {
|
||||||
|
--i;
|
||||||
|
QModelIndex index = model->index (i, 0, QModelIndex ());
|
||||||
|
SaltGrain *g = model->grain_from_index (index);
|
||||||
|
if (g && g->name () == current) {
|
||||||
|
salt_view->setCurrentIndex (index);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SaltManagerDialog::create_grain ()
|
SaltManagerDialog::create_grain ()
|
||||||
{
|
{
|
||||||
|
|
@ -572,15 +591,12 @@ BEGIN_PROTECTED
|
||||||
// select the new one
|
// select the new one
|
||||||
SaltModel *model = dynamic_cast <SaltModel *> (salt_view->model ());
|
SaltModel *model = dynamic_cast <SaltModel *> (salt_view->model ());
|
||||||
if (model) {
|
if (model) {
|
||||||
for (int i = model->rowCount (QModelIndex ()); i > 0; ) {
|
|
||||||
--i;
|
// NOTE: this is basically redundant (because it happens in the background later
|
||||||
QModelIndex index = model->index (i, 0, QModelIndex ());
|
// through dm_update_models). But we need this now to establish the selection.
|
||||||
SaltGrain *g = model->grain_from_index (index);
|
model->update();
|
||||||
if (g && g->name () == target.name ()) {
|
|
||||||
salt_view->setCurrentIndex (index);
|
set_current_grain_by_name (target.name ());
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -675,6 +691,15 @@ SaltManagerDialog::update_models ()
|
||||||
|
|
||||||
model->clear_messages ();
|
model->clear_messages ();
|
||||||
|
|
||||||
|
// Maintain the current index while updating
|
||||||
|
std::string current;
|
||||||
|
if (salt_view->currentIndex ().isValid ()) {
|
||||||
|
const lay::SaltGrain *g = model->grain_from_index (salt_view->currentIndex ());
|
||||||
|
if (g) {
|
||||||
|
current = g->name ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Establish a message saying that an update is available
|
// Establish a message saying that an update is available
|
||||||
for (Salt::flat_iterator g = mp_salt->begin_flat (); g != mp_salt->end_flat (); ++g) {
|
for (Salt::flat_iterator g = mp_salt->begin_flat (); g != mp_salt->end_flat (); ++g) {
|
||||||
SaltGrain *gm = m_salt_mine.grain_by_name ((*g)->name ());
|
SaltGrain *gm = m_salt_mine.grain_by_name ((*g)->name ());
|
||||||
|
|
@ -685,6 +710,10 @@ SaltManagerDialog::update_models ()
|
||||||
|
|
||||||
model->update ();
|
model->update ();
|
||||||
|
|
||||||
|
if (! current.empty ()) {
|
||||||
|
set_current_grain_by_name (current);
|
||||||
|
}
|
||||||
|
|
||||||
if (mp_salt->is_empty ()) {
|
if (mp_salt->is_empty ()) {
|
||||||
|
|
||||||
list_stack->setCurrentIndex (1);
|
list_stack->setCurrentIndex (1);
|
||||||
|
|
@ -695,8 +724,8 @@ SaltManagerDialog::update_models ()
|
||||||
list_stack->setCurrentIndex (0);
|
list_stack->setCurrentIndex (0);
|
||||||
details_frame->show ();
|
details_frame->show ();
|
||||||
|
|
||||||
// select the first grain
|
// select the first grain if required
|
||||||
if (model->rowCount (QModelIndex ()) > 0) {
|
if (! salt_view->currentIndex ().isValid () && model->rowCount (QModelIndex ()) > 0) {
|
||||||
salt_view->setCurrentIndex (model->index (0, 0, QModelIndex ()));
|
salt_view->setCurrentIndex (model->index (0, 0, QModelIndex ()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -164,6 +164,7 @@ private:
|
||||||
int m_current_tab;
|
int m_current_tab;
|
||||||
|
|
||||||
SaltGrain *current_grain ();
|
SaltGrain *current_grain ();
|
||||||
|
void set_current_grain_by_name (const std::string ¤t);
|
||||||
void update_models ();
|
void update_models ();
|
||||||
void update_apply_state ();
|
void update_apply_state ();
|
||||||
void get_remote_grain_info (lay::SaltGrain *g, SaltGrainDetailsTextWidget *details);
|
void get_remote_grain_info (lay::SaltGrain *g, SaltGrainDetailsTextWidget *details);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue