cleanups, added const iterators to xqmaptor
This commit is contained in:
@@ -98,7 +98,7 @@ void XQMainWindow::initMainWindow()
|
||||
|
||||
connect( _mainTreeView, &QTreeView::clicked, this, [&,this](const QModelIndex& index)
|
||||
{
|
||||
onChildViewItemClicked( XQItem::xqItemFromIndex(index) );
|
||||
onTreeViewItemClicked( XQItem::xqItemFromIndex(index) );
|
||||
});
|
||||
|
||||
|
||||
@@ -125,7 +125,8 @@ void XQMainWindow::initMainWindow()
|
||||
|
||||
// #2. load demo data
|
||||
loadDocument( c_DocumentFileName1 );
|
||||
loadDocumentQML( c_DocumentFileName2 );
|
||||
//loadDocumentQML( c_DocumentFileName2 );
|
||||
loadDocument( c_DocumentFileName2 );
|
||||
|
||||
qDebug() << " --- all here: " << XQNode::s_Count;
|
||||
|
||||
@@ -259,48 +260,58 @@ void XQMainWindow::onAbout()
|
||||
|
||||
void XQMainWindow::onTreeViewItemClicked( const XQItem& item )
|
||||
{
|
||||
|
||||
qDebug() << " --- XXX mainWindow onTreeItemClicked:" << item.text();
|
||||
/*
|
||||
_mainTreeView->selectionModel()->select(item.index(), QItemSelectionModel::Select);
|
||||
|
||||
if( XQNodePtr contentNode = item.contentNode() )
|
||||
{
|
||||
//XQNodePtr contentNode = item.contentNode()
|
||||
QString key = contentNode->attribute(c_ProjectID);
|
||||
qDebug() << " --- FIRZ: key: " << key;
|
||||
|
||||
bool isThere = _documentStore.contains(key);
|
||||
if( isThere)
|
||||
_tabWidget->setCurrentWidget( _documentStore[key].modelView->treeTable() );
|
||||
_tabWidget->setCurrentWidget( _documentStore[key].viewModel->treeTable() );
|
||||
}
|
||||
*/
|
||||
|
||||
qDebug() << " --- Tree item CLICK:" << item.text() << " : " << item.itemType().text();
|
||||
if( item.itemType().text() == "TreeChildType" )
|
||||
{
|
||||
setChildTabByName( item.text() );
|
||||
}
|
||||
}
|
||||
|
||||
void XQMainWindow::onTreeViewItemChanged(const XQItem &item )
|
||||
void XQMainWindow::onTreeViewItemChanged(const XQItem& item )
|
||||
{
|
||||
qDebug() << " --- MAIN WINDOW on itemChanged:" << item.text();
|
||||
}
|
||||
|
||||
void XQMainWindow::onChildViewItemClicked( const XQItem& item )
|
||||
{
|
||||
qDebug() << " --- MAIN WINDOW on CHILD item CLICK:" << item.text();
|
||||
}
|
||||
|
||||
void XQMainWindow::onChildViewItemChanged(const XQItem &item )
|
||||
{
|
||||
qDebug() << " --- MAIN WINDOW on CHILD itemChanged:" << item.text();
|
||||
qDebug() << " --- TREE VIEW itemChanged:" << item.text() << " : " << item.parent()->text();
|
||||
// hier müssen wir erst das projekt aktivieren
|
||||
XQItem* xqItem = static_cast<XQItem*>(item.parent());
|
||||
onTreeViewItemClicked( *xqItem );
|
||||
//if( item.itemType().text() == "TreeSectionType" )
|
||||
{
|
||||
int idx = _tabWidget->currentIndex();
|
||||
if(_documentStore.contains(idx) )
|
||||
{
|
||||
qDebug() << " --- should toggle: " << item.text();
|
||||
XQViewModel& childModel = *_documentStore[idx].viewModel;
|
||||
childModel.toggleSection(item.text());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//! beim click auf ein tab im linken fenster wird der navigationsbaum angepasst.
|
||||
|
||||
void XQMainWindow::onChildViewTabClicked( int index )
|
||||
void XQMainWindow::onChildViewTabClicked( int idx )
|
||||
{
|
||||
qDebug() << " --- onChildTabClicked: " << index;
|
||||
//const QString& key = _documentStore[index].treeItem->attribute( c_ProjectID );
|
||||
//qDebug() << " ---- tab clicked: " << index << " : " << _documentStore[index].friendlyName;// << ": " << key;
|
||||
//_mainTreeView->setCurrentIndex( _documentStore[index]->treeTtem.index() );
|
||||
if(_documentStore.contains(idx) )
|
||||
{
|
||||
QModelIndex treeIndex =_documentStore[idx].treeItem->index();
|
||||
_mainModel.expandNewItem( treeIndex );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//! firz
|
||||
|
||||
void XQMainWindow::onSectionCreated( const XQModelSection& section )
|
||||
{
|
||||
qDebug() << " --- XXX section created: " << section.contentType() << ":" << section.sheetRootNode()->to_string();
|
||||
@@ -315,16 +326,16 @@ 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::setChildTabByName( const QString& key )
|
||||
{
|
||||
for( int i=0; i<_documentStore.size(); ++i )
|
||||
{
|
||||
if( key == _documentStore[i].friendlyName)
|
||||
{
|
||||
_tabWidget->setCurrentIndex(i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void XQMainWindow::loadDocumentQML( const QString& fileName )
|
||||
@@ -391,13 +402,13 @@ void XQMainWindow::loadDocument( const QString& fileName )
|
||||
// 'friendly Name' ist ein Link auf ein anderes Attribute
|
||||
// das als Namen verwendet wird.
|
||||
const QString& fName = contentRoot->friendly_name();
|
||||
QString pTitle = QString("Project %1: %2").arg( pID, fName );
|
||||
QString pTabTitle = QString("Project %1: %2").arg( pID, fName );
|
||||
|
||||
// Eine neue TreeView erzeugn und im TabWidget parken.
|
||||
XQTreeTable* childTreeView = new XQTreeTable(_tabWidget);
|
||||
_tabWidget->addTab( childTreeView, pTitle );
|
||||
_tabWidget->addTab( childTreeView, pTabTitle );
|
||||
_tabWidget->setCurrentWidget( childTreeView );
|
||||
setWindowTitle( pTitle );
|
||||
setWindowTitle( pTabTitle );
|
||||
|
||||
// Ein neues Child-Model erzeugen
|
||||
XQChildModel* childModel = new XQChildModel(this);
|
||||
@@ -413,7 +424,7 @@ void XQMainWindow::loadDocument( const QString& fileName )
|
||||
|
||||
// neuen eintrag im übsichts-baum erzeugen
|
||||
_currentProjectItem = _mainModel.addProjectItem( contentRoot );
|
||||
_documentStore.addDocument( fileName, pTitle, _currentProjectItem, childModel );
|
||||
_documentStore.addDocument( fileName, fName, _currentProjectItem, childModel );
|
||||
|
||||
// die Modelstruktur anlegen
|
||||
childModel->initModel( c_ChildModelName );
|
||||
@@ -432,7 +443,7 @@ void XQMainWindow::saveDocument( const QString& fileName )
|
||||
XQNodeWriter nodeWriter;
|
||||
int curIdx = _tabWidget->currentIndex();
|
||||
//XQNodePtr rootNode = _documentStore[curIdx].treeItem->contentNode();
|
||||
XQNodePtr rootNode = _documentStore[curIdx].modelView->contentRootNode();
|
||||
XQNodePtr rootNode = _documentStore[curIdx].viewModel->contentRootNode();
|
||||
Q_ASSERT(rootNode);
|
||||
nodeWriter.dumpTree( rootNode, fileName );
|
||||
}
|
||||
|
Reference in New Issue
Block a user