wrecked it on purpose.
This commit is contained in:
@@ -47,15 +47,17 @@ XQItem* XQMainModel::addProjectItem( XQNodePtr contentNode )
|
||||
{
|
||||
// wir durchsuchen alle unsere section nach dem passenden content-type,
|
||||
// hier: content-type beschreibt die
|
||||
|
||||
/*
|
||||
for(const auto& section : _sections )
|
||||
{
|
||||
|
||||
if( contentNode->attribute( c_ContentType) == section.contentType() )
|
||||
{
|
||||
const QString& content = contentNode->attribute( "ProjectName" );
|
||||
const QString* contentPtr = contentNode->attribute_ptr( "ProjectName" );
|
||||
// __fixme! das ist mist!
|
||||
const XQNodePtr sheetNode = section.sheetRootNode()->first_child();
|
||||
XQItem* newItem = _itemFactory.makeStaticItem(sheetNode, content );
|
||||
XQItem* newItem = _itemFactory.makeItem(sheetNode, contentPtr );
|
||||
// erzeuger sheet node speichern
|
||||
newItem->setSheetNode( sheetNode );
|
||||
|
||||
@@ -75,14 +77,17 @@ XQItem* XQMainModel::addProjectItem( XQNodePtr contentNode )
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
throw XQException( "addProjectItem: main model should not be empty!" );
|
||||
}
|
||||
|
||||
void XQMainModel::addSectionItem( const XQModelSection& section, XQItem* projectItem )
|
||||
{
|
||||
/*
|
||||
XQNodePtr sheetNode = projectItem->sheetNode()->find_child_by_tag_name("CurrentSection");
|
||||
XQItem* newItem = _itemFactory.makeStaticItem(sheetNode, section.contentType() );
|
||||
XQItem* newItem = _itemFactory.makeItem(sheetNode, §ion.contentType() );
|
||||
projectItem->appendRow( newItem );
|
||||
_treeTable->expand( projectItem->index() );
|
||||
*/
|
||||
}
|
||||
|
@@ -123,7 +123,7 @@ void XQMainWindow::initMainWindow()
|
||||
_mainModelView.initModel( c_MainModelName );
|
||||
|
||||
// #2. load demo data
|
||||
//loadDocument( c_DocumentFileName1 );
|
||||
loadDocument( c_DocumentFileName1 );
|
||||
//loadDocument( c_DocumentFileName2 );
|
||||
|
||||
qDebug() << " --- all here: " << XQNode::s_Count;
|
||||
@@ -265,13 +265,14 @@ void XQMainWindow::onTreeItemClicked(const QModelIndex& index )
|
||||
|
||||
XQNodePtr ptr = variant.value<XQNodePtr>();
|
||||
|
||||
/*
|
||||
QString key = entry.attribute(c_ProjectID);
|
||||
qDebug() << " --- FIRZ: key: " << key;
|
||||
|
||||
bool isThere = _documentStore.contains(key);
|
||||
if( isThere)
|
||||
_tabWidget->setCurrentWidget( _documentStore[key].modelView->treeTable() );
|
||||
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
@@ -279,9 +280,9 @@ void XQMainWindow::onTreeItemClicked(const QModelIndex& index )
|
||||
|
||||
void XQMainWindow::onTabClicked( int index )
|
||||
{
|
||||
const QString& key = _documentStore[index].treeItem->attribute( c_ProjectID );
|
||||
qDebug() << " ---- tab clicked: " << index << " : " << _documentStore[index].friendlyName << ": " << key;
|
||||
_mainTreeView->setCurrentIndex( _documentStore[index].treeItem->index() );
|
||||
//const QString& key = _documentStore[index].treeItem->attribute( c_ProjectID );
|
||||
qDebug() << " ---- tab clicked: " << index << " : " << _documentStore[index].friendlyName;// << ": " << key;
|
||||
//_mainTreeView->setCurrentIndex( _documentStore[index].treeItem->index() );
|
||||
}
|
||||
|
||||
void XQMainWindow::onSectionCreated( const XQModelSection& section )
|
||||
@@ -347,8 +348,8 @@ void XQMainWindow::loadDocument( const QString& fileName )
|
||||
childModel->setTreeTable(childTreeView);
|
||||
|
||||
// neuen eintrag im übsichts-baum erzeugen
|
||||
_currentProjectItem = _mainModelView.addProjectItem( contentRoot );
|
||||
_documentStore.addDocument( fileName, pTitle, _currentProjectItem, childModel );
|
||||
//_currentProjectItem = _mainModelView.addProjectItem( contentRoot );
|
||||
//_documentStore.addDocument( fileName, pTitle, _currentProjectItem, childModel );
|
||||
|
||||
qDebug() << " --- ZZZ und jetzt:";
|
||||
|
||||
|
@@ -188,32 +188,6 @@ void XQItem::setSheetNode(const XQNodePtr& sheetNode )
|
||||
}
|
||||
|
||||
|
||||
//! tested, ob ein attribut mit dem namen 'attribKey' vorhanden ist.
|
||||
|
||||
bool XQItem::hasAttribute( const QString& attribKey ) const
|
||||
{
|
||||
return contentNode()->has_attribute( attribKey );
|
||||
}
|
||||
|
||||
|
||||
//! gibt das attribut namens 'attribKey' zurück, sofern vorhanden, sonst 'defaultValue'
|
||||
|
||||
const QString& XQItem::attribute( const QString& attribKey, const QString& defaultValue ) const
|
||||
{
|
||||
if( !hasAttribute(attribKey ) )
|
||||
return defaultValue;
|
||||
return contentNode()->attribute( attribKey );
|
||||
}
|
||||
|
||||
|
||||
//! tested, ob das attribut namens 'attribKey' dem wert 'attribValue' entspricht.
|
||||
|
||||
bool XQItem::testAttribute( const QString& attribKey, const QString& attribValue ) const
|
||||
{
|
||||
return contentNode()->test_attribute( attribKey, attribValue );
|
||||
}
|
||||
|
||||
|
||||
//! gibt eine referenz auf den itemType dieses items zurück.
|
||||
|
||||
XQItemType& XQItem::itemType() const
|
||||
@@ -730,65 +704,3 @@ QString XQItem::fetchUnitTypeToString( UnitType 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
|
||||
{
|
||||
|
||||
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 )
|
||||
{
|
||||
// hier: behandlung wie gehabt
|
||||
return XQItem::setData( value,role);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -35,6 +35,8 @@ class XQItemType;
|
||||
class XQItem : public QStandardItem
|
||||
{
|
||||
|
||||
friend class XQItemFactory;
|
||||
|
||||
public:
|
||||
|
||||
/// Die data(enum role) Infrastruktur wird sowohl für XQItem als auch
|
||||
@@ -138,18 +140,12 @@ public:
|
||||
//!
|
||||
bool isValid() const;
|
||||
|
||||
// shortcuts auf XQNodePtr
|
||||
//! gibt den zu diesem item gehörigen datenknoten
|
||||
//! gibt den zu diesem item gehörigen datenknoten zurück
|
||||
virtual XQNodePtr contentNode() const;
|
||||
virtual void setContentNode(const XQNodePtr& contentNode );
|
||||
|
||||
virtual XQNodePtr sheetNode() const;
|
||||
virtual void setSheetNode( const XQNodePtr& sheetNode );
|
||||
|
||||
bool hasAttribute( const QString& attribKey ) const;
|
||||
const QString& attribute( const QString& attribKey, const QString& defaultValue="" ) const;
|
||||
bool testAttribute( const QString& attribKey, const QString& attribValue ) const;
|
||||
|
||||
XQItemType& itemType() const;
|
||||
void setItemType( XQItemType* itemTypePtr );
|
||||
|
||||
@@ -242,6 +238,8 @@ protected:
|
||||
XQItem(const XQItem& other) = default;
|
||||
XQItem& operator=(const XQItem& other) = default;
|
||||
|
||||
void setContentNode(const XQNodePtr& contentNode );
|
||||
|
||||
using XQItemFlagMap = QMap<QString,int>;
|
||||
using XQItemDataRoleMap = QMap<QString,int>;
|
||||
using XQRenderStyleMap = QMap<QString,RenderStyle>;
|
||||
@@ -261,24 +259,6 @@ 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;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
@@ -386,7 +386,7 @@ XQItem* XQItemFactory::makeContentItem( const XQNodePtr& sheetNode, const XQNode
|
||||
|
||||
// das ist Unterschied vom HeaderItem zum normalen Item: Der Titel kommt aus der Modelbeschreibung
|
||||
if(!contentNode)
|
||||
return makeStaticItem( sheetNode, sheetNode->attribute(c_Caption) );
|
||||
return makeItem( sheetNode, sheetNode->attribute_ptr(c_Caption) );
|
||||
|
||||
// der content wird indirect über den tag-name des sheetnode geholt
|
||||
const QString* contentPtr = contentNode->attribute_ptr( sheetNode->tag_name() );
|
||||
@@ -409,18 +409,3 @@ XQItem* XQItemFactory::makeItem( const XQNodePtr& sheetNode, const QString* cont
|
||||
return newItem;
|
||||
}
|
||||
|
||||
XQStaticItem* XQItemFactory::makeStaticItem( const XQNodePtr& sheetNode, const QString& content )
|
||||
{
|
||||
XQItemType* itemType = makeItemType(sheetNode); // throws
|
||||
XQStaticItem* newItem = new XQStaticItem( itemType, content );
|
||||
|
||||
// __fixme!
|
||||
if( newItem->isCheckable() )
|
||||
{
|
||||
newItem->setCheckState( Qt::Checked );
|
||||
}
|
||||
|
||||
return newItem;
|
||||
|
||||
}
|
||||
|
||||
|
@@ -40,9 +40,6 @@ public:
|
||||
// wozu ist das gut?
|
||||
//XQItemList createGenericRow( const XQNodePtr& contentNode, const XQNodePtr& sheetNode );
|
||||
|
||||
XQStaticItem* makeStaticItem( const XQNodePtr& sheetNode, const QString& contentPtr );
|
||||
|
||||
|
||||
void setItemDataFromString( XQItem& item, const QString& roleKey, const QString& source ) const;
|
||||
|
||||
XQItemType* makeItemType(const XQNodePtr& sheetEntry );
|
||||
|
Reference in New Issue
Block a user