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 )
{
// __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;

View File

@@ -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");

View File

@@ -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<XQItem*>(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;

View File

@@ -28,7 +28,7 @@
#include <xqviewmodel.h>
//! firz
//! erzeugt eine editorfactory mit den hauseigenen editortypen.
class XQItemEditorFactory : public QItemEditorFactory
{
@@ -36,43 +36,28 @@ public:
XQItemEditorFactory()
{
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::ProgressBarType, new QStandardItemEditorCreator<QLineEdit>());
registerEditor(XQItem::SpinBoxType, new QStandardItemEditorCreator<QLineEdit>());
registerEditor(XQItem::ProgressBarType, new QStandardItemEditorCreator<QProgressBar>());
registerEditor(XQItem::SpinBoxType, new QStandardItemEditorCreator<QSpinBox>());
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)
: _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;
}

View File

@@ -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;

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

View File

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

View File

@@ -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));

View File

@@ -133,9 +133,7 @@ void XQViewModel::initModel(const QString& modelName)
*/
setObjectName( modelName );
qDebug() << " --- initModel: " << objectName();
// model rootnode finden -> <DocumentTreeModel>
// model rootnode finden -> <DocumentTreeModel>
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);
}

View File

@@ -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<XQViewModel*>(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 )

View File

@@ -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 );