reworked section handling (a bit)
This commit is contained in:
@@ -59,10 +59,12 @@ void XQChildModel::setContent( const XQNodePtr& contentRoot )
|
|||||||
// wir speichern das parent des datenknoten auch in der
|
// wir speichern das parent des datenknoten auch in der
|
||||||
// section.
|
// section.
|
||||||
// contentEntry->parent == _contentRoot, aber halt nur weil das model flach ist
|
// contentEntry->parent == _contentRoot, aber halt nur weil das model flach ist
|
||||||
section.contentRootNode = contentEntry->parent();
|
section.setContentRootNode( contentEntry->parent() );
|
||||||
int newRow = _sections.lastRow(section);
|
int newRow = _sections.lastRow(section);
|
||||||
|
|
||||||
XQItemList list = _itemFactory.makeContentRow( section.sheetRootNode, contentEntry );
|
XQNodePtr node = section.sheetRootNode();
|
||||||
|
XQItemList list = _itemFactory.makeContentRow( node, contentEntry );
|
||||||
|
//XQItemList list = _itemFactory.makeContentRow( section.sheetRootNode, contentEntry );
|
||||||
|
|
||||||
// als Baum?
|
// als Baum?
|
||||||
//section.headerItem().appendRow( list );
|
//section.headerItem().appendRow( list );
|
||||||
|
@@ -41,3 +41,42 @@ void XQMainModel::initContextMenu()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//! erzeugt einen eintrag in der baum-übersicht.
|
||||||
|
|
||||||
|
XQItem* XQMainModel::createTreeEntry( XQNodePtr contentNode )
|
||||||
|
{
|
||||||
|
|
||||||
|
for(const auto& section : _sections )
|
||||||
|
{
|
||||||
|
qDebug() << " --- wtf1: " << contentNode->to_string();
|
||||||
|
qDebug() << " --- wtf2: " << section.sheetRootNode()->to_string();
|
||||||
|
/*
|
||||||
|
if( contentNode->attribute("State") == section.sheetRootNode->attribute("State") )
|
||||||
|
{
|
||||||
|
//XQItem* newTreeentry = _itemFactory.makeTreeChildItem( contentNode, section.sheetRootNode );
|
||||||
|
|
||||||
|
makeTreeChildItem:
|
||||||
|
// den itemtype des neuen items rausfinden
|
||||||
|
QString typeKey = sheetEntry->attribute("ItemType");
|
||||||
|
XQItemType* itemType = findItemTypeTemplate(typeKey); // throws
|
||||||
|
//XQItemType* itemType = makeItemType(sheetEntry); // throws
|
||||||
|
|
||||||
|
const QString* contentPtr = contentNode->attribute_ptr( "ProjectName" );
|
||||||
|
|
||||||
|
XQItem* newItem = new XQItem( itemType, contentPtr );
|
||||||
|
|
||||||
|
return newItem;
|
||||||
|
|
||||||
|
section.headerItem().appendRow( newTreeentry );
|
||||||
|
_treeTable->expand( section.modelIndex );
|
||||||
|
// ??
|
||||||
|
_treeTable->setCurrentIndex( section.modelIndex );
|
||||||
|
newTreeentry->setContentNode(contentNode);
|
||||||
|
emit xqItemCreated( newTreeentry );
|
||||||
|
return newTreeentry;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
throw XQException( "createTreeEntry: main model should not be empty!" );
|
||||||
|
}
|
||||||
|
@@ -32,7 +32,7 @@ public:
|
|||||||
explicit XQMainModel(QObject *parent = nullptr);
|
explicit XQMainModel(QObject *parent = nullptr);
|
||||||
virtual ~XQMainModel() = default;
|
virtual ~XQMainModel() = default;
|
||||||
|
|
||||||
|
XQItem* createTreeEntry( XQNodePtr contentNode );
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
|
@@ -271,39 +271,38 @@ void XQMainWindow::onTabClicked( int index )
|
|||||||
_mainTreeView->setCurrentIndex( _documentStore[index].treeItem->index() );
|
_mainTreeView->setCurrentIndex( _documentStore[index].treeItem->index() );
|
||||||
}
|
}
|
||||||
|
|
||||||
void XQMainWindow::onSectionCreated( const XQModelSection* section )
|
void XQMainWindow::onSectionCreated( const XQModelSection& section )
|
||||||
{
|
{
|
||||||
qDebug() << " --- XXX section created: " << section->row();
|
qDebug() << " --- XXX section created: " << section.contentType() << ":" << section.contentType();
|
||||||
}
|
}
|
||||||
|
|
||||||
void XQMainWindow::onSectionToggled( const XQModelSection* section )
|
void XQMainWindow::onSectionToggled( const XQModelSection& section )
|
||||||
{
|
{
|
||||||
qDebug() << " --- XXX section toggled: " << section->row();
|
qDebug() << " --- XXX section toggled: " << section.contentType() << ":" << section.sheetRootNode()->to_string();
|
||||||
}
|
}
|
||||||
|
|
||||||
//! liest eine XML datei namens 'fileName'
|
//! liest eine XML datei namens 'fileName'
|
||||||
|
|
||||||
void XQMainWindow::loadDocument( const QString& fileName )
|
void XQMainWindow::loadDocument( const QString& fileName )
|
||||||
{
|
{
|
||||||
|
|
||||||
// gibts die Datei?
|
// gibts die Datei?
|
||||||
if( !QFile::exists( fileName) )
|
if( !QFile::exists( fileName) )
|
||||||
throw XQException( "no such file", fileName );
|
throw XQException( "no such file", fileName );
|
||||||
|
|
||||||
// load data tree from xml file
|
|
||||||
XQNodeFactory treeLoader;
|
XQNodeFactory treeLoader;
|
||||||
|
// xml daten laden
|
||||||
XQNodePtr rawTree = treeLoader.load_tree( qPrintable(fileName) );
|
XQNodePtr rawTree = treeLoader.load_tree( qPrintable(fileName) );
|
||||||
|
|
||||||
// versteckten root node ignorieren
|
// versteckten root node ignorieren
|
||||||
XQNodePtr contentRoot = rawTree->first_child();
|
XQNodePtr contentRoot = rawTree->first_child();
|
||||||
|
|
||||||
// Project-ID behandeln
|
// Project-ID behandeln
|
||||||
const QString& pID = contentRoot->attribute(c_ProjectID);
|
const QString& pID = contentRoot->attribute(c_ProjectID);
|
||||||
int idx = _documentStore.indexOf( pID );
|
int idx = _documentStore.indexOf( pID );
|
||||||
if( idx > -1 )
|
if( idx > -1 )
|
||||||
{
|
{
|
||||||
const XQDocument& doc = _documentStore.at(idx);
|
const XQDocument& document = _documentStore.at(idx);
|
||||||
QMessageBox::warning( this, "Load Document", QString("File: %1 already loaded.").arg( fileName ) );
|
QMessageBox::warning( this, "Load Document", QString("File: %1 already loaded.").arg( fileName ) );
|
||||||
_mainTreeView->setCurrentIndex( doc.treeItem->index() );
|
_mainTreeView->setCurrentIndex( document.treeItem->index() );
|
||||||
_tabWidget->setCurrentIndex( idx );
|
_tabWidget->setCurrentIndex( idx );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -322,8 +321,9 @@ void XQMainWindow::loadDocument( const QString& fileName )
|
|||||||
// Ein neues Child-Model erzeugen
|
// Ein neues Child-Model erzeugen
|
||||||
XQChildModel* childModel = new XQChildModel(this);
|
XQChildModel* childModel = new XQChildModel(this);
|
||||||
|
|
||||||
// die Modelstruktur anlegen
|
connect( childModel, SIGNAL(sectionCreated(XQModelSection)), this, SLOT(onSectionCreated(XQModelSection)) );
|
||||||
childModel->initModel( c_ChildModelName );
|
connect( childModel, SIGNAL(sectionToggled(XQModelSection)), this, SLOT(onSectionToggled(XQModelSection)) );
|
||||||
|
|
||||||
|
|
||||||
// Den globalen undo-stack ...
|
// Den globalen undo-stack ...
|
||||||
childModel->setUndoStack(&_undoStack);
|
childModel->setUndoStack(&_undoStack);
|
||||||
@@ -331,24 +331,17 @@ void XQMainWindow::loadDocument( const QString& fileName )
|
|||||||
// und die TreeView übergeben
|
// und die TreeView übergeben
|
||||||
childModel->setTreeTable(childTreeView);
|
childModel->setTreeTable(childTreeView);
|
||||||
|
|
||||||
bool c1 = connect( childModel, SIGNAL(sectionCreated(const XQModelSection*)), this, SLOT(onSectionCreated(const XQModelSection*)) );
|
// create new entry in the left side main tree view
|
||||||
bool c2 = connect( childModel, SIGNAL(sectionToggled(const XQModelSection*)), this, SLOT(onSectionToggled(const XQModelSection*)) );
|
//XQItem* newEntry = _mainModelView.createTreeEntry( contentRoot );
|
||||||
|
//_mainTreeView->setCurrentIndex( newEntry->index() );
|
||||||
|
//_documentStore.addDocument( fileName, pTitle, newEntry, childModel );
|
||||||
|
|
||||||
qDebug() << " --- EWTF: " << c1 << ":" << c2;
|
// die Modelstruktur anlegen
|
||||||
|
childModel->initModel( c_ChildModelName );
|
||||||
|
|
||||||
// model inhalte laden
|
// model inhalte laden
|
||||||
childModel->setContent( contentRoot->first_child() );
|
childModel->setContent( contentRoot->first_child() );
|
||||||
|
|
||||||
/*
|
|
||||||
// create new entry in the left side main tree view
|
|
||||||
XQItem* newEntry = _mainModelView.createTreeEntry( contentRoot );
|
|
||||||
_mainTreeView->setCurrentIndex( newEntry->index() );
|
|
||||||
_documentStore.addDocument( fileName, pTitle, newEntry, childModel );
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -49,8 +49,8 @@ public slots:
|
|||||||
void onTreeItemClicked(const QModelIndex& index );
|
void onTreeItemClicked(const QModelIndex& index );
|
||||||
void onTabClicked( int index );
|
void onTabClicked( int index );
|
||||||
//void onItemCreated( XQItem* item );
|
//void onItemCreated( XQItem* item );
|
||||||
void onSectionCreated( const XQModelSection* section);
|
void onSectionCreated( const XQModelSection& section);
|
||||||
void onSectionToggled( const XQModelSection* section );
|
void onSectionToggled( const XQModelSection& section );
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@@ -62,6 +62,7 @@ protected:
|
|||||||
void loadDocument( const QString& fileName );
|
void loadDocument( const QString& fileName );
|
||||||
void saveDocument( const QString& fileName );
|
void saveDocument( const QString& fileName );
|
||||||
|
|
||||||
|
|
||||||
QUndoStack _undoStack;
|
QUndoStack _undoStack;
|
||||||
XQDocumentStore _documentStore;
|
XQDocumentStore _documentStore;
|
||||||
|
|
||||||
|
@@ -15,12 +15,11 @@
|
|||||||
#include <xqmodelsectionlist.h>
|
#include <xqmodelsectionlist.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//! kontstruktor. übergibt den start-index und einen model-knoten mit der beschreibung
|
//! kontstruktor. übergibt den start-index und einen model-knoten mit der beschreibung
|
||||||
//! der datenknoten.
|
//! der datenknoten.
|
||||||
|
|
||||||
XQModelSection::XQModelSection(const QModelIndex& aModelIndex, XQNodePtr aSheetNode)
|
XQModelSection::XQModelSection(const QModelIndex& modelIndex, XQNodePtr sheetNode)
|
||||||
: modelIndex{ aModelIndex }, sheetRootNode{ aSheetNode }
|
: _modelIndex{ modelIndex }, _sectionRootNode{ sheetNode }
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -30,7 +29,7 @@ XQModelSection::XQModelSection(const QModelIndex& aModelIndex, XQNodePtr aSheetN
|
|||||||
|
|
||||||
bool XQModelSection::operator==(const XQModelSection& other) const
|
bool XQModelSection::operator==(const XQModelSection& other) const
|
||||||
{
|
{
|
||||||
return modelIndex == other.modelIndex && sheetRootNode == other.sheetRootNode;
|
return _modelIndex == other._modelIndex && _sectionRootNode == other._sectionRootNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -38,7 +37,44 @@ bool XQModelSection::operator==(const XQModelSection& other) const
|
|||||||
|
|
||||||
bool XQModelSection::isValid() const
|
bool XQModelSection::isValid() const
|
||||||
{
|
{
|
||||||
return modelIndex.isValid() && sheetRootNode;
|
return _modelIndex.isValid() && _sectionRootNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QModelIndex& XQModelSection::modelIndex() const
|
||||||
|
{
|
||||||
|
return _modelIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
XQNodePtr XQModelSection::sectionRootNode() const
|
||||||
|
{
|
||||||
|
return _sectionRootNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Gibt den sheet-node zurück, das ist die model-beschreibung,
|
||||||
|
//! siehe modelsheet.xml:
|
||||||
|
//! <section>
|
||||||
|
//! <header>
|
||||||
|
//! <data> <- dort
|
||||||
|
|
||||||
|
//! __fix! das versteht doch kein mensch!
|
||||||
|
|
||||||
|
XQNodePtr XQModelSection::sheetRootNode() const
|
||||||
|
{
|
||||||
|
return _sectionRootNode->find_child_by_tag_name( c_Data );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//! Gibt den content root node zurück, das ist der
|
||||||
|
//! zeiger auf die realen inhalte.
|
||||||
|
|
||||||
|
XQNodePtr XQModelSection::contentRootNode() const
|
||||||
|
{
|
||||||
|
return _contentRootNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
void XQModelSection::setContentRootNode( const XQNodePtr contentRootNode )
|
||||||
|
{
|
||||||
|
_contentRootNode = contentRootNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -46,7 +82,15 @@ bool XQModelSection::isValid() const
|
|||||||
|
|
||||||
int XQModelSection::XQModelSection::row() const
|
int XQModelSection::XQModelSection::row() const
|
||||||
{
|
{
|
||||||
return modelIndex.row();
|
return _modelIndex.row();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//! gibt den 'content type' zurück.
|
||||||
|
|
||||||
|
const QString& XQModelSection::contentType() const
|
||||||
|
{
|
||||||
|
return _sectionRootNode->attribute( c_ContentType );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -54,9 +98,10 @@ int XQModelSection::XQModelSection::row() const
|
|||||||
|
|
||||||
XQItem& XQModelSection::XQModelSection::headerItem() const
|
XQItem& XQModelSection::XQModelSection::headerItem() const
|
||||||
{
|
{
|
||||||
return XQItem::xqItemFromIndex( modelIndex );
|
return XQItem::xqItemFromIndex( _modelIndex );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//! testet, ob die unter 'sectionKey' eine gültige section vorhanden ist.
|
//! testet, ob die unter 'sectionKey' eine gültige section vorhanden ist.
|
||||||
|
|
||||||
bool XQModelSectionList::hasValidSection(const QString& sectionKey) const
|
bool XQModelSectionList::hasValidSection(const QString& sectionKey) const
|
||||||
@@ -66,6 +111,7 @@ bool XQModelSectionList::hasValidSection(const QString& sectionKey) const
|
|||||||
return at(sectionKey).isValid();
|
return at(sectionKey).isValid();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//! gibt für einen model index die 'zuständige' section zurück.
|
//! gibt für einen model index die 'zuständige' section zurück.
|
||||||
|
|
||||||
const XQModelSection& XQModelSectionList::sectionFromIndex( const QModelIndex& index ) const
|
const XQModelSection& XQModelSectionList::sectionFromIndex( const QModelIndex& index ) const
|
||||||
@@ -83,11 +129,12 @@ const XQModelSection& XQModelSectionList::sectionFromRow(int itemRow ) const
|
|||||||
int i = size() - 1;
|
int i = size() - 1;
|
||||||
for (; i >= 0; --i)
|
for (; i >= 0; --i)
|
||||||
{
|
{
|
||||||
if ( at(i).modelIndex.row() < itemRow )
|
if ( at(i).modelIndex().row() < itemRow )
|
||||||
return at(i);
|
return at(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
static XQModelSection s_DummySection;
|
static XQModelSection s_DummySection;
|
||||||
|
|
||||||
return s_DummySection;
|
return s_DummySection;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -123,7 +170,7 @@ int XQModelSectionList::lastRow(const XQModelSection& section ) const
|
|||||||
{
|
{
|
||||||
// last section? return last row of model
|
// last section? return last row of model
|
||||||
if (index == size() - 1)
|
if (index == size() - 1)
|
||||||
return section.modelIndex.model()->rowCount();// - 1;
|
return section.modelIndex().model()->rowCount();// - 1;
|
||||||
// return row above the row of the next section -> last row of given section
|
// return row above the row of the next section -> last row of given section
|
||||||
return at(index+1).row();
|
return at(index+1).row();
|
||||||
}
|
}
|
||||||
@@ -138,7 +185,7 @@ void XQModelSectionList::dump() const
|
|||||||
qDebug() << " --- sections dump(): " <<size() << " entries.";
|
qDebug() << " --- sections dump(): " <<size() << " entries.";
|
||||||
for( int i = 0; i<size(); ++i )
|
for( int i = 0; i<size(); ++i )
|
||||||
{
|
{
|
||||||
QModelIndex idx = at(i).modelIndex;
|
QModelIndex idx = at(i).modelIndex();
|
||||||
qDebug() << " --- sections:" << i << "row: " << idx.row() << " keyOf(i): " << keyOf(i) << " indexData: "<< idx.data().toString() << " itemData: " << XQItem::xqItemFromIndex(idx).data(Qt::DisplayRole).toString();
|
qDebug() << " --- sections:" << i << "row: " << idx.row() << " keyOf(i): " << keyOf(i) << " indexData: "<< idx.data().toString() << " itemData: " << XQItem::xqItemFromIndex(idx).data(Qt::DisplayRole).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -24,21 +24,35 @@
|
|||||||
* @brief Struct containing data for a header section
|
* @brief Struct containing data for a header section
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct XQModelSection
|
class XQModelSection
|
||||||
{
|
{
|
||||||
QPersistentModelIndex modelIndex;
|
|
||||||
|
|
||||||
XQNodePtr sheetRootNode{};
|
public:
|
||||||
XQNodePtr contentRootNode{};
|
|
||||||
|
|
||||||
XQModelSection() = default;
|
XQModelSection() = default;
|
||||||
XQModelSection(const QModelIndex& aModelIndex, XQNodePtr aSheetNode);
|
XQModelSection(const QModelIndex& modelIndex, XQNodePtr sheetNode );
|
||||||
|
|
||||||
bool operator==(const XQModelSection& other) const;
|
bool operator==(const XQModelSection& other) const;
|
||||||
bool isValid() const;
|
bool isValid() const;
|
||||||
int row() const;
|
int row() const;
|
||||||
|
|
||||||
|
const QModelIndex& modelIndex() const;
|
||||||
|
XQNodePtr sectionRootNode() const;
|
||||||
|
XQNodePtr sheetRootNode() const;
|
||||||
|
XQNodePtr contentRootNode() const;
|
||||||
|
void setContentRootNode( const XQNodePtr dataRootNode );
|
||||||
|
|
||||||
|
const QString& contentType() const;
|
||||||
XQItem& headerItem() const;
|
XQItem& headerItem() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
QPersistentModelIndex _modelIndex;
|
||||||
|
|
||||||
|
XQNodePtr _sectionRootNode{};
|
||||||
|
XQNodePtr _contentRootNode{};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(XQModelSection)
|
Q_DECLARE_METATYPE(XQModelSection)
|
||||||
|
@@ -102,50 +102,49 @@ void XQViewModel::initModel(const QString& modelName)
|
|||||||
XQNodePtr modelSheet = _itemFactory.findModelSheet( modelName ); // throws
|
XQNodePtr modelSheet = _itemFactory.findModelSheet( modelName ); // throws
|
||||||
|
|
||||||
// #1: über alle sections
|
// #1: über alle sections
|
||||||
for( auto& section : modelSheet->children() )
|
for( auto& sectionNode : modelSheet->children() )
|
||||||
{
|
{
|
||||||
// #2: (optionalen?) header erzeugen
|
// #2: (optionalen?) header erzeugen
|
||||||
const XQNodePtr header = section->find_child_by_tag_name( "Header");
|
const XQNodePtr header = sectionNode->find_child_by_tag_name( c_Header );
|
||||||
if( header )
|
if( header )
|
||||||
{
|
{
|
||||||
XQItemList list = _itemFactory.makeContentRow( header, nullptr );
|
XQItemList list = _itemFactory.makeContentRow( header, nullptr );
|
||||||
addSection(list, section );
|
addSection(list, sectionNode );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//! hilfsfunktion: fügt die liste unserem model hinzu und erzeugt eine 'section'.
|
//! Hilfsfunktion: fügt die item-liste unserem model hinzu und erzeugt eine 'section'.
|
||||||
//! die section kann erst gültig sein, wenn die items im model gelandet sind,
|
//! die section kann erst gültig sein, wenn die items im model gelandet sind,
|
||||||
//! deswegen ist das hier zusammengefasst.
|
//! deswegen ist das hier zusammengefasst.
|
||||||
|
|
||||||
//! erzeugt dann eine section aus einer frisch erzeugten itemlist. der erste modelindex
|
//! Wrzeugt dann eine section aus einer frisch erzeugten itemlist. Der erste modelindex
|
||||||
//! der liste und der unterknoten 'Data' werden gespeichert.
|
//! der liste und der root knoten der model-beschreibung werden gespeichert.
|
||||||
|
|
||||||
void XQViewModel::addSection(const XQItemList& list, const XQNodePtr& sheetNode )
|
void XQViewModel::addSection(const XQItemList& list, const XQNodePtr& sectionNode )
|
||||||
{
|
{
|
||||||
// 1. die liste darf nicht leer sein
|
// 1. die liste darf nicht leer sein
|
||||||
Q_ASSERT(!list.isEmpty());
|
Q_ASSERT(!list.isEmpty());
|
||||||
// 2. sheetNode muss da sein
|
// 2. sectionNode muss da sein
|
||||||
Q_ASSERT(sheetNode);
|
Q_ASSERT(sectionNode);
|
||||||
// 3. 'ContenType' muss vorhanden sein
|
// 3. 'ContenType' muss vorhanden sein
|
||||||
if( !sheetNode->has_attribute( c_ContentType) )
|
if( !sectionNode->has_attribute( c_ContentType) )
|
||||||
throw XQException( "section list: Section node needs attribute 'ContentType'!");
|
throw XQException( "section list: Section node needs attribute 'ContentType'!");
|
||||||
// 4. Data child muss auch da sein
|
|
||||||
XQNodePtr dataNode = sheetNode->find_child_by_tag_name( c_Data );
|
|
||||||
if( !dataNode )
|
|
||||||
throw XQException( "section list: 'Data' child is missing!");
|
|
||||||
|
|
||||||
// 5. das erzeugt dann auch valide indices
|
// 5. das erzeugt dann auch valide indices
|
||||||
appendRow(list);
|
appendRow(list);
|
||||||
|
|
||||||
|
// 6. die beschreibung der daten liegt im unterknoten 'Data'
|
||||||
|
|
||||||
|
|
||||||
// 6. jetzt können wir auch die sction erzeugen
|
// 6. jetzt können wir auch die sction erzeugen
|
||||||
XQModelSection section(list[0]->index(), dataNode );
|
XQModelSection section(list[0]->index(), sectionNode );
|
||||||
_sections.addAtKey(sheetNode->attribute( c_ContentType), section);
|
_sections.addAtKey(sectionNode->attribute( c_ContentType), section);
|
||||||
|
|
||||||
// ... und es der welt mitteilen.
|
// ... und es der welt mitteilen.
|
||||||
emit sectionCreated( §ion );
|
emit sectionCreated( section );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -354,7 +353,7 @@ void XQViewModel::cmdCutUndo( XQCommand& command )
|
|||||||
const XQNodePtr& savedNode = entry.contentNode;
|
const XQNodePtr& savedNode = entry.contentNode;
|
||||||
// __fix! should not be _contentRoot!
|
// __fix! should not be _contentRoot!
|
||||||
savedNode->add_me_at( entry.nodePos, _contentRoot );
|
savedNode->add_me_at( entry.nodePos, _contentRoot );
|
||||||
XQItemList list = _itemFactory.makeContentRow( section.sheetRootNode, savedNode );
|
XQItemList list = _itemFactory.makeContentRow( section.sheetRootNode(), savedNode );
|
||||||
|
|
||||||
XQItem& firstItem = *((XQItem*)list[0]);
|
XQItem& firstItem = *((XQItem*)list[0]);
|
||||||
qDebug() << " --- Cut Undo: " << firstItem.text() << " " << firstItem.row() << " id#" << entry.contentNode->_id << " count: " << entry.contentNode.use_count();
|
qDebug() << " --- Cut Undo: " << firstItem.text() << " " << firstItem.row() << " id#" << entry.contentNode->_id << " count: " << entry.contentNode.use_count();
|
||||||
@@ -386,10 +385,10 @@ void XQViewModel::cmdPaste( XQCommand& command )
|
|||||||
for (auto& entry : _clipBoard )
|
for (auto& entry : _clipBoard )
|
||||||
{
|
{
|
||||||
// noch ein clone vom clone erzeugen ...
|
// noch ein clone vom clone erzeugen ...
|
||||||
XQNodePtr newNode = entry.contentNode->clone(section.contentRootNode );
|
XQNodePtr newNode = entry.contentNode->clone(section.contentRootNode() );
|
||||||
newNode->clone(section.contentRootNode )->add_me_at( nodePos );
|
newNode->clone(section.contentRootNode() )->add_me_at( nodePos );
|
||||||
// ... und damit eine frische item-row erzeugen
|
// ... und damit eine frische item-row erzeugen
|
||||||
XQItemList list = _itemFactory.makeContentRow( section.sheetRootNode, newNode );
|
XQItemList list = _itemFactory.makeContentRow( section.sheetRootNode(), newNode );
|
||||||
insertRow( insRow, list );
|
insertRow( insRow, list );
|
||||||
// die neue item-row selektieren
|
// die neue item-row selektieren
|
||||||
const QModelIndex& selIdx = list[0]->index();
|
const QModelIndex& selIdx = list[0]->index();
|
||||||
@@ -508,7 +507,7 @@ void XQViewModel::cmdToggleSection( XQCommand& command )
|
|||||||
for (int row = fstRow; row < lstRow; ++row )
|
for (int row = fstRow; row < lstRow; ++row )
|
||||||
_treeTable->setRowHidden( row, _treeTable->rootIndex(), !hidden );
|
_treeTable->setRowHidden( row, _treeTable->rootIndex(), !hidden );
|
||||||
|
|
||||||
emit sectionToggled( &_sections.sectionFromIndex(index) );
|
emit sectionToggled( _sections.sectionFromIndex(index) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -100,8 +100,8 @@ public slots:
|
|||||||
signals:
|
signals:
|
||||||
|
|
||||||
void itemCreated( XQItem* newItem );
|
void itemCreated( XQItem* newItem );
|
||||||
void sectionCreated( const XQModelSection* section );
|
void sectionCreated( const XQModelSection& section );
|
||||||
void sectionToggled( const XQModelSection* section );
|
void sectionToggled( const XQModelSection& section );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
@@ -53,7 +53,7 @@
|
|||||||
|
|
||||||
<DocumentDetailsModel>
|
<DocumentDetailsModel>
|
||||||
|
|
||||||
<Section ContentType="Panel">
|
<Section ContentType="Panel" firz="farz">
|
||||||
<Header Marker="Panel">
|
<Header Marker="Panel">
|
||||||
<PanelID Caption="Panel" ItemType="HeaderType" />
|
<PanelID Caption="Panel" ItemType="HeaderType" />
|
||||||
<PanelName Caption="Name" ItemType="HeaderType" Icon="BrowserStop" />
|
<PanelName Caption="Name" ItemType="HeaderType" Icon="BrowserStop" />
|
||||||
@@ -65,7 +65,7 @@
|
|||||||
<MaxVolt Caption="max. Volt" ItemType="HeaderType" />
|
<MaxVolt Caption="max. Volt" ItemType="HeaderType" />
|
||||||
<MaxAmpere Caption="max. Ampere" ItemType="HeaderType" />
|
<MaxAmpere Caption="max. Ampere" ItemType="HeaderType" />
|
||||||
</Header>
|
</Header>
|
||||||
<Data>
|
<Data Marker="Panel">
|
||||||
<!-- 'Icon' überschreibt den default wert im ItemType und erzeugt damit einen neuen ItemType-->
|
<!-- 'Icon' überschreibt den default wert im ItemType und erzeugt damit einen neuen ItemType-->
|
||||||
<PanelID ItemType="PlainType" Icon="DesktopIcon"/>
|
<PanelID ItemType="PlainType" Icon="DesktopIcon"/>
|
||||||
<PanelName ItemType="PlainType" Icon="BrowserStop"/>
|
<PanelName ItemType="PlainType" Icon="BrowserStop"/>
|
||||||
@@ -80,7 +80,7 @@
|
|||||||
</Data>
|
</Data>
|
||||||
</Section>
|
</Section>
|
||||||
|
|
||||||
<Section ContentType="Inverter">
|
<Section ContentType="Inverter" firz="farz">
|
||||||
<Header Marker="Inverter">
|
<Header Marker="Inverter">
|
||||||
<InverterID Caption="Inverter" ItemType="HeaderType" />
|
<InverterID Caption="Inverter" ItemType="HeaderType" />
|
||||||
<InverterName Caption="Name" ItemType="HeaderType" />
|
<InverterName Caption="Name" ItemType="HeaderType" />
|
||||||
@@ -90,7 +90,7 @@
|
|||||||
<NumStrings Caption="Strings" ItemType="HeaderType" />
|
<NumStrings Caption="Strings" ItemType="HeaderType" />
|
||||||
<Weight Caption="Weight" ItemType="HeaderType" />
|
<Weight Caption="Weight" ItemType="HeaderType" />
|
||||||
</Header>
|
</Header>
|
||||||
<Data>
|
<Data Marker="Inverter">
|
||||||
<InverterID Caption="Inverter" ItemType="ValueType" />
|
<InverterID Caption="Inverter" ItemType="ValueType" />
|
||||||
<InverterName Caption="Name" ItemType="ValueType" />
|
<InverterName Caption="Name" ItemType="ValueType" />
|
||||||
<Manufacturer Caption="Manufacturer" ItemType="ValueType" />
|
<Manufacturer Caption="Manufacturer" ItemType="ValueType" />
|
||||||
@@ -101,7 +101,7 @@
|
|||||||
</Data>
|
</Data>
|
||||||
</Section>
|
</Section>
|
||||||
|
|
||||||
<Section ContentType="Battery">
|
<Section ContentType="Battery" firz="farz">
|
||||||
<Header Marker="Battery">
|
<Header Marker="Battery">
|
||||||
<BatteryID Caption="Name" ItemType="HeaderType" />
|
<BatteryID Caption="Name" ItemType="HeaderType" />
|
||||||
<BatteryName Caption="Battery" ItemType="HeaderType" />
|
<BatteryName Caption="Battery" ItemType="HeaderType" />
|
||||||
@@ -111,7 +111,7 @@
|
|||||||
<MaxCurrent Caption="max. Current" ItemType="HeaderType" />
|
<MaxCurrent Caption="max. Current" ItemType="HeaderType" />
|
||||||
<MaxVolt Caption="max. Volt" ItemType="HeaderType" />
|
<MaxVolt Caption="max. Volt" ItemType="HeaderType" />
|
||||||
</Header>
|
</Header>
|
||||||
<Data>
|
<Data Marker="Bettery">
|
||||||
<BatteryID Caption="Battery" ItemType="ValueType" />
|
<BatteryID Caption="Battery" ItemType="ValueType" />
|
||||||
<BatteryName Caption="Name" ItemType="ValueType" />
|
<BatteryName Caption="Name" ItemType="ValueType" />
|
||||||
<Manufacturer Caption="Manufacturer" ItemType="ValueType" />
|
<Manufacturer Caption="Manufacturer" ItemType="ValueType" />
|
||||||
|
Reference in New Issue
Block a user