2 Achegas 5eab65716a ... 3cee9ddf1f

Autor SHA1 Mensaxe Data
  devnull auf KSeon 3cee9ddf1f SQLite Änderungen hai 4 días
  devnull 7e398ad5c7 - es gibt eine weitere Version der Datenbank hai 4 días
Modificáronse 7 ficheiros con 123 adicións e 22 borrados
  1. 3 1
      CMakeLists.txt
  2. 1 1
      CMakeLists.txt.user
  3. 4 6
      po/utarchery.siningsoft.de.pot
  4. 23 14
      qml/Main.qml
  5. 82 0
      qml/database.js
  6. 10 0
      test/utarcherydb.sqbpro
  7. BIN=BIN
      test/utarcherydb.sqlite

+ 3 - 1
CMakeLists.txt

@@ -67,7 +67,9 @@ add_custom_target(${DESKTOP_FILE_NAME} ALL
 
 target_sources(utarchery.desktop
   PRIVATE
-    Main.qml
+    qml/Main.qml
+    qml/ViewPasse.qml
+    qml/database.js
 )
 
 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${DESKTOP_FILE_NAME} DESTINATION ${DATA_DIR})

+ 1 - 1
CMakeLists.txt.user

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE QtCreatorProject>
-<!-- Written by QtCreator 12.0.82, 2026-11-16T22:30:32. -->
+<!-- Written by QtCreator 12.0.82, 2026-11-18T23:21:19. -->
 <qtcreator>
  <data>
   <variable>EnvironmentId</variable>

+ 4 - 6
po/utarchery.siningsoft.de.pot

@@ -1,14 +1,14 @@
 # SOME DESCRIPTIVE TITLE.
 # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
-# This file is distributed under the same license as the PACKAGE package.
+# This file is distributed under the same license as the utarchery.siningsoft.de package.
 # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
 #
 #, fuzzy
 msgid ""
 msgstr ""
-"Project-Id-Version: utarchery\n"
+"Project-Id-Version: utarchery.siningsoft.de\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2017-01-17 02:22+0000\n"
+"POT-Creation-Date: 2026-11-19 00:51+0000\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -17,8 +17,6 @@ msgstr ""
 "Content-Type: text/plain; charset=CHARSET\n"
 "Content-Transfer-Encoding: 8bit\n"
 
-msgid "Hello World!"
-msgstr ""
-
+#: ../qml/Main.qml:40 utarchery.desktop.in.h:1
 msgid "utArchery"
 msgstr ""

+ 23 - 14
qml/Main.qml

@@ -12,19 +12,28 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+ * QML/LocalStorage
+ *   https://code.qt.io/cgit/qt/qtdeclarative.git/tree/examples/quick/localstorage/localstorage.qml?h=6.12
+ *   https://code.qt.io/cgit/qt/qtdeclarative.git/tree/examples/quick/localstorage/Database.js?h=6.12
+ *   https://ubports.gitlab.io/docs/api-docs/?p=qtquick%2Fqtquick-localstorage-qmlmodule.html
  */
 
 import QtQuick 2.7
 import Lomiri.Components 1.3
-//import QtQuick.Controls 2.2
+import QtQuick.Controls 2.2
 import QtQuick.Layouts 1.3
 import Qt.labs.settings 1.0
+import QtQuick.LocalStorage 2.7
+import QtQml 2.7
+import "database.js" as DBjs
 
 MainView {
     id: root
-    objectName: 'mainView'
+
     applicationName: 'utarchery.siningsoft.de'
 
+    visible: true
     width: units.gu(45)
     height: units.gu(75)
 
@@ -36,17 +45,17 @@ MainView {
             title: i18n.tr('utArchery')
         }
 
-        Label {
-            anchors {
-                top: header.bottom
-                left: parent.left
-                right: parent.right
-                bottom: parent.bottom
-            }
-            text: i18n.tr('Hello World!')
-
-            verticalAlignment: Label.AlignVCenter
-            horizontalAlignment: Label.AlignHCenter
-        }
+
+
+
+
+        Component.onCompleted : DBjs.init()
+
+
+
+
+
     }
+
 }
+

+ 82 - 0
qml/database.js

@@ -0,0 +1,82 @@
+
+/* Datenbankhandle übergeben
+ *
+ */
+function getHandle()
+{
+    try {
+        var db = LocalStorage.openDatabaseSync("utarchery.sqlite", "0.9", "utArchery Datenbank", 1000000)
+        console.log("Database Handle angelegt")
+    }
+    catch (err) {
+
+        console.log("Error creating tables in database: " + err)
+    }
+
+    return db
+}
+
+/* Initialisiere Datenbank
+ * - Tabellen anlegen
+ */
+function init()
+{
+    let db = getHandle()
+    try {
+        db.transaction(function (tx) {
+
+            // Tabellenstruktur anlegen
+            tx.executeSql('CREATE TABLE IF NOT EXISTS "event" ("nr"	INTEGER,"timestamp"	INTEGER,"note"	TEXT,PRIMARY KEY("nr" AUTOINCREMENT))')
+            tx.executeSql('CREATE TABLE IF NOT EXISTS"passe" ("nr"	INTEGER NOT NULL,"score"	INTEGER NOT NULL DEFAULT 0,"event"	INTEGER NOT NULL,"arrow"	INTEGER NOT NULL,"note"	TEXT,"pic"	TEXT,FOREIGN KEY("event") REFERENCES "event"("nr"),PRIMARY KEY("nr" AUTOINCREMENT))')
+
+            // Views erzeugen
+            tx.executeSql('create view if not exists event_view_1 as \
+                            select
+                                e.nr as nr,
+                                e.timestamp as timestamp,
+                                e.note as eventnote,
+                                (select sum(score) from passe as p where p.event = e.nr) as sum_score,
+                                (select count(nr) from passe as p where p.event = e.nr) as count_passe,
+                                (select sum(arrow) from passe as p where p.event = e.nr) as sum_arrow
+
+                            from event e')
+            })
+
+            console.log("Tabellen und Views erfolgreich angelegt")
+    }
+    catch (err) {
+        console.log("Error creating tables in database: " + err)
+    }
+}
+
+/* wir lesen die Eventuebersicht aus dem View event_view_1 aus
+ *
+ * Spalten
+ *   | nr          | laufende AI Nummer über alle Events |
+ *   | timestampt  | Zeitstempel                         |
+ *   | eventnote   | Notiz                               |
+ *   | sum_score   | Gesamtpunktzahl über alle Passen    |
+ *   | count_passe | Anzahl der Passen                   |
+ *   | sum_arrow   | Gesamtanzahl der Pfeile             |
+
+ * ToDo: das listModel muss auf ein TableModel umgestellt werden
+ * ToDo: der Timestampt für Date muss wohl noch konvertiert werden
+ */
+function readEvents()
+{
+    let db = getHandle()
+    db.transaction(function(tx) {
+        let results = ty.executeSql('select * from event_view_1')
+        for (let i = 0; i< results.rows.length; i++) {
+            listModel.append({id: results.rows.item(i).rowid,
+                                 nr: results.rows.item(1).nr,
+                                 timestamp: results.rows.item(i).timestamp,
+                                 note: results.rows.item(i).eventnote,
+                                 sum_score: results.rows.item(i).sum_score,
+                                 count_passe: results.rows.item(i).cout_passe,
+                                 sum_arrow: results.rows.item(i).sum_arrow
+
+    })
+        }
+    })
+}

+ 10 - 0
test/utarcherydb.sqbpro

@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?><sqlb_project><db path="utarcherydb.sqlite" readonly="0" foreign_keys="1" case_sensitive_like="0" temp_store="0" wal_autocheckpoint="1000" synchronous="2"/><attached/><window><main_tabs open="structure browser pragmas query" current="0"/></window><tab_structure><column_width id="0" width="300"/><column_width id="1" width="0"/><column_width id="2" width="100"/><column_width id="3" width="1933"/><column_width id="4" width="0"/><expanded_item id="0" parent="1"/><expanded_item id="1" parent="1"/><expanded_item id="2" parent="1"/><expanded_item id="0" parent="2"/><expanded_item id="3" parent="1"/></tab_structure><tab_browse><table title="event" custom_title="0" dock_id="1" table="4,5:mainevent"/><dock_state state="000000ff00000000fd0000000100000002000003a4000002d2fc0100000001fc00000000000003a40000011f00fffffffa000000000100000002fb000000160064006f0063006b00420072006f00770073006500310100000000ffffffff0000011f00fffffffb000000160064006f0063006b00420072006f00770073006500320000000000ffffffff0000000000000000000002790000000000000004000000040000000800000008fc00000000"/><default_encoding codec=""/><browse_table_settings><table schema="main" name="event" show_row_id="0" encoding="" plot_x_axis="" unlock_view_pk="_rowid_" freeze_columns="0"><sort/><column_widths><column index="1" value="38"/><column index="2" value="70"/><column index="3" value="38"/></column_widths><filter_values/><conditional_formats/><row_id_formats/><display_formats/><hidden_columns/><plot_y_axes/><global_filter/></table></browse_table_settings></tab_browse><tab_sql><sql name="SQL 1*">create view if not exists event_view_1 as 
+select 
+	e.nr,
+	e.timestamp as timestamp,
+	e.note as eventnote,
+	(select sum(score) from passe as p where p.event = e.nr) as sum_score,
+	(select count(nr) from passe as p where p.event = e.nr) as count_passe,
+	(select sum(arrow) from passe as p where p.event = e.nr) as sum_arrow
+
+from event e</sql><current_tab id="0"/></tab_sql></sqlb_project>

BIN=BIN
test/utarcherydb → test/utarcherydb.sqlite