Compare commits

..

2 Commits

3 changed files with 60 additions and 16 deletions

View File

@ -5,24 +5,45 @@ import QtQuick.Controls.Material
Page { Page {
id: page id: page
ListView { ColumnLayout {
id: listView
anchors.fill: parent anchors.fill: parent
focus: true
clip: true
model: mainModel ListView {
id: listView
Layout.fillWidth: true
Layout.fillHeight: true
focus: true
clip: true
// delegate: ListItemDelegate {} model: mainModel
delegate: ExpandableItemDelegate {}
// delegate: EditableItemDelegate {}
delegateModelAccess: DelegateModel.ReadWrite
header: bannercomponent // delegate: ListItemDelegate {}
footer: Rectangle { delegate: ExpandableItemDelegate {}
width: parent.width // delegate: EditableItemDelegate {}
height: 30 delegateModelAccess: DelegateModel.ReadWrite
gradient: mainGradient
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,13 +1,19 @@
import QtQuick import QtQuick
import QtQuick.Controls.Material
import QtQuick.Layouts import QtQuick.Layouts
import QtQml.Models import QtQml.Models
Window { Window {
property bool isDataModified: !appUndoStack.isClean
property string titleClean: `${Application.name}`
property string titleDirty: `${Application.name}` + " *"
id: window id: window
width: 480 width: 480
height: 800 height: 800
visible: true visible: true
title: `${Application.name}` title: appUndoStack.clean ? titleClean : titleDirty
property int fontSize: 16 property int fontSize: 16
@ -29,4 +35,18 @@ Window {
id: listPage id: listPage
anchors.fill: parent 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 = ""
// }
}
} }

View File

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