MCPcopy Create free account
hub / github.com/KDE/labplot / data

Method data

src/backend/core/AspectTreeModel.cpp:179–287  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

177}
178
179QVariant AspectTreeModel::data(const QModelIndex& index, int role) const {
180 if (!index.isValid())
181 return {};
182
183 auto* aspect = static_cast<AbstractAspect*>(index.internalPointer());
184 switch (role) {
185 case Qt::DisplayRole:
186 case Qt::EditRole:
187 switch (index.column()) {
188 case 0: {
189 const auto* column = dynamic_cast<const Column*>(aspect);
190 if (column) {
191 QString name = aspect->name();
192 if (m_plottableColumnsOnly && !column->isPlottable())
193 name = i18n("%1 (non-plottable data)", name);
194 else if (m_numericColumnsOnly && !column->isNumeric())
195 name = i18n("%1 (non-numeric data)", name);
196 else if (m_nonEmptyNumericColumnsOnly && !column->hasValues())
197 name = i18n("%1 (no values)", name);
198
199 if (m_showPlotDesignation)
200 name += QLatin1Char('\t') + column->plotDesignationString();
201
202 return name;
203 } else if (aspect)
204 return aspect->name();
205 else
206 return {};
207 }
208 case 1:
209 if (QLatin1String(aspect->metaObject()->className()) == QLatin1String("Datapicker"))
210 return QLatin1String("DataExtractor");
211 else if (QLatin1String(aspect->metaObject()->className()) == QLatin1String("CartesianPlot"))
212 return QLatin1String("Plot Area");
213 else if (QLatin1String(aspect->metaObject()->className()) == QLatin1String("XYCurve"))
214 return QLatin1String("Plot");
215 else
216 return QLatin1String(aspect->metaObject()->className());
217 case 2:
218 return QLocale::system().toString(aspect->creationTime(), QLocale::ShortFormat);
219 case 3:
220 return aspect->comment().replace(QLatin1Char('\n'), QLatin1Char(' ')).simplified();
221 default:
222 return {};
223 }
224 case Qt::ToolTipRole: {
225 QString toolTip;
226 if (aspect->comment().isEmpty())
227 toolTip = QLatin1String("<b>") + aspect->name() + QLatin1String("</b>");
228 else
229 toolTip =
230 QLatin1String("<b>") + aspect->name() + QLatin1String("</b><br><br>") + aspect->comment().replace(QLatin1Char('\n'), QLatin1String("<br>"));
231
232 const auto* col = dynamic_cast<const Column*>(aspect);
233 if (col) {
234 toolTip += QLatin1String("<br>");
235 toolTip += QLatin1String("<br>") + i18n("Size: %1", col->rowCount());
236 // TODO: active this once we have a more efficient implementation of this function

Callers

nothing calls this directly

Calls 15

QIconClass · 0.85
isPlottableMethod · 0.80
classNameMethod · 0.80
replaceMethod · 0.80
commentMethod · 0.80
isValidMethod · 0.45
columnMethod · 0.45
nameMethod · 0.45
isNumericMethod · 0.45
hasValuesMethod · 0.45
plotDesignationStringMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected