[-]
[+]
|
Changed |
_service:tar_git:harbour-meecalc.changes
|
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-meecalc.spec
^
|
|
[-]
[+]
|
Changed |
_service
^
|
@@ -2,6 +2,6 @@
<service name="tar_git">
<param name="branch">master</param>
<param name="url">https://github.com/monich/harbour-meecalc</param>
- <param name="revision">6c32ba5</param>
+ <param name="revision">dd5a9b5</param>
</service>
</services>
\ No newline at end of file
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/.gitignore
^
|
@@ -1,2 +1,2 @@
build
-harbour-meecalc.pro.user
+harbour-meecalc.pro.user*
|
[-]
[+]
|
Added |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/LICENSE
^
|
@@ -0,0 +1,30 @@
+ Copyright (C) 2014-2018 Jolla Ltd.
+ Copyright (C) 2014-2023 Slava Monich <slava@monich.com>
+
+ You may use this file under the terms of BSD license as follows:
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+ 3. Neither the names of the copyright holders nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/LICENSE
^
|
@@ -1,5 +1,5 @@
Copyright (C) 2015-2021 Jolla Ltd.
-Copyright (C) 2015-2021 Slava Monich <slava@monich.com>
+Copyright (C) 2015-2023 Slava Monich <slava@monich.com>
You may use this file under the terms of BSD license as follows:
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/harbour-lib.pro
^
|
@@ -25,6 +25,7 @@
SOURCES += \
src/HarbourBase32.cpp \
src/HarbourBase45.cpp \
+ src/HarbourBattery.cpp \
src/HarbourClipboard.cpp \
src/HarbourColorEditorModel.cpp \
src/HarbourDisplayBlanking.cpp \
@@ -36,6 +37,7 @@
src/HarbourOrganizeListModel.cpp \
src/HarbourPolicyPlugin.cpp \
src/HarbourProcessState.cpp \
+ src/HarbourProtoBuf.cpp \
src/HarbourSelectionListModel.cpp \
src/HarbourSigChildHandler.cpp \
src/HarbourSingleImageProvider.cpp \
@@ -46,7 +48,8 @@
src/HarbourTask.cpp \
src/HarbourTemporaryFile.cpp \
src/HarbourTransferMethodInfo.cpp \
- src/HarbourTransferMethodsModel.cpp
+ src/HarbourTransferMethodsModel.cpp \
+ src/HarbourUtil.cpp
greaterThan(QT_MAJOR_VERSION, 4) {
SOURCES += \
@@ -59,6 +62,7 @@
PUBLIC_HEADERS += \
include/HarbourBase32.h \
include/HarbourBase45.h \
+ include/HarbourBattery.h \
include/HarbourClipboard.h \
include/HarbourColorEditorModel.h \
include/HarbourDebug.h \
@@ -70,6 +74,7 @@
include/HarbourOrganizeListModel.h \
include/HarbourPolicyPlugin.h \
include/HarbourProcessState.h \
+ include/HarbourProtoBuf.h \
include/HarbourSelectionListModel.h \
include/HarbourSigChildHandler.h \
include/HarbourSingleImageProvider.h \
@@ -80,7 +85,8 @@
include/HarbourTask.h \
include/HarbourTemporaryFile.h \
include/HarbourTransferMethodInfo.h \
- include/HarbourTransferMethodsModel.h
+ include/HarbourTransferMethodsModel.h \
+ include/HarbourUtil.h
greaterThan(QT_MAJOR_VERSION, 4) {
PUBLIC_HEADERS += \
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/include/HarbourBase32.h
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2019-2021 Jolla Ltd.
- * Copyright (C) 2019-2021 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2019-2022 Jolla Ltd.
+ * Copyright (C) 2019-2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@@ -37,13 +37,15 @@
#include <QString>
#include <QByteArray>
-class HarbourBase32 {
+class HarbourBase32
+{
class Private;
- HarbourBase32();
+ HarbourBase32() Q_DECL_EQ_DELETE;
+
public:
- static QByteArray fromBase32(QString aBase32);
- static QString toBase32(QByteArray aBinary, bool aLowerCase = true);
- static bool isValidBase32(QString aBase32);
+ static bool isValidBase32(const QString);
+ static QString toBase32(const QByteArray, bool aLowerCase = true);
+ static QByteArray fromBase32(const QString);
};
#endif // HARBOUR_BASE32_H
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/include/HarbourBase45.h
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2021 Jolla Ltd.
- * Copyright (C) 2021 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2021-2022 Jolla Ltd.
+ * Copyright (C) 2021-2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@@ -37,13 +37,15 @@
#include <QString>
#include <QByteArray>
-class HarbourBase45 {
+class HarbourBase45
+{
class Private;
- HarbourBase45();
+ HarbourBase45() Q_DECL_EQ_DELETE;
+
public:
- static bool isValidBase45(QString aBase45);
- static QByteArray fromBase45(QString aBase45);
- static QString toBase45(QByteArray aBinary);
+ static bool isValidBase45(const QString);
+ static QString toBase45(const QByteArray);
+ static QByteArray fromBase45(const QString);
};
#endif // HARBOUR_BASE45_H
|
[-]
[+]
|
Added |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/include/HarbourBattery.h
^
|
@@ -0,0 +1,89 @@
+/*
+ * Copyright (C) 2022 Jolla Ltd.
+ * Copyright (C) 2022 Slava Monich <slava.monich@jolla.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef HARBOUR_BATTERY_H
+#define HARBOUR_BATTERY_H
+
+#include <QObject>
+
+class QQmlEngine;
+class QJSEngine;
+
+// D-Bus calls used by this object require mce 1.86.0 (Sailfish OS 2.1)
+class HarbourBattery: public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(BatteryStatus batteryStatus READ batteryStatus NOTIFY batteryStatusChanged)
+ Q_PROPERTY(BatteryState batteryState READ batteryState NOTIFY batteryStateChanged)
+ Q_PROPERTY(int batteryLevel READ batteryLevel NOTIFY batteryLevelChanged)
+ Q_ENUMS(BatteryStatus)
+ Q_ENUMS(BatteryState)
+
+public:
+ enum BatteryStatus {
+ BatteryStatusUnknown,
+ BatteryStatusEmpty,
+ BatteryStatusLow,
+ BatteryStatusOk,
+ BatteryStatusFull
+ };
+
+ enum BatteryState {
+ BatteryStateUnknown,
+ BatteryStateCharging,
+ BatteryStateDischarging,
+ BatteryStateNotCharging,
+ BatteryStateFull
+ };
+
+ explicit HarbourBattery(QObject* aParent = Q_NULLPTR);
+ ~HarbourBattery();
+
+ // Callback for qmlRegisterSingletonType<HarbourBattery>
+ static QObject* createSingleton(QQmlEngine*, QJSEngine*);
+
+ BatteryStatus batteryStatus() const;
+ BatteryState batteryState() const;
+ int batteryLevel() const;
+
+Q_SIGNALS:
+ void batteryStatusChanged();
+ void batteryStateChanged();
+ void batteryLevelChanged();
+
+private:
+ class Private;
+ Private* iPrivate;
+};
+
+#endif // HARBOUR_BATTERY_H
|
[-]
[+]
|
Added |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/include/HarbourProtoBuf.h
^
|
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2022 Jolla Ltd.
+ * Copyright (C) 2022 Slava Monich <slava.monich@jolla.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef HARBOUR_PROTOBUF_H
+#define HARBOUR_PROTOBUF_H
+
+#include <QByteArray>
+
+#include <gutil_types.h>
+
+// https://developers.google.com/protocol-buffers/docs/encoding
+
+class HarbourProtoBuf
+{
+ HarbourProtoBuf() Q_DECL_EQ_DELETE;
+
+public:
+ enum {
+ TYPE_SHIFT = 3,
+ TYPE_MASK = ((1 << TYPE_SHIFT)-1),
+ TYPE_VARINT = 0,
+ TYPE_DELIMITED = 2
+ };
+
+ static QByteArray* appendVarInt(QByteArray*, quint64);
+ static QByteArray* appendVarIntKeyValue(QByteArray*, quint64, quint64);
+ static QByteArray* appendDelimitedValue(QByteArray*, const QByteArray);
+ static QByteArray* appendDelimitedKeyValue(QByteArray*, quint64, const QByteArray);
+
+ static bool parseVarInt(GUtilRange*, quint64*);
+ static bool parseDelimitedValue(GUtilRange*, GUtilData*);
+};
+
+#endif // HARBOUR_PROTOBUF_H
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/include/HarbourSelectionListModel.h
^
|
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2019 Jolla Ltd.
- * Copyright (C) 2019 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2019-2023 Slava Monich <slava@jolla.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@@ -37,33 +37,44 @@
#include <QtQml>
#include <QIdentityProxyModel>
-class HarbourSelectionListModel : public QIdentityProxyModel {
+class HarbourSelectionListModel : public QIdentityProxyModel
+{
Q_OBJECT
Q_PROPERTY(QObject* sourceModel READ sourceModel WRITE setSourceModelObject NOTIFY sourceModelObjectChanged)
+ Q_PROPERTY(QList<int> nonSelectableRows READ nonSelectableRows WRITE setNonSelectableRows NOTIFY nonSelectableRowsChanged)
Q_PROPERTY(QList<int> selectedRows READ selectedRows NOTIFY selectedRowsChanged)
- Q_PROPERTY(int selectionCount READ selectionCount NOTIFY selectedRowsChanged)
+ Q_PROPERTY(int selectableCount READ selectableCount NOTIFY selectableCountChanged)
+ Q_PROPERTY(int selectionCount READ selectionCount NOTIFY selectionCountChanged)
Q_PROPERTY(int count READ rowCount NOTIFY countChanged)
public:
HarbourSelectionListModel(QObject* aParent = Q_NULLPTR);
- void setSourceModelObject(QObject* aModel);
+ void setSourceModelObject(QObject*);
+
+ QList<int> nonSelectableRows() const;
+ void setNonSelectableRows(const QList<int>);
QList<int> selectedRows() const;
+ int selectableCount() const;
int selectionCount() const;
Q_INVOKABLE void selectAll();
Q_INVOKABLE void clearSelection();
+ Q_INVOKABLE void toggleRows(const QList<int>);
// QAbstractItemModel
- Qt::ItemFlags flags(const QModelIndex& aIndex) const Q_DECL_OVERRIDE;
+ Qt::ItemFlags flags(const QModelIndex&) const Q_DECL_OVERRIDE;
QHash<int,QByteArray> roleNames() const Q_DECL_OVERRIDE;
- QVariant data(const QModelIndex& aIndex, int aRole) const Q_DECL_OVERRIDE;
- bool setData(const QModelIndex& aIndex, const QVariant& aValue, int aRole) Q_DECL_OVERRIDE;
+ QVariant data(const QModelIndex&, int) const Q_DECL_OVERRIDE;
+ bool setData(const QModelIndex&, const QVariant&, int) Q_DECL_OVERRIDE;
Q_SIGNALS:
void sourceModelObjectChanged();
+ void nonSelectableRowsChanged();
void selectedRowsChanged();
+ void selectableCountChanged();
+ void selectionCountChanged();
void countChanged();
private:
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/include/HarbourTheme.h
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2018-2020 Jolla Ltd.
- * Copyright (C) 2018-2020 Slava Monich <slava@monich.com>
+ * Copyright (C) 2018-2022 Jolla Ltd.
+ * Copyright (C) 2018-2022 Slava Monich <slava@monich.com>
*
* You may use this file under the terms of the BSD license as follows:
*
|
[-]
[+]
|
Added |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/include/HarbourUtil.h
^
|
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2022 Jolla Ltd.
+ * Copyright (C) 2022 Slava Monich <slava.monich@jolla.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef HARBOUR_UTIL_H
+#define HARBOUR_UTIL_H
+
+#include <QByteArray>
+#include <QColor>
+#include <QObject>
+#include <QRgb>
+#include <QString>
+
+class QQmlEngine;
+class QJSEngine;
+
+class HarbourUtil :
+ public QObject
+{
+ Q_OBJECT
+ class Private;
+
+public:
+ explicit HarbourUtil(QObject* aParent = Q_NULLPTR);
+
+ // Callback for qmlRegisterSingletonType<HarbourUtil>
+ static QObject* createSingleton(QQmlEngine*, QJSEngine*);
+
+ // QML (and possibly native) utilities
+ Q_INVOKABLE static QColor invertedColor(const QColor&);
+
+ // Static utilities
+ static QRgb invertedRgb(QRgb);
+ static QByteArray toHexBytes(const void*, size_t);
+ static QString toHex(const void*, size_t);
+ static inline QString toHex(const QByteArray& aData)
+ { return toHex(aData.constData(), aData.size()); }
+};
+
+#endif // HARBOUR_UTIL_H
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/qml/HarbourBadge.qml
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2018-2019 Jolla Ltd.
- * Copyright (C) 2018-2019 Slava Monich <slava@monich.com>
+ * Copyright (C) 2018-2022 Jolla Ltd.
+ * Copyright (C) 2018-2022 Slava Monich <slava@monich.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -11,8 +11,8 @@
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
+ * notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
* distribution.
* 3. Neither the names of the copyright holders nor the names of its
* contributors may be used to endorse or promote products derived
@@ -39,6 +39,9 @@
property real maxWidth: parent.width
property alias text: label.text
+ property alias backgroundColor: background.color
+ property alias textColor: label.color
+
readonly property real radius: height/2
width: Math.max(label.implicitWidth + radius, height)
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/qml/HarbourColorEditorDialog.qml
^
|
@@ -164,12 +164,9 @@
EnterKey.onClicked: hexText.focus = false
onTextChanged: {
- if (!ignoreTextUpdates && acceptableInput) {
- tmpColor = "#" + text
- ignoreTextUpdates++
- brightnessSlider.value = hueItem.getV(tmpColor)
- hueSlider.value = hueItem.getH(tmpColor)
- ignoreTextUpdates--
+ if (!ignoreTextUpdates) {
+ // acceptableInput hasn't been updated yet
+ syncTimer.restart()
}
}
@@ -179,6 +176,16 @@
}
}
+ function syncColor() {
+ if (acceptableInput) {
+ tmpColor = "#" + text
+ ignoreTextUpdates++
+ brightnessSlider.value = hueItem.getV(tmpColor)
+ hueSlider.value = hueItem.getH(tmpColor)
+ ignoreTextUpdates--
+ }
+ }
+
function updateText() {
if (!ignoreTextUpdates) {
ignoreTextUpdates++
@@ -187,6 +194,13 @@
ignoreTextUpdates--
}
}
+
+ Timer {
+ id: syncTimer
+
+ interval: 0
+ onTriggered: hexText.syncColor()
+ }
}
}
}
@@ -198,15 +212,16 @@
width: 2 * height
height: hexText.height - 2 * Theme.paddingLarge
anchors.right: parent.right
+ visible: hexText.acceptableInput
onClicked: thisDialog.accept()
Rectangle {
id: sampleItem
+ radius: Theme.paddingSmall
anchors.fill: parent
color: "#" + hexText.text
- visible: hexText.acceptableInput
layer.enabled: sample.pressed && sample.containsMouse
layer.effect: HarbourPressEffect { source: sampleItem }
}
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/qml/HarbourColorHueItem.qml
^
|
@@ -38,6 +38,7 @@
id: thisItem
color: "black"
+
property alias brightness: mouseArea.opacity
property alias pressed: mouseArea.pressed
@@ -143,6 +144,7 @@
sourceItem: Rectangle {
width: mouseArea.width
height: mouseArea.height
+ radius: Theme.paddingSmall
gradient: Gradient {
GradientStop { position: 0.0; color: color0 }
GradientStop { position: colorStop1; color: color1 }
|
[-]
[+]
|
Added |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/qml/HarbourInvertEffect.qml
^
|
@@ -0,0 +1,13 @@
+import QtQuick 2.0
+
+ShaderEffect {
+ property variant source
+ fragmentShader: "
+ uniform sampler2D source;
+ uniform lowp float qt_Opacity;
+ varying highp vec2 qt_TexCoord0;
+ void main(void) {
+ highp vec4 pixelColor = texture2D(source, qt_TexCoord0);
+ gl_FragColor = vec4(vec3(1,1,1) - pixelColor.rgb, pixelColor.a) * qt_Opacity;
+ }"
+}
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/src/HarbourBase32.cpp
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2019 Jolla Ltd.
- * Copyright (C) 2019 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2019-2022 Jolla Ltd.
+ * Copyright (C) 2019-2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@@ -46,25 +46,33 @@
// HarbourBase32::Private
// ==========================================================================
-class HarbourBase32::Private {
+class HarbourBase32::Private
+{
public:
- static char nibbleToBase32(int nibble, char a);
- static int base32ToNibble(char a);
+ static char nibbleToBase32(int, char);
+ static int base32ToNibble(char);
};
-inline char HarbourBase32::Private::nibbleToBase32(int nibble, char a)
+inline
+char
+HarbourBase32::Private::nibbleToBase32(
+ int aNibble,
+ char aBaseChar)
{
- return (nibble < 26) ? (a + nibble) : ('2' + (nibble - 26));
+ return (aNibble < 26) ? (aBaseChar + aNibble) : ('2' + (aNibble - 26));
}
-inline int HarbourBase32::Private::base32ToNibble(char c)
+inline
+int
+HarbourBase32::Private::base32ToNibble(
+ char aChar)
{
- if (c >= 'a' && c <= 'z') {
- return c - 'a';
- } else if (c >= 'A' && c <= 'Z') {
- return c - 'A';
- } else if (c >= '2' && c <= '7') {
- return 26 + (c - '2');
+ if (aChar >= 'a' && aChar <= 'z') {
+ return aChar - 'a';
+ } else if (aChar >= 'A' && aChar <= 'Z') {
+ return aChar - 'A';
+ } else if (aChar >= '2' && aChar <= '7') {
+ return 26 + (aChar - '2');
} else {
return -1;
}
@@ -74,7 +82,9 @@
// HarbourBase32
// ==========================================================================
-bool HarbourBase32::isValidBase32(QString aBase32)
+bool
+HarbourBase32::isValidBase32(
+ QString aBase32)
{
const int n = aBase32.length();
const QChar* chars = aBase32.constData();
@@ -133,7 +143,9 @@
return !empty;
}
-QByteArray HarbourBase32::fromBase32(QString aBase32)
+QByteArray
+HarbourBase32::fromBase32(
+ const QString aBase32)
{
QByteArray out;
@@ -205,7 +217,10 @@
return out;
}
-QString HarbourBase32::toBase32(QByteArray aBinary, bool aLowerCase)
+QString
+HarbourBase32::toBase32(
+ const QByteArray aBinary,
+ bool aLowerCase)
{
QString str;
const int n = aBinary.size();
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/src/HarbourBase45.cpp
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2021 Jolla Ltd.
- * Copyright (C) 2021 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2021-2022 Jolla Ltd.
+ * Copyright (C) 2021-2022 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@@ -39,7 +39,8 @@
// HarbourBase45::Private
// ==========================================================================
-class HarbourBase45::Private {
+class HarbourBase45::Private
+{
public:
enum {
BASE = 45,
@@ -48,7 +49,7 @@
};
static const char mapBase45[BASE];
static const int reverseMapBase45[REVERSE_MAP_SIZE];
- static bool isValidChar(uint x);
+ static bool isValidChar(uint);
};
const char HarbourBase45::Private::mapBase45[HarbourBase45::Private::BASE] = {
@@ -75,16 +76,22 @@
33, 34, 35
};
-inline bool HarbourBase45::Private::isValidChar(uint x)
+inline
+bool
+HarbourBase45::Private::isValidChar(
+ uint aChar)
{
- return (x < Private::REVERSE_MAP_SIZE) && Private::reverseMapBase45[x] >= 0;
+ return (aChar < Private::REVERSE_MAP_SIZE) &&
+ Private::reverseMapBase45[aChar] >= 0;
}
// ==========================================================================
// HarbourBase45::Private
// ==========================================================================
-bool HarbourBase45::isValidBase45(QString aBase45)
+bool
+HarbourBase45::isValidBase45(
+ const QString aBase45)
{
const int len = aBase45.length();
@@ -123,7 +130,9 @@
return false;
}
-QByteArray HarbourBase45::fromBase45(QString aBase45)
+QByteArray
+HarbourBase45::fromBase45(
+ const QString aBase45)
{
QByteArray out;
const int len = aBase45.length();
@@ -175,7 +184,9 @@
return out;
}
-QString HarbourBase45::toBase45(QByteArray aBinary)
+QString
+HarbourBase45::toBase45(
+ const QByteArray aBinary)
{
const uchar* ptr = (uchar*)aBinary.constData();
const int n = aBinary.size();
|
[-]
[+]
|
Added |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/src/HarbourBattery.cpp
^
|
@@ -0,0 +1,266 @@
+/*
+ * Copyright (C) 2022 Jolla Ltd.
+ * Copyright (C) 2022 Slava Monich <slava.monich@jolla.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "HarbourBattery.h"
+#include "HarbourDebug.h"
+#include "HarbourMce.h"
+
+#include <QDBusPendingCallWatcher>
+#include <QDBusPendingReply>
+
+// ==========================================================================
+// HarbourBattery::Private
+// ==========================================================================
+
+class HarbourBattery::Private : public HarbourMce
+{
+ Q_OBJECT
+
+public:
+ static const QString MCE_BATTERY_STATUS_UNKNOWN;
+ static const QString MCE_BATTERY_STATUS_FULL;
+ static const QString MCE_BATTERY_STATUS_OK;
+ static const QString MCE_BATTERY_STATUS_LOW;
+ static const QString MCE_BATTERY_STATUS_EMPTY;
+
+ static const QString MCE_BATTERY_STATE_UNKNOWN;
+ static const QString MCE_BATTERY_STATE_DISCHARGING;
+ static const QString MCE_BATTERY_STATE_CHARGING;
+ static const QString MCE_BATTERY_STATE_NOT_CHARGING;
+ static const QString MCE_BATTERY_STATE_FULL;
+
+ Private(HarbourBattery*);
+
+ HarbourBattery* parentObject() const;
+
+public Q_SLOTS:
+ void updateBatteryStatus(const QString);
+ void updateBatteryState(const QString);
+ void updateBatteryLevel(int);
+ void onBatteryStatusQueryDone(QDBusPendingCallWatcher*);
+ void onBatteryStateQueryDone(QDBusPendingCallWatcher*);
+ void onBatteryLevelQueryDone(QDBusPendingCallWatcher*);
+
+public:
+ BatteryStatus iBatteryStatus;
+ BatteryState iBatteryState;
+ int iBatteryLevel;
+};
+
+const QString HarbourBattery::Private::MCE_BATTERY_STATUS_UNKNOWN("unknown");
+const QString HarbourBattery::Private::MCE_BATTERY_STATUS_FULL("full");
+const QString HarbourBattery::Private::MCE_BATTERY_STATUS_OK("ok");
+const QString HarbourBattery::Private::MCE_BATTERY_STATUS_LOW("low");
+const QString HarbourBattery::Private::MCE_BATTERY_STATUS_EMPTY("empty");
+
+const QString HarbourBattery::Private::MCE_BATTERY_STATE_UNKNOWN("unknown");
+const QString HarbourBattery::Private::MCE_BATTERY_STATE_DISCHARGING("discharging");
+const QString HarbourBattery::Private::MCE_BATTERY_STATE_CHARGING("charging");
+const QString HarbourBattery::Private::MCE_BATTERY_STATE_NOT_CHARGING("not_charging");
+const QString HarbourBattery::Private::MCE_BATTERY_STATE_FULL("full");
+
+HarbourBattery::Private::Private(
+ HarbourBattery* aParent) :
+ HarbourMce(aParent),
+ iBatteryStatus(BatteryStatusUnknown),
+ iBatteryState(BatteryStateUnknown),
+ iBatteryLevel(0)
+{
+ setupProperty("get_battery_status", "battery_status_ind",
+ SLOT(onBatteryStatusQueryDone(QDBusPendingCallWatcher*)),
+ SLOT(updateBatteryStatus(QString)));
+ setupProperty("get_battery_state", "battery_state_ind",
+ SLOT(onBatteryStateQueryDone(QDBusPendingCallWatcher*)),
+ SLOT(updateBatteryState(QString)));
+ setupProperty("get_battery_level", "battery_level_ind",
+ SLOT(onBatteryLevelQueryDone(QDBusPendingCallWatcher*)),
+ SLOT(updateBatteryLevel(int)));
+}
+
+inline
+HarbourBattery*
+HarbourBattery::Private::parentObject() const
+{
+ return qobject_cast<HarbourBattery*>(parent());
+}
+
+void
+HarbourBattery::Private::updateBatteryStatus(
+ const QString aStatus)
+{
+ BatteryStatus status = BatteryStatusUnknown;
+
+ if (aStatus == MCE_BATTERY_STATUS_OK) {
+ status = BatteryStatusOk;
+ } else if (aStatus == MCE_BATTERY_STATUS_FULL) {
+ status = BatteryStatusFull;
+ } else if (aStatus == MCE_BATTERY_STATUS_LOW) {
+ status = BatteryStatusLow;
+ } else if (aStatus == MCE_BATTERY_STATUS_EMPTY) {
+ status = BatteryStatusEmpty;
+ } else if (aStatus != MCE_BATTERY_STATUS_UNKNOWN) {
+ HWARN("Unexpected battery status" << aStatus);
+ return;
+ }
+
+ if (iBatteryStatus != status) {
+ iBatteryStatus = status;
+ HDEBUG(aStatus);
+ Q_EMIT parentObject()->batteryStatusChanged();
+ }
+}
+
+void
+HarbourBattery::Private::updateBatteryState(
+ const QString aState)
+{
+ BatteryState state = BatteryStateUnknown;
+
+ if (aState == MCE_BATTERY_STATE_CHARGING) {
+ state = BatteryStateCharging;
+ } else if (aState == MCE_BATTERY_STATE_DISCHARGING) {
+ state = BatteryStateDischarging;
+ } else if (aState == MCE_BATTERY_STATE_NOT_CHARGING) {
+ state = BatteryStateNotCharging;
+ } else if (aState == MCE_BATTERY_STATE_FULL) {
+ state = BatteryStateFull;
+ } else if (aState != MCE_BATTERY_STATE_UNKNOWN) {
+ HWARN("Unexpected battery state" << aState);
+ return;
+ }
+
+ if (iBatteryState != state) {
+ iBatteryState = state;
+ HDEBUG(aState);
+ Q_EMIT parentObject()->batteryStateChanged();
+ }
+}
+
+void
+HarbourBattery::Private::updateBatteryLevel(
+ int aLevel)
+{
+ if (iBatteryLevel != aLevel) {
+ iBatteryLevel = aLevel;
+ HDEBUG(aLevel);
+ Q_EMIT parentObject()->batteryLevelChanged();
+ }
+}
+
+void
+HarbourBattery::Private::onBatteryStatusQueryDone(
+ QDBusPendingCallWatcher* aWatcher)
+{
+ QDBusPendingReply<QString> reply(*aWatcher);
+
+ if (reply.isError()) {
+ HWARN(reply.error().message());
+ } else {
+ updateBatteryStatus(reply.value());
+ }
+ aWatcher->deleteLater();
+}
+
+void
+HarbourBattery::Private::onBatteryStateQueryDone(
+ QDBusPendingCallWatcher* aWatcher)
+{
+ QDBusPendingReply<QString> reply(*aWatcher);
+
|
[-]
[+]
|
Added |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/src/HarbourProtoBuf.cpp
^
|
@@ -0,0 +1,144 @@
+/*
+ * Copyright (C) 2022 Jolla Ltd.
+ * Copyright (C) 2022 Slava Monich <slava.monich@jolla.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "HarbourDebug.h"
+#include "HarbourProtoBuf.h"
+
+// https://developers.google.com/protocol-buffers/docs/encoding
+
+QByteArray*
+HarbourProtoBuf::appendVarInt(
+ QByteArray* aOutput,
+ quint64 aValue)
+{
+ if (aOutput) {
+ uchar out[10];
+ quint64 value = aValue;
+ int i = sizeof(out) - 1;
+
+ out[i] = value & 0x7f;
+ value >>= 7;
+ while (value) {
+ out[--i] = 0x80 | (uchar)value;
+ value >>= 7;
+ }
+
+ const int n = sizeof(out) - i;
+
+ aOutput->reserve(aOutput->size() + n);
+ aOutput->append((char*)(out + i), n);
+ }
+ return aOutput;
+}
+
+QByteArray*
+HarbourProtoBuf::appendVarIntKeyValue(
+ QByteArray* aOutput,
+ quint64 aKey,
+ quint64 aValue)
+{
+ HASSERT((aKey & TYPE_MASK) == TYPE_VARINT);
+ return appendVarInt(appendVarInt(aOutput, aKey), aValue);
+}
+
+QByteArray*
+HarbourProtoBuf::appendDelimitedValue(
+ QByteArray* aOutput,
+ const QByteArray aValue)
+{
+ if (aOutput) {
+ appendVarInt(aOutput, aValue.size())->append(aValue);
+ }
+ return aOutput;
+}
+
+QByteArray*
+HarbourProtoBuf::appendDelimitedKeyValue(
+ QByteArray* aOutput,
+ quint64 aKey,
+ const QByteArray aValue)
+{
+ HASSERT((aKey & TYPE_MASK) == TYPE_DELIMITED);
+ return appendDelimitedValue(appendVarInt(aOutput, aKey), aValue);
+}
+
+bool
+HarbourProtoBuf::parseVarInt(
+ GUtilRange* aPos,
+ quint64* aResult)
+{
+ if (aPos) {
+ quint64 value = 0;
+ const guint8* ptr = aPos->ptr;
+
+ for (int i = 0; i < 10 && ptr < aPos->end; i++, ptr++) {
+ value = (value << 7) | (*ptr & 0x7f);
+ if (!(*ptr & 0x80)) {
+ aPos->ptr = ptr + 1;
+ if (aResult) {
+ *aResult = value;
+ }
+ return true;
+ }
+ }
+
+ // Premature end of stream or too many bytes
+ if (aResult) {
+ *aResult = 0;
+ }
+ }
+ return false;
+}
+
+// A delimited value is stored as a size, encoded as a varint, followed
+// by the payload of type (message | string | bytes | packed)
+bool
+HarbourProtoBuf::parseDelimitedValue(
+ GUtilRange* aPos,
+ GUtilData* aPayload)
+{
+ if (aPos) {
+ GUtilRange pos = *aPos;
+ quint64 size;
+
+ if (parseVarInt(&pos, &size) && (pos.ptr + size) <= pos.end) {
+ if (aPayload) {
+ aPayload->bytes = pos.ptr;
+ aPayload->size = size;
+ }
+ aPos->ptr = pos.ptr + size;
+ return true;
+ }
+ }
+ return false;
+}
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/src/HarbourSelectionListModel.cpp
^
|
@@ -1,6 +1,6 @@
-/*
+/*
* Copyright (C) 2019 Jolla Ltd.
- * Copyright (C) 2019 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2019-2023 Slava Monich <slava@jolla.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@@ -41,20 +41,47 @@
// HarbourSelectionListModel::Private
// ==========================================================================
-class HarbourSelectionListModel::Private : public QObject {
+// s(SignalName,signalName)
+#define QUEUED_SIGNALS(s) \
+ s(NonSelectableRows,nonSelectableRows) \
+ s(SelectedRows,selectedRows) \
+ s(SelectableCount,selectableCount) \
+ s(SelectionCount,selectionCount) \
+ s(Count,count)
+
+class HarbourSelectionListModel::Private : public QObject
+{
Q_OBJECT
public:
- Private(HarbourSelectionListModel* aParent);
+ typedef void (HarbourSelectionListModel::*SignalEmitter)();
+ typedef uint SignalMask;
+
+ enum Signal {
+#define SIGNAL_ENUM_(Name,name) Signal##Name##Changed,
+ QUEUED_SIGNALS(SIGNAL_ENUM_)
+#undef SIGNAL_ENUM_
+ SignalCount
+ };
+
+ Private(HarbourSelectionListModel*);
+
+ static int binaryFind(const QList<int>, int);
HarbourSelectionListModel* parentModel();
- static int binaryFind(const QList<int> aList, int aValue);
- bool isSelectionRole(int aRole) const;
- bool isSelectedRow(int aRow) const;
- int findSelectedRow(int aRow) const;
- void selectRow(int aRow);
- void unselectRow(int aRow);
- void selectionChangedAt(int aRow);
+ void queueSignal(Signal aSignal);
+ void emitQueuedSignals();
+ bool isSelectionRole(int) const;
+ bool isSelectedRow(int) const;
+ bool isSelectableRow(int) const;
+ int findSelectedRow(int) const;
+ void updateCounts();
+ void selectRow(int);
+ void unselectRow(int);
+ void toggleRows(const QList<int>);
+ void setNonSelectableRows(const QList<int>);
+ void selectedRowChanged(int);
+ void selectionChangedAt(int);
void clearSelection();
void selectAll();
void reset();
@@ -63,13 +90,20 @@
void onCountChanged();
public:
+ SignalMask iQueuedSignals;
+ Signal iFirstQueuedSignal;
QList<int> iSelectedRows;
- QVector<int> iSelectedRole;
+ QList<int> iNonSelectableRows;
+ QList<int> iNormalizedNonSelectableRows;
+ QVector<int> iSelectedRole; // Passed to dataChanged as an argument
+ int iLastKnownSelectableCount;
int iLastKnownCount;
};
-HarbourSelectionListModel::Private::Private(HarbourSelectionListModel* aParent) :
+HarbourSelectionListModel::Private::Private(
+ HarbourSelectionListModel* aParent) :
QObject(aParent),
+ iLastKnownSelectableCount(0),
iLastKnownCount(0)
{
connect(aParent, SIGNAL(modelReset()), SLOT(onCountChanged()));
@@ -77,22 +111,10 @@
connect(aParent, SIGNAL(rowsRemoved(QModelIndex,int,int)), SLOT(onCountChanged()));
}
-inline HarbourSelectionListModel* HarbourSelectionListModel::Private::parentModel()
-{
- return qobject_cast<HarbourSelectionListModel*>(parent());
-}
-
-inline bool HarbourSelectionListModel::Private::isSelectionRole(int aRole) const
-{
- return !iSelectedRole.isEmpty() && iSelectedRole.first() == aRole;
-}
-
-inline bool HarbourSelectionListModel::Private::isSelectedRow(int aRow) const
-{
- return findSelectedRow(aRow) >= 0;
-}
-
-int HarbourSelectionListModel::Private::binaryFind(const QList<int> aList, int aValue)
+int
+HarbourSelectionListModel::Private::binaryFind(
+ const QList<int> aList,
+ int aValue)
{
// It turned out to be significantly easier to copy/paste this code
// than to fight with qBinaryFind and iterators which behave strangely
@@ -117,34 +139,131 @@
return -(low + 1);
}
-int HarbourSelectionListModel::Private::findSelectedRow(int aRow) const
+inline
+HarbourSelectionListModel*
+HarbourSelectionListModel::Private::parentModel()
+{
+ return qobject_cast<HarbourSelectionListModel*>(parent());
+}
+
+void
+HarbourSelectionListModel::Private::queueSignal(
+ Signal aSignal)
+{
+ if (aSignal >= 0 && aSignal < SignalCount) {
+ const SignalMask signalBit = (SignalMask(1) << aSignal);
+ if (iQueuedSignals) {
+ iQueuedSignals |= signalBit;
+ if (iFirstQueuedSignal > aSignal) {
+ iFirstQueuedSignal = aSignal;
+ }
+ } else {
+ iQueuedSignals = signalBit;
+ iFirstQueuedSignal = aSignal;
+ }
+ }
+}
+
+void
+HarbourSelectionListModel::Private::emitQueuedSignals()
+{
+ static const SignalEmitter emitSignal [] = {
+#define SIGNAL_EMITTER_(Name,name) &HarbourSelectionListModel::name##Changed,
+ QUEUED_SIGNALS(SIGNAL_EMITTER_)
+#undef SIGNAL_EMITTER_
+ };
+ if (iQueuedSignals) {
+ HarbourSelectionListModel* model = parentModel();
+ // Reset first queued signal before emitting the signals.
+ // Signal handlers may emit new signals.
+ uint i = iFirstQueuedSignal;
+ iFirstQueuedSignal = SignalCount;
+ for (; i < SignalCount && iQueuedSignals; i++) {
+ const SignalMask signalBit = (SignalMask(1) << i);
+ if (iQueuedSignals & signalBit) {
+ iQueuedSignals &= ~signalBit;
+ Q_EMIT (model->*(emitSignal[i]))();
+ }
+ }
+ }
+}
+
+inline
+bool
+HarbourSelectionListModel::Private::isSelectionRole(
+ int aRole) const
+{
+ return !iSelectedRole.isEmpty() && iSelectedRole.first() == aRole;
+}
+
+inline
+bool
+HarbourSelectionListModel::Private::isSelectedRow(
+ int aRow) const
+{
+ return findSelectedRow(aRow) >= 0;
+}
+
+inline
+bool
+HarbourSelectionListModel::Private::isSelectableRow(
+ int aRow) const
+{
+ return binaryFind(iNonSelectableRows, aRow) < 0;
+}
+
+int
+HarbourSelectionListModel::Private::findSelectedRow(
+ int aRow) const
{
return binaryFind(iSelectedRows, aRow);
}
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/src/HarbourTheme.cpp
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2018-2020 Jolla Ltd.
- * Copyright (C) 2018-2020 Slava Monich <slava@monich.com>
+ * Copyright (C) 2018-2022 Jolla Ltd.
+ * Copyright (C) 2018-2022 Slava Monich <slava@monich.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@@ -31,9 +31,10 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "HarbourTheme.h"
-#include "HarbourSystem.h"
#include "HarbourDebug.h"
+#include "HarbourSystem.h"
+#include "HarbourTheme.h"
+#include "HarbourUtil.h"
#include <QQmlEngine>
@@ -212,17 +213,12 @@
QColor HarbourTheme::invertedPrimaryColor() const
{
- return invertedColor(Private::primaryColor());
+ return HarbourUtil::invertedColor(Private::primaryColor());
}
QColor HarbourTheme::invertedColor(const QColor& aColor)
{
- if (aColor.isValid()) {
- const QRgb rgba = aColor.rgba();
- return QColor(((~(rgba & RGB_MASK)) & RGB_MASK) | (rgba & (~RGB_MASK)));
- } else {
- return aColor;
- }
+ return HarbourUtil::invertedColor(aColor);
}
qreal HarbourTheme::colorDifference(const QColor& aColor1, const QColor& aColor2)
|
[-]
[+]
|
Added |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/src/HarbourUtil.cpp
^
|
@@ -0,0 +1,116 @@
+/*
+ * Copyright (C) 2022 Jolla Ltd.
+ * Copyright (C) 2022 Slava Monich <slava.monich@jolla.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "HarbourUtil.h"
+
+// ==========================================================================
+// HarbourUtil::Private
+// ==========================================================================
+
+class HarbourUtil::Private
+{
+public:
+ static const char hex[];
+};
+
+const char HarbourUtil::Private::hex[] = "0123456789abcdef";
+
+// ==========================================================================
+// HarbourUtil
+// ==========================================================================
+
+HarbourUtil::HarbourUtil(
+ QObject* aParent) :
+ QObject(aParent)
+{
+}
+
+// Callback for qmlRegisterSingletonType<HarbourUtil>
+QObject*
+HarbourUtil::createSingleton(
+ QQmlEngine*,
+ QJSEngine*)
+{
+ return new HarbourUtil();
+}
+
+QColor
+HarbourUtil::invertedColor(
+ const QColor& aColor)
+{
+ if (aColor.isValid()) {
+ const QRgb inv = invertedRgb(aColor.rgba());
+
+ return QColor(qRed(inv), qGreen(inv), qBlue(inv), qAlpha(inv));
+ } else {
+ return aColor;
+ }
+}
+
+QRgb
+HarbourUtil::invertedRgb(
+ QRgb aRgb)
+{
+ return ((~(aRgb & RGB_MASK)) & RGB_MASK) | (aRgb & (~RGB_MASK));
+}
+
+QString
+HarbourUtil::toHex(
+ const void* aData,
+ size_t aSize)
+{
+ QString hex;
+
+ if (aSize > 0) {
+ const uchar* bytes = (const uchar*)aData;
+
+ hex.reserve(2 * aSize);
+ for (size_t i = 0; i < aSize; i++) {
+ const uchar b = bytes[i];
+
+ hex.append(QChar(Private::hex[(b & 0xf0) >> 4]));
+ hex.append(QChar(Private::hex[b & 0x0f]));
+ }
+ }
+ return hex;
+}
+
+QByteArray
+HarbourUtil::toHexBytes(
+ const void* aData,
+ size_t aSize)
+{
+ return aSize ?
+ QByteArray::fromRawData((const char*) aData, (int) aSize).toHex() :
+ QByteArray();
+}
|
[-]
[+]
|
Added |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/src/libcrypto.c
^
|
@@ -0,0 +1,276 @@
+/*
+ * Copyright (C) 2021 Jolla Ltd.
+ * Copyright (C) 2021-2023 Slava Monich <slava@monich.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "gutil_log.h"
+
+#include <dlfcn.h>
+#include <stdint.h>
+
+#include <openssl/aes.h>
+#include <openssl/des.h>
+#include <openssl/md5.h>
+#include <openssl/rsa.h>
+#include <openssl/sha.h>
+
+/*
+ * What is this code?
+ *
+ * Sailfish OS comes in 3 flavors wrt openssl versions:
+ *
+ * 1. Sailfish OS up to 3.4 had openssl 1.0
+ * 2. Sailfish 4.0..4.2 had both openssl 1.0 and openssl 1.1 libraries
+ * 3. Sailfish 4.3 dropped openssl 1.0 libraries and only has openssl 1.1
+ *
+ * Which means that explicitly linking with any version of openssl
+ * makes your app incompatible with either Sailfish OS <= 3.4 or
+ * Sailfish OS >= 4.3 (nice symmetry).
+ *
+ * If you want to build an app which runs on both Sailfish OS <= 3.4
+ * and Sailfish OS >= 4.3 you have two options:
+ *
+ * 1. Link openssl statically
+ * 2. Load libcrypts.so dynamically with dlopen/dlsym
+ *
+ * This module allows you to implement the second strategy. It works
+ * because openssl 1.0 and 1.1 (luckily!) appear to be binary compatible.
+ * It doesn't load all libcrypto functions, only those referenced by my
+ * apps but the list can be easily expanded.
+ */
+
+#ifndef LIBDIR
+# ifdef __aarch64__
+# define LIBDIR "/usr/lib64"
+# else
+# define LIBDIR "/usr/lib"
+# endif
+#endif
+
+/*
+ * OpenSSL 1.0 headers define ERR_load_crypto_strings as a function:
+ *
+ * void ERR_load_crypto_strings(void);
+ *
+ * and OpenSSL 1.1 as a macro:
+ *
+ * #if OPENSSL_API_COMPAT < 0x10100000L
+ * # define ERR_load_crypto_strings() \
+ * OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL)
+ * # define ERR_free_strings() while(0) continue
+ * #endif
+ *
+ * We want to try loading both ERR_load_crypto_strings and
+ * OPENSSL_init_crypto, one of which will probably fail.
+ */
+
+#if OPENSSL_VERSION_NUMBER >= 0x10100000L
+# undef ERR_load_crypto_strings
+#else
+# define OPENSSL_INIT_SETTINGS void
+#endif
+
+/* f(name,params,args) */
+#define LIBCRYPTO_FUNCTIONS1(f) \
+ f(AES_cbc_encrypt, \
+ (const unsigned char* in, unsigned char* out, size_t length, \
+ const AES_KEY* key, unsigned char* ivec, const int enc), \
+ (in, out, length, key, ivec, enc)) \
+ f(AES_cfb128_encrypt, \
+ (const unsigned char* in, unsigned char* out, size_t length, \
+ const AES_KEY* key,unsigned char* ivec, int* num, const int enc), \
+ (in, out, length, key, ivec, num, enc)) \
+ f(AES_ecb_encrypt, \
+ (const unsigned char* in, unsigned char* out, const AES_KEY* key, \
+ const int enc), \
+ (in, out, key, enc)) \
+ f(BN_clear_free, (BIGNUM *a), (a)) \
+ f(BN_free, (BIGNUM *a), (a)) \
+ f(DES_ede3_cbc_encrypt, \
+ (const unsigned char* input, unsigned char* output, long length, \
+ DES_key_schedule* ks1, DES_key_schedule* ks2, DES_key_schedule* ks3, \
+ DES_cblock* ivec, int enc), \
+ (input, output, length, ks1, ks2, ks3, ivec, enc)) \
+ f(/* libcrypto.so.10 */ ERR_load_crypto_strings, (void), ()) \
+ f(RSA_free, (RSA* r), (r)) \
+ f(/* libcrypto.so.1.1 */ RSA_get0_key, (const RSA* r, const BIGNUM** n, \
+ const BIGNUM** e, const BIGNUM** d), (r, n, e, d)) \
+ f(/* libcrypto.so.1.1 */ RSA_get0_factors, (const RSA* r, \
+ const BIGNUM** p, const BIGNUM** q), (r, p, q)) \
+ f(/* libcrypto.so.1.1 */ RSA_get0_crt_params, (const RSA* r, \
+ const BIGNUM** dmp1, const BIGNUM** dmq1, const BIGNUM** iqmp), \
+ (r, dmp1, dmq1, iqmp))
+
+/* f(ret,name,params,args,def) */
+#define LIBCRYPTO_FUNCTIONS2(f) \
+ f(int, AES_set_decrypt_key, \
+ (const unsigned char* userKey, const int bits, AES_KEY* key), \
+ (userKey, bits, key), -1) \
+ f(int, AES_set_encrypt_key, \
+ (const unsigned char* userKey, const int bits, AES_KEY* key), \
+ (userKey, bits, key), -1) \
+ f(BIGNUM*, BN_bin2bn, \
+ (const unsigned char* s, int len, BIGNUM* ret), (s, len, ret), NULL) \
+ f(int, BN_bn2bin, \
+ (const BIGNUM* a, unsigned char* to), (a, to), 0) \
+ f(BIGNUM*, BN_new, (void), (), NULL) \
+ f(int, BN_num_bits, (const BIGNUM *a), (a), 0) \
+ f(int, BN_set_word, (BIGNUM* a, BN_ULONG w), (a, w), 0) \
+ f(int, DES_check_key_parity, (const_DES_cblock* key), (key), 0) \
+ f(int, DES_is_weak_key, (const_DES_cblock* key), (key), 0) \
+ f(int, DES_set_key, \
+ (const_DES_cblock* key, DES_key_schedule* schedule), \
+ (key, schedule), -1) \
+ f(char*, ERR_error_string, (unsigned long e, char* buf), (e, buf), NULL) \
+ f(unsigned long, ERR_get_error, (void), (), 0) \
+ f(unsigned char*, MD5, \
+ (const unsigned char* d, size_t n, unsigned char* md), (d, n, md), NULL) \
+ f(int, MD5_Final, (unsigned char* md, MD5_CTX* c), (md, c), 0) \
+ f(int, MD5_Init, (MD5_CTX* c), (c), 0) \
+ f(int, MD5_Update, (MD5_CTX* c, const void* data, size_t len), \
+ (c, data, len), 0) \
+ f(int, /* libcrypto.so.1.1 */ OPENSSL_init_crypto, \
+ (uint64_t opts, const OPENSSL_INIT_SETTINGS* settings), \
+ (opts, settings), 0) \
+ f(int, RAND_bytes, (unsigned char* buf, int num), (buf, num), 0) \
+ f(int, RAND_poll, (void), (), 0) \
+ f(RSA*, RSAPrivateKey_dup, (RSA* rsa), (rsa), NULL) \
+ f(RSA*, RSAPublicKey_dup, (RSA* rsa), (rsa), NULL) \
+ f(int, RSA_generate_key_ex, \
+ (RSA* rsa, int bits, BIGNUM* e, BN_GENCB* cb), \
+ (rsa, bits, e, cb), 0) \
+ f(RSA*, RSA_new, (void), (), NULL) \
+ f(int, RSA_private_decrypt, \
+ (int flen, const unsigned char* from, unsigned char* to, RSA* rsa, \
+ int padding), (flen, from, to, rsa, padding), 0) \
+ f(int, RSA_private_encrypt, \
+ (int flen, const unsigned char* from, unsigned char* to, RSA* rsa, \
+ int padding), (flen, from, to, rsa, padding), 0) \
+ f(int, RSA_public_decrypt, \
+ (int flen, const unsigned char* from, unsigned char* to, RSA* rsa, \
+ int padding), (flen, from, to, rsa, padding), 0) \
+ f(int, RSA_public_encrypt, \
+ (int flen, const unsigned char* from, unsigned char* to, RSA* rsa, \
+ int padding), (flen, from, to, rsa, padding), 0) \
+ f(int, RSA_size, (const RSA* rsa), (rsa), 0) \
+ f(int, /* libcrypto.so.1.1 */ RSA_set0_key, (RSA* r, BIGNUM* n, \
+ BIGNUM* e, BIGNUM* d), (r, n, e, d), 0) \
+ f(int, /* libcrypto.so.1.1 */ RSA_set0_factors, (RSA* r, BIGNUM* p, \
+ BIGNUM* q), (r, p, q), 0) \
+ f(int, /* libcrypto.so.1.1 */ RSA_set0_crt_params, (RSA* r, \
+ BIGNUM* dmp1, BIGNUM* dmq1, BIGNUM* iqmp), (r, dmp1, dmq1, iqmp), 0) \
+ f(unsigned char*, SHA1, (const unsigned char* d, size_t n, \
+ unsigned char* md), (d, n, md), NULL) \
+ f(int, SHA1_Final, (unsigned char* md, SHA_CTX* c), (md, c), 0) \
+ f(int, SHA1_Init, (SHA_CTX* c), (c), 0) \
+ f(int, SHA1_Update, (SHA_CTX* c, const void* data, size_t len), \
+ (c, data, len), 0) \
+ f(unsigned char*, SHA256, (const unsigned char* d, size_t n, \
+ unsigned char* md), (d, n, md), NULL) \
+ f(int, SHA256_Final, (unsigned char* md, SHA256_CTX* c), (md, c), 0) \
+ f(int, SHA256_Init, (SHA256_CTX* c), (c), 0) \
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/test/Makefile
^
|
@@ -4,3 +4,5 @@
%:
@$(MAKE) -C TestHarbourBase32 $*
@$(MAKE) -C TestHarbourBase45 $*
+ @$(MAKE) -C TestHarbourProtoBuf $*
+ @$(MAKE) -C TestHarbourUtil $*
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/test/Makefile.common
^
|
@@ -31,6 +31,8 @@
SRC_DIR = .
TOP_DIR = ../..
HARBOUR_DIR = $(TOP_DIR)
+HARBOUR_INCLUDE_DIR = $(HARBOUR_DIR)/include
+HARBOUR_SRC_DIR = $(HARBOUR_DIR)/src
BUILD_DIR = build
DEBUG_BUILD_DIR = $(BUILD_DIR)/debug
RELEASE_BUILD_DIR = $(BUILD_DIR)/release
@@ -44,7 +46,7 @@
LD = $(CC)
MOC = qtchooser -run-tool=moc -qt=5
WARNINGS = -Wall
-INCLUDES = -I$(BUILD_DIR) -I$(HARBOUR_DIR)/include
+INCLUDES = -I$(BUILD_DIR) -I$(HARBOUR_INCLUDE_DIR)
BASE_FLAGS = -fPIC
BASE_LDFLAGS = $(BASE_FLAGS) $(LDFLAGS)
BASE_CFLAGS = $(BASE_FLAGS) $(CFLAGS)
@@ -84,6 +86,9 @@
$(MOC_CPP:%.cpp=$(COVERAGE_BUILD_DIR)/moc_cpp_%.o) \
$(SRC:%.cpp=$(COVERAGE_BUILD_DIR)/%.o) \
$(HARBOUR_SRC:%.cpp=$(COVERAGE_BUILD_DIR)/harbour_%.o)
+GEN_FILES = \
+ $(MOC_H:%.h=$(BUILD_DIR)/moc_%.cpp) \
+ $(MOC_CPP:%.cpp=$(BUILD_DIR)/%.moc)
#
# Dependencies
@@ -96,6 +101,7 @@
endif
endif
+$(GEN_FILES): | $(BUILD_DIR)
$(DEBUG_OBJS): | $(DEBUG_BUILD_DIR)
$(RELEASE_OBJS): | $(RELEASE_BUILD_DIR)
$(COVERAGE_OBJS): | $(COVERAGE_BUILD_DIR)
@@ -139,10 +145,10 @@
$(COVERAGE_BUILD_DIR):
mkdir -p $@
-$(BUILD_DIR)/moc_%.cpp : $(APP_DIR)/%.h
+$(BUILD_DIR)/moc_%.cpp : $(HARBOUR_INCLUDE_DIR)/%.h
$(MOC) $< -o $@
-$(BUILD_DIR)/%.moc : $(APP_DIR)/%.cpp
+$(BUILD_DIR)/%.moc : $(HARBOUR_SRC_DIR)/%.cpp
$(MOC) $< -o $@
$(DEBUG_BUILD_DIR)/%.o : $(SRC_DIR)/%.cpp
@@ -163,31 +169,22 @@
$(COVERAGE_BUILD_DIR)/moc_h_%.o : $(BUILD_DIR)/moc_%.cpp $(BUILD_DIR)
$(CC) -c $(COVERAGE_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
-$(DEBUG_BUILD_DIR)/moc_cpp_%.o : $(HARBOUR_DIR)/%.cpp $(BUILD_DIR)/%.moc
+$(DEBUG_BUILD_DIR)/moc_cpp_%.o : $(HARBOUR_SRC_DIR)/%.cpp $(BUILD_DIR)/%.moc
$(CC) -c $(DEBUG_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
-$(RELEASE_BUILD_DIR)/moc_cpp_%.o : $(HARBOUR_DIR)/%.cpp $(BUILD_DIR)/%.moc
+$(RELEASE_BUILD_DIR)/moc_cpp_%.o : $(HARBOUR_SRC_DIR)/%.cpp $(BUILD_DIR)/%.moc
$(CC) -c $(RELEASE_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
-$(COVERAGE_BUILD_DIR)/moc_cpp_%.o : $(HARBOUR_DIR)/%.cpp $(BUILD_DIR)/%.moc
+$(COVERAGE_BUILD_DIR)/moc_cpp_%.o : $(HARBOUR_SRC_DIR)/%.cpp $(BUILD_DIR)/%.moc
$(CC) -c $(COVERAGE_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
-$(DEBUG_BUILD_DIR)/app_%.o : $(APP_DIR)/%.cpp
+$(DEBUG_BUILD_DIR)/harbour_%.o : $(HARBOUR_SRC_DIR)/%.cpp
$(CC) -c $(DEBUG_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
-$(RELEASE_BUILD_DIR)/app_%.o : $(APP_DIR)/%.cpp
+$(RELEASE_BUILD_DIR)/harbour_%.o : $(HARBOUR_SRC_DIR)/%.cpp
$(CC) -c $(RELEASE_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
-$(COVERAGE_BUILD_DIR)/app_%.o : $(APP_DIR)/%.cpp
- $(CC) -c $(COVERAGE_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
-
-$(DEBUG_BUILD_DIR)/harbour_%.o : $(HARBOUR_DIR)/src/%.cpp
- $(CC) -c $(DEBUG_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
-
-$(RELEASE_BUILD_DIR)/harbour_%.o : $(HARBOUR_DIR)/src/%.cpp
- $(CC) -c $(RELEASE_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
-
-$(COVERAGE_BUILD_DIR)/harbour_%.o : $(HARBOUR_DIR)/src/%.cpp
+$(COVERAGE_BUILD_DIR)/harbour_%.o : $(HARBOUR_SRC_DIR)/%.cpp
$(CC) -c $(COVERAGE_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
$(DEBUG_EXE): $(DEBUG_OBJS)
|
[-]
[+]
|
Added |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/test/TestHarbourProtoBuf/Makefile
^
|
@@ -0,0 +1,7 @@
+# -*- Mode: makefile-gmake -*-
+
+PKGS = libglibutil
+EXE = TestHarbourProtoBuf
+HARBOUR_SRC = HarbourProtoBuf.cpp
+
+include ../Makefile.common
|
[-]
[+]
|
Added |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/test/TestHarbourProtoBuf/TestHarbourProtoBuf.cpp
^
|
@@ -0,0 +1,168 @@
+/*
+ * Copyright (C) 2022 Jolla Ltd.
+ * Copyright (C) 2022 Slava Monich <slava.monich@jolla.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "HarbourProtoBuf.h"
+
+#include <glib.h>
+
+/*==========================================================================*
+ * null
+ *==========================================================================*/
+
+static
+void
+test_null(
+ void)
+{
+ g_assert(!HarbourProtoBuf::appendVarInt(NULL, 0));
+ g_assert(!HarbourProtoBuf::appendVarIntKeyValue(NULL, 0, 0));
+ g_assert(!HarbourProtoBuf::appendDelimitedValue(NULL, QByteArray()));
+ g_assert(!HarbourProtoBuf::appendDelimitedKeyValue(NULL,
+ HarbourProtoBuf::TYPE_DELIMITED, QByteArray()));
+ g_assert(!HarbourProtoBuf::parseVarInt(NULL, NULL));
+ g_assert(!HarbourProtoBuf::parseDelimitedValue(NULL, NULL));
+}
+
+/*==========================================================================*
+ * int
+ *==========================================================================*/
+
+static
+void
+test_int(
+ void)
+{
+ QByteArray buf;
+ GUtilRange range;
+ quint64 res;
+
+ static const guint8 enc0[] = { 0 };
+
+ g_assert(HarbourProtoBuf::appendVarInt(&buf, 0) == &buf);
+ g_assert(buf == QByteArray::fromRawData((char*)enc0, sizeof(enc0)));
+
+ range.end = (range.ptr = enc0);
+ g_assert(!HarbourProtoBuf::parseVarInt(&range, NULL));
+ range.end = (range.ptr = enc0);
+
+ res = 42;
+ g_assert(!HarbourProtoBuf::parseVarInt(&range, &res));
+ g_assert_cmpuint(res, == ,0);
+
+ range.end = (range.ptr = enc0) + sizeof(enc0);
+ g_assert(HarbourProtoBuf::parseVarInt(&range, NULL));
+ g_assert(range.ptr == range.end);
+
+ res = 42;
+ range.end = (range.ptr = enc0) + sizeof(enc0);
+ g_assert(HarbourProtoBuf::parseVarInt(&range, &res));
+ g_assert_cmpuint(res, == ,0);
+
+ static const guint8 enc257[] = { 0x82, 0x01 };
+
+ buf.clear();
+ g_assert(HarbourProtoBuf::appendVarInt(&buf, 257) == &buf);
+ g_assert(buf == QByteArray::fromRawData((char*)enc257, sizeof(enc257)));
+
+ res = 42;
+ range.end = (range.ptr = enc257) + 1;
+ g_assert(!HarbourProtoBuf::parseVarInt(&range, &res));
+ g_assert_cmpuint(res, == ,0);
+
+ res = 42;
+ range.end = (range.ptr = enc257) + sizeof(enc257);
+ g_assert(HarbourProtoBuf::parseVarInt(&range, &res));
+ g_assert(range.ptr == range.end);
+ g_assert_cmpuint(res, == ,257);
+}
+
+/*==========================================================================*
+ * delimited
+ *==========================================================================*/
+
+static
+void
+test_delimited(
+ void)
+{
+ QByteArray buf;
+ GUtilRange range;
+ GUtilData payload;
+ static const guint8 value[] = { 0x01, 0x02 };
+ static const guint8 encodedValue[] = { 0x02, 0x01, 0x02 };
+
+ g_assert(HarbourProtoBuf::appendDelimitedValue(&buf,
+ QByteArray::fromRawData((char*)value, sizeof(value))) == &buf);
+ g_assert(buf == QByteArray::fromRawData((char*)encodedValue,
+ sizeof(encodedValue)));
+
+ range.end = (range.ptr = encodedValue);
+ g_assert(!HarbourProtoBuf::parseDelimitedValue(&range, NULL));
+ g_assert(range.ptr == encodedValue);
+
+ range.end = (range.ptr = encodedValue) + sizeof(encodedValue) - 1;
+ g_assert(!HarbourProtoBuf::parseDelimitedValue(&range, NULL));
+ g_assert(range.ptr == encodedValue);
+
+ range.end = (range.ptr = encodedValue) + sizeof(encodedValue);
+ g_assert(HarbourProtoBuf::parseDelimitedValue(&range, NULL));
+
+ memset(&payload, 0, sizeof(payload));
+ range.end = (range.ptr = encodedValue) + sizeof(encodedValue);
+ g_assert(HarbourProtoBuf::parseDelimitedValue(&range, &payload));
+ g_assert_cmpuint(payload.size, == ,sizeof(value));
+ g_assert(!memcmp(payload.bytes, value, sizeof(value)));
+}
+
+/*==========================================================================*
+ * Common
+ *==========================================================================*/
+
+#define TEST_(name) "/HarbourProtoBuf/" name
+
+int main(int argc, char* argv[])
+{
+ g_test_init(&argc, &argv, NULL);
+ g_test_add_func(TEST_("null"), test_null);
+ g_test_add_func(TEST_("int"), test_int);
+ g_test_add_func(TEST_("delimited"), test_delimited);
+ return g_test_run();
+}
+
+/*
+ * Local Variables:
+ * mode: C++
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
|
[-]
[+]
|
Added |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/test/TestHarbourUtil/Makefile
^
|
@@ -0,0 +1,8 @@
+# -*- Mode: makefile-gmake -*-
+
+PKGS = Qt5Gui
+EXE = TestHarbourUtil
+MOC_H = HarbourUtil.h
+HARBOUR_SRC = HarbourUtil.cpp
+
+include ../Makefile.common
|
[-]
[+]
|
Added |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/test/TestHarbourUtil/TestHarbourUtil.cpp
^
|
@@ -0,0 +1,115 @@
+/*
+ * Copyright (C) 2022 Jolla Ltd.
+ * Copyright (C) 2022 Slava Monich <slava.monich@jolla.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "HarbourUtil.h"
+
+#include <glib.h>
+
+/*==========================================================================*
+ * object
+ *==========================================================================*/
+
+static
+void
+test_object(
+ void)
+{
+ QObject* obj = HarbourUtil::createSingleton(Q_NULLPTR, Q_NULLPTR);
+
+ g_assert(qobject_cast<HarbourUtil*>(obj));
+ delete obj;
+}
+
+/*==========================================================================*
+ * invertColor
+ *==========================================================================*/
+
+static
+void
+test_invertColor(
+ void)
+{
+ g_assert_cmpuint(HarbourUtil::invertedRgb(0x12345678), == ,0x12cba987);
+ const QColor original(0xcb,0xa9,0x87,0x12);
+ const QColor inverted(0x34,0x56,0x78,0x12);
+ g_assert(HarbourUtil::invertedColor(original) == inverted);
+ g_assert(!HarbourUtil::invertedColor(QColor()).isValid());
+}
+
+/*==========================================================================*
+ * toHex
+ *==========================================================================*/
+
+static
+void
+test_toHex(
+ void)
+{
+ static const char data[] = {
+ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A,
+ 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14
+ };
+
+ // Lower case is assumed
+ const QByteArray hex("0102030405060708090a0b0c0d0e0f1011121314");
+
+ g_assert(HarbourUtil::toHex(QByteArray()).isEmpty());
+ g_assert(HarbourUtil::toHex(Q_NULLPTR, 0).isEmpty());
+ g_assert(HarbourUtil::toHexBytes(Q_NULLPTR, 0).isEmpty());
+ g_assert(HarbourUtil::toHex(data, sizeof(data)) == QString::fromLatin1(hex));
+ const QByteArray out(HarbourUtil::toHexBytes(data, sizeof(data)));
+ g_assert_cmpstr(out.constData(), == ,hex.constData());
+}
+
+/*==========================================================================*
+ * Common
+ *==========================================================================*/
+
+#define TEST_(name) "/HarbourUtil/" name
+
+int main(int argc, char* argv[])
+{
+ g_test_init(&argc, &argv, NULL);
+ g_test_add_func(TEST_("object"), test_object);
+ g_test_add_func(TEST_("invertColor"), test_invertColor);
+ g_test_add_func(TEST_("toHex"), test_toHex);
+ return g_test_run();
+}
+
+/*
+ * Local Variables:
+ * mode: C++
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-lib/test/coverage/run
^
|
@@ -5,7 +5,9 @@
TESTS="\
TestHarbourBase32 \
-TestHarbourBase45"
+TestHarbourBase45 \
+TestHarbourProtoBuf \
+TestHarbourUtil"
function err() {
echo "*** ERROR!" $1
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-meecalc.desktop
^
|
@@ -5,3 +5,9 @@
Name=MeeCalc
Icon=harbour-meecalc
Exec=harbour-meecalc
+
+[X-HarbourBackup]
+BackupPathList = .local/share/harbour-meecalc/
+
+[X-Sailjail]
+Permissions=
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-meecalc-1.0.10.tar.bz2/harbour-meecalc.pro
^
|
@@ -41,6 +41,7 @@
icons/*.svg \
*.md \
*.desktop \
+ LICENSE \
rpm/harbour-meecalc.changes \
rpm/harbour-meecalc.spec
|