some renamings.
This commit is contained in:
@@ -31,6 +31,22 @@ XQChildModel::XQChildModel( QObject *parent )
|
||||
}
|
||||
|
||||
|
||||
|
||||
//! Erzeugt eine model-section und fügt den zugehörigen header ein.
|
||||
|
||||
void XQChildModel::addSectionEntry( const QString& key, const XQNodePtr& contentEntry )
|
||||
{
|
||||
const XQModelSection& section = _sections.sectionByKey( key );
|
||||
if(section.isValid() )
|
||||
{
|
||||
section.setContentRootNode( contentEntry->parent() );
|
||||
int newRow =_sections.lastRow(section);
|
||||
XQNodePtr sheetNode = section.sheetRootNode();
|
||||
XQItemList list = _itemFactory.makeRow( sheetNode, nullptr );
|
||||
insertRow( newRow, list);
|
||||
}
|
||||
}
|
||||
|
||||
//! erzegt den sichtbaren inhalt des models aus einem root-datenknoten.
|
||||
|
||||
void XQChildModel::addModelData( const XQNodePtr& contentRoot )
|
||||
@@ -46,7 +62,6 @@ void XQChildModel::addModelData( const XQNodePtr& contentRoot )
|
||||
// Das ist hier der Typ des Eintrags: Panel, Battery ...
|
||||
QString key = contentEntry->tag_name();
|
||||
|
||||
|
||||
// 'silent failure' hier der Datenbaum kann auch Knoten enthalten
|
||||
// die nicht für uns gedacht sind.
|
||||
if (!_sections.hasValidSection(key))
|
||||
@@ -69,28 +84,28 @@ void XQChildModel::addModelData( const XQNodePtr& contentRoot )
|
||||
{
|
||||
qDebug() << " --- AddModelData: CHILD Found for: :" << contentEntry->tag_name() << " sheet parent: " << sheetNode->tag_name();
|
||||
if( !sheetNode->has_children() )
|
||||
qDebug() << " --- AUA";
|
||||
//else
|
||||
{
|
||||
qDebug() << " --- no sheet node for children";
|
||||
continue;
|
||||
}Sehr geehrte Frau Hollerbaum,
|
||||
|
||||
Derzeit in Festanstellung, kann mir aber bin aber offen
|
||||
|
||||
Mein Fachgebiet ist Qt ma
|
||||
addSectionChildren( list.front(), sheetNode, contentEntry );
|
||||
}
|
||||
|
||||
} // for
|
||||
|
||||
}
|
||||
|
||||
|
||||
//! Erzeugt eine model-section und fügt den zugehörigen header ein.
|
||||
|
||||
void XQChildModel::addSectionEntry( const QString& key, const XQNodePtr& contentEntry )
|
||||
void XQChildModel::addSectionChildren( QStandardItem* parent, const XQNodePtr& sheetEntry, const XQNodePtr& contentRoot )
|
||||
{
|
||||
const XQModelSection& section = _sections.sectionByKey( key );
|
||||
if(section.isValid() )
|
||||
for (const auto& contentEntry : contentRoot->children())
|
||||
{
|
||||
section.setContentRootNode( contentEntry->parent() );
|
||||
int newRow =_sections.lastRow(section);
|
||||
XQNodePtr sheetNode = section.sheetRootNode();
|
||||
XQItemList list = _itemFactory.makeRow( sheetNode, nullptr );
|
||||
insertRow( newRow, list);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -30,7 +30,8 @@ public:
|
||||
virtual ~XQChildModel() = default;
|
||||
|
||||
void addModelData(const XQNodePtr& contentRoot );
|
||||
void addSectionEntry(const QString& key, const XQNodePtr& contentEntry );
|
||||
void addSectionEntry( const QString& key, const XQNodePtr& contentEntry );
|
||||
void addSectionChildren( QStandardItem* parent, const XQNodePtr& sheetEntry, const XQNodePtr& contentEntry );
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ XQItem* XQMainModel::addProjectItem( XQNodePtr contentNode )
|
||||
|
||||
void XQMainModel::addSectionItem( const XQModelSection& section, XQItem* projectItem )
|
||||
{
|
||||
XQNodePtr sheetNode = projectItem->sheetNode()->find_child_by_tag_name("CurrentSection");
|
||||
XQNodePtr sheetNode = projectItem->sheetNode()->child("CurrentSection");
|
||||
XQItem* newItem = _itemFactory.makeSingleItem( sheetNode, section.contentType() );
|
||||
projectItem->appendRow( newItem );
|
||||
expandNewItem(projectItem->index() );
|
||||
|
||||
@@ -42,7 +42,7 @@ void XQItemFactory::initItemFactory( const QString& modelSheetFileName )
|
||||
throw XQException("modelSheet load failed. ", modelSheetFileName);
|
||||
|
||||
// schritt #3: itemtype beschreibungen laden ...
|
||||
_typesSheet = _modelSheet->find_child_by_tag_name( "ItemTypes" );
|
||||
_typesSheet = _modelSheet->child( "ItemTypes" );
|
||||
// ... und testen
|
||||
if( !_typesSheet )
|
||||
throw XQException( "initItemFactory <ItemTypes> is null" );
|
||||
@@ -114,7 +114,7 @@ XQItemType* XQItemFactory::findItemTypeTemplate(const QString& key ) const
|
||||
|
||||
XQNodePtr XQItemFactory::findModelSheet( const QString& modelName ) const
|
||||
{
|
||||
XQNodePtr modelSheet = _modelSheet->find_child_by_tag_name( modelName );
|
||||
XQNodePtr modelSheet = _modelSheet->child( modelName );
|
||||
if( !modelSheet )
|
||||
throw XQException( "model sheet not found: ", modelName );
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ XQNodePtr XQModelSection::sectionRootNode() const
|
||||
|
||||
XQNodePtr XQModelSection::sheetRootNode() const
|
||||
{
|
||||
return _sectionSheetRootNode->find_child_by_tag_name( c_ModelSheet );
|
||||
return _sectionSheetRootNode->child( c_ModelSheet );
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -139,7 +139,7 @@ void XQViewModel::initModel(const QString& modelName)
|
||||
for( auto& sectionNode : modelSheet->children() )
|
||||
{
|
||||
// #2: (optionalen?) header erzeugen
|
||||
const XQNodePtr header = sectionNode->find_child_by_tag_name( c_Header );
|
||||
const XQNodePtr header = sectionNode->child( c_Header );
|
||||
if( header )
|
||||
{
|
||||
XQItemList list = _itemFactory.makeRow( header, nullptr );
|
||||
|
||||
@@ -206,6 +206,12 @@ namespace znode
|
||||
return !children().empty();
|
||||
}
|
||||
|
||||
//! testet, ob kinder vorhanden sind.
|
||||
bool has_child(str_cref tagname ) const
|
||||
{
|
||||
return child(tagname ) != nullptr;
|
||||
}
|
||||
|
||||
//! gibt das erste kind zurück
|
||||
zshared_node first_child()
|
||||
{
|
||||
@@ -229,6 +235,17 @@ namespace znode
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//
|
||||
zshared_node child(str_cref tagname ) const
|
||||
{
|
||||
for( auto child : _children )
|
||||
{
|
||||
if( child->tag_name() == tagname )
|
||||
return child;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//! hängt einen knoten an meine kinderliste an.
|
||||
int add_child( const zshared_node& node )
|
||||
{
|
||||
@@ -313,7 +330,7 @@ namespace znode
|
||||
|
||||
//! findet den ersten kind-knoten mit dem attribut 'attrkey' welches den
|
||||
//! wert 'attrvalue' hat.
|
||||
zshared_node find_child_by_attribute(str_cref attrkey, str_cref attrvalue )
|
||||
zshared_node find_child_by_attribute(str_cref attrkey, str_cref attrvalue ) const
|
||||
{
|
||||
for( auto child : _children )
|
||||
{
|
||||
@@ -323,18 +340,9 @@ namespace znode
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//
|
||||
zshared_node find_child_by_tag_name(str_cref tagname )
|
||||
{
|
||||
for( auto child : _children )
|
||||
{
|
||||
if( child->tag_name() == tagname )
|
||||
return child;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
zshared_node find_child_by_id( int id )
|
||||
|
||||
zshared_node find_child_by_id( int id ) const
|
||||
{
|
||||
for (auto child : _children )
|
||||
{
|
||||
|
||||
@@ -630,7 +630,7 @@ namespace pugi
|
||||
}
|
||||
|
||||
// Find child node using predicate. Returns first child for which predicate returned true.
|
||||
template <typename Predicate> xml_node find_child_by_tag_name(Predicate pred) const
|
||||
template <typename Predicate> xml_node child(Predicate pred) const
|
||||
{
|
||||
if (!_root) return xml_node();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user