mini sucess

This commit is contained in:
2025-08-12 23:41:36 +02:00
parent 756ec3f1fc
commit 7c267bcb33
8 changed files with 109 additions and 48 deletions

View File

@@ -24,6 +24,10 @@
const QString c_Version = "0.1.1 04.09.2024"; const QString c_Version = "0.1.1 04.09.2024";
const QString c_ItemType = "ItemType";
const QString c_Caption = "Caption";
const QString c_Header = "Header";
const QString c_MainModelName = "DocumentTreeModel"; const QString c_MainModelName = "DocumentTreeModel";
const QString c_ChildModelName = "DocumentDetailsModel"; const QString c_ChildModelName = "DocumentDetailsModel";
const QString c_ProjectID = "ProjectID"; const QString c_ProjectID = "ProjectID";

View File

@@ -38,17 +38,22 @@ XQMainModel::XQMainModel(QObject *parent )
void XQMainModel::initModel(const QString& modelName) void XQMainModel::initModel(const QString& modelName)
{ {
XQNodePtr modelSheet = _itemFactory.findModelSheet( modelName );
// #1: create structure: create static sections for this model // model rootnode finden -> <ModelX>
for( auto& sheetNode : modelSheet->children() ) XQNodePtr modelSheet = _itemFactory.findModelSheet( modelName ); // throws
// #1: über alle sections
for( auto& section : modelSheet->children() )
{ {
qDebug() << " create main model: " << sheetNode->tag_name(); // #2: (optionalen) header erzeugen
const XQNodePtr header = section->find_child_by_tag_name( "Header");
XQItemList list = { _itemFactory.makeHeaderItem( sheetNode ) }; if( header )
{
XQItemList list = _itemFactory.makeHeader( header );
Q_ASSERT(!list.isEmpty()); Q_ASSERT(!list.isEmpty());
addSection(list, sheetNode ); addSection(list, section );
//appendRow( list ); }
} }
} }

View File

@@ -85,10 +85,11 @@ void XQMainWindow::initMainWindow()
// hand over left side navigation tree // hand over left side navigation tree
_mainModelView.setTreeTable(_mainTreeView); _mainModelView.setTreeTable(_mainTreeView);
// #1. init the left side main tree view // #1. init the left side main tree view
_mainModelView.initModel( c_MainModelName ); //_mainModelView.initModel( c_MainModelName );
_mainModelView.initModel( "ModelX" );
// #2. load demo data // #2. load demo data
loadDocument( c_DocumentFileName1 ); //loadDocument( c_DocumentFileName1 );
//loadDocument( c_DocumentFileName2 ); //loadDocument( c_DocumentFileName2 );
qDebug() << " --- all here: " << XQNode::s_Count; qDebug() << " --- all here: " << XQNode::s_Count;

View File

@@ -135,19 +135,6 @@ XQItem* XQItemFactory::makeHeaderItem( const XQNodePtr& sheetEntry )
} }
XQItem* XQItemFactory::makeContentItem( const XQNodePtr& contentNode, const XQNodePtr& sheetEntry )
{
// 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( sheetEntry->tag_name() );
return new XQItem( itemType, contentPtr );
}
XQItem* XQItemFactory::makeTreeChildItem( const XQNodePtr& contentNode, const XQNodePtr& sheetEntry ) XQItem* XQItemFactory::makeTreeChildItem( const XQNodePtr& contentNode, const XQNodePtr& sheetEntry )
{ {
@@ -295,6 +282,56 @@ QVariant XQItemFactory::makeVariant( int dataRole, const QString& source ) const
/// ------------------------------------------------ /// ------------------------------------------------
/// ///
XQItem* XQItemFactory::makeContentItem( const XQNodePtr& contentNode, const XQNodePtr& sheetEntry )
{
// den itemtype des neuen items rausfinden
QString typeKey = sheetEntry->attribute(c_ItemType);
//XQItemType* itemType = findItemTypeTemplate(typeKey); // throws
XQItemType* itemType = makeItemType(sheetEntry); // throws
// das ist Unterschied zum normalen Item: Der Titel kommt aus der Modelbeschreibung
const QString* contentPtr = contentNode->attribute_ptr( sheetEntry->tag_name() );
return new XQItem( itemType, contentPtr );
}
XQItem* XQItemFactory::makeItem( const XQNodePtr& sheetNode, const XQNodePtr& contentNode )
{
// den itemtype des neuen items rausfinden
QString typeKey = sheetNode->attribute(c_ItemType);
//XQItemType* itemType = makeItemType(sheetEntry); // throws
XQItemType* itemType = findItemTypeTemplate(typeKey);
// fallunterscheidung beim inhalt:
const QString* contentPtr{};
// das ist Unterschied zum normalen Item: Der Titel kommt aus der Modelbeschreibung
if(!contentNode)
contentPtr = sheetNode->attribute_ptr(c_Caption);
else
// der content wird indirect über den tag-name des sheetnode geholt
contentPtr = contentNode->attribute_ptr( sheetNode->tag_name() );
return new XQItem( itemType, contentPtr );
}
XQItemList XQItemFactory::makeHeader( const XQNodePtr& headerNode )
{
XQItemList list;
for( const auto& headerEntry : headerNode->children() )
{
qDebug() << " --- headerEntry: " << headerEntry->tag_name() << ": " << headerEntry->attribute( "ItemType") << headerEntry->attribute( "Caption");
XQItem* headerItem = makeItem( headerEntry );
list.append( headerItem );
}
return list;
}
XQItemList XQItemFactory::makeHeaderRow( const XQNodePtr& sheetNode ) XQItemList XQItemFactory::makeHeaderRow( const XQNodePtr& sheetNode )
{ {
XQItemList list; XQItemList list;

View File

@@ -36,11 +36,16 @@ public:
XQItem* makeContentItem( const XQNodePtr& contentNode, const XQNodePtr& sheetEntry ); XQItem* makeContentItem( const XQNodePtr& contentNode, const XQNodePtr& sheetEntry );
XQItem* makeTreeChildItem( const XQNodePtr& contentNode, const XQNodePtr& sheetEntry ); XQItem* makeTreeChildItem( const XQNodePtr& contentNode, const XQNodePtr& sheetEntry );
virtual XQItemList makeHeaderRow( const XQNodePtr& sheetNode ); XQItem* makeItem( const XQNodePtr& sheetNode, const XQNodePtr& contentNode=nullptr);
virtual XQItemList makeContentRow( const XQNodePtr& contentNode, const XQNodePtr& sheetNode ); XQItemList makeHeader( const XQNodePtr& sheetNode );
virtual XQItemList makeEmptyRow( const XQNodePtr& contentNode, const XQNodePtr& sheetNode );
XQItemList makeHeaderRow( const XQNodePtr& sheetNode );
XQItemList makeContentRow( const XQNodePtr& contentNode, const XQNodePtr& sheetNode );
XQItemList makeEmptyRow( const XQNodePtr& contentNode, const XQNodePtr& sheetNode );
// wozu ist das gut? // wozu ist das gut?
virtual XQItemList createGenericRow( const XQNodePtr& contentNode, const XQNodePtr& sheetNode ); XQItemList createGenericRow( const XQNodePtr& contentNode, const XQNodePtr& sheetNode );
void setItemDataFromString( XQItem& item, const QString& roleKey, const QString& source ) const; void setItemDataFromString( XQItem& item, const QString& roleKey, const QString& source ) const;

View File

@@ -91,7 +91,7 @@ void XQViewModel::initModel( const QString& modelName)
section section
header header
section section
...
*/ */

View File

@@ -18,6 +18,7 @@
#include <QUndoStack> #include <QUndoStack>
#include <QMenu> #include <QMenu>
#include <QStandardItemModel> #include <QStandardItemModel>
#include <QAbstractItemView>
#include <xqsimpleclipboard.h> #include <xqsimpleclipboard.h>
#include <xqmodelsectionlist.h> #include <xqmodelsectionlist.h>
@@ -30,18 +31,7 @@ class XQItem;
class XQCommand; class XQCommand;
/** //! ein erweitertes QStandardItemModel welches 'seine' view bereits enthält.
* @brief Abstract baseclass of all modelviews: Extends QStandardItemModel with a treeview.
*/
// might be own implementation of QAbstractItemModel, not done yet.
// using QStandardItemModel = XQSimpleItemModel;
using QStandardItemModel = QStandardItemModel;
/**
* @brief The XQViewModel class: An extendend QStandardItem model
* containing its own view.
*/
class XQViewModel : public QStandardItemModel class XQViewModel : public QStandardItemModel
{ {
@@ -131,6 +121,7 @@ protected:
XQModelSectionList _sections; XQModelSectionList _sections;
XQTreeTable* _treeTable{}; XQTreeTable* _treeTable{};
//QAbstractItemView* _treeTable{};
QUndoStack* _undoStack{}; QUndoStack* _undoStack{};
XQContextMenu* _contextMenu{}; XQContextMenu* _contextMenu{};

View File

@@ -47,15 +47,33 @@
<!-- <!--
DocumentDetailsModel: DocumentDetailsModel:
--> -->
<X> <ModelX>
<Section> <Section State="runnning">
<Header> <Header>
<Entry Caption="Active Projects" ItemType="TreeParentType"/>
</Header> </Header>
<data> <Data>
</data> <Project Caption="@ProjectName" ItemType="TreeParentType"/>
</Data>
</Section>
<Section State="planned">
<Header>
<Entry Caption="Planned Projects" ItemType="TreeParentType"/>
</Header>
<Data>
<Project Caption="@ProjectName" ItemType="TreeParentType"/>
</Data>
</Section>
<Section State="finished">
<Header>
<Entry Caption="Finished Projects" ItemType="TreeParentType"/>
</Header>
<Data>
<Project Caption="@ProjectName" ItemType="TreeParentType"/>
</Data>
</Section> </Section>
</X> </ModelX>
<DocumentDetailsModel> <DocumentDetailsModel>