// tonalisa - software to look at overtone-structures // Copyright (C) 2016 Dominik Schmidt-Philipp // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see . // import QtQuick 2.3 import QtQuick.Controls 1.2 import QtQuick.LocalStorage 2.0 Item { id: root width: parent.width; height:parent.height property alias model: scaleModel property alias list: scaleList property var db; Rectangle { anchors.fill: parent } Button { id: newScale text: "new" x:0;y:0 onClicked: { scaleList.model.append({ "name":"equal", "tunedStep":9, "pitch":440.0, "highest":0, "lowest":0, "cents":"[0,100,200,300,400,500,600,700,800,900,1000,1100]" }); scaleList.currentIndex = scaleModel.count-1 } } Button { id: updateScale text: "update" x:80;y:0 onClicked: { scaleList.model.get(scaleList.currentIndex).name = sEname.text; scaleList.model.get(scaleList.currentIndex).tunedStep = sEtunedStep.text; scaleList.model.get(scaleList.currentIndex).pitch = sEpitch.text; scaleList.model.get(scaleList.currentIndex).lowest = sElowest.text; scaleList.model.get(scaleList.currentIndex).highest = sEhighest.text; scaleList.model.get(scaleList.currentIndex).cents = JSON.stringify(scaleEditor.centBuffer); } } Button { id: deleteScale text: "delete" anchors.right:parent.right; onClicked: { scaleList.model.remove(scaleList.currentIndex) } } Item { id: scaleEditor x:2;y:30 width:parent.width/2-4 height:parent.height-40 property var index:0 property var centBuffer:[] TextField { height:18 x:10;y:0 id: sEname } Text {x:120;y:0;text:"name" } TextField { height:18 x:10;y:20 id: sEpitch } Text {x:120;y:20;text:"ReferencePitch (Hz)" } TextField { height:18 x:10;y:40 id: sEtunedStep } Text {x:120;y:40;text:"index of tuned Step" } TextField { height:18 x:10;y:60 id: sEhighest } Text {x:120;y:60;text:"upper limit (Hz)" } TextField { height:18 x:10;y:80 id: sElowest } Text {x:120;y:80;text:"lower limit (Hz)" } ListView { id:sEcents x: 10;y:100 height:200 model:[10,20,30] delegate: Item { height:16 TextField { height:16;width:40; text:modelData onTextChanged: { scaleEditor.centBuffer[index]=text } } Text { x:45; text: "cents" } } } } function initDatabase() { db = LocalStorage.openDatabaseSync( "ExtendedFrequencyToolDB", "0.2", "Scales and Spectra", 100000) db.transaction( function(tx) { console.log("... create 'scales' table") tx.executeSql( // all entries for scales are in cents, which are saved as REALs 'CREATE TABLE IF NOT EXISTS scales(' +'id INTEGER,' +'name TEXT,' +'tunedStep INTEGER,' +'pitch REAL,' // Hz +'highest REAL,' +'lowest REAL,' +'cents TEXT)' ) }); } function storeData() { if(!db) { return; } db.transaction( function(tx) { for (var i=0;i 0 ) { for ( var i=0;i