Files
xtree/src/model/xqsectionmanager.h

93 lines
2.1 KiB
C
Raw Normal View History

2025-08-22 22:57:06 +02:00
/***************************************************************************
source::worx xtree
Copyright © 2024-2025 c.holzheuer
christoph.holzheuer@gmail.com
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
***************************************************************************/
2025-09-05 11:49:36 +02:00
#ifndef XQSECTIONMANAGER_H
#define XQSECTIONMANAGER_H
2025-08-22 22:57:06 +02:00
#include <QPersistentModelIndex>
#include <xqmaptor.h>
#include <xqitem.h>
2025-09-05 17:12:38 +02:00
//! Daten zur beschreibung einer 'sektion' des models.
2025-08-22 22:57:06 +02:00
class XQModelSection
{
public:
XQModelSection() = default;
XQModelSection(const QModelIndex& modelIndex, XQNodePtr sheetNode );
bool operator==(const XQModelSection& other) const;
bool isValid() const;
2025-09-05 21:42:40 +02:00
int firstRow() const;
2025-08-22 22:57:06 +02:00
2025-09-05 21:42:40 +02:00
QModelIndex startIndex() const;
2025-08-22 22:57:06 +02:00
XQNodePtr sectionRootNode() const;
XQNodePtr sheetRootNode() const;
XQNodePtr contentRootNode() const;
2025-09-05 11:49:36 +02:00
void setContentRootNode( const XQNodePtr dataRootNode ) const;
2025-08-22 22:57:06 +02:00
const QString& contentType() const;
XQItem& headerItem() const;
protected:
QPersistentModelIndex _modelIndex;
2025-09-06 14:07:25 +02:00
mutable XQNodePtr _sectionSheetRootNode{};
2025-09-05 11:49:36 +02:00
mutable XQNodePtr _contentRootNode{};
2025-08-22 22:57:06 +02:00
};
Q_DECLARE_METATYPE(XQModelSection)
2025-09-05 17:12:38 +02:00
//! Erste und letzte ziele einer XQModelSection
2025-09-05 21:42:40 +02:00
struct XQSectionRange
2025-09-05 17:12:38 +02:00
{
int firstRow{-1};
int lastRow{-1};
};
2025-09-01 17:40:08 +02:00
2025-09-05 17:12:38 +02:00
//! struktur, die alle sections enthält
2025-08-22 22:57:06 +02:00
2025-09-05 11:49:36 +02:00
class XQSectionManager
2025-08-22 22:57:06 +02:00
{
public:
bool hasValidSection(const QString& sectionKey) const;
2025-09-05 21:42:40 +02:00
const XQModelSection& sectionByKey( const QString& sectionKey ) const;
2025-09-05 11:49:36 +02:00
const XQModelSection& sectionByRow( int row ) const;
2025-09-06 14:07:25 +02:00
const XQModelSection& createSection(const QModelIndex& modelIndex, XQNodePtr sheetNode);
2025-09-05 21:42:40 +02:00
int lastRow(const XQModelSection& section ) const;
XQSectionRange sectionRange(const XQModelSection &section) const;
2025-08-22 22:57:06 +02:00
2025-09-05 11:49:36 +02:00
void dump()const;
protected:
XQMaptor<XQModelSection> _sections;
2025-08-22 22:57:06 +02:00
};
2025-09-05 11:49:36 +02:00
#endif // XQSECTIONMANAGER_H