repaired it (a bit)
This commit is contained in:
@@ -81,8 +81,11 @@ XQItem* XQMainModel::addProjectItem( XQNodePtr contentNode )
|
|||||||
|
|
||||||
void XQMainModel::addSectionItem( const XQModelSection& section, XQItem* projectItem )
|
void XQMainModel::addSectionItem( const XQModelSection& section, XQItem* projectItem )
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
qDebug() << " --- SUPPA0: " << section.contentType();
|
qDebug() << " --- SUPPA0: " << section.contentType();
|
||||||
qDebug() << " --- SUPPA1: -> " << projectItem->contentNode()->to_string();
|
if( projectItem->hasContentNode())
|
||||||
|
qDebug() << " --- SUPPA1: -> " << projectItem->contentNode()->to_string();
|
||||||
qDebug() << " --- SUPPA2: -> " << projectItem->sheetNode()->to_string();
|
qDebug() << " --- SUPPA2: -> " << projectItem->sheetNode()->to_string();
|
||||||
qDebug() << " --- SUPPA3: -> " << projectItem->sheetNode()->find_child_by_tag_name("CurrentSection")->to_string();
|
qDebug() << " --- SUPPA3: -> " << projectItem->sheetNode()->find_child_by_tag_name("CurrentSection")->to_string();
|
||||||
|
|
||||||
|
@@ -141,7 +141,8 @@ XQItem::XQItem( XQItemType* itemType )
|
|||||||
XQItem::XQItem(XQItemType* itemType, const QString *content )
|
XQItem::XQItem(XQItemType* itemType, const QString *content )
|
||||||
: XQItem{ itemType }
|
: XQItem{ itemType }
|
||||||
{
|
{
|
||||||
setContent(content);
|
// hier setzen wir direkt ohne umwege den string pointer
|
||||||
|
QStandardItem::setData( QVariant::fromValue<const QString*>(content), XQItem::ContentRole );
|
||||||
}
|
}
|
||||||
|
|
||||||
XQItem::XQItem( XQItemType* itemType, const QString& content )
|
XQItem::XQItem( XQItemType* itemType, const QString& content )
|
||||||
@@ -160,20 +161,29 @@ XQItem* XQItem::clone() const
|
|||||||
//! false für ein ungültiges item. 'ungültig' heisst hier, dass nur ein
|
//! false für ein ungültiges item. 'ungültig' heisst hier, dass nur ein
|
||||||
//! mockup-itemtype gesetzt ist.
|
//! mockup-itemtype gesetzt ist.
|
||||||
|
|
||||||
bool XQItem::isValid() const
|
bool XQItem::isValidX() const
|
||||||
{
|
{
|
||||||
XQItemType* dummyType = XQItemType::staticItemType();
|
XQItemType* dummyType = XQItemType::staticItemType();
|
||||||
return QStandardItem::data( XQItem::ItemTypeRole ).value<XQItemType*>() != dummyType;
|
return QStandardItem::data( XQItem::ItemTypeRole ).value<XQItemType*>() != dummyType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//! testet, ob es einen content-node gibt.
|
|
||||||
|
|
||||||
bool XQItem::hasContentNode() const
|
bool XQItem::hasContentNode() const
|
||||||
{
|
{
|
||||||
return contentNode() != nullptr;
|
if( column() == 0)
|
||||||
}
|
{
|
||||||
|
QVariant value = QStandardItem::data( XQItem::ContentNodeRole );
|
||||||
|
return !value.isNull();
|
||||||
|
}
|
||||||
|
|
||||||
|
// sonst: delegieren an den node-Besitzer
|
||||||
|
QModelIndex pIndex = model()->index( row(), 0 );
|
||||||
|
if( pIndex.isValid() )
|
||||||
|
{
|
||||||
|
XQItem& firstItem = xqItemFromIndex( pIndex );
|
||||||
|
return firstItem.hasContentNode();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//! gibt den content-node zurück.
|
//! gibt den content-node zurück.
|
||||||
|
|
||||||
@@ -346,21 +356,6 @@ QString* XQItem::content() const
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
//! Setzt den content()-string pointer. (als leihgabe)
|
|
||||||
|
|
||||||
void XQItem::setContent( const QString* content )
|
|
||||||
{
|
|
||||||
setData( QVariant::fromValue<const QString*>(content), XQItem::ContentRole );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//! Holt den schlüssel bzw. bezeicher des content() string aus 'unserem' content knoten.
|
|
||||||
|
|
||||||
QString XQItem::contentKey() const
|
|
||||||
{
|
|
||||||
return contentNode()->attributes().key_of( rawText() );
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Gibt den content-format string zurück
|
//! Gibt den content-format string zurück
|
||||||
|
|
||||||
QString XQItem::contentFormat() const
|
QString XQItem::contentFormat() const
|
||||||
@@ -432,6 +427,10 @@ QString XQItem::dataRoleName(int role) const
|
|||||||
return XQItem::fetchItemDataRoleName(role);
|
return XQItem::fetchItemDataRoleName(role);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool XQItem::hasContentPtr() const
|
||||||
|
{
|
||||||
|
return !QStandardItem::data( XQItem::ContentRole ).isNull();
|
||||||
|
}
|
||||||
|
|
||||||
//! Gibt den content()-String zurück, sofern vorhanden.
|
//! Gibt den content()-String zurück, sofern vorhanden.
|
||||||
//! sonst: gibt der ihnalt der Qt::DisplayRole als fallback
|
//! sonst: gibt der ihnalt der Qt::DisplayRole als fallback
|
||||||
@@ -439,9 +438,12 @@ QString XQItem::dataRoleName(int role) const
|
|||||||
|
|
||||||
QString XQItem::contentFallBackText() const
|
QString XQItem::contentFallBackText() const
|
||||||
{
|
{
|
||||||
const QString* contentPtr = QStandardItem::data( XQItem::ContentRole ).value<const QString*>();
|
if( hasContentPtr() )
|
||||||
if(contentPtr)
|
{
|
||||||
return *contentPtr;
|
const QString* contentPtr = QStandardItem::data( XQItem::ContentRole ).value<const QString*>();
|
||||||
|
if(contentPtr)
|
||||||
|
return *contentPtr;
|
||||||
|
}
|
||||||
|
|
||||||
// wenn wir keinen contentPtr haben, benutzen wir als fallback
|
// wenn wir keinen contentPtr haben, benutzen wir als fallback
|
||||||
// die basis-text() role
|
// die basis-text() role
|
||||||
@@ -516,16 +518,24 @@ QVariant XQItem::data(int role ) const
|
|||||||
|
|
||||||
case ContentNodeRole:
|
case ContentNodeRole:
|
||||||
{
|
{
|
||||||
// Das Node-Besitzer-Item wohnt in der ersten Spalte,
|
// Das Node-Besitzer-Item wohnt in der ersten Spalte,
|
||||||
// wenn wir also der Node-Besitzer item sind ...
|
// wenn wir also der Node-Besitzer item sind ...
|
||||||
if( column() == 0)
|
if( column() == 0)
|
||||||
return QStandardItem::data( XQItem::ContentNodeRole );
|
{
|
||||||
|
QVariant value = QStandardItem::data( XQItem::ContentNodeRole );
|
||||||
|
if( !value.isNull() )
|
||||||
|
return value;
|
||||||
|
throw XQException( "ContentNode is nullptr!");
|
||||||
|
}
|
||||||
|
|
||||||
// sonst: delegieren an den node-Besitzer
|
// sonst: delegieren an den node-Besitzer
|
||||||
QModelIndex pIndex = model()->index( row(), 0 );
|
QModelIndex pIndex = model()->index( row(), 0 );
|
||||||
|
if( pIndex.isValid())
|
||||||
|
{
|
||||||
XQItem& firstItem = xqItemFromIndex( pIndex );
|
XQItem& firstItem = xqItemFromIndex( pIndex );
|
||||||
|
|
||||||
return firstItem.data( XQItem::ContentNodeRole );
|
return firstItem.data( XQItem::ContentNodeRole );
|
||||||
|
}
|
||||||
|
throw XQException( "Item has no valid index (yet)!");
|
||||||
}
|
}
|
||||||
|
|
||||||
case Qt::StatusTipRole:
|
case Qt::StatusTipRole:
|
||||||
@@ -606,7 +616,7 @@ void XQItem::setData(const QVariant& value, int role )
|
|||||||
// fallback: wenns keinen content node gibt, dann nehmen wir
|
// fallback: wenns keinen content node gibt, dann nehmen wir
|
||||||
// das standardverfahren.
|
// das standardverfahren.
|
||||||
int role = XQItem::ContentRole;
|
int role = XQItem::ContentRole;
|
||||||
if( !hasContentNode() )
|
if( !hasContentPtr() )
|
||||||
role = Qt::DisplayRole;
|
role = Qt::DisplayRole;
|
||||||
QStandardItem::setData( plainText, role );
|
QStandardItem::setData( plainText, role );
|
||||||
return;
|
return;
|
||||||
@@ -728,13 +738,10 @@ XQItem::UnitType XQItem::fetchUnitType(const QString& unitTypeKey)
|
|||||||
return s_UnitTypeMap.key(unitTypeKey);
|
return s_UnitTypeMap.key(unitTypeKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//! gibt die bezeichung für den gegebenen unitType aus.
|
//! gibt die bezeichung für den gegebenen unitType aus.
|
||||||
|
|
||||||
QString XQItem::fetchUnitTypeToString( UnitType unitType)
|
QString XQItem::fetchUnitTypeToString( UnitType unitType)
|
||||||
{
|
{
|
||||||
return s_UnitTypeMap[unitType];
|
return s_UnitTypeMap[unitType];
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ---
|
|
||||||
/// ---
|
|
||||||
/// ---
|
|
||||||
|
@@ -141,15 +141,16 @@ public:
|
|||||||
//! -- not used at the moment --
|
//! -- not used at the moment --
|
||||||
XQItem* clone() const override;
|
XQItem* clone() const override;
|
||||||
|
|
||||||
//!
|
//! __fix Tested, ob ein itemtype vorhanden ist.
|
||||||
bool isValid() const;
|
bool isValidX() const;
|
||||||
|
|
||||||
bool hasContentNode() const;
|
bool hasContentNode() const;
|
||||||
//! gibt den zu diesem item gehörigen datenknoten zurück
|
//! gibt den zu diesem item gehörigen datenknoten zurück
|
||||||
virtual XQNodePtr contentNode() const;
|
XQNodePtr contentNode() const;
|
||||||
|
|
||||||
virtual XQNodePtr sheetNode() const;
|
|
||||||
virtual void setSheetNode( const XQNodePtr& sheetNode );
|
XQNodePtr sheetNode() const;
|
||||||
|
void setSheetNode( const XQNodePtr& sheetNode );
|
||||||
|
|
||||||
XQItemType& itemType() const;
|
XQItemType& itemType() const;
|
||||||
void setItemType( XQItemType* itemTypePtr );
|
void setItemType( XQItemType* itemTypePtr );
|
||||||
@@ -165,8 +166,7 @@ public:
|
|||||||
|
|
||||||
// changed: gibt jetzt den pointer zurück.
|
// changed: gibt jetzt den pointer zurück.
|
||||||
//QString* content() const;
|
//QString* content() const;
|
||||||
QString contentKey() const;
|
//void setContent( const QString* content );
|
||||||
void setContent( const QString* content );
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Convenience-Funktionen zum Memberzugriff, die Implementierung
|
// Convenience-Funktionen zum Memberzugriff, die Implementierung
|
||||||
@@ -243,6 +243,7 @@ protected:
|
|||||||
XQItem(const XQItem& other) = default;
|
XQItem(const XQItem& other) = default;
|
||||||
XQItem& operator=(const XQItem& other) = default;
|
XQItem& operator=(const XQItem& other) = default;
|
||||||
|
|
||||||
|
bool hasContentPtr() const;
|
||||||
QString contentFallBackText() const;
|
QString contentFallBackText() const;
|
||||||
|
|
||||||
// das ist protected, weil damit der content()-zugriff demoliert werden kann
|
// das ist protected, weil damit der content()-zugriff demoliert werden kann
|
||||||
|
@@ -87,29 +87,28 @@ void XQItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option
|
|||||||
qDebug() << " index DEAD!";
|
qDebug() << " index DEAD!";
|
||||||
|
|
||||||
XQItem& item = xqItemFromIndex( index );
|
XQItem& item = xqItemFromIndex( index );
|
||||||
if( item.isValid() )
|
|
||||||
|
|
||||||
|
switch( item.renderStyle() )
|
||||||
{
|
{
|
||||||
|
case XQItem::HeaderStyle :
|
||||||
|
return drawHeaderStyle( painter, option, index );
|
||||||
|
|
||||||
switch( item.renderStyle() )
|
case XQItem::ComboBoxStyle :
|
||||||
{
|
return drawComboBoxStyle( painter, option, index );
|
||||||
case XQItem::HeaderStyle :
|
|
||||||
return drawHeaderStyle( painter, option, index );
|
|
||||||
|
|
||||||
case XQItem::ComboBoxStyle :
|
case XQItem::HiddenStyle :
|
||||||
return drawComboBoxStyle( painter, option, index );
|
return;
|
||||||
|
|
||||||
case XQItem::HiddenStyle :
|
//case XQItem::ProgressBarStyle :
|
||||||
return;
|
// return drawProgressBarStyle( painter, option, index );
|
||||||
|
|
||||||
//case XQItem::ProgressBarStyle :
|
|
||||||
// return drawProgressBarStyle( painter, option, index );
|
|
||||||
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
} // switch
|
} // switch
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
QStyledItemDelegate::paint(painter, option, index);
|
QStyledItemDelegate::paint(painter, option, index);
|
||||||
|
|
||||||
@@ -226,7 +225,7 @@ QWidget* XQItemDelegate::createEditor(QWidget* parent, const QStyleOptionViewIte
|
|||||||
{
|
{
|
||||||
XQItem& item = xqItemFromIndex(index);
|
XQItem& item = xqItemFromIndex(index);
|
||||||
XQItem::EditorType edType = item.editorType();
|
XQItem::EditorType edType = item.editorType();
|
||||||
if( !item.hasContentNode() || edType == XQItem::NoEditorType )
|
if( edType == XQItem::NoEditorType )
|
||||||
{
|
{
|
||||||
qDebug() << "---- NO Content or NO EditorType";
|
qDebug() << "---- NO Content or NO EditorType";
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@@ -235,7 +234,7 @@ QWidget* XQItemDelegate::createEditor(QWidget* parent, const QStyleOptionViewIte
|
|||||||
qDebug() << "---- ed type:" << XQItem::fetchEditorTypeToString( edType ) << ": " << edType;
|
qDebug() << "---- ed type:" << XQItem::fetchEditorTypeToString( edType ) << ": " << edType;
|
||||||
//return QStyledItemDelegate::createEditor( parent, option, index );
|
//return QStyledItemDelegate::createEditor( parent, option, index );
|
||||||
|
|
||||||
return itemEditorFactory()->createEditor(edType, parent);
|
return itemEditorFactory()->createEditor(edType, parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -8,8 +8,8 @@
|
|||||||
|
|
||||||
<ItemTypes>
|
<ItemTypes>
|
||||||
<TreeParentType RenderStyle="PlainStyle" EditorType="LineEditType" ItemFlags="IsEnabled|IsDropEnabled" Icon="DirIcon" />
|
<TreeParentType RenderStyle="PlainStyle" EditorType="LineEditType" ItemFlags="IsEnabled|IsDropEnabled" Icon="DirIcon" />
|
||||||
<TreeSectionType RenderStyle="PlainStyle" EditorType="LineEditType" ItemFlags="IsEnabled" Icon="DesktopIcon"/>
|
<TreeChildType RenderStyle="PlainStyle" EditorType="LineEditType" ItemFlags="IsEnabled" Icon="MediaPlay"/>
|
||||||
<TreeChildType RenderStyle="PlainStyle" EditorType="LineEditType" ItemFlags="IsUserCheckable|IsEnabled" Icon="MediaPlay"/>
|
<TreeSectionType RenderStyle="PlainStyle" EditorType="LineEditType" ItemFlags="IsUserCheckable|IsEnabled" Icon="DesktopIcon"/>
|
||||||
<HeaderType RenderStyle="HeaderStyle" EditorType="LineEditType" ItemFlags="IsEnabled"/>
|
<HeaderType RenderStyle="HeaderStyle" EditorType="LineEditType" ItemFlags="IsEnabled"/>
|
||||||
<HiddenType RenderStyle="HiddenStyle"/>
|
<HiddenType RenderStyle="HiddenStyle"/>
|
||||||
<StaticType RenderStyle="PlainStyle"/>
|
<StaticType RenderStyle="PlainStyle"/>
|
||||||
@@ -75,7 +75,7 @@
|
|||||||
<!-- 'Icon' überschreibt den default wert im ItemType und erzeugt damit einen neuen ItemType-->
|
<!-- 'Icon' überschreibt den default wert im ItemType und erzeugt damit einen neuen ItemType-->
|
||||||
<PanelID ItemType="PlainType" Icon="DesktopIcon"/>
|
<PanelID ItemType="PlainType" Icon="DesktopIcon"/>
|
||||||
<PanelName ItemType="PlainType" Icon="BrowserStop"/>
|
<PanelName ItemType="PlainType" Icon="BrowserStop"/>
|
||||||
<Manufacturer ItemType="ValueType"/>
|
<Manufacturer ItemType="PlainType"/>
|
||||||
<!-- 'UnitType' überschreibt den default wert im ItemType und erzeugt damit einen neuen ItemType-->
|
<!-- 'UnitType' überschreibt den default wert im ItemType und erzeugt damit einen neuen ItemType-->
|
||||||
<WattPeak ItemType="ValueType" UnitType="Wp"/>
|
<WattPeak ItemType="ValueType" UnitType="Wp"/>
|
||||||
<Width ItemType="CheckableType" Icon="VistaShield" UnitType="m"/>
|
<Width ItemType="CheckableType" Icon="VistaShield" UnitType="m"/>
|
||||||
@@ -98,12 +98,12 @@
|
|||||||
<Weight Caption="Weight" ItemType="HeaderType" />
|
<Weight Caption="Weight" ItemType="HeaderType" />
|
||||||
</Header>
|
</Header>
|
||||||
<ModelSheet>
|
<ModelSheet>
|
||||||
<InverterID Caption="Inverter" ItemType="ValueType" />
|
<InverterID Caption="Inverter" ItemType="PlainType" />
|
||||||
<InverterName Caption="Name" ItemType="ValueType" />
|
<InverterName Caption="Name" ItemType="PlainType" />
|
||||||
<Manufacturer Caption="Manufacturer" ItemType="ValueType" />
|
<Manufacturer Caption="Manufacturer" ItemType="PlainType" />
|
||||||
<MaxPowerInput Caption="max. Input" ItemType="ValueType" ItemType="ChoiceType" ChoiceModelSheetSource="MaxPowerInputChoice" UnitType="W"/>
|
<MaxPowerInput Caption="max. Input" ItemType="ValueType" ItemType="ChoiceType" ChoiceModelSheetSource="MaxPowerInputChoice" UnitType="W"/>
|
||||||
<MaxPowerOutput Caption="max Output" ItemType="ValueType" UnitType="W"/>
|
<MaxPowerOutput Caption="max Output" ItemType="ValueType" UnitType="W"/>
|
||||||
<NumStrings Caption="Strings" ItemType="ValueType" />
|
<NumStrings Caption="Strings" ItemType="PlainType" />
|
||||||
<Weight Caption="Weight" ItemType="ValueType" UnitType="kg"/>
|
<Weight Caption="Weight" ItemType="ValueType" UnitType="kg"/>
|
||||||
</ModelSheet>
|
</ModelSheet>
|
||||||
</Section>
|
</Section>
|
||||||
@@ -119,9 +119,9 @@
|
|||||||
<MaxVolt Caption="max. Volt" ItemType="HeaderType" />
|
<MaxVolt Caption="max. Volt" ItemType="HeaderType" />
|
||||||
</Header>
|
</Header>
|
||||||
<ModelSheet>
|
<ModelSheet>
|
||||||
<BatteryID Caption="Battery" ItemType="ValueType" />
|
<BatteryID Caption="Battery" ItemType="PlainType" />
|
||||||
<BatteryName Caption="Name" ItemType="ValueType" />
|
<BatteryName Caption="Name" ItemType="PlainType" />
|
||||||
<Manufacturer Caption="Manufacturer" ItemType="ValueType" />
|
<Manufacturer Caption="Manufacturer" ItemType="PlainType" />
|
||||||
<Capacity Caption="Capacity" ItemType="ValueType" UnitType="Wh"/>
|
<Capacity Caption="Capacity" ItemType="ValueType" UnitType="Wh"/>
|
||||||
<Yield Caption="Yield" ItemType="ValueType" ItemType="PercentageType" UnitType="%"/>
|
<Yield Caption="Yield" ItemType="ValueType" ItemType="PercentageType" UnitType="%"/>
|
||||||
<MaxCurrent Caption="max. Current" ItemType="ValueType" UnitType="A"/>
|
<MaxCurrent Caption="max. Current" ItemType="ValueType" UnitType="A"/>
|
||||||
|
Reference in New Issue
Block a user