use qvariants for the samples
now addSamples actually works and doesn't crash
This commit is contained in:
parent
5e2e0ceeac
commit
22f536b6fd
@ -39,7 +39,6 @@
|
|||||||
#include <Plasma/ScrollBar>
|
#include <Plasma/ScrollBar>
|
||||||
#include <Plasma/ScrollWidget>
|
#include <Plasma/ScrollWidget>
|
||||||
#include <Plasma/Separator>
|
#include <Plasma/Separator>
|
||||||
#include <Plasma/SignalPlotter>
|
|
||||||
#include <Plasma/Slider>
|
#include <Plasma/Slider>
|
||||||
#include <Plasma/SpinBox>
|
#include <Plasma/SpinBox>
|
||||||
#include <Plasma/SvgWidget>
|
#include <Plasma/SvgWidget>
|
||||||
@ -52,11 +51,29 @@
|
|||||||
|
|
||||||
#include "declarativetabbar.h"
|
#include "declarativetabbar.h"
|
||||||
|
|
||||||
|
SignalPlotter::SignalPlotter(QGraphicsItem *parent)
|
||||||
|
: Plasma::SignalPlotter(parent)
|
||||||
|
{}
|
||||||
|
|
||||||
|
SignalPlotter::~SignalPlotter()
|
||||||
|
{}
|
||||||
|
|
||||||
|
void SignalPlotter::addSample(const QVariantList &samples)
|
||||||
|
{
|
||||||
|
QList<double> doubleSamples;
|
||||||
|
foreach (const QVariant &sampleItem, samples) {
|
||||||
|
doubleSamples << sampleItem.toDouble();
|
||||||
|
}
|
||||||
|
if (plotColors().size() == doubleSamples.size()) {
|
||||||
|
Plasma::SignalPlotter::addSample(doubleSamples);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void GraphicsWidgetsBindingsPlugin::registerTypes(const char *uri)
|
void GraphicsWidgetsBindingsPlugin::registerTypes(const char *uri)
|
||||||
{
|
{
|
||||||
Q_ASSERT(uri == QLatin1String("org.kde.plasma.graphicswidgets"));
|
Q_ASSERT(uri == QLatin1String("org.kde.plasma.graphicswidgets"));
|
||||||
qmlRegisterType<DeclarativeTabBar>(uri, 0, 1, "TabBar");
|
qmlRegisterType<DeclarativeTabBar>(uri, 0, 1, "TabBar");
|
||||||
|
qmlRegisterType<SignalPlotter>(uri, 0, 1, "SignalPlotter");
|
||||||
|
|
||||||
qmlRegisterType<Plasma::BusyWidget>(uri, 0, 1, "BusyWidget");
|
qmlRegisterType<Plasma::BusyWidget>(uri, 0, 1, "BusyWidget");
|
||||||
qmlRegisterType<Plasma::CheckBox>(uri, 0, 1, "CheckBox");
|
qmlRegisterType<Plasma::CheckBox>(uri, 0, 1, "CheckBox");
|
||||||
@ -74,7 +91,6 @@ void GraphicsWidgetsBindingsPlugin::registerTypes(const char *uri)
|
|||||||
qmlRegisterType<Plasma::ScrollBar>(uri, 0, 1, "ScrollBar");
|
qmlRegisterType<Plasma::ScrollBar>(uri, 0, 1, "ScrollBar");
|
||||||
qmlRegisterType<Plasma::ScrollWidget>(uri, 0, 1, "ScrollWidget");
|
qmlRegisterType<Plasma::ScrollWidget>(uri, 0, 1, "ScrollWidget");
|
||||||
qmlRegisterType<Plasma::Separator>(uri, 0, 1, "Separator");
|
qmlRegisterType<Plasma::Separator>(uri, 0, 1, "Separator");
|
||||||
qmlRegisterType<Plasma::SignalPlotter>(uri, 0, 1, "SignalPlotter");
|
|
||||||
qmlRegisterType<Plasma::Slider>(uri, 0, 1, "Slider");
|
qmlRegisterType<Plasma::Slider>(uri, 0, 1, "Slider");
|
||||||
qmlRegisterType<Plasma::SpinBox>(uri, 0, 1, "SpinBox");
|
qmlRegisterType<Plasma::SpinBox>(uri, 0, 1, "SpinBox");
|
||||||
qmlRegisterType<Plasma::SvgWidget>(uri, 0, 1, "SvgWidget");
|
qmlRegisterType<Plasma::SvgWidget>(uri, 0, 1, "SvgWidget");
|
||||||
|
@ -24,6 +24,17 @@
|
|||||||
|
|
||||||
#include <QDeclarativeExtensionPlugin>
|
#include <QDeclarativeExtensionPlugin>
|
||||||
|
|
||||||
|
#include <Plasma/SignalPlotter>
|
||||||
|
|
||||||
|
class SignalPlotter : public Plasma::SignalPlotter
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
SignalPlotter(QGraphicsItem *parent = 0);
|
||||||
|
~SignalPlotter();
|
||||||
|
Q_INVOKABLE void addSample(const QVariantList &samples);
|
||||||
|
};
|
||||||
|
|
||||||
class GraphicsWidgetsBindingsPlugin : public QDeclarativeExtensionPlugin
|
class GraphicsWidgetsBindingsPlugin : public QDeclarativeExtensionPlugin
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user