cleanups, added const iterators to xqmaptor
This commit is contained in:
@@ -38,6 +38,7 @@ const QString c_ProjectID = "ProjectID";
|
||||
const QString c_ModelSheetFileName = "xml/modelsheets.xml";
|
||||
const QString c_ModelDummyFileName = "xml/saved_testfile.xtr";
|
||||
const QString c_DocumentDirectory = "xml/";
|
||||
|
||||
const QString c_DocumentFileName1 = "xml/modeldata1.xtr";
|
||||
const QString c_DocumentFileName2 = "xml/modeldata2.xtr";
|
||||
const QString c_DocumentFileName3 = "xml/modeldata3.xtr";
|
||||
|
@@ -18,8 +18,8 @@
|
||||
|
||||
//! erzeugt ein docukument
|
||||
|
||||
XQDocument::XQDocument(const QString& aFileName, const QString& aFriendlyName, XQItem* aTreeItem, XQViewModel* aModelView )
|
||||
: fileName{ aFileName }, friendlyName{ aFriendlyName }, treeItem{ aTreeItem }, modelView{ aModelView }
|
||||
XQDocument::XQDocument(const QString& aFileName, const QString& aFriendlyName, XQItem* aTreeItem, XQViewModel* aViewModel )
|
||||
: fileName{ aFileName }, friendlyName{ aFriendlyName }, treeItem{ aTreeItem }, viewModel{ aViewModel }
|
||||
{
|
||||
|
||||
}
|
||||
@@ -44,9 +44,9 @@ XQDocumentStore::~XQDocumentStore()
|
||||
|
||||
//! erzeugt ein document eintrag
|
||||
|
||||
void XQDocumentStore::addDocument( const QString& aFileName, const QString& aFriendlyName, XQItem* aTreeItem, XQViewModel* aModelView )
|
||||
void XQDocumentStore::addDocument(const QString& aFileName, const QString& aFriendlyName, XQItem* aTreeItem, XQViewModel* aViewModel )
|
||||
{
|
||||
XQDocument newDocument( aFileName, aFriendlyName, aTreeItem, aModelView );
|
||||
XQDocument newDocument( aFileName, aFriendlyName, aTreeItem, aViewModel );
|
||||
addAtKey( aFileName, newDocument );
|
||||
// attention: this assumes the presence of the 'ProjectID' value
|
||||
//addAlias( aFileName, aTreeItem->attribute(c_ProjectID) );
|
||||
|
@@ -28,12 +28,10 @@ struct XQDocument
|
||||
XQDocument() = default;
|
||||
XQDocument( const QString& aFileName, const QString& aFriendlyName, XQItem* aTreeItem, XQViewModel* aModelView );
|
||||
|
||||
virtual ~XQDocument() = default;
|
||||
|
||||
QString fileName; // also used as key
|
||||
QString friendlyName;
|
||||
XQItem* treeItem{};
|
||||
XQViewModel* modelView{};
|
||||
XQViewModel* viewModel{};
|
||||
|
||||
};
|
||||
|
||||
@@ -46,11 +44,7 @@ public:
|
||||
XQDocumentStore() = default;
|
||||
virtual ~ XQDocumentStore();
|
||||
|
||||
void addDocument( const QString& aFileName, const QString& aFriendlyName, XQItem* aTreeItem, XQViewModel* aModelView );
|
||||
|
||||
protected:
|
||||
|
||||
XQNode _treeRootNode{ "treeRootNode" };
|
||||
void addDocument( const QString& aFileName, const QString& aFriendlyName, XQItem* aTreeItem, XQViewModel* aViewModel );
|
||||
|
||||
};
|
||||
|
||||
|
@@ -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 );
|
||||
}
|
||||
|
@@ -51,33 +51,32 @@ public slots:
|
||||
void onAbout();
|
||||
void onExit();
|
||||
|
||||
void onTreeViewItemClicked(const XQItem& item );
|
||||
void onTreeViewItemClicked( const XQItem& item );
|
||||
void onTreeViewItemChanged( const XQItem& item );
|
||||
void onChildViewItemClicked( const XQItem& item );
|
||||
void onChildViewItemChanged( const XQItem& item );
|
||||
void onChildViewTabClicked( int index );
|
||||
|
||||
//void onItemCreated( XQItem* item );
|
||||
void onSectionCreated( const XQModelSection& section);
|
||||
void onSectionToggled( const XQModelSection& section );
|
||||
|
||||
void setChildTabByName( const QString& key );
|
||||
|
||||
static void setupWorkingDir();
|
||||
|
||||
protected:
|
||||
|
||||
// fixme implement
|
||||
void showDocumnet( const QString& key ){}
|
||||
void showDocument( const QString& key ){}
|
||||
void loadDocument( const QString& fileName );
|
||||
void loadDocumentQML( const QString& fileName );
|
||||
void saveDocument( const QString& fileName );
|
||||
|
||||
|
||||
QUndoStack _undoStack;
|
||||
XQDocumentStore _documentStore;
|
||||
|
||||
XQMainModel _mainModel;
|
||||
XQItem* _currentProjectItem{};
|
||||
|
||||
//XQChildModel* _currentChildModel{};
|
||||
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user