Compare commits
3 Commits
a39ce321f2
...
5057edb9ad
Author | SHA1 | Date | |
---|---|---|---|
5057edb9ad | |||
39909ad543 | |||
b217f2f9ad |
44
qml/HorizontalHeaderViewDelegate.qml
Normal file
44
qml/HorizontalHeaderViewDelegate.qml
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
// SPDX-FileCopyrightText: 2025 Martin Leutelt <martin.leutelt@basyskom.com>
|
||||||
|
// SPDX-FileCopyrightText: 2025 basysKom GmbH
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: LGPL-3.0-or-later
|
||||||
|
|
||||||
|
import QtQuick
|
||||||
|
import QtQuick.Controls
|
||||||
|
|
||||||
|
Control {
|
||||||
|
id: container
|
||||||
|
|
||||||
|
required property int column
|
||||||
|
required property var model
|
||||||
|
property int sortOrder: Qt.AscendingOrder
|
||||||
|
|
||||||
|
signal clicked(int sortOrder)
|
||||||
|
|
||||||
|
padding: 8
|
||||||
|
|
||||||
|
background: Rectangle {
|
||||||
|
color: tapHandler.pressed ? "gray" : "lightgray"
|
||||||
|
|
||||||
|
TapHandler {
|
||||||
|
id: tapHandler
|
||||||
|
|
||||||
|
onTapped: {
|
||||||
|
if (container.sortOrder === Qt.AscendingOrder) {
|
||||||
|
container.sortOrder = Qt.DescendingOrder
|
||||||
|
} else {
|
||||||
|
container.sortOrder = Qt.AscendingOrder
|
||||||
|
}
|
||||||
|
|
||||||
|
container.clicked(container.sortOrder)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
contentItem: Label {
|
||||||
|
horizontalAlignment: Text.AlignHCenter
|
||||||
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
elide: Text.ElideRight
|
||||||
|
text: container.model.display
|
||||||
|
}
|
||||||
|
}
|
26
qml/VerticalHeaderViewDelegate.qml
Normal file
26
qml/VerticalHeaderViewDelegate.qml
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
import QtQuick
|
||||||
|
import QtQuick.Controls
|
||||||
|
|
||||||
|
Control {
|
||||||
|
id: container
|
||||||
|
|
||||||
|
required property int row
|
||||||
|
required property var model
|
||||||
|
|
||||||
|
padding: 8
|
||||||
|
|
||||||
|
background: Rectangle {
|
||||||
|
color: tapHandler.pressed ? "gray" : "lightgray"
|
||||||
|
|
||||||
|
TapHandler {
|
||||||
|
id: tapHandler
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
contentItem: Label {
|
||||||
|
horizontalAlignment: Text.AlignHCenter
|
||||||
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
elide: Text.ElideRight
|
||||||
|
text: container.model.display
|
||||||
|
}
|
||||||
|
}
|
161
qml/XMain.qml
Normal file
161
qml/XMain.qml
Normal file
@@ -0,0 +1,161 @@
|
|||||||
|
// SPDX-FileCopyrightText: 2025 Martin Leutelt <martin.leutelt@basyskom.com>
|
||||||
|
// SPDX-FileCopyrightText: 2025 basysKom GmbH
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: LGPL-3.0-or-later
|
||||||
|
|
||||||
|
pragma ComponentBehavior: Bound
|
||||||
|
|
||||||
|
import QtQuick
|
||||||
|
import QtQuick.Controls
|
||||||
|
import QtQuick.Layouts
|
||||||
|
|
||||||
|
ApplicationWindow {
|
||||||
|
width: 640
|
||||||
|
height: 480
|
||||||
|
visible: true
|
||||||
|
title: Application.displayName
|
||||||
|
|
||||||
|
header: ToolBar {
|
||||||
|
ColumnLayout {
|
||||||
|
RowLayout {
|
||||||
|
Label {
|
||||||
|
text: "Rows"
|
||||||
|
}
|
||||||
|
SpinBox {
|
||||||
|
id: rowSettings
|
||||||
|
from: 1
|
||||||
|
to: 20
|
||||||
|
}
|
||||||
|
|
||||||
|
ToolSeparator {}
|
||||||
|
|
||||||
|
Label {
|
||||||
|
text: "Columns"
|
||||||
|
}
|
||||||
|
SpinBox {
|
||||||
|
id: columnSettings
|
||||||
|
from: 1
|
||||||
|
to: 20
|
||||||
|
}
|
||||||
|
|
||||||
|
ToolSeparator {}
|
||||||
|
|
||||||
|
CheckBox {
|
||||||
|
id: movableColumnsSetting
|
||||||
|
|
||||||
|
text: "Movable columns"
|
||||||
|
}
|
||||||
|
|
||||||
|
ToolSeparator {}
|
||||||
|
|
||||||
|
CheckBox {
|
||||||
|
id: resizableColumnsSetting
|
||||||
|
|
||||||
|
text: "Resizable columns"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RowLayout {
|
||||||
|
Label {
|
||||||
|
text: "Selection"
|
||||||
|
}
|
||||||
|
ComboBox {
|
||||||
|
id: selectionSetting
|
||||||
|
textRole: "text"
|
||||||
|
valueRole: "value"
|
||||||
|
model: [
|
||||||
|
{ text: "disabled", value: TableView.SelectionDisabled },
|
||||||
|
{ text: "by cells", value: TableView.SelectCells },
|
||||||
|
{ text: "by rows", value: TableView.SelectRows },
|
||||||
|
{ text: "by columns", value: TableView.SelectColumns }
|
||||||
|
]
|
||||||
|
|
||||||
|
onCurrentIndexChanged: tableView.selectionModel.clear()
|
||||||
|
}
|
||||||
|
Label {
|
||||||
|
text: "Longpress to start selection, modify selection with CTRL/SHIFT of by mouse"
|
||||||
|
visible: selectionSetting.currentIndex > 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
id: tableBackground
|
||||||
|
|
||||||
|
anchors.fill: parent
|
||||||
|
|
||||||
|
color: Application.styleHints.colorScheme === Qt.Light ? palette.mid : palette.midlight
|
||||||
|
|
||||||
|
HorizontalHeaderView {
|
||||||
|
id: horizontalHeader
|
||||||
|
|
||||||
|
anchors.left: tableView.left
|
||||||
|
anchors.top: parent.top
|
||||||
|
|
||||||
|
syncView: tableView
|
||||||
|
movableColumns: movableColumnsSetting.checked
|
||||||
|
resizableColumns: resizableColumnsSetting.checked
|
||||||
|
clip: true
|
||||||
|
boundsBehavior: tableView.boundsBehavior
|
||||||
|
|
||||||
|
delegate: HorizontalHeaderViewDelegate {
|
||||||
|
onClicked: (sortOrder) => tableView.model.sort(column, sortOrder)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
VerticalHeaderView {
|
||||||
|
id: verticalHeader
|
||||||
|
|
||||||
|
anchors.top: tableView.top
|
||||||
|
anchors.left: parent.left
|
||||||
|
|
||||||
|
syncView: tableView
|
||||||
|
clip: true
|
||||||
|
boundsBehavior: tableView.boundsBehavior
|
||||||
|
|
||||||
|
delegate: VerticalHeaderViewDelegate {}
|
||||||
|
}
|
||||||
|
|
||||||
|
TableView {
|
||||||
|
id: tableView
|
||||||
|
|
||||||
|
anchors.left: verticalHeader.right
|
||||||
|
anchors.top: horizontalHeader.bottom
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.bottom: parent.bottom
|
||||||
|
|
||||||
|
clip: true
|
||||||
|
columnSpacing: 1
|
||||||
|
rowSpacing: 1
|
||||||
|
rowHeightProvider: (row) => 40
|
||||||
|
boundsBehavior: TableView.StopAtBounds
|
||||||
|
selectionModel: ItemSelectionModel {}
|
||||||
|
selectionBehavior: selectionSetting.currentValue
|
||||||
|
|
||||||
|
model: SortFilterModel {
|
||||||
|
sourceModel: TableModel {
|
||||||
|
columns: columnSettings.value
|
||||||
|
rows: rowSettings.value
|
||||||
|
|
||||||
|
// when adding a new column its width isn't properly applied to the header, so we do that manually
|
||||||
|
onColumnsInserted: {
|
||||||
|
if (columns > 1) {
|
||||||
|
horizontalHeader.setColumnWidth(columns - 1, tableView.implicitColumnWidth(columns - 1))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
delegate: TableViewDelegate {
|
||||||
|
implicitWidth: tableView.width / columnSettings.to
|
||||||
|
}
|
||||||
|
|
||||||
|
ScrollBar.horizontal: ScrollBar {}
|
||||||
|
ScrollBar.vertical: ScrollBar {}
|
||||||
|
}
|
||||||
|
|
||||||
|
SelectionRectangle {
|
||||||
|
target: tableView
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
45
qml/dummyview.qml
Normal file
45
qml/dummyview.qml
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
import QtQuick
|
||||||
|
import QtQuick.Controls
|
||||||
|
import QtQuick.Layouts
|
||||||
|
import QtQuick.Window
|
||||||
|
|
||||||
|
ApplicationWindow
|
||||||
|
{
|
||||||
|
visible: true
|
||||||
|
width: 600
|
||||||
|
height: 400
|
||||||
|
title: "TableView mit myChildModel"
|
||||||
|
|
||||||
|
TreeView
|
||||||
|
{
|
||||||
|
anchors.fill: parent
|
||||||
|
clip: true
|
||||||
|
columnSpacing: 1
|
||||||
|
rowSpacing: 1
|
||||||
|
|
||||||
|
model: myChildModel
|
||||||
|
|
||||||
|
delegate: Rectangle
|
||||||
|
{
|
||||||
|
implicitWidth: 150
|
||||||
|
implicitHeight: 40
|
||||||
|
border.color: "#cccccc"
|
||||||
|
//color: index % 2 === 0 ? "#f9f9f9" : "#e0e0e0"
|
||||||
|
|
||||||
|
Text {
|
||||||
|
anchors.centerIn: parent
|
||||||
|
text: display
|
||||||
|
font.pixelSize: 14
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ScrollBar.horizontal: ScrollBar {}
|
||||||
|
ScrollBar.vertical: ScrollBar {}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
65
qml/xqtableview.qml
Normal file
65
qml/xqtableview.qml
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
import QtQuick
|
||||||
|
import QtQuick.Controls
|
||||||
|
import QtQuick.Layouts
|
||||||
|
|
||||||
|
Window
|
||||||
|
{
|
||||||
|
width: 640
|
||||||
|
height: 480
|
||||||
|
visible: true
|
||||||
|
title: qsTr("StringListModel")
|
||||||
|
|
||||||
|
TableView
|
||||||
|
{
|
||||||
|
id: childTableView
|
||||||
|
anchors.fill: parent
|
||||||
|
|
||||||
|
model: myChildModel // z. B. QStandardItemModel mit 9 Spalten
|
||||||
|
|
||||||
|
delegate: Rectangle
|
||||||
|
{
|
||||||
|
required property string display
|
||||||
|
|
||||||
|
//height: 5
|
||||||
|
//width: childTableView.width
|
||||||
|
color : "blue"
|
||||||
|
border.color: "#ccc"
|
||||||
|
width: childTableView.width;
|
||||||
|
|
||||||
|
RowLayout
|
||||||
|
{
|
||||||
|
anchors.fill: parent
|
||||||
|
anchors.margins: 2
|
||||||
|
|
||||||
|
TextField
|
||||||
|
{
|
||||||
|
text : display
|
||||||
|
font.pixelSize: 10
|
||||||
|
Layout.fillWidth: true
|
||||||
|
|
||||||
|
background: Rectangle
|
||||||
|
{
|
||||||
|
color : "white"
|
||||||
|
}
|
||||||
|
|
||||||
|
onEditingFinished:
|
||||||
|
{
|
||||||
|
console.log("Editing finished, new text is :"+ text + " at index :" + index)
|
||||||
|
model.names = text //The roles here are defined in model class
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
ScrollBar.horizontal: ScrollBar {}
|
||||||
|
ScrollBar.vertical: ScrollBar {}
|
||||||
|
|
||||||
|
// // Optional: Spaltenbreiten setzen
|
||||||
|
// onModelChanged: {
|
||||||
|
// for (let i = 0; i < model.columns; ++i)
|
||||||
|
// table.setColumnWidth(i, 100)
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -1,35 +0,0 @@
|
|||||||
import QtQuick
|
|
||||||
import QtQuick.Controls
|
|
||||||
import QtQuick.Layouts
|
|
||||||
|
|
||||||
TableView
|
|
||||||
{
|
|
||||||
id: table
|
|
||||||
anchors.fill: parent
|
|
||||||
columnSpacing: 2
|
|
||||||
rowSpacing: 2
|
|
||||||
model: meinModel // z. B. QStandardItemModel mit 9 Spalten
|
|
||||||
|
|
||||||
delegate: Rectangle
|
|
||||||
{
|
|
||||||
|
|
||||||
required property string display
|
|
||||||
width: 100
|
|
||||||
height: 20
|
|
||||||
border.color: "#ccc"
|
|
||||||
|
|
||||||
Text
|
|
||||||
{
|
|
||||||
anchors.centerIn: parent
|
|
||||||
text: display
|
|
||||||
font.pixelSize: 10
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// // Optional: Spaltenbreiten setzen
|
|
||||||
// onModelChanged: {
|
|
||||||
// for (let i = 0; i < model.columns; ++i)
|
|
||||||
// table.setColumnWidth(i, 100)
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
@@ -117,7 +117,7 @@ void XQMainWindow::initMainWindow()
|
|||||||
|
|
||||||
// #2. load demo data
|
// #2. load demo data
|
||||||
loadDocument( c_DocumentFileName1 );
|
loadDocument( c_DocumentFileName1 );
|
||||||
//loadDocumentQML( c_DocumentFileName2 );
|
loadDocumentQML( c_DocumentFileName2 );
|
||||||
|
|
||||||
qDebug() << " --- all here: " << XQNode::s_Count;
|
qDebug() << " --- all here: " << XQNode::s_Count;
|
||||||
|
|
||||||
@@ -131,6 +131,9 @@ void XQMainWindow::initMainWindow()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//! slot für zentrales undo
|
//! slot für zentrales undo
|
||||||
|
|
||||||
void XQMainWindow::onUndo()
|
void XQMainWindow::onUndo()
|
||||||
@@ -319,8 +322,6 @@ void XQMainWindow::loadDocumentQML( const QString& fileName )
|
|||||||
// das als Namen verwendet wird.
|
// das als Namen verwendet wird.
|
||||||
const QString& fName = contentRoot->friendly_name();
|
const QString& fName = contentRoot->friendly_name();
|
||||||
|
|
||||||
QStandardItemModel* model = createModel();
|
|
||||||
|
|
||||||
// Ein neues Child-Model erzeugen
|
// Ein neues Child-Model erzeugen
|
||||||
XQChildModel* childModel = new XQChildModel(this);
|
XQChildModel* childModel = new XQChildModel(this);
|
||||||
// die Modelstruktur anlegen
|
// die Modelstruktur anlegen
|
||||||
@@ -331,13 +332,12 @@ void XQMainWindow::loadDocumentQML( const QString& fileName )
|
|||||||
XQQuickWidget* quickChild = new XQQuickWidget(_tabWidget);
|
XQQuickWidget* quickChild = new XQQuickWidget(_tabWidget);
|
||||||
//quickChild->setResizeMode(QQuickWidget::SizeViewToRootObject);
|
//quickChild->setResizeMode(QQuickWidget::SizeViewToRootObject);
|
||||||
|
|
||||||
quickChild->rootContext()->setContextProperty("meinModel", childModel);
|
quickChild->rootContext()->setContextProperty("myChildModel", childModel);
|
||||||
quickChild->setSource(QUrl(QStringLiteral("qrc:/quickview.qml")));
|
quickChild->setSource(QUrl("qrc:/xqtableview.qml"));
|
||||||
_tabWidget->addTab( quickChild, "Fitze!" );
|
_tabWidget->addTab( quickChild, "QML:"+fName );
|
||||||
_tabWidget->setCurrentWidget( quickChild );
|
_tabWidget->setCurrentWidget( quickChild );
|
||||||
quickChild->setResizeMode(QQuickWidget::SizeRootObjectToView);
|
quickChild->setResizeMode(QQuickWidget::SizeRootObjectToView);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//! liest eine XML datei namens 'fileName'
|
//! liest eine XML datei namens 'fileName'
|
||||||
|
@@ -52,10 +52,11 @@ public slots:
|
|||||||
void onSectionCreated( const XQModelSection& section);
|
void onSectionCreated( const XQModelSection& section);
|
||||||
void onSectionToggled( const XQModelSection& section );
|
void onSectionToggled( const XQModelSection& section );
|
||||||
|
|
||||||
|
static void setupWorkingDir();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
void setupWorkingDir();
|
|
||||||
|
|
||||||
// fixme implement
|
// fixme implement
|
||||||
void showDocumnet( const QString& key ){}
|
void showDocumnet( const QString& key ){}
|
||||||
|
90
src/main.cpp
90
src/main.cpp
@@ -15,6 +15,13 @@
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QMetaType>
|
#include <QMetaType>
|
||||||
|
#include <QGuiApplication>
|
||||||
|
#include <QQmlApplicationEngine>
|
||||||
|
#include <QUrl>
|
||||||
|
#include <QQmlContext>
|
||||||
|
|
||||||
|
#include <xqchildmodel.h>
|
||||||
|
#include <xqquickwidget.h>
|
||||||
|
|
||||||
#include <xqmainwindow.h>
|
#include <xqmainwindow.h>
|
||||||
|
|
||||||
@@ -49,12 +56,58 @@ who is who:
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
XQChildModel* createChildModel()
|
||||||
|
{
|
||||||
|
XQChildModel* myModel = new XQChildModel();
|
||||||
|
|
||||||
|
myModel->initModel( c_ChildModelName );
|
||||||
|
|
||||||
|
XQNodeFactory treeLoader;
|
||||||
|
// xml daten laden
|
||||||
|
XQNodePtr rawTree = treeLoader.load_tree( qPrintable(c_DocumentFileName1) );
|
||||||
|
// versteckten root node ignorieren
|
||||||
|
XQNodePtr contentRoot = rawTree->first_child();
|
||||||
|
myModel->addModelData( contentRoot->first_child() );
|
||||||
|
|
||||||
|
return myModel;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class DummyModel : public XQChildModel
|
||||||
|
{
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
DummyModel()
|
||||||
|
{
|
||||||
|
|
||||||
|
initModel( c_ChildModelName );
|
||||||
|
XQNodeFactory treeLoader;
|
||||||
|
// xml daten laden
|
||||||
|
XQNodePtr rawTree = treeLoader.load_tree( qPrintable(c_DocumentFileName1) );
|
||||||
|
// versteckten root node ignorieren
|
||||||
|
XQNodePtr contentRoot = rawTree->first_child();
|
||||||
|
addModelData( contentRoot->first_child() );
|
||||||
|
|
||||||
|
//XQTreeTable* treeTable = new XQTreeTable;
|
||||||
|
//treeTable->setModel(this);
|
||||||
|
//setTreeTable( treeTable );
|
||||||
|
|
||||||
|
//treeTable->show();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
using namespace Qt::Literals::StringLiterals;
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
|
||||||
QApplication app(argc, argv);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Signal für einzelne QStandardItem-Änderungen
|
// Signal für einzelne QStandardItem-Änderungen
|
||||||
connect(model, &QStandardItemModel::itemChanged,
|
connect(model, &QStandardItemModel::itemChanged,
|
||||||
this, [](QStandardItem *changedItem){
|
this, [](QStandardItem *changedItem){
|
||||||
@@ -63,10 +116,41 @@ connect(model, &QStandardItemModel::itemChanged,
|
|||||||
});
|
});
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
QApplication app(argc, argv);
|
||||||
//app.setStyle("fusion");
|
//app.setStyle("fusion");
|
||||||
XQMainWindow window;
|
XQMainWindow window;
|
||||||
window.show();
|
window.show();
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
QApplication app(argc, argv);
|
||||||
|
|
||||||
|
|
||||||
|
XQMainWindow::setupWorkingDir();
|
||||||
|
XQItemFactory::instance().initItemFactory( c_ModelSheetFileName );
|
||||||
|
|
||||||
|
XQChildModel* myModel = createChildModel();
|
||||||
|
qmlRegisterType< XQChildModel>("MyApp.Models", 1, 0, "MyChildModel");
|
||||||
|
|
||||||
|
|
||||||
|
QQmlApplicationEngine engine;
|
||||||
|
|
||||||
|
engine.rootContext()->setContextProperty("myChildModel", myModel);
|
||||||
|
|
||||||
|
QObject::connect(
|
||||||
|
&engine,
|
||||||
|
&QQmlApplicationEngine::objectCreationFailed,
|
||||||
|
&app,
|
||||||
|
[]() { QCoreApplication::exit(-1); },
|
||||||
|
Qt::QueuedConnection);
|
||||||
|
|
||||||
|
qDebug() << " fitz!";
|
||||||
|
|
||||||
|
engine.load( QUrl(QStringLiteral("qrc:/dummyview.qml")) );
|
||||||
|
//engine.load( QUrl(QStringLiteral("qrc:/xqtableview.qml")) );
|
||||||
|
|
||||||
|
qDebug() << " hhakl!";
|
||||||
|
|
||||||
return app.exec();
|
return app.exec();
|
||||||
|
|
||||||
|
@@ -31,7 +31,7 @@ void XQNodeStore::dumpList( const QString& title ) const
|
|||||||
//! kostruktor. übergibt command-type und die aufrufende modelView.
|
//! kostruktor. übergibt command-type und die aufrufende modelView.
|
||||||
|
|
||||||
XQCommand::XQCommand(CmdType cmdType, XQViewModel* modelView )
|
XQCommand::XQCommand(CmdType cmdType, XQViewModel* modelView )
|
||||||
: _cmdType{ cmdType }, _model(modelView)
|
: _cmdType{ cmdType }, _viewModel(modelView)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -66,7 +66,7 @@ void XQCommand::setCommandType( XQCommand::CmdType cmdType )
|
|||||||
|
|
||||||
void XQCommand::redo()
|
void XQCommand::redo()
|
||||||
{
|
{
|
||||||
_model->onCommandRedo( *this );
|
_viewModel->onCommandRedo( *this );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -74,7 +74,7 @@ void XQCommand::redo()
|
|||||||
|
|
||||||
void XQCommand::undo()
|
void XQCommand::undo()
|
||||||
{
|
{
|
||||||
_model->onCommandUndo( *this );
|
_viewModel->onCommandUndo( *this );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -84,9 +84,9 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
CmdType _cmdType{cmdInvalid};
|
CmdType _cmdType{cmdInvalid};
|
||||||
XQViewModel* _model{}; // needed for redo() / undo()
|
XQViewModel* _viewModel{}; // needed for redo() / undo()
|
||||||
QModelIndex _originIndex;
|
QModelIndex _originIndex;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
|
@@ -40,9 +40,9 @@ bool XQModelSection::isValid() const
|
|||||||
return _modelIndex.isValid() && _sectionRootNode;
|
return _modelIndex.isValid() && _sectionRootNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QModelIndex& XQModelSection::modelIndex() const
|
QModelIndex XQModelSection::persistentModelIndex() const
|
||||||
{
|
{
|
||||||
return _modelIndex;
|
return _modelIndex.operator QModelIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
XQNodePtr XQModelSection::sectionRootNode() const
|
XQNodePtr XQModelSection::sectionRootNode() const
|
||||||
@@ -129,7 +129,7 @@ const XQModelSection& XQModelSectionList::sectionFromRow(int itemRow ) const
|
|||||||
int i = size() - 1;
|
int i = size() - 1;
|
||||||
for (; i >= 0; --i)
|
for (; i >= 0; --i)
|
||||||
{
|
{
|
||||||
if ( at(i).modelIndex().row() < itemRow )
|
if ( at(i).persistentModelIndex().row() < itemRow )
|
||||||
return at(i);
|
return at(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,7 +170,7 @@ int XQModelSectionList::lastRow(const XQModelSection& section ) const
|
|||||||
{
|
{
|
||||||
// last section? return last row of model
|
// last section? return last row of model
|
||||||
if (index == size() - 1)
|
if (index == size() - 1)
|
||||||
return section.modelIndex().model()->rowCount();// - 1;
|
return section.persistentModelIndex().model()->rowCount();// - 1;
|
||||||
// return row above the row of the next section -> last row of given section
|
// return row above the row of the next section -> last row of given section
|
||||||
return at(index+1).row();
|
return at(index+1).row();
|
||||||
}
|
}
|
||||||
@@ -185,7 +185,7 @@ void XQModelSectionList::dump() const
|
|||||||
qDebug() << " --- sections dump(): " <<size() << " entries.";
|
qDebug() << " --- sections dump(): " <<size() << " entries.";
|
||||||
for( int i = 0; i<size(); ++i )
|
for( int i = 0; i<size(); ++i )
|
||||||
{
|
{
|
||||||
QModelIndex idx = at(i).modelIndex();
|
QModelIndex idx = at(i).persistentModelIndex();
|
||||||
qDebug() << " --- sections:" << i << "row: " << idx.row() << " keyOf(i): " << keyOf(i) << " indexData: "<< idx.data().toString() << " itemData: " << XQItem::xqItemFromIndex(idx).data(Qt::DisplayRole).toString();
|
qDebug() << " --- sections:" << i << "row: " << idx.row() << " keyOf(i): " << keyOf(i) << " indexData: "<< idx.data().toString() << " itemData: " << XQItem::xqItemFromIndex(idx).data(Qt::DisplayRole).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -37,7 +37,7 @@ public:
|
|||||||
bool isValid() const;
|
bool isValid() const;
|
||||||
int row() const;
|
int row() const;
|
||||||
|
|
||||||
const QModelIndex& modelIndex() const;
|
QModelIndex persistentModelIndex() const;
|
||||||
XQNodePtr sectionRootNode() const;
|
XQNodePtr sectionRootNode() const;
|
||||||
XQNodePtr sheetRootNode() const;
|
XQNodePtr sheetRootNode() const;
|
||||||
XQNodePtr contentRootNode() const;
|
XQNodePtr contentRootNode() const;
|
||||||
|
@@ -19,6 +19,7 @@
|
|||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QStandardItemModel>
|
#include <QStandardItemModel>
|
||||||
#include <QAbstractItemView>
|
#include <QAbstractItemView>
|
||||||
|
#include <QtQmlIntegration>
|
||||||
|
|
||||||
#include <xqsimpleclipboard.h>
|
#include <xqsimpleclipboard.h>
|
||||||
#include <xqmodelsectionlist.h>
|
#include <xqmodelsectionlist.h>
|
||||||
@@ -36,12 +37,15 @@ class XQCommand;
|
|||||||
class XQViewModel : public QStandardItemModel
|
class XQViewModel : public QStandardItemModel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
//QML_ELEMENT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
XQViewModel(QObject* parent = nullptr);
|
XQViewModel(QObject* parent = nullptr);
|
||||||
virtual ~XQViewModel() = default;
|
virtual ~XQViewModel() = default;
|
||||||
|
|
||||||
|
QHash<int, QByteArray> roleNames() const override;
|
||||||
|
|
||||||
XQTreeTable* treeTable();
|
XQTreeTable* treeTable();
|
||||||
virtual void setTreeTable( XQTreeTable* mainView );
|
virtual void setTreeTable( XQTreeTable* mainView );
|
||||||
|
|
||||||
@@ -68,7 +72,7 @@ public:
|
|||||||
virtual void cmdNew( XQCommand& command );
|
virtual void cmdNew( XQCommand& command );
|
||||||
virtual void cmdNewUndo( XQCommand& command );
|
virtual void cmdNewUndo( XQCommand& command );
|
||||||
|
|
||||||
QHash<int, QByteArray> roleNames() const override;
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|
||||||
@@ -106,7 +110,7 @@ signals:
|
|||||||
protected:
|
protected:
|
||||||
|
|
||||||
void addSection(const XQItemList& list, const XQNodePtr& sheetNode );
|
void addSection(const XQItemList& list, const XQNodePtr& sheetNode );
|
||||||
virtual void initContextMenu() = 0;
|
virtual void initContextMenu(){}
|
||||||
|
|
||||||
// __fixme: should be created from xml
|
// __fixme: should be created from xml
|
||||||
virtual void setupViewProperties();
|
virtual void setupViewProperties();
|
||||||
|
@@ -1,7 +1,10 @@
|
|||||||
QT += core gui widgets quick quickwidgets
|
QT += core gui widgets quick quickwidgets
|
||||||
# widgets-private
|
# widgets-private
|
||||||
|
|
||||||
CONFIG += c++20
|
CONFIG += c++20 qmltypes
|
||||||
|
|
||||||
|
QML_IMPORT_NAME = org.sourceworx.qmlcomponents
|
||||||
|
QML_IMPORT_MAJOR_VERSION = 1
|
||||||
|
|
||||||
# You can make your code fail to compile if it uses deprecated APIs.
|
# You can make your code fail to compile if it uses deprecated APIs.
|
||||||
# In order to do so, uncomment the following line.
|
# In order to do so, uncomment the following line.
|
||||||
|
@@ -1,10 +1,13 @@
|
|||||||
<RCC>
|
<RCC>
|
||||||
<qresource prefix="/">
|
<qresource prefix="/">
|
||||||
<file alias="modeldata1.xtr">../xml/modeldata1.xtr</file>
|
<file alias="modeldata1.xtr">../xml/modeldata1.xtr</file>
|
||||||
<file alias="modeldata2.xtr">../xml/modeldata2.xtr</file>
|
<file alias="modeldata2.xtr">../xml/modeldata2.xtr</file>
|
||||||
<file alias="modeldata3.xtr">../xml/modeldata3.xtr</file>
|
<file alias="modeldata3.xtr">../xml/modeldata3.xtr</file>
|
||||||
<file alias="modelsheet.xml">../xml/modelsheets.xml</file>
|
<file alias="modelsheet.xml">../xml/modelsheets.xml</file>
|
||||||
<file alias="quickview.qml">../quick/quickview.qml</file>
|
<file alias="xqtableview.qml">../qml/xqtableview.qml</file>
|
||||||
|
<file alias="HorizontalHeaderViewDelegate.qml">../qml/HorizontalHeaderViewDelegate.qml</file>
|
||||||
</qresource>
|
<file alias="XMain.qml">../qml/XMain.qml</file>
|
||||||
</RCC>
|
<file alias="VerticalHeaderViewDelegate.qml">../qml/VerticalHeaderViewDelegate.qml</file>
|
||||||
|
<file alias="dummyview.qml">../qml/dummyview.qml</file>
|
||||||
|
</qresource>
|
||||||
|
</RCC>
|
Reference in New Issue
Block a user