-- fyerabend

This commit is contained in:
2025-08-08 21:39:33 +02:00
parent 666a2a9440
commit 5919d9d90d
15 changed files with 228 additions and 257 deletions

View File

@@ -12,7 +12,7 @@
***************************************************************************/
#include <xqmodelsections.h>
#include <xqmodelsectionlist.h>
#include <xqitem.h>

View File

@@ -12,8 +12,8 @@
***************************************************************************/
#ifndef XQMODELSECTIONS_H
#define XQMODELSECTIONS_H
#ifndef XQMODELSECTIONLIST_H
#define XQMODELSECTIONLIST_H
#include <QPersistentModelIndex>
#include <xqnode.h>
@@ -68,4 +68,4 @@ public:
};
#endif // XQMODELSECTIONS_H
#endif // XQMODELSECTIONLIST_H

View File

@@ -18,120 +18,25 @@
#include <iostream>
#include <memory>
#include <stack>
#include <iterator>
#include <QDebug>
#include <QModelIndex>
#include <znode.h>
#include <xqappdata.h>
#include <znode_factory.h>
// Overload the operator<< for QString and std::ostream
//! überlädt den operator<< für QString und std::ostream
std::ostream& operator<<(std::ostream& os, const QString& obj);
// raw node
//! raw node
using XQNode = znode::zbasic_node<QString>;
// default shared node
//! default shared node
using XQNodePtr = std::shared_ptr<znode::zbasic_node<QString>>;
// the node factory
//! die node factory
using XQNodeFactory = znode::znode_factory<QString>;
class XQNodeList : public znode::zbasic_node<QString>::znode_list
{
public:
XQNodeList() = default;
virtual ~XQNodeList() = default;
};
class XNodeIterator
{
public:
using iterator_category = std::forward_iterator_tag;
using value_type = XQNode;
using difference_type = std::ptrdiff_t;
using pointer = XQNode*;
using reference = XQNode&;
XNodeIterator() = default;
XNodeIterator(XQNodePtr root)
{
if (root) {
_stack.push(root);
}
}
reference operator*() const {
return *_stack.top();
}
pointer operator->() const {
return _stack.top().get();
}
XNodeIterator& operator++() {
auto node = _stack.top();
_stack.pop();
for (auto it = node->children().rbegin(); it != node->children().rend(); ++it)
{
_stack.push(*it);
}
return *this;
}
XNodeIterator operator++(int) {
XNodeIterator tmp = *this;
++(*this);
return tmp;
}
bool operator==(const XNodeIterator& other) const {
return _stack == other._stack;
}
bool operator!=(const XNodeIterator& other) const {
return !(*this == other);
}
private:
std::stack<XQNodePtr> _stack;
};
// Define the tree class with begin and end methods
class XTree
{
public:
XTree(XQNodePtr root)
: _root(root)
{}
XNodeIterator begin()
{
return XNodeIterator(_root);
}
XNodeIterator end()
{
return XNodeIterator();
}
private:
XQNodePtr _root;
};
//void inspect( XQNodePtr node, int offSet=0 );
void inspect( const XQNodePtr& node, int indent=0 );

View File

@@ -20,7 +20,7 @@
#include <QStandardItemModel>
#include <xqsimpleclipboard.h>
#include <xqmodelsections.h>
#include <xqmodelsectionlist.h>
#include <xqitemfactory.h>
#include <xqcontextmenu.h>
@@ -81,17 +81,22 @@ public:
virtual void cmdNew( XQCommand& command );
virtual void cmdNewUndo( XQCommand& command );
/*
/*!
Derzeit wir die default-implementierung von data/setData genutzt. hier wäre dann die
Stelle um setData & data an externe 'handler' umzubiegen, siehe giovannies 'model-injection'
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override
{
return QStandardItemModel::data( index, role );
}
bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override
{
qDebug() << " --- setData: " << value.toString();
return QStandardItemModel::setData( index, value, role );
}
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override
{
return QStandardItemModel::data( index, role );
}
*/
public slots: