[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [labplot] src: [live data] improve keep N values option
From: Stefan Gerlach <null () kde ! org>
Date: 2018-07-01 7:34:44
Message-ID: E1fZWse-00026z-4L () code ! kde ! org
[Download RAW message or body]
Git commit 2890668f8b5089d6a9869b959dede0683f04a634 by Stefan Gerlach.
Committed on 01/07/2018 at 06:58.
Pushed by sgerlach into branch 'master'.
[live data] improve keep N values option
M +10 -8 src/backend/datasources/LiveDataSource.cpp
M +3 -3 src/backend/datasources/LiveDataSource.h
M +11 -14 src/backend/datasources/filters/AsciiFilter.cpp
M +1 -1 src/kdefrontend/datasources/ImportFileWidget.cpp
M +5 -5 src/kdefrontend/dockwidgets/LiveDataDock.cpp
M +1 -1 src/kdefrontend/dockwidgets/LiveDataDock.h
M +1 -1 src/kdefrontend/ui/dockwidgets/livedatadock.ui
https://commits.kde.org/labplot/2890668f8b5089d6a9869b959dede0683f04a634
diff --git a/src/backend/datasources/LiveDataSource.cpp \
b/src/backend/datasources/LiveDataSource.cpp index f07b57cd..6477b85a 100644
--- a/src/backend/datasources/LiveDataSource.cpp
+++ b/src/backend/datasources/LiveDataSource.cpp
@@ -72,7 +72,8 @@ LiveDataSource::LiveDataSource(AbstractScriptingEngine* engine, \
const QString& n m_keepLastValues(false),
m_sampleSize(1),
m_updateInterval(1000),
-//TODO: m_keepNvalues, m_port, m_baudRate ?
+ m_keepNValues(0),
+//TODO: m_port, m_baudRate ?
m_bytesRead(0),
m_filter(nullptr),
m_updateTimer(new QTimer(this)),
@@ -284,7 +285,7 @@ bool LiveDataSource::isFileWatched() const {
}
/*!
- * \brief Sets whether we'll keep the last values or append it to the previous ones
+ * \brief Sets whether we'll keep only the last values or append to the previous \
ones
* \param keepLastValues
*/
void LiveDataSource::setKeepLastValues(bool keepLastValues) {
@@ -321,15 +322,15 @@ int LiveDataSource::updateInterval() const {
}
/*!
- * \brief Sets how many values we should store
+ * \brief Sets how many values we should keep when keepLastValues is true
* \param keepnvalues
*/
-void LiveDataSource::setKeepNvalues(int keepnvalues) {
- m_keepNvalues = keepnvalues;
+void LiveDataSource::setKeepNValues(int keepnvalues) {
+ m_keepNValues = keepnvalues;
}
-int LiveDataSource::keepNvalues() const {
- return m_keepNvalues;
+int LiveDataSource::keepNValues() const {
+ return m_keepNValues;
}
/*!
@@ -862,7 +863,8 @@ void LiveDataSource::save(QXmlStreamWriter* writer) const {
writer->writeAttribute("updateType", QString::number(m_updateType));
writer->writeAttribute("readingType", QString::number(m_readingType));
writer->writeAttribute("sourceType", QString::number(m_sourceType));
- writer->writeAttribute("keepValues", QString::number(m_keepNvalues));
+ writer->writeAttribute("keepLastValues", QString::number(m_keepLastValues));
+ writer->writeAttribute("keepNValues", QString::number(m_keepNValues));
if (m_updateType == TimeInterval)
writer->writeAttribute("updateInterval", QString::number(m_updateInterval));
diff --git a/src/backend/datasources/LiveDataSource.h \
b/src/backend/datasources/LiveDataSource.h index bf9c442e..7fa4f558 100644
--- a/src/backend/datasources/LiveDataSource.h
+++ b/src/backend/datasources/LiveDataSource.h
@@ -120,8 +120,8 @@ public:
void setUpdateInterval(int);
int updateInterval() const;
- void setKeepNvalues(int);
- int keepNvalues() const;
+ void setKeepNValues(int);
+ int keepNValues() const;
void setKeepLastValues(bool);
bool keepLastValues() const;
@@ -173,7 +173,7 @@ private:
bool m_keepLastValues;
int m_sampleSize;
- int m_keepNvalues;
+ int m_keepNValues; // number of values to keep (0 - all)
int m_updateInterval;
quint16 m_port;
int m_baudRate;
diff --git a/src/backend/datasources/filters/AsciiFilter.cpp \
b/src/backend/datasources/filters/AsciiFilter.cpp index 2df2e50f..4c6444ec 100644
--- a/src/backend/datasources/filters/AsciiFilter.cpp
+++ b/src/backend/datasources/filters/AsciiFilter.cpp
@@ -655,12 +655,12 @@ qint64 AsciiFilterPrivate::readFromLiveDevice(QIODevice& \
device, AbstractDataSou \
spreadsheet->child<Column>(i)->setSuppressDataChangedSignal(true); }
- //also here we need a cheaper version of this
- if (!spreadsheet->keepLastValues())
+ int keepNValues = spreadsheet->keepNValues();
+ if (keepNValues == 0)
spreadsheet->setRowCount(m_actualRows > 1 ? m_actualRows : 1);
else {
- spreadsheet->setRowCount(spreadsheet->keepNvalues());
- m_actualRows = spreadsheet->keepNvalues();
+ spreadsheet->setRowCount(keepNValues);
+ m_actualRows = keepNValues;
}
m_dataContainer.resize(m_actualCols);
@@ -825,11 +825,13 @@ qint64 AsciiFilterPrivate::readFromLiveDevice(QIODevice& \
device, AbstractDataSou else
m_actualRows = newData.size();
}
- }
- DEBUG(" actual row = " << m_actualRows);
- //fixed size
- if (spreadsheet->keepLastValues()) {
+ //appending
+ if (spreadsheet->readingType() == LiveDataSource::ReadingType::WholeFile)
+ linesToRead = m_actualRows;
+ else
+ linesToRead = m_actualRows - spreadsheetRowCountBeforeResize;
+ } else { // fixed size
if (readingType == LiveDataSource::ReadingType::TillEnd) {
//we had more lines than the fixed size, so we read m_actualRows number of lines
if (newLinesTillEnd > m_actualRows) {
@@ -843,13 +845,8 @@ qint64 AsciiFilterPrivate::readFromLiveDevice(QIODevice& device, \
AbstractDataSou //is ContinuouslyFixed or FromEnd, WholeFile is disabled
linesToRead = qMin(spreadsheet->sampleSize(), newLinesTillEnd);
}
- } else {
- //appending
- if (spreadsheet->readingType() == LiveDataSource::ReadingType::WholeFile)
- linesToRead = m_actualRows;
- else
- linesToRead = m_actualRows - spreadsheetRowCountBeforeResize;
}
+ DEBUG(" actual row = " << m_actualRows);
if (linesToRead == 0)
return 0;
diff --git a/src/kdefrontend/datasources/ImportFileWidget.cpp \
b/src/kdefrontend/datasources/ImportFileWidget.cpp index d327a879..66e40c47 100644
--- a/src/kdefrontend/datasources/ImportFileWidget.cpp
+++ b/src/kdefrontend/datasources/ImportFileWidget.cpp
@@ -387,7 +387,7 @@ void ImportFileWidget::saveSettings(LiveDataSource* source) const \
{
if (!ui.leKeepLastValues->text().isEmpty()) {
source->setKeepLastValues(true);
- source->setKeepNvalues(ui.leKeepLastValues->text().toInt());
+ source->setKeepNValues(ui.leKeepLastValues->text().toInt());
}
source->setUpdateType(updateType);
diff --git a/src/kdefrontend/dockwidgets/LiveDataDock.cpp \
b/src/kdefrontend/dockwidgets/LiveDataDock.cpp index b823e0ab..8b73841a 100644
--- a/src/kdefrontend/dockwidgets/LiveDataDock.cpp
+++ b/src/kdefrontend/dockwidgets/LiveDataDock.cpp
@@ -38,7 +38,7 @@ LiveDataDock::LiveDataDock(QWidget* parent) :
connect(ui.bUpdateNow, &QPushButton::clicked, this, &LiveDataDock::updateNow);
connect(ui.sbUpdateInterval, static_cast<void (QSpinBox::*) \
(int)>(&QSpinBox::valueChanged), this, &LiveDataDock::updateIntervalChanged);
- connect(ui.leKeepNValues, &QLineEdit::textChanged, this, \
&LiveDataDock::keepNvaluesChanged); + connect(ui.leKeepNValues, \
&QLineEdit::textChanged, this, &LiveDataDock::keepNValuesChanged); \
connect(ui.sbSampleSize, static_cast<void (QSpinBox::*) \
(int)>(&QSpinBox::valueChanged), this, &LiveDataDock::sampleSizeChanged); \
connect(ui.cbUpdateType, static_cast<void (QComboBox::*) \
(int)>(&QComboBox::currentIndexChanged), this, &LiveDataDock::updateTypeChanged); \
connect(ui.cbReadingType, static_cast<void (QComboBox::*) \
(int)>(&QComboBox::currentIndexChanged), this, &LiveDataDock::readingTypeChanged); @@ \
-74,10 +74,10 @@ void LiveDataDock::setLiveDataSources(const QList<LiveDataSource*>& \
sources) {
if(!fds->keepLastValues()) {
ui.leKeepNValues->hide();
- ui.lKeepNvalues->hide();
+ ui.lKeepNValues->hide();
} else {
ui.leKeepNValues->setValidator(new QIntValidator(2, 100000));
- ui.leKeepNValues->setText(QString::number(fds->keepNvalues()));
+ ui.leKeepNValues->setText(QString::number(fds->keepNValues()));
}
// disable "whole file" when having no file (i.e. socket or port)
@@ -174,9 +174,9 @@ void LiveDataDock::updateIntervalChanged(int updateInterval) {
* \brief Modifies the number of samples to keep in each of the live data sources
* \param keepNvalues
*/
-void LiveDataDock::keepNvaluesChanged(const QString& keepNvalues) {
+void LiveDataDock::keepNValuesChanged(const QString& keepNValues) {
for (auto* source : m_liveDataSources)
- source->setKeepNvalues(keepNvalues.toInt());
+ source->setKeepNValues(keepNValues.toInt());
}
/*!
diff --git a/src/kdefrontend/dockwidgets/LiveDataDock.h \
b/src/kdefrontend/dockwidgets/LiveDataDock.h index 83c2cea0..d520a9eb 100644
--- a/src/kdefrontend/dockwidgets/LiveDataDock.h
+++ b/src/kdefrontend/dockwidgets/LiveDataDock.h
@@ -55,7 +55,7 @@ private slots:
void readingTypeChanged(int);
void sampleSizeChanged(int);
void updateIntervalChanged(int);
- void keepNvaluesChanged(const QString&);
+ void keepNValuesChanged(const QString&);
void updateNow();
void pauseContinueReading();
diff --git a/src/kdefrontend/ui/dockwidgets/livedatadock.ui \
b/src/kdefrontend/ui/dockwidgets/livedatadock.ui index 5c7bd243..d788058e 100644
--- a/src/kdefrontend/ui/dockwidgets/livedatadock.ui
+++ b/src/kdefrontend/ui/dockwidgets/livedatadock.ui
@@ -53,7 +53,7 @@
</widget>
</item>
<item row="2" column="0">
- <widget class="QLabel" name="lKeepNvalues">
+ <widget class="QLabel" name="lKeepNValues">
<property name="text">
<string>Keep last N values:</string>
</property>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic