diff --git a/src/model/xqviewmodel.cpp b/src/model/xqviewmodel.cpp index a1808eb..61fbe3b 100644 --- a/src/model/xqviewmodel.cpp +++ b/src/model/xqviewmodel.cpp @@ -30,7 +30,7 @@ //Q_GLOBAL_STATIC(XQItem,s_dummyItem) -//! firz +//! hilfsfunkion, zeigt den string-content() für alle elemente der liste void showItemList( const XQItemList& list) { @@ -40,14 +40,7 @@ void showItemList( const XQItemList& list) } -//! firz - -XQViewModel::~XQViewModel() -{ -} - - -//! firz +//! Konstruktur mit parent. XQViewModel::XQViewModel( QObject* parent ) : QStandardItemModel{ parent }, _itemFactory{ XQItemFactory::instance() } @@ -57,7 +50,7 @@ XQViewModel::XQViewModel( QObject* parent ) } -//! firz +//! gibt einen static-cast auf 'invisibleRootItem()' zurück const XQItem& XQViewModel::xqRootItem() { @@ -70,7 +63,7 @@ const XQItem& XQViewModel::xqRootItem() } -//! firz +//! hifsfunktion, die das item zu einen index zurückgibt XQItem& XQViewModel::xqItemFromIndex(const QModelIndex& index) const { @@ -83,14 +76,68 @@ XQItem& XQViewModel::xqItemFromIndex(const QModelIndex& index) const return XQItem::fallBackDummyItem(); } -//! firz +//! hilfsfunktiom, die das erste xqitem einer zeile zurückgibt. XQItem& XQViewModel::xqFirstItem(int row) const { return *static_cast( QStandardItemModel::item(row) ); } -//! firz +//! create the own model structure +void XQViewModel::initModel( const QString& modelName) +{ + /* + model + section + header + section + + + */ + + /* + // #0: Wir suchen die Model-Beschreibung + XQNodePtr modelSheet = _itemFactory.findModelSheet( modelName ); // throws + + // #1: Wir erzeugen die Model-Struktur: Jedes Kind beschreibt einen + // XML-Datentyp, z.B. , + // Jeder XML-Knoten entspricht einer Zeile im späteren Model, jedes + // Attribut wird einem eigenen Feld (XQItem) abgebildet. + + for( const auto& sheetNode : modelSheet->children() ) + { + + + XQItemList list = _itemFactory.makeHeaderRow( sheetNode ); + + // für jeden XML-Knotentyp in der Modelbeschreibung erzeugen wir eine section + addSection(list, sheetNode ); + + // jedes kind kann enthält einen itemType und einen headerItemType. Für + // diese sind eventuell weitere attribute vorhanden, die die im type + // enthaltenen defualt-werte überschreiben. + + for( const auto& sheetChild : sheetNode->children() ) + { + //qDebug() << "---- kloppo: " << sheetChild->tag_name() << ": " << sheetChild->to_string(); + extendItemType( sheetChild ); + } + + + + // empty row: + //XQNodePtr contentNode = XQNode::make_node( sheetNode->tag_name() ); + //XQItemList emptyRow = _itemFactory.makeEmptyRow( contentNode, sheetNode ); + //appendRow( emptyRow ); + + + } // for + */ + +} + + +//! SLOT, der aufgerufen wird, wenn eine edit-action getriggert wurde. void XQViewModel::onActionTriggered(QAction* action) { @@ -138,12 +185,7 @@ void XQViewModel::onActionTriggered(QAction* action) } -/** - * @brief XQViewModel::onCommandRedo called to execute a command ('do'). - * @param command the current command - */ - -//! firz +//! führt die 'redo' action des gegebenen commnds aus. void XQViewModel::onCommandRedo( XQCommand& command ) { @@ -182,12 +224,7 @@ void XQViewModel::onCommandRedo( XQCommand& command ) } -/** - * @brief XQViewModel::onCommandUndo: called to 'undo' a command. - * @param command the command to be undone. - */ - -//! firz +//! führt die 'undo' action des gegebenen commnds aus. void XQViewModel::onCommandUndo( XQCommand& command ) { @@ -341,7 +378,7 @@ void XQViewModel::cmdPasteUndo( XQCommand& command ) // don't clone into clipboard, remove items -//! firz +//! entfernen der selection ohne copy in clipboard. void XQViewModel::cmdDelete( XQCommand& command ) { @@ -358,7 +395,7 @@ void XQViewModel::cmdDelete( XQCommand& command ) } } -//! firz +//! macht 'delete' wirder rückgängig. void XQViewModel::cmdDeleteUndo( XQCommand& command ) { @@ -366,12 +403,7 @@ void XQViewModel::cmdDeleteUndo( XQCommand& command ) } -/** - * @brief XQViewModel::cmdNewRow create one new item row - * @param command the command - */ - -//! firz +//! legt eine neue, leere zeile an. void XQViewModel::cmdNew( XQCommand& command ) { @@ -407,14 +439,14 @@ void XQViewModel::cmdNew( XQCommand& command ) */ } -//! firz +//! entfernt die neu angelegte zeile. void XQViewModel::cmdNewUndo( XQCommand& command ) { } -//! firz +//! schaltet eine section sichtbar oder unsichtbar. void XQViewModel::cmdToggleSection( const QModelIndex& index ) { @@ -458,12 +490,8 @@ void XQViewModel::setTreeTable(XQTreeTable* mainView ) setupViewProperties(); } -/** - * @brief XQViewModel::setupViewProperties set the tree views' properties: context menu policy, - * edit triggers and so on. - */ -//! firz +//! setzt die eigenschaften der TreeTable. void XQViewModel::setupViewProperties() { @@ -476,7 +504,7 @@ void XQViewModel::setupViewProperties() } -//! firz +//! füg eine section mit header hinzu. void XQViewModel::addSection( const XQItemList& list, const XQNodePtr& sheetNode ) { @@ -485,7 +513,7 @@ void XQViewModel::addSection( const XQItemList& list, const XQNodePtr& sheetNode } -//! firz +//! gibt den undo-stack zurück. QUndoStack* XQViewModel::undoStack() { @@ -493,7 +521,7 @@ QUndoStack* XQViewModel::undoStack() } -//! firz +//! setzt den undo-stack. void XQViewModel::setUndoStack( QUndoStack* undoStack ) { @@ -501,7 +529,7 @@ void XQViewModel::setUndoStack( QUndoStack* undoStack ) } -//! firz +//! SLOT, der die erstellung & anzeige es context-menues triggert. void XQViewModel::onShowContextMenu(const QPoint& point) { @@ -510,7 +538,8 @@ void XQViewModel::onShowContextMenu(const QPoint& point) } -//! firz +//! gibt die namen der neuen data-roles zurück. +//! __fix: die alten roles fehlen hier! QHash XQViewModel::roleNames() const { diff --git a/src/model/xqviewmodel.h b/src/model/xqviewmodel.h index f70c9be..5a09049 100644 --- a/src/model/xqviewmodel.h +++ b/src/model/xqviewmodel.h @@ -50,7 +50,7 @@ class XQViewModel : public QStandardItemModel public: XQViewModel(QObject* parent = nullptr); - virtual ~XQViewModel(); + virtual ~XQViewModel() = default; XQTreeTable* treeTable(); virtual void setTreeTable( XQTreeTable* mainView ); @@ -58,10 +58,8 @@ public: QUndoStack* undoStack(); void setUndoStack( QUndoStack* undoStack ); - QHash roleNames() const override; - //! create the own model structure - virtual void initModel( const QString& modelName) = 0; + virtual void initModel( const QString& modelName); //little helpers const XQItem& xqRootItem(); @@ -81,6 +79,8 @@ public: virtual void cmdNew( XQCommand& command ); virtual void cmdNewUndo( XQCommand& command ); + QHash roleNames() const override; + /*! Derzeit wir die default-implementierung von data/setData genutzt. hier wäre dann die