Compare commits
3 Commits
main
...
experiment
Author | SHA1 | Date | |
---|---|---|---|
3c4893f308 | |||
e3be14c27b | |||
b6299be24b |
@@ -47,20 +47,23 @@ XQItem* XQMainModel::addProjectItem( XQNodePtr contentNode )
|
|||||||
{
|
{
|
||||||
// wir durchsuchen alle unsere section nach dem passenden content-type,
|
// wir durchsuchen alle unsere section nach dem passenden content-type,
|
||||||
// hier: content-type beschreibt die
|
// hier: content-type beschreibt die
|
||||||
|
|
||||||
|
/*
|
||||||
for(const auto& section : _sections )
|
for(const auto& section : _sections )
|
||||||
{
|
{
|
||||||
|
|
||||||
if( contentNode->attribute( c_ContentType) == section.contentType() )
|
if( contentNode->attribute( c_ContentType) == section.contentType() )
|
||||||
{
|
{
|
||||||
const QString& content = contentNode->attribute( "ProjectName" );
|
|
||||||
|
const QString* contentPtr = contentNode->attribute_ptr( "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.makeStaticItem(sheetNode, content );
|
XQItemList list = _itemFactory.makeHeaderRow( sheetNode, contentPtr );
|
||||||
// erzeuger sheet node speichern
|
// erzeuger sheet node speichern
|
||||||
newItem->setSheetNode( sheetNode );
|
//newItem->setSheetNode( sheetNode );
|
||||||
|
|
||||||
// den neuen eintrag in die passende section der übersicht eintragen ...
|
// den neuen eintrag in die passende section der übersicht eintragen ...
|
||||||
section.headerItem().appendRow( newItem );
|
section.headerItem().appendRow( list );
|
||||||
// ... ausklappen...
|
// ... ausklappen...
|
||||||
const QModelIndex index = section.headerItem().index();
|
const QModelIndex index = section.headerItem().index();
|
||||||
_treeTable->expand( index );
|
_treeTable->expand( index );
|
||||||
@@ -68,21 +71,25 @@ XQItem* XQMainModel::addProjectItem( XQNodePtr contentNode )
|
|||||||
_treeTable->setCurrentIndex( index );
|
_treeTable->setCurrentIndex( index );
|
||||||
// quellknoten auch speichern
|
// quellknoten auch speichern
|
||||||
//newItem->setContentNode( contentNode );
|
//newItem->setContentNode( contentNode );
|
||||||
|
|
||||||
//emit itemCreated( newItem );
|
//emit itemCreated( newItem );
|
||||||
|
|
||||||
return newItem;
|
return list[0];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
. */
|
||||||
|
|
||||||
throw XQException( "addProjectItem: main model should not be empty!" );
|
throw XQException( "addProjectItem: main model should not be empty!" );
|
||||||
}
|
}
|
||||||
|
|
||||||
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.makeStaticItem(sheetNode, section.contentType() );
|
XQItem* newItem = _itemFactory.makeItem(sheetNode, §ion.contentType() );
|
||||||
projectItem->appendRow( newItem );
|
projectItem->appendRow( newItem );
|
||||||
_treeTable->expand( projectItem->index() );
|
_treeTable->expand( projectItem->index() );
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
@@ -123,7 +123,7 @@ void XQMainWindow::initMainWindow()
|
|||||||
_mainModelView.initModel( c_MainModelName );
|
_mainModelView.initModel( c_MainModelName );
|
||||||
|
|
||||||
// #2. load demo data
|
// #2. load demo data
|
||||||
//loadDocument( c_DocumentFileName1 );
|
loadDocument( c_DocumentFileName1 );
|
||||||
//loadDocument( c_DocumentFileName2 );
|
//loadDocument( c_DocumentFileName2 );
|
||||||
|
|
||||||
qDebug() << " --- all here: " << XQNode::s_Count;
|
qDebug() << " --- all here: " << XQNode::s_Count;
|
||||||
@@ -259,18 +259,17 @@ void XQMainWindow::onTreeItemClicked(const QModelIndex& index )
|
|||||||
|
|
||||||
qDebug() << " --- XXX mainWindow onTreeItemClicked:" << entry.text();
|
qDebug() << " --- XXX mainWindow onTreeItemClicked:" << entry.text();
|
||||||
_mainTreeView->selectionModel()->select(index, QItemSelectionModel::Select);
|
_mainTreeView->selectionModel()->select(index, QItemSelectionModel::Select);
|
||||||
//entry.setBackground( QBrush( Qt::green ) );
|
|
||||||
|
|
||||||
QVariant variant = entry.QStandardItem::data( XQItem::ContentNodeRole );
|
if( XQNodePtr contentNode = entry.contentNode() )
|
||||||
|
{
|
||||||
XQNodePtr ptr = variant.value<XQNodePtr>();
|
QString key = contentNode->attribute(c_ProjectID);
|
||||||
|
|
||||||
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() );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -279,9 +278,9 @@ void XQMainWindow::onTreeItemClicked(const QModelIndex& index )
|
|||||||
|
|
||||||
void XQMainWindow::onTabClicked( int index )
|
void XQMainWindow::onTabClicked( int index )
|
||||||
{
|
{
|
||||||
const QString& key = _documentStore[index].treeItem->attribute( c_ProjectID );
|
//const QString& key = _documentStore[index].treeItem->attribute( c_ProjectID );
|
||||||
qDebug() << " ---- tab clicked: " << index << " : " << _documentStore[index].friendlyName << ": " << key;
|
qDebug() << " ---- tab clicked: " << index << " : " << _documentStore[index].friendlyName;// << ": " << key;
|
||||||
_mainTreeView->setCurrentIndex( _documentStore[index].treeItem->index() );
|
//_mainTreeView->setCurrentIndex( _documentStore[index].treeItem->index() );
|
||||||
}
|
}
|
||||||
|
|
||||||
void XQMainWindow::onSectionCreated( const XQModelSection& section )
|
void XQMainWindow::onSectionCreated( const XQModelSection& section )
|
||||||
@@ -347,8 +346,8 @@ void XQMainWindow::loadDocument( const QString& fileName )
|
|||||||
childModel->setTreeTable(childTreeView);
|
childModel->setTreeTable(childTreeView);
|
||||||
|
|
||||||
// neuen eintrag im übsichts-baum erzeugen
|
// neuen eintrag im übsichts-baum erzeugen
|
||||||
_currentProjectItem = _mainModelView.addProjectItem( contentRoot );
|
//_currentProjectItem = _mainModelView.addProjectItem( contentRoot );
|
||||||
_documentStore.addDocument( fileName, pTitle, _currentProjectItem, childModel );
|
//_documentStore.addDocument( fileName, pTitle, _currentProjectItem, childModel );
|
||||||
|
|
||||||
qDebug() << " --- ZZZ und jetzt:";
|
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.
|
//! gibt eine referenz auf den itemType dieses items zurück.
|
||||||
|
|
||||||
XQItemType& XQItem::itemType() const
|
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
|
class XQItem : public QStandardItem
|
||||||
{
|
{
|
||||||
|
|
||||||
|
friend class XQItemFactory;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/// Die data(enum role) Infrastruktur wird sowohl für XQItem als auch
|
/// Die data(enum role) Infrastruktur wird sowohl für XQItem als auch
|
||||||
@@ -138,18 +140,12 @@ public:
|
|||||||
//!
|
//!
|
||||||
bool isValid() const;
|
bool isValid() const;
|
||||||
|
|
||||||
// shortcuts auf XQNodePtr
|
//! gibt den zu diesem item gehörigen datenknoten zurück
|
||||||
//! gibt den zu diesem item gehörigen datenknoten
|
|
||||||
virtual XQNodePtr contentNode() const;
|
virtual XQNodePtr contentNode() const;
|
||||||
virtual void setContentNode(const XQNodePtr& contentNode );
|
|
||||||
|
|
||||||
virtual XQNodePtr sheetNode() const;
|
virtual XQNodePtr sheetNode() const;
|
||||||
virtual void setSheetNode( const XQNodePtr& sheetNode );
|
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;
|
XQItemType& itemType() const;
|
||||||
void setItemType( XQItemType* itemTypePtr );
|
void setItemType( XQItemType* itemTypePtr );
|
||||||
|
|
||||||
@@ -242,6 +238,8 @@ protected:
|
|||||||
XQItem(const XQItem& other) = default;
|
XQItem(const XQItem& other) = default;
|
||||||
XQItem& operator=(const XQItem& other) = default;
|
XQItem& operator=(const XQItem& other) = default;
|
||||||
|
|
||||||
|
void setContentNode(const XQNodePtr& contentNode );
|
||||||
|
|
||||||
using XQItemFlagMap = QMap<QString,int>;
|
using XQItemFlagMap = QMap<QString,int>;
|
||||||
using XQItemDataRoleMap = QMap<QString,int>;
|
using XQItemDataRoleMap = QMap<QString,int>;
|
||||||
using XQRenderStyleMap = QMap<QString,RenderStyle>;
|
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;
|
|
||||||
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -306,14 +306,14 @@ XQItemList XQItemFactory::createGenericRow( const XQNodePtr& contentNode, const
|
|||||||
|
|
||||||
//! erzeugt eine header-item row.
|
//! erzeugt eine header-item row.
|
||||||
|
|
||||||
XQItemList XQItemFactory::makeHeaderRow( const XQNodePtr& sheetNode )
|
XQItemList XQItemFactory::makeHeaderRow( const XQNodePtr& sheetNode, const QString& caption )
|
||||||
{
|
{
|
||||||
|
|
||||||
XQItemList list;
|
XQItemList list;
|
||||||
|
|
||||||
for( const auto& sheetEntry : sheetNode->children() )
|
for( const auto& sheetEntry : sheetNode->children() )
|
||||||
{
|
{
|
||||||
list.append( makeHeaderItem( sheetEntry ) );
|
list.append( makeHeaderItem( sheetEntry, caption ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
Q_ASSERT(!list.empty());
|
Q_ASSERT(!list.empty());
|
||||||
@@ -354,7 +354,7 @@ XQItemList XQItemFactory::makeContentRow( const XQNodePtr& sheetNode, const XQNo
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
XQItem* XQItemFactory::makeHeaderItem( const XQNodePtr& sheetNode )
|
XQItem* XQItemFactory::makeHeaderItem( const XQNodePtr& sheetNode, const QString& caption )
|
||||||
{
|
{
|
||||||
// den itemtype des neuen items rausfinden
|
// den itemtype des neuen items rausfinden
|
||||||
XQItemType* itemType = makeItemType(sheetNode); // throws
|
XQItemType* itemType = makeItemType(sheetNode); // throws
|
||||||
@@ -362,7 +362,7 @@ XQItem* XQItemFactory::makeHeaderItem( const XQNodePtr& sheetNode )
|
|||||||
// das ist Unterschied zum normalen Item: Der Titel kommt aus der Modelbeschreibung
|
// das ist Unterschied zum normalen Item: Der Titel kommt aus der Modelbeschreibung
|
||||||
// der content wird indirect über den tag-name des sheetnode geholt
|
// der content wird indirect über den tag-name des sheetnode geholt
|
||||||
|
|
||||||
XQItem* newItem = new XQItem( itemType, sheetNode->attribute_ptr(c_Caption) );
|
XQItem* newItem = new XQItem( itemType, sheetNode->attribute_ptr(caption) );
|
||||||
|
|
||||||
// __fixme!
|
// __fixme!
|
||||||
if( newItem->isCheckable() )
|
if( newItem->isCheckable() )
|
||||||
@@ -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
|
// das ist Unterschied vom HeaderItem zum normalen Item: Der Titel kommt aus der Modelbeschreibung
|
||||||
if(!contentNode)
|
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
|
// 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() );
|
||||||
@@ -409,18 +409,3 @@ XQItem* XQItemFactory::makeItem( const XQNodePtr& sheetNode, const QString* cont
|
|||||||
return newItem;
|
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;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@@ -34,15 +34,12 @@ public:
|
|||||||
|
|
||||||
//XQItemList makeEmptyRow( const XQNodePtr& contentNode, const XQNodePtr& sheetNode );
|
//XQItemList makeEmptyRow( const XQNodePtr& contentNode, const XQNodePtr& sheetNode );
|
||||||
|
|
||||||
XQItemList makeHeaderRow( const XQNodePtr& sheetNode );
|
XQItemList makeHeaderRow( const XQNodePtr& sheetNode, const QString& caption = c_Caption );
|
||||||
XQItemList makeContentRow( const XQNodePtr& sheetNode, const XQNodePtr& contentNode );
|
XQItemList makeContentRow( const XQNodePtr& sheetNode, const XQNodePtr& contentNode );
|
||||||
|
|
||||||
// wozu ist das gut?
|
// wozu ist das gut?
|
||||||
//XQItemList createGenericRow( const XQNodePtr& contentNode, const XQNodePtr& sheetNode );
|
//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;
|
void setItemDataFromString( XQItem& item, const QString& roleKey, const QString& source ) const;
|
||||||
|
|
||||||
XQItemType* makeItemType(const XQNodePtr& sheetEntry );
|
XQItemType* makeItemType(const XQNodePtr& sheetEntry );
|
||||||
@@ -53,7 +50,7 @@ protected:
|
|||||||
|
|
||||||
bool isValid();
|
bool isValid();
|
||||||
|
|
||||||
XQItem* makeHeaderItem( const XQNodePtr& sheetNode );
|
XQItem* makeHeaderItem( const XQNodePtr& sheetNode, const QString& caption );
|
||||||
XQItem* makeContentItem( const XQNodePtr& sheetNode, const XQNodePtr& contentNode );
|
XQItem* makeContentItem( const XQNodePtr& sheetNode, const XQNodePtr& contentNode );
|
||||||
|
|
||||||
XQItem* makeItem( const XQNodePtr& sheetNode, const XQNodePtr& contentNode );
|
XQItem* makeItem( const XQNodePtr& sheetNode, const XQNodePtr& contentNode );
|
||||||
|
Reference in New Issue
Block a user