diff --git a/src/db/db/dbLayoutQuery.cc b/src/db/db/dbLayoutQuery.cc index ce77f784f..37150d420 100644 --- a/src/db/db/dbLayoutQuery.cc +++ b/src/db/db/dbLayoutQuery.cc @@ -1938,9 +1938,11 @@ struct SelectFilterPropertyIDs SelectFilterPropertyIDs (LayoutQuery *q) { data = q->register_property ("data", LQ_variant); + expressions = q->register_property ("expressions", LQ_variant); } unsigned int data; // data -> An array of the selected values + unsigned int expressions; // data -> An array with the expressions }; class DB_PUBLIC SelectFilterReportingState @@ -2037,7 +2039,16 @@ public: } } - virtual void reset (FilterStateBase *previous) + void get_expressions (tl::Variant &v) + { + std::vector vd; + v = tl::Variant (vd.begin (), vd.end ()); + for (std::vector::const_iterator e = m_expressions.begin (); e != m_expressions.end (); ++e) { + v.push (e->text ()); + } + } + + virtual void reset (FilterStateBase *previous) { if (m_has_sorting) { @@ -2082,6 +2093,9 @@ public: if (id == m_pids.data) { get_data (v); return true; + } else if (id == m_pids.expressions) { + get_expressions (v); + return true; } else if (m_in_data_eval) { return FilterStateBase::get_property (id, v); } else { diff --git a/src/lay/lay/laySearchReplaceDialog.cc b/src/lay/lay/laySearchReplaceDialog.cc index 97d04235e..425e248d1 100644 --- a/src/lay/lay/laySearchReplaceDialog.cc +++ b/src/lay/lay/laySearchReplaceDialog.cc @@ -78,6 +78,15 @@ SearchReplaceResults::clear () m_has_more = false; } +void +SearchReplaceResults::set_data_column_headers (const tl::Variant &v) +{ + m_data_column_headers = v; + if (v.is_list ()) { + m_data_columns = std::max (v.get_list ().size (), m_data_columns); + } +} + void SearchReplaceResults::push_back (const tl::Variant &v) { @@ -168,7 +177,13 @@ SearchReplaceResults::headerData (int section, Qt::Orientation /*orientation*/, { if (role == Qt::DisplayRole) { if (! m_data_result.empty ()) { - if (section == 0) { + if (m_data_column_headers.is_list ()) { + if (section < int (m_data_column_headers.get_list ().size ())) { + return QVariant (m_data_column_headers.get_list () [section].to_string ()); + } else { + return QVariant (QString ()); + } + } else if (section == 0) { return QVariant (QObject::tr ("Value")); } else { return QVariant (QString ()); @@ -1774,6 +1789,7 @@ SearchReplaceDialog::query_to_model (SearchReplaceResults &model, const db::Layo bool res = false; int data_prop_id = lq.has_property ("data") ? int (lq.property_by_name ("data")) : -1; + int expressions_prop_id = lq.has_property ("expressions") ? int (lq.property_by_name ("expressions")) : -1; int shape_prop_id = lq.has_property ("shape") ? int (lq.property_by_name ("shape")) : -1; int layer_index_prop_id = lq.has_property ("layer_index") ? int (lq.property_by_name ("layer_index")) : -1; int instance_prop_id = lq.has_property ("inst") ? int (lq.property_by_name ("inst")) : -1; @@ -1784,6 +1800,11 @@ SearchReplaceDialog::query_to_model (SearchReplaceResults &model, const db::Layo int parent_cell_index_prop_id = lq.has_property ("parent_cell_index") ? int (lq.property_by_name ("parent_cell_index")) : -1; int initial_cell_index_prop_id = lq.has_property ("initial_cell_index") ? int (lq.property_by_name ("initial_cell_index")) : -1; + tl::Variant ve; + if (expressions_prop_id >= 0 && iq.get (expressions_prop_id, ve)) { + model.set_data_column_headers (ve); + } + while (! iq.at_end ()) { if (++n > max_item_count) { diff --git a/src/lay/lay/laySearchReplaceDialog.h b/src/lay/lay/laySearchReplaceDialog.h index 69a295398..ad572e184 100644 --- a/src/lay/lay/laySearchReplaceDialog.h +++ b/src/lay/lay/laySearchReplaceDialog.h @@ -98,6 +98,7 @@ public: SearchReplaceResults (); void clear (); + void set_data_column_headers (const tl::Variant &v); void push_back (const tl::Variant &v); void push_back (const QueryShapeResult &v); void push_back (const QueryInstResult &v); @@ -169,6 +170,7 @@ private: std::vector m_inst_result; std::vector m_cell_result; size_t m_data_columns; + tl::Variant m_data_column_headers; mutable int m_last_column_count; std::map m_cellname_map; std::map m_lp_map; diff --git a/src/tl/tl/tlExpression.cc b/src/tl/tl/tlExpression.cc index 35eaa01a4..07a76af92 100644 --- a/src/tl/tl/tlExpression.cc +++ b/src/tl/tl/tlExpression.cc @@ -4059,7 +4059,6 @@ Eval::parse (Expression &expr, const std::string &s, bool top) expr = Expression (this, s); tl::Extractor ex (s.c_str ()); - tl::Extractor ex0 = ex; ExpressionParserContext context (&expr, ex); if (top) { @@ -4074,6 +4073,8 @@ Eval::parse (Expression &expr, const std::string &s, bool top) void Eval::parse (Expression &expr, tl::Extractor &ex, bool top) { + ex.skip (); + expr = Expression (this, ex.get ()); tl::Extractor ex0 = ex; @@ -4093,6 +4094,8 @@ Eval::parse (Expression &expr, tl::Extractor &ex, bool top) std::string Eval::parse_expr (tl::Extractor &ex, bool top) { + ex.skip (); + tl::Eval eval (0, true); Expression expr (&eval, ex.get ());