Files
xtree.ng/src/main.cpp

126 lines
2.6 KiB
C++
Raw Normal View History

2025-08-22 22:57:06 +02:00
/***************************************************************************
source::worx xtree
Copyright © 2024-2025 c.holzheuer
christoph.holzheuer@gmail.com
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 2 of the License, or
(at your option) any later version.
***************************************************************************/
#include <QDebug>
#include <QApplication>
#include <QMetaType>
2025-08-26 17:45:06 +02:00
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QUrl>
#include <QQmlContext>
#include <xqchildmodel.h>
#include <xqquickwidget.h>
2025-08-22 22:57:06 +02:00
#include <xqmainwindow.h>
/*
TODO:
- kann ich die Enums auto generieren?
- entries einfach abzählen,
- einen enum als type
- auf diesen type drauf-casten, siehe qtglobal.h
- FIX! in reality, we have nested types, also.
- done: reference style
- done: shared_ptr
- try QML
- try 'model->readMore'
doc:
- vorhandenes xnode konzept soll am qt angebunden werden
- datensparsam: flyweight pattern & pointer auf orig
who is who:
- item
-itemtype
- factory
- model
- section
*/
2025-08-26 17:45:06 +02:00
XQChildModel* createChildModel()
2025-08-22 22:57:06 +02:00
{
2025-08-26 17:45:06 +02:00
XQChildModel* myModel = new XQChildModel();
2025-08-22 22:57:06 +02:00
2025-08-26 17:45:06 +02:00
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;
}
using namespace Qt::Literals::StringLiterals;
int main(int argc, char *argv[])
{
2025-08-22 22:57:06 +02:00
2025-08-26 17:45:06 +02:00
QApplication app(argc, argv);
2025-09-04 13:52:23 +02:00
//app.setStyle("WindowsVista");
2025-08-22 22:57:06 +02:00
XQMainWindow window;
window.show();
2025-08-26 17:45:06 +02:00
2025-08-26 19:41:28 +02:00
/*
2025-08-26 17:45:06 +02:00
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!";
2025-08-22 22:57:06 +02:00
2025-08-26 19:41:28 +02:00
*/
2025-08-22 22:57:06 +02:00
return app.exec();
}