diff --git a/src/application/xqdocumentstore.cpp b/src/application/xqdocumentstore.cpp index 20cebfc..127b679 100644 --- a/src/application/xqdocumentstore.cpp +++ b/src/application/xqdocumentstore.cpp @@ -16,9 +16,7 @@ #include #include - - - +//! firz XQDocument::XQDocument(const QString& aFileName, const QString& aFriendlyName, XQItem* aTreeItem, XQViewModel* aModelView ) : fileName{ aFileName }, friendlyName{ aFriendlyName }, treeItem{ aTreeItem }, modelView{ aModelView } @@ -26,6 +24,8 @@ XQDocument::XQDocument(const QString& aFileName, const QString& aFriendlyName, X } +//! firz + XQDocument::~XQDocument() { //delete _documentRoot; @@ -37,6 +37,8 @@ XQDocument::~XQDocument() /// +//! firz + XQDocumentStore::~XQDocumentStore() { //for (auto entry : *this) @@ -46,6 +48,7 @@ XQDocumentStore::~XQDocumentStore() } +//! firz void XQDocumentStore::addDocument( const QString& aFileName, const QString& aFriendlyName, XQItem* aTreeItem, XQViewModel* aModelView ) { diff --git a/src/application/xqmainmodel.cpp b/src/application/xqmainmodel.cpp index b5f5a00..745dc5c 100644 --- a/src/application/xqmainmodel.cpp +++ b/src/application/xqmainmodel.cpp @@ -26,18 +26,15 @@ #include +//! default konstruktor. + XQMainModel::XQMainModel(QObject *parent ) : XQViewModel{parent} { } - -XQMainModel::~XQMainModel() -{ - // delete -} - +//! initialisiert dieses model über den namen. void XQMainModel::initModel(const QString& modelName) { @@ -56,6 +53,8 @@ void XQMainModel::initModel(const QString& modelName) } +//! erzeugt einen eintrag in der baum-übersicht. + XQItem* XQMainModel::createTreeEntry( XQNodePtr contentNode ) { for(const auto& section : _sections ) @@ -75,6 +74,7 @@ XQItem* XQMainModel::createTreeEntry( XQNodePtr contentNode ) throw XQException( "createTreeEntry: main model should not be emtpy!" ); } +//! firz void XQMainModel::initContextMenu() { diff --git a/src/application/xqmainmodel.h b/src/application/xqmainmodel.h index 57c5b50..dfd4856 100644 --- a/src/application/xqmainmodel.h +++ b/src/application/xqmainmodel.h @@ -30,7 +30,7 @@ class XQMainModel : public XQViewModel public: explicit XQMainModel(QObject *parent = nullptr); - virtual ~XQMainModel(); + virtual ~XQMainModel() = default; void initModel(const QString& modelName) override; XQItem* createTreeEntry( XQNodePtr contentNode ); diff --git a/src/application/xqmainwindow.cpp b/src/application/xqmainwindow.cpp index 687e910..c71320f 100644 --- a/src/application/xqmainwindow.cpp +++ b/src/application/xqmainwindow.cpp @@ -23,6 +23,7 @@ #include +//! firz XQMainWindow::XQMainWindow( QWidget* parent ) : QMainWindow(parent) @@ -32,6 +33,9 @@ XQMainWindow::XQMainWindow( QWidget* parent ) initMainWindow(); } + +//! firz + void XQMainWindow::initMainWindow() { @@ -97,6 +101,9 @@ void XQMainWindow::initMainWindow() } + +//! firz + void XQMainWindow::onUndo() { qDebug() << " --- undo Pressed"; @@ -105,6 +112,9 @@ void XQMainWindow::onUndo() } + +//! + void XQMainWindow::onRedo() { qDebug() << " --- redo Pressed"; @@ -114,12 +124,16 @@ void XQMainWindow::onRedo() } +//! erzeugt ein document + void XQMainWindow::onCreateDocument() { qDebug() << " ---- create document Pressed!"; } +//! öffnet ein XML document + void XQMainWindow::onOpenDocument() { QString fileName = QFileDialog::getOpenFileName(this, tr("Open Project"), c_DocumentDirectory, tr("project data(*.xtr)") ); @@ -137,6 +151,7 @@ void XQMainWindow::onOpenDocument() } +//! speichert ein XML document void XQMainWindow::onSaveDocument() { @@ -145,6 +160,9 @@ void XQMainWindow::onSaveDocument() } +//! fragt nach einem datei-namen und speichert das akutelle XML +//! document unter diesem + void XQMainWindow::onSaveDocumentAs() { QString fileName = QFileDialog::getSaveFileName(this, "Save as", c_DocumentDirectory, tr("project data(*.xtr)") ); @@ -162,17 +180,24 @@ void XQMainWindow::onSaveDocumentAs() } +//! wird aufgerufen, wenn ein XML geschlossen werden soll. + void XQMainWindow::onCloseDocument() { qDebug() << " ---- close Pressed!"; } +//! beendet diese application + void XQMainWindow::onExit() { qApp->exit(); } + +//! zeigt den about-dialog + void XQMainWindow::onAbout() { @@ -189,6 +214,7 @@ void XQMainWindow::onAbout() } +//! firz // when item in the left tree is clicked, switch view on the right side void XQMainWindow::onTreeItemClicked(const QModelIndex& index ) { @@ -207,6 +233,8 @@ void XQMainWindow::onTreeItemClicked(const QModelIndex& index ) } + +//! firz // when item in the left tree is clicked, switch view on the right side void XQMainWindow::onTabClicked( int index ) { @@ -215,10 +243,12 @@ void XQMainWindow::onTabClicked( int index ) _mainTreeView->setCurrentIndex( _documentStore[index].treeItem->index() ); } + +//! liest eine XML datei namens 'fileName' + void XQMainWindow::loadDocument( const QString& fileName ) { - //ntThrowIfNullPtr - // gibts die Datei? + // gibts die Datei? if( !QFile::exists( fileName) ) throw XQException( "no such file", fileName ); @@ -271,6 +301,8 @@ void XQMainWindow::loadDocument( const QString& fileName ) } +//! speichert ein XML unter dem 'filename' + void XQMainWindow::saveDocument( const QString& fileName ) { XQNodeWriter nodeWriter; diff --git a/src/items/xqitem.cpp b/src/items/xqitem.cpp index dc49f91..ecacfed 100644 --- a/src/items/xqitem.cpp +++ b/src/items/xqitem.cpp @@ -144,42 +144,11 @@ XQItem::XQItem(XQItemType* itemType, const QString *content, const XQNodePtr& co } -/* -XQItem::XQItem(const XQItem& other) - : QStandardItem( other ) -{ - // QStandardItem( other ) koopiert bereits - // die data() struktur -} - -XQItem& XQItem::operator=(const XQItem& other) -{ - if( this != &other) - { - // kopiert data() - this->QStandardItem::operator=( other ); - } - return *this; -} -*/ - -//! firz - -XQItem::~XQItem() -{ - -} - - -//! firz +//! ruft den copy-konstruktor auf. XQItem* XQItem::clone() const { - //return new XQItem( *this ); - // this is used as invisible filling material - //return new XQItem( "", XQItemType::StaticStyle ); - // __fix! - return new XQItem(); + return new XQItem( *this ); } @@ -193,7 +162,7 @@ bool XQItem::isValid() const } -//! firz +//! gibt den content-node zurück. XQNodePtr XQItem::contentNode() const { @@ -201,7 +170,7 @@ XQNodePtr XQItem::contentNode() const } -//! firz +//! setzt den content node. void XQItem::setContentNode( const XQNodePtr& contentNode ) { @@ -209,15 +178,14 @@ void XQItem::setContentNode( const XQNodePtr& contentNode ) } -//! firz +//! gibt den sheet-node zurück. XQNodePtr XQItem::sheetNode() const { - // return data( SheetNodeRole ).value(); } -//! firz +//! setzt den sheet-node void XQItem::setSheetNode(const XQNodePtr& sheetNode ) { @@ -225,7 +193,7 @@ void XQItem::setSheetNode(const XQNodePtr& sheetNode ) } -//! firz +//! tested, ob ein attribut mit dem namen 'attribKey' vorhanden ist. bool XQItem::hasAttribute( const QString& attribKey ) const { @@ -233,7 +201,7 @@ bool XQItem::hasAttribute( const QString& attribKey ) const } -//! firz +//! gibt das attribut namens 'attribKey' zurück, sofern vorhanden, sonst 'defaultValue' const QString& XQItem::attribute( const QString& attribKey, const QString& defaultValue ) const { @@ -243,7 +211,7 @@ const QString& XQItem::attribute( const QString& attribKey, const QString& defau } -//! firz +//! tested, ob das attribut namens 'attribKey' dem wert 'attribValue' entspricht. bool XQItem::testAttribute( const QString& attribKey, const QString& attribValue ) const { @@ -251,15 +219,21 @@ bool XQItem::testAttribute( const QString& attribKey, const QString& attribValue } -//! firz +//! gibt eine referenz auf den itemType dieses items zurück. XQItemType& XQItem::itemType() const { + // __fix: wir gehen hier davon aus, das der itemType immer existiert, + // nur weil er in jeden konstruktor gesetzt wird, das muss aber nicht + // so sein! XQItemType* itemTypePtr = QStandardItem::data( XQItem::ItemTypeRole ).value(); return *itemTypePtr; + // should_throw + } -//! firz + +//! speichert einen neuen itemType. void XQItem::setItemType( XQItemType* itemTypePtr ) { @@ -268,7 +242,7 @@ void XQItem::setItemType( XQItemType* itemTypePtr ) } -//! firz +//! set ein einzelnes itemFlag. void XQItem::addFlag( Qt::ItemFlag newFlag ) { @@ -276,7 +250,7 @@ void XQItem::addFlag( Qt::ItemFlag newFlag ) } -//! firz +//! löscht ein einzelnes itemFlag. void XQItem::clearFlag( Qt::ItemFlag newFlag ) { @@ -287,7 +261,7 @@ void XQItem::clearFlag( Qt::ItemFlag newFlag ) /// data() access shortcuts /// -//! firz +//! gibt den renderStyle zurück. XQItem::RenderStyle XQItem::renderStyle() const { @@ -295,37 +269,38 @@ XQItem::RenderStyle XQItem::renderStyle() const } -//! firz +//! gibt den renderStyle als string zurück. QString XQItem::renderStyleToString() const { return XQItem::fetchRenderStyleToString( renderStyle() ); } -//! firz + +//! setzt den editorType. wird im itemType gespeichert. void XQItem::setRenderStyle(RenderStyle renderStyle ) { setData( QVariant::fromValue(renderStyle), XQItem::RenderStyleRole ); - // Der RenderStyle wohnt im ItemType - //itemType().replaceAttribute( this, RenderStyleRole, renderStyle ); } +//! gibt den editorType zurück. + XQItem::EditorType XQItem::editorType() const { return data( EditorTypeRole ).value(); } -//! firz +//! gibt den renderStyle als string zurück. QString XQItem::editorTypeToString() const { return XQItem::fetchEditorTypeToString( editorType() ); } -//! firz +//! setzt den editorType. wird im itemType gespeichert. void XQItem::setEditorType(EditorType editorType) { @@ -335,7 +310,7 @@ void XQItem::setEditorType(EditorType editorType) } -//! firz +//! setzt den unitType. XQItem::UnitType XQItem::unitType() const { @@ -343,7 +318,7 @@ XQItem::UnitType XQItem::unitType() const } -//! firz +//! gibt den unitType als string zurück. QString XQItem::unitTypeToString() const { @@ -351,7 +326,7 @@ QString XQItem::unitTypeToString() const } -//! firz +//! setzt den editorType. wird im itemType gespeichert. void XQItem::setUnitType(UnitType unitType) { @@ -359,7 +334,8 @@ void XQItem::setUnitType(UnitType unitType) } -//! firz +//! gibt den content-string zurück. das ist ein derefenzierter pointer +//! auf das zu diesem item gehörige daten-attribut 'useres' datenknotens. const QString& XQItem::content() const { @@ -373,7 +349,7 @@ const QString& XQItem::content() const } -//! firz +//! set den content()-string pointer. (als leihgabe) void XQItem::setContent( const QString* content ) { @@ -381,7 +357,7 @@ void XQItem::setContent( const QString* content ) } -//! firz +//! holt den schlüssel bzw. bezeicher des content() string aus 'unserem' content knoten. const QString& XQItem::contentKey() const { @@ -395,6 +371,7 @@ QString XQItem::contentFormat() const return data( XQItem::ContentFormatRole ).toString(); } +//! setz den den content format-string. wird im itemType gespeichert. void XQItem::setContentFormat(const QString& contentFormat) { @@ -403,7 +380,7 @@ void XQItem::setContentFormat(const QString& contentFormat) //! gibt das read-only auswahl-model zurück (wenn dieses item als -//! combobox gerendert wird) +//! combobox gerendert wird). wird im itemType gespeichert. QStandardItemModel* XQItem::fixedChoices() const { @@ -451,7 +428,7 @@ bool XQItem::isHeaderStyle() //! gibt den namen der datarole zurück -QString XQItem::dataRoleName(int role) +QString XQItem::dataRoleName(int role) const { if( role < XQItem::NoRole && model() ) return model()->roleNames()[role]; @@ -483,11 +460,24 @@ QVariant XQItem::data(int role ) const return itemType().data(role); } - // Das ist der Sonderfall, hier dereferenzieren wir den - // Zeiger auf den QString* aus unserem XQNodePtr + // Zugriffe auf den sichtbaren inhalt geben den inhalt des string pointer + // auf ein feld in content node wieder. + + // DisplayRole gibt den formatieren inhalt wieder. die formatierung übernimmt + // der item type + // auf den original inhalt im content node zurückgeben. case Qt::DisplayRole : - case Qt::EditRole : + { + if( itemType().renderStyle() == XQItem::FormattedStyle)//return "display:"+content(); + return itemType().formatText( *this ); + [[fallthrough]]; + } + + // EditRole & ContentRole sollen den 'rohen' inhalt unseres string-pointers + // auf den original inhalt im content node zurückgeben. + + case Qt::EditRole : case XQItem::ContentRole: { return content(); @@ -538,41 +528,85 @@ QVariant XQItem::data(int role ) const } +/*! + + Überschreibt setData() vom QStandardItem. Es wird unterschieden zwischen den data roles, die von + 'unserem' itemType verwaltet und gespeichert werden und unseren eigenen. ein XQItem enthält nur folgende + Felder: + + // - die ItemFlags (geerbt vom QStandardItem) stimmt nicht! + - den pointer auf den ItemType + - den pointer auf den inhalts-string: content() + + Die anderen werte werden vom itemType verwaltet: + + - der EditorType + - der RenderStyle + - der UnitType + - das ContentFormat + - das Icon + - ggf. das choiceModel, falls dieses Item als combobox gerendert wird. + +*/ void XQItem::setData(const QVariant& value, int role ) { - //replaceAttribute( XQItem* item, XQItem::ItemDataRole role, const QVariant& newValue) - - //emitDataChanged() switch(role) { - // das ist ein pointer auf den original-string aus dem XML - // ContentRole : - // ItemTypeRole : + case RenderStyleRole : case EditorTypeRole : case UnitTypeRole: case ContentFormatRole: - case FlagsRole: + case FlagsRole: // Stimmt das? case IconRole: case FixedChoicesRole: + { //qDebug() << " ---call type set Data: " << role << ": " << XQItem::fetchItemDataRoleName(role) << ":" << value.toString(); itemType().replaceAttribute( this, value, role ); - break; + emitDataChanged(); + // no break, return! + return; + } + // DAS PASSIERT NIE, AUSSER + // set the raw, unformatted data + case ContentRole: + { + // what will happen? value is a string ptr ?! + qDebug() << " --- setting content: " << value.toString(); + // string ptr setzen kann die basis. + break; + return; + } + + case Qt::EditRole : + { + // what will happen? value is a string ptr ?! + qDebug() << " --- setting editrole: " << value.toString(); + return; + } + + case Qt::DisplayRole : + { + // what will happen? value is a string ptr ?! + qDebug() << " --- setting DISPLAYrole: " << value.toString(); + // ignore this + return; + } + + // alles andere wie gehabt case ContentNodeRole: case SheetNodeRole: - case TypeKeyRole: - case Qt::DisplayRole : - case Qt::EditRole : - // return the raw, unformatted data - case ContentRole: - + //case TypeKeyRole: not used default: - QStandardItem::setData( value,role); - + break; } + + // hier: behandlung wie gehabt + QStandardItem::setData( value,role); + } diff --git a/src/items/xqitem.h b/src/items/xqitem.h index d499295..dafc095 100644 --- a/src/items/xqitem.h +++ b/src/items/xqitem.h @@ -131,7 +131,7 @@ public: XQItem( XQItemType* itemType, const QString* content ); XQItem( XQItemType* itemType, const QString* content, const XQNodePtr& contentNode ); - virtual ~XQItem(); + virtual ~XQItem() = default; //! creates not a clone but a new default item, \see QStandardItemModel::setItemPrototype() //! -- not used at the moment -- @@ -202,7 +202,7 @@ public: // bool isHeaderStyle(); - QString dataRoleName(int role); + QString dataRoleName(int role) const; QVariant data(int role = Qt::DisplayRole ) const override; void setData(const QVariant &value, int role ) override; diff --git a/src/items/xqitemdelegate.cpp b/src/items/xqitemdelegate.cpp index 6fbc9b7..79883b3 100644 --- a/src/items/xqitemdelegate.cpp +++ b/src/items/xqitemdelegate.cpp @@ -242,7 +242,6 @@ void XQItemDelegate::setEditorData(QWidget* editor, const QModelIndex& index) co { XQItem& item = xqItemFromIndex( index ); - qDebug() << " --- ZZZ: setEditorData: " << item.text(); switch( item.editorType() ) { case XQItemType::ComboBoxType : diff --git a/src/items/xqitemtype.cpp b/src/items/xqitemtype.cpp index 87b79d3..370f10f 100644 --- a/src/items/xqitemtype.cpp +++ b/src/items/xqitemtype.cpp @@ -30,33 +30,47 @@ size_t XQItemType::s_ItemTypeCount = 0; XQItemType::XQItemType() : XQItem(nullptr) // vermeide rekursion { - } XQItemType::XQItemType( const XQItemType& other) : XQItem( other ) { - - - } + +//! destruktor, räumt das fixedChoices auf, so vorhanden. + XQItemType::~XQItemType() { - + // das einzige property, was auch auf dem heap liegt. + QStandardItemModel* choices = fixedChoices(); + if( choices ) + { + setfixedChoices( nullptr ); + delete choices; + } } + +//! ruft QStandardItem::data auf + QVariant XQItemType::data( int role ) const { return QStandardItem::data(role); } + +//! ruft QStandardItem::setData auf + void XQItemType::setData(const QVariant &value, int role ) { return QStandardItem::setData(value,role); } + +//! setzt einen attributwert neu. Ggf. wird ein neuer ItemType erzeugt. + void XQItemType::replaceAttribute( XQItem* item, const QVariant& newValue, int role ) { // hat sich überhaupt was geändert? @@ -82,20 +96,26 @@ void XQItemType::replaceAttribute( XQItem* item, const QVariant& newValue, int r // und ins item übernehmen item->setItemType( myClone ); - /// Obacht! Der alte, geänderte itemType bleibt erhaltent + /// Obacht! Der alte, geänderte itemType bleibt erhalten /// und verrottet ggf. ohne Daseinszweck } } } - -QString XQItemType::formatToSI( const QString& valueTxt ) const +QVariant XQItemType::formatText( const XQItem& item ) const { - /* + return "type says:"+ item.content(); +} + +//! firz + +QString XQItemType::formatToSI( const QString& valueTxt, XQItem::UnitType unitType ) const +{ + if( valueTxt.isEmpty() ) return valueTxt; - if( XQItem::ISODate == _unitType ) + if( XQItem::ISODate == unitType ) { // format iso date QDateTime dateTime = QDateTime::fromString(valueTxt, Qt::ISODate); @@ -122,14 +142,14 @@ QString XQItemType::formatToSI( const QString& valueTxt ) const //qDebug() << " convert: " << dVal << " : " << valueTxt << ": " << strVal << ":" << exp << " : " << strPrefix << ": " << nVal; return QString("%1 %2%3").arg( strVal, strPrefix, unitTypeToString() ); - */ - return "fitze!"; + } +//! firz QString XQItemType::unFormatFromSI(const QString& formText ) const { - /* + QString input = formText.simplified(); // #1: strip numeric part if( input.isEmpty() ) @@ -167,14 +187,15 @@ QString XQItemType::unFormatFromSI(const QString& formText ) const //qDebug() << " convert: " << numPart << " : " << unitPart << " : " << dVal << " : " << result; return result; - */ - return "fitze!"; + } /// /// --- statics -------------------------------------------------------------------------- /// +//! gibt den dummy item type zurück (benutzt für null-items). + XQItemType* XQItemType::staticItemType() { static XQItemType s_DummyItemType; @@ -182,6 +203,8 @@ XQItemType* XQItemType::staticItemType() } +//! erzeugt aus den eingenschaften des itemTypes einen eindeutigen schlüssel. + QString XQItemType::makeItemTypeKey() { QString key("%1:%2:%3:%4:%5:%6:%7"); diff --git a/src/items/xqitemtype.h b/src/items/xqitemtype.h index 9846a73..37e14eb 100644 --- a/src/items/xqitemtype.h +++ b/src/items/xqitemtype.h @@ -40,8 +40,10 @@ public: QVariant data( int role ) const override; void setData(const QVariant& value, int role ) override; + virtual QVariant formatText( const XQItem& item ) const; + // FIX! Das gehört hier nicht her! - QString formatToSI(const QString& rawText ) const; + QString formatToSI(const QString& rawText, XQItem::UnitType unitType ) const; QString unFormatFromSI(const QString& valueText ) const; void replaceAttribute( XQItem* item, const QVariant& newValue, int role ); diff --git a/src/model/xqmodelsections.cpp b/src/model/xqmodelsectionlist.cpp similarity index 99% rename from src/model/xqmodelsections.cpp rename to src/model/xqmodelsectionlist.cpp index 90b668d..74a69b6 100644 --- a/src/model/xqmodelsections.cpp +++ b/src/model/xqmodelsectionlist.cpp @@ -12,7 +12,7 @@ ***************************************************************************/ -#include +#include #include diff --git a/src/model/xqmodelsections.h b/src/model/xqmodelsectionlist.h similarity index 94% rename from src/model/xqmodelsections.h rename to src/model/xqmodelsectionlist.h index 60d32f6..9df1f7b 100644 --- a/src/model/xqmodelsections.h +++ b/src/model/xqmodelsectionlist.h @@ -12,8 +12,8 @@ ***************************************************************************/ -#ifndef XQMODELSECTIONS_H -#define XQMODELSECTIONS_H +#ifndef XQMODELSECTIONLIST_H +#define XQMODELSECTIONLIST_H #include #include @@ -68,4 +68,4 @@ public: }; -#endif // XQMODELSECTIONS_H +#endif // XQMODELSECTIONLIST_H diff --git a/src/model/xqnode.h b/src/model/xqnode.h index 173de3b..fd78935 100644 --- a/src/model/xqnode.h +++ b/src/model/xqnode.h @@ -18,120 +18,25 @@ #include #include -#include -#include - #include #include + #include #include #include -// Overload the operator<< for QString and std::ostream +//! überlädt den operator<< für QString und std::ostream std::ostream& operator<<(std::ostream& os, const QString& obj); -// raw node +//! raw node using XQNode = znode::zbasic_node; -// default shared node +//! default shared node using XQNodePtr = std::shared_ptr>; -// the node factory +//! die node factory using XQNodeFactory = znode::znode_factory; -class XQNodeList : public znode::zbasic_node::znode_list -{ -public: - - XQNodeList() = default; - virtual ~XQNodeList() = default; - -}; - - - -class XNodeIterator -{ - -public: - - using iterator_category = std::forward_iterator_tag; - using value_type = XQNode; - using difference_type = std::ptrdiff_t; - using pointer = XQNode*; - using reference = XQNode&; - - XNodeIterator() = default; - - XNodeIterator(XQNodePtr root) - { - if (root) { - _stack.push(root); - } - } - - reference operator*() const { - return *_stack.top(); - } - - pointer operator->() const { - return _stack.top().get(); - } - - XNodeIterator& operator++() { - auto node = _stack.top(); - _stack.pop(); - for (auto it = node->children().rbegin(); it != node->children().rend(); ++it) - { - _stack.push(*it); - } - return *this; - } - - XNodeIterator operator++(int) { - XNodeIterator tmp = *this; - ++(*this); - return tmp; - } - - bool operator==(const XNodeIterator& other) const { - return _stack == other._stack; - } - - bool operator!=(const XNodeIterator& other) const { - return !(*this == other); - } - -private: - - std::stack _stack; -}; - -// Define the tree class with begin and end methods -class XTree -{ - -public: - - XTree(XQNodePtr root) - : _root(root) - {} - - XNodeIterator begin() - { - return XNodeIterator(_root); - } - - XNodeIterator end() - { - return XNodeIterator(); - } - -private: - - XQNodePtr _root; - -}; //void inspect( XQNodePtr node, int offSet=0 ); void inspect( const XQNodePtr& node, int indent=0 ); diff --git a/src/model/xqviewmodel.h b/src/model/xqviewmodel.h index 2ac99c2..f70c9be 100644 --- a/src/model/xqviewmodel.h +++ b/src/model/xqviewmodel.h @@ -20,7 +20,7 @@ #include #include -#include +#include #include #include @@ -81,17 +81,22 @@ public: virtual void cmdNew( XQCommand& command ); virtual void cmdNewUndo( XQCommand& command ); - /* + /*! + + Derzeit wir die default-implementierung von data/setData genutzt. hier wäre dann die + Stelle um setData & data an externe 'handler' umzubiegen, siehe giovannies 'model-injection' + + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override + { + return QStandardItemModel::data( index, role ); + } + bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override { qDebug() << " --- setData: " << value.toString(); return QStandardItemModel::setData( index, value, role ); } - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override - { - return QStandardItemModel::data( index, role ); - } */ public slots: diff --git a/src/xtree.pro b/src/xtree.pro index dc73ba4..1415e11 100644 --- a/src/xtree.pro +++ b/src/xtree.pro @@ -21,7 +21,7 @@ HEADERS += \ items/xqitemtype.h \ items/xqitemdelegate.h \ model/xqcommand.h \ - model/xqmodelsections.h \ + model/xqmodelsectionlist.h \ model/xqnode.h \ model/xqnodewriter.h \ model/xqselectionmodel.h \ @@ -59,7 +59,7 @@ SOURCES += \ items/xqitemdelegate.cpp \ main.cpp \ model/xqcommand.cpp \ - model/xqmodelsections.cpp \ + model/xqmodelsectionlist.cpp \ model/xqnode.cpp \ model/xqnodewriter.cpp \ model/xqselectionmodel.cpp \ diff --git a/xml/modelsheets.xml b/xml/modelsheets.xml index 9b5884f..9520e55 100644 --- a/xml/modelsheets.xml +++ b/xml/modelsheets.xml @@ -6,43 +6,11 @@ --> - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -69,8 +37,8 @@ - - + +