From 81f3547906b7f1e6a8ff2dc696f570aae78c90b7 Mon Sep 17 00:00:00 2001 From: Alexandre PROUST Date: Sat, 18 Jan 2025 20:03:20 +0100 Subject: [PATCH] Ajout du menu d'emprunt --- CMakeLists.txt | 3 +- Database.js | 2 +- DemoDetail.qml => DetailCostume.qml | 131 +++++++++++----- EmpruntMenu.qml | 229 ++++++++++++++++++++++++++++ Launch.bat | 3 + SortFilterModel.qml | 2 +- DemoTile.qml => TileCostume.qml | 0 dependency.bat | 1 + main.cpp | 2 +- main.qml | 25 ++- 10 files changed, 351 insertions(+), 47 deletions(-) rename DemoDetail.qml => DetailCostume.qml (70%) create mode 100644 EmpruntMenu.qml create mode 100644 Launch.bat rename DemoTile.qml => TileCostume.qml (100%) create mode 100644 dependency.bat diff --git a/CMakeLists.txt b/CMakeLists.txt index bfc45aa..e70ea0f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,9 +19,10 @@ qt_add_qml_module(appGestionnaire_dressing Main.qml QML_FILES RESOURCES Data/Photos/Pas-dimage-disponible.jpg Data/Photos/logo.png Theme/QUANTUM/Fonts/Roboto/LICENSE.txt Theme/QUANTUM/Fonts/Roboto/Roboto-Black.ttf Theme/QUANTUM/Fonts/Roboto/Roboto-BlackItalic.ttf Theme/QUANTUM/Fonts/Roboto/Roboto-Bold.ttf Theme/QUANTUM/Fonts/Roboto/Roboto-BoldItalic.ttf Theme/QUANTUM/Fonts/Roboto/Roboto-Italic.ttf Theme/QUANTUM/Fonts/Roboto/Roboto-Light.ttf Theme/QUANTUM/Fonts/Roboto/Roboto-LightItalic.ttf Theme/QUANTUM/Fonts/Roboto/Roboto-Medium.ttf Theme/QUANTUM/Fonts/Roboto/Roboto-MediumItalic.ttf Theme/QUANTUM/Fonts/Roboto/Roboto-Regular.ttf Theme/QUANTUM/Fonts/Roboto/Roboto-Thin.ttf Theme/QUANTUM/Fonts/Roboto/Roboto-ThinItalic.ttf Theme/QUANTUM/Fonts/Roboto-Mono/static/RobotoMono-Bold.ttf Theme/QUANTUM/Fonts/Roboto-Mono/static/RobotoMono-BoldItalic.ttf Theme/QUANTUM/Fonts/Roboto-Mono/static/RobotoMono-ExtraLight.ttf Theme/QUANTUM/Fonts/Roboto-Mono/static/RobotoMono-ExtraLightItalic.ttf Theme/QUANTUM/Fonts/Roboto-Mono/static/RobotoMono-Italic.ttf Theme/QUANTUM/Fonts/Roboto-Mono/static/RobotoMono-Light.ttf Theme/QUANTUM/Fonts/Roboto-Mono/static/RobotoMono-LightItalic.ttf Theme/QUANTUM/Fonts/Roboto-Mono/static/RobotoMono-Medium.ttf Theme/QUANTUM/Fonts/Roboto-Mono/static/RobotoMono-MediumItalic.ttf Theme/QUANTUM/Fonts/Roboto-Mono/static/RobotoMono-Regular.ttf Theme/QUANTUM/Fonts/Roboto-Mono/static/RobotoMono-SemiBold.ttf Theme/QUANTUM/Fonts/Roboto-Mono/static/RobotoMono-SemiBoldItalic.ttf Theme/QUANTUM/Fonts/Roboto-Mono/static/RobotoMono-Thin.ttf Theme/QUANTUM/Fonts/Roboto-Mono/static/RobotoMono-ThinItalic.ttf Theme/QUANTUM/Fonts/Roboto-Mono/LICENSE.txt Theme/QUANTUM/Fonts/Roboto-Mono/README.txt Theme/QUANTUM/Fonts/Roboto-Mono/RobotoMono-Italic-VariableFont_wght.ttf Theme/QUANTUM/Fonts/Roboto-Mono/RobotoMono-VariableFont_wght.ttf Theme/QUANTUM/Images/Material_Icons.woff2 Theme/QUANTUM/Images/Material_Icons_Outlined.woff2 Theme/QUANTUM/Images/Material_Icons_Round.woff2 Theme/QUANTUM/Images/Material_Icons_Sharp.woff2 Theme/QUANTUM/Images/Material_Icons_Two_Tone.woff2 Theme/QUANTUM/qmldir -QML_FILES Theme/QUANTUM/Controls/AppliQuantum.qml Theme/QUANTUM/Controls/Button.qml Theme/QUANTUM/Controls/Header.qml Theme/QUANTUM/Controls/Switch.qml Theme/QUANTUM/Controls/Tag.qml Theme/QUANTUM/Colors.qml Theme/QUANTUM/Fonts.qml Database.js DemoDetail.qml DemoTile.qml Filters.qml JSONLoader.qml +QML_FILES Theme/QUANTUM/Controls/AppliQuantum.qml Theme/QUANTUM/Controls/Button.qml Theme/QUANTUM/Controls/Header.qml Theme/QUANTUM/Controls/Switch.qml Theme/QUANTUM/Controls/Tag.qml Theme/QUANTUM/Colors.qml Theme/QUANTUM/Fonts.qml Database.js DetailCostume.qml TileCostume.qml Filters.qml JSONLoader.qml SOURCES filevalidator.h filevalidator.cpp QML_FILES SortFilterModel.qml +QML_FILES EmpruntMenu.qml ) # Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1. diff --git a/Database.js b/Database.js index a45594d..32c7c9a 100644 --- a/Database.js +++ b/Database.js @@ -88,7 +88,7 @@ function dbUpdate(costume) db.transaction(function (tx) { tx.executeSql( 'update costume set id=?, type=?, description=?, genre=?, mode=?, epoque=?, couleur=?, taille=?, etat=?, emplacement=?, emprunteur=?, date_emprunt=?, date_versement_caution=?, date_retour=?, date_remoursement_caution=?, commentaires=? where rowid = ?', - [costume.id, costume.type, costume.description, costume.genre, costume.mode, costume.epoque, costume.couleur, costume.taille, costume.etat, costume.emplacement, costume.emprunteur, "", "", "", "", "", costume.id]) + [costume.id, costume.type, costume.description, costume.genre, costume.mode, costume.epoque, costume.couleur, costume.taille, costume.etat, costume.emplacement, costume.emprunteur, costume.date_emprunt, "", costume.date_retour, "", "", costume.id]) }) } diff --git a/DemoDetail.qml b/DetailCostume.qml similarity index 70% rename from DemoDetail.qml rename to DetailCostume.qml index fc6e225..ca6ea08 100644 --- a/DemoDetail.qml +++ b/DetailCostume.qml @@ -8,6 +8,15 @@ import Gestionnaire_dressing 1.0 Rectangle { id: demoDetail property var costumeSelected: ({}) + property string type: "" + property string description: "" + property string genre: "" + property string mode: "" + property string epoque: "" + property string couleur: "" + property string taille: "" + property string etat: "" + property string emplacement: "" property bool editMode: false property var filter: ({}) width: parent.width - 100 @@ -15,10 +24,11 @@ Rectangle { anchors.centerIn: parent radius: 50 visible: false - color: Colors.bluegrey25 + color: Colors.bluegrey50 signal recordModification() signal deleteCostume() signal duplicateCostume() + signal emprunterCostume() MouseArea { width: parent.width + 100 @@ -45,7 +55,17 @@ Rectangle { anchors.left: parent.left anchors.top: parent.top anchors.margins: 16 - onClicked: demoDetail.editMode = !demoDetail.editMode + onClicked: { + if (!demoDetail.editMode){ + demoDetail.type = costumeSelected.type + demoDetail.genre = costumeSelected.genre + demoDetail.couleur = costumeSelected.couleur + demoDetail.etat = costumeSelected.etat + demoDetail.taille = costumeSelected.taille + demoDetail.description = costumeSelected.description + } + demoDetail.editMode = !demoDetail.editMode + } } Button { @@ -70,6 +90,17 @@ Rectangle { } } + Button { + id: emprunterButton + text: "Emprunter" + anchors.left: duplicateButton.right + anchors.top: parent.top + anchors.margins: 16 + onClicked: { + demoDetail.emprunterCostume() + } + } + Button { text: demoDetail.editMode ? "Sauvegarder" : "Fermer" anchors.right: parent.right @@ -77,8 +108,14 @@ Rectangle { anchors.margins: 16 onClicked: { if (demoDetail.editMode){ - demoDetail.editMode = !demoDetail.editMode + costumeSelected.type = demoDetail.type + costumeSelected.genre = demoDetail.genre + costumeSelected.couleur = demoDetail.couleur + costumeSelected.etat = demoDetail.etat + costumeSelected.taille = demoDetail.taille + costumeSelected.description = demoDetail.description demoDetail.recordModification() + demoDetail.editMode = !demoDetail.editMode } else { parent.visible = false @@ -129,13 +166,13 @@ Rectangle { Layout.preferredHeight: 64 visible: demoDetail.editMode model: filter.type - onCurrentIndexChanged: { - console.log("onCurrentIndexChanged " + filter.type[currentIndex]) - costumeSelected.type = filter.type[currentIndex] - } + // onCurrentIndexChanged: { + // console.log("onCurrentIndexChanged " + filter.type[currentIndex]) + // type = filter.type[currentIndex] + // } onActivated: { - console.log("onActivated " + filter.type[currentIndex]) - costumeSelected.type = filter.type[currentIndex] + demoDetail.type = filter.type[currentIndex] + console.log("onActivated " + demoDetail.type) } onVisibleChanged: { currentIndex = indexOfValue(costumeSelected.type) @@ -153,12 +190,12 @@ Rectangle { } TextArea { id: descriptionInput - text: costumeSelected.description ? costumeSelected.description : "" + text: description Layout.fillWidth: true Layout.preferredHeight: 64 visible: demoDetail.editMode onTextChanged: { - costumeSelected.description = text + description = text } } } @@ -179,12 +216,12 @@ Rectangle { Layout.preferredHeight: 64 visible: demoDetail.editMode model: filter.genre - onCurrentIndexChanged: { - costumeSelected.genre = filter.genre[currentIndex] - } + // onCurrentIndexChanged: { + // costumeSelected.genre = filter.genre[currentIndex] + // } onActivated: { - console.log("onActivated " + filter.genre[currentIndex]) - costumeSelected.genre = filter.genre[currentIndex] + genre = filter.genre[currentIndex] + console.log("onActivated " + genre) } onVisibleChanged: { currentIndex = indexOfValue(costumeSelected.genre) @@ -248,12 +285,12 @@ Rectangle { Layout.preferredHeight: 64 visible: demoDetail.editMode model: filter.couleur - onCurrentIndexChanged: { - costumeSelected.couleur = filter.couleur[currentIndex] - } + // onCurrentIndexChanged: { + // costumeSelected.couleur = filter.couleur[currentIndex] + // } onActivated: { - console.log("onActivated " + filter.couleur[currentIndex]) - costumeSelected.couleur = filter.couleur[currentIndex] + couleur = filter.couleur[currentIndex] + console.log("onActivated " + couleur) } onVisibleChanged: { currentIndex = indexOfValue(costumeSelected.couleur) @@ -277,12 +314,12 @@ Rectangle { Layout.preferredHeight: 64 visible: demoDetail.editMode model: filter.taille - onCurrentIndexChanged: { - costumeSelected.taille = filter.taille[currentIndex] - } + // onCurrentIndexChanged: { + // costumeSelected.taille = filter.taille[currentIndex] + // } onActivated: { - console.log("onActivated " + filter.taille[currentIndex]) - costumeSelected.taille = filter.taille[currentIndex] + taille = filter.taille[currentIndex] + console.log("onActivated " + taille) } onVisibleChanged: { currentIndex = indexOfValue(costumeSelected.taille) @@ -306,12 +343,12 @@ Rectangle { Layout.preferredHeight: 64 visible: demoDetail.editMode model: filter.etat - onCurrentIndexChanged: { - costumeSelected.etat = filter.etat[currentIndex] - } + // onCurrentIndexChanged: { + // costumeSelected.etat = filter.etat[currentIndex] + // } onActivated: { - console.log("onActivated " + filter.etat[currentIndex]) - costumeSelected.etat = filter.etat[currentIndex] + etat = filter.etat[currentIndex] + console.log("onActivated " + etat) } onVisibleChanged: { currentIndex = indexOfValue(costumeSelected.etat) @@ -319,24 +356,34 @@ Rectangle { } } + // RowLayout { + // Text { + // Layout.fillWidth: true + // Layout.preferredHeight: 64 + // text: !demoDetail.editMode ? "Emplacement: " + costumeSelected.emplacement : "Emplacement: " + // font: Fonts.body1 + // wrapMode: Text.WordWrap + // } + // TextField { + // id: placementInput + // text: costumeSelected.emplacement ? costumeSelected.emplacement : "" + // Layout.fillWidth: true + // Layout.preferredHeight: 64 + // visible: demoDetail.editMode + // onTextChanged: { + // costumeSelected.emplacement = text + // } + // } + // } + RowLayout { Text { Layout.fillWidth: true Layout.preferredHeight: 64 - text: !demoDetail.editMode ? "Emplacement: " + costumeSelected.emplacement : "Emplacement: " + text: costumeSelected.emprunteur ? "Emprunteur: " + costumeSelected.emprunteur : "Disponible à l'emprunt" font: Fonts.body1 wrapMode: Text.WordWrap } - TextField { - id: placementInput - text: costumeSelected.emplacement ? costumeSelected.emplacement : "" - Layout.fillWidth: true - Layout.preferredHeight: 64 - visible: demoDetail.editMode - onTextChanged: { - costumeSelected.emplacement = text - } - } } } } diff --git a/EmpruntMenu.qml b/EmpruntMenu.qml new file mode 100644 index 0000000..d76582d --- /dev/null +++ b/EmpruntMenu.qml @@ -0,0 +1,229 @@ +import QtQuick 6.0 +import QtQuick.Controls 6.0 +import QtQuick.Layouts + +import Theme.QUANTUM 1.0 +import Gestionnaire_dressing 1.0 + +Rectangle { + id: empruntMenu + property string jourEmprunt: "" + property string moisEmprunt: "" + property string anneeEmprunt: "" + property string jourRetour: "" + property string moisRetour: "" + property string anneeRetour: "" + property string emprunteur: "" + property var costumeSelected: ({}) + property bool editMode: false + property var aderents: ({}) + width: parent.width - 400 + height: parent.height - 400 + anchors.centerIn: parent + radius: 50 + visible: false + color: Colors.bluegrey100 + signal recordModification() + signal deleteCostume() + signal duplicateCostume() + signal emprunterCostume() + + MouseArea { + width: parent.width + 400 + height: parent.height + 400 + anchors.centerIn: parent + propagateComposedEvents: false + hoverEnabled: true + preventStealing: true + onClicked: { + // parent.visible = false + } + z: empruntMenu.z-1 + } + + Button { + id: modificationButton + text: empruntMenu.editMode ? "Annuler" : "Modifier" + anchors.left: parent.left + anchors.top: parent.top + anchors.margins: 16 + onClicked: empruntMenu.editMode = !empruntMenu.editMode + } + + Button { + text: empruntMenu.editMode ? "Sauvegarder" : "Fermer" + anchors.right: parent.right + anchors.top: parent.top + anchors.margins: 16 + onClicked: { + if (empruntMenu.editMode){ + empruntMenu.editMode = !empruntMenu.editMode + costumeSelected.emprunteur = emprunteur + if (emprunteur){ + costumeSelected.date_emprunt = jourEmprunt + "/" + moisEmprunt + "/" + anneeEmprunt + costumeSelected.date_retour = "" + } + else { + costumeSelected.date_retour = jourRetour + "/" + moisRetour + "/" + anneeRetour + costumeSelected.date_emprunt = "" + } + empruntMenu.recordModification() + } + else { + parent.visible = false + } + } + } + + ColumnLayout { + id: row + Layout.preferredHeight: parent.height + Layout.alignment: Qt.AlignVCenter + Layout.fillWidth: true + Layout.fillHeight: true + anchors.top: modificationButton.bottom + anchors.left: parent.left + anchors.margins: 60 + spacing: 12 + + Text { + Layout.fillWidth: true + text: "Identifiant: " + costumeSelected.id + font: Fonts.subtitle1 + } + + Text { + id: nameText + Layout.fillWidth: true + // Layout.preferredHeight: 64 + text: !empruntMenu.editMode ? "Emprunteur: " + costumeSelected.emprunteur : "Emprunteur: " + font: Fonts.body1 + wrapMode: Text.WordWrap + } + ComboBox { + id: nameSelected + Layout.fillWidth: true + // Layout.preferredHeight: 64 + visible: empruntMenu.editMode + model: aderents + onCurrentIndexChanged: { + console.log("onCurrentIndexChanged " + aderents[currentIndex]) + emprunteur = aderents[currentIndex] + } + onActivated: { + console.log("onActivated " + aderents[currentIndex]) + emprunteur = aderents[currentIndex] + } + onVisibleChanged: { + currentIndex = indexOfValue(emprunteur) + } + } + + Text { + id: dateEmpruntText + Layout.fillWidth: true + // Layout.preferredHeight: 64 + text: !empruntMenu.editMode ? "Date Emprunt: " + costumeSelected.date_emprunt : "Date Emprunt: " + font: Fonts.body1 + wrapMode: Text.WordWrap + } + RowLayout{ + ComboBox { + id: daySelected + Layout.fillWidth: true + // Layout.preferredHeight: 64 + visible: empruntMenu.editMode && emprunteur + model: ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", + "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31"] + onActivated: { + console.log("onActivated " + currentValue) + jourEmprunt = currentValue + } + onVisibleChanged: { + currentIndex = indexOfValue(jourEmprunt) + } + } + ComboBox { + id: monthSelected + Layout.fillWidth: true + // Layout.preferredHeight: 64 + visible: empruntMenu.editMode && emprunteur + model: ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"] + onActivated: { + console.log("onActivated " + currentValue) + moisEmprunt = currentValue + } + onVisibleChanged: { + currentIndex = indexOfValue(moisEmprunt) + } + } + ComboBox { + id: yearSelected + Layout.fillWidth: true + // Layout.preferredHeight: 64 + visible: empruntMenu.editMode && emprunteur + model: ["2024", "2025", "2026", "2027", "2028", "2029", "2030", "2031", "2032", "2033"] + onActivated: { + console.log("onActivated " + currentValue) + anneeEmprunt = currentValue + } + onVisibleChanged: { + currentIndex = indexOfValue(anneeEmprunt) + } + } + } + Text { + id: dateRetourText + Layout.fillWidth: true + // Layout.preferredHeight: 64 + text: !empruntMenu.editMode ? "Date Retour: " + costumeSelected.date_retour : "Date Retour: " + font: Fonts.body1 + wrapMode: Text.WordWrap + } + RowLayout{ + ComboBox { + id: dayReturnSelected + Layout.fillWidth: true + // Layout.preferredHeight: 64 + visible: empruntMenu.editMode && !emprunteur + model: ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", + "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31"] + onActivated: { + console.log("onActivated " + currentValue) + jourRetour = currentValue + } + onVisibleChanged: { + currentIndex = indexOfValue(jourRetour) + } + } + ComboBox { + id: monthReturnSelected + Layout.fillWidth: true + // Layout.preferredHeight: 64 + visible: empruntMenu.editMode && !emprunteur + model: ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"] + onActivated: { + console.log("onActivated " + currentValue) + moisRetour = currentValue + } + onVisibleChanged: { + currentIndex = indexOfValue(moisRetour) + } + } + ComboBox { + id: yearReturnSelected + Layout.fillWidth: true + // Layout.preferredHeight: 64 + visible: empruntMenu.editMode && !emprunteur + model: ["2024", "2025", "2026", "2027", "2028", "2029", "2030", "2031", "2032", "2033"] + onActivated: { + console.log("onActivated " + currentValue) + anneeRetour = currentValue + } + onVisibleChanged: { + currentIndex = indexOfValue(anneeRetour) + } + } + } + } +} diff --git a/Launch.bat b/Launch.bat new file mode 100644 index 0000000..e2abc14 --- /dev/null +++ b/Launch.bat @@ -0,0 +1,3 @@ +set QML_XHR_ALLOW_FILE_READ=1 +set QML_XHR_ALLOW_FILE_WRITE=1 +appGestionnaire_dressing.exe \ No newline at end of file diff --git a/SortFilterModel.qml b/SortFilterModel.qml index b312563..45565fc 100644 --- a/SortFilterModel.qml +++ b/SortFilterModel.qml @@ -98,7 +98,7 @@ DelegateModel { } ] - delegate: DemoTile { + delegate: TileCostume { id: tile onTileSelect: { demoDetail.costumeSelected = listModel.get(index) diff --git a/DemoTile.qml b/TileCostume.qml similarity index 100% rename from DemoTile.qml rename to TileCostume.qml diff --git a/dependency.bat b/dependency.bat new file mode 100644 index 0000000..9a7855d --- /dev/null +++ b/dependency.bat @@ -0,0 +1 @@ +D:\Qt\6.7.2\msvc2019_64\bin\windeployqt.exe --qmldir C:\Users\Alex\Documents\gestionnaire_dressing .\appGestionnaire_dressing.exe \ No newline at end of file diff --git a/main.cpp b/main.cpp index de8f2bf..96cd206 100644 --- a/main.cpp +++ b/main.cpp @@ -14,7 +14,7 @@ int main(int argc, char *argv[]) []() { QCoreApplication::exit(-1); }, Qt::QueuedConnection); - QString customPath = "Database"; + QString customPath = "Data"; QDir dir; if(dir.mkpath(QString(customPath))){ qInfo() << "Default path >> "+engine.offlineStoragePath(); diff --git a/main.qml b/main.qml index 7c3a61b..e0e5762 100644 --- a/main.qml +++ b/main.qml @@ -11,6 +11,7 @@ AppliQuantum { title: qsTr("Gestionnaire dressing") visible: true property var filterTemplate: ({}) + property var aderentTemplate: ({}) property JSONLoader filter: JSONLoader { source: "file:Data/filter.json" @@ -26,6 +27,16 @@ AppliQuantum { } } + property JSONLoader aderents: JSONLoader { + source: "file:Data/aderents.json" + + onJsonObjectChanged: { + var aderents = jsonObject.aderents + aderentTemplate = aderents + aderentTemplateChanged() + } + } + RowLayout { anchors.fill: parent anchors.topMargin: 85 @@ -83,7 +94,7 @@ AppliQuantum { id: visualModel } - DemoDetail{ + DetailCostume{ id: demoDetail filter: root.filterTemplate onRecordModification: { @@ -102,6 +113,18 @@ AppliQuantum { demoDetail.visible = true demoDetail.editMode = true } + onEmprunterCostume: { + empruntMenu.costumeSelected = demoDetail.costumeSelected + empruntMenu.visible = true + } + } + + EmpruntMenu{ + id: empruntMenu + aderents: root.aderentTemplate + onRecordModification: { + JS.dbUpdate(costumeSelected); + } } Component.onCompleted: {