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

Method showSparkLines

src/frontend/spreadsheet/SpreadsheetSparkLineHeaderModel.cpp:52–83  ·  view source on GitHub ↗

show sparkLine of respective column

Source from the content-addressed store, hash-verified

50
51// show sparkLine of respective column
52QPixmap SpreadsheetSparkLinesHeaderModel::showSparkLines(Column* col) {
53 // Create a QThreadPool instance and set the maximum number of threads
54 QThreadPool threadPool;
55 threadPool.setMaxThreadCount(QThread::idealThreadCount());
56 PERFTRACE(QLatin1String(Q_FUNC_INFO));
57 // Create a QFutureWatcher to monitor the task's progress
58 QFutureWatcher<QPixmap> watcher;
59 // Create an instance of SparkLineRunnable
60 auto* runnable = new SparkLineRunnable(col);
61
62 // Connect the finished signal of the runnable to the watcher's setFuture slot
63 connect(runnable, &SparkLineRunnable::taskFinished, [&]() {
64 const auto& resultPixmap = runnable->pixmap();
65 // Check if the result is valid
66 if (!resultPixmap.isNull()) {
67 watcher.setFuture(QtConcurrent::run(&threadPool, [=]() {
68 return resultPixmap;
69 }));
70 } else
71 watcher.cancel();
72 });
73
74 // Start the runnable in the thread pool
75 threadPool.start(runnable);
76
77 // Wait for the task to finish
78 QEventLoop loop;
79 QObject::connect(runnable, &SparkLineRunnable::taskFinished, &loop, &QEventLoop::quit);
80 loop.exec();
81
82 return watcher.result();
83}
84
85QVariant SpreadsheetSparkLinesHeaderModel::data(const QModelIndex& /*index*/, int /*role*/) const {
86 return {};

Callers

nothing calls this directly

Calls 5

isNullMethod · 0.80
cancelMethod · 0.80
execMethod · 0.80
pixmapMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected