-- fy
This commit is contained in:
@@ -55,7 +55,7 @@ XQItem* XQMainModel::addProjectItem( XQNodePtr contentNode )
|
|||||||
const QString& content = contentNode->attribute( "ProjectName" );
|
const QString& content = contentNode->attribute( "ProjectName" );
|
||||||
// __fixme! das ist mist!
|
// __fixme! das ist mist!
|
||||||
const XQNodePtr sheetNode = section.sheetRootNode()->first_child();
|
const XQNodePtr sheetNode = section.sheetRootNode()->first_child();
|
||||||
XQItem* newItem = _itemFactory.makeItem(sheetNode, content );
|
XQItem* newItem = _itemFactory.makeStaticItem(sheetNode, content );
|
||||||
// erzeuger sheet node speichern
|
// erzeuger sheet node speichern
|
||||||
newItem->setSheetNode( sheetNode );
|
newItem->setSheetNode( sheetNode );
|
||||||
|
|
||||||
@@ -82,7 +82,7 @@ XQItem* XQMainModel::addProjectItem( XQNodePtr contentNode )
|
|||||||
void XQMainModel::addSectionItem( const XQModelSection& section, XQItem* projectItem )
|
void XQMainModel::addSectionItem( const XQModelSection& section, XQItem* projectItem )
|
||||||
{
|
{
|
||||||
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, section.contentType() );
|
XQItem* newItem = _itemFactory.makeStaticItem(sheetNode, section.contentType() );
|
||||||
projectItem->appendRow( newItem );
|
projectItem->appendRow( newItem );
|
||||||
_treeTable->expand( projectItem->index() );
|
_treeTable->expand( projectItem->index() );
|
||||||
}
|
}
|
||||||
|
@@ -257,20 +257,16 @@ void XQMainWindow::onTreeItemClicked(const QModelIndex& index )
|
|||||||
|
|
||||||
XQItem& entry = XQItem::xqItemFromIndex(index);
|
XQItem& entry = XQItem::xqItemFromIndex(index);
|
||||||
|
|
||||||
qDebug() << " --- mainWindow onTreeItemClicked:" << entry.text();
|
qDebug() << " --- XXX mainWindow onTreeItemClicked:" << entry.text();
|
||||||
|
_mainTreeView->selectionModel()->select(index, QItemSelectionModel::Select);
|
||||||
|
//entry.setBackground( QBrush( Qt::green ) );
|
||||||
|
|
||||||
|
QString key = entry.attribute(c_ProjectID);
|
||||||
_mainTreeView->selectionModel()->select(index, QItemSelectionModel::Select);
|
|
||||||
entry.setBackground( QBrush( Qt::green ) );
|
|
||||||
|
|
||||||
QString key = entry.attribute(c_ProjectID);
|
|
||||||
qDebug() << " --- FIRZ: key: " << key;
|
qDebug() << " --- FIRZ: key: " << key;
|
||||||
|
|
||||||
|
|
||||||
bool isThere = _documentStore.contains(key);
|
bool isThere = _documentStore.contains(key);
|
||||||
if( isThere)
|
if( isThere)
|
||||||
|
_tabWidget->setCurrentWidget( _documentStore[key].modelView->treeTable() );
|
||||||
_tabWidget->setCurrentWidget( _documentStore[key].modelView->treeTable() );
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -336,16 +336,23 @@ void XQItem::setUnitType(UnitType unitType)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//! gibt den content-string zurück. das ist ein derefenzierter pointer
|
//! Verweist auf data(Qt::EditRole). Das ist der unformatierte text.
|
||||||
//! auf das zu diesem item gehörige daten-attribut 'useres' datenknotens.
|
|
||||||
|
|
||||||
QString XQItem::content() const
|
QString XQItem::rawText() const
|
||||||
{
|
{
|
||||||
// umleitung auf raw text
|
|
||||||
return data( Qt::EditRole ).toString();
|
return data( Qt::EditRole ).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//! 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
|
||||||
|
return data( XQItem::ContentRole ).value<QString*>();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//! set den content()-string pointer. (als leihgabe)
|
//! set den content()-string pointer. (als leihgabe)
|
||||||
|
|
||||||
void XQItem::setContent( const QString* content )
|
void XQItem::setContent( const QString* content )
|
||||||
@@ -358,7 +365,7 @@ void XQItem::setContent( const QString* content )
|
|||||||
|
|
||||||
QString XQItem::contentKey() const
|
QString XQItem::contentKey() const
|
||||||
{
|
{
|
||||||
return contentNode()->attributes().key_of( content() );
|
return contentNode()->attributes().key_of( rawText() );
|
||||||
}
|
}
|
||||||
|
|
||||||
//! gibt den content-format string zurück
|
//! gibt den content-format string zurück
|
||||||
@@ -488,7 +495,7 @@ QVariant XQItem::data(int role ) const
|
|||||||
|
|
||||||
case Qt::ToolTipRole:
|
case Qt::ToolTipRole:
|
||||||
{
|
{
|
||||||
return content() + ":" + unitTypeToString() + ":" + renderStyleToString() + ":" + unitTypeToString() + ":" + itemFlagsToString();
|
return rawText() + ":" + unitTypeToString() + ":" + renderStyleToString() + ":" + unitTypeToString() + ":" + itemFlagsToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -576,30 +583,24 @@ void XQItem::setData(const QVariant& value, int role )
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// DAS PASSIERT NIE, AUSSER
|
|
||||||
// set the raw, unformatted data
|
// set the raw, unformatted data
|
||||||
case ContentRole:
|
case ContentRole:
|
||||||
{
|
{
|
||||||
// what will happen? value is a string ptr ?!
|
// string ptr setzen kann die basis.
|
||||||
//qDebug() << " --- setting content: " << value.toString();
|
|
||||||
// string ptr setzen kann die basis.
|
|
||||||
break;
|
break;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case Qt::EditRole :
|
case Qt::EditRole :
|
||||||
{
|
{
|
||||||
// what will happen? value is a string ptr ?!
|
qDebug() << " --- setting EDITrole: " << value.toString();
|
||||||
qDebug() << " --- setting editrole: " << value.toString();
|
break;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case Qt::DisplayRole :
|
case Qt::DisplayRole :
|
||||||
{
|
{
|
||||||
// what will happen? value is a string ptr ?!
|
// what will happen? value is a string ptr ?!
|
||||||
qDebug() << " --- setting DISPLAYrole: " << value.toString();
|
qDebug() << " --- setting DISPLAYrole: " << value.toString();
|
||||||
// ignore this
|
break;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// alles andere wie gehabt
|
// alles andere wie gehabt
|
||||||
@@ -753,11 +754,41 @@ XQStaticItem::XQStaticItem(XQItemType* itemType, const QString& content )
|
|||||||
QVariant XQStaticItem::data(int role ) const
|
QVariant XQStaticItem::data(int role ) const
|
||||||
{
|
{
|
||||||
|
|
||||||
|
switch(role)
|
||||||
|
{
|
||||||
|
// DisplayRole gibt den formatieren inhalt wieder. die formatierung übernimmt
|
||||||
|
// der item type
|
||||||
|
// auf den original inhalt im content node zurückgeben.
|
||||||
|
|
||||||
|
case Qt::DisplayRole :
|
||||||
|
{
|
||||||
|
if( itemType().renderStyle() == XQItem::FormattedStyle)//return "display:"+content();
|
||||||
|
return itemType().formatText( *this );
|
||||||
|
return QStandardItem::data(Qt::DisplayRole);
|
||||||
|
}
|
||||||
|
|
||||||
|
case Qt::EditRole :
|
||||||
|
{
|
||||||
|
return QStandardItem::data(Qt::EditRole);
|
||||||
|
}
|
||||||
|
|
||||||
|
case XQItem::ContentRole:
|
||||||
|
{
|
||||||
|
qDebug() << " --- FIRTZ!";
|
||||||
|
return QStandardItem::data( XQItem::ContentRole );
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return XQItem::data(role);
|
||||||
}
|
}
|
||||||
|
|
||||||
void XQStaticItem::setData(const QVariant &value, int role )
|
void XQStaticItem::setData(const QVariant &value, int role )
|
||||||
{
|
{
|
||||||
|
// hier: behandlung wie gehabt
|
||||||
|
return XQItem::setData( value,role);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -159,11 +159,11 @@ public:
|
|||||||
void clearFlag( Qt::ItemFlag newFlag );
|
void clearFlag( Qt::ItemFlag newFlag );
|
||||||
QString itemFlagsToString() const;
|
QString itemFlagsToString() const;
|
||||||
|
|
||||||
//das ist ein Sonderfall: Ein ist ein dereferenzierter Zeiger auf 'unser' Atrribut in
|
// das ist die EditRole: unformatierter Text
|
||||||
// XQNodePtr, also unserem contentNode(). Das wird hier direkt aufgelöst und nicht auf
|
QString rawText() const;
|
||||||
// data() umgeleitet.
|
|
||||||
|
|
||||||
QString content() const;
|
// changed: gibt jetzt den pointer zurück.
|
||||||
|
QString* content() const;
|
||||||
QString contentKey() const;
|
QString contentKey() const;
|
||||||
void setContent( const QString* content );
|
void setContent( const QString* content );
|
||||||
|
|
||||||
|
@@ -258,12 +258,89 @@ QVariant XQItemFactory::makeVariant( int dataRole, const QString& source ) const
|
|||||||
///
|
///
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
XQItemList XQItemFactory::makeEmptyRow( const XQNodePtr& contentNode, const XQNodePtr& sheetNode )
|
||||||
|
{
|
||||||
|
Q_UNUSED(contentNode)
|
||||||
|
|
||||||
|
XQItemList list;
|
||||||
|
|
||||||
|
// create a data node for each sheet entry
|
||||||
|
size_t max = sheetNode->children().size();
|
||||||
|
for( size_t i=0; i<max; ++i )
|
||||||
|
{
|
||||||
|
// __fix
|
||||||
|
//list.append( new XQItem( "", XQItemType::EmptyStyle ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
XQItemList XQItemFactory::createGenericRow( const XQNodePtr& contentNode, const XQNodePtr& sheetNode )
|
||||||
|
{
|
||||||
|
|
||||||
|
// we have a new empty contentNode, so we add attributes first.
|
||||||
|
for( const auto& sheetEntry : sheetNode->children() )
|
||||||
|
{
|
||||||
|
QString value = "[" + sheetEntry->tag_name() + "]";
|
||||||
|
if( sheetEntry->has_attribute("Unit") )
|
||||||
|
value = "0";
|
||||||
|
contentNode->set_attribute( sheetEntry->tag_name(), value );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( sheetNode->has_attribute( c_FriendlyName ) )
|
||||||
|
contentNode->set_attribute( c_FriendlyName, sheetNode->friendly_name() );
|
||||||
|
|
||||||
|
// now, we can create a normal entry row
|
||||||
|
return makeContentRow(contentNode, sheetNode );
|
||||||
|
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
//! erzeugt eine item-row.
|
||||||
|
|
||||||
|
XQItemList XQItemFactory::makeContentRow( const XQNodePtr& sheetNode, const XQNodePtr& contentNode )
|
||||||
|
{
|
||||||
|
|
||||||
|
XQItemList list;
|
||||||
|
|
||||||
|
// - Gehe über alle Einträge der Typbeschreibung:
|
||||||
|
//
|
||||||
|
// <Battery>
|
||||||
|
// <Voltage .../>
|
||||||
|
// -> <Capacity ../>
|
||||||
|
//
|
||||||
|
// - Nimm das dazugehörige Attribut aus dem contentNode
|
||||||
|
// value = contentNode->attributes["Capacity"];
|
||||||
|
//
|
||||||
|
|
||||||
|
for( const auto& sheetEntry : sheetNode->children() )
|
||||||
|
{
|
||||||
|
list.append( makeItem( sheetEntry, contentNode ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !list.empty() )
|
||||||
|
{
|
||||||
|
// wir merken uns den original content node auch, aber
|
||||||
|
// im ersten Item.
|
||||||
|
dynamic_cast<XQItem*>(list[0])->setContentNode(contentNode);
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
//! fixme! unsinn!
|
//! fixme! unsinn!
|
||||||
//! erzeugt ein XQItem aus einer typ-beschreibung ('sheetNode') und einem daten-knoten ('contentNode').
|
//! erzeugt ein XQItem aus einer typ-beschreibung ('sheetNode') und einem daten-knoten ('contentNode').
|
||||||
//! wenn der content node nicht gesetzt ist, wird stattdess das attribut 'Caption' aus der typ-beschreibung
|
//! wenn der content node nicht gesetzt ist, wird stattdess das attribut 'Caption' aus der typ-beschreibung
|
||||||
//! verwendet: es handelt sich dann um ein header item, das erzeugt wurde.
|
//! verwendet: es handelt sich dann um ein header item, das erzeugt wurde.
|
||||||
|
|
||||||
XQItem* XQItemFactory::makeItem( const XQNodePtr& sheetNode, const XQNodePtr& contentNode )
|
XQItem* XQItemFactory::makeContentItem( const XQNodePtr& sheetNode, const XQNodePtr& contentNode )
|
||||||
{
|
{
|
||||||
// den itemtype des neuen items rausfinden
|
// den itemtype des neuen items rausfinden
|
||||||
XQItemType* itemType = makeItemType(sheetNode); // throws
|
XQItemType* itemType = makeItemType(sheetNode); // throws
|
||||||
@@ -273,7 +350,7 @@ XQItem* XQItemFactory::makeItem( const XQNodePtr& sheetNode, const XQNodePtr& co
|
|||||||
|
|
||||||
// das ist Unterschied vom HeaderItem zum normalen Item: Der Titel kommt aus der Modelbeschreibung
|
// das ist Unterschied vom HeaderItem zum normalen Item: Der Titel kommt aus der Modelbeschreibung
|
||||||
if(!contentNode)
|
if(!contentNode)
|
||||||
return makeItem( sheetNode, sheetNode->attribute(c_Caption) );
|
return makeStaticItem( sheetNode, sheetNode->attribute(c_Caption) );
|
||||||
|
|
||||||
// der content wird indirect über den tag-name des sheetnode geholt
|
// der content wird indirect über den tag-name des sheetnode geholt
|
||||||
const QString* contentPtr = contentNode->attribute_ptr( sheetNode->tag_name() );
|
const QString* contentPtr = contentNode->attribute_ptr( sheetNode->tag_name() );
|
||||||
@@ -300,86 +377,14 @@ XQStaticItem* XQItemFactory::makeStaticItem( const XQNodePtr& sheetNode, const Q
|
|||||||
{
|
{
|
||||||
XQItemType* itemType = makeItemType(sheetNode); // throws
|
XQItemType* itemType = makeItemType(sheetNode); // throws
|
||||||
XQStaticItem* newItem = new XQStaticItem( itemType, content );
|
XQStaticItem* newItem = new XQStaticItem( itemType, content );
|
||||||
|
|
||||||
// __fixme!
|
// __fixme!
|
||||||
if( newItem->isCheckable() )
|
if( newItem->isCheckable() )
|
||||||
{
|
{
|
||||||
newItem->setCheckState( Qt::Checked );
|
newItem->setCheckState( Qt::Checked );
|
||||||
}
|
}
|
||||||
|
|
||||||
return newItem;
|
return newItem;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//! erzeugt eine item-row.
|
|
||||||
|
|
||||||
XQItemList XQItemFactory::makeContentRow( const XQNodePtr& sheetNode, const XQNodePtr& contentNode )
|
|
||||||
{
|
|
||||||
|
|
||||||
XQItemList list;
|
|
||||||
|
|
||||||
// - Gehe über alle Einträge der Typbeschreibung:
|
|
||||||
//
|
|
||||||
// <Battery>
|
|
||||||
// <Voltage .../>
|
|
||||||
// -> <Capacity ../>
|
|
||||||
//
|
|
||||||
// - Nimm das dazugehörige Attribut aus dem contentNode
|
|
||||||
// value = contentNode->attributes["Capacity"];
|
|
||||||
//
|
|
||||||
|
|
||||||
for( const auto& sheetEntry : sheetNode->children() )
|
|
||||||
{
|
|
||||||
list.append( makeItem( sheetEntry, contentNode ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( !list.empty() )
|
|
||||||
{
|
|
||||||
// wir merken uns den original content node auch, aber
|
|
||||||
// im ersten Item.
|
|
||||||
dynamic_cast<XQItem*>(list[0])->setContentNode(contentNode);
|
|
||||||
}
|
|
||||||
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
XQItemList XQItemFactory::makeEmptyRow( const XQNodePtr& contentNode, const XQNodePtr& sheetNode )
|
|
||||||
{
|
|
||||||
Q_UNUSED(contentNode)
|
|
||||||
|
|
||||||
XQItemList list;
|
|
||||||
|
|
||||||
// create a data node for each sheet entry
|
|
||||||
size_t max = sheetNode->children().size();
|
|
||||||
for( size_t i=0; i<max; ++i )
|
|
||||||
{
|
|
||||||
// __fix
|
|
||||||
//list.append( new XQItem( "", XQItemType::EmptyStyle ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
XQItemList XQItemFactory::createGenericRow( const XQNodePtr& contentNode, const XQNodePtr& sheetNode )
|
|
||||||
{
|
|
||||||
|
|
||||||
// we have a new empty contentNode, so we add attributes first.
|
|
||||||
for( const auto& sheetEntry : sheetNode->children() )
|
|
||||||
{
|
|
||||||
QString value = "[" + sheetEntry->tag_name() + "]";
|
|
||||||
if( sheetEntry->has_attribute("Unit") )
|
|
||||||
value = "0";
|
|
||||||
contentNode->set_attribute( sheetEntry->tag_name(), value );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( sheetNode->has_attribute( c_FriendlyName ) )
|
|
||||||
contentNode->set_attribute( c_FriendlyName, sheetNode->friendly_name() );
|
|
||||||
|
|
||||||
// now, we can create a normal entry row
|
|
||||||
return makeContentRow(contentNode, sheetNode );
|
|
||||||
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
@@ -32,15 +32,16 @@ public:
|
|||||||
|
|
||||||
XQNodePtr findModelSheet( const QString& modelName ) const;
|
XQNodePtr findModelSheet( const QString& modelName ) const;
|
||||||
|
|
||||||
XQItem* makeItem( const XQNodePtr& sheetNode, const XQNodePtr& contentNode );
|
|
||||||
XQItem* makeItem( const XQNodePtr& sheetNode, const QString* contentPtr );
|
|
||||||
XQStaticItem* makeStaticItem( const XQNodePtr& sheetNode, const QString& contentPtr );
|
|
||||||
|
|
||||||
XQItemList makeContentRow( const XQNodePtr& sheetNode, const XQNodePtr& contentNode );
|
|
||||||
//XQItemList makeEmptyRow( const XQNodePtr& contentNode, const XQNodePtr& sheetNode );
|
//XQItemList makeEmptyRow( const XQNodePtr& contentNode, const XQNodePtr& sheetNode );
|
||||||
|
|
||||||
// wozu ist das gut?
|
// wozu ist das gut?
|
||||||
//XQItemList createGenericRow( const XQNodePtr& contentNode, const XQNodePtr& sheetNode );
|
//XQItemList createGenericRow( const XQNodePtr& contentNode, const XQNodePtr& sheetNode );
|
||||||
|
XQItemList makeContentRow( const XQNodePtr& sheetNode, const XQNodePtr& contentNode );
|
||||||
|
|
||||||
|
XQItem* makeItem( const XQNodePtr& sheetNode, const XQNodePtr& contentNode );
|
||||||
|
XQItem* makeItem( const XQNodePtr& sheetNode, const QString* contentPtr );
|
||||||
|
XQStaticItem* makeStaticItem( const XQNodePtr& sheetNode, const QString& contentPtr );
|
||||||
|
|
||||||
|
|
||||||
void setItemDataFromString( XQItem& item, const QString& roleKey, const QString& source ) const;
|
void setItemDataFromString( XQItem& item, const QString& roleKey, const QString& source ) const;
|
||||||
|
|
||||||
|
@@ -140,7 +140,7 @@ QVariant XQItemType::formatText( const XQItem& item ) const
|
|||||||
{
|
{
|
||||||
XQItem::UnitType uType = unitType();
|
XQItem::UnitType uType = unitType();
|
||||||
//qDebug() << " --- formatText: " << XQItem::fetchUnitTypeToString( uType);
|
//qDebug() << " --- formatText: " << XQItem::fetchUnitTypeToString( uType);
|
||||||
const QString& cont = item.content();
|
const QString& cont = item.rawText();
|
||||||
if( uType != XQItem::NoUnitType )
|
if( uType != XQItem::NoUnitType )
|
||||||
return formatToSI( cont, uType );
|
return formatToSI( cont, uType );
|
||||||
return cont;
|
return cont;
|
||||||
|
Reference in New Issue
Block a user