diff --git a/src/activities/server/components/RemovePupilsDialog.qml b/src/activities/server/components/RemovePupilsDialog.qml new file mode 100644 index 000000000..bfcd546c7 --- /dev/null +++ b/src/activities/server/components/RemovePupilsDialog.qml @@ -0,0 +1,115 @@ +import QtQuick 2.6 +import "../../../core" +import QtQuick.Controls 2.12 +import QtQuick.Layouts 1.12 +import "../server.js" as Activity + +Popup { + id: removePupilsDialog + + signal pupilsToBeRemoved() + + anchors.centerIn: Overlay.overlay + width: 600 + height: 600 + modal: true + focus: true + closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent + + onOpened: { + pupilsNamesText.text = "test" + print("uuuu") + print(pupilsDetailsRepeater.itemAt(2).pupilDetailsRectangleMouseArea.pupilName.pupilNameCheckBox.text) + + } + + + ColumnLayout { + height: parent.height + + width: parent.width + + Rectangle { + id: removePupilsTextRectangle + + Layout.preferredWidth: parent.width + Layout.alignment: Qt.AlignCenter + Layout.minimumHeight: 40 + Layout.preferredHeight: 40 + Text { + id: deletePupilGroupsText + anchors.centerIn: parent + text: qsTr("Are you sure you want to remove the following children from the server?") + font.bold: true + color: Style.colourNavigationBarBackground + font { + family: Style.fontAwesome + pixelSize: 15 + } + } + } + + Rectangle { + id: pupilsNamesTextRectangle + + Layout.preferredWidth: parent.width + Layout.alignment: Qt.AlignCenter + Layout.minimumHeight: 80 + Layout.preferredHeight: 100 + Text { + id: pupilsNamesText + anchors.centerIn: parent + //text: qsTr("Format:\nPatrick Dummy;2003\nPatricia Brown;2004\nor\nPatrick Dummy;2003;2nd grade-music-sport\nPatricia Brown;2004;2nd grade-music-art") + font.bold: true + color: "grey" + font { + family: Style.fontAwesome + pixelSize: 12 + } + } + + } + + + + Rectangle { + id: okCancelRectangle + + Layout.preferredWidth: parent.width + Layout.alignment: Qt.AlignCenter + Layout.minimumHeight: saveButton.height + Layout.preferredHeight: Layout.minimumHeight + + ViewButton { + id: saveButton + + anchors.right: parent.right + anchors.bottom: parent.bottom + text: qsTr("Ok") + onClicked: { + + // var lines = edit.text.split('\n') + + Activity.addPupilsNamesFromList(edit.text) + + //console.log("---- " + lines) + removePupilsDialog.pupilsToBeRemoved() + } + + } + + ViewButton { + id: cancelButton + + anchors.right: saveButton.left + anchors.bottom: parent.bottom + text: qsTr("Cancel") + + onClicked: { + console.log("cancel...") + removePupilsDialog.close(); + } + } + } + } +} diff --git a/src/activities/server/components/WarningDialog.qml b/src/activities/server/components/WarningDialog.qml new file mode 100644 index 000000000..0aa7d673a --- /dev/null +++ b/src/activities/server/components/WarningDialog.qml @@ -0,0 +1,59 @@ +import QtQuick 2.6 +import "../../../core" +import QtQuick.Controls 2.12 +import "../server.js" as Activity + +Popup { + id: warningDialog + + property string label: "To be modified in calling element." + property string additionalInformations: "Additional informations." + property bool textInputReadOnly: false + + anchors.centerIn: Overlay.overlay + width: 600 + height: 200 + modal: true + focus: true + closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent + + Text { + id: labelText + + x: parent.width / 10 + y: parent.height / 8 + text: label + font.bold: true + font { + family: Style.fontAwesome + pixelSize: 20 + } + } + + Text { + id: additionalInformationsText + + x: parent.width / 10 + y: parent.height / 3 + text: additionalInformations + font.bold: true + font { + family: Style.fontAwesome + pixelSize: 20 + } + } + + + ViewButton { + id: okButton + + anchors.right: parent.right + anchors.bottom: parent.bottom + text: qsTr("Ok") + onClicked: { + console.log("---- " + addModifyGroupNameTextInput.text) + warningDialog.close() + } + + } +} diff --git a/src/activities/server/server.js b/src/activities/server/server.js index c7f811dea..1ec3c8b63 100644 --- a/src/activities/server/server.js +++ b/src/activities/server/server.js @@ -1,160 +1,157 @@ /* GCompris - server.js * * Copyright (C) 2018 YOUR NAME * * Authors: * (GTK+ version) * "YOUR NAME" (Qt Quick port) * * 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 . */ .pragma library .import QtQuick 2.6 as Quick var currentLevel = 0 var numberOfLevel = 4 var items var dataArray = [{"color":"red"},{"color":"blue"},{"color":"yellow"}] var groupsNamesArray = [] var debugString = "Aurélien2 Richelieu;2004;CP-CE1-CE2-Judo-Théâtre\nNadia Comtois;2003;CP-CE1-CE2-Judo-Théâtre-Maison\nRaphaël Thibault;2003;CP-CE1-CE2\nAnastasie Firmin;2001;CP-CE1-CE2\nArianne Vincent;2001;CE2-Judo-Théâtre\nMarlène Porcher;2001;CP-CE1-CE2-Théâtre\nGervais Plourde;2001;CP-CE2-Judo-Théâtre\nMadeline François;2002;CP-CE1-CE2-Théâtre\nSolange Géroux;2003;CP-CE2-Judo-Théâtre-volley\nAxel Deniau;2002;CP-CE2-Judo-Théâtre" groupsNamesArray = ["CP","CE1","CE2","Judo","Théâtre"] groupsNamesArray.push("Chant") var pupilsNamesArray = [] // [["Aurélien Richelieu","2004",["CP","CE1","CE2","Judo","Théâtre"]], // ["Nadia Comtois","2003",["CP","CE1","CE2","Judo","Théâtre"]], // ["Raphaël Thibault","2003",["CP","CE1","CE2"]], // ["Anastasie Firmin","2001",["CP","CE1","CE2"]], // ["Arianne Vincent","2001",["CE2","Judo","Théâtre"]], // ["Marlène Porcher","2001",["CP","CE1","CE2","Théâtre"]], // ["Gervais Plourde","2001",["CP","CE2","Judo","Théâtre"]], // ["Madeline François","2002",["CP","CE1","CE2","Théâtre","maison"]], // ["Solange Géroux","2003",["CP","CE2","Judo","Théâtre"]], // ["Axel Deniau","2002",["CP","CE2","Judo","Théâtre"]]] - - - function addPupilsNamesFromList(pupilsDetailsStr) { var addedPupilsNamesArray = [] var pupilDetailsLineArray = pupilsDetailsStr.split("\n") var lineIndex = 0 for (const pupilDetailsLine of pupilDetailsLineArray) { //console.log(pupilDetails) lineIndex++ var pupilDetails = pupilDetailsLine.split(";") var groupsNames = [] var reformatedPupilDetailsArray = [] var groupsArray = pupilDetails[2].split("-") //check if all the groups exist for (const group of groupsArray) { if (groupsNamesArray.indexOf(group) === -1) { console.log("Failed to add unexisting group. Line " + lineIndex + " " + group) } } reformatedPupilDetailsArray.push(pupilDetails[0].toString()) reformatedPupilDetailsArray.push(pupilDetails[1].toString()) - reformatedPupilDetailsArray.push(groupsArray) + reformatedPupilDetailsArray.push(pupilDetails[2].toString()) addedPupilsNamesArray.push(reformatedPupilDetailsArray) console.log(JSON.stringify(reformatedPupilDetailsArray)) } if (pupilsNamesArray.length === 0) { console.log("dummy") pupilsNamesArray = addedPupilsNamesArray } else { pupilsNamesArray = pupilsNamesArray.concat(addedPupilsNamesArray) } console.log("-----------------------------------------------------------") console.log(JSON.stringify(pupilsNamesArray)) console.log("-----------------------------------------------------------") console.log(JSON.stringify(pupilsNamesArray[0])) } function start(items_) { items = items_ currentLevel = 0 initLevel() } function stop() { } function initLevel() { items.bar.level = currentLevel + 1 } function nextLevel() { if(numberOfLevel <= ++currentLevel) { currentLevel = 0 } initLevel(); } function previousLevel() { if(--currentLevel < 0) { currentLevel = numberOfLevel - 1 } initLevel(); } function savePupilNameGroups(pupilIndex) { } function setModifyPupilGroupDialogCheckboxes(pupilIndex) { groupsNamesArray.forEach((groupName) => { console.log(groupName) }) var test = [] test = items.groupNamesListView.contentItem print(test) } diff --git a/src/activities/server/views/ManagePupilsView.qml b/src/activities/server/views/ManagePupilsView.qml index 34d576b97..66067f495 100644 --- a/src/activities/server/views/ManagePupilsView.qml +++ b/src/activities/server/views/ManagePupilsView.qml @@ -1,533 +1,548 @@ import QtQuick 2.12 import QtQuick.Layouts 1.12 import QtQml.Models 2.12 import CM 1.0 import "../components" import "../../../core" import QtQuick.Controls 2.2 import "." import "../server.js" as Activity Item { id: managePupilsView //width: activity.width // property Client newClient: masterController.ui_newClient + property alias pupilsDetailsRepeater: pupilsDetailsRepeater + Connections { target: masterController.ui_navigationController onGoAddPupilsFromListDialog: addPupilsFromListDialog.open() + onGoRemovePupilsDialog: removePupilsDialog.open() } + ListView { + id: selectedPupilsListview + } + Rectangle { anchors.fill: parent color: Style.colourBackground Text { anchors.centerIn: parent text: "Manage Pupils View" } } TopBanner { id: topBanner text: "Groups and pupils management" } ManageGroupsBar { id: pupilsNavigationBar anchors.top: topBanner.bottom } Rectangle { id: managePupilsViewRectangle anchors.left: pupilsNavigationBar.right anchors.top: topBanner.bottom anchors.right: parent.right anchors.bottom: parent.bottom width: managePupilsView.width - pupilsNavigationBar.width //color: "red" ColumnLayout{ id: pupilsDetailsColumn spacing: 2 anchors.top: parent.top width: parent.width property int pupilNameColWidth : pupilsDetailsColumn.width/3 property int yearOfBirthColWidth : pupilsDetailsColumn.width/8 //pupils header Rectangle { id: pupilsHeaderRectangle height: 60 width: parent.width RowLayout { width: managePupilsViewRectangle.width - 10 height: parent.height Rectangle { id: pupilNameHeader Layout.fillHeight: true Layout.minimumWidth: pupilsDetailsColumn.pupilNameColWidth Text { anchors.verticalCenter: parent.verticalCenter color: Style.colourNavigationBarBackground text: "Pupils Names" font.bold: true leftPadding: 60 topPadding: 20 } } Rectangle { id: yearOfBirthHeader Layout.fillHeight: true Layout.minimumWidth: pupilsDetailsColumn.yearOfBirthColWidth //any way to find "year of birth text width" if translations ? Text { anchors.verticalCenter: parent.verticalCenter anchors.horizontalCenter: parent.horizontalCenter text: "Year of Birth" font.bold: true color: Style.colourNavigationBarBackground topPadding: 20 } } Rectangle { Layout.fillWidth: true Layout.fillHeight: true Text { anchors.verticalCenter: parent.verticalCenter anchors.left: parent.left leftPadding: 10 text: "Groups" font.bold: true color: Style.colourNavigationBarBackground topPadding: 20 } } } } //pupils data Repeater { id: pupilsDetailsRepeater - model: Activity.pupilsNamesArray - + model: Activity.pupilsNamesArray Rectangle { id: pupilDetailsRectangle + //property alias pupilNameCheckBox: pupilDetailsRectangle.pupilDetailsRectangleMouseArea.pupilDetailsRectangleRowLayout.pupilName.pupilNameCheckBox + property bool editPupilRectangleVisible: false property bool optionsPupilRectangleVisible: false width: managePupilsViewRectangle.width height: 40 border.color: "green" border.width: 5 MouseArea { + id: pupilDetailsRectangleMouseArea anchors.right: pupilDetailsRectangle.right //right: pupilCommandOptions.right anchors.top: pupilDetailsRectangle.top height: pupilDetailsRectangle.height width: parent.width hoverEnabled: true onEntered: { //modifyPupilCommandsRectangle.visible = true pupilDetailsRectangle.color = Style.colourPanelBackgroundHover pupilDetailsRectangle.editPupilRectangleVisible = true pupilDetailsRectangle.optionsPupilRectangleVisible = true } onExited: { ///modifyPupilCommandsRectangle.visible = false pupilDetailsRectangle.color = Style.colourBackground pupilDetailsRectangle.editPupilRectangleVisible = false pupilDetailsRectangle.optionsPupilRectangleVisible = false } RowLayout { id: pupilDetailsRectangleRowLayout width: parent.width height: 40 Rectangle { id: pupilName Layout.alignment: Qt.AlignLeft Layout.fillHeight: true Layout.minimumWidth: pupilsDetailsColumn.pupilNameColWidth color: "transparent" CheckBox { + id: pupilNameCheckBox text: modelData[0] anchors.verticalCenter: parent.verticalCenter leftPadding: 20 + + } } Rectangle { id: yearOfBirth Layout.fillHeight: true Layout.minimumWidth: pupilsDetailsColumn.yearOfBirthColWidth //any way to find "year of birth text width" if translations ? color: "transparent" Text { id: yearText text: modelData[1] anchors.verticalCenter: parent.verticalCenter anchors.horizontalCenter: parent.horizontalCenter color: "grey" } } Rectangle { id: groups Layout.fillWidth: true Layout.fillHeight: true height: 40 color: "transparent" Text { id: groupsText - text: "yy" //modelData[2] + text: modelData[2] leftPadding: 10 anchors.verticalCenter: parent.verticalCenter color: "grey" } } Rectangle { id: editPupilRectangle Layout.minimumWidth: 50 //Layout.alignment: Qt.AlignRight Layout.fillHeight: true height: 40 visible: pupilDetailsRectangle.editPupilRectangleVisible color: "transparent" Text { id: editIcon text: "\uf304" anchors.centerIn: parent color: "grey" font { family: Style.fontAwesome pixelSize: Style.pixelSizeNavigationBarIcon / 2 } } MouseArea { anchors.left: parent.left anchors.top: parent.top height: parent.height width: parent.width //anchors.fill: parent hoverEnabled: true onEntered: { //modifyPupilCommandsRectangle.visible = true editIcon.color = Style.colourNavigationBarBackground //Style.colourPanelBackgroundHover //pupilDetailsRectangle.editPupilRectangleVisible = true //pupilDetailsRectangle.optionsPupilRectangleVisible = true print("sdfsfsdf") } onExited: { ///modifyPupilCommandsRectangle.visible = false editIcon.color = Style.colourCommandBarFontDisabled //Style.colourBackground //pupilDetailsRectangle.editPupilRectangleVisible = false //pupilDetailsRectangle.optionsPupilRectangleVisible = false } } } Rectangle { id: optionsPupilRectangle Layout.minimumWidth: 50 Layout.alignment: Qt.AlignRight Layout.fillHeight: true height: 40 visible: pupilDetailsRectangle.optionsPupilRectangleVisible color: "transparent" Text { id: optionsIcon text: "\uf142" //elipsis-v anchors.horizontalCenter: parent.horizontalCenter anchors.verticalCenter: parent.verticalCenter color: "grey" font { family: Style.fontAwesome pixelSize: Style.pixelSizeNavigationBarIcon / 2 //? see with style } } MouseArea { anchors.left: parent.left anchors.top: parent.top height: parent.height width: parent.width hoverEnabled: true onClicked: { modifyPupilGroupsDialog.open() } onEntered: { //modifyPupilCommandsRectangle.visible = true optionsIcon.color = Style.colourNavigationBarBackground //Style.colourPanelBackgroundHover //pupilDetailsRectangle.editPupilRectangleVisible = true //pupilDetailsRectangle.optionsPupilRectangleVisible = true print("sdfsfsdf") } onExited: { ///modifyPupilCommandsRectangle.visible = false optionsIcon.color = Style.colourCommandBarFontDisabled //Style.colourBackground //pupilDetailsRectangle.editPupilRectangleVisible = false //pupilDetailsRectangle.optionsPupilRectangleVisible = false } } } } } ModifyPupilGroupsDialog { id: modifyPupilGroupsDialog } // Rectangle { // id: pupilCommandOptions // Layout.minimumWidth: 50 // Layout.fillHeight: true // Layout.alignment: Qt.AlignRight // height: 40 // color: "transparent" // Text { // id: elipsisText // text: "\uf142" //elipsis-v // anchors.horizontalCenter: parent.horizontalCenter // anchors.verticalCenter: parent.verticalCenter // color: "grey" // font { // family: Style.fontAwesome // pixelSize: Style.pixelSizeNavigationBarIcon / 2 //? see with style // } // } // MouseArea { // anchors.right: pupilCommandOptions.right // anchors.top: pupilCommandOptions.top // height: pupilCommandOptions.height // width: pupilCommandOptions.width // //anchors.fill: parent // hoverEnabled: true // onEntered: { modifyPupilCommandsRectangle.visible = true // pupilCommandOptions.color = Style.colourPanelBackgroundHover // } // onExited: { // modifyPupilCommandsRectangle.visible = false // pupilCommandOptions.color = Style.colourBackground // } // Rectangle { // id: modifyPupilCommandsRectangle // anchors.right: parent.right // visible: false // height: parent.height // width: 100 // color: "transparent" // border.width: 3 // border.color: "red" // Row { // id: pupilDetailsRow // width: parent.width // height: parent.height // Rectangle { // id: editIconRectangle // width: parent.width/2 // height: parent.height // color: "transparent" // border.color: "red" // border.width: 3 // Text { // id: editIcon // text: "\uf304" // anchors.centerIn: parent // color: "grey" // font { // family: Style.fontAwesome // pixelSize: Style.pixelSizeNavigationBarIcon / 2 // } // } // MouseArea { // anchors.fill: parent // hoverEnabled: true // onClicked: { // modifyPupilDialog.inputText = modelData[0] // console.log("--" + index) // modifyPupilDialog.pupilDetailsIndex = index // modifyPupilDialog.open() // console.log("clicked ...") // } // onEntered: { editIcon.color = Style.colourNavigationBarBackground } // onExited: { editIcon.color = Style.colourCommandBarFontDisabled } // } // } // Rectangle { // width: parent.width/2 // height: parent.height // color: "transparent" // Text { // id: trashIcon // text: "\uf2ed" // anchors.centerIn: parent // color: "grey" // font { // family: Style.fontAwesome // pixelSize: Style.pixelSizeNavigationBarIcon / 2 // } // } // MouseArea { // anchors.fill: parent // hoverEnabled: true // onClicked: { // addAGroupText.color = Style.colourNavigationBarBackground // removeGroupDialog.pupilDetailsIndex = index // removeGroupDialog.open() // console.log("clicked ...") // } // onEntered: { trashIcon.color = Style.colourNavigationBarBackground } // onExited: { trashIcon.color = Style.colourCommandBarFontDisabled } // } // } // } // } // AddModifyGroupDialog { // id: modifyPupilDialog // property int pupilDetailsIndex // label: "Modify Pupil Details" // inputText: "testdefault" // onAccepted: { // console.log("save.dfg..") // console.log(textInputValue) // Activity.pupilsNamesArray[pupilDetailsIndex][0] = textInputValue // Activity.pupilsNamesArray[pupilDetailsIndex][1] = "2004" // console.log(Activity.pupilsNamesArray) // pupilsDetailsRepeater.model = Activity.pupilsNamesArray // modifyPupilDialog.close() // } // } // AddModifyGroupDialog { // id: removeGroupDialog // property int groupNameIndex // label: qsTr("Are you sure you want to remove the group") // inputText: Activity.groupsNamesArray[groupNameIndex] // textInputReadOnly: true // onAccepted: { // console.log("save.dfg..") // console.log(textInputValue) // Activity.groupsNamesArray[groupNameIndex][0] = textInputValue // Activity.groupsNamesArray[groupNameIndex][1] = "2004" // console.log(Activity.groupsNamesArray) // pupilsDetailsRepeater.model = Activity.pupilsNamesArray // modifyGroupDialog.close() // } // } // } // } } } } } CommandBar { commandList: masterController.ui_commandController.ui_managePupilsViewContextCommands } AddPupilsFromListDialog { id: addPupilsFromListDialog onPupilsDetailsAdded: pupilsDetailsRepeater.model = Activity.pupilsNamesArray } + RemovePupilsDialog { + id: removePupilsDialog + } /* ScrollView { id: scrollView anchors { left: parent.left right: parent.right top: parent.top //bottom: commandBar.top margins: Style.sizeScreenMargin } clip: true Column { spacing: Style.sizeScreenMargin width: scrollView.width Panel { headerText: "Client Details" contentComponent: Column { spacing: Style.sizeControlSpacing StringEditorSingleLine { stringDecorator: newClient.ui_reference anchors { left: parent.left right: parent.right } } StringEditorSingleLine { stringDecorator: newClient.ui_name anchors { left: parent.left right: parent.right } } } } AddressEditor { address: newClient.ui_supplyAddress headerText: "Supply Address" } AddressEditor { address: newClient.ui_billingAddress headerText: "Billing Address" } } } */ } diff --git a/src/core/serverMasterController/controllers/command-controller.cpp b/src/core/serverMasterController/controllers/command-controller.cpp index b7c4f5823..1043891f0 100644 --- a/src/core/serverMasterController/controllers/command-controller.cpp +++ b/src/core/serverMasterController/controllers/command-controller.cpp @@ -1,201 +1,202 @@ #include "command-controller.h" #include #include using namespace cm::framework; using namespace cm::models; namespace cm { namespace controllers { class CommandController::Implementation { public: Implementation(CommandController* _commandController, IDatabaseController* _databaseController, NavigationController* _navigationController, Client* _newClient, ClientSearch* _clientSearch) : commandController(_commandController) , databaseController(_databaseController) , navigationController(_navigationController) , newClient(_newClient) , clientSearch(_clientSearch) { Command* createClientSaveCommand = new Command( commandController, QChar( 0xf0c7 ), "Save" ); QObject::connect( createClientSaveCommand, &Command::executed, commandController, &CommandController::onCreateClientSaveExecuted ); createClientViewContextCommands.append( createClientSaveCommand ); Command* findClientSearchCommand = new Command( commandController, QChar( 0xf002 ), "Search" ); QObject::connect( findClientSearchCommand, &Command::executed, commandController, &CommandController::onFindClientSearchExecuted ); findClientViewContextCommands.append( findClientSearchCommand ); Command* editClientDeleteCommand = new Command( commandController, QChar( 0xf235 ), "Delete" ); QObject::connect( editClientDeleteCommand, &Command::executed, commandController, &CommandController::onEditClientDeleteExecuted ); editClientViewContextCommands.append( editClientDeleteCommand ); Command* editClientSaveCommand = new Command( commandController, QChar( 0xf0c7 ), "Save" ); QObject::connect( editClientSaveCommand, &Command::executed, commandController, &CommandController::onEditClientSaveExecuted ); editClientViewContextCommands.append( editClientSaveCommand ); Command* managePupilsAddPupilCommand = new Command( commandController, QChar( 0xf234 ), "Add Pupil" ); QObject::connect( managePupilsAddPupilCommand, &Command::executed, commandController, &CommandController::onManagePupilsAddPupilExecuted ); managePupilsViewContextCommands.append( managePupilsAddPupilCommand ); Command* managePupilsAddPupilFromListCommand = new Command( commandController, QChar( 0xf2c2 ), "Add Pupils from List" ); QObject::connect( managePupilsAddPupilFromListCommand, &Command::executed, commandController, &CommandController::onManagePupilsAddPupilsFromListExecuted ); managePupilsViewContextCommands.append( managePupilsAddPupilFromListCommand ); Command* managePupilsRemovePupilsFromListCommand = new Command( commandController, QChar( 0xf503 ), "Remove Pupil(s)" ); QObject::connect( managePupilsRemovePupilsFromListCommand, &Command::executed, commandController, &CommandController::onManagePupilsRemovePupilsExecuted ); managePupilsViewContextCommands.append( managePupilsRemovePupilsFromListCommand ); Command* managePupilsEditPupilFromListCommand = new Command( commandController, QChar( 0xf4ff ), "Edit Pupil" ); QObject::connect( managePupilsEditPupilFromListCommand, &Command::executed, commandController, &CommandController::onManagePupilsEditPupilExecuted ); managePupilsViewContextCommands.append( managePupilsEditPupilFromListCommand ); } CommandController* commandController{nullptr}; IDatabaseController* databaseController{nullptr}; NavigationController* navigationController{nullptr}; Client* newClient{nullptr}; ClientSearch* clientSearch{nullptr}; Client* selectedClient{nullptr}; QList createClientViewContextCommands{}; QList findClientViewContextCommands{}; QList editClientViewContextCommands{}; QList managePupilsViewContextCommands{}; }; CommandController::CommandController(QObject* parent, IDatabaseController* databaseController, NavigationController* navigationController, Client* newClient, ClientSearch* clientSearch) : QObject(parent) { implementation.reset(new Implementation(this, databaseController, navigationController, newClient, clientSearch)); } CommandController::~CommandController() { } QQmlListProperty CommandController::ui_createClientViewContextCommands() { return QQmlListProperty(this, implementation->createClientViewContextCommands); } QQmlListProperty CommandController::ui_findClientViewContextCommands() { return QQmlListProperty(this, implementation->findClientViewContextCommands); } QQmlListProperty CommandController::ui_editClientViewContextCommands() { return QQmlListProperty(this, implementation->editClientViewContextCommands); } QQmlListProperty CommandController::ui_managePupilsViewContextCommands() { return QQmlListProperty(this, implementation->managePupilsViewContextCommands); } void CommandController::setSelectedClient(Client* client) { implementation->selectedClient = client; } void CommandController::onCreateClientSaveExecuted() { qDebug() << "You executed the Save command!"; implementation->databaseController->createRow(implementation->newClient->key(), implementation->newClient->id(), implementation->newClient->toJson()); qDebug() << "New client saved."; implementation->clientSearch->searchText()->setValue(implementation->newClient->id()); implementation->clientSearch->search(); implementation->navigationController->goFindClientView(); } void CommandController::onFindClientSearchExecuted() { qDebug() << "You executed the Search command!"; implementation->clientSearch->search(); } void CommandController::onEditClientSaveExecuted() { qDebug() << "You executed the Save command!"; implementation->databaseController->updateRow(implementation->selectedClient->key(), implementation->selectedClient->id(), implementation->selectedClient->toJson()); qDebug() << "Updated client saved."; } void CommandController::onEditClientDeleteExecuted() { qDebug() << "You executed the Delete command!"; implementation->databaseController->deleteRow(implementation->selectedClient->key(), implementation->selectedClient->id()); implementation->selectedClient = nullptr; qDebug() << "Client deleted."; implementation->clientSearch->search(); implementation->navigationController->goAddPupilsFromListDialog(); } void CommandController::onManagePupilsAddPupilExecuted() { qDebug() << "You created a new pupil!"; /* implementation->databaseController->createRow(implementation->newClient->key(), implementation->newClient->id(), implementation->newClient->toJson()); qDebug() << "New client saved."; implementation->clientSearch->searchText()->setValue(implementation->newClient->id()); implementation->clientSearch->search(); implementation->navigationController->goFindClientView();*/ } void CommandController::onManagePupilsAddPupilsFromListExecuted() { qDebug() << "You created new pupils from list!"; implementation->navigationController->goAddPupilsFromListDialog(); /* implementation->databaseController->createRow(implementation->newClient->key(), implementation->newClient->id(), implementation->newClient->toJson()); qDebug() << "New client saved."; implementation->clientSearch->searchText()->setValue(implementation->newClient->id()); implementation->clientSearch->search(); implementation->navigationController->goFindClientView();*/ } void CommandController::onManagePupilsEditPupilExecuted() { qDebug() << "You edited a pupil!"; /* implementation->databaseController->createRow(implementation->newClient->key(), implementation->newClient->id(), implementation->newClient->toJson()); qDebug() << "New client saved."; implementation->clientSearch->searchText()->setValue(implementation->newClient->id()); implementation->clientSearch->search(); implementation->navigationController->goFindClientView();*/ } void CommandController::onManagePupilsRemovePupilsExecuted() { qDebug() << "You removed pupil(s)!"; + implementation->navigationController->goRemovePupilsDialog(); - /* implementation->databaseController->createRow(implementation->newClient->key(), implementation->newClient->id(), implementation->newClient->toJson()); + /* implementation->databaseController->createRow(implementation->newClient->key(), implementation->newClient->id(), implementation->newClient->toJson()); qDebug() << "New client saved."; implementation->clientSearch->searchText()->setValue(implementation->newClient->id()); implementation->clientSearch->search(); implementation->navigationController->goFindClientView();*/ } }} diff --git a/src/core/serverMasterController/controllers/navigation-controller.h b/src/core/serverMasterController/controllers/navigation-controller.h index 521e13346..4090e0b9c 100644 --- a/src/core/serverMasterController/controllers/navigation-controller.h +++ b/src/core/serverMasterController/controllers/navigation-controller.h @@ -1,33 +1,34 @@ #ifndef NAVIGATIONCONTROLLER_H #define NAVIGATIONCONTROLLER_H #include #include #include namespace cm { namespace controllers { class CMLIBSHARED_EXPORT NavigationController : public QObject { Q_OBJECT public: explicit NavigationController(QObject* parent = nullptr) : QObject(parent){} signals: void goManagePupilsView(); void goCreateClientView(); void goDashboardView(); void goEditClientView(cm::models::Client* client); void goFindClientView(); void goManageWorkPlanView(); void goAddPupilsFromListDialog(); + void goRemovePupilsDialog(); }; } } #endif