refurbished old style item creation.
This commit is contained in:
@@ -62,9 +62,8 @@ void XQChildModel::setContent( const XQNodePtr& contentRoot )
|
||||
section.setContentRootNode( contentEntry->parent() );
|
||||
int newRow = _sections.lastRow(section);
|
||||
|
||||
XQNodePtr node = section.sheetRootNode();
|
||||
XQItemList list = _itemFactory.makeContentRow( node, contentEntry );
|
||||
//XQItemList list = _itemFactory.makeContentRow( section.sheetRootNode, contentEntry );
|
||||
XQNodePtr sheetNode = section.sheetRootNode();
|
||||
XQItemList list = _itemFactory.makeRow( sheetNode, contentEntry );
|
||||
|
||||
// als Baum?
|
||||
//section.headerItem().appendRow( list );
|
||||
|
@@ -48,6 +48,7 @@ XQItem* XQMainModel::addProjectItem( XQNodePtr contentNode )
|
||||
// wir durchsuchen alle unsere section nach dem passenden content-type,
|
||||
// hier: content-type beschreibt die
|
||||
|
||||
/*
|
||||
for(const auto& section : _sections )
|
||||
{
|
||||
|
||||
@@ -76,7 +77,8 @@ XQItem* XQMainModel::addProjectItem( XQNodePtr contentNode )
|
||||
}
|
||||
|
||||
}
|
||||
.
|
||||
*/
|
||||
|
||||
throw XQException( "addProjectItem: main model should not be empty!" );
|
||||
}
|
||||
|
||||
|
@@ -303,28 +303,9 @@ XQItemList XQItemFactory::createGenericRow( const XQNodePtr& contentNode, const
|
||||
*/
|
||||
|
||||
|
||||
|
||||
//! erzeugt eine header-item row.
|
||||
|
||||
XQItemList XQItemFactory::makeHeaderRow( const XQNodePtr& sheetNode, const QString& caption )
|
||||
{
|
||||
|
||||
XQItemList list;
|
||||
|
||||
for( const auto& sheetEntry : sheetNode->children() )
|
||||
{
|
||||
list.append( makeHeaderItem( sheetEntry, caption ) );
|
||||
}
|
||||
|
||||
Q_ASSERT(!list.empty());
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
//! erzeugt eine item-row.
|
||||
|
||||
XQItemList XQItemFactory::makeContentRow( const XQNodePtr& sheetNode, const XQNodePtr& contentNode )
|
||||
XQItemList XQItemFactory::makeRow( const XQNodePtr& sheetNode, const XQNodePtr& contentNode )
|
||||
{
|
||||
|
||||
XQItemList list;
|
||||
@@ -340,65 +321,38 @@ XQItemList XQItemFactory::makeContentRow( const XQNodePtr& sheetNode, const XQNo
|
||||
//
|
||||
|
||||
for( const auto& sheetEntry : sheetNode->children() )
|
||||
{
|
||||
list.append( makeContentItem( sheetEntry, contentNode ) );
|
||||
}
|
||||
list.append( makeItem( sheetEntry, contentNode ) );
|
||||
|
||||
Q_ASSERT(!list.empty());
|
||||
|
||||
// wir merken uns den original content node auch, aber
|
||||
// wir merken uns den original content node auch, aber
|
||||
// im ersten Item.
|
||||
dynamic_cast<XQItem*>(list[0])->setContentNode(contentNode);
|
||||
dynamic_cast<XQItem*>(list[0])->setContentNode(contentNode);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
XQItem* XQItemFactory::makeHeaderItem( const XQNodePtr& sheetNode, const QString& caption )
|
||||
{
|
||||
// den itemtype des neuen items rausfinden
|
||||
XQItemType* itemType = makeItemType(sheetNode); // throws
|
||||
|
||||
// das ist Unterschied zum normalen Item: Der Titel kommt aus der Modelbeschreibung
|
||||
// der content wird indirect über den tag-name des sheetnode geholt
|
||||
|
||||
XQItem* newItem = new XQItem( itemType, sheetNode->attribute_ptr(caption) );
|
||||
|
||||
// __fixme!
|
||||
if( newItem->isCheckable() )
|
||||
newItem->setCheckState( Qt::Checked );
|
||||
|
||||
return newItem;
|
||||
}
|
||||
|
||||
//! fixme! unsinn!
|
||||
//! erzeugt ein XQItem aus einer typ-beschreibung ('sheetNode') und einem daten-knoten ('contentNode').
|
||||
//! wenn der content node nicht gesetzt ist, wird stattdess das attribut 'Caption' aus der typ-beschreibung
|
||||
//! verwendet: es handelt sich dann um ein header item, das erzeugt wurde.
|
||||
|
||||
XQItem* XQItemFactory::makeContentItem( const XQNodePtr& sheetNode, const XQNodePtr& contentNode )
|
||||
XQItem* XQItemFactory::makeItem( const XQNodePtr& sheetNode, const XQNodePtr& contentNode )
|
||||
{
|
||||
// den itemtype des neuen items rausfinden
|
||||
XQItemType* itemType = makeItemType(sheetNode); // throws
|
||||
|
||||
// das ist Unterschied zum normalen Item: Der Titel kommt aus der Modelbeschreibung
|
||||
// der content wird indirect über den tag-name des sheetnode geholt
|
||||
const QString* contentPtr{};
|
||||
|
||||
// das ist Unterschied vom HeaderItem zum normalen Item: Der Titel kommt aus der Modelbeschreibung
|
||||
if(!contentNode)
|
||||
return makeItem( sheetNode, sheetNode->attribute_ptr(c_Caption) );
|
||||
|
||||
contentPtr = sheetNode->attribute_ptr(c_Caption);
|
||||
else
|
||||
// der content wird indirect über den tag-name des sheetnode geholt
|
||||
const QString* contentPtr = contentNode->attribute_ptr( sheetNode->tag_name() );
|
||||
return makeItem( sheetNode, contentPtr );
|
||||
}
|
||||
contentPtr = contentNode->attribute_ptr( sheetNode->tag_name() );
|
||||
|
||||
|
||||
XQItem* XQItemFactory::makeItem( const XQNodePtr& sheetNode, const QString* contentPtr )
|
||||
{
|
||||
// den itemtype des neuen items rausfinden
|
||||
XQItemType* itemType = makeItemType(sheetNode); // throws
|
||||
XQItem* newItem = new XQItem( itemType, contentPtr );
|
||||
XQItem* newItem = new XQItem( itemType, contentPtr);
|
||||
|
||||
// __fixme!
|
||||
if( newItem->isCheckable() )
|
||||
@@ -408,4 +362,3 @@ XQItem* XQItemFactory::makeItem( const XQNodePtr& sheetNode, const QString* cont
|
||||
|
||||
return newItem;
|
||||
}
|
||||
|
||||
|
@@ -34,8 +34,7 @@ public:
|
||||
|
||||
//XQItemList makeEmptyRow( const XQNodePtr& contentNode, const XQNodePtr& sheetNode );
|
||||
|
||||
XQItemList makeHeaderRow( const XQNodePtr& sheetNode, const QString& caption = c_Caption );
|
||||
XQItemList makeContentRow( const XQNodePtr& sheetNode, const XQNodePtr& contentNode );
|
||||
XQItemList makeRow( const XQNodePtr& sheetNode, const XQNodePtr& contentNode );
|
||||
|
||||
// wozu ist das gut?
|
||||
//XQItemList createGenericRow( const XQNodePtr& contentNode, const XQNodePtr& sheetNode );
|
||||
@@ -50,11 +49,7 @@ protected:
|
||||
|
||||
bool isValid();
|
||||
|
||||
XQItem* makeHeaderItem( const XQNodePtr& sheetNode, const QString& caption );
|
||||
XQItem* makeContentItem( const XQNodePtr& sheetNode, const XQNodePtr& contentNode );
|
||||
|
||||
XQItem* makeItem( const XQNodePtr& sheetNode, const XQNodePtr& contentNode );
|
||||
XQItem* makeItem( const XQNodePtr& sheetNode, const QString* contentPtr );
|
||||
|
||||
// shortcuts
|
||||
using ItemConfigFunc = std::function<void( XQItem* item, const QString& attrValue, XQNodePtr contentNode, XQNodePtr sheetNode )>;
|
||||
|
@@ -108,7 +108,8 @@ void XQViewModel::initModel(const QString& modelName)
|
||||
const XQNodePtr header = sectionNode->find_child_by_tag_name( c_Header );
|
||||
if( header )
|
||||
{
|
||||
XQItemList list = _itemFactory.makeHeaderRow( header );
|
||||
|
||||
XQItemList list = _itemFactory.makeRow( header, nullptr );
|
||||
addSection(list, sectionNode );
|
||||
}
|
||||
|
||||
@@ -353,7 +354,7 @@ void XQViewModel::cmdCutUndo( XQCommand& command )
|
||||
const XQNodePtr& savedNode = entry.contentNode;
|
||||
// __fix! should not be _contentRoot!
|
||||
savedNode->add_me_at( entry.nodePos, _contentRoot );
|
||||
XQItemList list = _itemFactory.makeContentRow( section.sheetRootNode(), savedNode );
|
||||
XQItemList list = _itemFactory.makeRow( section.sheetRootNode(), savedNode );
|
||||
|
||||
XQItem& firstItem = *((XQItem*)list[0]);
|
||||
qDebug() << " --- Cut Undo: " << firstItem.text() << " " << firstItem.row() << " id#" << entry.contentNode->_id << " count: " << entry.contentNode.use_count();
|
||||
@@ -388,7 +389,7 @@ void XQViewModel::cmdPaste( XQCommand& command )
|
||||
XQNodePtr newNode = entry.contentNode->clone(section.contentRootNode() );
|
||||
newNode->clone(section.contentRootNode() )->add_me_at( nodePos );
|
||||
// ... und damit eine frische item-row erzeugen
|
||||
XQItemList list = _itemFactory.makeContentRow( section.sheetRootNode(), newNode );
|
||||
XQItemList list = _itemFactory.makeRow( section.sheetRootNode(), newNode );
|
||||
insertRow( insRow, list );
|
||||
// die neue item-row selektieren
|
||||
const QModelIndex& selIdx = list[0]->index();
|
||||
|
Reference in New Issue
Block a user