[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [labplot/gsoc2017_live_data] src: Some new members in FileDataSource, moved SourceType and UpdateTyp
From: Fabian Kristof <null () kde ! org>
Date: 2017-06-30 17:13:39
Message-ID: E1dQzUB-00043k-67 () code ! kde ! org
[Download RAW message or body]
Git commit f49864a9de455771b71597c35584d5a4c5c33703 by Fabian Kristof.
Committed on 30/06/2017 at 17:13.
Pushed by fkristof into branch 'gsoc2017_live_data'.
Some new members in FileDataSource, moved SourceType and UpdateType in FileDataSource
M +84 -1 src/backend/datasources/FileDataSource.cpp
M +46 -1 src/backend/datasources/FileDataSource.h
M +7 -7 src/kdefrontend/datasources/ImportFileWidget.cpp
M +0 -11 src/kdefrontend/datasources/ImportFileWidget.h
https://commits.kde.org/labplot/f49864a9de455771b71597c35584d5a4c5c33703
diff --git a/src/backend/datasources/FileDataSource.cpp \
b/src/backend/datasources/FileDataSource.cpp index 91f7604a..13efbf45 100644
--- a/src/backend/datasources/FileDataSource.cpp
+++ b/src/backend/datasources/FileDataSource.cpp
@@ -42,7 +42,6 @@ Copyright : (C) 2009-2017 Alexander Semke (alexander.semke@web.de)
#include <QtSerialPort/QSerialPort>
#include <QtSerialPort/QSerialPortInfo>
#include <QLocalSocket>
-#include <QSocketNotifier>
#include <QIcon>
#include <QAction>
@@ -173,6 +172,90 @@ bool FileDataSource::isFileWatched() const {
}
/*!
+ * \brief Sets the serial port's baud rate
+ * \param baudrate
+ */
+void FileDataSource::setBaudRate(const int baudrate) {
+ m_baudRate = baudrate;
+}
+
+int FileDataSource::baudRate() const {
+ return m_baudRate;
+}
+
+/*!
+ * \brief Sets the source's update frequency to frequency
+ * \param frequency
+ */
+void FileDataSource::setUpdateFrequency(const int frequency) {
+ m_updateFrequency = frequency;
+}
+
+int FileDataSource::updateFrequency() const {
+ return m_updateFrequency;
+}
+
+/*!
+ * \brief Sets the network socket's port to port
+ * \param port
+ */
+void FileDataSource::setPort(const int port) {
+ m_port = port;
+}
+
+int FileDataSource::port() const {
+ return m_port;
+}
+
+/*!
+ * \brief Sets the sample rate to samplerate
+ * \param samplerate
+ */
+void FileDataSource::setSampleRate(const int samplerate) {
+ m_sampleRate = samplerate;
+}
+
+int FileDataSource::sampleRate() const {
+ return m_sampleRate;
+}
+
+/*!
+ * \brief Sets the source's type to sourcetype
+ * \param sourcetype
+ */
+void FileDataSource::setSourceType(const SourceType sourcetype) {
+ m_sourceType = sourcetype;
+}
+
+FileDataSource::SourceType FileDataSource::sourceType() const {
+ return m_sourceType;
+}
+
+/*!
+ * \brief Sets the source's update type to updatetype
+ * \param updatetype
+ */
+void FileDataSource::setUpdateType(const UpdateType updatetype) {
+ m_updateType = updatetype;
+}
+
+FileDataSource::UpdateType FileDataSource::updateType() const {
+ return m_updateType;
+}
+
+/*!
+ * \brief Sets the network socket's host
+ * \param host
+ */
+void FileDataSource::setHost(const QString & host) {
+ m_host = host;
+}
+
+QString FileDataSource::host() const {
+ return m_host;
+}
+
+/*!
sets whether only a link to the file is saved in the project file (\c b=true)
or the whole content of the file (\c b=false).
*/
diff --git a/src/backend/datasources/FileDataSource.h \
b/src/backend/datasources/FileDataSource.h index 0942e6d8..d726d1d1 100644
--- a/src/backend/datasources/FileDataSource.h
+++ b/src/backend/datasources/FileDataSource.h
@@ -30,6 +30,9 @@
#include "backend/spreadsheet/Spreadsheet.h"
#include "backend/matrix/Matrix.h"
+#include <QSerialPort>
+#include <QSocketNotifier>
+#include <QLocalSocket>
class QString;
class AbstractFileFilter;
@@ -42,7 +45,17 @@ class FileDataSource : public Spreadsheet {
public:
enum FileType {Ascii, Binary, Image, HDF, NETCDF, FITS};
-
+ enum SourceType {
+ FileOrPipe = 0,
+ NetworkSocket,
+ LocalSocket,
+ SerialPort
+ };
+
+ enum UpdateType {
+ TimeInterval = 0,
+ NewData
+ };
FileDataSource(AbstractScriptingEngine*, const QString& name, bool loading = \
false); ~FileDataSource();
@@ -55,6 +68,27 @@ public:
void setFileType(const FileType);
FileType fileType() const;
+ UpdateType updateType() const;
+ void setUpdateType(const UpdateType);
+
+ SourceType sourceType() const;
+ void setSourceType(const SourceType);
+
+ int sampleRate() const;
+ void setSampleRate(const int);
+
+ int port() const;
+ void setPort(const int);
+
+ QString host() const;
+ void setHost(const QString&);
+
+ int baudRate() const;
+ void setBaudRate(const int);
+
+ void setUpdateFrequency(const int);
+ int updateFrequency() const;
+
void setFileWatched(const bool);
bool isFileWatched() const;
@@ -85,6 +119,17 @@ private:
AbstractFileFilter* m_filter;
QFileSystemWatcher* m_fileSystemWatcher;
+ UpdateType m_updateType;
+ SourceType m_sourceType;
+ int m_sampleRate;
+ int m_updateFrequency;
+ int m_port;
+ int m_baudRate;
+ QString m_host;
+ QSerialPort m_serialPort;
+ QSocketNotifier* m_localSocketNotifier;
+ QLocalSocket m_localSocket;
+
QAction* m_reloadAction;
QAction* m_toggleLinkAction;
QAction* m_toggleWatchAction;
diff --git a/src/kdefrontend/datasources/ImportFileWidget.cpp \
b/src/kdefrontend/datasources/ImportFileWidget.cpp index f4f87c60..dd2f2c5e 100644
--- a/src/kdefrontend/datasources/ImportFileWidget.cpp
+++ b/src/kdefrontend/datasources/ImportFileWidget.cpp
@@ -1040,21 +1040,21 @@ void ImportFileWidget::refreshPreview() {
}
void ImportFileWidget::updateTypeChanged(int idx) {
- UpdateType type = static_cast<UpdateType>(idx);
+ FileDataSource::UpdateType type = static_cast<FileDataSource::UpdateType>(idx);
- if (type == UpdateType::TimeInterval) {
+ if (type == FileDataSource::UpdateType::TimeInterval) {
ui.lUpdateFrequency->show();
ui.sbUpdateFrequency->show();
- } else if (type == UpdateType::NewData) {
+ } else if (type == FileDataSource::UpdateType::NewData) {
ui.lUpdateFrequency->hide();
ui.sbUpdateFrequency->hide();
}
}
void ImportFileWidget::sourceTypeChanged(int idx) {
- SourceType type = static_cast<SourceType>(idx);
+ FileDataSource::SourceType type = static_cast<FileDataSource::SourceType>(idx);
- if ((type == SourceType::FileOrPipe) || (type == SourceType::LocalSocket)) {
+ if ((type == FileDataSource::SourceType::FileOrPipe) || (type == \
FileDataSource::SourceType::LocalSocket)) { ui.lFileName->show();
ui.kleFileName->show();
ui.bFileInfo->show();
@@ -1068,7 +1068,7 @@ void ImportFileWidget::sourceTypeChanged(int idx) {
ui.lePort->hide();
ui.cbSerialPort->hide();
ui.lSerialPort->hide();
- } else if (type == SourceType::NetworkSocket) {
+ } else if (type == FileDataSource::SourceType::NetworkSocket) {
ui.lHost->show();
ui.leHost->show();
ui.lePort->show();
@@ -1084,7 +1084,7 @@ void ImportFileWidget::sourceTypeChanged(int idx) {
ui.bFileInfo->hide();
ui.bOpen->hide();
- } else if (type == SourceType::SerialPort) {
+ } else if (type == FileDataSource::SourceType::SerialPort) {
ui.lBaudRate->show();
ui.cbBaudRate->show();
ui.lSerialPort->show();
diff --git a/src/kdefrontend/datasources/ImportFileWidget.h \
b/src/kdefrontend/datasources/ImportFileWidget.h index a0d1c15a..261171f7 100644
--- a/src/kdefrontend/datasources/ImportFileWidget.h
+++ b/src/kdefrontend/datasources/ImportFileWidget.h
@@ -62,17 +62,6 @@ public:
void initializeAndFillPortsAndBaudRates();
private:
- enum SourceType {
- FileOrPipe = 0,
- NetworkSocket,
- LocalSocket,
- SerialPort
- };
-
- enum UpdateType {
- TimeInterval = 0,
- NewData
- };
Ui::ImportFileWidget ui;
Ui::AsciiOptionsWidget asciiOptionsWidget;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic