mirror of https://github.com/KLayout/klayout.git
Fixed issue #1779 (make the state of the "By Cell" or "By Category" tree persistent)
This commit is contained in:
parent
d3921844d6
commit
5b9cb95e68
|
|
@ -46,6 +46,7 @@ std::string cfg_rdb_show_all ("rdb-show-all");
|
||||||
std::string cfg_rdb_list_shapes ("rdb-list-shapes");
|
std::string cfg_rdb_list_shapes ("rdb-list-shapes");
|
||||||
std::string cfg_rdb_window_state ("rdb-window-state-v2"); // v2: 0.24++
|
std::string cfg_rdb_window_state ("rdb-window-state-v2"); // v2: 0.24++
|
||||||
std::string cfg_rdb_window_mode ("rdb-window-mode");
|
std::string cfg_rdb_window_mode ("rdb-window-mode");
|
||||||
|
std::string cfg_rdb_tree_state ("rdb-tree-state");
|
||||||
std::string cfg_rdb_window_dim ("rdb-window-dim");
|
std::string cfg_rdb_window_dim ("rdb-window-dim");
|
||||||
std::string cfg_rdb_max_marker_count ("rdb-max-marker-count");
|
std::string cfg_rdb_max_marker_count ("rdb-max-marker-count");
|
||||||
std::string cfg_rdb_marker_color ("rdb-marker-color");
|
std::string cfg_rdb_marker_color ("rdb-marker-color");
|
||||||
|
|
@ -296,6 +297,7 @@ public:
|
||||||
options.push_back (std::pair<std::string, std::string> (cfg_rdb_window_mode, "fit-marker"));
|
options.push_back (std::pair<std::string, std::string> (cfg_rdb_window_mode, "fit-marker"));
|
||||||
options.push_back (std::pair<std::string, std::string> (cfg_rdb_window_state, ""));
|
options.push_back (std::pair<std::string, std::string> (cfg_rdb_window_state, ""));
|
||||||
options.push_back (std::pair<std::string, std::string> (cfg_rdb_window_dim, "1.0"));
|
options.push_back (std::pair<std::string, std::string> (cfg_rdb_window_dim, "1.0"));
|
||||||
|
options.push_back (std::pair<std::string, std::string> (cfg_rdb_tree_state, ""));
|
||||||
options.push_back (std::pair<std::string, std::string> (cfg_rdb_max_marker_count, "1000"));
|
options.push_back (std::pair<std::string, std::string> (cfg_rdb_max_marker_count, "1000"));
|
||||||
options.push_back (std::pair<std::string, std::string> (cfg_rdb_marker_color, lay::ColorConverter ().to_string (QColor ())));
|
options.push_back (std::pair<std::string, std::string> (cfg_rdb_marker_color, lay::ColorConverter ().to_string (QColor ())));
|
||||||
options.push_back (std::pair<std::string, std::string> (cfg_rdb_marker_line_width, "-1"));
|
options.push_back (std::pair<std::string, std::string> (cfg_rdb_marker_line_width, "-1"));
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,7 @@ extern std::string cfg_rdb_list_shapes;
|
||||||
extern std::string cfg_rdb_window_state;
|
extern std::string cfg_rdb_window_state;
|
||||||
extern std::string cfg_rdb_window_mode;
|
extern std::string cfg_rdb_window_mode;
|
||||||
extern std::string cfg_rdb_window_dim;
|
extern std::string cfg_rdb_window_dim;
|
||||||
|
extern std::string cfg_rdb_tree_state;
|
||||||
extern std::string cfg_rdb_max_marker_count;
|
extern std::string cfg_rdb_max_marker_count;
|
||||||
extern std::string cfg_rdb_marker_color;
|
extern std::string cfg_rdb_marker_color;
|
||||||
extern std::string cfg_rdb_marker_line_width;
|
extern std::string cfg_rdb_marker_line_width;
|
||||||
|
|
@ -847,6 +848,10 @@ MarkerBrowserDialog::update_content ()
|
||||||
mp_ui->browser_frame->set_view (view (), m_cv_index);
|
mp_ui->browser_frame->set_view (view (), m_cv_index);
|
||||||
mp_ui->browser_frame->enable_updates (true);
|
mp_ui->browser_frame->enable_updates (true);
|
||||||
|
|
||||||
|
std::string tree_state;
|
||||||
|
view ()->config_get (cfg_rdb_tree_state, tree_state);
|
||||||
|
mp_ui->browser_frame->set_tree_state (tree_state);
|
||||||
|
|
||||||
if (rdb) {
|
if (rdb) {
|
||||||
// Note: it appears to be required to show the browser page after it has been configured.
|
// Note: it appears to be required to show the browser page after it has been configured.
|
||||||
// Otherwise the header gets messed up and the configuration is reset.
|
// Otherwise the header gets messed up and the configuration is reset.
|
||||||
|
|
@ -872,7 +877,11 @@ void
|
||||||
MarkerBrowserDialog::deactivated ()
|
MarkerBrowserDialog::deactivated ()
|
||||||
{
|
{
|
||||||
if (lay::Dispatcher::instance ()) {
|
if (lay::Dispatcher::instance ()) {
|
||||||
lay::Dispatcher::instance ()->config_set (cfg_rdb_window_state, lay::save_dialog_state (this).c_str ());
|
lay::Dispatcher::instance ()->config_set (cfg_rdb_window_state, lay::save_dialog_state (this));
|
||||||
|
std::string tree_state = mp_ui->browser_frame->get_tree_state ();
|
||||||
|
if (! tree_state.empty ()) {
|
||||||
|
lay::Dispatcher::instance ()->config_set (cfg_rdb_tree_state, tree_state);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mp_ui->browser_frame->set_rdb (0);
|
mp_ui->browser_frame->set_rdb (0);
|
||||||
|
|
|
||||||
|
|
@ -1953,7 +1953,83 @@ MarkerBrowserPage::set_rdb (rdb::Database *database)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static std::string top_item_by_index (int i)
|
||||||
|
{
|
||||||
|
if (i == 0) {
|
||||||
|
return std::string ("by-cell");
|
||||||
|
} else if (i == 1) {
|
||||||
|
return std::string ("by-category");
|
||||||
|
} else {
|
||||||
|
return std::string ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static int top_index_from_item (const std::string &s)
|
||||||
|
{
|
||||||
|
if (s == "by-cell") {
|
||||||
|
return 0;
|
||||||
|
} else if (s == "by-category") {
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string
|
||||||
|
MarkerBrowserPage::get_tree_state ()
|
||||||
|
{
|
||||||
|
std::string res;
|
||||||
|
|
||||||
|
QAbstractItemModel *tree_model = directory_tree->model ();
|
||||||
|
if (! tree_model) {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
int rows = tree_model->rowCount (QModelIndex ());
|
||||||
|
for (int i = 0; i < rows; ++i) {
|
||||||
|
bool expanded = directory_tree->isExpanded (tree_model->index (i, 0, QModelIndex ()));
|
||||||
|
std::string item = top_item_by_index (i);
|
||||||
|
if (! item.empty ()) {
|
||||||
|
if (! res.empty ()) {
|
||||||
|
res += ",";
|
||||||
|
}
|
||||||
|
res += expanded ? "+" : "-";
|
||||||
|
res += item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
MarkerBrowserPage::set_tree_state (const std::string &state)
|
||||||
|
{
|
||||||
|
QAbstractItemModel *tree_model = directory_tree->model ();
|
||||||
|
if (! tree_model) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
tl::Extractor ex (state.c_str ());
|
||||||
|
while (! ex.at_end ()) {
|
||||||
|
bool expanded = false;
|
||||||
|
if (ex.test ("+")) {
|
||||||
|
expanded = true;
|
||||||
|
} else {
|
||||||
|
ex.test ("-");
|
||||||
|
}
|
||||||
|
std::string item;
|
||||||
|
if (! ex.try_read_word (item, "-_")) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
int index = top_index_from_item (item);
|
||||||
|
if (index >= 0) {
|
||||||
|
directory_tree->setExpanded (tree_model->index (index, 0, QModelIndex ()), expanded);
|
||||||
|
}
|
||||||
|
ex.test (",");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
MarkerBrowserPage::update_content ()
|
MarkerBrowserPage::update_content ()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -161,6 +161,16 @@ public:
|
||||||
*/
|
*/
|
||||||
void enable_updates (bool f);
|
void enable_updates (bool f);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Gets a string with the serialized tree state
|
||||||
|
*/
|
||||||
|
std::string get_tree_state ();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Restores the tree state from the serialized string (see get_tree_state)
|
||||||
|
*/
|
||||||
|
void set_tree_state (const std::string &state);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void directory_header_clicked (int section);
|
void directory_header_clicked (int section);
|
||||||
void directory_sorting_changed (int section, Qt::SortOrder order);
|
void directory_sorting_changed (int section, Qt::SortOrder order);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue