Compare commits

...

5 Commits

4 changed files with 98 additions and 18 deletions

View File

@ -184,7 +184,7 @@ Item {
ComboBox {
// TODO use model from metadata.h (in some way)
model: ["A", "B", "C", ""]
// BUG type will probably not been updated due to undo/redo step
// BUG type is not been updated due to undo/redo step
currentIndex: find(item.type)
Component.onCompleted: currentIndex = find(item.type)
onCurrentTextChanged: {

View File

@ -5,24 +5,45 @@ import QtQuick.Controls.Material
Page {
id: page
ListView {
id: listView
ColumnLayout {
anchors.fill: parent
focus: true
clip: true
model: mainModel
ListView {
id: listView
Layout.fillWidth: true
Layout.fillHeight: true
focus: true
clip: true
// delegate: ListItemDelegate {}
delegate: ExpandableItemDelegate {}
// delegate: EditableItemDelegate {}
delegateModelAccess: DelegateModel.ReadWrite
model: mainModel
header: bannercomponent
footer: Rectangle {
width: parent.width
height: 30
gradient: mainGradient
// delegate: ListItemDelegate {}
delegate: ExpandableItemDelegate {}
// delegate: EditableItemDelegate {}
delegateModelAccess: DelegateModel.ReadWrite
header: bannercomponent
footer: Rectangle {
width: parent.width
height: 30
gradient: mainGradient
}
}
Button {
Layout.fillWidth: true
text: "Undo: " + appUndoStack.undoText
enabled: appUndoStack.canUndo
onClicked: {
appUndoStack.undo()
}
}
Button {
Layout.fillWidth: true
text: "Redo: " + appUndoStack.redoText
enabled: appUndoStack.canRedo
onClicked: {
appUndoStack.redo()
}
}
}

View File

@ -1,16 +1,21 @@
import QtQuick
import QtQuick.Controls.Material
import QtQuick.Layouts
import QtQml.Models
Window {
id: window
property bool discardChangesOnExit: false
property bool isDataModified: !appUndoStack.isClean
property string titleClean: `${Application.name}`
property string titleDirty: `${Application.name}` + " *"
width: 480
height: 800
visible: true
title: `${Application.name}`
title: appUndoStack.clean ? titleClean : titleDirty
property int fontSize: 16
property color textColor: "black"
property color wccDarkDark: "#010101"
@ -29,4 +34,55 @@ Window {
id: listPage
anchors.fill: parent
}
// Component.onCompleted: {
// // core.displayStatusMessage.connect(displayStatusMessage)
// appUndoStack.cleanChanged.connect(cleanChanged)
// // core.userConfigChanged.connect(onUserConfigChanged)
// }
// function cleanChanged() {
// let clean = appUndoStack.clean
// console.debug("Clean state changed to: " + clean)
// // if (!clean) {
// // footerText.text = ""
// // }
// }
onClosing: event => {
if (appUndoStack.clean) {
console.debug("Closing on a clean undo stack.");
} else {
console.debug("Closing on an unclean undo stack!");
if (!window.discardChangesOnExit) {
event.accepted = false;
exitOnUnsavedChangesDialog.open();
}
}
}
Dialog {
id: exitOnUnsavedChangesDialog
title: "Unsaved Changes"
modal: false
anchors.centerIn: parent
width: 300
standardButtons: Dialog.Yes | Dialog.Cancel | Dialog.Discard
contentItem: Label {
text: "Do you want save your changes?\n" + "Or discard them?"
}
onAccepted: {
core.saveItems();
window.close();
}
onDiscarded: {
window.discardChangesOnExit = true;
window.close();
}
onRejected: {
console.debug("Canceling exit...");
}
}
}

View File

@ -1,8 +1,9 @@
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include <QUndoCommand>
#include <model/generalsortfiltermodel.h>
#include "model/generalsortfiltermodel.h"
#include "genericcore.h"
@ -18,6 +19,7 @@ int main(int argc, char* argv[]) {
QGuiApplication app(argc, argv);
std::unique_ptr<GenericCore> core = std::make_unique<GenericCore>();
std::shared_ptr<GeneralSortFilterModel> mainModel = core->getSortFilterModel();
QUndoStack* undoStack = core->getModelUndoStack();
// qInfo() << "QMLApp Version:" << QMLAPP_VERSION;
qInfo() << "core->getString():" << core->toString();
@ -25,6 +27,7 @@ int main(int argc, char* argv[]) {
QQmlApplicationEngine engine;
engine.rootContext()->setContextProperty(QStringLiteral("core"), core.get());
engine.rootContext()->setContextProperty(QStringLiteral("mainModel"), mainModel.get());
engine.rootContext()->setContextProperty(QStringLiteral("appUndoStack"), undoStack);
QObject::connect(
&engine, &QQmlApplicationEngine::objectCreationFailed, &app,