QString LegendWidget::parse(const QString& str) { QString s = str; s.remove(QRegExp("\\l(*)", Qt::CaseSensitive, QRegExp::Wildcard)); s.remove(QRegExp("\\p{*}", Qt::CaseSensitive, QRegExp::Wildcard)); QString aux = str; while (aux.contains(QRegExp("%(*)", Qt::CaseInsensitive, QRegExp::Wildcard))){//curve name specification int pos = str.indexOf("%(", 0, Qt::CaseInsensitive); int pos2 = str.indexOf(")", pos, Qt::CaseInsensitive); QString spec = str.mid(pos + 2, pos2 - pos - 2); QStringList lst = spec.split(","); if (!lst.isEmpty()){ int cv = lst[0].toInt() - 1; if (d_plot && cv >= 0 && cv < d_plot->curveCount()){ PlotCurve *c = (PlotCurve *)d_plot->curve(cv); if (c){ if (lst.count() == 1) s = s.replace(pos, pos2-pos+1, c->title().text()); else if (lst.count() == 3 && c->type() == Graph::Pie){ Table *t = ((DataCurve *)c)->table(); int col = t->colIndex(c->title().text()); int row = lst[2].toInt() - 1; s = s.replace(pos, pos2-pos+1, t->text(row, col)); } } } aux = aux.right(aux.length() - pos2 - 1); } } return s; }
PlotCurve::PlotCurve(const PlotCurve &c) : QObject(), QwtPlotCurve(c.title().text()), d_type(c.d_type), d_x_offset(c.d_x_offset), d_y_offset(c.d_y_offset), d_side_lines(c.d_side_lines), d_skip_symbols(c.d_skip_symbols), m_isDistribution(c.m_isDistribution) {}