added XQStaticItem
This commit is contained in:
@@ -43,8 +43,8 @@ void XQChildModel::setContent( const XQNodePtr& contentRoot )
|
|||||||
// Die Datenbasis als shared_ptr sichern
|
// Die Datenbasis als shared_ptr sichern
|
||||||
_contentRoot = contentRoot;
|
_contentRoot = contentRoot;
|
||||||
|
|
||||||
// Wir gehen über alle Einträge, die verschiedenen Typen
|
// Wir gehen über alle Einträge, die auch unterschiedliche Typen
|
||||||
// haben, hier: <Panel>. <Battery> ...
|
// haben können, hier: <Panel>. <Battery> ...
|
||||||
for (const auto& contentEntry : _contentRoot->children())
|
for (const auto& contentEntry : _contentRoot->children())
|
||||||
{
|
{
|
||||||
// Das ist hier der Typ des Eintrags: Panel, Battery ...
|
// Das ist hier der Typ des Eintrags: Panel, Battery ...
|
||||||
|
@@ -80,8 +80,6 @@ XQItem* XQMainModel::addProjectItem( XQNodePtr contentNode )
|
|||||||
|
|
||||||
void XQMainModel::addSectionItem( const XQModelSection& section, XQItem* projectItem )
|
void XQMainModel::addSectionItem( const XQModelSection& section, XQItem* projectItem )
|
||||||
{
|
{
|
||||||
//XQNodePtr sheetNode = projectParent->sheetNode();
|
|
||||||
//XQItem* newItem = _itemFactory.makeItem(sheetNode, contentPtr );
|
|
||||||
XQNodePtr sheetNode = projectItem->sheetNode()->find_child_by_tag_name("CurrentSection");
|
XQNodePtr sheetNode = projectItem->sheetNode()->find_child_by_tag_name("CurrentSection");
|
||||||
XQItem* newItem = _itemFactory.makeItem(sheetNode, §ion.contentType() );
|
XQItem* newItem = _itemFactory.makeItem(sheetNode, §ion.contentType() );
|
||||||
projectItem->appendRow( newItem );
|
projectItem->appendRow( newItem );
|
||||||
|
@@ -136,14 +136,6 @@ XQItem::XQItem(XQItemType* itemType, const QString *content )
|
|||||||
setContent(content);
|
setContent(content);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Warum beides?
|
|
||||||
XQItem::XQItem(XQItemType* itemType, const QString *content, const XQNodePtr& contentNode )
|
|
||||||
: XQItem{ itemType, content }
|
|
||||||
{
|
|
||||||
setContentNode(contentNode);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//! ruft den copy-konstruktor auf.
|
//! ruft den copy-konstruktor auf.
|
||||||
|
|
||||||
XQItem* XQItem::clone() const
|
XQItem* XQItem::clone() const
|
||||||
@@ -166,7 +158,10 @@ bool XQItem::isValid() const
|
|||||||
|
|
||||||
XQNodePtr XQItem::contentNode() const
|
XQNodePtr XQItem::contentNode() const
|
||||||
{
|
{
|
||||||
return data( ContentNodeRole ).value<XQNodePtr>();
|
XQNodePtr node = data( ContentNodeRole ).value<XQNodePtr>();
|
||||||
|
if( node )
|
||||||
|
return node;
|
||||||
|
throw XQException("XQItem::contentNode() nullptr");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -344,15 +339,10 @@ void XQItem::setUnitType(UnitType unitType)
|
|||||||
//! gibt den content-string zurück. das ist ein derefenzierter pointer
|
//! gibt den content-string zurück. das ist ein derefenzierter pointer
|
||||||
//! auf das zu diesem item gehörige daten-attribut 'useres' datenknotens.
|
//! auf das zu diesem item gehörige daten-attribut 'useres' datenknotens.
|
||||||
|
|
||||||
const QString& XQItem::content() const
|
QString XQItem::content() const
|
||||||
{
|
{
|
||||||
const QString* contentPtr = QStandardItem::data( XQItem::ContentRole ).value<const QString*>();
|
// umleitung auf text()
|
||||||
if(contentPtr)
|
return data( Qt::EditRole ).toString();
|
||||||
return *contentPtr;
|
|
||||||
|
|
||||||
static const QString s_dummyContent("-");
|
|
||||||
|
|
||||||
return s_dummyContent;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -366,7 +356,7 @@ void XQItem::setContent( const QString* content )
|
|||||||
|
|
||||||
//! holt den schlüssel bzw. bezeicher des content() string aus 'unserem' content knoten.
|
//! holt den schlüssel bzw. bezeicher des content() string aus 'unserem' content knoten.
|
||||||
|
|
||||||
const QString& XQItem::contentKey() const
|
QString XQItem::contentKey() const
|
||||||
{
|
{
|
||||||
return contentNode()->attributes().key_of( content() );
|
return contentNode()->attributes().key_of( content() );
|
||||||
}
|
}
|
||||||
@@ -487,7 +477,13 @@ QVariant XQItem::data(int role ) const
|
|||||||
case Qt::EditRole :
|
case Qt::EditRole :
|
||||||
case XQItem::ContentRole:
|
case XQItem::ContentRole:
|
||||||
{
|
{
|
||||||
return content();
|
|
||||||
|
const QString* contentPtr = QStandardItem::data( XQItem::ContentRole ).value<const QString*>();
|
||||||
|
if(contentPtr)
|
||||||
|
return *contentPtr;
|
||||||
|
|
||||||
|
static const QString s_dummyContent("-");
|
||||||
|
return s_dummyContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
case Qt::ToolTipRole:
|
case Qt::ToolTipRole:
|
||||||
@@ -730,5 +726,38 @@ QString XQItem::fetchUnitTypeToString( UnitType unitType)
|
|||||||
return s_UnitTypeMap[unitType];
|
return s_UnitTypeMap[unitType];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// ---
|
||||||
|
/// ---
|
||||||
|
/// ---
|
||||||
|
|
||||||
|
XQStaticItem::XQStaticItem()
|
||||||
|
: XQItem{XQItemType::staticItemType()}
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
XQStaticItem::XQStaticItem( XQItemType* itemType )
|
||||||
|
{
|
||||||
|
setItemType( itemType );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
XQStaticItem::XQStaticItem(XQItemType* itemType, const QString& content )
|
||||||
|
: XQItem{ itemType }
|
||||||
|
{
|
||||||
|
setText(content);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
QVariant XQStaticItem::data(int role ) const
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void XQStaticItem::setData(const QVariant &value, int role )
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -126,10 +126,8 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
XQItem();
|
XQItem();
|
||||||
|
|
||||||
XQItem( XQItemType* itemType );
|
XQItem( XQItemType* itemType );
|
||||||
XQItem( XQItemType* itemType, const QString* content );
|
XQItem( XQItemType* itemType, const QString* content );
|
||||||
XQItem( XQItemType* itemType, const QString* content, const XQNodePtr& contentNode );
|
|
||||||
|
|
||||||
virtual ~XQItem() = default;
|
virtual ~XQItem() = default;
|
||||||
|
|
||||||
@@ -143,8 +141,6 @@ public:
|
|||||||
// shortcuts auf XQNodePtr
|
// shortcuts auf XQNodePtr
|
||||||
//! gibt den zu diesem item gehörigen datenknoten
|
//! gibt den zu diesem item gehörigen datenknoten
|
||||||
virtual XQNodePtr contentNode() const;
|
virtual XQNodePtr contentNode() const;
|
||||||
|
|
||||||
|
|
||||||
virtual void setContentNode(const XQNodePtr& contentNode );
|
virtual void setContentNode(const XQNodePtr& contentNode );
|
||||||
|
|
||||||
virtual XQNodePtr sheetNode() const;
|
virtual XQNodePtr sheetNode() const;
|
||||||
@@ -167,8 +163,8 @@ public:
|
|||||||
// XQNodePtr, also unserem contentNode(). Das wird hier direkt aufgelöst und nicht auf
|
// XQNodePtr, also unserem contentNode(). Das wird hier direkt aufgelöst und nicht auf
|
||||||
// data() umgeleitet.
|
// data() umgeleitet.
|
||||||
|
|
||||||
const QString& content() const;
|
QString content() const;
|
||||||
const QString& contentKey() const;
|
QString contentKey() const;
|
||||||
void setContent( const QString* content );
|
void setContent( const QString* content );
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -265,6 +261,27 @@ protected:
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class XQStaticItem : public XQItem
|
||||||
|
{
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
|
||||||
|
XQStaticItem();
|
||||||
|
|
||||||
|
XQStaticItem( XQItemType* itemType );
|
||||||
|
XQStaticItem( XQItemType* itemType, const QString& content );
|
||||||
|
|
||||||
|
virtual ~XQStaticItem() = default;
|
||||||
|
|
||||||
|
QVariant data(int role = Qt::DisplayRole ) const override;
|
||||||
|
void setData(const QVariant &value, int role ) override;
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(XQItem::RenderStyle);
|
Q_DECLARE_METATYPE(XQItem::RenderStyle);
|
||||||
Q_DECLARE_METATYPE(XQItem::EditorType);
|
Q_DECLARE_METATYPE(XQItem::EditorType);
|
||||||
Q_DECLARE_METATYPE(XQItem::UnitType);
|
Q_DECLARE_METATYPE(XQItem::UnitType);
|
||||||
|
@@ -9,7 +9,7 @@
|
|||||||
<ItemTypes>
|
<ItemTypes>
|
||||||
<TreeParentType RenderStyle="PlainStyle" ItemFlags="IsEnabled|IsDropEnabled" Icon="DirIcon" />
|
<TreeParentType RenderStyle="PlainStyle" ItemFlags="IsEnabled|IsDropEnabled" Icon="DirIcon" />
|
||||||
<TreeChildType RenderStyle="PlainStyle" ItemFlags="IsEnabled" Icon="DesktopIcon"/>
|
<TreeChildType RenderStyle="PlainStyle" ItemFlags="IsEnabled" Icon="DesktopIcon"/>
|
||||||
<TreeSectionType RenderStyle="PlainStyle" ItemFlags="IsUserCheckable|IsEnabled" Icon="DirIcon"/>
|
<TreeSectionType RenderStyle="PlainStyle" ItemFlags="IsUserCheckable|IsEnabled" Icon="DirIcon"/>
|
||||||
<HeaderType RenderStyle="HeaderStyle" ItemFlags="IsEnabled"/>
|
<HeaderType RenderStyle="HeaderStyle" ItemFlags="IsEnabled"/>
|
||||||
<HiddenType RenderStyle="HiddenStyle"/>
|
<HiddenType RenderStyle="HiddenStyle"/>
|
||||||
<StaticType RenderStyle="PlainStyle"/>
|
<StaticType RenderStyle="PlainStyle"/>
|
||||||
|
Reference in New Issue
Block a user