From d70df0cbaa35189a5ed1d70cb1e1c8cee9ce2435 Mon Sep 17 00:00:00 2001 From: "PANIK\\chris" Date: Thu, 7 Aug 2025 10:39:42 +0200 Subject: [PATCH] major 'firzifikation' --- src/application/xqchildmodel.cpp | 4 +- src/application/xqmainmodel.cpp | 4 +- src/application/xqmainwindow.cpp | 8 +-- src/items/xqitem.cpp | 28 ++++++---- src/items/xqitem.h | 26 ++++----- src/items/xqitemdelegate.cpp | 6 +-- src/items/xqitemdelegate.h | 2 +- src/main.cpp | 1 - src/model/xqcommand.cpp | 14 +++++ src/model/xqmodelsections.cpp | 10 ++++ src/model/xqnode.cpp | 18 ++++++- src/model/xqnodewriter.cpp | 5 ++ src/model/xqselectionmodel.cpp | 11 ++-- src/model/xqsimpleclipboard.cpp | 4 ++ src/model/xqviewmodel.cpp | 90 ++++++++++++++++++++++++-------- src/model/xqviewmodel.h | 6 +-- src/nodes/znode.cpp | 3 ++ src/util/xqexception.cpp | 2 + src/widgets/xqcontextmenu.cpp | 12 ++++- src/widgets/xqtreetable.cpp | 25 +++++++-- src/widgets/xqtreetable.h | 9 ++-- 21 files changed, 208 insertions(+), 80 deletions(-) diff --git a/src/application/xqchildmodel.cpp b/src/application/xqchildmodel.cpp index 42bb2ab..1d988fe 100644 --- a/src/application/xqchildmodel.cpp +++ b/src/application/xqchildmodel.cpp @@ -127,8 +127,8 @@ void XQChildModel::initContextMenu() // __fixme! add a menu title _contextMenu->clear(); - const QModelIndex& curIdx = _treeView->currentIndex(); - bool hasSel = curIdx.isValid() && _treeView->selectionModel()->hasSelection(); + const QModelIndex& curIdx = _treeTable->currentIndex(); + bool hasSel = curIdx.isValid() && _treeTable->selectionModel()->hasSelection(); bool canPaste = _clipBoard.canPaste( curIdx ); _contextMenu->addAction( "icn11Dummy", "Undo", XQCommand::cmdUndo, _undoStack->canUndo() ); diff --git a/src/application/xqmainmodel.cpp b/src/application/xqmainmodel.cpp index a61a953..b5f5a00 100644 --- a/src/application/xqmainmodel.cpp +++ b/src/application/xqmainmodel.cpp @@ -64,9 +64,9 @@ XQItem* XQMainModel::createTreeEntry( XQNodePtr contentNode ) { XQItem* newTreeentry = _itemFactory.makeContentItem( contentNode, section.sheetRootNode ); section.headerItem().appendRow( newTreeentry ); - _treeView->expand( section.modelIndex ); + _treeTable->expand( section.modelIndex ); // ?? - _treeView->setCurrentIndex( section.modelIndex ); + _treeTable->setCurrentIndex( section.modelIndex ); newTreeentry->setContentNode(contentNode); emit xqItemCreated( newTreeentry ); return newTreeentry; diff --git a/src/application/xqmainwindow.cpp b/src/application/xqmainwindow.cpp index 0fe9115..687e910 100644 --- a/src/application/xqmainwindow.cpp +++ b/src/application/xqmainwindow.cpp @@ -70,7 +70,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->treeView() ); + _tabWidget->setCurrentWidget( _documentStore[pID].modelView->treeTable() ); } ); try @@ -78,7 +78,7 @@ void XQMainWindow::initMainWindow() // hand over undostack _mainModelView.setUndoStack(&_undoStack); // hand over left side navigation tree - _mainModelView.setTreeView(_mainTreeView); + _mainModelView.setTreeTable(_mainTreeView); // #1. init the left side main tree view _mainModelView.initModel( c_MainModelName ); @@ -203,7 +203,7 @@ void XQMainWindow::onTreeItemClicked(const QModelIndex& index ) QString key = entry.attribute(c_ProjectID); if( _documentStore.contains(key) ) - _tabWidget->setCurrentWidget( _documentStore[key].modelView->treeView() ); + _tabWidget->setCurrentWidget( _documentStore[key].modelView->treeTable() ); } @@ -259,7 +259,7 @@ void XQMainWindow::loadDocument( const QString& fileName ) // Den globalen undo-stack ... childModel->setUndoStack(&_undoStack); // und die TreeView übergeben - childModel->setTreeView(childTreeView); + childModel->setTreeTable(childTreeView); // read the model data childModel->setContent( contentRoot->first_child() ); diff --git a/src/items/xqitem.cpp b/src/items/xqitem.cpp index 631508a..dc49f91 100644 --- a/src/items/xqitem.cpp +++ b/src/items/xqitem.cpp @@ -144,7 +144,7 @@ XQItem::XQItem(XQItemType* itemType, const QString *content, const XQNodePtr& co } - +/* XQItem::XQItem(const XQItem& other) : QStandardItem( other ) { @@ -152,17 +152,22 @@ XQItem::XQItem(const XQItem& other) // die data() struktur } +XQItem& XQItem::operator=(const XQItem& other) +{ + if( this != &other) + { + // kopiert data() + this->QStandardItem::operator=( other ); + } + return *this; +} +*/ //! firz XQItem::~XQItem() { - // fixed choices lebt im item type, also - // im parent - //QAbstractItemModel* model = fixedChoices(); - //if( model ) - // delete model; } @@ -178,12 +183,13 @@ XQItem* XQItem::clone() const } -//! firz +//! false für ein ungültiges item. 'ungültig' heisst hier, dass nur ein +//! mockup-itemtype gesetzt ist. bool XQItem::isValid() const { - // fragwürdig - return QStandardItem::data( XQItem::ItemTypeRole ).value() != nullptr; + XQItemType* dummyType = XQItemType::staticItemType(); + return QStandardItem::data( XQItem::ItemTypeRole ).value() != dummyType; } @@ -429,12 +435,14 @@ QString XQItem::fixedChoicesToString() const } //! setzt das auswahl-model für read-only comboboxes + void XQItem::setfixedChoices( QStandardItemModel* newModel ) { setData( QVariant::fromValue(newModel), XQItem::FixedChoicesRole); } //! true, wenn 'ich' ein header item bin + bool XQItem::isHeaderStyle() { return renderStyle() == XQItem::HeaderStyle; @@ -442,6 +450,7 @@ bool XQItem::isHeaderStyle() //! gibt den namen der datarole zurück + QString XQItem::dataRoleName(int role) { if( role < XQItem::NoRole && model() ) @@ -451,6 +460,7 @@ QString XQItem::dataRoleName(int role) //! angespasste variante von qstandarditem::setData. geteilte attribute //! werden vom xqitemtype geholt + QVariant XQItem::data(int role ) const { //emitDataChanged() diff --git a/src/items/xqitem.h b/src/items/xqitem.h index 1d51a91..d499295 100644 --- a/src/items/xqitem.h +++ b/src/items/xqitem.h @@ -125,16 +125,12 @@ public: }; - //XQItem(int rows, int columns = 1); XQItem(); XQItem( XQItemType* itemType ); XQItem( XQItemType* itemType, const QString* content ); XQItem( XQItemType* itemType, const QString* content, const XQNodePtr& contentNode ); - XQItem(const XQItem& other); - XQItem(const QStandardItem& other); - virtual ~XQItem(); //! creates not a clone but a new default item, \see QStandardItemModel::setItemPrototype() @@ -184,7 +180,6 @@ public: QString renderStyleToString() const; void setRenderStyle(RenderStyle renderStyle ); - //! fitze FATZE! EditorType editorType() const; QString editorTypeToString() const; void setEditorType(EditorType editorType); @@ -195,9 +190,11 @@ public: QString contentFormat() const; void setContentFormat(const QString& contentFormat); - QStandardItemModel* fixedChoices() const; - QString fixedChoicesToString() const; + + QString fixedChoicesToString() const; + + //! setzt das auswahl-model für read-only comboboxes void setfixedChoices( QStandardItemModel* newModel ); // @@ -205,20 +202,11 @@ public: // bool isHeaderStyle(); - - //! gibt den namen der datarole zurück QString dataRoleName(int role); - //! angespasste variante von qstandarditem::data QVariant data(int role = Qt::DisplayRole ) const override; - - //! angespasste variante von qstandarditem::setData void setData(const QVariant &value, int role ) override; - // Das sind die die items im tree links: icon,text, node pointer - //XQItem( const QString& text, XQNodePtr contentNode ); - //XQItem( const QString& text, XQItemType::RenderStyle renderStyle ); - /* template void setToVariant(T entry, QtExtUserRoles::NTDataRoles role) @@ -254,6 +242,9 @@ public: protected: + XQItem(const XQItem& other) = default; + XQItem& operator=(const XQItem& other) = default; + using XQItemFlagMap = QMap; using XQItemDataRoleMap = QMap; using XQRenderStyleMap = QMap; @@ -268,6 +259,9 @@ protected: static XQUnitTypeMap s_UnitTypeMap; static XQPrefixExponentMap s_PrefixExponentMap; + //! leerer itemtype als mockup für den xqitem default constructor + static XQItemType s_DummyItemType; + }; Q_DECLARE_METATYPE(XQItem::RenderStyle); diff --git a/src/items/xqitemdelegate.cpp b/src/items/xqitemdelegate.cpp index 62513ea..6fbc9b7 100644 --- a/src/items/xqitemdelegate.cpp +++ b/src/items/xqitemdelegate.cpp @@ -69,9 +69,9 @@ XQItemDelegate::XQItemDelegate( XQViewModel& modelView) } -XQTreeTable* XQItemDelegate::treeView() const +XQTreeTable* XQItemDelegate::treeTable() const { - return _modelView.treeView(); + return _modelView.treeTable(); } @@ -85,7 +85,7 @@ XQItem& XQItemDelegate::xqItemFromIndex( const QModelIndex& index ) const QWidget* XQItemDelegate::prepareHeaderOption(const QStyleOptionViewItem& option, const QModelIndex& index, QStyleOptionHeader& headerOption) const { // use the header as "parent" for style init - QWidget* srcWidget = treeView()->header(); + QWidget* srcWidget = treeTable()->header(); headerOption.initFrom(srcWidget); headerOption.text = index.data(Qt::DisplayRole).toString(); headerOption.rect = option.rect; diff --git a/src/items/xqitemdelegate.h b/src/items/xqitemdelegate.h index a51b692..bc3c46b 100644 --- a/src/items/xqitemdelegate.h +++ b/src/items/xqitemdelegate.h @@ -34,7 +34,7 @@ public: explicit XQItemDelegate(XQViewModel& modelView); - XQTreeTable* treeView() const; + XQTreeTable* treeTable() const; XQItem& xqItemFromIndex( const QModelIndex& index ) const; void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override; diff --git a/src/main.cpp b/src/main.cpp index 073c367..819e40c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -53,7 +53,6 @@ int main(int argc, char *argv[]) { QApplication app(argc, argv); - //qDebug() << " lebt"; //app.setStyle("fusion"); XQMainWindow window; diff --git a/src/model/xqcommand.cpp b/src/model/xqcommand.cpp index f724e6f..cf2b343 100644 --- a/src/model/xqcommand.cpp +++ b/src/model/xqcommand.cpp @@ -17,6 +17,8 @@ #include +//! firz + void XQNodeStore::dumpList( const QString& title ) const { if( !title.isEmpty() ) @@ -26,23 +28,34 @@ void XQNodeStore::dumpList( const QString& title ) const } +//! firz + XQCommand::XQCommand(CmdType cmdType, XQViewModel* modelView ) : _cmdType{ cmdType }, _model(modelView) { } + +//! firz + XQCommand::~XQCommand() { qDebug() << " --- command destructor: " << toString(); } + +//! firz + XQCommand::CmdType XQCommand::commandType() const { return _cmdType; } + +//! firz + void XQCommand::setCommandType( XQCommand::CmdType cmdType ) { _cmdType = cmdType; @@ -105,6 +118,7 @@ void XQCommand::saveNodes( const QModelIndexList& list ) } } + //! erzeugt einen string aus dem command-type, fürs debuggen. QString XQCommand::toString() diff --git a/src/model/xqmodelsections.cpp b/src/model/xqmodelsections.cpp index 6916baf..f1e456d 100644 --- a/src/model/xqmodelsections.cpp +++ b/src/model/xqmodelsections.cpp @@ -16,6 +16,8 @@ #include +//! firz + XQModelSection::XQModelSection(const QModelIndex& aModelIndex, XQNodePtr aSheetNode) : modelIndex{ aModelIndex }, sheetRootNode{ aSheetNode } { @@ -23,24 +25,32 @@ XQModelSection::XQModelSection(const QModelIndex& aModelIndex, XQNodePtr aSheetN } +//! firz + bool XQModelSection::operator==(const XQModelSection& other) const { return modelIndex == other.modelIndex && sheetRootNode == other.sheetRootNode; } +//! firz + bool XQModelSection::isValid() const { return modelIndex.isValid() && sheetRootNode; } +//! firz + int XQModelSection::XQModelSection::row() const { return modelIndex.row(); } +//! firz + XQItem& XQModelSection::XQModelSection::headerItem() const { return XQItem::xqItemFromIndex( modelIndex ); diff --git a/src/model/xqnode.cpp b/src/model/xqnode.cpp index db11e03..e310d13 100644 --- a/src/model/xqnode.cpp +++ b/src/model/xqnode.cpp @@ -17,6 +17,9 @@ + +//! firz + void inspect( const XQNodePtr& node, int indent ) { qDebug() << std::string(indent * 2, ' ').c_str() << node.use_count() << ": " << node->to_string(); @@ -31,6 +34,10 @@ void inspect( const XQNodePtr& node, int indent ) } + + +//! firz + // Overload the operator<< for MyClass and std::ostream std::ostream& operator<<(std::ostream& os, const QString& obj) { @@ -40,8 +47,7 @@ std::ostream& operator<<(std::ostream& os, const QString& obj) } - - +//! firz template<> bool znode::zpayload::xstr_split_by(const QString& entry, const QString& sep, QString& key, QString& value ) { @@ -53,12 +59,18 @@ bool znode::zpayload::xstr_split_by(const QString& entry, const QString return true; } + +//! firz + template<> QString znode::zpayload::xstr_sub_str( const QString& entry, int pos ) const { return entry.mid(pos); } + +//! firz + template<> bool znode::zpayload::xstr_is_empty(const QString& entry ) const { @@ -66,6 +78,8 @@ bool znode::zpayload::xstr_is_empty(const QString& entry ) const } +//! firz + template<> const QString znode::zpayload::cType = "Type"; diff --git a/src/model/xqnodewriter.cpp b/src/model/xqnodewriter.cpp index 4a6854c..185702d 100644 --- a/src/model/xqnodewriter.cpp +++ b/src/model/xqnodewriter.cpp @@ -20,6 +20,10 @@ #include + + +//! firz + void XQNodeWriter::dumpTree( XQNodePtr rootNode, const QString& fileName ) const { QFile treeFile( fileName ); @@ -36,6 +40,7 @@ void XQNodeWriter::dumpTree( XQNodePtr rootNode, const QString& fileName ) const treeFile.close(); } +//! firz void XQNodeWriter::dumpNode( QXmlStreamWriter& writer, XQNodePtr node ) const { diff --git a/src/model/xqselectionmodel.cpp b/src/model/xqselectionmodel.cpp index 5edaa0b..b829604 100644 --- a/src/model/xqselectionmodel.cpp +++ b/src/model/xqselectionmodel.cpp @@ -15,12 +15,19 @@ #include #include + + +//! firz + XQSelectionModel::XQSelectionModel(QAbstractItemModel* model) : QItemSelectionModel(model) { } + +//! firz + XQSelectionModel::XQSelectionModel(QAbstractItemModel* model, QObject* parent) : QItemSelectionModel(model, parent) { @@ -28,6 +35,7 @@ XQSelectionModel::XQSelectionModel(QAbstractItemModel* model, QObject* parent) } +//! firz void XQSelectionModel::select(const QItemSelection& selection, QItemSelectionModel::SelectionFlags command) { @@ -58,8 +66,5 @@ void XQSelectionModel::select(const QItemSelection& selection, QItemSelectionMod } return QItemSelectionModel::select(newSelection, command); } - - QItemSelectionModel::select(selection, command); - } diff --git a/src/model/xqsimpleclipboard.cpp b/src/model/xqsimpleclipboard.cpp index b9c7119..3f15017 100644 --- a/src/model/xqsimpleclipboard.cpp +++ b/src/model/xqsimpleclipboard.cpp @@ -16,6 +16,8 @@ #include +//! firz + bool XQSimpleClipBoard::canPaste( const QModelIndex& curIdx ) const { bool pasteOk = false; @@ -36,6 +38,8 @@ bool XQSimpleClipBoard::canPaste( const QModelIndex& curIdx ) const } +//! firz + void XQSimpleClipBoard::saveNodes( const QModelIndexList& list ) { clear(); diff --git a/src/model/xqviewmodel.cpp b/src/model/xqviewmodel.cpp index c68a193..9220aae 100644 --- a/src/model/xqviewmodel.cpp +++ b/src/model/xqviewmodel.cpp @@ -30,6 +30,8 @@ //Q_GLOBAL_STATIC(XQItem,s_dummyItem) +//! firz + void showItemList( const XQItemList& list) { for(const auto& entry : list ) @@ -38,11 +40,15 @@ void showItemList( const XQItemList& list) } +//! firz + XQViewModel::~XQViewModel() { } +//! firz + XQViewModel::XQViewModel( QObject* parent ) : QStandardItemModel{ parent }, _itemFactory{ XQItemFactory::instance() } { @@ -51,6 +57,8 @@ XQViewModel::XQViewModel( QObject* parent ) } +//! firz + const XQItem& XQViewModel::xqRootItem() { // das ist ein hack, denn 'invisibleRootItem()' ist und bleibt ein @@ -62,6 +70,8 @@ const XQItem& XQViewModel::xqRootItem() } +//! firz + XQItem& XQViewModel::xqItemFromIndex(const QModelIndex& index) const { if( index.isValid() ) @@ -73,17 +83,21 @@ XQItem& XQViewModel::xqItemFromIndex(const QModelIndex& index) const return XQItem::fallBackDummyItem(); } +//! firz + XQItem& XQViewModel::xqFirstItem(int row) const { return *static_cast( QStandardItemModel::item(row) ); } +//! firz + void XQViewModel::onActionTriggered(QAction* action) { qDebug() << " --- onActionTriggered: count:" << XQNode::s_Count; // all selected indices - QModelIndexList selectionList = treeView()->selectionModel()->selectedRows(); + QModelIndexList selectionList = treeTable()->selectionModel()->selectedRows(); // extract command type XQCommand::CmdType cmdType = action->data().value(); @@ -115,7 +129,7 @@ void XQViewModel::onActionTriggered(QAction* action) XQCommand* command = new XQCommand( cmdType, this ); // store the row positions of the selected indices command->saveNodes( selectionList ); - command->setOriginIndex( treeView()->currentIndex() ); + command->setOriginIndex( treeTable()->currentIndex() ); // execute command _undoStack->push( command ); @@ -129,6 +143,8 @@ void XQViewModel::onActionTriggered(QAction* action) * @param command the current command */ +//! firz + void XQViewModel::onCommandRedo( XQCommand& command ) { try @@ -171,6 +187,8 @@ void XQViewModel::onCommandRedo( XQCommand& command ) * @param command the command to be undone. */ +//! firz + void XQViewModel::onCommandUndo( XQCommand& command ) { qDebug() << " --- onCommandUndo: count: " << XQNode::s_Count; @@ -220,6 +238,7 @@ void XQViewModel::onCommandUndo( XQCommand& command ) // undo-/redo-able stuff //! markierte knoten entfernen, 'command' enthält die liste + void XQViewModel::cmdCut( XQCommand& command ) { // wir gehen rückwärts über alle gemerkten knoten ... @@ -265,7 +284,7 @@ void XQViewModel::cmdCutUndo( XQCommand& command ) void XQViewModel::cmdPaste( XQCommand& command ) { // selection holen ... - QItemSelectionModel* selectionModel = treeView()->selectionModel(); + QItemSelectionModel* selectionModel = treeTable()->selectionModel(); // ... und löschen selectionModel->clearSelection(); @@ -289,7 +308,7 @@ void XQViewModel::cmdPaste( XQCommand& command ) insertRow( insRow, list ); // die neue item-row selektieren const QModelIndex& selIdx = list[0]->index(); - _treeView->selectionModel()->select(selIdx, QItemSelectionModel::Select | QItemSelectionModel::Rows); + _treeTable->selectionModel()->select(selIdx, QItemSelectionModel::Select | QItemSelectionModel::Rows); // zur nächsten zeile insRow++; nodePos++; @@ -322,6 +341,8 @@ void XQViewModel::cmdPasteUndo( XQCommand& command ) // don't clone into clipboard, remove items +//! firz + void XQViewModel::cmdDelete( XQCommand& command ) { // wir gehen rückwärts über alle markieren knoten ... @@ -337,6 +358,8 @@ void XQViewModel::cmdDelete( XQCommand& command ) } } +//! firz + void XQViewModel::cmdDeleteUndo( XQCommand& command ) { @@ -348,6 +371,8 @@ void XQViewModel::cmdDeleteUndo( XQCommand& command ) * @param command the command */ +//! firz + void XQViewModel::cmdNew( XQCommand& command ) { @@ -376,17 +401,21 @@ void XQViewModel::cmdNew( XQCommand& command ) insertRow( origin.row(), list ); // ... and make it ... - treeView()->setCurrentIndex( list[0]->index() ); + treeTable()->setCurrentIndex( list[0]->index() ); // ... editable - treeView()->edit( list[0]->index() ); + treeTable()->edit( list[0]->index() ); */ } +//! firz + void XQViewModel::cmdNewUndo( XQCommand& command ) { } +//! firz + void XQViewModel::cmdToggleSection( const QModelIndex& index ) { Q_ASSERT(index.isValid()); @@ -394,31 +423,35 @@ void XQViewModel::cmdToggleSection( const QModelIndex& index ) int fstRow = _sections.firstRow( index ); int lstRow = _sections.lastRow( index ); - bool hidden =_treeView->isRowHidden( fstRow, _treeView->rootIndex() ); + bool hidden =_treeTable->isRowHidden( fstRow, _treeTable->rootIndex() ); for (int row = fstRow; row < lstRow; ++row ) - _treeView->setRowHidden( row, _treeView->rootIndex(), !hidden ); + _treeTable->setRowHidden( row, _treeTable->rootIndex(), !hidden ); } -XQTreeTable* XQViewModel::treeView() +//! firz + +XQTreeTable* XQViewModel::treeTable() { - return _treeView; + return _treeTable; } -void XQViewModel::setTreeView(XQTreeTable* mainView ) +//! firz + +void XQViewModel::setTreeTable(XQTreeTable* mainView ) { // store view for direct access: the maintree - _treeView = mainView; + _treeTable = mainView; // connect myself as model to the mainview - _treeView->setModel(this); + _treeTable->setModel(this); XQItemDelegate* delegate = new XQItemDelegate( *this ); - _treeView->setItemDelegate( delegate ); + _treeTable->setItemDelegate( delegate ); _contextMenu = new XQContextMenu( mainView ); - connect( _treeView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(onShowContextMenu(QPoint))); - //connect( _treeView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(onDoubleClicked(QModelIndex)) ); + connect( _treeTable, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(onShowContextMenu(QPoint))); + //connect( _treeTable, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(onDoubleClicked(QModelIndex)) ); connect(_contextMenu, SIGNAL(triggered(QAction*)), this, SLOT(onActionTriggered(QAction*))); // __fixme, die view soll über das modelsheet konfiguriert werden! @@ -430,17 +463,21 @@ void XQViewModel::setTreeView(XQTreeTable* mainView ) * edit triggers and so on. */ +//! firz + void XQViewModel::setupViewProperties() { - _treeView->setContextMenuPolicy(Qt::CustomContextMenu); - _treeView->setEditTriggers(QAbstractItemView::DoubleClicked | QAbstractItemView::EditKeyPressed); - _treeView->setSelectionBehavior(QAbstractItemView::SelectRows); - _treeView->setSelectionMode(QAbstractItemView::ExtendedSelection); - //_treeView->setSelectionMode(QAbstractItemView::ContiguousSelection); - _treeView->setSelectionModel( new XQSelectionModel(this) ); + _treeTable->setContextMenuPolicy(Qt::CustomContextMenu); + _treeTable->setEditTriggers(QAbstractItemView::DoubleClicked | QAbstractItemView::EditKeyPressed); + _treeTable->setSelectionBehavior(QAbstractItemView::SelectRows); + _treeTable->setSelectionMode(QAbstractItemView::ExtendedSelection); + //_treeTable->setSelectionMode(QAbstractItemView::ContiguousSelection); + _treeTable->setSelectionModel( new XQSelectionModel(this) ); } +//! firz + void XQViewModel::addSection( const XQItemList& list, const XQNodePtr& sheetNode ) { appendRow(list); @@ -448,25 +485,32 @@ void XQViewModel::addSection( const XQItemList& list, const XQNodePtr& sheetNode } +//! firz + QUndoStack* XQViewModel::undoStack() { return _undoStack; } +//! firz + void XQViewModel::setUndoStack( QUndoStack* undoStack ) { _undoStack = undoStack; } +//! firz + void XQViewModel::onShowContextMenu(const QPoint& point) { initContextMenu(); - _contextMenu->popup(_treeView->mapToGlobal(point)); + _contextMenu->popup(_treeTable->mapToGlobal(point)); } +//! firz QHash XQViewModel::roleNames() const { diff --git a/src/model/xqviewmodel.h b/src/model/xqviewmodel.h index 57e1d2f..b05e6b8 100644 --- a/src/model/xqviewmodel.h +++ b/src/model/xqviewmodel.h @@ -52,8 +52,8 @@ public: XQViewModel(QObject* parent = nullptr); virtual ~XQViewModel(); - XQTreeTable* treeView(); - virtual void setTreeView( XQTreeTable* mainView ); + XQTreeTable* treeTable(); + virtual void setTreeTable( XQTreeTable* mainView ); QUndoStack* undoStack(); void setUndoStack( QUndoStack* undoStack ); @@ -125,7 +125,7 @@ protected: XQSimpleClipBoard _clipBoard; XQModelSections _sections; - XQTreeTable* _treeView{}; + XQTreeTable* _treeTable{}; QUndoStack* _undoStack{}; XQContextMenu* _contextMenu{}; diff --git a/src/nodes/znode.cpp b/src/nodes/znode.cpp index 749f63c..2452bb4 100644 --- a/src/nodes/znode.cpp +++ b/src/nodes/znode.cpp @@ -14,6 +14,9 @@ #include + +//! firz + namespace znode { diff --git a/src/util/xqexception.cpp b/src/util/xqexception.cpp index 103f1a7..762ee46 100644 --- a/src/util/xqexception.cpp +++ b/src/util/xqexception.cpp @@ -14,6 +14,8 @@ #include +//! firz + XQException::XQException(const QString& what, const QString& param ) : std::runtime_error( param.isEmpty() ? what.toStdString() : QString( "%1: %2" ).arg(what,param).toStdString( ) ) {} diff --git a/src/widgets/xqcontextmenu.cpp b/src/widgets/xqcontextmenu.cpp index 89a6b44..2e71322 100644 --- a/src/widgets/xqcontextmenu.cpp +++ b/src/widgets/xqcontextmenu.cpp @@ -15,6 +15,8 @@ #include +//! firz + XQContextMenu::XQContextMenu(const QString& title, QWidget* parent ) : QMenu( title, parent ) { @@ -27,13 +29,15 @@ XQContextMenu::XQContextMenu(const QString& title, QWidget* parent ) } +//! firz + XQContextMenu::XQContextMenu(QWidget* parent) : QMenu( parent ) { } - +//! firz void XQContextMenu::addAction(const QString& text, XQCommand::CmdType commandType, bool enabled) { @@ -45,12 +49,16 @@ void XQContextMenu::addAction(const QString& text, XQCommand::CmdType commandTyp } +//! firz + void XQContextMenu::addAction(const QString& iconKey, const QString& name, XQCommand::CmdType commandType, bool enabled) { addAction(XQAppData::typeIcon( iconKey), name, commandType, enabled ); } +//! firz + void XQContextMenu::addAction(const QIcon& icon, const QString& text, XQCommand::CmdType commandType, bool enabled) { QAction* newAction = new QAction(icon, text, this); @@ -61,6 +69,8 @@ void XQContextMenu::addAction(const QIcon& icon, const QString& text, XQCommand: } +//! firz + void XQContextMenu::setActionEnabled(XQCommand::CmdType commandType, bool enabled) { if( _actionMap.contains(commandType) ) diff --git a/src/widgets/xqtreetable.cpp b/src/widgets/xqtreetable.cpp index 81d2069..e282704 100644 --- a/src/widgets/xqtreetable.cpp +++ b/src/widgets/xqtreetable.cpp @@ -20,6 +20,8 @@ #define DB_TIMESTAMP QTime::currentTime().toString(" -- HH:mm:ss.zzz") +//! firz + XQTreeTable::XQTreeTable(QWidget* parent) : QTreeView(parent) { @@ -34,10 +36,7 @@ XQTreeTable::XQTreeTable(QWidget* parent) } -XQTreeTable::~XQTreeTable() -{ -} - +//! firz XQViewModel* XQTreeTable::modelView() { @@ -45,12 +44,16 @@ XQViewModel* XQTreeTable::modelView() } // __fixme: necessary? +//! firz + XQItem& XQTreeTable::xqItemFromIndex(const QModelIndex& index ) { return modelView()->xqItemFromIndex( index ); } +//! firz + void XQTreeTable::currentChanged(const QModelIndex& current, const QModelIndex& previous) { @@ -68,6 +71,8 @@ void XQTreeTable::currentChanged(const QModelIndex& current, const QModelIndex& } +//! firz + void XQTreeTable::mouseResizeHeaderEntry(int xpos) { // resize colummn: minimal vertical margin in pixels @@ -90,6 +95,9 @@ void XQTreeTable::mouseResizeHeaderEntry(int xpos) } } + +//! firz + void XQTreeTable::mouseMoveEvent(QMouseEvent* event) { // pixel Grenzwert zur Anzeige des Splitcursors @@ -128,6 +136,9 @@ void XQTreeTable::mouseMoveEvent(QMouseEvent* event) QTreeView::mouseMoveEvent(event); } + +//! firz + void XQTreeTable::mouseDoubleClickEvent(QMouseEvent* event) { /* @@ -144,6 +155,8 @@ void XQTreeTable::mouseDoubleClickEvent(QMouseEvent* event) } +//! firz + void XQTreeTable::mousePressEvent(QMouseEvent* event) { @@ -161,6 +174,8 @@ void XQTreeTable::mousePressEvent(QMouseEvent* event) } +//! firz + void XQTreeTable::mouseReleaseEvent(QMouseEvent* event) { // reset index for resize column @@ -170,6 +185,8 @@ void XQTreeTable::mouseReleaseEvent(QMouseEvent* event) } +//! firz + void XQTreeTable::wheelEvent(QWheelEvent* event) { // Ctrl-key down? diff --git a/src/widgets/xqtreetable.h b/src/widgets/xqtreetable.h index dfc215e..123b4f7 100644 --- a/src/widgets/xqtreetable.h +++ b/src/widgets/xqtreetable.h @@ -30,12 +30,13 @@ class XQViewModel; class XQTreeTable : public QTreeView { Q_OBJECT - Q_DECLARE_PRIVATE(QTreeView) + // wird hier lieber ncht benutzt + //Q_DECLARE_PRIVATE(QTreeView) public: XQTreeTable(QWidget* parent = nullptr ); - virtual ~XQTreeTable(); + virtual ~XQTreeTable() = default; XQViewModel* modelView(); XQItem& xqItemFromIndex(const QModelIndex& index ); @@ -45,14 +46,10 @@ protected: void currentChanged(const QModelIndex& current, const QModelIndex& previous) override; void mouseMoveEvent(QMouseEvent* event) override; - //! Mouse press event.used to emulate the behavior of a QHeaderView in the first line of the view void mouseDoubleClickEvent(QMouseEvent* event) override; - //! Mouse release event.used to emulate the behavior of a QHeaderView in the first line of the view void mouseReleaseEvent(QMouseEvent* event) override; - //! Mouse press event.used to emulate the behavior of a QHeaderView in the first line of the view void mousePressEvent(QMouseEvent* event) override; void mouseResizeHeaderEntry(int xpos); - //! Mouse wheel event. void wheelEvent(QWheelEvent* event) override; //! used by the mouse events