Compare commits
3 Commits
609f777d13
...
3e3aae63ae
| Author | SHA1 | Date | |
|---|---|---|---|
| 3e3aae63ae | |||
| d08325cc3c | |||
| e76fdaae9f |
@ -11,6 +11,7 @@ Item {
|
|||||||
required property string info
|
required property string info
|
||||||
required property int amount
|
required property int amount
|
||||||
required property real factor
|
required property real factor
|
||||||
|
required property string type
|
||||||
|
|
||||||
property real detailsOpacity: 0
|
property real detailsOpacity: 0
|
||||||
width: ListView.view.width
|
width: ListView.view.width
|
||||||
@ -66,7 +67,7 @@ Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
text: qsTr("Details")
|
text: qsTr("Description")
|
||||||
font.bold: true
|
font.bold: true
|
||||||
font.pointSize: 9
|
font.pointSize: 9
|
||||||
opacity: item.detailsOpacity
|
opacity: item.detailsOpacity
|
||||||
@ -108,6 +109,7 @@ Item {
|
|||||||
anchors {
|
anchors {
|
||||||
top: moreInfoTitle.bottom
|
top: moreInfoTitle.bottom
|
||||||
bottom: parent.bottom
|
bottom: parent.bottom
|
||||||
|
topMargin: 5
|
||||||
}
|
}
|
||||||
contentHeight: infoText.height
|
contentHeight: infoText.height
|
||||||
clip: true
|
clip: true
|
||||||
@ -119,11 +121,18 @@ Item {
|
|||||||
wrapMode: Text.WordWrap
|
wrapMode: Text.WordWrap
|
||||||
width: details.width
|
width: details.width
|
||||||
}
|
}
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
id: amountText
|
id: amountText
|
||||||
text: "Amount: " + item.amount
|
text: "Amount: " + item.amount
|
||||||
wrapMode: Text.WordWrap
|
wrapMode: Text.WordWrap
|
||||||
width: details.width
|
}
|
||||||
|
|
||||||
|
SpinBox {
|
||||||
|
value: item.amount
|
||||||
|
width: 80
|
||||||
|
height: 25
|
||||||
|
onValueModified: item.amount = value
|
||||||
}
|
}
|
||||||
Text {
|
Text {
|
||||||
id: factorText
|
id: factorText
|
||||||
@ -131,6 +140,59 @@ Item {
|
|||||||
wrapMode: Text.WordWrap
|
wrapMode: Text.WordWrap
|
||||||
width: details.width
|
width: details.width
|
||||||
}
|
}
|
||||||
|
SpinBox {
|
||||||
|
id: spinBox
|
||||||
|
from: 0
|
||||||
|
value: decimalToInt(item.factor)
|
||||||
|
to: decimalToInt(100)
|
||||||
|
stepSize: decimalFactor
|
||||||
|
editable: true
|
||||||
|
|
||||||
|
property int decimals: 2
|
||||||
|
property real realValue: value / decimalFactor
|
||||||
|
readonly property int decimalFactor: Math.pow(10, decimals)
|
||||||
|
|
||||||
|
function decimalToInt(decimal) {
|
||||||
|
return decimal * decimalFactor
|
||||||
|
}
|
||||||
|
|
||||||
|
onValueModified: item.factor = value / decimalFactor
|
||||||
|
|
||||||
|
validator: DoubleValidator {
|
||||||
|
bottom: Math.min(spinBox.from, spinBox.to)
|
||||||
|
top: Math.max(spinBox.from, spinBox.to)
|
||||||
|
decimals: spinBox.decimals
|
||||||
|
notation: DoubleValidator.StandardNotation
|
||||||
|
}
|
||||||
|
|
||||||
|
textFromValue: function (value, locale) {
|
||||||
|
return Number(value / decimalFactor).toLocaleString(
|
||||||
|
locale, 'f', spinBox.decimals)
|
||||||
|
}
|
||||||
|
|
||||||
|
valueFromText: function (text, locale) {
|
||||||
|
return Math.round(Number.fromLocaleString(
|
||||||
|
locale, text) * decimalFactor)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Text {
|
||||||
|
id: typeText
|
||||||
|
text: "Type: " + item.type
|
||||||
|
wrapMode: Text.WordWrap
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
currentIndex: find(item.type)
|
||||||
|
Component.onCompleted: currentIndex = find(item.type)
|
||||||
|
onCurrentTextChanged: {
|
||||||
|
item.type = currentText
|
||||||
|
}
|
||||||
|
width: 80
|
||||||
|
height: 25
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
29
ListPage.qml
29
ListPage.qml
@ -5,18 +5,22 @@ import QtQuick.Controls.Material
|
|||||||
Page {
|
Page {
|
||||||
id: page
|
id: page
|
||||||
|
|
||||||
|
ColumnLayout {
|
||||||
|
anchors.fill: parent
|
||||||
|
|
||||||
ListView {
|
ListView {
|
||||||
id: listView
|
id: listView
|
||||||
anchors.fill: parent
|
Layout.fillWidth: true
|
||||||
|
Layout.fillHeight: true
|
||||||
focus: true
|
focus: true
|
||||||
clip: true
|
clip: true
|
||||||
|
|
||||||
model: mainModel
|
model: mainModel
|
||||||
delegateModelAccess: DelegateModel.ReadWrite
|
|
||||||
|
|
||||||
// delegate: ListItemDelegate {}
|
// delegate: ListItemDelegate {}
|
||||||
// delegate: ExpandableItemDelegate {}
|
delegate: ExpandableItemDelegate {}
|
||||||
delegate: EditableItemDelegate {}
|
// delegate: EditableItemDelegate {}
|
||||||
|
delegateModelAccess: DelegateModel.ReadWrite
|
||||||
|
|
||||||
header: bannercomponent
|
header: bannercomponent
|
||||||
footer: Rectangle {
|
footer: Rectangle {
|
||||||
@ -25,6 +29,23 @@ Page {
|
|||||||
gradient: mainGradient
|
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()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Component {
|
Component {
|
||||||
//instantiated when header is processed
|
//instantiated when header is processed
|
||||||
|
|||||||
22
Main.qml
22
Main.qml
@ -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 = ""
|
||||||
|
// }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
5
main.cpp
5
main.cpp
@ -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,
|
||||||
|
|||||||
Reference in New Issue
Block a user