-- fy
This commit is contained in:
@@ -60,17 +60,9 @@ XQItem* XQMainModel::addProjectItem( XQNodePtr contentNode )
|
|||||||
|
|
||||||
// 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( newItem );
|
||||||
// ... ausklappen...
|
|
||||||
const QModelIndex index = section.headerItem().index();
|
|
||||||
_treeTable->expand( index );
|
|
||||||
// ... und markieren
|
|
||||||
_treeTable->setCurrentIndex( index );
|
|
||||||
// quellknoten auch speichern
|
|
||||||
//newItem->setContentNode( contentNode );
|
|
||||||
//emit itemCreated( newItem );
|
|
||||||
|
|
||||||
// erzeuger sheet node speichern
|
// erzeuger sheet node speichern
|
||||||
newItem->setSheetNode( sheetNode );
|
newItem->setSheetNode( sheetNode );
|
||||||
|
expandNewItem(section.headerItem().index() );
|
||||||
return newItem;
|
return newItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -80,24 +72,8 @@ XQItem* XQMainModel::addProjectItem( XQNodePtr contentNode )
|
|||||||
|
|
||||||
void XQMainModel::addSectionItem( const XQModelSection& section, XQItem* projectItem )
|
void XQMainModel::addSectionItem( const XQModelSection& section, XQItem* projectItem )
|
||||||
{
|
{
|
||||||
|
|
||||||
qDebug() << " --- SUPPA0: " << section.contentType();
|
|
||||||
if( projectItem->hasContentNode())
|
|
||||||
qDebug() << " --- SUPPA1: -> " << projectItem->contentNode()->to_string();
|
|
||||||
qDebug() << " --- SUPPA2: -> " << projectItem->sheetNode()->to_string();
|
|
||||||
qDebug() << " --- SUPPA3: -> " << projectItem->sheetNode()->find_child_by_tag_name("CurrentSection")->to_string();
|
|
||||||
|
|
||||||
XQNodePtr sheetNode = projectItem->sheetNode()->find_child_by_tag_name("CurrentSection");
|
XQNodePtr sheetNode = projectItem->sheetNode()->find_child_by_tag_name("CurrentSection");
|
||||||
XQItem* newItem = _itemFactory.makeSingleItem( sheetNode, section.contentType() );
|
XQItem* newItem = _itemFactory.makeSingleItem( sheetNode, section.contentType() );
|
||||||
projectItem->appendRow( newItem );
|
projectItem->appendRow( newItem );
|
||||||
//qDebug() << " --- SUPPA4: -> " << section.contentRootNode()->to_string();
|
expandNewItem(projectItem->index() );
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
XQNodePtr sheetNode = projectItem->sheetNode()->find_child_by_tag_name("CurrentSection");
|
|
||||||
XQItemList list = _itemFactory.makeRow( XQItemFactory::mSingle, sheetNode, nullptr, c_ContentType );
|
|
||||||
projectItem->appendRow( list );
|
|
||||||
_treeTable->expand( projectItem->index() );
|
|
||||||
*/
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -57,9 +57,8 @@ protected:
|
|||||||
|
|
||||||
Q_DECLARE_METATYPE(XQModelSection)
|
Q_DECLARE_METATYPE(XQModelSection)
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Maptor containing all header sections.
|
//! 'maptor' struktur, die alle sections enthält
|
||||||
*/
|
|
||||||
|
|
||||||
class XQModelSectionList : public XQMaptor<XQModelSection>
|
class XQModelSectionList : public XQMaptor<XQModelSection>
|
||||||
{
|
{
|
||||||
|
@@ -83,6 +83,16 @@ XQItem& XQViewModel::xqFirstItem(int row) const
|
|||||||
return *static_cast<XQItem*>( QStandardItemModel::item(row) );
|
return *static_cast<XQItem*>( QStandardItemModel::item(row) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void XQViewModel::expandNewItem(const QModelIndex& index)
|
||||||
|
{
|
||||||
|
if( _treeTable )
|
||||||
|
{
|
||||||
|
// ... ausklappen...
|
||||||
|
_treeTable->expand( index );
|
||||||
|
// ... und markieren
|
||||||
|
_treeTable->setCurrentIndex( index );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//! initialisiert dieses model über den namen. Es wird hier
|
//! initialisiert dieses model über den namen. Es wird hier
|
||||||
//! nur die strukur erzeugt, keine inhalte.
|
//! nur die strukur erzeugt, keine inhalte.
|
||||||
@@ -148,6 +158,27 @@ void XQViewModel::addSection(const XQItemList& list, const XQNodePtr& sectionNod
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void XQViewModel::onToggleSection(const QString& sectionKey )
|
||||||
|
{
|
||||||
|
qDebug() << " --- onToggleSection: " << sectionKey;
|
||||||
|
/*
|
||||||
|
|
||||||
|
connect(model, &QStandardItemModel::dataChanged, this, &YourClass::onItemChanged);
|
||||||
|
|
||||||
|
void YourClass::onItemChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles)
|
||||||
|
{
|
||||||
|
if (roles.contains(Qt::CheckStateRole)) {
|
||||||
|
Qt::CheckState state = static_cast<Qt::CheckState>(topLeft.data(Qt::CheckStateRole).toInt());
|
||||||
|
if (state == Qt::Checked) {
|
||||||
|
qDebug() << "Checkbox wurde aktiviert!";
|
||||||
|
// Hier kannst du dein QObject benachrichtigen
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
//! SLOT, der aufgerufen wird, wenn eine edit-action getriggert wurde.
|
//! SLOT, der aufgerufen wird, wenn eine edit-action getriggert wurde.
|
||||||
|
|
||||||
void XQViewModel::onActionTriggered(QAction* action)
|
void XQViewModel::onActionTriggered(QAction* action)
|
||||||
@@ -428,6 +459,29 @@ void XQViewModel::cmdNew( const XQCommand& command )
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void XQViewModel::toggleSection( const XQModelSection& section )
|
||||||
|
{
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
if(_treeTable)
|
||||||
|
{
|
||||||
|
|
||||||
|
qDebug() << " ---- FIRZ: " << _sections.keyOf( sec );
|
||||||
|
int fstRow = _sections.firstRow( index );
|
||||||
|
int lstRow = _sections.lastRow( index );
|
||||||
|
_treeTable->toggleRowsHidden(fstRow, lstRow );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
emit sectionToggled( section );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
//! entfernt die neu angelegte zeile.
|
//! entfernt die neu angelegte zeile.
|
||||||
|
|
||||||
void XQViewModel::cmdNewUndo( const XQCommand& command )
|
void XQViewModel::cmdNewUndo( const XQCommand& command )
|
||||||
@@ -441,19 +495,11 @@ void XQViewModel::cmdToggleSection( const XQCommand& command )
|
|||||||
{
|
{
|
||||||
const QModelIndex& index = command.originIndex();
|
const QModelIndex& index = command.originIndex();
|
||||||
Q_ASSERT(index.isValid());
|
Q_ASSERT(index.isValid());
|
||||||
|
toggleSection( _sections.sectionFromIndex(index) );
|
||||||
int fstRow = _sections.firstRow( index );
|
|
||||||
int lstRow = _sections.lastRow( index );
|
|
||||||
|
|
||||||
bool hidden =_treeTable->isRowHidden( fstRow, _treeTable->rootIndex() );
|
|
||||||
for (int row = fstRow; row < lstRow; ++row )
|
|
||||||
_treeTable->setRowHidden( row, _treeTable->rootIndex(), !hidden );
|
|
||||||
|
|
||||||
emit sectionToggled( _sections.sectionFromIndex(index) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//! git die treetable zurück
|
//! gibt die treetable zurück
|
||||||
|
|
||||||
XQTreeTable* XQViewModel::treeTable()
|
XQTreeTable* XQViewModel::treeTable()
|
||||||
{
|
{
|
||||||
|
@@ -54,6 +54,9 @@ public:
|
|||||||
|
|
||||||
virtual void initModel( const QString& modelName);
|
virtual void initModel( const QString& modelName);
|
||||||
|
|
||||||
|
void expandNewItem(const QModelIndex& index);
|
||||||
|
void toggleSection( const XQModelSection& section );
|
||||||
|
|
||||||
//little helpers
|
//little helpers
|
||||||
const XQItem& xqRootItem();
|
const XQItem& xqRootItem();
|
||||||
|
|
||||||
@@ -96,6 +99,7 @@ public slots:
|
|||||||
|
|
||||||
virtual void onShowContextMenu(const QPoint& point);
|
virtual void onShowContextMenu(const QPoint& point);
|
||||||
virtual void onActionTriggered(QAction* action);
|
virtual void onActionTriggered(QAction* action);
|
||||||
|
virtual void onToggleSection(const QString& sectionKey );
|
||||||
|
|
||||||
// handle XQCommands ( == UndoCommand )
|
// handle XQCommands ( == UndoCommand )
|
||||||
virtual void onCommandRedo( const XQCommand& command );
|
virtual void onCommandRedo( const XQCommand& command );
|
||||||
|
@@ -51,6 +51,12 @@ XQItem& XQTreeTable::xqItemFromIndex(const QModelIndex& index )
|
|||||||
return modelView()->xqItemFromIndex( index );
|
return modelView()->xqItemFromIndex( index );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void XQTreeTable::toggleRowsHidden( int fstRow, int lstRow )
|
||||||
|
{
|
||||||
|
bool hidden = isRowHidden( fstRow, rootIndex() );
|
||||||
|
for (int row = fstRow; row < lstRow; ++row )
|
||||||
|
setRowHidden( row, rootIndex(), !hidden );
|
||||||
|
}
|
||||||
|
|
||||||
//! override von 'currentChanged' (noch nicht implementiert)
|
//! override von 'currentChanged' (noch nicht implementiert)
|
||||||
|
|
||||||
|
@@ -41,6 +41,8 @@ public:
|
|||||||
XQViewModel* modelView();
|
XQViewModel* modelView();
|
||||||
XQItem& xqItemFromIndex(const QModelIndex& index );
|
XQItem& xqItemFromIndex(const QModelIndex& index );
|
||||||
|
|
||||||
|
void toggleRowsHidden(int fstRow, int lstRow );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
void currentChanged(const QModelIndex& current, const QModelIndex& previous) override;
|
void currentChanged(const QModelIndex& current, const QModelIndex& previous) override;
|
||||||
|
Reference in New Issue
Block a user