|
|
|
@@ -16,6 +16,7 @@
|
|
|
|
|
#include <QFileDialog>
|
|
|
|
|
#include <QMessageBox>
|
|
|
|
|
#include <QPushButton>
|
|
|
|
|
#include <QQmlContext>
|
|
|
|
|
|
|
|
|
|
#include <xqmainwindow.h>
|
|
|
|
|
#include <xqcommand.h>
|
|
|
|
@@ -91,15 +92,7 @@ void XQMainWindow::initMainWindow()
|
|
|
|
|
connect( _mainTreeView, SIGNAL(clicked(QModelIndex)), this, SLOT(onTreeItemClicked(QModelIndex)) );
|
|
|
|
|
connect( _tabWidget, SIGNAL(tabBarClicked(int)), this, SLOT(onTabClicked(int)) );
|
|
|
|
|
|
|
|
|
|
connect( _tabWidget, SIGNAL(tabBarClicked(int)), this, SLOT(onTabClicked(int)) );
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
XQQuickWidget* butt = new XQQuickWidget;
|
|
|
|
|
butt->resize(800,600);
|
|
|
|
|
butt->setWindowFlags(Qt::Dialog | Qt::WindowStaysOnTopHint);
|
|
|
|
|
butt->move( 1200,300);
|
|
|
|
|
butt->show();
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
connect( &_mainModelView, &XQViewModel::itemCreated, this, [=, this](XQItem* item)
|
|
|
|
@@ -124,7 +117,7 @@ void XQMainWindow::initMainWindow()
|
|
|
|
|
|
|
|
|
|
// #2. load demo data
|
|
|
|
|
loadDocument( c_DocumentFileName1 );
|
|
|
|
|
//loadDocument( c_DocumentFileName2 );
|
|
|
|
|
loadDocumentQML( c_DocumentFileName2 );
|
|
|
|
|
|
|
|
|
|
qDebug() << " --- all here: " << XQNode::s_Count;
|
|
|
|
|
|
|
|
|
@@ -279,12 +272,13 @@ void XQMainWindow::onTreeItemClicked(const QModelIndex& index )
|
|
|
|
|
void XQMainWindow::onTabClicked( int index )
|
|
|
|
|
{
|
|
|
|
|
//const QString& key = _documentStore[index].treeItem->attribute( c_ProjectID );
|
|
|
|
|
qDebug() << " ---- tab clicked: " << index << " : " << _documentStore[index].friendlyName;// << ": " << key;
|
|
|
|
|
//qDebug() << " ---- tab clicked: " << index << " : " << _documentStore[index].friendlyName;// << ": " << key;
|
|
|
|
|
//_mainTreeView->setCurrentIndex( _documentStore[index].treeItem->index() );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void XQMainWindow::onSectionCreated( const XQModelSection& section )
|
|
|
|
|
{
|
|
|
|
|
qDebug() << " --- XXX section created: " << section.contentType() << ":" << section.sheetRootNode()->to_string();
|
|
|
|
|
if( _currentProjectItem )
|
|
|
|
|
{
|
|
|
|
|
_mainModelView.addSectionItem( section, _currentProjectItem );
|
|
|
|
@@ -296,6 +290,56 @@ void XQMainWindow::onSectionToggled( const XQModelSection& section )
|
|
|
|
|
//qDebug() << " --- XXX section toggled: " << section.contentType() << ":" << section.sheetRootNode()->to_string();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QStandardItemModel* createModel() {
|
|
|
|
|
auto* model = new QStandardItemModel;
|
|
|
|
|
model->setHorizontalHeaderLabels({ "Name" });
|
|
|
|
|
|
|
|
|
|
QStandardItem* parent = new QStandardItem("Tiere");
|
|
|
|
|
parent->appendRow(new QStandardItem("Hund"));
|
|
|
|
|
parent->appendRow(new QStandardItem("Katze"));
|
|
|
|
|
model->appendRow(parent);
|
|
|
|
|
|
|
|
|
|
return model;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void XQMainWindow::loadDocumentQML( const QString& fileName )
|
|
|
|
|
{
|
|
|
|
|
// gibts die Datei?
|
|
|
|
|
if( !QFile::exists( fileName) )
|
|
|
|
|
throw XQException( "no such file", fileName );
|
|
|
|
|
|
|
|
|
|
XQNodeFactory treeLoader;
|
|
|
|
|
// xml daten laden
|
|
|
|
|
XQNodePtr rawTree = treeLoader.load_tree( qPrintable(fileName) );
|
|
|
|
|
// versteckten root node ignorieren
|
|
|
|
|
XQNodePtr contentRoot = rawTree->first_child();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 'friendly Name' ist ein Link auf ein anderes Attribute
|
|
|
|
|
// das als Namen verwendet wird.
|
|
|
|
|
const QString& fName = contentRoot->friendly_name();
|
|
|
|
|
|
|
|
|
|
QStandardItemModel* model = createModel();
|
|
|
|
|
|
|
|
|
|
// Ein neues Child-Model erzeugen
|
|
|
|
|
XQChildModel* childModel = new XQChildModel(this);
|
|
|
|
|
// die Modelstruktur anlegen
|
|
|
|
|
childModel->initModel( c_ChildModelName );
|
|
|
|
|
// model inhalte laden
|
|
|
|
|
childModel->addModelData( contentRoot->first_child() );
|
|
|
|
|
|
|
|
|
|
XQQuickWidget* quickChild = new XQQuickWidget(_tabWidget);
|
|
|
|
|
//quickChild->setResizeMode(QQuickWidget::SizeViewToRootObject);
|
|
|
|
|
|
|
|
|
|
quickChild->rootContext()->setContextProperty("meinModel", childModel);
|
|
|
|
|
quickChild->setSource(QUrl(QStringLiteral("qrc:/quickview.qml")));
|
|
|
|
|
_tabWidget->addTab( quickChild, "Fitze!" );
|
|
|
|
|
_tabWidget->setCurrentWidget( quickChild );
|
|
|
|
|
quickChild->setResizeMode(QQuickWidget::SizeRootObjectToView);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//! liest eine XML datei namens 'fileName'
|
|
|
|
|
|
|
|
|
|
void XQMainWindow::loadDocument( const QString& fileName )
|
|
|
|
@@ -347,9 +391,7 @@ void XQMainWindow::loadDocument( const QString& fileName )
|
|
|
|
|
|
|
|
|
|
// neuen eintrag im übsichts-baum erzeugen
|
|
|
|
|
_currentProjectItem = _mainModelView.addProjectItem( contentRoot );
|
|
|
|
|
//_documentStore.addDocument( fileName, pTitle, _currentProjectItem, childModel );
|
|
|
|
|
|
|
|
|
|
qDebug() << " --- ZZZ und jetzt:";
|
|
|
|
|
_documentStore.addDocument( fileName, pTitle, _currentProjectItem, childModel );
|
|
|
|
|
|
|
|
|
|
// die Modelstruktur anlegen
|
|
|
|
|
childModel->initModel( c_ChildModelName );
|
|
|
|
|