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 )
|
||||
{
|
||||
|
||||
|
||||
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() << " --- 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{ 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 )
|
||||
@@ -160,20 +161,29 @@ XQItem* XQItem::clone() const
|
||||
//! false für ein ungültiges item. 'ungültig' heisst hier, dass nur ein
|
||||
//! mockup-itemtype gesetzt ist.
|
||||
|
||||
bool XQItem::isValid() const
|
||||
bool XQItem::isValidX() const
|
||||
{
|
||||
XQItemType* dummyType = XQItemType::staticItemType();
|
||||
return QStandardItem::data( XQItem::ItemTypeRole ).value<XQItemType*>() != dummyType;
|
||||
}
|
||||
|
||||
|
||||
//! testet, ob es einen content-node gibt.
|
||||
|
||||
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.
|
||||
|
||||
@@ -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
|
||||
|
||||
QString XQItem::contentFormat() const
|
||||
@@ -432,6 +427,10 @@ QString XQItem::dataRoleName(int role) const
|
||||
return XQItem::fetchItemDataRoleName(role);
|
||||
}
|
||||
|
||||
bool XQItem::hasContentPtr() const
|
||||
{
|
||||
return !QStandardItem::data( XQItem::ContentRole ).isNull();
|
||||
}
|
||||
|
||||
//! Gibt den content()-String zurück, sofern vorhanden.
|
||||
//! sonst: gibt der ihnalt der Qt::DisplayRole als fallback
|
||||
@@ -439,9 +438,12 @@ QString XQItem::dataRoleName(int role) const
|
||||
|
||||
QString XQItem::contentFallBackText() const
|
||||
{
|
||||
const QString* contentPtr = QStandardItem::data( XQItem::ContentRole ).value<const QString*>();
|
||||
if(contentPtr)
|
||||
return *contentPtr;
|
||||
if( hasContentPtr() )
|
||||
{
|
||||
const QString* contentPtr = QStandardItem::data( XQItem::ContentRole ).value<const QString*>();
|
||||
if(contentPtr)
|
||||
return *contentPtr;
|
||||
}
|
||||
|
||||
// wenn wir keinen contentPtr haben, benutzen wir als fallback
|
||||
// die basis-text() role
|
||||
@@ -516,16 +518,24 @@ QVariant XQItem::data(int role ) const
|
||||
|
||||
case ContentNodeRole:
|
||||
{
|
||||
// Das Node-Besitzer-Item wohnt in der ersten Spalte,
|
||||
// wenn wir also der Node-Besitzer item sind ...
|
||||
if( column() == 0)
|
||||
return QStandardItem::data( XQItem::ContentNodeRole );
|
||||
// Das Node-Besitzer-Item wohnt in der ersten Spalte,
|
||||
// wenn wir also der Node-Besitzer item sind ...
|
||||
if( column() == 0)
|
||||
{
|
||||
QVariant value = QStandardItem::data( XQItem::ContentNodeRole );
|
||||
if( !value.isNull() )
|
||||
return value;
|
||||
throw XQException( "ContentNode is nullptr!");
|
||||
}
|
||||
|
||||
// sonst: delegieren an den node-Besitzer
|
||||
QModelIndex pIndex = model()->index( row(), 0 );
|
||||
// sonst: delegieren an den node-Besitzer
|
||||
QModelIndex pIndex = model()->index( row(), 0 );
|
||||
if( pIndex.isValid())
|
||||
{
|
||||
XQItem& firstItem = xqItemFromIndex( pIndex );
|
||||
|
||||
return firstItem.data( XQItem::ContentNodeRole );
|
||||
}
|
||||
throw XQException( "Item has no valid index (yet)!");
|
||||
}
|
||||
|
||||
case Qt::StatusTipRole:
|
||||
@@ -606,7 +616,7 @@ void XQItem::setData(const QVariant& value, int role )
|
||||
// fallback: wenns keinen content node gibt, dann nehmen wir
|
||||
// das standardverfahren.
|
||||
int role = XQItem::ContentRole;
|
||||
if( !hasContentNode() )
|
||||
if( !hasContentPtr() )
|
||||
role = Qt::DisplayRole;
|
||||
QStandardItem::setData( plainText, role );
|
||||
return;
|
||||
@@ -728,13 +738,10 @@ XQItem::UnitType XQItem::fetchUnitType(const QString& unitTypeKey)
|
||||
return s_UnitTypeMap.key(unitTypeKey);
|
||||
}
|
||||
|
||||
|
||||
//! gibt die bezeichung für den gegebenen unitType aus.
|
||||
|
||||
QString XQItem::fetchUnitTypeToString( UnitType unitType)
|
||||
{
|
||||
return s_UnitTypeMap[unitType];
|
||||
}
|
||||
|
||||
/// ---
|
||||
/// ---
|
||||
/// ---
|
||||
|
@@ -141,15 +141,16 @@ public:
|
||||
//! -- not used at the moment --
|
||||
XQItem* clone() const override;
|
||||
|
||||
//!
|
||||
bool isValid() const;
|
||||
//! __fix Tested, ob ein itemtype vorhanden ist.
|
||||
bool isValidX() const;
|
||||
|
||||
bool hasContentNode() const;
|
||||
bool hasContentNode() const;
|
||||
//! 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;
|
||||
void setItemType( XQItemType* itemTypePtr );
|
||||
@@ -165,8 +166,7 @@ public:
|
||||
|
||||
// changed: gibt jetzt den pointer zurück.
|
||||
//QString* content() const;
|
||||
QString contentKey() const;
|
||||
void setContent( const QString* content );
|
||||
//void setContent( const QString* content );
|
||||
|
||||
//
|
||||
// Convenience-Funktionen zum Memberzugriff, die Implementierung
|
||||
@@ -243,6 +243,7 @@ protected:
|
||||
XQItem(const XQItem& other) = default;
|
||||
XQItem& operator=(const XQItem& other) = default;
|
||||
|
||||
bool hasContentPtr() const;
|
||||
QString contentFallBackText() const;
|
||||
|
||||
// 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!";
|
||||
|
||||
XQItem& item = xqItemFromIndex( index );
|
||||
if( item.isValid() )
|
||||
|
||||
|
||||
switch( item.renderStyle() )
|
||||
{
|
||||
case XQItem::HeaderStyle :
|
||||
return drawHeaderStyle( painter, option, index );
|
||||
|
||||
switch( item.renderStyle() )
|
||||
{
|
||||
case XQItem::HeaderStyle :
|
||||
return drawHeaderStyle( painter, option, index );
|
||||
case XQItem::ComboBoxStyle :
|
||||
return drawComboBoxStyle( painter, option, index );
|
||||
|
||||
case XQItem::ComboBoxStyle :
|
||||
return drawComboBoxStyle( painter, option, index );
|
||||
case XQItem::HiddenStyle :
|
||||
return;
|
||||
|
||||
case XQItem::HiddenStyle :
|
||||
return;
|
||||
|
||||
//case XQItem::ProgressBarStyle :
|
||||
// return drawProgressBarStyle( painter, option, index );
|
||||
//case XQItem::ProgressBarStyle :
|
||||
// return drawProgressBarStyle( painter, option, index );
|
||||
|
||||
|
||||
default:
|
||||
break;
|
||||
} // switch
|
||||
default:
|
||||
break;
|
||||
} // switch
|
||||
|
||||
|
||||
}
|
||||
|
||||
QStyledItemDelegate::paint(painter, option, index);
|
||||
|
||||
@@ -226,7 +225,7 @@ QWidget* XQItemDelegate::createEditor(QWidget* parent, const QStyleOptionViewIte
|
||||
{
|
||||
XQItem& item = xqItemFromIndex(index);
|
||||
XQItem::EditorType edType = item.editorType();
|
||||
if( !item.hasContentNode() || edType == XQItem::NoEditorType )
|
||||
if( edType == XQItem::NoEditorType )
|
||||
{
|
||||
qDebug() << "---- NO Content or NO EditorType";
|
||||
return nullptr;
|
||||
@@ -235,7 +234,7 @@ QWidget* XQItemDelegate::createEditor(QWidget* parent, const QStyleOptionViewIte
|
||||
qDebug() << "---- ed type:" << XQItem::fetchEditorTypeToString( edType ) << ": " << edType;
|
||||
//return QStyledItemDelegate::createEditor( parent, option, index );
|
||||
|
||||
return itemEditorFactory()->createEditor(edType, parent);
|
||||
return itemEditorFactory()->createEditor(edType, parent);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -8,8 +8,8 @@
|
||||
|
||||
<ItemTypes>
|
||||
<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="IsUserCheckable|IsEnabled" Icon="MediaPlay"/>
|
||||
<TreeChildType RenderStyle="PlainStyle" EditorType="LineEditType" ItemFlags="IsEnabled" Icon="MediaPlay"/>
|
||||
<TreeSectionType RenderStyle="PlainStyle" EditorType="LineEditType" ItemFlags="IsUserCheckable|IsEnabled" Icon="DesktopIcon"/>
|
||||
<HeaderType RenderStyle="HeaderStyle" EditorType="LineEditType" ItemFlags="IsEnabled"/>
|
||||
<HiddenType RenderStyle="HiddenStyle"/>
|
||||
<StaticType RenderStyle="PlainStyle"/>
|
||||
@@ -75,7 +75,7 @@
|
||||
<!-- 'Icon' überschreibt den default wert im ItemType und erzeugt damit einen neuen ItemType-->
|
||||
<PanelID ItemType="PlainType" Icon="DesktopIcon"/>
|
||||
<PanelName ItemType="PlainType" Icon="BrowserStop"/>
|
||||
<Manufacturer ItemType="ValueType"/>
|
||||
<Manufacturer ItemType="PlainType"/>
|
||||
<!-- 'UnitType' überschreibt den default wert im ItemType und erzeugt damit einen neuen ItemType-->
|
||||
<WattPeak ItemType="ValueType" UnitType="Wp"/>
|
||||
<Width ItemType="CheckableType" Icon="VistaShield" UnitType="m"/>
|
||||
@@ -98,12 +98,12 @@
|
||||
<Weight Caption="Weight" ItemType="HeaderType" />
|
||||
</Header>
|
||||
<ModelSheet>
|
||||
<InverterID Caption="Inverter" ItemType="ValueType" />
|
||||
<InverterName Caption="Name" ItemType="ValueType" />
|
||||
<Manufacturer Caption="Manufacturer" ItemType="ValueType" />
|
||||
<InverterID Caption="Inverter" ItemType="PlainType" />
|
||||
<InverterName Caption="Name" ItemType="PlainType" />
|
||||
<Manufacturer Caption="Manufacturer" ItemType="PlainType" />
|
||||
<MaxPowerInput Caption="max. Input" ItemType="ValueType" ItemType="ChoiceType" ChoiceModelSheetSource="MaxPowerInputChoice" 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"/>
|
||||
</ModelSheet>
|
||||
</Section>
|
||||
@@ -119,9 +119,9 @@
|
||||
<MaxVolt Caption="max. Volt" ItemType="HeaderType" />
|
||||
</Header>
|
||||
<ModelSheet>
|
||||
<BatteryID Caption="Battery" ItemType="ValueType" />
|
||||
<BatteryName Caption="Name" ItemType="ValueType" />
|
||||
<Manufacturer Caption="Manufacturer" ItemType="ValueType" />
|
||||
<BatteryID Caption="Battery" ItemType="PlainType" />
|
||||
<BatteryName Caption="Name" ItemType="PlainType" />
|
||||
<Manufacturer Caption="Manufacturer" ItemType="PlainType" />
|
||||
<Capacity Caption="Capacity" ItemType="ValueType" UnitType="Wh"/>
|
||||
<Yield Caption="Yield" ItemType="ValueType" ItemType="PercentageType" UnitType="%"/>
|
||||
<MaxCurrent Caption="max. Current" ItemType="ValueType" UnitType="A"/>
|
||||
|
Reference in New Issue
Block a user