diff --git a/src/application/xqchildmodel.cpp b/src/application/xqchildmodel.cpp index dbf01fc..61198b2 100644 --- a/src/application/xqchildmodel.cpp +++ b/src/application/xqchildmodel.cpp @@ -57,7 +57,8 @@ void XQChildModel::addModelData( const XQNodePtr& contentRoot ) const XQModelSection& section = _sections.sectionByKey( key ); section.setContentRootNode( contentEntry->parent() ); - int newRow = _sections.lastRow(section); + // FaRZ! + //int newRow = _sections.lastRow(section); XQNodePtr sheetNode = section.sheetRootNode(); XQItemList list = _itemFactory.makeRow( sheetNode, contentEntry ); @@ -79,7 +80,8 @@ void XQChildModel::addSectionEntry( const QString& key, const XQNodePtr& content if(section.isValid() ) { section.setContentRootNode( contentEntry->parent() ); - int newRow = _sections.lastRow(section); + // FARZ! + int newRow = 1;//_sections.lastRow(section); XQNodePtr sheetNode = section.sheetRootNode(); XQItemList list = _itemFactory.makeRow( sheetNode, nullptr ); insertRow( newRow, list); diff --git a/src/model/xqcommand.h b/src/model/xqcommand.h index 607f186..3317403 100644 --- a/src/model/xqcommand.h +++ b/src/model/xqcommand.h @@ -61,8 +61,6 @@ public: cmdNew, cmdDelete, - cmdToggleSection, - cmdExtern //?? }; diff --git a/src/model/xqsectionmanager.cpp b/src/model/xqsectionmanager.cpp index 565435b..4f09f01 100644 --- a/src/model/xqsectionmanager.cpp +++ b/src/model/xqsectionmanager.cpp @@ -158,15 +158,17 @@ const XQModelSection& XQSectionManager::createSection(const QString& sectionKey, //! ermittelt die erste zeile einer section. +/* int XQSectionManager::firstRow(const QModelIndex& idx) const { return sectionByRow(idx.row() ).row(); } - +*/ //! ermittelt die zeile unterhalb des gegebenen modelindex, //! zum einfügen neuer items ebendort. +/* int XQSectionManager::lastRow(const QModelIndex& idx) const { return lastRow(sectionByRow(idx.row())); @@ -192,6 +194,18 @@ int XQSectionManager::lastRow(const XQModelSection& section ) const } return -1; } +*/ + +/* + int firstRow(const QModelIndex& idx) const; + int lastRow(const QModelIndex& idx) const; + int lastRow(const XQModelSection& section) const; + */ + +XQSectionPos XQSectionManager::sectionPos() +{ + return XQSectionPos(); +} //! gibt alle sections aus, zum ankucken. diff --git a/src/model/xqsectionmanager.h b/src/model/xqsectionmanager.h index d0842ad..9db755b 100644 --- a/src/model/xqsectionmanager.h +++ b/src/model/xqsectionmanager.h @@ -20,9 +20,10 @@ #include #include -/** - * @brief Struct containing data for a header section - */ + + + +//! Daten zur beschreibung einer 'sektion' des models. class XQModelSection { @@ -57,8 +58,15 @@ protected: Q_DECLARE_METATYPE(XQModelSection) +//! Erste und letzte ziele einer XQModelSection +struct XQSectionPos +{ + int firstRow{-1}; + int lastRow{-1}; +}; -//! 'maptor' struktur, die alle sections enthält + +//! struktur, die alle sections enthält class XQSectionManager { @@ -72,9 +80,13 @@ public: const XQModelSection& createSection(const QString& sectionKey, const QModelIndex& modelIndex, XQNodePtr sheetNode); + /* int firstRow(const QModelIndex& idx) const; int lastRow(const QModelIndex& idx) const; int lastRow(const XQModelSection& section) const; + */ + + XQSectionPos sectionPos(); void dump()const; diff --git a/src/model/xqviewmodel.cpp b/src/model/xqviewmodel.cpp index 550065a..967b323 100644 --- a/src/model/xqviewmodel.cpp +++ b/src/model/xqviewmodel.cpp @@ -178,27 +178,21 @@ void XQViewModel::addSection(const XQItemList& list, const XQNodePtr& sectionNod void XQViewModel::onToggleSection(const QString& sectionKey ) { qDebug() << " --- onToggleSection: " << sectionKey; - if( _sections.hasValidSection( sectionKey ) ) - toggleSection( _sections.sectionByKey(sectionKey)); -} - - -void XQViewModel::toggleSection( const XQModelSection& section ) -{ - if(_treeTable) + if( _sections.hasValidSection( sectionKey ) && _treeTable ) { - const QModelIndex& index = section.persistentModelIndex(); - qDebug() << " ---- toggle section: FIRZ: " << index.isValid() << " : " << index.data().toString() << " : " << section.contentType();//_sections.keyOf( sec ); - int fstRow = _sections.firstRow( index ); - int lstRow = _sections.lastRow( index ); - _treeTable->toggleRowsHidden(fstRow, lstRow ); - emit sectionToggled( section ); + //const XQModelSection& section =_sections.sectionByKey(sectionKey); + + //int fstRow = _sections.firstRow(index); + //int lstRow = _sections.lastRow(index); + //_treeTable->toggleRowsHidden(fstRow, lstRow); + + //emit sectionToggled(section); } - emit sectionToggled( section ); - } + + /* //! SLOT als weiterleitung vom SIGNAL itemchanged @@ -495,13 +489,14 @@ void XQViewModel::cmdNewUndo( const XQCommand& command ) //! schaltet eine section sichtbar oder unsichtbar. +/* void XQViewModel::cmdToggleSection( const XQCommand& command ) { const QModelIndex& index = command.originIndex(); Q_ASSERT(index.isValid()); toggleSection( _sections.sectionByIndex(index) ); } - +*/ //! gibt die treetable zurück diff --git a/src/model/xqviewmodel.h b/src/model/xqviewmodel.h index 1bc3a37..20db1f0 100644 --- a/src/model/xqviewmodel.h +++ b/src/model/xqviewmodel.h @@ -55,7 +55,6 @@ public: virtual void initModel( const QString& modelName); void expandNewItem(const QModelIndex& index); - void toggleSection( const XQModelSection& section ); void toggleSection( const QString& sectionKey ); //little helpers @@ -67,7 +66,7 @@ public: // undo-/redo-able stuff - virtual void cmdToggleSection( const XQCommand& command ); + //virtual void cmdToggleSection( const XQCommand& command ); virtual void cmdCut( const XQCommand& command ); virtual void cmdCutUndo( const XQCommand& command ); virtual void cmdPaste( const XQCommand& command ); @@ -77,29 +76,15 @@ public: virtual void cmdNew( const XQCommand& command ); virtual void cmdNewUndo( const XQCommand& command ); - - - /*! - - Derzeit wird 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 ); - } - - */ + // Derzeit wird die default-implementierung von data/setData genutzt. hier wäre dann die + // Stelle um setData & data an externe 'handler' umzubiegen, siehe giovannies 'model-injection' signals: void xqItemChanged( const XQItem& item ); + void itemCreated( XQItem* newItem ); + void sectionCreated( const XQModelSection& section ); + void sectionToggled( const XQModelSection& section ); public slots: @@ -111,11 +96,7 @@ public slots: virtual void onCommandRedo( const XQCommand& command ); virtual void onCommandUndo( const XQCommand& command ); -signals: - void itemCreated( XQItem* newItem ); - void sectionCreated( const XQModelSection& section ); - void sectionToggled( const XQModelSection& section ); protected: