[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [labplot] src: [live data] simplified keep N values usage
From: Stefan Gerlach <null () kde ! org>
Date: 2018-07-01 7:34:44
Message-ID: E1fZWse-00026z-5S () code ! kde ! org
[Download RAW message or body]
Git commit e5801bc3b0527a937444915c61ccd1d1eedb128a by Stefan Gerlach.
Committed on 01/07/2018 at 07:33.
Pushed by sgerlach into branch 'master'.
[live data] simplified keep N values usage
M +1 -15 src/backend/datasources/LiveDataSource.cpp
M +0 -1 src/backend/datasources/LiveDataSource.h
M +6 -5 src/backend/datasources/filters/AsciiFilter.cpp
M +5 -9 src/kdefrontend/datasources/ImportFileWidget.cpp
M +4 -10 src/kdefrontend/dockwidgets/LiveDataDock.cpp
M +1 -1 src/kdefrontend/dockwidgets/LiveDataDock.h
M +11 -4 src/kdefrontend/ui/datasources/importfilewidget.ui
M +11 -4 src/kdefrontend/ui/dockwidgets/livedatadock.ui
https://commits.kde.org/labplot/e5801bc3b0527a937444915c61ccd1d1eedb128a
diff --git a/src/backend/datasources/LiveDataSource.cpp \
b/src/backend/datasources/LiveDataSource.cpp index 6477b85a..54f90b0d 100644
--- a/src/backend/datasources/LiveDataSource.cpp
+++ b/src/backend/datasources/LiveDataSource.cpp
@@ -69,10 +69,9 @@ LiveDataSource::LiveDataSource(AbstractScriptingEngine* engine, \
const QString& n m_fileLinked(false),
m_paused(false),
m_prepared(false),
- m_keepLastValues(false),
m_sampleSize(1),
- m_updateInterval(1000),
m_keepNValues(0),
+ m_updateInterval(1000),
//TODO: m_port, m_baudRate ?
m_bytesRead(0),
m_filter(nullptr),
@@ -284,18 +283,6 @@ bool LiveDataSource::isFileWatched() const {
return m_fileWatched;
}
-/*!
- * \brief Sets whether we'll keep only the last values or append to the previous \
ones
- * \param keepLastValues
- */
-void LiveDataSource::setKeepLastValues(bool keepLastValues) {
- m_keepLastValues = keepLastValues;
-}
-
-bool LiveDataSource::keepLastValues() const {
- return m_keepLastValues;
-}
-
/*!
* \brief Sets the serial port's baud rate
* \param baudrate
@@ -863,7 +850,6 @@ 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("keepLastValues", QString::number(m_keepLastValues));
writer->writeAttribute("keepNValues", QString::number(m_keepNValues));
if (m_updateType == TimeInterval)
diff --git a/src/backend/datasources/LiveDataSource.h \
b/src/backend/datasources/LiveDataSource.h index 7fa4f558..0211964a 100644
--- a/src/backend/datasources/LiveDataSource.h
+++ b/src/backend/datasources/LiveDataSource.h
@@ -170,7 +170,6 @@ private:
bool m_fileLinked;
bool m_paused;
bool m_prepared;
- bool m_keepLastValues;
int m_sampleSize;
int m_keepNValues; // number of values to keep (0 - all)
diff --git a/src/backend/datasources/filters/AsciiFilter.cpp \
b/src/backend/datasources/filters/AsciiFilter.cpp index 4c6444ec..14d8be4f 100644
--- a/src/backend/datasources/filters/AsciiFilter.cpp
+++ b/src/backend/datasources/filters/AsciiFilter.cpp
@@ -810,12 +810,13 @@ qint64 AsciiFilterPrivate::readFromLiveDevice(QIODevice& \
device, AbstractDataSou
int currentRow = 0; // indexes the position in the vector(column)
int linesToRead = 0;
+ int keepNValues = spreadsheet->keepNValues();
DEBUG("Increase row count");
if (m_prepared) {
//increase row count if we don't have a fixed size
//but only after the preparation step
- if (!spreadsheet->keepLastValues()) {
+ if (keepNValues == 0) {
if (readingType != LiveDataSource::ReadingType::TillEnd)
m_actualRows += qMin(newData.size(), spreadsheet->sampleSize());
else {
@@ -867,7 +868,7 @@ qint64 AsciiFilterPrivate::readFromLiveDevice(QIODevice& device, \
AbstractDataSou
//new rows/resize columns if we don't have a fixed size
//TODO if the user changes this value..m_resizedToFixedSize..setResizedToFixedSize
- if (!spreadsheet->keepLastValues()) {
+ if (keepNValues == 0) {
#ifdef PERFTRACE_LIVE_IMPORT
PERFTRACE("AsciiLiveDataImportResizing: ");
#endif
@@ -1061,10 +1062,10 @@ qint64 AsciiFilterPrivate::readFromLiveDevice(QIODevice& \
device, AbstractDataSou QDEBUG(" line = " << lineStringList << ", separator = \'" << \
m_separator << "\'");
if (createIndexEnabled) {
- if (spreadsheet->keepLastValues())
- lineStringList.prepend(QString::number(indexColumnIdx++));
- else
+ if (spreadsheet->keepNValues() == 0)
lineStringList.prepend(QString::number(currentRow));
+ else
+ lineStringList.prepend(QString::number(indexColumnIdx++));
}
QDEBUG(" column modes = " << columnModes);
diff --git a/src/kdefrontend/datasources/ImportFileWidget.cpp \
b/src/kdefrontend/datasources/ImportFileWidget.cpp index 66e40c47..a8683b40 100644
--- a/src/kdefrontend/datasources/ImportFileWidget.cpp
+++ b/src/kdefrontend/datasources/ImportFileWidget.cpp
@@ -221,7 +221,7 @@ void ImportFileWidget::loadSettings() {
ui.cbSerialPort->setCurrentIndex(conf.readEntry("SerialPort").toInt());
ui.cbUpdateType->setCurrentIndex(conf.readEntry("UpdateType").toInt());
ui.leHost->setText(conf.readEntry("Host",""));
- ui.leKeepLastValues->setText(conf.readEntry("KeepLastNValues",""));
+ ui.sbKeepNValues->setValue(conf.readEntry("KeepNValues").toInt());
ui.lePort->setText(conf.readEntry("Port",""));
ui.sbSampleSize->setValue(conf.readEntry("SampleSize").toInt());
ui.sbUpdateInterval->setValue(conf.readEntry("UpdateInterval").toInt());
@@ -249,7 +249,7 @@ ImportFileWidget::~ImportFileWidget() {
conf.writeEntry("UpdateType", ui.cbUpdateType->currentIndex());
conf.writeEntry("ReadingType", ui.cbReadingType->currentIndex());
conf.writeEntry("SampleSize", ui.sbSampleSize->value());
- conf.writeEntry("KeepLastNValues", ui.leKeepLastValues->text());
+ conf.writeEntry("KeepNValues", ui.sbKeepNValues->value());
conf.writeEntry("BaudRate", ui.cbBaudRate->currentIndex());
conf.writeEntry("SerialPort", ui.cbSerialPort->currentIndex());
conf.writeEntry("Host", ui.leHost->text());
@@ -385,10 +385,7 @@ void ImportFileWidget::saveSettings(LiveDataSource* source) \
const { else
source->setFileWatched(true);
- if (!ui.leKeepLastValues->text().isEmpty()) {
- source->setKeepLastValues(true);
- source->setKeepNValues(ui.leKeepLastValues->text().toInt());
- }
+ source->setKeepNValues(ui.sbKeepNValues->value());
source->setUpdateType(updateType);
@@ -1096,10 +1093,10 @@ void ImportFileWidget::readingTypeChanged(int idx) {
if (type == LiveDataSource::ReadingType::WholeFile) {
ui.lKeepLastValues->hide();
- ui.leKeepLastValues->hide();
+ ui.sbKeepNValues->hide();
} else {
ui.lKeepLastValues->show();
- ui.leKeepLastValues->show();
+ ui.sbKeepNValues->show();
}
}
@@ -1232,6 +1229,5 @@ void ImportFileWidget::initializeAndFillPortsAndBaudRates() {
ui.cbBaudRate->addItems(LiveDataSource::supportedBaudRates());
ui.cbSerialPort->addItems(LiveDataSource::availablePorts());
- ui.leKeepLastValues->setValidator(new QIntValidator(2, 100000));
ui.tabWidget->removeTab(2);
}
diff --git a/src/kdefrontend/dockwidgets/LiveDataDock.cpp \
b/src/kdefrontend/dockwidgets/LiveDataDock.cpp index 8b73841a..d7877196 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.sbKeepNValues, static_cast<void \
(QSpinBox::*) (int)>(&QSpinBox::valueChanged), 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); @@ -72,13 +72,7 @@ void \
LiveDataDock::setLiveDataSources(const QList<LiveDataSource*>& sources) { \
ui.bPausePlayReading->setIcon(QIcon::fromTheme(QLatin1String("media-playback-pause")));
}
- if(!fds->keepLastValues()) {
- ui.leKeepNValues->hide();
- ui.lKeepNValues->hide();
- } else {
- ui.leKeepNValues->setValidator(new QIntValidator(2, 100000));
- ui.leKeepNValues->setText(QString::number(fds->keepNValues()));
- }
+ ui.sbKeepNValues->setValue(fds->keepNValues());
// disable "whole file" when having no file (i.e. socket or port)
const QStandardItemModel* model = qobject_cast<const \
QStandardItemModel*>(ui.cbReadingType->model()); @@ -174,9 +168,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 int keepNValues) {
for (auto* source : m_liveDataSources)
- source->setKeepNValues(keepNValues.toInt());
+ source->setKeepNValues(keepNValues);
}
/*!
diff --git a/src/kdefrontend/dockwidgets/LiveDataDock.h \
b/src/kdefrontend/dockwidgets/LiveDataDock.h index d520a9eb..b158bb17 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(int);
void updateNow();
void pauseContinueReading();
diff --git a/src/kdefrontend/ui/datasources/importfilewidget.ui \
b/src/kdefrontend/ui/datasources/importfilewidget.ui index d2fcb594..17f04e62 100644
--- a/src/kdefrontend/ui/datasources/importfilewidget.ui
+++ b/src/kdefrontend/ui/datasources/importfilewidget.ui
@@ -583,9 +583,6 @@
</property>
</widget>
</item>
- <item row="8" column="1">
- <widget class="QLineEdit" name="leKeepLastValues"/>
- </item>
<item row="3" column="1">
<widget class="QSpinBox" name="sbUpdateInterval">
<property name="sizePolicy">
@@ -671,7 +668,7 @@
<item row="8" column="0">
<widget class="QLabel" name="lKeepLastValues">
<property name="text">
- <string>Keep last N values:</string>
+ <string>Keep last values:</string>
</property>
</widget>
</item>
@@ -701,6 +698,16 @@
</item>
</widget>
</item>
+ <item row="8" column="1">
+ <widget class="QSpinBox" name="sbKeepNValues">
+ <property name="specialValueText">
+ <string>All</string>
+ </property>
+ <property name="maximum">
+ <number>999999</number>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
</item>
diff --git a/src/kdefrontend/ui/dockwidgets/livedatadock.ui \
b/src/kdefrontend/ui/dockwidgets/livedatadock.ui index d788058e..439916a9 100644
--- a/src/kdefrontend/ui/dockwidgets/livedatadock.ui
+++ b/src/kdefrontend/ui/dockwidgets/livedatadock.ui
@@ -55,7 +55,7 @@
<item row="2" column="0">
<widget class="QLabel" name="lKeepNValues">
<property name="text">
- <string>Keep last N values:</string>
+ <string>Keep last values:</string>
</property>
</widget>
</item>
@@ -124,9 +124,6 @@
</property>
</widget>
</item>
- <item row="2" column="1" colspan="3">
- <widget class="QLineEdit" name="leKeepNValues"/>
- </item>
<item row="4" column="1" colspan="3">
<widget class="QSpinBox" name="sbUpdateInterval">
<property name="suffix">
@@ -143,6 +140,16 @@
</property>
</widget>
</item>
+ <item row="2" column="1" colspan="3">
+ <widget class="QSpinBox" name="sbKeepNValues">
+ <property name="specialValueText">
+ <string>All</string>
+ </property>
+ <property name="maximum">
+ <number>999999</number>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
<resources/>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic