diff --git a/src/application/xqchildmodel.cpp b/src/application/xqchildmodel.cpp index f95aed2..0da5f4b 100644 --- a/src/application/xqchildmodel.cpp +++ b/src/application/xqchildmodel.cpp @@ -36,9 +36,8 @@ XQChildModel::XQChildModel( QObject *parent ) void XQChildModel::addModelData( const XQNodePtr& contentRoot ) { - // __fix: set object name ?? - - qDebug() << " --- create Model Data: " << contentRoot->to_string(); + setObjectName( contentRoot->to_string() ); + //qDebug() << " --- create Model Data: " << contentRoot->to_string(); // Die Datenbasis als shared_ptr sichern _contentRoot = contentRoot; diff --git a/src/application/xqmainmodel.cpp b/src/application/xqmainmodel.cpp index fe922a1..479e5d8 100644 --- a/src/application/xqmainmodel.cpp +++ b/src/application/xqmainmodel.cpp @@ -52,8 +52,6 @@ XQItem* XQMainModel::addProjectItem( XQNodePtr contentNode ) if( _sections.hasValidSection( sectionKey ) ) { const XQModelSection& section = _sections.sectionByKey( sectionKey ); - qDebug() << " --- add PROJECT: contentNode: " << contentNode->to_string(); - // __fixme! das ist mist! const XQNodePtr sheetNode = section.sheetRootNode()->first_child(); XQItem* newItem = _itemFactory.makeSingleItem( sheetNode, contentNode->attribute( "ProjectName") ); @@ -65,31 +63,12 @@ XQItem* XQMainModel::addProjectItem( XQNodePtr contentNode ) expandNewItem(section.headerItem().index() ); return newItem; } - - /* - for(const auto& section : _sections ) - { - if( contentNode->attribute(c_ContentType) == section.contentType() ) - { - qDebug() << " --- add PROJECT: contentNode: " << contentNode->to_string(); - - // __fixme! das ist mist! - const XQNodePtr sheetNode = section.sheetRootNode()->first_child(); - XQItem* newItem = _itemFactory.makeSingleItem( sheetNode, contentNode->attribute( "ProjectName") ); - - // den neuen eintrag in die passende section der übersicht eintragen ... - section.headerItem().appendRow( newItem ); - // erzeuger sheet node speichern - newItem->setSheetNode( sheetNode ); - expandNewItem(section.headerItem().index() ); - return newItem; - } - } - */ - throw XQException( "addProjectItem: main model should not be empty!" ); } + +//! erzeugt einen einzelen baum-eintrag mit hilfe der section und den projekt-daten + void XQMainModel::addSectionItem( const XQModelSection& section, XQItem* projectItem ) { XQNodePtr sheetNode = projectItem->sheetNode()->find_child_by_tag_name("CurrentSection"); diff --git a/src/application/xqmainwindow.cpp b/src/application/xqmainwindow.cpp index 511f89f..987e420 100644 --- a/src/application/xqmainwindow.cpp +++ b/src/application/xqmainwindow.cpp @@ -110,7 +110,7 @@ void XQMainWindow::initMainWindow() _mainTreeView->setCurrentIndex( item.index() ); // ... we set the current view to this node if( _documentStore.contains( pID ) ) - _tabWidget->setCurrentWidget( _documentStore[pID].modelView->treeTable() ); + _tabWidget->setCurrentWidget( _documentStore[pID].viewModel->treeTable() ); } ); */ @@ -257,19 +257,7 @@ void XQMainWindow::onAbout() void XQMainWindow::onTreeViewItemClicked( const XQItem& item ) { - /* - _mainTreeView->selectionModel()->select(item.index(), QItemSelectionModel::Select); - - if( XQNodePtr contentNode = item.contentNode() ) - { - QString key = contentNode->attribute(c_ProjectID); - bool isThere = _documentStore.contains(key); - if( isThere) - _tabWidget->setCurrentWidget( _documentStore[key].viewModel->treeTable() ); - } - */ - - qDebug() << " --- Tree item CLICK:" << item.text() << " : " << item.itemType().text(); + //qDebug() << " --- Tree item CLICK:" << item.text() << " : " << item.itemType().text(); if( item.itemType().text() == "TreeChildType" ) { setChildTabByName( item.text() ); @@ -278,7 +266,7 @@ void XQMainWindow::onTreeViewItemClicked( const XQItem& item ) void XQMainWindow::onTreeViewItemChanged(const XQItem& item ) { - qDebug() << " --- TREE VIEW itemChanged:" << item.text() << " : " << item.parent()->text(); + //qDebug() << " --- TREE VIEW itemChanged:" << item.text() << " : " << item.parent()->text(); // hier müssen wir erst das projekt aktivieren XQItem* xqItem = static_cast(item.parent()); onTreeViewItemClicked( *xqItem ); @@ -307,7 +295,7 @@ void XQMainWindow::onChildViewTabClicked( int idx ) } -//! firz +//! SLOT, der aufgerufen wird, sobald eine section erzeugt worden ist. void XQMainWindow::onSectionCreated( const XQModelSection& section ) { @@ -318,16 +306,22 @@ void XQMainWindow::onSectionCreated( const XQModelSection& section ) } } + +//! SLOT, der aufgerufen wird, wenn eine section getoggelt wurde. + void XQMainWindow::onSectionToggled( const XQModelSection& section ) { qDebug() << " --- XXX section toggled: " << section.contentType() << ":" << section.sheetRootNode()->to_string(); } + +//! firz + void XQMainWindow::setChildTabByName( const QString& key ) { for( int i=0; i<_documentStore.size(); ++i ) { - if( key == _documentStore[i].friendlyName) + if( key == _documentStore[i].friendlyName) { _tabWidget->setCurrentIndex(i); return; diff --git a/src/items/xqitemdelegate.cpp b/src/items/xqitemdelegate.cpp index 00925e9..c2a522a 100644 --- a/src/items/xqitemdelegate.cpp +++ b/src/items/xqitemdelegate.cpp @@ -28,7 +28,7 @@ #include -//! firz +//! erzeugt eine editorfactory mit den hauseigenen editortypen. class XQItemEditorFactory : public QItemEditorFactory { @@ -36,43 +36,28 @@ public: XQItemEditorFactory() { - registerEditor(XQItem::LineEditType, new QStandardItemEditorCreator()); - registerEditor(XQItem::ComboBoxType, new QStandardItemEditorCreator()); + registerEditor(XQItem::ComboBoxType, new QStandardItemEditorCreator()); registerEditor(XQItem::PickerType, new QStandardItemEditorCreator()); - registerEditor(XQItem::ProgressBarType, new QStandardItemEditorCreator()); - registerEditor(XQItem::SpinBoxType, new QStandardItemEditorCreator()); + registerEditor(XQItem::ProgressBarType, new QStandardItemEditorCreator()); + registerEditor(XQItem::SpinBoxType, new QStandardItemEditorCreator()); registerEditor(XQItem::CustomEditorType, new QStandardItemEditorCreator()); - -/* - registerEditor(XQItem::LineEditStyle, new QStandardItemEditorCreator()); - registerEditor(XQItemType::ComboBoxStyle, new QStandardItemEditorCreator()); - //registerEditor(XQItemType::ProgressBarStyle, new QStandardItemEditorCreator()); - registerEditor(XQItemType::SpinBoxStyle, new QStandardItemEditorCreator()); - */ - /* - registerEditor(XQItem::etDoubleSpinType, new QStandardItemEditorCreator()); - registerEditor(XQItemItemTypes::etDoubleSpinType, new QStandardItemEditorCreator()); - registerEditor(XQItemItemTypes::etIPAddressType, new QStandardItemEditorCreator()); - registerEditor(XQItemItemTypes::etLineEditBrowser, new QStandardItemEditorCreator()); - */ - } }; -//! firz +//! kontruktor mit dem zusändigen viewModel -XQItemDelegate::XQItemDelegate( XQViewModel& modelView) - : _modelView{modelView} +XQItemDelegate::XQItemDelegate( XQViewModel& viewModel) + : _modelView{viewModel} { static XQItemEditorFactory s_EditorFactory; setItemEditorFactory(&s_EditorFactory); } -//! firz +//! gibt die interne tree table zurück XQTreeTable* XQItemDelegate::treeTable() const { @@ -80,13 +65,15 @@ XQTreeTable* XQItemDelegate::treeTable() const } +//! shortcut: gibt das XQItem für den gegebenen index zurück. + XQItem& XQItemDelegate::xqItemFromIndex( const QModelIndex& index ) const { return _modelView.xqItemFromIndex( index ); } -//! firz +//! überladene paint-methode: zeichnet das item je nach render-style. void XQItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const { @@ -246,11 +233,11 @@ QWidget* XQItemDelegate::createEditor(QWidget* parent, const QStyleOptionViewIte qDebug() << "---- NO Content or NO EditorType"; return nullptr; } - qDebug() << "---- ed type:" << XQItem::fetchEditorTypeToString( edType ) << ": " << edType; - //return QStyledItemDelegate::createEditor( parent, option, index ); - return itemEditorFactory()->createEditor(edType, parent); + QWidget* editor = itemEditorFactory()->createEditor(edType, parent);; + //return QStyledItemDelegate::createEditor( parent, option, index ); + return editor; } diff --git a/src/items/xqitemdelegate.h b/src/items/xqitemdelegate.h index 05b29a5..b4ff029 100644 --- a/src/items/xqitemdelegate.h +++ b/src/items/xqitemdelegate.h @@ -32,7 +32,7 @@ class XQItemDelegate : public QStyledItemDelegate public: - explicit XQItemDelegate(XQViewModel& modelView); + explicit XQItemDelegate(XQViewModel& viewModel); XQTreeTable* treeTable() const; XQItem& xqItemFromIndex( const QModelIndex& index ) const; diff --git a/src/model/xqcommand.cpp b/src/model/xqcommand.cpp index c6081e2..fd79ddc 100644 --- a/src/model/xqcommand.cpp +++ b/src/model/xqcommand.cpp @@ -28,10 +28,10 @@ void XQNodeStore::dumpList( const QString& title ) const } -//! kostruktor. übergibt command-type und die aufrufende modelView. +//! kostruktor. übergibt command-type und die aufrufende viewModel. -XQCommand::XQCommand(CmdType cmdType, XQViewModel* modelView ) - : _cmdType{ cmdType }, _viewModel(modelView) +XQCommand::XQCommand(CmdType cmdType, XQViewModel* viewModel ) + : _cmdType{ cmdType }, _viewModel(viewModel) { } diff --git a/src/model/xqcommand.h b/src/model/xqcommand.h index 607f186..dfb8929 100644 --- a/src/model/xqcommand.h +++ b/src/model/xqcommand.h @@ -66,7 +66,7 @@ public: cmdExtern //?? }; - XQCommand(CmdType cmdType, XQViewModel* modelView ); + XQCommand(CmdType cmdType, XQViewModel* viewModel ); virtual ~XQCommand(); CmdType commandType() const; diff --git a/src/model/xqsectionmanager.cpp b/src/model/xqsectionmanager.cpp index 86b04a0..d52aad0 100644 --- a/src/model/xqsectionmanager.cpp +++ b/src/model/xqsectionmanager.cpp @@ -130,9 +130,6 @@ const XQModelSection& XQSectionManager::sectionByRow(int itemRow ) const if( _sections.size() > 0) { - - // shortcut für die erste position - // wir gehen rückwärts, weil wir da nur einen vergleich brauchen // und uns den test mit lastRow() sparen können. @@ -142,7 +139,6 @@ const XQModelSection& XQSectionManager::sectionByRow(int itemRow ) const if ( _sections.at(i).startIndex().row() < itemRow ) return _sections.at(i); } - } throw XQException( "No section for item row: ", QString::number(itemRow)); diff --git a/src/model/xqviewmodel.cpp b/src/model/xqviewmodel.cpp index 68830e6..14ee0c2 100644 --- a/src/model/xqviewmodel.cpp +++ b/src/model/xqviewmodel.cpp @@ -133,9 +133,7 @@ void XQViewModel::initModel(const QString& modelName) */ setObjectName( modelName ); - qDebug() << " --- initModel: " << objectName(); - - // model rootnode finden -> + // model rootnode finden -> XQNodePtr modelSheet = _itemFactory.findModelSheet( modelName ); // throws // #1: über alle sections @@ -479,6 +477,7 @@ void XQViewModel::cmdDeleteUndo( const XQCommand& command ) { qDebug() << " --- delete UNDo: " << entry.contentNode->friendly_name(); } + cmdCutUndo(command); } diff --git a/src/widgets/xqtreetable.cpp b/src/widgets/xqtreetable.cpp index 4e82e68..ae6f599 100644 --- a/src/widgets/xqtreetable.cpp +++ b/src/widgets/xqtreetable.cpp @@ -38,7 +38,7 @@ XQTreeTable::XQTreeTable(QWidget* parent) //! gibt die verbundene modelview zurück, cast auf 'model()' -XQViewModel* XQTreeTable::modelView() +XQViewModel* XQTreeTable::viewModel() { return static_cast(model()); } @@ -48,7 +48,7 @@ XQViewModel* XQTreeTable::modelView() XQItem& XQTreeTable::xqItemFromIndex(const QModelIndex& index ) { - return modelView()->xqItemFromIndex( index ); + return viewModel()->xqItemFromIndex( index ); } void XQTreeTable::toggleRowsHidden( int fstRow, int lstRow ) diff --git a/src/widgets/xqtreetable.h b/src/widgets/xqtreetable.h index 8f6db0a..5a1cba1 100644 --- a/src/widgets/xqtreetable.h +++ b/src/widgets/xqtreetable.h @@ -38,7 +38,7 @@ public: XQTreeTable(QWidget* parent = nullptr ); virtual ~XQTreeTable() = default; - XQViewModel* modelView(); + XQViewModel* viewModel(); XQItem& xqItemFromIndex(const QModelIndex& index ); void toggleRowsHidden(int fstRow, int lstRow );