[-]
[+]
|
Changed |
_service:tar_git:valuelogger.spec
|
|
[-]
[+]
|
Changed |
_service
^
|
@@ -2,6 +2,6 @@
<service name="tar_git">
<param name="url">https://github.com/monich/valuelogger.git</param>
<param name="branch">master</param>
- <param name="revision">3f62046</param>
+ <param name="revision">6bd0d90</param>
</service>
</services>
\ No newline at end of file
|
[-]
[+]
|
Added |
_service:tar_git:harbour-valuelogger2-1.0.17.tar.bz2/qml/components/ActionButton.qml
^
|
@@ -0,0 +1,16 @@
+import QtQuick 2.0
+import Sailfish.Silica 1.0
+
+Item {
+ property alias source: image.source
+
+ width: Theme.coverSizeSmall.width/2
+ height: Theme.itemSizeSmall
+
+ Image {
+ id: image
+
+ anchors.centerIn: parent
+ sourceSize.height: Theme.iconSizeSmall
+ }
+}
|
[-]
[+]
|
Added |
_service:tar_git:harbour-valuelogger2-1.0.17.tar.bz2/qml/components/CoverPreview.qml
^
|
@@ -0,0 +1,66 @@
+import QtQuick 2.0
+import Sailfish.Silica 1.0
+
+Rectangle {
+ id: root
+
+ property bool selected
+ property string source
+ property var dataModel
+
+ signal clicked()
+
+ readonly property bool darkOnLight: 'colorScheme' in Theme && Theme.colorScheme === Theme.DarkOnLight
+ readonly property url plotIconSource: Qt.resolvedUrl("../images/" + (darkOnLight ? "icon-cover-plot-dark.svg" : "icon-cover-plot.svg"))
+ property alias coverItem: coverItemLoader.item
+
+ width: Theme.coverSizeSmall.width
+ height: Theme.coverSizeSmall.height
+ color: Theme.rgba(Theme.highlightBackgroundColor, mouseArea.pressed ? Theme.highlightBackgroundOpacity : 0.2)
+ radius: Theme.paddingSmall
+ border {
+ color: Theme.highlightColor
+ width: root.selected ? Theme.paddingSmall/2 : 0
+ }
+ layer.enabled: mouseArea.pressed
+ layer.effect: PressEffect {
+ source: root
+ }
+
+ Loader {
+ id: coverItemLoader
+
+ width: Theme.coverSizeLarge.width
+ height: Theme.coverSizeLarge.height
+ scale: Theme.coverSizeSmall.width/Theme.coverSizeLarge.width
+ anchors.centerIn: parent
+ source: Qt.resolvedUrl(root.source)
+ }
+
+ Binding { target: coverItem; property: "coverScale"; value: Theme.coverSizeSmall.width/Theme.coverSizeLarge.width }
+ Binding { target: coverItem; property: "graphColor"; value: Theme.highlightBackgroundColor }
+ Binding { target: coverItem; property: "graphModel"; value: dataModel }
+ Binding { target: coverItem; property: "title"; value: qsTr("Example") }
+
+ Grid {
+ anchors.bottom: parent.bottom
+ columns: 2
+
+ ActionButton {
+ width: root.width/2
+ source: "image://theme/icon-cover-new"
+ }
+
+ ActionButton {
+ width: root.width/2
+ source: root.plotIconSource
+ }
+ }
+
+ MouseArea {
+ id: mouseArea
+
+ anchors.fill: parent
+ onClicked: root.clicked()
+ }
+}
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-valuelogger2-1.0.17.tar.bz2/qml/components/LinePlot.qml
^
|
@@ -627,7 +627,7 @@
maxTime: xend
lineWidth: paintedCount ? Math.max(Math.ceil(Math.min(maxLineWidth, width/paintedCount)), minLineWidth) : maxLineWidth
color: modelData.plotcolor
- model: DataModel {
+ model: DataTableModel {
dataTable: modelData.datatable
}
}
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-valuelogger2-1.0.17.tar.bz2/qml/components/SettingsView.qml
^
|
@@ -111,14 +111,29 @@
}
}
- SectionHeader { text: qsTr("Miscellaneous") }
+ SectionHeader { text: qsTr("Cover") }
- TextSwitch {
- width: parent.width
- text: qsTr("Show graph on the cover")
- automaticCheck: false
- checked: Settings.showGraphOnCover
- onClicked: Settings.showGraphOnCover = !Settings.showGraphOnCover
+ DataModel {
+ id: sampleModel
+
+ rawData: Settings.sampleData
+ }
+
+ Grid {
+ x: Theme.horizontalPageMargin
+ columnSpacing: Theme.paddingLarge
+ rowSpacing: Theme.paddingLarge
+ columns: Math.floor((parent.width - 2 * x + columnSpacing)/(Theme.coverSizeSmall.width + columnSpacing))
+
+ Repeater {
+ model: Settings.coverItems
+ delegate: CoverPreview {
+ dataModel: sampleModel
+ source: "../cover/" + modelData
+ selected: (Settings.coverStyle === model.index)
+ onClicked: Settings.coverStyle = model.index
+ }
+ }
}
}
}
|
[-]
[+]
|
Added |
_service:tar_git:harbour-valuelogger2-1.0.17.tar.bz2/qml/cover/CoverItem1.qml
^
|
@@ -0,0 +1,3 @@
+CoverItemBase {
+ showIcon: true
+}
|
[-]
[+]
|
Added |
_service:tar_git:harbour-valuelogger2-1.0.17.tar.bz2/qml/cover/CoverItem2.qml
^
|
@@ -0,0 +1,99 @@
+import QtQuick 2.0
+import Sailfish.Silica 1.0
+import harbour.valuelogger 1.0
+
+import "../components"
+
+CoverItemBase {
+ id: thisItem
+
+ graphBottomY: graphItem.x + graphItem.height
+
+ Loader {
+ id: graphItem
+
+ y: x
+ width: parent.width - 2 * Theme.paddingLarge
+ height: width
+ anchors.horizontalCenter: parent.horizontalCenter
+ active: showGraph
+ sourceComponent: Component {
+ Item {
+ anchors.fill: parent
+
+ Graph {
+ id: graph
+
+ readonly property real extraValueRoom: height ? (lineWidth / height * (model.maxValue - model.minValue)) : 0
+
+ anchors.centerIn: parent
+ width: parent.width - 2 * graphBorder.border.width
+ height: parent.height - 2 * graphBorder.border.width
+ model: graphModel
+ minValue: model.minValue - extraValueRoom
+ maxValue: model.maxValue + extraValueRoom
+ minTime: model.minTime
+ maxTime: model.maxTime
+ lineWidth: thickLine
+ nodeMarks: false
+ color: graphColor
+ }
+
+ ShaderEffectSource {
+ id: grid
+
+ readonly property color color: Theme.primaryColor
+
+ anchors.fill: parent
+ opacity: 0.4
+ sourceItem: Item {
+ width: grid.width
+ height: grid.height
+
+ Repeater {
+ id: verticalGrid
+
+ readonly property int gridCount: 5
+ model: gridCount - 1
+ delegate: VDashLine {
+ x: Math.round(graph.x + Math.round((index + 1) * graph.width / verticalGrid.gridCount - width / 2))
+ y: graph.y
+ width: thinLine
+ height: graph.height
+ dashSize: 2 * width
+ color: grid.color
+ }
+ }
+
+ Repeater {
+ id: horizontalGrid
+
+ readonly property int gridCount: 5
+ model: gridCount - 1
+ delegate: HDashLine {
+ x: graph.x
+ y: graph.y + Math.round((index + 1) * graph.height / horizontalGrid.gridCount - height / 2)
+ width: graph.width
+ height: thinLine
+ dashSize: 2 * height
+ color: grid.color
+ }
+ }
+ }
+ }
+
+ Rectangle {
+ id: graphBorder
+
+ anchors.fill: parent
+ opacity: 0.6
+ color: "transparent"
+ border {
+ width: thickLine
+ color: Theme.primaryColor
+ }
+ }
+ }
+ }
+ }
+}
|
[-]
[+]
|
Added |
_service:tar_git:harbour-valuelogger2-1.0.17.tar.bz2/qml/cover/CoverItem3.qml
^
|
@@ -0,0 +1,134 @@
+import QtQuick 2.0
+import QtGraphicalEffects 1.0
+import Sailfish.Silica 1.0
+import harbour.valuelogger 1.0
+
+import "../components"
+
+CoverItemBase {
+ id: thisItem
+
+ graphBottomY: graphItem.x + graphItem.height
+
+ Loader {
+ id: graphItem
+
+ y: x
+ width: parent.width - 2 * Theme.paddingLarge
+ height: width
+ anchors.horizontalCenter: parent.horizontalCenter
+ active: showGraph
+ sourceComponent: Component {
+ Item {
+ anchors.fill: parent
+
+ Rectangle {
+ id: background
+
+ x: thickLine
+ y: thickLine
+ width: parent.width - 2 * x
+ height: parent.height - 2 * y
+ color: darkOnLight ? "white" : "black"
+ radius: Theme.paddingSmall - thickLine
+ opacity: 0.2
+ }
+
+ Rectangle {
+ id: mask
+
+ anchors.fill: background
+ color: background.color
+ radius: background.radius
+ visible: false
+ }
+
+ Connections {
+ target: thisItem
+ onUpdateGraph: graph.update()
+ }
+
+ Graph {
+ id: graph
+
+ readonly property real extraValueRoom: height ? (lineWidth / height * (model.maxValue - model.minValue)) : 0
+
+ anchors.centerIn: parent
+ width: parent.width - 2 * graphBorder.border.width
+ height: parent.height - 2 * graphBorder.border.width
+ model: graphModel
+ minValue: model.minValue - extraValueRoom
+ maxValue: model.maxValue + extraValueRoom
+ minTime: model.minTime
+ maxTime: model.maxTime
+ lineWidth: thickLine
+ nodeMarks: false
+ color: graphColor
+ visible: false
+ }
+
+ OpacityMask {
+ anchors.fill: graph
+ source: graph
+ maskSource: mask
+ }
+
+ ShaderEffectSource {
+ id: grid
+
+ readonly property color color: Theme.primaryColor
+
+ anchors.fill: parent
+ opacity: 0.4
+ sourceItem: Item {
+ width: grid.width
+ height: grid.height
+
+ Repeater {
+ id: verticalGrid
+
+ readonly property int gridCount: 5
+ model: gridCount - 1
+ delegate: VDashLine {
+ x: Math.round(graph.x + Math.round((index + 1) * graph.width / verticalGrid.gridCount - width / 2))
+ y: graph.y
+ width: thinLine
+ height: graph.height
+ dashSize: 2 * width
+ color: grid.color
+ }
+ }
+
+ Repeater {
+ id: horizontalGrid
+
+ readonly property int gridCount: 5
+ model: gridCount - 1
+ delegate: HDashLine {
+ x: graph.x
+ y: graph.y + Math.round((index + 1) * graph.height / horizontalGrid.gridCount - height / 2)
+ width: graph.width
+ height: thinLine
+ dashSize: 2 * height
+ color: grid.color
+ }
+ }
+ }
+ }
+
+ Rectangle {
+ id: graphBorder
+
+ anchors.fill: parent
+ opacity: 0.6
+ color: "transparent"
+ radius: Theme.paddingSmall
+ border {
+ width: thickLine
+ color: Theme.primaryColor
+ }
+ }
+ }
+ }
+ }
+}
|
[-]
[+]
|
Added |
_service:tar_git:harbour-valuelogger2-1.0.17.tar.bz2/qml/cover/CoverItemBase.qml
^
|
@@ -0,0 +1,74 @@
+import QtQuick 2.0
+import Sailfish.Silica 1.0
+
+import "../components"
+
+Item {
+ /* API */
+
+ property real coverScale: scale
+ property bool showGraph: true
+ property color graphColor
+ property var graphModel
+ property alias title: label.text
+
+ signal updateGraph()
+
+ /* Internal API */
+
+ property real graphBottomY
+ property bool showIcon: !showGraph
+
+ readonly property bool darkOnLight: 'colorScheme' in Theme && Theme.colorScheme === Theme.DarkOnLight
+ readonly property real thinLine: Math.max(1/scale, Math.floor(Theme.paddingSmall/4))
+ readonly property real thickLine: Math.max(2, Math.floor(Theme.paddingSmall/2))
+
+ /* Implementation */
+
+ Item {
+ id: iconItem
+
+ readonly property int padding: Theme.paddingSmall
+
+ y: x
+ width: parent.width / 2 + 2 * padding
+ height: width
+ anchors.horizontalCenter: parent.horizontalCenter
+ visible: showIcon
+
+ HighlightIcon {
+ source: showIcon ? "../images/icon-background.svg" : ""
+ highlightColor: Theme.primaryColor
+ anchors.centerIn: parent
+ sourceSize.width: icon.width + parent.padding
+ sourceSize.height: icon.height + parent.padding
+ opacity: 0.2
+ }
+
+ Image {
+ id: icon
+
+ source: showIcon ? "../images/harbour-valuelogger2.svg" : ""
+ anchors.centerIn: parent
+ sourceSize.width: parent.width - 2 * parent.padding
+ }
+ }
+
+ Label {
+ id: label
+
+ anchors {
+ horizontalCenter: parent.horizontalCenter
+ top: parent.top
+ topMargin: showIcon ? (iconItem.y + iconItem.height) : graphBottomY
+ bottom: parent.bottom
+ bottomMargin: (Theme.itemSizeSmall + Theme.iconSizeSmall)/2/coverScale
+ }
+ width: Math.min(implicitWidth, parent.width - 2 * Theme.paddingLarge)
+ verticalAlignment: Text.AlignVCenter
+ truncationMode: TruncationMode.Fade
+ minimumPixelSize: Theme.fontSizeExtraSmall
+ fontSizeMode: Text.Fit
+ color: Theme.highlightColor
+ }
+}
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-valuelogger2-1.0.17.tar.bz2/qml/cover/CoverPage.qml
^
|
@@ -1,5 +1,4 @@
import QtQuick 2.0
-import QtGraphicalEffects 1.0
import Sailfish.Silica 1.0
import harbour.valuelogger 1.0
@@ -16,191 +15,43 @@
readonly property int thinLine: Math.max(1, Math.floor(Theme.paddingSmall/4))
readonly property int thickLine: Math.max(2, Math.floor(Theme.paddingSmall/2))
readonly property bool showGraph: Settings.showGraphOnCover && Logger.defaultParameterTable !== ""
+ readonly property string title: Logger.defaultParameterName ? Logger.defaultParameterName : "Value logger"
- Item {
- id: iconItem
+ property alias coverItem: coverItemLoader.item
- readonly property int padding: Theme.paddingSmall
-
- y: x
- width: parent.width / 2 + 2 * padding
- height: width
- anchors.horizontalCenter: parent.horizontalCenter
- visible: !showGraph
-
- HighlightIcon {
- source: showGraph ? "" : "../images/icon-background.svg"
- highlightColor: Theme.primaryColor
- anchors.centerIn: parent
- sourceSize.width: icon.width + parent.padding
- sourceSize.height: icon.height + parent.padding
- opacity: 0.2
- }
-
- Image {
- id: icon
-
- source: showGraph ? "" : Qt.resolvedUrl("../images/harbour-valuelogger2.svg")
- anchors.centerIn: parent
- sourceSize.width: parent.width - 2 * parent.padding
+ Connections {
+ target: Logger
+ onTableUpdated: {
+ if (table == defaultParameterData.dataTable) {
+ defaultParameterData.reset()
+ }
}
}
- Loader {
- id: graphItem
+ DataTableModel {
+ id: defaultParameterData
- y: x
- width: parent.width - 2 * Theme.paddingLarge
- height: width
- anchors.horizontalCenter: parent.horizontalCenter
- active: Settings.showGraphOnCover
- sourceComponent: Component {
- Item {
- anchors.fill: parent
- visible: showGraph
-
- Connections {
- target: Logger
- onTableUpdated: {
- if (table == defaultParameterData.dataTable) {
- defaultParameterData.reset()
- }
- }
- }
-
- DataModel {
- id: defaultParameterData
-
- readonly property real valueSpan: maxValue - minValue
-
- dataTable: Logger.defaultParameterTable
-
- onModelReset: graph.update()
- }
-
- Rectangle {
- id: background
-
- x: thickLine
- y: thickLine
- width: parent.width - 2 * x
- height: parent.height - 2 * y
- color: darkOnLight ? "white" : "black"
- radius: Theme.paddingSmall - thickLine
- opacity: 0.2
- }
-
- Rectangle {
- id: mask
-
- anchors.fill: background
- color: background.color
- radius: background.radius
- visible: false
- }
-
- Graph {
- id: graph
-
- readonly property real extraValueRoom: height ? (lineWidth / height * defaultParameterData.valueSpan) : 0
-
- anchors.centerIn: parent
- width: parent.width - 2 * graphBorder.border.width
- height: parent.height - 2 * graphBorder.border.width
- model: defaultParameterData
- minValue: defaultParameterData.minValue - extraValueRoom
- maxValue: defaultParameterData.maxValue + extraValueRoom
- minTime: defaultParameterData.minTime
- maxTime: defaultParameterData.maxTime
- lineWidth: thickLine
- nodeMarks: false
- color: Logger.defaultParameterColor
- visible: false
- }
-
- OpacityMask {
- anchors.fill: graph
- source: graph
- maskSource: mask
- }
-
- ShaderEffectSource {
- id: grid
-
- readonly property color color: Theme.primaryColor
-
- anchors.fill: parent
- opacity: 0.4
- sourceItem: Item {
- width: grid.width
- height: grid.height
-
- Repeater {
- id: verticalGrid
-
- readonly property int gridCount: 5
- model: gridCount - 1
- delegate: VDashLine {
- x: graph.x + Math.round((index + 1) * graph.width / verticalGrid.gridCount - width / 2)
- y: graph.y
- width: thinLine
- height: graph.height
- dashSize: 2 * width
- color: grid.color
- }
- }
-
- Repeater {
- id: horizontalGrid
-
- readonly property int gridCount: 5
- model: gridCount - 1
- delegate: HDashLine {
- x: graph.x
- y: graph.x + Math.round((index + 1) * graph.height / horizontalGrid.gridCount - height / 2)
- width: graph.width
- height: thinLine
- dashSize: 2 * height
- color: grid.color
- }
- }
- }
- }
-
- Rectangle {
- id: graphBorder
-
- anchors.fill: parent
- opacity: 0.6
- color: "transparent"
- radius: Theme.paddingSmall
- border {
- width: thickLine
- color: Theme.primaryColor
- }
- }
+ dataTable: Logger.defaultParameterTable
+ onModelReset: {
+ if (coverItem) {
+ coverItem.updateGraph()
}
}
}
- Label {
- id: label
+ Loader {
+ id: coverItemLoader
- anchors {
- horizontalCenter: parent.horizontalCenter
- top: showGraph ? graphItem.bottom : iconItem.bottom
- bottom: parent.bottom
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-valuelogger2-1.0.17.tar.bz2/qml/pages/ShowData.qml
^
|
@@ -19,7 +19,7 @@
}
}
- DataModel {
+ DataTableModel {
id: dataModel
}
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-valuelogger2-1.0.17.tar.bz2/src/datamodel.cpp
^
|
@@ -21,6 +21,7 @@
DEALINGS IN THE SOFTWARE.
*/
+#include "database.h"
#include "datamodel.h"
#include "debuglog.h"
@@ -32,12 +33,13 @@
AnnotationRole
};
+#define ROLE_TIMESTAMP_UTC_ROLE "timestampUTC"
+
namespace {
- const QString KEY(DATA_KEY_ROLE);
- const QString TIMESTAMP(DATA_TIMESTAMP_ROLE);
- const QString TIMESTAMP_UTC(DATA_TIMESTAMP_UTC_ROLE);
- const QString VALUE(DATA_VALUE_ROLE);
- const QString ANNOTATION(DATA_ANNOTATION_ROLE);
+ const QString KEY(ROLE_KEY_ROLE);
+ const QString TIMESTAMP(ROLE_TIMESTAMP_ROLE);
+ const QString VALUE(ROLE_VALUE_ROLE);
+ const QString ANNOTATION(ROLE_ANNOTATION_ROLE);
}
// UTC times are signiticantly faster to compare.
@@ -75,79 +77,137 @@
qDeleteAll(m_data);
}
-void DataModel::setDataTable(QString table)
+void DataModel::setRawData(QVariantList list)
{
- if (m_dataTable != table) {
- m_dataTable = table;
- reset();
- emit dataTableChanged();
+ if (m_rawData != list) {
+ const QDateTime prevMinTime(m_minTime);
+ const QDateTime prevMaxTime(m_maxTime);
+ const qreal prevMinValue(m_minValue);
+ const qreal prevMaxValue(m_maxValue);
+
+ beginResetModel();
+ m_rawData = list;
+
+ qDeleteAll(m_data);
+ m_data.resize(0);
+ m_minTime = m_maxTime = QDateTime();
+ m_minValue = m_maxValue = 0.0;
+ const int n = list.count();
+ DBG(n << "items");
+ if (n > 0) {
+
+ #define FIRST_TIME 0x01
+ #define FIRST_VALUE 0x02
+
+ m_data.reserve(n);
+ int first = (FIRST_TIME | FIRST_VALUE);
+ for (int i = 0; i < n; i++) {
+ Data* data = new Data(list.at(i).toMap());
+ m_data.append(data);
+
+ if (data->timestampUtc.isValid()) {
+ if (first & FIRST_TIME) {
+ first &= ~FIRST_TIME;
+ m_minTime = m_maxTime = data->timestampUtc;
+ } else if (m_minTime > data->timestampUtc) {
+ m_minTime = data->timestampUtc;
+ } else if (m_maxTime < data->timestampUtc) {
+ m_maxTime = data->timestampUtc;
+ }
+ }
+
+ bool ok;
+ const qreal value = data->value.toFloat(&ok);
+ if (ok) {
+ if (first & FIRST_VALUE) {
+ first &= ~FIRST_VALUE;
+ m_minValue = m_maxValue = value;
+ } else if (m_minValue > value) {
+ m_minValue = value;
+ } else if (m_maxValue < value) {
+ m_maxValue = value;
+ }
+ }
+ }
+ // Convert back to local
+ m_minTime = m_minTime.toLocalTime();
+ m_maxTime = m_maxTime.toLocalTime();
+ }
+ endResetModel();
+
+ DBG("Start:" << m_minTime);
+ DBG("End:" << m_maxTime);
+ DBG("Min:" << m_minValue);
+ DBG("Max:" << m_maxValue);
+
+ emit rawDataChanged();
+ if (m_minTime != prevMinTime) {
+ emit minTimeChanged();
+ }
+ if (m_maxTime != prevMaxTime) {
+ emit maxTimeChanged();
+ }
+ if (m_minValue != prevMinValue) {
+ emit minValueChanged();
+ }
+ if (m_maxValue != prevMaxValue) {
+ emit maxValueChanged();
+ }
}
}
-void DataModel::reset()
+void DataModel::updateRanges()
{
const QDateTime prevMinTime(m_minTime);
const QDateTime prevMaxTime(m_maxTime);
const qreal prevMinValue(m_minValue);
const qreal prevMaxValue(m_maxValue);
- beginResetModel();
- QVariantList rawData;
- if (!m_dataTable.isEmpty()) {
- rawData = m_db.readData(m_dataTable);
- }
-
- qDeleteAll(m_data);
- m_data.resize(0);
m_minTime = m_maxTime = QDateTime();
m_minValue = m_maxValue = 0.0;
- const int n = rawData.count();
- if (n > 0) {
-#define FIRST_TIME 0x01
-#define FIRST_VALUE 0x02
+ #define FIRST_TIME 0x01
+ #define FIRST_VALUE 0x02
- m_data.reserve(n);
- int first = (FIRST_TIME | FIRST_VALUE);
- for (int i = 0; i < n; i++) {
- Data* data = new Data(rawData.at(i).toMap());
- m_data.append(data);
-
- if (data->timestampUtc.isValid()) {
- if (first & FIRST_TIME) {
- first &= ~FIRST_TIME;
- m_minTime = m_maxTime = data->timestampUtc;
- } else if (m_minTime > data->timestampUtc) {
- m_minTime = data->timestampUtc;
- } else if (m_maxTime < data->timestampUtc) {
- m_maxTime = data->timestampUtc;
- }
+ int first = (FIRST_TIME | FIRST_VALUE);
+ const int n = m_data.count();
+ for (int i = 0; i < n; i++) {
+ const Data* data = m_data.at(i);
+
+ if (data->timestampUtc.isValid()) {
+ if (first & FIRST_TIME) {
+ first &= ~FIRST_TIME;
+ m_minTime = m_maxTime = data->timestampUtc;
+ } else if (m_minTime > data->timestampUtc) {
+ m_minTime = data->timestampUtc;
+ } else if (m_maxTime < data->timestampUtc) {
+ m_maxTime = data->timestampUtc;
}
+ }
- bool ok;
- const qreal value = data->value.toFloat(&ok);
- if (ok) {
- if (first & FIRST_VALUE) {
- first &= ~FIRST_VALUE;
- m_minValue = m_maxValue = value;
- } else if (m_minValue > value) {
- m_minValue = value;
- } else if (m_maxValue < value) {
- m_maxValue = value;
- }
+ bool ok;
+ const qreal value = data->value.toFloat(&ok);
+ if (ok) {
+ if (first & FIRST_VALUE) {
+ first &= ~FIRST_VALUE;
+ m_minValue = m_maxValue = value;
+ } else if (m_minValue > value) {
+ m_minValue = value;
+ } else if (m_maxValue < value) {
+ m_maxValue = value;
}
}
- // Convert back to local
- m_minTime = m_minTime.toLocalTime();
- m_maxTime = m_maxTime.toLocalTime();
}
- endResetModel();
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-valuelogger2-1.0.17.tar.bz2/src/datamodel.h
^
|
@@ -24,16 +24,19 @@
#ifndef DATAMODEL_H
#define DATAMODEL_H
-#include "database.h"
-
#include <QDateTime>
#include <QVariantList>
#include <QAbstractListModel>
+#define ROLE_KEY_ROLE "key"
+#define ROLE_TIMESTAMP_ROLE "timestamp"
+#define ROLE_VALUE_ROLE "value"
+#define ROLE_ANNOTATION_ROLE "annotation"
+
class DataModel : public QAbstractListModel
{
Q_OBJECT
- Q_PROPERTY(QString dataTable READ getDataTable WRITE setDataTable NOTIFY dataTableChanged)
+ Q_PROPERTY(QVariantList rawData READ getRawdata WRITE setRawData NOTIFY rawDataChanged)
Q_PROPERTY(QDateTime minTime READ getMinTime NOTIFY minTimeChanged)
Q_PROPERTY(QDateTime maxTime READ getMaxTime NOTIFY maxTimeChanged)
Q_PROPERTY(qreal minValue READ getMinValue NOTIFY minValueChanged)
@@ -44,15 +47,14 @@
explicit DataModel(QObject* parent = Q_NULLPTR);
~DataModel();
- QString getDataTable() const { return m_dataTable; }
- void setDataTable(QString table);
+ QVariantList getRawdata() const { return m_rawData; }
+ void setRawData(QVariantList data);
const QDateTime& getMinTime() const { return m_minTime; }
const QDateTime& getMaxTime() const { return m_maxTime; }
qreal getMinValue() const { return m_minValue; }
qreal getMaxValue() const { return m_maxValue; }
- Q_INVOKABLE void reset();
Q_INVOKABLE void deleteRow(int row);
Q_INVOKABLE void updateRow(int row, QString value, QString annotation, QString timestamp);
@@ -61,11 +63,15 @@
int rowCount(const QModelIndex& parent = QModelIndex()) const Q_DECL_OVERRIDE;
QVariant data(const QModelIndex& idx, int role) const Q_DECL_OVERRIDE;
+protected:
+ virtual void deleteRowStorage(QString key);
+ virtual bool updateRowStorage(QString key, QString value, QString annotation, QString timestamp);
+
private:
void updateRanges();
signals:
- void dataTableChanged();
+ void rawDataChanged();
void minTimeChanged();
void maxTimeChanged();
void minValueChanged();
@@ -74,8 +80,7 @@
private:
class Data;
- Database m_db;
- QString m_dataTable;
+ QVariantList m_rawData;
QVector<Data*> m_data;
QDateTime m_minTime;
QDateTime m_maxTime;
|
[-]
[+]
|
Added |
_service:tar_git:harbour-valuelogger2-1.0.17.tar.bz2/src/datatablemodel.cpp
^
|
@@ -0,0 +1,61 @@
+/*
+Copyright (c) 2021 Slava Monich <slava@monich.com>
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without restriction,
+including without limitation the rights to use, copy, modify, merge,
+publish, distribute, sublicense, and/or sell copies of the Software,
+and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
+*/
+
+#include "datatablemodel.h"
+#include "debuglog.h"
+
+DataTableModel::DataTableModel(QObject* parent) :
+ DataModel(parent)
+{
+}
+
+DataTableModel::~DataTableModel()
+{
+}
+
+void DataTableModel::setDataTable(QString table)
+{
+ if (m_dataTable != table) {
+ m_dataTable = table;
+ reset();
+ emit dataTableChanged();
+ }
+}
+
+void DataTableModel::deleteRowStorage(QString key)
+{
+ if (!m_dataTable.isEmpty()) {
+ m_db.deleteData(m_dataTable, key);
+ }
+}
+
+bool DataTableModel::updateRowStorage(QString key, QString value, QString annotation, QString timestamp)
+{
+ return !m_dataTable.isEmpty() &&
+ !m_db.addData(m_dataTable, key, value, annotation, timestamp).isEmpty();
+}
+
+void DataTableModel::reset()
+{
+ setRawData(m_dataTable.isEmpty() ? QVariantList() : m_db.readData(m_dataTable));
+}
|
[-]
[+]
|
Added |
_service:tar_git:harbour-valuelogger2-1.0.17.tar.bz2/src/datatablemodel.h
^
|
@@ -0,0 +1,56 @@
+/*
+Copyright (c) 2021 Slava Monich <slava@monich.com>
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without restriction,
+including without limitation the rights to use, copy, modify, merge,
+publish, distribute, sublicense, and/or sell copies of the Software,
+and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
+*/
+
+#ifndef DATATABLEMODEL_H
+#define DATATABLEMODEL_H
+
+#include "datamodel.h"
+#include "database.h"
+
+class DataTableModel : public DataModel
+{
+ Q_OBJECT
+ Q_PROPERTY(QString dataTable READ getDataTable WRITE setDataTable NOTIFY dataTableChanged)
+
+public:
+ explicit DataTableModel(QObject* parent = Q_NULLPTR);
+ ~DataTableModel();
+
+ QString getDataTable() const { return m_dataTable; }
+ void setDataTable(QString table);
+
+ Q_INVOKABLE void reset();
+
+protected:
+ void deleteRowStorage(QString key) Q_DECL_OVERRIDE;
+ bool updateRowStorage(QString key, QString value, QString annotation, QString timestamp) Q_DECL_OVERRIDE;
+
+signals:
+ void dataTableChanged();
+
+private:
+ Database m_db;
+ QString m_dataTable;
+};
+
+#endif // DATATABLEMODEL_H
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-valuelogger2-1.0.17.tar.bz2/src/settings.cpp
^
|
@@ -22,11 +22,26 @@
*/
#include "settings.h"
+#include "datamodel.h"
+#include "debuglog.h"
#define CONFIG_ROOT "/apps/harbour-valuelogger2/"
#define DCONF_KEY(x) CONFIG_ROOT x
+namespace {
+ const QString KEY(ROLE_KEY_ROLE);
+ const QString TIMESTAMP(ROLE_TIMESTAMP_ROLE);
+ const QString VALUE(ROLE_VALUE_ROLE);
+ const int STATIC_COVER_STYLE = 0;
+ const int DEFAULT_COVER_STYLE = 2;
+}
+
const QString Settings::ConfigRoot(CONFIG_ROOT);
+const QVariantList Settings::SampleData(Settings::createSampleData());
+const QStringList Settings::CoverItems(QStringList(
+ QStringLiteral("CoverItem1.qml")) <<
+ QStringLiteral("CoverItem2.qml") <<
+ QStringLiteral("CoverItem3.qml"));
Settings::Settings(QObject* parent) :
QObject(parent),
@@ -35,7 +50,8 @@
m_topGridLabels(new MGConfItem(DCONF_KEY("topGridLabels"), this)),
m_leftGridLabels(new MGConfItem(DCONF_KEY("leftGridLabels"), this)),
m_rightGridLabels(new MGConfItem(DCONF_KEY("rightGridLabels"), this)),
- m_showGraphOnCover(new MGConfItem(DCONF_KEY("showGraphOnCover"), this))
+ m_showGraphOnCover(new MGConfItem(DCONF_KEY("showGraphOnCover"), this)),
+ m_coverStyle(new MGConfItem(DCONF_KEY("coverStyle"), this))
{
connect(m_verticalGridLinesStyle, SIGNAL(valueChanged()), SIGNAL(verticalGridLinesStyleChanged()));
connect(m_horizontalGridLinesStyle, SIGNAL(valueChanged()), SIGNAL(horizontalGridLinesStyleChanged()));
@@ -43,6 +59,8 @@
connect(m_leftGridLabels, SIGNAL(valueChanged()), SIGNAL(leftGridLabelsChanged()));
connect(m_rightGridLabels, SIGNAL(valueChanged()), SIGNAL(rightGridLabelsChanged()));
connect(m_showGraphOnCover, SIGNAL(valueChanged()), SIGNAL(showGraphOnCoverChanged()));
+ connect(m_showGraphOnCover, SIGNAL(valueChanged()), SIGNAL(coverStyleChanged()));
+ connect(m_coverStyle, SIGNAL(valueChanged()), SIGNAL(coverStyleChanged()));
}
/* Callback for qmlRegisterSingletonType<Settings> */
@@ -50,3 +68,56 @@
{
return new Settings;
}
+
+QVariantList Settings::createSampleData()
+{
+ QVariantList list;
+ QVariantMap entry;
+
+ entry.insert(KEY, 0);
+ entry.insert(VALUE, 275);
+ entry.insert(TIMESTAMP, "2020-11-01 00:00:00");
+ list.append(entry);
+ entry.clear();
+
+ entry.insert(KEY, 1);
+ entry.insert(VALUE, 284);
+ entry.insert(TIMESTAMP, "2020-12-01 00:00:00");
+ list.append(entry);
+ entry.clear();
+
+ entry.insert(KEY, 2);
+ entry.insert(VALUE, 273);
+ entry.insert(TIMESTAMP, "2021-01-01 00:00:00");
+ list.append(entry);
+ entry.clear();
+
+ entry.insert(KEY, 3);
+ entry.insert(VALUE, 289);
+ entry.insert(TIMESTAMP, "2021-02-01 00:00:00");
+ list.append(entry);
+ return list;
+}
+
+int Settings::validateCoverStyle(int style)
+{
+ return (style >= 0 && style < CoverItems.size()) ? style : DEFAULT_COVER_STYLE;
+}
+
+int Settings::getCoverStyle() const
+{
+ if (getShowGraphOnCover()) {
+ int style = validateCoverStyle(m_coverStyle->value(DEFAULT_COVER_STYLE).toInt());
+ return (style != STATIC_COVER_STYLE) ? style : DEFAULT_COVER_STYLE;
+ } else {
+ return STATIC_COVER_STYLE;
+ }
+}
+
+void Settings::setCoverStyle(int style)
+{
+ const int validatedStyle = validateCoverStyle(style);
+ DBG(validatedStyle);
+ setShowGraphOnCover(validatedStyle != STATIC_COVER_STYLE);
+ m_coverStyle->set(validatedStyle);
+}
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-valuelogger2-1.0.17.tar.bz2/src/settings.h
^
|
@@ -42,6 +42,14 @@
Q_PROPERTY(bool leftGridLabels READ getLeftGridLabels WRITE setLeftGridLabels NOTIFY leftGridLabelsChanged)
Q_PROPERTY(bool rightGridLabels READ getRightGridLabels WRITE setRightGridLabels NOTIFY rightGridLabelsChanged)
Q_PROPERTY(bool showGraphOnCover READ getShowGraphOnCover WRITE setShowGraphOnCover NOTIFY showGraphOnCoverChanged)
+ Q_PROPERTY(int coverStyle READ getCoverStyle WRITE setCoverStyle NOTIFY coverStyleChanged)
+ Q_PROPERTY(QString coverItem READ getCoverItem NOTIFY coverStyleChanged)
+ Q_PROPERTY(QStringList coverItems READ getCoverItems CONSTANT)
+ Q_PROPERTY(QVariantList sampleData READ getSampleData CONSTANT)
+
+ static const QString ConfigRoot;
+ static const QStringList CoverItems;
+ static const QVariantList SampleData;
public:
enum GridLinesStyle {
@@ -51,6 +59,16 @@
explicit Settings(QObject* parent = Q_NULLPTR);
+ /* Callback for qmlRegisterSingletonType<Settings> */
+ static QObject* createSingleton(QQmlEngine* engine, QJSEngine* js);
+
+ /* Static helpers */
+ static const QString& getConfigRoot() { return ConfigRoot; }
+ static const QStringList& getCoverItems() { return CoverItems; }
+ static const QVariantList& getSampleData() { return SampleData; }
+ static int validateCoverStyle(int style);
+
+ /* Getters and setters */
GridLinesStyle getVerticalGridLinesStyle() const { return (GridLinesStyle) m_verticalGridLinesStyle->value((int) GridLinesDynamic).toInt(); }
void setVerticalGridLinesStyle(GridLinesStyle value) { m_verticalGridLinesStyle->set((int) value); }
@@ -69,11 +87,12 @@
bool getShowGraphOnCover() const { return m_showGraphOnCover->value(true).toBool(); }
void setShowGraphOnCover(bool value) { m_showGraphOnCover->set(value); }
- static const QString ConfigRoot;
- static const QString getConfigRoot() { return ConfigRoot; }
+ int getCoverStyle() const;
+ void setCoverStyle(int style);
+ const QString& getCoverItem() const { return CoverItems.at(getCoverStyle()); }
- /* Callback for qmlRegisterSingletonType<Settings> */
- static QObject* createSingleton(QQmlEngine* engine, QJSEngine* js);
+private:
+ static QVariantList createSampleData();
signals:
void verticalGridLinesStyleChanged();
@@ -82,6 +101,7 @@
void leftGridLabelsChanged();
void rightGridLabelsChanged();
void showGraphOnCoverChanged();
+ void coverStyleChanged();
private:
MGConfItem* m_verticalGridLinesStyle;
@@ -90,6 +110,7 @@
MGConfItem* m_leftGridLabels;
MGConfItem* m_rightGridLabels;
MGConfItem* m_showGraphOnCover;
+ MGConfItem* m_coverStyle;
};
#endif // SETTINGS_H
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-valuelogger2-1.0.17.tar.bz2/src/valuelogger.cpp
^
|
@@ -27,6 +27,7 @@
#include "hdashline.h"
#include "logger.h"
#include "datamodel.h"
+#include "datatablemodel.h"
#include "debuglog.h"
#include "pairmodel.h"
#include "settings.h"
@@ -71,6 +72,7 @@
qmlRegisterType<ColorModel>(uri, 1, 0, "ColorModel");
qmlRegisterType<Graph>(uri, 1, 0, "Graph");
qmlRegisterType<DataModel>(uri, 1, 0, "DataModel");
+ qmlRegisterType<DataTableModel>(uri, 1, 0, "DataTableModel");
qmlRegisterType<HDashLine>(uri, 1, 0, "HDashLine");
qmlRegisterType<VDashLine>(uri, 1, 0, "VDashLine");
qmlRegisterType<PairModel>(uri, 1, 0, "PairModel");
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-valuelogger2-1.0.17.tar.bz2/translations/harbour-valuelogger2.ts
^
|
@@ -81,6 +81,13 @@
</message>
</context>
<context>
+ <name>CoverPreview</name>
+ <message>
+ <source>Example</source>
+ <translation>Example</translation>
+ </message>
+</context>
+<context>
<name>DrawData</name>
<message>
<source>Plot</source>
@@ -208,12 +215,8 @@
<translation>Right labels</translation>
</message>
<message>
- <source>Miscellaneous</source>
- <translation>Miscellaneous</translation>
- </message>
- <message>
- <source>Show graph on the cover</source>
- <translation>Show graph on the cover</translation>
+ <source>Cover</source>
+ <translation>Cover</translation>
</message>
</context>
<context>
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-valuelogger2-1.0.17.tar.bz2/translations/harbour-valuelogger2_fi.ts
^
|
@@ -81,6 +81,13 @@
</message>
</context>
<context>
+ <name>CoverPreview</name>
+ <message>
+ <source>Example</source>
+ <translation type="unfinished">Esimerkki</translation>
+ </message>
+</context>
+<context>
<name>DrawData</name>
<message>
<source>Plot</source>
@@ -208,12 +215,8 @@
<translation type="unfinished">Otsikot oikealla</translation>
</message>
<message>
- <source>Miscellaneous</source>
- <translation type="unfinished">Sekalaista</translation>
- </message>
- <message>
- <source>Show graph on the cover</source>
- <translation type="unfinished">Näytä käppyrä kansilehdellä</translation>
+ <source>Cover</source>
+ <translation type="unfinished">Kansilehti</translation>
</message>
</context>
<context>
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-valuelogger2-1.0.17.tar.bz2/translations/harbour-valuelogger2_pl.ts
^
|
@@ -81,6 +81,13 @@
</message>
</context>
<context>
+ <name>CoverPreview</name>
+ <message>
+ <source>Example</source>
+ <translation type="unfinished">Przykład</translation>
+ </message>
+</context>
+<context>
<name>DrawData</name>
<message>
<source>Plot</source>
@@ -208,12 +215,8 @@
<translation>Prawe etykiety</translation>
</message>
<message>
- <source>Miscellaneous</source>
- <translation>Różne</translation>
- </message>
- <message>
- <source>Show graph on the cover</source>
- <translation>Pokaż wykres na okładce</translation>
+ <source>Cover</source>
+ <translation>Okładka</translation>
</message>
</context>
<context>
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-valuelogger2-1.0.17.tar.bz2/translations/harbour-valuelogger2_ru.ts
^
|
@@ -81,6 +81,13 @@
</message>
</context>
<context>
+ <name>CoverPreview</name>
+ <message>
+ <source>Example</source>
+ <translation>Пример</translation>
+ </message>
+</context>
+<context>
<name>DrawData</name>
<message>
<source>Plot</source>
@@ -208,12 +215,8 @@
<translation>Значения справа</translation>
</message>
<message>
- <source>Miscellaneous</source>
- <translation>Разное</translation>
- </message>
- <message>
- <source>Show graph on the cover</source>
- <translation>Показывать график на обложке</translation>
+ <source>Cover</source>
+ <translation>Обложка</translation>
</message>
</context>
<context>
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-valuelogger2-1.0.17.tar.bz2/translations/harbour-valuelogger2_sv.ts
^
|
@@ -81,6 +81,13 @@
</message>
</context>
<context>
+ <name>CoverPreview</name>
+ <message>
+ <source>Example</source>
+ <translation type="unfinished">Exempel</translation>
+ </message>
+</context>
+<context>
<name>DrawData</name>
<message>
<source>Plot</source>
@@ -208,12 +215,8 @@
<translation>Etiketter till höger</translation>
</message>
<message>
- <source>Miscellaneous</source>
- <translation type="unfinished">Varierad</translation>
- </message>
- <message>
- <source>Show graph on the cover</source>
- <translation type="unfinished">Visa diagram på omslagsbild</translation>
+ <source>Cover</source>
+ <translation>Miniatyr</translation>
</message>
</context>
<context>
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-valuelogger2-1.0.17.tar.bz2/valuelogger.pro
^
|
@@ -11,7 +11,7 @@
QMAKE_CXXFLAGS += -Wno-unused-parameter -Wno-psabi
isEmpty(SPECVERSION) {
- SPECVERSION=1.0.16
+ SPECVERSION=1.0.17
}
DEFINES += "APPVERSION=\\\"$${SPECVERSION}\\\""
@@ -21,6 +21,7 @@
}
SOURCES += src/colormodel.cpp \
+ src/datatablemodel.cpp \
src/dashline.cpp \
src/database.cpp \
src/datamodel.cpp \
@@ -35,6 +36,7 @@
src/vdashline.cpp
HEADERS += src/colormodel.h \
+ src/datatablemodel.h \
src/dashline.h \
src/database.h \
src/datamodel.h \
|