fixed delete undo.

This commit is contained in:
2025-09-07 15:46:01 +02:00
parent 50703a4c44
commit 3ac129ef26
11 changed files with 40 additions and 86 deletions

View File

@@ -36,9 +36,8 @@ XQChildModel::XQChildModel( QObject *parent )
void XQChildModel::addModelData( const XQNodePtr& contentRoot ) void XQChildModel::addModelData( const XQNodePtr& contentRoot )
{ {
// __fix: set object name ?? setObjectName( contentRoot->to_string() );
//qDebug() << " --- create Model Data: " << contentRoot->to_string();
qDebug() << " --- create Model Data: " << contentRoot->to_string();
// Die Datenbasis als shared_ptr sichern // Die Datenbasis als shared_ptr sichern
_contentRoot = contentRoot; _contentRoot = contentRoot;

View File

@@ -52,8 +52,6 @@ XQItem* XQMainModel::addProjectItem( XQNodePtr contentNode )
if( _sections.hasValidSection( sectionKey ) ) if( _sections.hasValidSection( sectionKey ) )
{ {
const XQModelSection& section = _sections.sectionByKey( sectionKey ); const XQModelSection& section = _sections.sectionByKey( sectionKey );
qDebug() << " --- add PROJECT: contentNode: " << contentNode->to_string();
// __fixme! das ist mist! // __fixme! das ist mist!
const XQNodePtr sheetNode = section.sheetRootNode()->first_child(); const XQNodePtr sheetNode = section.sheetRootNode()->first_child();
XQItem* newItem = _itemFactory.makeSingleItem( sheetNode, contentNode->attribute( "ProjectName") ); XQItem* newItem = _itemFactory.makeSingleItem( sheetNode, contentNode->attribute( "ProjectName") );
@@ -65,31 +63,12 @@ XQItem* XQMainModel::addProjectItem( XQNodePtr contentNode )
expandNewItem(section.headerItem().index() ); expandNewItem(section.headerItem().index() );
return newItem; 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!" ); 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 ) void XQMainModel::addSectionItem( const XQModelSection& section, XQItem* projectItem )
{ {
XQNodePtr sheetNode = projectItem->sheetNode()->find_child_by_tag_name("CurrentSection"); XQNodePtr sheetNode = projectItem->sheetNode()->find_child_by_tag_name("CurrentSection");

View File

@@ -110,7 +110,7 @@ void XQMainWindow::initMainWindow()
_mainTreeView->setCurrentIndex( item.index() ); _mainTreeView->setCurrentIndex( item.index() );
// ... we set the current view to this node // ... we set the current view to this node
if( _documentStore.contains( pID ) ) 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 ) void XQMainWindow::onTreeViewItemClicked( const XQItem& item )
{ {
/* //qDebug() << " --- Tree item CLICK:" << item.text() << " : " << item.itemType().text();
_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();
if( item.itemType().text() == "TreeChildType" ) if( item.itemType().text() == "TreeChildType" )
{ {
setChildTabByName( item.text() ); setChildTabByName( item.text() );
@@ -278,7 +266,7 @@ void XQMainWindow::onTreeViewItemClicked( const XQItem& item )
void XQMainWindow::onTreeViewItemChanged(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 // hier müssen wir erst das projekt aktivieren
XQItem* xqItem = static_cast<XQItem*>(item.parent()); XQItem* xqItem = static_cast<XQItem*>(item.parent());
onTreeViewItemClicked( *xqItem ); 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 ) void XQMainWindow::onSectionCreated( const XQModelSection& section )
{ {
@@ -318,11 +306,17 @@ void XQMainWindow::onSectionCreated( const XQModelSection& section )
} }
} }
//! SLOT, der aufgerufen wird, wenn eine section getoggelt wurde.
void XQMainWindow::onSectionToggled( const XQModelSection& section ) void XQMainWindow::onSectionToggled( const XQModelSection& section )
{ {
qDebug() << " --- XXX section toggled: " << section.contentType() << ":" << section.sheetRootNode()->to_string(); qDebug() << " --- XXX section toggled: " << section.contentType() << ":" << section.sheetRootNode()->to_string();
} }
//! firz
void XQMainWindow::setChildTabByName( const QString& key ) void XQMainWindow::setChildTabByName( const QString& key )
{ {
for( int i=0; i<_documentStore.size(); ++i ) for( int i=0; i<_documentStore.size(); ++i )

View File

@@ -28,7 +28,7 @@
#include <xqviewmodel.h> #include <xqviewmodel.h>
//! firz //! erzeugt eine editorfactory mit den hauseigenen editortypen.
class XQItemEditorFactory : public QItemEditorFactory class XQItemEditorFactory : public QItemEditorFactory
{ {
@@ -36,43 +36,28 @@ public:
XQItemEditorFactory() XQItemEditorFactory()
{ {
registerEditor(XQItem::LineEditType, new QStandardItemEditorCreator<QLineEdit>()); registerEditor(XQItem::LineEditType, new QStandardItemEditorCreator<QLineEdit>());
registerEditor(XQItem::ComboBoxType, new QStandardItemEditorCreator<QLineEdit>()); registerEditor(XQItem::ComboBoxType, new QStandardItemEditorCreator<QComboBox>());
registerEditor(XQItem::PickerType, new QStandardItemEditorCreator<QLineEdit>()); registerEditor(XQItem::PickerType, new QStandardItemEditorCreator<QLineEdit>());
registerEditor(XQItem::ProgressBarType, new QStandardItemEditorCreator<QLineEdit>()); registerEditor(XQItem::ProgressBarType, new QStandardItemEditorCreator<QProgressBar>());
registerEditor(XQItem::SpinBoxType, new QStandardItemEditorCreator<QLineEdit>()); registerEditor(XQItem::SpinBoxType, new QStandardItemEditorCreator<QSpinBox>());
registerEditor(XQItem::CustomEditorType, new QStandardItemEditorCreator<QLineEdit>()); registerEditor(XQItem::CustomEditorType, new QStandardItemEditorCreator<QLineEdit>());
/*
registerEditor(XQItem::LineEditStyle, new QStandardItemEditorCreator<QLineEdit>());
registerEditor(XQItemType::ComboBoxStyle, new QStandardItemEditorCreator<QComboBox>());
//registerEditor(XQItemType::ProgressBarStyle, new QStandardItemEditorCreator<QProgressBar>());
registerEditor(XQItemType::SpinBoxStyle, new QStandardItemEditorCreator<QSpinBox>());
*/
/*
registerEditor(XQItem::etDoubleSpinType, new QStandardItemEditorCreator<QDoubleSpinBox>());
registerEditor(XQItemItemTypes::etDoubleSpinType, new QStandardItemEditorCreator<QDoubleSpinBox>());
registerEditor(XQItemItemTypes::etIPAddressType, new QStandardItemEditorCreator<NTIpAddressEdit>());
registerEditor(XQItemItemTypes::etLineEditBrowser, new QStandardItemEditorCreator<NTFileSelectLine>());
*/
} }
}; };
//! firz //! kontruktor mit dem zusändigen viewModel
XQItemDelegate::XQItemDelegate( XQViewModel& modelView) XQItemDelegate::XQItemDelegate( XQViewModel& viewModel)
: _modelView{modelView} : _modelView{viewModel}
{ {
static XQItemEditorFactory s_EditorFactory; static XQItemEditorFactory s_EditorFactory;
setItemEditorFactory(&s_EditorFactory); setItemEditorFactory(&s_EditorFactory);
} }
//! firz //! gibt die interne tree table zurück
XQTreeTable* XQItemDelegate::treeTable() const 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 XQItem& XQItemDelegate::xqItemFromIndex( const QModelIndex& index ) const
{ {
return _modelView.xqItemFromIndex( index ); 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 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"; qDebug() << "---- NO Content or NO EditorType";
return nullptr; return nullptr;
} }
qDebug() << "---- ed type:" << XQItem::fetchEditorTypeToString( edType ) << ": " << edType; 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;
} }

View File

@@ -32,7 +32,7 @@ class XQItemDelegate : public QStyledItemDelegate
public: public:
explicit XQItemDelegate(XQViewModel& modelView); explicit XQItemDelegate(XQViewModel& viewModel);
XQTreeTable* treeTable() const; XQTreeTable* treeTable() const;
XQItem& xqItemFromIndex( const QModelIndex& index ) const; XQItem& xqItemFromIndex( const QModelIndex& index ) const;

View File

@@ -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 ) XQCommand::XQCommand(CmdType cmdType, XQViewModel* viewModel )
: _cmdType{ cmdType }, _viewModel(modelView) : _cmdType{ cmdType }, _viewModel(viewModel)
{ {
} }

View File

@@ -66,7 +66,7 @@ public:
cmdExtern //?? cmdExtern //??
}; };
XQCommand(CmdType cmdType, XQViewModel* modelView ); XQCommand(CmdType cmdType, XQViewModel* viewModel );
virtual ~XQCommand(); virtual ~XQCommand();
CmdType commandType() const; CmdType commandType() const;

View File

@@ -130,9 +130,6 @@ const XQModelSection& XQSectionManager::sectionByRow(int itemRow ) const
if( _sections.size() > 0) if( _sections.size() > 0)
{ {
// shortcut für die erste position
// wir gehen rückwärts, weil wir da nur einen vergleich brauchen // wir gehen rückwärts, weil wir da nur einen vergleich brauchen
// und uns den test mit lastRow() sparen können. // 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 ) if ( _sections.at(i).startIndex().row() < itemRow )
return _sections.at(i); return _sections.at(i);
} }
} }
throw XQException( "No section for item row: ", QString::number(itemRow)); throw XQException( "No section for item row: ", QString::number(itemRow));

View File

@@ -133,8 +133,6 @@ void XQViewModel::initModel(const QString& modelName)
*/ */
setObjectName( modelName ); setObjectName( modelName );
qDebug() << " --- initModel: " << objectName();
// model rootnode finden -> <DocumentTreeModel> // model rootnode finden -> <DocumentTreeModel>
XQNodePtr modelSheet = _itemFactory.findModelSheet( modelName ); // throws XQNodePtr modelSheet = _itemFactory.findModelSheet( modelName ); // throws
@@ -479,6 +477,7 @@ void XQViewModel::cmdDeleteUndo( const XQCommand& command )
{ {
qDebug() << " --- delete UNDo: " << entry.contentNode->friendly_name(); qDebug() << " --- delete UNDo: " << entry.contentNode->friendly_name();
} }
cmdCutUndo(command);
} }

View File

@@ -38,7 +38,7 @@ XQTreeTable::XQTreeTable(QWidget* parent)
//! gibt die verbundene modelview zurück, cast auf 'model()' //! gibt die verbundene modelview zurück, cast auf 'model()'
XQViewModel* XQTreeTable::modelView() XQViewModel* XQTreeTable::viewModel()
{ {
return static_cast<XQViewModel*>(model()); return static_cast<XQViewModel*>(model());
} }
@@ -48,7 +48,7 @@ XQViewModel* XQTreeTable::modelView()
XQItem& XQTreeTable::xqItemFromIndex(const QModelIndex& index ) XQItem& XQTreeTable::xqItemFromIndex(const QModelIndex& index )
{ {
return modelView()->xqItemFromIndex( index ); return viewModel()->xqItemFromIndex( index );
} }
void XQTreeTable::toggleRowsHidden( int fstRow, int lstRow ) void XQTreeTable::toggleRowsHidden( int fstRow, int lstRow )

View File

@@ -38,7 +38,7 @@ public:
XQTreeTable(QWidget* parent = nullptr ); XQTreeTable(QWidget* parent = nullptr );
virtual ~XQTreeTable() = default; virtual ~XQTreeTable() = default;
XQViewModel* modelView(); XQViewModel* viewModel();
XQItem& xqItemFromIndex(const QModelIndex& index ); XQItem& xqItemFromIndex(const QModelIndex& index );
void toggleRowsHidden(int fstRow, int lstRow ); void toggleRowsHidden(int fstRow, int lstRow );