[-]
[+]
|
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">6bd0d90</param>
+ <param name="revision">25d1584</param>
</service>
</services>
\ No newline at end of file
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-valuelogger2-1.0.18.tar.bz2/LICENSE
^
|
@@ -1,5 +1,5 @@
Copyright (c) 2014-2015 Kimmo Lindholm
-Copyright (c) 2021 Slava Monich
+Copyright (c) 2021-2022 Slava Monich
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-valuelogger2-1.0.18.tar.bz2/qml/components/AboutView.qml
^
|
@@ -32,7 +32,7 @@
Label {
x: Theme.horizontalPageMargin
width: parent.width - 2 * x
- text: "© 2014-2015 kimmoli\n© 2021 Slava Monich"
+ text: "© 2014-2015 kimmoli\n© 2021-2022 Slava Monich"
color: Theme.highlightColor
font.pixelSize: Theme.fontSizeSmall
horizontalAlignment: Text.AlignHCenter
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-valuelogger2-1.0.18.tar.bz2/qml/pages/AddPair.qml
^
|
@@ -113,19 +113,6 @@
visible: text !== ""
}
}
-
- Image {
- id: check
-
- anchors {
- top: parent.top
- topMargin: Theme.paddingSmall
- right: parent.right
- rightMargin: Theme.paddingSmall
- }
- visible: parameterItem.paired
- source: "image://theme/icon-s-installed" + (parameterItem.highlighted ? ("?" + Theme.highlightColor) : "")
- }
}
VerticalScrollDecorator { }
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-valuelogger2-1.0.18.tar.bz2/qml/pages/DrawData.qml
^
|
@@ -11,16 +11,19 @@
Component.onCompleted: plot.enableSizeTracking()
PageHeader {
- id: ph
+ id: header
+
title: parInfo.length === 1 ? parInfo[0].name : qsTr("Plot")
+ description: parInfo.length === 1 ? parInfo[0].description : ""
}
LinePlot {
id: plot
+
x: Theme.horizontalPageMargin
width: parent.width - 2 * x
anchors {
- top: ph.bottom
+ top: header.bottom
bottom: parent.bottom
}
}
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-valuelogger2-1.0.18.tar.bz2/qml/pages/MainPage.qml
^
|
@@ -11,6 +11,7 @@
readonly property real fullHeight: isPortrait ? Screen.height : Screen.width
readonly property bool darkOnLight: 'colorScheme' in Theme && Theme.colorScheme === Theme.DarkOnLight
+ readonly property bool sailfishShare: Logger.compareVersions(Logger.transferEngineVersion, "0.4.0") >= 0
signal plotSelected()
@@ -29,12 +30,17 @@
})
}
- Notification {
- id: notification
- expireTimeout: 2500
- Component.onCompleted: {
- if ("icon" in notification) {
- notification.icon = Qt.binding(function() { return Qt.resolvedUrl("../images/" + (darkOnLight ? "icon-cover-plot-dark.svg" : "icon-cover-plot.svg")) })
+ Component {
+ id: notificationComponent
+
+ Notification {
+ id: notification
+
+ expireTimeout: 2500
+ Component.onCompleted: {
+ if ("icon" in notification) {
+ notification.icon = Qt.binding(function() { return Qt.resolvedUrl("../images/" + (darkOnLight ? "icon-cover-plot-dark.svg" : "icon-cover-plot.svg")) })
+ }
}
}
}
@@ -55,12 +61,30 @@
}
MenuItem {
- text: qsTr("Export to CSV")
- enabled: Logger.count > 0
+ text: sailfishShare ? qsTr("Share CSV") : qsTr("Export to CSV")
+ visible: Logger.visualizeCount > 0
+ property var action
onClicked: {
- notification.previewBody = qsTr("Exported to %1").arg(Logger.exportToCSV())
- notification.publish()
+ if (sailfishShare) {
+ if (!action) {
+ action = Qt.createQmlObject("import Sailfish.Share 1.0;ShareAction {mimeType: 'application/octet-stream'}",
+ mainPage, "SailfishShare")
+ }
+ if (action) {
+ action.resources = [ Logger.exportTempCSV() ]
+ action.trigger()
+ }
+ } else {
+ if (!action) {
+ action = notificationComponent.createObject(mainPage)
+ }
+ if (action) {
+ action.previewBody = qsTr("Exported to %1").arg(Logger.exportToCSV())
+ action.publish()
+ }
+ }
}
+
}
MenuItem {
@@ -110,6 +134,12 @@
menu: Component {
ContextMenu {
MenuItem {
+ // Allow 5 items only in portrait
+ visible: mainPage.isPortrait
+ text: qsTr("Plot")
+ onClicked: parameterItem.plotParameter()
+ }
+ MenuItem {
text: qsTr("Show raw data")
onClicked: parameterItem.showRawData()
}
@@ -131,6 +161,18 @@
ListView.onRemove: animateRemoval(parameterItem)
+ function plotParameter() {
+ pageStack.push(Qt.resolvedUrl("DrawData.qml"), {
+ "allowedOrientations": mainPage.allowedOrientations,
+ "parInfo": [{
+ "name": parName,
+ "description": model.description,
+ "plotcolor": model.plotcolor,
+ "datatable": model.datatable
+ }]
+ })
+ }
+
function showRawData() {
var dialog = pageStack.push(Qt.resolvedUrl("ShowData.qml"), {
"allowedOrientations": allowedOrientations,
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-valuelogger2-1.0.18.tar.bz2/qml/valuelogger.qml
^
|
@@ -125,6 +125,7 @@
Debug.log("showing", par.name)
parInfo.push({
"name": par.name,
+ "description": par.description,
"plotcolor": par.plotcolor,
"datatable": par.datatable
})
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-valuelogger2-1.0.18.tar.bz2/src/logger.cpp
^
|
@@ -1,6 +1,6 @@
/*
Copyright (c) 2014-2015 kimmoli <kimmo.lindholm@gmail.com> @likimmo
-Copyright (c) 2021 Slava Monich <slava@monich.com>
+Copyright (c) 2021-2022 Slava Monich <slava@monich.com>
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
@@ -25,11 +25,17 @@
#include "logger.h"
#include "debuglog.h"
+#include <QDir>
#include <QColor>
-#include <QFile>
#include <QLocale>
#include <QStandardPaths>
+#include <stdlib.h>
+#include <unistd.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+
enum LoggerRole {
NameRole = Qt::UserRole,
DescriptionRole,
@@ -71,6 +77,7 @@
QAbstractListModel(parent),
queuedSignals(0)
{
+ m_shareCSV.setFileTemplate(QDir::tempPath() + "/valuelogger.XXXXXX.csv");
m_parameters = readParameters();
m_visualizeCount = currentVisualizeCount();
m_defaultParameterIndex = currentDefaultParameterIndex();
@@ -96,6 +103,14 @@
return VERSION;
}
+QString Logger::transferEngineVersion()
+{
+ if (m_transferEngineVersion.isEmpty()) {
+ m_transferEngineVersion = queryPackageVersion2("declarative-transferengine-qt5");
+ }
+ return m_transferEngineVersion;
+}
+
void Logger::queueSignal(uint signal)
{
queuedSignals |= 1u << signal;
@@ -387,44 +402,153 @@
QString Logger::exportToCSV()
{
- DBG("Exporting");
-
- QLocale loc = QLocale::system(); /* Should return current locale */
+ const QString filename(QString("%1/valuelogger.csv").arg(QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation)));
+ DBG("Exporting to" << qPrintable(filename));
- QChar separator = (loc.decimalPoint() == '.') ? ',' : ';';
- DBG("Using" << separator << "as separator");
+ QFile file(filename);
+ if (file.open(QIODevice::ReadWrite)) {
+ writeCSV(file);
+ file.close();
+ return filename;
+ }
+ return QString();
+}
- QString filename = QString("%1/valuelogger.csv").arg(QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation));
- DBG("Output filename is" << filename);
+QString Logger::exportTempCSV()
+{
+ m_shareCSV.close();
+ if (m_shareCSV.open()) {
+ DBG("Writing" << qPrintable(m_shareCSV.fileName()));
+ writeCSV(m_shareCSV);
+ return m_shareCSV.fileName();
+ }
+ return QString();
+}
- QFile file(filename);
- file.open(QIODevice::WriteOnly | QIODevice::Text);
+void Logger::writeCSV(QFile& file)
+{
QTextStream out(&file);
out.setCodec("UTF-8");
+ static const QString QUOTE("\"");
+ static const QString SEP("\",\""); // Includes quotes
+ static const QString EOL("\"\r\n"); // Includes quote
+
const QVariantList parList = readParameters();
QListIterator<QVariant> i(parList);
-
while (i.hasNext()) {
- const QVariantMap par(i.next().value<QVariantMap>());
+ const QVariantMap par(i.next().toMap());
+ if (par.value(VISUALIZE).toBool()) {
+ out << QUOTE << esc(par.value(NAME).toString()) << SEP
+ << esc(par.value(DESCRIPTION).toString()) << EOL;
+
+ const QVariantList dataList(m_db.readData(par.value(DATATABLE).toString()));
+ QListIterator<QVariant> n(dataList);
+ while (n.hasNext()) {
+ const QVariantMap data(n.next().toMap());
+ out << QUOTE << esc(data.value(TIMESTAMP).toString()) << SEP
+ << esc(data.value(VALUE).toString()) << SEP
+ << esc(data.value(ANNOTATION).toString()) << EOL;
+ }
+ }
+ }
+
+ out.flush();
+}
+
+QString Logger::esc(QString str)
+{
+ static const QString BEFORE("\"");
+ static const QString AFTER("\"\"");
+ return str.replace(BEFORE, AFTER);
+}
+
+QString Logger::queryPackageVersion(QString package)
+{
+ const QByteArray packageLatin1(package.toLatin1());
+ return queryPackageVersion2(packageLatin1.constData());
+}
+
+QString Logger::queryPackageVersion2(const char* package)
+{
+ QString version;
+ int fds[2];
+ if (pipe(fds) == 0) {
+ pid_t pid = fork();
+ if (!pid) {
+ const char* argv[6];
+ argv[0] = "rpm";
+ argv[1] = "-q";
+ argv[2] = "--qf";
+ argv[3] = "%{version}";
+ argv[4] = package;
+ argv[5] = NULL;
+ while ((dup2(fds[1], STDOUT_FILENO) == -1) && (errno == EINTR));
+ execvp(argv[0], (char**)argv);
+ abort();
+ }
+ close(fds[1]);
- out << par.value(NAME).toString() << separator << par.value(DESCRIPTION).toString() << "\n";
+ // There shouldn't be much output
+ QByteArray out;
+ const int chunk = 16;
+ ssize_t n = 0;
+ do {
+ const int size = out.size();
+ out.resize(size + chunk);
+ while ((n = read(fds[0], out.data() + size, chunk)) == -1 && (errno == EINTR));
+ out.resize(size + qMax(n, (ssize_t)0));
+ } while (n > 0);
- const QVariantList dataList(m_db.readData(par.value(DATATABLE).toString()));
- QListIterator<QVariant> n(dataList);
+ // Parse the version
+ if (out.size() > 0) {
+ version = QString::fromLatin1(out);
+ DBG(package << qPrintable(version));
+ }
+ waitpid(pid, NULL, 0);
+ close(fds[0]);
+ }
+ return version;
+}
- while (n.hasNext()) {
- const QVariantMap data(n.next().value<QVariantMap>());
- out << data.value(TIMESTAMP).toString() << separator <<
- data.value(VALUE).toString().replace('.', loc.decimalPoint()) << separator << "\"" <<
- data.value(ANNOTATION).toString() << "\"\n";
+QVector<uint> Logger::parseVersion(QString version)
+{
+ QVector<uint> parsed;
+ QStringList parts(version.split('.', QString::SkipEmptyParts));
+ const int n = qMin(parts.count(),4);
+ for (int i = 0; i < n; i++) {
+ const QString part(parts.at(i));
+ bool ok = false;
+ int val = part.toUInt(&ok);
+ if (ok) {
+ parsed.append(val);
+ } else {
+ break;
}
}
+ return parsed;
+}
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-valuelogger2-1.0.18.tar.bz2/src/logger.h
^
|
@@ -1,6 +1,6 @@
/*
Copyright (c) 2014-2015 kimmoli <kimmo.lindholm@gmail.com> @likimmo
-Copyright (c) 2021 Slava Monich <slava@monich.com>
+Copyright (c) 2021-2022 Slava Monich <slava@monich.com>
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
@@ -29,6 +29,9 @@
#include <QColor>
#include <QString>
+#include <QVector>
+#include <QFile>
+#include <QTemporaryFile>
#include <QVariantList>
#include <QAbstractListModel>
@@ -39,6 +42,7 @@
{
Q_OBJECT
Q_PROPERTY(QString version READ getVersion CONSTANT)
+ Q_PROPERTY(QString transferEngineVersion READ transferEngineVersion CONSTANT)
Q_PROPERTY(int count READ rowCount NOTIFY rowCountChanged)
Q_PROPERTY(int visualizeCount READ getVisualizeCount NOTIFY visualizeCountChanged)
Q_PROPERTY(int defaultParameterIndex READ getDefaultParameterIndex NOTIFY defaultParameterIndexChanged)
@@ -54,6 +58,7 @@
static int dataTableRole();
static QString getVersion();
+ QString transferEngineVersion();
int getVisualizeCount() const { return m_visualizeCount; }
int getDefaultParameterIndex() const { return m_defaultParameterIndex; }
@@ -61,6 +66,7 @@
QString getDefaultParameterTable() const { return m_defaultParameterTable; }
QColor getDefaultParameterColor() const { return m_defaultParameterColor; }
+ Q_INVOKABLE static int compareVersions(QString v1, QString v2);
Q_INVOKABLE QString addParameter(QString name, QString description, bool visualize, QColor plotcolor);
Q_INVOKABLE void editParameterAt(int row, QString name, QString description, bool visualize, QColor plotcolor, QString pairedtable);
Q_INVOKABLE void deleteParameterAt(int row);
@@ -68,6 +74,7 @@
Q_INVOKABLE QVariantMap get(int row);
Q_INVOKABLE QString addData(QString table, QString value, QString annotation, QString timestamp);
Q_INVOKABLE QString exportToCSV();
+ Q_INVOKABLE QString exportTempCSV();
/* QAbstractItemModel */
Qt::ItemFlags flags(const QModelIndex& idx) const Q_DECL_OVERRIDE;
@@ -95,10 +102,19 @@
int currentDefaultParameterIndex();
void updateVisualizeCount();
void updateDefaultParameter();
+ void writeCSV(QFile& file);
+
+ static QString esc(QString str);
+ static QString queryPackageVersion(QString package);
+ static QString queryPackageVersion2(const char* package);
+ static QVector<uint> parseVersion(QString version);
+ static int compareParsedVersions(const QVector<uint> v1, const QVector<uint> v2);
private:
Database m_db;
QVariantList m_parameters;
+ QString m_transferEngineVersion;
+ QTemporaryFile m_shareCSV;
int m_visualizeCount;
int m_defaultParameterIndex;
QString m_defaultParameterName;
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-valuelogger2-1.0.18.tar.bz2/src/pairmodel.cpp
^
|
@@ -29,14 +29,15 @@
PairModel::PairModel(QObject* parent) :
QSortFilterProxyModel(parent)
{
- setFilterRole(Logger::dataTableRole());
}
-/* This is easier than to build a regex for inverse matching */
bool PairModel::filterAcceptsRow(int row, const QModelIndex& parent) const
{
- return m_ignoreDataTable.isEmpty() ||
- !QSortFilterProxyModel::filterAcceptsRow(row, parent);
+ const int role = Logger::dataTableRole();
+ const QAbstractItemModel* source = sourceModel();
+ const QModelIndex sourceIndex(source->index(row, 0, parent));
+ const QString key(source->data(sourceIndex, role).toString());
+ return key != m_ignoreDataTable;
}
void PairModel::setIgnoreDataTable(QString table)
@@ -46,7 +47,5 @@
m_ignoreDataTable = table;
endResetModel();
emit ignoreDataTableChanged();
- setFilterRegExp(table.isEmpty() ? QRegExp() :
- QRegExp("^" + table + "$")); /* inverted by filterAcceptsRow */
}
}
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-valuelogger2-1.0.18.tar.bz2/translations/harbour-valuelogger2.ts
^
|
@@ -101,6 +101,10 @@
<translation>Export to CSV</translation>
</message>
<message>
+ <source>Share CSV</source>
+ <translation>Share CSV</translation>
+ </message>
+ <message>
<source>Exported to %1</source>
<translation>Exported to %1</translation>
</message>
@@ -109,6 +113,10 @@
<translation>Add new parameter</translation>
</message>
<message>
+ <source>Plot</source>
+ <translation>Plot</translation>
+ </message>
+ <message>
<source>Show raw data</source>
<translation>Show raw data</translation>
</message>
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-valuelogger2-1.0.18.tar.bz2/translations/harbour-valuelogger2_fi.ts
^
|
@@ -101,6 +101,10 @@
<translation>Vie CSV muotoon</translation>
</message>
<message>
+ <source>Share CSV</source>
+ <translation type="unfinished">Jaa CSV</translation>
+ </message>
+ <message>
<source>Exported to %1</source>
<translation>Viety tiedostoon %1</translation>
</message>
@@ -109,6 +113,10 @@
<translation>Lisää uusi parametri</translation>
</message>
<message>
+ <source>Plot</source>
+ <translation type="unfinished">Piirrä</translation>
+ </message>
+ <message>
<source>Show raw data</source>
<translation>Näytä arvot</translation>
</message>
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-valuelogger2-1.0.18.tar.bz2/translations/harbour-valuelogger2_pl.ts
^
|
@@ -101,10 +101,18 @@
<translation>Eksportuj do CSV</translation>
</message>
<message>
+ <source>Share CSV</source>
+ <translation type="unfinished">Udostępnij CSV</translation>
+ </message>
+ <message>
<source>Add new parameter</source>
<translation>dodaj nowy parametr</translation>
</message>
<message>
+ <source>Plot</source>
+ <translation type="unfinished">Wykres</translation>
+ </message>
+ <message>
<source>Show raw data</source>
<translation>Pokaż surowe dane</translation>
</message>
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-valuelogger2-1.0.18.tar.bz2/translations/harbour-valuelogger2_ru.ts
^
|
@@ -101,6 +101,10 @@
<translation>Сохранить в CSV</translation>
</message>
<message>
+ <source>Share CSV</source>
+ <translation>Переслать CSV</translation>
+ </message>
+ <message>
<source>Exported to %1</source>
<translation>Файл %1 сохранён</translation>
</message>
@@ -109,6 +113,10 @@
<translation>Добавить параметр</translation>
</message>
<message>
+ <source>Plot</source>
+ <translation>Показать график</translation>
+ </message>
+ <message>
<source>Show raw data</source>
<translation>Показать данные</translation>
</message>
@@ -118,7 +126,7 @@
</message>
<message>
<source>Pair</source>
- <translation>Связать параметры...</translation>
+ <translation>Связать параметры</translation>
</message>
<message>
<source>Remove</source>
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-valuelogger2-1.0.18.tar.bz2/translations/harbour-valuelogger2_sv.ts
^
|
@@ -101,6 +101,10 @@
<translation>Exportera till CSV</translation>
</message>
<message>
+ <source>Share CSV</source>
+ <translation type="unfinished">Dela CSV</translation>
+ </message>
+ <message>
<source>Exported to %1</source>
<translation>Exporterad till %1</translation>
</message>
@@ -109,6 +113,10 @@
<translation>Lägg till ny parameter</translation>
</message>
<message>
+ <source>Plot</source>
+ <translation type="unfinished">Diagram</translation>
+ </message>
+ <message>
<source>Show raw data</source>
<translation>Visa rådata</translation>
</message>
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-valuelogger2-1.0.18.tar.bz2/valuelogger.pro
^
|
@@ -11,7 +11,7 @@
QMAKE_CXXFLAGS += -Wno-unused-parameter -Wno-psabi
isEmpty(SPECVERSION) {
- SPECVERSION=1.0.17
+ SPECVERSION=1.0.18
}
DEFINES += "APPVERSION=\\\"$${SPECVERSION}\\\""
|