Still works...
This commit is contained in:
@@ -71,7 +71,7 @@ namespace XQAppData
|
|||||||
insert( "icn29Dummy", QApplication::style()->standardIcon(QStyle::SP_BrowserReload));
|
insert( "icn29Dummy", QApplication::style()->standardIcon(QStyle::SP_BrowserReload));
|
||||||
insert( "icn30Dummy", QApplication::style()->standardIcon(QStyle::SP_DriveFDIcon));
|
insert( "icn30Dummy", QApplication::style()->standardIcon(QStyle::SP_DriveFDIcon));
|
||||||
insert( "icn31Dummy", QApplication::style()->standardIcon(QStyle::SP_MessageBoxInformation));
|
insert( "icn31Dummy", QApplication::style()->standardIcon(QStyle::SP_MessageBoxInformation));
|
||||||
insert( "icn32Dummy", QApplication::style()->standardIcon(QStyle::SP_BrowserStop));
|
insert( "BrowserStop", QApplication::style()->standardIcon(QStyle::SP_BrowserStop));
|
||||||
insert( "icn33Dummy", QApplication::style()->standardIcon(QStyle::SP_DriveHDIcon));
|
insert( "icn33Dummy", QApplication::style()->standardIcon(QStyle::SP_DriveHDIcon));
|
||||||
insert( "icn34Dummy", QApplication::style()->standardIcon(QStyle::SP_MessageBoxQuestion));
|
insert( "icn34Dummy", QApplication::style()->standardIcon(QStyle::SP_MessageBoxQuestion));
|
||||||
insert( "icn35Dummy", QApplication::style()->standardIcon(QStyle::SP_CommandLink));
|
insert( "icn35Dummy", QApplication::style()->standardIcon(QStyle::SP_CommandLink));
|
||||||
@@ -249,3 +249,5 @@ namespace XQAppData
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
}; // namespace XQAppData
|
}; // namespace XQAppData
|
||||||
|
|
||||||
|
|
||||||
|
@@ -32,7 +32,7 @@ XQChildModel::XQChildModel( QObject *parent )
|
|||||||
|
|
||||||
|
|
||||||
//! erzeugt die basisstruktur des models.
|
//! erzeugt die basisstruktur des models.
|
||||||
|
/*
|
||||||
void XQChildModel::initModel(const QString& modelName)
|
void XQChildModel::initModel(const QString& modelName)
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -84,16 +84,17 @@ void XQChildModel::initModel(const QString& modelName)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
// empty row:
|
// empty row:
|
||||||
XQNodePtr contentNode = XQNode::make_node( sheetNode->tag_name() );
|
// XQNodePtr contentNode = XQNode::make_node( sheetNode->tag_name() );
|
||||||
XQItemList emptyRow = _itemFactory.makeEmptyRow( contentNode, sheetNode );
|
// XQItemList emptyRow = _itemFactory.makeEmptyRow( contentNode, sheetNode );
|
||||||
appendRow( emptyRow );
|
// appendRow( emptyRow );
|
||||||
*/
|
|
||||||
|
|
||||||
} // for
|
} // for
|
||||||
|
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
//! erzegut den sichtbaren inhalt des models aus einem root-datenknoten.
|
//! erzegut den sichtbaren inhalt des models aus einem root-datenknoten.
|
||||||
|
@@ -29,13 +29,10 @@ public:
|
|||||||
explicit XQChildModel(QObject *parent = nullptr);
|
explicit XQChildModel(QObject *parent = nullptr);
|
||||||
virtual ~XQChildModel() = default;
|
virtual ~XQChildModel() = default;
|
||||||
|
|
||||||
void initModel(const QString& modelName) override;
|
|
||||||
void setContent(const XQNodePtr& contentRoot );
|
void setContent(const XQNodePtr& contentRoot );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//void setupViewProperties() override;
|
//void setupViewProperties() override;
|
||||||
void initContextMenu() override;
|
void initContextMenu() override;
|
||||||
|
|
||||||
|
@@ -34,29 +34,6 @@ XQMainModel::XQMainModel(QObject *parent )
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//! initialisiert dieses model über den namen.
|
|
||||||
|
|
||||||
void XQMainModel::initModel(const QString& modelName)
|
|
||||||
{
|
|
||||||
|
|
||||||
// model rootnode finden -> <DocumentTreeModel>
|
|
||||||
XQNodePtr modelSheet = _itemFactory.findModelSheet( modelName ); // throws
|
|
||||||
|
|
||||||
// #1: über alle sections
|
|
||||||
for( auto& section : modelSheet->children() )
|
|
||||||
{
|
|
||||||
// #2: (optionalen) header erzeugen
|
|
||||||
const XQNodePtr header = section->find_child_by_tag_name( "Header");
|
|
||||||
if( header )
|
|
||||||
{
|
|
||||||
XQItemList list = _itemFactory.makeHeader( header );
|
|
||||||
Q_ASSERT(!list.isEmpty());
|
|
||||||
addSection(list, section );
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//! erzeugt einen eintrag in der baum-übersicht.
|
//! erzeugt einen eintrag in der baum-übersicht.
|
||||||
|
|
||||||
@@ -79,7 +56,7 @@ XQItem* XQMainModel::createTreeEntry( XQNodePtr contentNode )
|
|||||||
return newTreeentry;
|
return newTreeentry;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw XQException( "createTreeEntry: main model should not be emtpy!" );
|
throw XQException( "createTreeEntry: main model should not be empty!" );
|
||||||
}
|
}
|
||||||
|
|
||||||
//! leere default implementation
|
//! leere default implementation
|
||||||
|
@@ -32,7 +32,6 @@ public:
|
|||||||
explicit XQMainModel(QObject *parent = nullptr);
|
explicit XQMainModel(QObject *parent = nullptr);
|
||||||
virtual ~XQMainModel() = default;
|
virtual ~XQMainModel() = default;
|
||||||
|
|
||||||
void initModel(const QString& modelName) override;
|
|
||||||
XQItem* createTreeEntry( XQNodePtr contentNode );
|
XQItem* createTreeEntry( XQNodePtr contentNode );
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
@@ -319,7 +319,7 @@ XQItemList XQItemFactory::makeHeader( const XQNodePtr& headerNode )
|
|||||||
{
|
{
|
||||||
|
|
||||||
XQItemList list;
|
XQItemList list;
|
||||||
|
// über alle kinder der <Header> sektion
|
||||||
for( const auto& headerEntry : headerNode->children() )
|
for( const auto& headerEntry : headerNode->children() )
|
||||||
{
|
{
|
||||||
qDebug() << " --- headerEntry: " << headerEntry->tag_name() << ": " << headerEntry->attribute( "ItemType") << headerEntry->attribute( "Caption");
|
qDebug() << " --- headerEntry: " << headerEntry->tag_name() << ": " << headerEntry->attribute( "ItemType") << headerEntry->attribute( "Caption");
|
||||||
|
@@ -83,57 +83,37 @@ XQItem& XQViewModel::xqFirstItem(int row) const
|
|||||||
return *static_cast<XQItem*>( QStandardItemModel::item(row) );
|
return *static_cast<XQItem*>( QStandardItemModel::item(row) );
|
||||||
}
|
}
|
||||||
|
|
||||||
//! create the own model structure
|
|
||||||
void XQViewModel::initModel( const QString& modelName)
|
//! initialisiert dieses model über den namen. Es wird hier
|
||||||
|
//! nur die strukur erzeugt, keine inhalte.
|
||||||
|
|
||||||
|
void XQViewModel::initModel(const QString& modelName)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
model
|
model
|
||||||
section
|
section
|
||||||
header
|
header
|
||||||
|
data
|
||||||
section
|
section
|
||||||
...
|
...
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
// model rootnode finden -> <DocumentTreeModel>
|
||||||
|
XQNodePtr modelSheet = _itemFactory.findModelSheet( modelName ); // throws
|
||||||
|
|
||||||
/*
|
// #1: über alle sections
|
||||||
// #0: Wir suchen die Model-Beschreibung
|
for( auto& section : modelSheet->children() )
|
||||||
XQNodePtr modelSheet = _itemFactory.findModelSheet( modelName ); // throws
|
|
||||||
|
|
||||||
// #1: Wir erzeugen die Model-Struktur: Jedes Kind beschreibt einen
|
|
||||||
// XML-Datentyp, z.B. <Panel atr1="..." />, <Battery .../>
|
|
||||||
// Jeder XML-Knoten entspricht einer Zeile im späteren Model, jedes
|
|
||||||
// Attribut wird einem eigenen Feld (XQItem) abgebildet.
|
|
||||||
|
|
||||||
for( const auto& sheetNode : modelSheet->children() )
|
|
||||||
{
|
{
|
||||||
|
// #2: (optionalen) header erzeugen
|
||||||
|
const XQNodePtr header = section->find_child_by_tag_name( "Header");
|
||||||
XQItemList list = _itemFactory.makeHeaderRow( sheetNode );
|
if( header )
|
||||||
|
|
||||||
// für jeden XML-Knotentyp in der Modelbeschreibung erzeugen wir eine section
|
|
||||||
addSection(list, sheetNode );
|
|
||||||
|
|
||||||
// jedes kind kann enthält einen itemType und einen headerItemType. Für
|
|
||||||
// diese sind eventuell weitere attribute vorhanden, die die im type
|
|
||||||
// enthaltenen defualt-werte überschreiben.
|
|
||||||
|
|
||||||
for( const auto& sheetChild : sheetNode->children() )
|
|
||||||
{
|
{
|
||||||
//qDebug() << "---- kloppo: " << sheetChild->tag_name() << ": " << sheetChild->to_string();
|
XQItemList list = _itemFactory.makeHeader( header );
|
||||||
extendItemType( sheetChild );
|
Q_ASSERT(!list.isEmpty());
|
||||||
|
addSection(list, section );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// empty row:
|
|
||||||
//XQNodePtr contentNode = XQNode::make_node( sheetNode->tag_name() );
|
|
||||||
//XQItemList emptyRow = _itemFactory.makeEmptyRow( contentNode, sheetNode );
|
|
||||||
//appendRow( emptyRow );
|
|
||||||
|
|
||||||
|
|
||||||
} // for
|
|
||||||
*/
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -48,7 +48,6 @@ public:
|
|||||||
QUndoStack* undoStack();
|
QUndoStack* undoStack();
|
||||||
void setUndoStack( QUndoStack* undoStack );
|
void setUndoStack( QUndoStack* undoStack );
|
||||||
|
|
||||||
//! create the own model structure
|
|
||||||
virtual void initModel( const QString& modelName);
|
virtual void initModel( const QString& modelName);
|
||||||
|
|
||||||
//little helpers
|
//little helpers
|
||||||
@@ -73,7 +72,7 @@ public:
|
|||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|
||||||
Derzeit wir die default-implementierung von data/setData genutzt. hier wäre dann die
|
Derzeit wird die default-implementierung von data/setData genutzt. hier wäre dann die
|
||||||
Stelle um setData & data an externe 'handler' umzubiegen, siehe giovannies 'model-injection'
|
Stelle um setData & data an externe 'handler' umzubiegen, siehe giovannies 'model-injection'
|
||||||
|
|
||||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override
|
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override
|
||||||
|
@@ -71,8 +71,83 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<DocumentDetailsModel>
|
<DocumentDetailsModel>
|
||||||
|
|
||||||
|
<Section>
|
||||||
|
<Header>
|
||||||
|
<PanelID Caption="Panel" ItemType="HeaderType" />
|
||||||
|
<PanelName Caption="Name" ItemType="HeaderType" Icon="BrowserStop" />
|
||||||
|
<Manufacturer Caption="Manufacturer" ItemType="HeaderType" />
|
||||||
|
<WattPeak Caption="Watt Peak" ItemType="HeaderType" />
|
||||||
|
<Width Caption="Width" ItemType="HeaderType" />
|
||||||
|
<Height Caption="Height" ItemType="HeaderType" />
|
||||||
|
<Wight Caption="Weight" ItemType="HeaderType" />
|
||||||
|
<MaxVolt Caption="max. Volt" ItemType="HeaderType" />
|
||||||
|
<MaxAmpere Caption="max. Ampere" ItemType="HeaderType" />
|
||||||
|
</Header>
|
||||||
|
<Data>
|
||||||
|
<!-- 'Icon' überschreibt den default wert im ItemType und erzeugt damit einen neuen ItemType-->
|
||||||
|
<PanelID ItemType="PlainType" Icon="FileIcon"/>
|
||||||
|
<PanelName ItemType="PlainType"/>
|
||||||
|
<Manufacturer ItemType="ValueType"/>
|
||||||
|
<!-- 'UnitType' überschreibt den default wert im ItemType und erzeugt damit einen neuen ItemType-->
|
||||||
|
<WattPeak ItemType="ValueType" UnitType="Wp"/>
|
||||||
|
<Width ItemType="ValueType" UnitType="m"/>
|
||||||
|
<Height ItemType="ValueType" UnitType="m"/>
|
||||||
|
<Weight ItemType="ValueType" UnitType="kg"/>
|
||||||
|
<MaxVolt ItemType="ValueType" UnitType="V"/>
|
||||||
|
<MaxAmpere ItemType="ValueType" UnitType="A"/>
|
||||||
|
</Data>
|
||||||
|
</Section>
|
||||||
|
|
||||||
|
<Section>
|
||||||
|
<Header>
|
||||||
|
<InverterID Caption="Inverter" ItemType="HeaderType" />
|
||||||
|
<InverterName Caption="Name" ItemType="HeaderType" />
|
||||||
|
<Manufacturer Caption="Manufacturer" ItemType="HeaderType" />
|
||||||
|
<MaxPowerInput Caption="max. Input" ItemType="HeaderType" />
|
||||||
|
<MaxPowerOutput Caption="max Output" ItemType="HeaderType" />
|
||||||
|
<NumStrings Caption="Strings" ItemType="HeaderType" />
|
||||||
|
<Weight Caption="Weight" ItemType="HeaderType" />
|
||||||
|
</Header>
|
||||||
|
<Data>
|
||||||
|
<InverterID Caption="Inverter" ItemType="ValueType" />
|
||||||
|
<InverterName Caption="Name" ItemType="ValueType" />
|
||||||
|
<Manufacturer Caption="Manufacturer" ItemType="ValueType" />
|
||||||
|
<MaxPowerInput Caption="max. Input" ItemType="ValueType" ItemType="ChoiceType" ChoiceDataSource="MaxPowerInputChoice" UnitType="W"/>
|
||||||
|
<MaxPowerOutput Caption="max Output" ItemType="ValueType" UnitType="W"/>
|
||||||
|
<NumStrings Caption="Strings" ItemType="ValueType" />
|
||||||
|
<Weight Caption="Weight" ItemType="ValueType" UnitType="kg"/>
|
||||||
|
</Data>
|
||||||
|
</Section>
|
||||||
|
|
||||||
|
<Section>
|
||||||
|
<Header>
|
||||||
|
<BatteryID Caption="Name" ItemType="HeaderType" />
|
||||||
|
<BatteryName Caption="Battery" ItemType="HeaderType" />
|
||||||
|
<Manufacturer Caption="Manufacturer" ItemType="HeaderType" />
|
||||||
|
<Capacity Caption="Capacity" ItemType="HeaderType"/>
|
||||||
|
<Yield Caption="Yield" ItemType="HeaderType" />
|
||||||
|
<MaxCurrent Caption="max. Current" ItemType="HeaderType" />
|
||||||
|
<MaxVolt Caption="max. Volt" ItemType="HeaderType" />
|
||||||
|
</Header>
|
||||||
|
<Data>
|
||||||
|
<BatteryID Caption="Battery" ItemType="ValueType" />
|
||||||
|
<BatteryName Caption="Name" ItemType="ValueType" />
|
||||||
|
<Manufacturer Caption="Manufacturer" ItemType="ValueType" />
|
||||||
|
<Capacity Caption="Capacity" ItemType="ValueType" UnitType="Wh"/>
|
||||||
|
<Yield Caption="Yield" ItemType="ValueType" ItemType="PercentageType" UnitType="%"/>
|
||||||
|
<MaxCurrent Caption="max. Current" ItemType="ValueType" UnitType="A"/>
|
||||||
|
<MaxVolt Caption="max. Volt" ItemType="ValueType" UnitType="V"/>
|
||||||
|
</Data>
|
||||||
|
</Section>
|
||||||
|
|
||||||
|
</DocumentDetailsModel>
|
||||||
|
|
||||||
|
|
||||||
|
<DocumentDetailsModelX>
|
||||||
|
|
||||||
<Panel FriendlyName="@PanelName">
|
<Panel FriendlyName="@PanelName">
|
||||||
<PanelID HeaderCaption="Panel" HeaderItemType="HeaderType" ItemType="PlainType" Icon="icn74Dummy"/>
|
<PanelID HeaderCaption="Panel" HeaderItemType="HeaderType" ItemType="PlainType" Icon="icn74Dummy"/>
|
||||||
<PanelName HeaderCaption="Name" HeaderItemType="HeaderType" ItemType="PlainType"/>
|
<PanelName HeaderCaption="Name" HeaderItemType="HeaderType" ItemType="PlainType"/>
|
||||||
@@ -105,4 +180,4 @@
|
|||||||
<MaxVolt HeaderCaption="max. Volt" HeaderItemType="HeaderType" ItemType="ValueType" UnitType="V"/>
|
<MaxVolt HeaderCaption="max. Volt" HeaderItemType="HeaderType" ItemType="ValueType" UnitType="V"/>
|
||||||
</Battery>
|
</Battery>
|
||||||
|
|
||||||
</DocumentDetailsModel>
|
</DocumentDetailsModelX>
|
||||||
|
Reference in New Issue
Block a user