harbour-seaprint/qml/harbour-seaprint.qml

59 lines
1.5 KiB
QML
Raw Normal View History

2019-12-01 17:40:10 +03:00
import QtQuick 2.0
import Sailfish.Silica 1.0
2019-12-01 17:55:55 +03:00
import QtQuick.LocalStorage 2.0
import Nemo.Notifications 1.0
2019-12-01 17:40:10 +03:00
import "pages"
ApplicationWindow
{
initialPage: Component { FirstPage { } }
cover: Qt.resolvedUrl("cover/CoverPage.qml")
allowedOrientations: defaultAllowedOrientations
2019-12-01 17:55:55 +03:00
Item {
id: db
property var db_conn
Component.onCompleted: {
db_conn = LocalStorage.openDatabaseSync("TintDB", "1.0", "Tint storage", 100000)
db_conn.transaction(function (tx) {
2019-12-01 22:21:36 +03:00
tx.executeSql('CREATE TABLE IF NOT EXISTS Favourites (ssid STRING, url STRING)');
2019-12-01 17:55:55 +03:00
});
}
2019-12-01 22:21:36 +03:00
function addFavourite(ssid, url) {
2019-12-01 17:55:55 +03:00
db_conn.transaction(function (tx) {
2019-12-01 22:21:36 +03:00
tx.executeSql('INSERT INTO Favourites VALUES(?, ?)', [ssid, url] );
2019-12-01 17:55:55 +03:00
});
}
2019-12-01 22:21:36 +03:00
function getFavourites(ssid) {
2019-12-01 17:55:55 +03:00
var favs = [];
db_conn.transaction(function (tx) {
2019-12-01 22:21:36 +03:00
var res = tx.executeSql('SELECT * FROM Favourites WHERE ssid=?', [ssid]);
2019-12-01 17:55:55 +03:00
if (res.rows.length !== 0) {
console.log(res.rows.item(0).url)
favs.push(res.rows.item(0).url);
}
});
2019-12-01 22:21:36 +03:00
console.log(ssid, favs);
2019-12-01 17:55:55 +03:00
return favs
}
}
Notification {
id: notifier
expireTimeout: 4000
function notify(data) {
console.log("notifyMessage", data)
body = data
previewBody = data
publish()
}
}
2019-12-01 17:40:10 +03:00
}
2019-12-01 17:55:55 +03:00