invented creation-mode for items
This commit is contained in:
@@ -60,13 +60,13 @@ void XQChildModel::addModelData( const XQNodePtr& contentRoot )
|
|||||||
// section.
|
// section.
|
||||||
// contentEntry->parent == _contentRoot, aber halt nur weil das model flach ist
|
// contentEntry->parent == _contentRoot, aber halt nur weil das model flach ist
|
||||||
|
|
||||||
qDebug() << " --- add section ENTRY: " << key << " TagName: " << contentEntry->attribute("TagName");
|
//qDebug() << " --- add section ENTRY: " << key << " TagName: " << contentEntry->attribute("TagName");
|
||||||
|
|
||||||
section.setContentRootNode( contentEntry->parent() );
|
section.setContentRootNode( contentEntry->parent() );
|
||||||
int newRow = _sections.lastRow(section);
|
int newRow = _sections.lastRow(section);
|
||||||
|
|
||||||
XQNodePtr sheetNode = section.sheetRootNode();
|
XQNodePtr sheetNode = section.sheetRootNode();
|
||||||
XQItemList list = _itemFactory.makeRow( sheetNode, contentEntry );
|
XQItemList list = _itemFactory.makeRow( XQItemFactory::mData, sheetNode, contentEntry );
|
||||||
|
|
||||||
// als Baum?
|
// als Baum?
|
||||||
//section.headerItem().appendRow( list );
|
//section.headerItem().appendRow( list );
|
||||||
@@ -84,7 +84,7 @@ void XQChildModel::addSectionEntry( const QString& key, const XQNodePtr& content
|
|||||||
section.setContentRootNode( contentEntry->parent() );
|
section.setContentRootNode( contentEntry->parent() );
|
||||||
int newRow = _sections.lastRow(section);
|
int newRow = _sections.lastRow(section);
|
||||||
XQNodePtr sheetNode = section.sheetRootNode();
|
XQNodePtr sheetNode = section.sheetRootNode();
|
||||||
XQItemList list = _itemFactory.makeRow( sheetNode, contentEntry );
|
XQItemList list = _itemFactory.makeRow( XQItemFactory::mHeader, sheetNode, contentEntry );
|
||||||
insertRow( newRow, list);
|
insertRow( newRow, list);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -48,16 +48,18 @@ XQItem* XQMainModel::addProjectItem( XQNodePtr contentNode )
|
|||||||
// wir durchsuchen alle unsere section nach dem passenden content-type,
|
// wir durchsuchen alle unsere section nach dem passenden content-type,
|
||||||
// hier: content-type beschreibt die
|
// hier: content-type beschreibt die
|
||||||
|
|
||||||
/*
|
|
||||||
for(const auto& section : _sections )
|
for(const auto& section : _sections )
|
||||||
{
|
{
|
||||||
|
|
||||||
if( contentNode->attribute( c_ContentType) == section.contentType() )
|
if( contentNode->attribute( c_ContentType) == section.contentType() )
|
||||||
{
|
{
|
||||||
const QString* contentPtr = contentNode->attribute_ptr( "ProjectName" );
|
|
||||||
|
qDebug() << " --- add PROJECT: contentNode: " << contentNode->to_string();
|
||||||
|
|
||||||
// __fixme! das ist mist!
|
// __fixme! das ist mist!
|
||||||
const XQNodePtr sheetNode = section.sheetRootNode()->first_child();
|
const XQNodePtr sheetNode = section.sheetRootNode()->first_child();
|
||||||
XQItemList list = _itemFactory.makeHeaderRow( sheetNode, contentPtr );
|
XQItemList list = _itemFactory.makeRow( XQItemFactory::mSingle, sheetNode, contentNode, "ProjectName");
|
||||||
// erzeuger sheet node speichern
|
// erzeuger sheet node speichern
|
||||||
//newItem->setSheetNode( sheetNode );
|
//newItem->setSheetNode( sheetNode );
|
||||||
|
|
||||||
@@ -72,12 +74,12 @@ XQItem* XQMainModel::addProjectItem( XQNodePtr contentNode )
|
|||||||
//newItem->setContentNode( contentNode );
|
//newItem->setContentNode( contentNode );
|
||||||
//emit itemCreated( newItem );
|
//emit itemCreated( newItem );
|
||||||
|
|
||||||
return list[0];
|
return dynamic_cast<XQItem*>(list[0]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
throw XQException( "addProjectItem: main model should not be empty!" );
|
throw XQException( "addProjectItem: main model should not be empty!" );
|
||||||
}
|
}
|
||||||
|
@@ -346,7 +346,7 @@ void XQMainWindow::loadDocument( const QString& fileName )
|
|||||||
childModel->setTreeTable(childTreeView);
|
childModel->setTreeTable(childTreeView);
|
||||||
|
|
||||||
// neuen eintrag im übsichts-baum erzeugen
|
// neuen eintrag im übsichts-baum erzeugen
|
||||||
//_currentProjectItem = _mainModelView.addProjectItem( contentRoot );
|
_currentProjectItem = _mainModelView.addProjectItem( contentRoot );
|
||||||
//_documentStore.addDocument( fileName, pTitle, _currentProjectItem, childModel );
|
//_documentStore.addDocument( fileName, pTitle, _currentProjectItem, childModel );
|
||||||
|
|
||||||
qDebug() << " --- ZZZ und jetzt:";
|
qDebug() << " --- ZZZ und jetzt:";
|
||||||
|
@@ -305,7 +305,7 @@ XQItemList XQItemFactory::createGenericRow( const XQNodePtr& contentNode, const
|
|||||||
|
|
||||||
//! erzeugt eine item-row.
|
//! erzeugt eine item-row.
|
||||||
|
|
||||||
XQItemList XQItemFactory::makeRow( const XQNodePtr& sheetNode, const XQNodePtr& contentNode )
|
XQItemList XQItemFactory::makeRow(CreationMode mode, const XQNodePtr& sheetNode, const XQNodePtr& contentNode, const QString& captionKey )
|
||||||
{
|
{
|
||||||
|
|
||||||
XQItemList list;
|
XQItemList list;
|
||||||
@@ -321,7 +321,7 @@ XQItemList XQItemFactory::makeRow( const XQNodePtr& sheetNode, const XQNodePtr&
|
|||||||
//
|
//
|
||||||
|
|
||||||
for( const auto& sheetEntry : sheetNode->children() )
|
for( const auto& sheetEntry : sheetNode->children() )
|
||||||
list.append( makeItem( sheetEntry, contentNode ) );
|
list.append( makeItem( mode, sheetEntry, contentNode, captionKey ) );
|
||||||
|
|
||||||
Q_ASSERT(!list.empty());
|
Q_ASSERT(!list.empty());
|
||||||
|
|
||||||
@@ -338,19 +338,29 @@ XQItemList XQItemFactory::makeRow( const XQNodePtr& sheetNode, const XQNodePtr&
|
|||||||
//! wenn der content node nicht gesetzt ist, wird stattdess das attribut 'Caption' aus der typ-beschreibung
|
//! 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.
|
//! verwendet: es handelt sich dann um ein header item, das erzeugt wurde.
|
||||||
|
|
||||||
XQItem* XQItemFactory::makeItem( const XQNodePtr& sheetNode, const XQNodePtr& contentNode )
|
XQItem* XQItemFactory::makeItem(CreationMode mode, const XQNodePtr& sheetNode, const XQNodePtr& contentNode, const QString& captionKey )
|
||||||
{
|
{
|
||||||
// den itemtype des neuen items rausfinden
|
// den itemtype des neuen items rausfinden
|
||||||
XQItemType* itemType = makeItemType(sheetNode); // throws
|
XQItemType* itemType = makeItemType(sheetNode); // throws
|
||||||
|
|
||||||
const QString* contentPtr{};
|
const QString* contentPtr{};
|
||||||
|
|
||||||
// das ist Unterschied vom HeaderItem zum normalen Item: Der Titel kommt aus der Modelbeschreibung
|
// das ist Unterschied vom HeaderItem zum normalen Item: Der Titel kommt aus der Modelbeschreibung,
|
||||||
if(!contentNode)
|
// sonst wird der content indirekt über den tag-name des sheetnode geholt
|
||||||
contentPtr = sheetNode->attribute_ptr(c_Caption);
|
|
||||||
else
|
switch( mode )
|
||||||
// der content wird indirect über den tag-name des sheetnode geholt
|
{
|
||||||
contentPtr = contentNode->attribute_ptr( sheetNode->tag_name() );
|
case mHeader:
|
||||||
|
contentPtr = sheetNode->attribute_ptr(captionKey);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case mData:
|
||||||
|
contentPtr = contentNode->attribute_ptr( sheetNode->tag_name() );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case mSingle:
|
||||||
|
contentPtr = contentNode->attribute_ptr( captionKey );
|
||||||
|
}
|
||||||
|
|
||||||
XQItem* newItem = new XQItem( itemType, contentPtr);
|
XQItem* newItem = new XQItem( itemType, contentPtr);
|
||||||
|
|
||||||
|
@@ -28,13 +28,20 @@ class XQItemFactory : public xsingleton<XQItemFactory>
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
enum CreationMode
|
||||||
|
{
|
||||||
|
mHeader,
|
||||||
|
mData,
|
||||||
|
mSingle
|
||||||
|
};
|
||||||
|
|
||||||
void initItemFactory(const QString& modelSheetFileName );
|
void initItemFactory(const QString& modelSheetFileName );
|
||||||
|
|
||||||
XQNodePtr findModelSheet( const QString& modelName ) const;
|
XQNodePtr findModelSheet( const QString& modelName ) const;
|
||||||
|
|
||||||
//XQItemList makeEmptyRow( const XQNodePtr& contentNode, const XQNodePtr& sheetNode );
|
//XQItemList makeEmptyRow( const XQNodePtr& contentNode, const XQNodePtr& sheetNode );
|
||||||
|
|
||||||
XQItemList makeRow( const XQNodePtr& sheetNode, const XQNodePtr& contentNode );
|
XQItemList makeRow( CreationMode mode, const XQNodePtr& sheetNode, const XQNodePtr& contentNode, const QString& captionKey=c_Caption );
|
||||||
|
|
||||||
// wozu ist das gut?
|
// wozu ist das gut?
|
||||||
//XQItemList createGenericRow( const XQNodePtr& contentNode, const XQNodePtr& sheetNode );
|
//XQItemList createGenericRow( const XQNodePtr& contentNode, const XQNodePtr& sheetNode );
|
||||||
@@ -49,7 +56,7 @@ protected:
|
|||||||
|
|
||||||
bool isValid();
|
bool isValid();
|
||||||
|
|
||||||
XQItem* makeItem( const XQNodePtr& sheetNode, const XQNodePtr& contentNode );
|
XQItem* makeItem( CreationMode mode, const XQNodePtr& sheetNode, const XQNodePtr& contentNode, const QString& captionKey );
|
||||||
|
|
||||||
// shortcuts
|
// shortcuts
|
||||||
using ItemConfigFunc = std::function<void( XQItem* item, const QString& attrValue, XQNodePtr contentNode, XQNodePtr sheetNode )>;
|
using ItemConfigFunc = std::function<void( XQItem* item, const QString& attrValue, XQNodePtr contentNode, XQNodePtr sheetNode )>;
|
||||||
|
@@ -65,10 +65,6 @@ class XQModelSectionList : public XQMaptor<XQModelSection>
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
XQModelSectionList() = default;
|
|
||||||
virtual ~XQModelSectionList() = default;
|
|
||||||
|
|
||||||
void createSectionEntry(const XQItemList& list, const XQNodePtr& sheetNode );
|
|
||||||
bool hasValidSection(const QString& sectionKey) const;
|
bool hasValidSection(const QString& sectionKey) const;
|
||||||
|
|
||||||
const XQModelSection& sectionFromRow( int row ) const;
|
const XQModelSection& sectionFromRow( int row ) const;
|
||||||
|
@@ -111,7 +111,7 @@ void XQViewModel::initModel(const QString& modelName)
|
|||||||
const XQNodePtr header = sectionNode->find_child_by_tag_name( c_Header );
|
const XQNodePtr header = sectionNode->find_child_by_tag_name( c_Header );
|
||||||
if( header )
|
if( header )
|
||||||
{
|
{
|
||||||
XQItemList list = _itemFactory.makeRow( header, nullptr );
|
XQItemList list = _itemFactory.makeRow( XQItemFactory::mHeader, header, nullptr );
|
||||||
addSection(list, sectionNode );
|
addSection(list, sectionNode );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -138,9 +138,6 @@ void XQViewModel::addSection(const XQItemList& list, const XQNodePtr& sectionNod
|
|||||||
// 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(), sectionNode );
|
XQModelSection section(list[0]->index(), sectionNode );
|
||||||
_sections.addAtKey(sectionNode->attribute( c_ContentType), section);
|
_sections.addAtKey(sectionNode->attribute( c_ContentType), section);
|
||||||
@@ -355,7 +352,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.makeRow( section.sheetRootNode(), savedNode );
|
XQItemList list = _itemFactory.makeRow( XQItemFactory::mData, 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();
|
||||||
@@ -393,7 +390,7 @@ void XQViewModel::cmdPaste( XQCommand& command )
|
|||||||
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.makeRow( section.sheetRootNode(), newNode );
|
XQItemList list = _itemFactory.makeRow( XQItemFactory::mData, 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();
|
||||||
|
@@ -235,7 +235,7 @@ namespace znode
|
|||||||
|
|
||||||
auto it = s_fixed_attributes_ptr.find(key);
|
auto it = s_fixed_attributes_ptr.find(key);
|
||||||
if (it != s_fixed_attributes_ptr.end() )
|
if (it != s_fixed_attributes_ptr.end() )
|
||||||
(this->*(it->second))();
|
return (this->*(it->second))();
|
||||||
|
|
||||||
return &s_dummy_value;
|
return &s_dummy_value;
|
||||||
}
|
}
|
||||||
|
@@ -59,7 +59,7 @@
|
|||||||
|
|
||||||
<DocumentDetailsModel>
|
<DocumentDetailsModel>
|
||||||
|
|
||||||
<Section ContentType="Panel" >
|
<Section ContentType="Panel" CatchBlock="TagName=Panel">
|
||||||
<Header>
|
<Header>
|
||||||
<PanelID Caption="Panel" ItemType="HeaderType" />
|
<PanelID Caption="Panel" ItemType="HeaderType" />
|
||||||
<PanelName Caption="Name" ItemType="HeaderType" Icon="BrowserStop" />
|
<PanelName Caption="Name" ItemType="HeaderType" Icon="BrowserStop" />
|
||||||
|
Reference in New Issue
Block a user