little breakthrought im QML Layouts

This commit is contained in:
2025-08-26 17:45:06 +02:00
parent a39ce321f2
commit b217f2f9ad
16 changed files with 463 additions and 70 deletions

View File

@@ -31,7 +31,7 @@ void XQNodeStore::dumpList( const QString& title ) const
//! kostruktor. übergibt command-type und die aufrufende modelView.
XQCommand::XQCommand(CmdType cmdType, XQViewModel* modelView )
: _cmdType{ cmdType }, _model(modelView)
: _cmdType{ cmdType }, _viewModel(modelView)
{
}
@@ -66,7 +66,7 @@ void XQCommand::setCommandType( XQCommand::CmdType cmdType )
void XQCommand::redo()
{
_model->onCommandRedo( *this );
_viewModel->onCommandRedo( *this );
}
@@ -74,7 +74,7 @@ void XQCommand::redo()
void XQCommand::undo()
{
_model->onCommandUndo( *this );
_viewModel->onCommandUndo( *this );
}

View File

@@ -84,9 +84,9 @@ public:
protected:
CmdType _cmdType{cmdInvalid};
XQViewModel* _model{}; // needed for redo() / undo()
QModelIndex _originIndex;
CmdType _cmdType{cmdInvalid};
XQViewModel* _viewModel{}; // needed for redo() / undo()
QModelIndex _originIndex;
/*

View File

@@ -40,9 +40,9 @@ bool XQModelSection::isValid() const
return _modelIndex.isValid() && _sectionRootNode;
}
const QModelIndex& XQModelSection::modelIndex() const
QModelIndex XQModelSection::persistentModelIndex() const
{
return _modelIndex;
return _modelIndex.operator QModelIndex();
}
XQNodePtr XQModelSection::sectionRootNode() const
@@ -129,7 +129,7 @@ const XQModelSection& XQModelSectionList::sectionFromRow(int itemRow ) const
int i = size() - 1;
for (; i >= 0; --i)
{
if ( at(i).modelIndex().row() < itemRow )
if ( at(i).persistentModelIndex().row() < itemRow )
return at(i);
}
@@ -170,7 +170,7 @@ int XQModelSectionList::lastRow(const XQModelSection& section ) const
{
// last section? return last row of model
if (index == size() - 1)
return section.modelIndex().model()->rowCount();// - 1;
return section.persistentModelIndex().model()->rowCount();// - 1;
// return row above the row of the next section -> last row of given section
return at(index+1).row();
}
@@ -185,7 +185,7 @@ void XQModelSectionList::dump() const
qDebug() << " --- sections dump(): " <<size() << " entries.";
for( int i = 0; i<size(); ++i )
{
QModelIndex idx = at(i).modelIndex();
QModelIndex idx = at(i).persistentModelIndex();
qDebug() << " --- sections:" << i << "row: " << idx.row() << " keyOf(i): " << keyOf(i) << " indexData: "<< idx.data().toString() << " itemData: " << XQItem::xqItemFromIndex(idx).data(Qt::DisplayRole).toString();
}

View File

@@ -37,7 +37,7 @@ public:
bool isValid() const;
int row() const;
const QModelIndex& modelIndex() const;
QModelIndex persistentModelIndex() const;
XQNodePtr sectionRootNode() const;
XQNodePtr sheetRootNode() const;
XQNodePtr contentRootNode() const;

View File

@@ -19,6 +19,7 @@
#include <QMenu>
#include <QStandardItemModel>
#include <QAbstractItemView>
#include <QtQmlIntegration>
#include <xqsimpleclipboard.h>
#include <xqmodelsectionlist.h>
@@ -36,12 +37,15 @@ class XQCommand;
class XQViewModel : public QStandardItemModel
{
Q_OBJECT
//QML_ELEMENT
public:
XQViewModel(QObject* parent = nullptr);
virtual ~XQViewModel() = default;
QHash<int, QByteArray> roleNames() const override;
XQTreeTable* treeTable();
virtual void setTreeTable( XQTreeTable* mainView );
@@ -68,7 +72,7 @@ public:
virtual void cmdNew( XQCommand& command );
virtual void cmdNewUndo( XQCommand& command );
QHash<int, QByteArray> roleNames() const override;
/*!
@@ -106,7 +110,7 @@ signals:
protected:
void addSection(const XQItemList& list, const XQNodePtr& sheetNode );
virtual void initContextMenu() = 0;
virtual void initContextMenu(){}
// __fixme: should be created from xml
virtual void setupViewProperties();