-- pre-holiday
This commit is contained in:
@@ -116,6 +116,8 @@ XQItem::XQPrefixExponentMap XQItem::s_PrefixExponentMap
|
||||
};
|
||||
|
||||
|
||||
//! Default konstruktor, setzt einen ungültigen (dummy)
|
||||
//! itemType.
|
||||
|
||||
XQItem::XQItem()
|
||||
: XQItem{XQItemType::staticItemType()}
|
||||
@@ -123,6 +125,9 @@ XQItem::XQItem()
|
||||
|
||||
}
|
||||
|
||||
|
||||
//! Default konstruktor mit einem vorhandenen itemType.
|
||||
|
||||
XQItem::XQItem( XQItemType* itemType )
|
||||
: QStandardItem{}
|
||||
{
|
||||
@@ -130,12 +135,20 @@ XQItem::XQItem( XQItemType* itemType )
|
||||
}
|
||||
|
||||
|
||||
//! konstruiert ein daten-item mit zeiger auf 'unser' attribut
|
||||
//! im übergeordneten content-node.
|
||||
|
||||
XQItem::XQItem(XQItemType* itemType, const QString *content )
|
||||
: XQItem{ itemType }
|
||||
{
|
||||
setContent(content);
|
||||
}
|
||||
|
||||
XQItem::XQItem( XQItemType* itemType, const QString& content )
|
||||
: XQItem{ itemType }
|
||||
{
|
||||
setText(content);
|
||||
}
|
||||
//! ruft den copy-konstruktor auf.
|
||||
|
||||
XQItem* XQItem::clone() const
|
||||
@@ -154,14 +167,19 @@ bool XQItem::isValid() const
|
||||
}
|
||||
|
||||
|
||||
//! testet, ob es einen content-node gibt.
|
||||
|
||||
bool XQItem::hasContentNode() const
|
||||
{
|
||||
return contentNode() != nullptr;
|
||||
}
|
||||
|
||||
|
||||
//! gibt den content-node zurück.
|
||||
|
||||
XQNodePtr XQItem::contentNode() const
|
||||
{
|
||||
XQNodePtr node = data( ContentNodeRole ).value<XQNodePtr>();
|
||||
if( node )
|
||||
return node;
|
||||
throw XQException("XQItem::contentNode() nullptr");
|
||||
return data( ContentNodeRole ).value<XQNodePtr>();
|
||||
}
|
||||
|
||||
|
||||
@@ -319,15 +337,16 @@ QString XQItem::rawText() const
|
||||
|
||||
|
||||
//! Gibt den string-zeiger auf das attribut aus unseren XQNodePtr zurück.
|
||||
|
||||
/*
|
||||
QString* XQItem::content() const
|
||||
{
|
||||
// macht jetzt das, ws draufsteht: gibt einen string* zurück
|
||||
// macht jetzt das, was draufsteht: gibt einen string* zurück
|
||||
return data( XQItem::ContentRole ).value<QString*>();
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
//! set den content()-string pointer. (als leihgabe)
|
||||
//! Setzt den content()-string pointer. (als leihgabe)
|
||||
|
||||
void XQItem::setContent( const QString* content )
|
||||
{
|
||||
@@ -335,21 +354,21 @@ 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.
|
||||
|
||||
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
|
||||
{
|
||||
return data( XQItem::ContentFormatRole ).toString();
|
||||
}
|
||||
|
||||
//! setz den den content format-string. wird im itemType gespeichert.
|
||||
//! Setzt den den content format-string. wird im itemType gespeichert.
|
||||
|
||||
void XQItem::setContentFormat(const QString& contentFormat)
|
||||
{
|
||||
@@ -357,7 +376,7 @@ void XQItem::setContentFormat(const QString& contentFormat)
|
||||
}
|
||||
|
||||
|
||||
//! gibt das read-only auswahl-model zurück (wenn dieses item als
|
||||
//! Gibt das read-only auswahl-model zurück (wenn dieses item als
|
||||
//! combobox gerendert wird). wird im itemType gespeichert.
|
||||
|
||||
QStandardItemModel* XQItem::fixedChoices() const
|
||||
@@ -413,6 +432,23 @@ QString XQItem::dataRoleName(int role) const
|
||||
return XQItem::fetchItemDataRoleName(role);
|
||||
}
|
||||
|
||||
|
||||
//! Gibt den content()-String zurück, sofern vorhanden.
|
||||
//! sonst: gibt der ihnalt der Qt::DisplayRole als fallback
|
||||
//! zurück.
|
||||
|
||||
QString XQItem::contentFallBackText() const
|
||||
{
|
||||
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
|
||||
return QStandardItem::data( Qt::DisplayRole ).toString();
|
||||
|
||||
}
|
||||
|
||||
//! angespasste variante von qstandarditem::setData. geteilte attribute
|
||||
//! werden vom xqitemtype geholt
|
||||
|
||||
@@ -438,33 +474,34 @@ QVariant XQItem::data(int role ) const
|
||||
return itemType().data(role);
|
||||
}
|
||||
|
||||
// Zugriffe auf den sichtbaren inhalt geben den inhalt des string pointer
|
||||
// auf ein feld in content node wieder.
|
||||
|
||||
// DisplayRole gibt den formatieren inhalt wieder. die formatierung übernimmt
|
||||
// der item type
|
||||
// auf den original inhalt im content node zurückgeben.
|
||||
|
||||
case Qt::DisplayRole :
|
||||
case XQItem::ContentRole:
|
||||
{
|
||||
if( itemType().renderStyle() == XQItem::FormattedStyle)//return "display:"+content();
|
||||
return itemType().formatText( *this );
|
||||
[[fallthrough]];
|
||||
qDebug() << " --- data(XQItem::ContentRole) should NOT be called!";
|
||||
return *QStandardItem::data( XQItem::ContentRole ).value<QString*>();
|
||||
}
|
||||
|
||||
// EditRole & ContentRole sollen den 'rohen' inhalt unseres string-pointers
|
||||
// auf den original inhalt im content node zurückgeben.
|
||||
|
||||
case Qt::EditRole :
|
||||
case XQItem::ContentRole:
|
||||
case Qt::EditRole :
|
||||
{
|
||||
// Zugriffe auf den text-inhalt geben den inhalt des string pointer
|
||||
// auf ein feld in content-node wieder. Wenn kein content-node vorhanden
|
||||
// ist (single-items), wird Qt::DisplayRole zurückgeliefert.
|
||||
|
||||
const QString* contentPtr = QStandardItem::data( XQItem::ContentRole ).value<const QString*>();
|
||||
if(contentPtr)
|
||||
return *contentPtr;
|
||||
return contentFallBackText();
|
||||
//[[fallthrough]];
|
||||
}
|
||||
|
||||
static const QString s_dummyContent("-");
|
||||
return s_dummyContent;
|
||||
// DisplayRole gibt den formatierten inhalt wieder. die formatierung übernimmt
|
||||
// der item type
|
||||
|
||||
case Qt::DisplayRole :
|
||||
{
|
||||
QString plainText = contentFallBackText();
|
||||
if( renderStyle() == XQItem::FormattedStyle)
|
||||
return XQItemType::formatToSI( plainText, unitType() );
|
||||
return plainText;
|
||||
}
|
||||
|
||||
case Qt::ToolTipRole:
|
||||
@@ -482,7 +519,7 @@ QVariant XQItem::data(int role ) const
|
||||
// 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 );
|
||||
return QStandardItem::data( XQItem::ContentNodeRole );
|
||||
|
||||
// sonst: delegieren an den node-Besitzer
|
||||
QModelIndex pIndex = model()->index( row(), 0 );
|
||||
@@ -557,25 +594,67 @@ void XQItem::setData(const QVariant& value, int role )
|
||||
return;
|
||||
}
|
||||
|
||||
// set the raw, unformatted data
|
||||
case ContentRole:
|
||||
case XQItem::ContentRole:
|
||||
{
|
||||
// string ptr setzen kann die basis.
|
||||
break;
|
||||
qDebug() << " --- data(XQItem::ContentRole) should NOT be called!";
|
||||
// string ptr setzen macht die basis implementierung
|
||||
[[fallthrough]];
|
||||
}
|
||||
|
||||
// set the raw, unformatted data
|
||||
case Qt::EditRole:
|
||||
{
|
||||
QString currentText = contentFallBackText();
|
||||
qDebug() << " --- setting EDITrole: " << currentText;
|
||||
|
||||
}
|
||||
|
||||
case Qt::DisplayRole:
|
||||
{
|
||||
// Wenn wir formatiert sind, machen wir das rückgängig
|
||||
if( itemType().renderStyle() == XQItem::FormattedStyle)
|
||||
QVariant plainText = XQItemType::unFormatFromSI( value.toString() );
|
||||
|
||||
// string setzen kann die basis ...
|
||||
qDebug() << " --- setting CONTENTrole: " << value.toString();
|
||||
// ... aber nur, wenn wir auch einen contentNode haben
|
||||
/*
|
||||
if( itemType().renderStyle() == XQItem::FormattedStyle)//return "display:"+content();
|
||||
return itemType().formatText( *this );
|
||||
[[fallthrough]];
|
||||
}
|
||||
|
||||
case Qt::DisplayRole:
|
||||
{
|
||||
// Wenn wir formatiert sind, machen wir das rückgängig
|
||||
if( itemType().renderStyle() == XQItem::FormattedStyle)
|
||||
QVariant plaintText = XQItemType::unFormatFromSI( value.toString() );
|
||||
|
||||
// string setzen kann die basis ...
|
||||
qDebug() << " --- setting CONTENTrole: " << value.toString();
|
||||
// ... aber nur, wenn wir auch einen contentNode haben
|
||||
|
||||
if( itemType().renderStyle() == XQItem::FormattedStyle)//return "display:"+content();
|
||||
return itemType().formatText( *this );
|
||||
[[fallthrough]];
|
||||
}
|
||||
|
||||
// EditRole & ContentRole sollen den 'rohen' inhalt unseres string-pointers
|
||||
// auf den original inhalt im content node zurückgeben.
|
||||
|
||||
case Qt::EditRole :
|
||||
case XQItem::ContentRole:
|
||||
{
|
||||
qDebug() << " --- setting EDITrole: " << value.toString();
|
||||
break;
|
||||
}
|
||||
|
||||
case Qt::DisplayRole :
|
||||
{
|
||||
// what will happen? value is a string ptr ?!
|
||||
qDebug() << " --- setting DISPLAYrole: " << value.toString();
|
||||
const QString* contentPtr = QStandardItem::data( XQItem::ContentRole ).value<const QString*>();
|
||||
if(contentPtr)
|
||||
return *contentPtr;
|
||||
if( )
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
*/
|
||||
|
||||
// alles andere wie gehabt
|
||||
case ContentNodeRole:
|
||||
|
Reference in New Issue
Block a user