major 'firzifikation'

This commit is contained in:
2025-08-07 10:39:42 +02:00
parent e7213c60b8
commit d70df0cbaa
21 changed files with 208 additions and 80 deletions

View File

@@ -127,8 +127,8 @@ void XQChildModel::initContextMenu()
// __fixme! add a menu title // __fixme! add a menu title
_contextMenu->clear(); _contextMenu->clear();
const QModelIndex& curIdx = _treeView->currentIndex(); const QModelIndex& curIdx = _treeTable->currentIndex();
bool hasSel = curIdx.isValid() && _treeView->selectionModel()->hasSelection(); bool hasSel = curIdx.isValid() && _treeTable->selectionModel()->hasSelection();
bool canPaste = _clipBoard.canPaste( curIdx ); bool canPaste = _clipBoard.canPaste( curIdx );
_contextMenu->addAction( "icn11Dummy", "Undo", XQCommand::cmdUndo, _undoStack->canUndo() ); _contextMenu->addAction( "icn11Dummy", "Undo", XQCommand::cmdUndo, _undoStack->canUndo() );

View File

@@ -64,9 +64,9 @@ XQItem* XQMainModel::createTreeEntry( XQNodePtr contentNode )
{ {
XQItem* newTreeentry = _itemFactory.makeContentItem( contentNode, section.sheetRootNode ); XQItem* newTreeentry = _itemFactory.makeContentItem( contentNode, section.sheetRootNode );
section.headerItem().appendRow( newTreeentry ); section.headerItem().appendRow( newTreeentry );
_treeView->expand( section.modelIndex ); _treeTable->expand( section.modelIndex );
// ?? // ??
_treeView->setCurrentIndex( section.modelIndex ); _treeTable->setCurrentIndex( section.modelIndex );
newTreeentry->setContentNode(contentNode); newTreeentry->setContentNode(contentNode);
emit xqItemCreated( newTreeentry ); emit xqItemCreated( newTreeentry );
return newTreeentry; return newTreeentry;

View File

@@ -70,7 +70,7 @@ void XQMainWindow::initMainWindow()
_mainTreeView->setCurrentIndex( item->index() ); _mainTreeView->setCurrentIndex( item->index() );
// ... we set the current view to this node // ... we set the current view to this node
if( _documentStore.contains( pID ) ) if( _documentStore.contains( pID ) )
_tabWidget->setCurrentWidget( _documentStore[pID].modelView->treeView() ); _tabWidget->setCurrentWidget( _documentStore[pID].modelView->treeTable() );
} ); } );
try try
@@ -78,7 +78,7 @@ void XQMainWindow::initMainWindow()
// hand over undostack // hand over undostack
_mainModelView.setUndoStack(&_undoStack); _mainModelView.setUndoStack(&_undoStack);
// hand over left side navigation tree // hand over left side navigation tree
_mainModelView.setTreeView(_mainTreeView); _mainModelView.setTreeTable(_mainTreeView);
// #1. init the left side main tree view // #1. init the left side main tree view
_mainModelView.initModel( c_MainModelName ); _mainModelView.initModel( c_MainModelName );
@@ -203,7 +203,7 @@ void XQMainWindow::onTreeItemClicked(const QModelIndex& index )
QString key = entry.attribute(c_ProjectID); QString key = entry.attribute(c_ProjectID);
if( _documentStore.contains(key) ) if( _documentStore.contains(key) )
_tabWidget->setCurrentWidget( _documentStore[key].modelView->treeView() ); _tabWidget->setCurrentWidget( _documentStore[key].modelView->treeTable() );
} }
@@ -259,7 +259,7 @@ void XQMainWindow::loadDocument( const QString& fileName )
// Den globalen undo-stack ... // Den globalen undo-stack ...
childModel->setUndoStack(&_undoStack); childModel->setUndoStack(&_undoStack);
// und die TreeView übergeben // und die TreeView übergeben
childModel->setTreeView(childTreeView); childModel->setTreeTable(childTreeView);
// read the model data // read the model data
childModel->setContent( contentRoot->first_child() ); childModel->setContent( contentRoot->first_child() );

View File

@@ -144,7 +144,7 @@ XQItem::XQItem(XQItemType* itemType, const QString *content, const XQNodePtr& co
} }
/*
XQItem::XQItem(const XQItem& other) XQItem::XQItem(const XQItem& other)
: QStandardItem( other ) : QStandardItem( other )
{ {
@@ -152,17 +152,22 @@ XQItem::XQItem(const XQItem& other)
// die data() struktur // die data() struktur
} }
XQItem& XQItem::operator=(const XQItem& other)
{
if( this != &other)
{
// kopiert data()
this->QStandardItem::operator=( other );
}
return *this;
}
*/
//! firz //! firz
XQItem::~XQItem() XQItem::~XQItem()
{ {
// fixed choices lebt im item type, also
// im parent
//QAbstractItemModel* model = fixedChoices();
//if( model )
// delete model;
} }
@@ -178,12 +183,13 @@ XQItem* XQItem::clone() const
} }
//! firz //! false für ein ungültiges item. 'ungültig' heisst hier, dass nur ein
//! mockup-itemtype gesetzt ist.
bool XQItem::isValid() const bool XQItem::isValid() const
{ {
// fragwürdig XQItemType* dummyType = XQItemType::staticItemType();
return QStandardItem::data( XQItem::ItemTypeRole ).value<XQItemType*>() != nullptr; return QStandardItem::data( XQItem::ItemTypeRole ).value<XQItemType*>() != dummyType;
} }
@@ -429,12 +435,14 @@ QString XQItem::fixedChoicesToString() const
} }
//! setzt das auswahl-model für read-only comboboxes //! setzt das auswahl-model für read-only comboboxes
void XQItem::setfixedChoices( QStandardItemModel* newModel ) void XQItem::setfixedChoices( QStandardItemModel* newModel )
{ {
setData( QVariant::fromValue(newModel), XQItem::FixedChoicesRole); setData( QVariant::fromValue(newModel), XQItem::FixedChoicesRole);
} }
//! true, wenn 'ich' ein header item bin //! true, wenn 'ich' ein header item bin
bool XQItem::isHeaderStyle() bool XQItem::isHeaderStyle()
{ {
return renderStyle() == XQItem::HeaderStyle; return renderStyle() == XQItem::HeaderStyle;
@@ -442,6 +450,7 @@ bool XQItem::isHeaderStyle()
//! gibt den namen der datarole zurück //! gibt den namen der datarole zurück
QString XQItem::dataRoleName(int role) QString XQItem::dataRoleName(int role)
{ {
if( role < XQItem::NoRole && model() ) if( role < XQItem::NoRole && model() )
@@ -451,6 +460,7 @@ QString XQItem::dataRoleName(int role)
//! angespasste variante von qstandarditem::setData. geteilte attribute //! angespasste variante von qstandarditem::setData. geteilte attribute
//! werden vom xqitemtype geholt //! werden vom xqitemtype geholt
QVariant XQItem::data(int role ) const QVariant XQItem::data(int role ) const
{ {
//emitDataChanged() //emitDataChanged()

View File

@@ -125,16 +125,12 @@ public:
}; };
//XQItem(int rows, int columns = 1);
XQItem(); XQItem();
XQItem( XQItemType* itemType ); XQItem( XQItemType* itemType );
XQItem( XQItemType* itemType, const QString* content ); XQItem( XQItemType* itemType, const QString* content );
XQItem( XQItemType* itemType, const QString* content, const XQNodePtr& contentNode ); XQItem( XQItemType* itemType, const QString* content, const XQNodePtr& contentNode );
XQItem(const XQItem& other);
XQItem(const QStandardItem& other);
virtual ~XQItem(); virtual ~XQItem();
//! creates not a clone but a new default item, \see QStandardItemModel::setItemPrototype() //! creates not a clone but a new default item, \see QStandardItemModel::setItemPrototype()
@@ -184,7 +180,6 @@ public:
QString renderStyleToString() const; QString renderStyleToString() const;
void setRenderStyle(RenderStyle renderStyle ); void setRenderStyle(RenderStyle renderStyle );
//! fitze FATZE!
EditorType editorType() const; EditorType editorType() const;
QString editorTypeToString() const; QString editorTypeToString() const;
void setEditorType(EditorType editorType); void setEditorType(EditorType editorType);
@@ -195,9 +190,11 @@ public:
QString contentFormat() const; QString contentFormat() const;
void setContentFormat(const QString& contentFormat); void setContentFormat(const QString& contentFormat);
QStandardItemModel* fixedChoices() const; QStandardItemModel* fixedChoices() const;
QString fixedChoicesToString() const; QString fixedChoicesToString() const;
//! setzt das auswahl-model für read-only comboboxes
void setfixedChoices( QStandardItemModel* newModel ); void setfixedChoices( QStandardItemModel* newModel );
// //
@@ -205,20 +202,11 @@ public:
// //
bool isHeaderStyle(); bool isHeaderStyle();
//! gibt den namen der datarole zurück
QString dataRoleName(int role); QString dataRoleName(int role);
//! angespasste variante von qstandarditem::data
QVariant data(int role = Qt::DisplayRole ) const override; QVariant data(int role = Qt::DisplayRole ) const override;
//! angespasste variante von qstandarditem::setData
void setData(const QVariant &value, int role ) override; void setData(const QVariant &value, int role ) override;
// Das sind die die items im tree links: icon,text, node pointer
//XQItem( const QString& text, XQNodePtr contentNode );
//XQItem( const QString& text, XQItemType::RenderStyle renderStyle );
/* /*
template<class T> template<class T>
void setToVariant(T entry, QtExtUserRoles::NTDataRoles role) void setToVariant(T entry, QtExtUserRoles::NTDataRoles role)
@@ -254,6 +242,9 @@ public:
protected: protected:
XQItem(const XQItem& other) = default;
XQItem& operator=(const XQItem& other) = default;
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>;
@@ -268,6 +259,9 @@ protected:
static XQUnitTypeMap s_UnitTypeMap; static XQUnitTypeMap s_UnitTypeMap;
static XQPrefixExponentMap s_PrefixExponentMap; static XQPrefixExponentMap s_PrefixExponentMap;
//! leerer itemtype als mockup für den xqitem default constructor
static XQItemType s_DummyItemType;
}; };
Q_DECLARE_METATYPE(XQItem::RenderStyle); Q_DECLARE_METATYPE(XQItem::RenderStyle);

View File

@@ -69,9 +69,9 @@ XQItemDelegate::XQItemDelegate( XQViewModel& modelView)
} }
XQTreeTable* XQItemDelegate::treeView() const XQTreeTable* XQItemDelegate::treeTable() const
{ {
return _modelView.treeView(); return _modelView.treeTable();
} }
@@ -85,7 +85,7 @@ XQItem& XQItemDelegate::xqItemFromIndex( const QModelIndex& index ) const
QWidget* XQItemDelegate::prepareHeaderOption(const QStyleOptionViewItem& option, const QModelIndex& index, QStyleOptionHeader& headerOption) const QWidget* XQItemDelegate::prepareHeaderOption(const QStyleOptionViewItem& option, const QModelIndex& index, QStyleOptionHeader& headerOption) const
{ {
// use the header as "parent" for style init // use the header as "parent" for style init
QWidget* srcWidget = treeView()->header(); QWidget* srcWidget = treeTable()->header();
headerOption.initFrom(srcWidget); headerOption.initFrom(srcWidget);
headerOption.text = index.data(Qt::DisplayRole).toString(); headerOption.text = index.data(Qt::DisplayRole).toString();
headerOption.rect = option.rect; headerOption.rect = option.rect;

View File

@@ -34,7 +34,7 @@ public:
explicit XQItemDelegate(XQViewModel& modelView); explicit XQItemDelegate(XQViewModel& modelView);
XQTreeTable* treeView() const; XQTreeTable* treeTable() const;
XQItem& xqItemFromIndex( const QModelIndex& index ) const; XQItem& xqItemFromIndex( const QModelIndex& index ) const;
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override; void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;

View File

@@ -53,7 +53,6 @@ int main(int argc, char *argv[])
{ {
QApplication app(argc, argv); QApplication app(argc, argv);
//qDebug() << " lebt";
//app.setStyle("fusion"); //app.setStyle("fusion");
XQMainWindow window; XQMainWindow window;

View File

@@ -17,6 +17,8 @@
#include <xqtreetable.h> #include <xqtreetable.h>
//! firz
void XQNodeStore::dumpList( const QString& title ) const void XQNodeStore::dumpList( const QString& title ) const
{ {
if( !title.isEmpty() ) if( !title.isEmpty() )
@@ -26,23 +28,34 @@ void XQNodeStore::dumpList( const QString& title ) const
} }
//! firz
XQCommand::XQCommand(CmdType cmdType, XQViewModel* modelView ) XQCommand::XQCommand(CmdType cmdType, XQViewModel* modelView )
: _cmdType{ cmdType }, _model(modelView) : _cmdType{ cmdType }, _model(modelView)
{ {
} }
//! firz
XQCommand::~XQCommand() XQCommand::~XQCommand()
{ {
qDebug() << " --- command destructor: " << toString(); qDebug() << " --- command destructor: " << toString();
} }
//! firz
XQCommand::CmdType XQCommand::commandType() const XQCommand::CmdType XQCommand::commandType() const
{ {
return _cmdType; return _cmdType;
} }
//! firz
void XQCommand::setCommandType( XQCommand::CmdType cmdType ) void XQCommand::setCommandType( XQCommand::CmdType cmdType )
{ {
_cmdType = cmdType; _cmdType = cmdType;
@@ -105,6 +118,7 @@ void XQCommand::saveNodes( const QModelIndexList& list )
} }
} }
//! erzeugt einen string aus dem command-type, fürs debuggen. //! erzeugt einen string aus dem command-type, fürs debuggen.
QString XQCommand::toString() QString XQCommand::toString()

View File

@@ -16,6 +16,8 @@
#include <xqitem.h> #include <xqitem.h>
//! firz
XQModelSection::XQModelSection(const QModelIndex& aModelIndex, XQNodePtr aSheetNode) XQModelSection::XQModelSection(const QModelIndex& aModelIndex, XQNodePtr aSheetNode)
: modelIndex{ aModelIndex }, sheetRootNode{ aSheetNode } : modelIndex{ aModelIndex }, sheetRootNode{ aSheetNode }
{ {
@@ -23,24 +25,32 @@ XQModelSection::XQModelSection(const QModelIndex& aModelIndex, XQNodePtr aSheetN
} }
//! firz
bool XQModelSection::operator==(const XQModelSection& other) const bool XQModelSection::operator==(const XQModelSection& other) const
{ {
return modelIndex == other.modelIndex && sheetRootNode == other.sheetRootNode; return modelIndex == other.modelIndex && sheetRootNode == other.sheetRootNode;
} }
//! firz
bool XQModelSection::isValid() const bool XQModelSection::isValid() const
{ {
return modelIndex.isValid() && sheetRootNode; return modelIndex.isValid() && sheetRootNode;
} }
//! firz
int XQModelSection::XQModelSection::row() const int XQModelSection::XQModelSection::row() const
{ {
return modelIndex.row(); return modelIndex.row();
} }
//! firz
XQItem& XQModelSection::XQModelSection::headerItem() const XQItem& XQModelSection::XQModelSection::headerItem() const
{ {
return XQItem::xqItemFromIndex( modelIndex ); return XQItem::xqItemFromIndex( modelIndex );

View File

@@ -17,6 +17,9 @@
//! firz
void inspect( const XQNodePtr& node, int indent ) void inspect( const XQNodePtr& node, int indent )
{ {
qDebug() << std::string(indent * 2, ' ').c_str() << node.use_count() << ": " << node->to_string(); qDebug() << std::string(indent * 2, ' ').c_str() << node.use_count() << ": " << node->to_string();
@@ -31,6 +34,10 @@ void inspect( const XQNodePtr& node, int indent )
} }
//! firz
// Overload the operator<< for MyClass and std::ostream // Overload the operator<< for MyClass and std::ostream
std::ostream& operator<<(std::ostream& os, const QString& obj) std::ostream& operator<<(std::ostream& os, const QString& obj)
{ {
@@ -40,8 +47,7 @@ std::ostream& operator<<(std::ostream& os, const QString& obj)
} }
//! firz
template<> template<>
bool znode::zpayload<QString>::xstr_split_by(const QString& entry, const QString& sep, QString& key, QString& value ) bool znode::zpayload<QString>::xstr_split_by(const QString& entry, const QString& sep, QString& key, QString& value )
{ {
@@ -53,12 +59,18 @@ bool znode::zpayload<QString>::xstr_split_by(const QString& entry, const QString
return true; return true;
} }
//! firz
template<> template<>
QString znode::zpayload<QString>::xstr_sub_str( const QString& entry, int pos ) const QString znode::zpayload<QString>::xstr_sub_str( const QString& entry, int pos ) const
{ {
return entry.mid(pos); return entry.mid(pos);
} }
//! firz
template<> template<>
bool znode::zpayload<QString>::xstr_is_empty(const QString& entry ) const bool znode::zpayload<QString>::xstr_is_empty(const QString& entry ) const
{ {
@@ -66,6 +78,8 @@ bool znode::zpayload<QString>::xstr_is_empty(const QString& entry ) const
} }
//! firz
template<> template<>
const QString znode::zpayload<QString>::cType = "Type"; const QString znode::zpayload<QString>::cType = "Type";

View File

@@ -20,6 +20,10 @@
#include <xqnode.h> #include <xqnode.h>
//! firz
void XQNodeWriter::dumpTree( XQNodePtr rootNode, const QString& fileName ) const void XQNodeWriter::dumpTree( XQNodePtr rootNode, const QString& fileName ) const
{ {
QFile treeFile( fileName ); QFile treeFile( fileName );
@@ -36,6 +40,7 @@ void XQNodeWriter::dumpTree( XQNodePtr rootNode, const QString& fileName ) const
treeFile.close(); treeFile.close();
} }
//! firz
void XQNodeWriter::dumpNode( QXmlStreamWriter& writer, XQNodePtr node ) const void XQNodeWriter::dumpNode( QXmlStreamWriter& writer, XQNodePtr node ) const
{ {

View File

@@ -15,12 +15,19 @@
#include <xqselectionmodel.h> #include <xqselectionmodel.h>
#include <xqitem.h> #include <xqitem.h>
//! firz
XQSelectionModel::XQSelectionModel(QAbstractItemModel* model) XQSelectionModel::XQSelectionModel(QAbstractItemModel* model)
: QItemSelectionModel(model) : QItemSelectionModel(model)
{ {
} }
//! firz
XQSelectionModel::XQSelectionModel(QAbstractItemModel* model, QObject* parent) XQSelectionModel::XQSelectionModel(QAbstractItemModel* model, QObject* parent)
: QItemSelectionModel(model, parent) : QItemSelectionModel(model, parent)
{ {
@@ -28,6 +35,7 @@ XQSelectionModel::XQSelectionModel(QAbstractItemModel* model, QObject* parent)
} }
//! firz
void XQSelectionModel::select(const QItemSelection& selection, QItemSelectionModel::SelectionFlags command) void XQSelectionModel::select(const QItemSelection& selection, QItemSelectionModel::SelectionFlags command)
{ {
@@ -58,8 +66,5 @@ void XQSelectionModel::select(const QItemSelection& selection, QItemSelectionMod
} }
return QItemSelectionModel::select(newSelection, command); return QItemSelectionModel::select(newSelection, command);
} }
QItemSelectionModel::select(selection, command); QItemSelectionModel::select(selection, command);
} }

View File

@@ -16,6 +16,8 @@
#include <xqviewmodel.h> #include <xqviewmodel.h>
//! firz
bool XQSimpleClipBoard::canPaste( const QModelIndex& curIdx ) const bool XQSimpleClipBoard::canPaste( const QModelIndex& curIdx ) const
{ {
bool pasteOk = false; bool pasteOk = false;
@@ -36,6 +38,8 @@ bool XQSimpleClipBoard::canPaste( const QModelIndex& curIdx ) const
} }
//! firz
void XQSimpleClipBoard::saveNodes( const QModelIndexList& list ) void XQSimpleClipBoard::saveNodes( const QModelIndexList& list )
{ {
clear(); clear();

View File

@@ -30,6 +30,8 @@
//Q_GLOBAL_STATIC(XQItem,s_dummyItem) //Q_GLOBAL_STATIC(XQItem,s_dummyItem)
//! firz
void showItemList( const XQItemList& list) void showItemList( const XQItemList& list)
{ {
for(const auto& entry : list ) for(const auto& entry : list )
@@ -38,11 +40,15 @@ void showItemList( const XQItemList& list)
} }
//! firz
XQViewModel::~XQViewModel() XQViewModel::~XQViewModel()
{ {
} }
//! firz
XQViewModel::XQViewModel( QObject* parent ) XQViewModel::XQViewModel( QObject* parent )
: QStandardItemModel{ parent }, _itemFactory{ XQItemFactory::instance() } : QStandardItemModel{ parent }, _itemFactory{ XQItemFactory::instance() }
{ {
@@ -51,6 +57,8 @@ XQViewModel::XQViewModel( QObject* parent )
} }
//! firz
const XQItem& XQViewModel::xqRootItem() const XQItem& XQViewModel::xqRootItem()
{ {
// das ist ein hack, denn 'invisibleRootItem()' ist und bleibt ein // das ist ein hack, denn 'invisibleRootItem()' ist und bleibt ein
@@ -62,6 +70,8 @@ const XQItem& XQViewModel::xqRootItem()
} }
//! firz
XQItem& XQViewModel::xqItemFromIndex(const QModelIndex& index) const XQItem& XQViewModel::xqItemFromIndex(const QModelIndex& index) const
{ {
if( index.isValid() ) if( index.isValid() )
@@ -73,17 +83,21 @@ XQItem& XQViewModel::xqItemFromIndex(const QModelIndex& index) const
return XQItem::fallBackDummyItem(); return XQItem::fallBackDummyItem();
} }
//! firz
XQItem& XQViewModel::xqFirstItem(int row) const XQItem& XQViewModel::xqFirstItem(int row) const
{ {
return *static_cast<XQItem*>( QStandardItemModel::item(row) ); return *static_cast<XQItem*>( QStandardItemModel::item(row) );
} }
//! firz
void XQViewModel::onActionTriggered(QAction* action) void XQViewModel::onActionTriggered(QAction* action)
{ {
qDebug() << " --- onActionTriggered: count:" << XQNode::s_Count; qDebug() << " --- onActionTriggered: count:" << XQNode::s_Count;
// all selected indices // all selected indices
QModelIndexList selectionList = treeView()->selectionModel()->selectedRows(); QModelIndexList selectionList = treeTable()->selectionModel()->selectedRows();
// extract command type // extract command type
XQCommand::CmdType cmdType = action->data().value<XQCommand::CmdType>(); XQCommand::CmdType cmdType = action->data().value<XQCommand::CmdType>();
@@ -115,7 +129,7 @@ void XQViewModel::onActionTriggered(QAction* action)
XQCommand* command = new XQCommand( cmdType, this ); XQCommand* command = new XQCommand( cmdType, this );
// store the row positions of the selected indices // store the row positions of the selected indices
command->saveNodes( selectionList ); command->saveNodes( selectionList );
command->setOriginIndex( treeView()->currentIndex() ); command->setOriginIndex( treeTable()->currentIndex() );
// execute command // execute command
_undoStack->push( command ); _undoStack->push( command );
@@ -129,6 +143,8 @@ void XQViewModel::onActionTriggered(QAction* action)
* @param command the current command * @param command the current command
*/ */
//! firz
void XQViewModel::onCommandRedo( XQCommand& command ) void XQViewModel::onCommandRedo( XQCommand& command )
{ {
try try
@@ -171,6 +187,8 @@ void XQViewModel::onCommandRedo( XQCommand& command )
* @param command the command to be undone. * @param command the command to be undone.
*/ */
//! firz
void XQViewModel::onCommandUndo( XQCommand& command ) void XQViewModel::onCommandUndo( XQCommand& command )
{ {
qDebug() << " --- onCommandUndo: count: " << XQNode::s_Count; qDebug() << " --- onCommandUndo: count: " << XQNode::s_Count;
@@ -220,6 +238,7 @@ void XQViewModel::onCommandUndo( XQCommand& command )
// undo-/redo-able stuff // undo-/redo-able stuff
//! markierte knoten entfernen, 'command' enthält die liste //! markierte knoten entfernen, 'command' enthält die liste
void XQViewModel::cmdCut( XQCommand& command ) void XQViewModel::cmdCut( XQCommand& command )
{ {
// wir gehen rückwärts über alle gemerkten knoten ... // wir gehen rückwärts über alle gemerkten knoten ...
@@ -265,7 +284,7 @@ void XQViewModel::cmdCutUndo( XQCommand& command )
void XQViewModel::cmdPaste( XQCommand& command ) void XQViewModel::cmdPaste( XQCommand& command )
{ {
// selection holen ... // selection holen ...
QItemSelectionModel* selectionModel = treeView()->selectionModel(); QItemSelectionModel* selectionModel = treeTable()->selectionModel();
// ... und löschen // ... und löschen
selectionModel->clearSelection(); selectionModel->clearSelection();
@@ -289,7 +308,7 @@ void XQViewModel::cmdPaste( XQCommand& command )
insertRow( insRow, list ); insertRow( insRow, list );
// die neue item-row selektieren // die neue item-row selektieren
const QModelIndex& selIdx = list[0]->index(); const QModelIndex& selIdx = list[0]->index();
_treeView->selectionModel()->select(selIdx, QItemSelectionModel::Select | QItemSelectionModel::Rows); _treeTable->selectionModel()->select(selIdx, QItemSelectionModel::Select | QItemSelectionModel::Rows);
// zur nächsten zeile // zur nächsten zeile
insRow++; insRow++;
nodePos++; nodePos++;
@@ -322,6 +341,8 @@ void XQViewModel::cmdPasteUndo( XQCommand& command )
// don't clone into clipboard, remove items // don't clone into clipboard, remove items
//! firz
void XQViewModel::cmdDelete( XQCommand& command ) void XQViewModel::cmdDelete( XQCommand& command )
{ {
// wir gehen rückwärts über alle markieren knoten ... // wir gehen rückwärts über alle markieren knoten ...
@@ -337,6 +358,8 @@ void XQViewModel::cmdDelete( XQCommand& command )
} }
} }
//! firz
void XQViewModel::cmdDeleteUndo( XQCommand& command ) void XQViewModel::cmdDeleteUndo( XQCommand& command )
{ {
@@ -348,6 +371,8 @@ void XQViewModel::cmdDeleteUndo( XQCommand& command )
* @param command the command * @param command the command
*/ */
//! firz
void XQViewModel::cmdNew( XQCommand& command ) void XQViewModel::cmdNew( XQCommand& command )
{ {
@@ -376,17 +401,21 @@ void XQViewModel::cmdNew( XQCommand& command )
insertRow( origin.row(), list ); insertRow( origin.row(), list );
// ... and make it ... // ... and make it ...
treeView()->setCurrentIndex( list[0]->index() ); treeTable()->setCurrentIndex( list[0]->index() );
// ... editable // ... editable
treeView()->edit( list[0]->index() ); treeTable()->edit( list[0]->index() );
*/ */
} }
//! firz
void XQViewModel::cmdNewUndo( XQCommand& command ) void XQViewModel::cmdNewUndo( XQCommand& command )
{ {
} }
//! firz
void XQViewModel::cmdToggleSection( const QModelIndex& index ) void XQViewModel::cmdToggleSection( const QModelIndex& index )
{ {
Q_ASSERT(index.isValid()); Q_ASSERT(index.isValid());
@@ -394,31 +423,35 @@ void XQViewModel::cmdToggleSection( const QModelIndex& index )
int fstRow = _sections.firstRow( index ); int fstRow = _sections.firstRow( index );
int lstRow = _sections.lastRow( index ); int lstRow = _sections.lastRow( index );
bool hidden =_treeView->isRowHidden( fstRow, _treeView->rootIndex() ); bool hidden =_treeTable->isRowHidden( fstRow, _treeTable->rootIndex() );
for (int row = fstRow; row < lstRow; ++row ) for (int row = fstRow; row < lstRow; ++row )
_treeView->setRowHidden( row, _treeView->rootIndex(), !hidden ); _treeTable->setRowHidden( row, _treeTable->rootIndex(), !hidden );
} }
XQTreeTable* XQViewModel::treeView() //! firz
XQTreeTable* XQViewModel::treeTable()
{ {
return _treeView; return _treeTable;
} }
void XQViewModel::setTreeView(XQTreeTable* mainView ) //! firz
void XQViewModel::setTreeTable(XQTreeTable* mainView )
{ {
// store view for direct access: the maintree // store view for direct access: the maintree
_treeView = mainView; _treeTable = mainView;
// connect myself as model to the mainview // connect myself as model to the mainview
_treeView->setModel(this); _treeTable->setModel(this);
XQItemDelegate* delegate = new XQItemDelegate( *this ); XQItemDelegate* delegate = new XQItemDelegate( *this );
_treeView->setItemDelegate( delegate ); _treeTable->setItemDelegate( delegate );
_contextMenu = new XQContextMenu( mainView ); _contextMenu = new XQContextMenu( mainView );
connect( _treeView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(onShowContextMenu(QPoint))); connect( _treeTable, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(onShowContextMenu(QPoint)));
//connect( _treeView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(onDoubleClicked(QModelIndex)) ); //connect( _treeTable, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(onDoubleClicked(QModelIndex)) );
connect(_contextMenu, SIGNAL(triggered(QAction*)), this, SLOT(onActionTriggered(QAction*))); connect(_contextMenu, SIGNAL(triggered(QAction*)), this, SLOT(onActionTriggered(QAction*)));
// __fixme, die view soll über das modelsheet konfiguriert werden! // __fixme, die view soll über das modelsheet konfiguriert werden!
@@ -430,17 +463,21 @@ void XQViewModel::setTreeView(XQTreeTable* mainView )
* edit triggers and so on. * edit triggers and so on.
*/ */
//! firz
void XQViewModel::setupViewProperties() void XQViewModel::setupViewProperties()
{ {
_treeView->setContextMenuPolicy(Qt::CustomContextMenu); _treeTable->setContextMenuPolicy(Qt::CustomContextMenu);
_treeView->setEditTriggers(QAbstractItemView::DoubleClicked | QAbstractItemView::EditKeyPressed); _treeTable->setEditTriggers(QAbstractItemView::DoubleClicked | QAbstractItemView::EditKeyPressed);
_treeView->setSelectionBehavior(QAbstractItemView::SelectRows); _treeTable->setSelectionBehavior(QAbstractItemView::SelectRows);
_treeView->setSelectionMode(QAbstractItemView::ExtendedSelection); _treeTable->setSelectionMode(QAbstractItemView::ExtendedSelection);
//_treeView->setSelectionMode(QAbstractItemView::ContiguousSelection); //_treeTable->setSelectionMode(QAbstractItemView::ContiguousSelection);
_treeView->setSelectionModel( new XQSelectionModel(this) ); _treeTable->setSelectionModel( new XQSelectionModel(this) );
} }
//! firz
void XQViewModel::addSection( const XQItemList& list, const XQNodePtr& sheetNode ) void XQViewModel::addSection( const XQItemList& list, const XQNodePtr& sheetNode )
{ {
appendRow(list); appendRow(list);
@@ -448,25 +485,32 @@ void XQViewModel::addSection( const XQItemList& list, const XQNodePtr& sheetNode
} }
//! firz
QUndoStack* XQViewModel::undoStack() QUndoStack* XQViewModel::undoStack()
{ {
return _undoStack; return _undoStack;
} }
//! firz
void XQViewModel::setUndoStack( QUndoStack* undoStack ) void XQViewModel::setUndoStack( QUndoStack* undoStack )
{ {
_undoStack = undoStack; _undoStack = undoStack;
} }
//! firz
void XQViewModel::onShowContextMenu(const QPoint& point) void XQViewModel::onShowContextMenu(const QPoint& point)
{ {
initContextMenu(); initContextMenu();
_contextMenu->popup(_treeView->mapToGlobal(point)); _contextMenu->popup(_treeTable->mapToGlobal(point));
} }
//! firz
QHash<int, QByteArray> XQViewModel::roleNames() const QHash<int, QByteArray> XQViewModel::roleNames() const
{ {

View File

@@ -52,8 +52,8 @@ public:
XQViewModel(QObject* parent = nullptr); XQViewModel(QObject* parent = nullptr);
virtual ~XQViewModel(); virtual ~XQViewModel();
XQTreeTable* treeView(); XQTreeTable* treeTable();
virtual void setTreeView( XQTreeTable* mainView ); virtual void setTreeTable( XQTreeTable* mainView );
QUndoStack* undoStack(); QUndoStack* undoStack();
void setUndoStack( QUndoStack* undoStack ); void setUndoStack( QUndoStack* undoStack );
@@ -125,7 +125,7 @@ protected:
XQSimpleClipBoard _clipBoard; XQSimpleClipBoard _clipBoard;
XQModelSections _sections; XQModelSections _sections;
XQTreeTable* _treeView{}; XQTreeTable* _treeTable{};
QUndoStack* _undoStack{}; QUndoStack* _undoStack{};
XQContextMenu* _contextMenu{}; XQContextMenu* _contextMenu{};

View File

@@ -14,6 +14,9 @@
#include <znode.h> #include <znode.h>
//! firz
namespace znode namespace znode
{ {

View File

@@ -14,6 +14,8 @@
#include <xqexception.h> #include <xqexception.h>
//! firz
XQException::XQException(const QString& what, const QString& param ) XQException::XQException(const QString& what, const QString& param )
: std::runtime_error( param.isEmpty() ? what.toStdString() : QString( "%1: %2" ).arg(what,param).toStdString( ) ) : std::runtime_error( param.isEmpty() ? what.toStdString() : QString( "%1: %2" ).arg(what,param).toStdString( ) )
{} {}

View File

@@ -15,6 +15,8 @@
#include <xqcontextmenu.h> #include <xqcontextmenu.h>
//! firz
XQContextMenu::XQContextMenu(const QString& title, QWidget* parent ) XQContextMenu::XQContextMenu(const QString& title, QWidget* parent )
: QMenu( title, parent ) : QMenu( title, parent )
{ {
@@ -27,13 +29,15 @@ XQContextMenu::XQContextMenu(const QString& title, QWidget* parent )
} }
//! firz
XQContextMenu::XQContextMenu(QWidget* parent) XQContextMenu::XQContextMenu(QWidget* parent)
: QMenu( parent ) : QMenu( parent )
{ {
} }
//! firz
void XQContextMenu::addAction(const QString& text, XQCommand::CmdType commandType, bool enabled) void XQContextMenu::addAction(const QString& text, XQCommand::CmdType commandType, bool enabled)
{ {
@@ -45,12 +49,16 @@ void XQContextMenu::addAction(const QString& text, XQCommand::CmdType commandTyp
} }
//! firz
void XQContextMenu::addAction(const QString& iconKey, const QString& name, XQCommand::CmdType commandType, bool enabled) void XQContextMenu::addAction(const QString& iconKey, const QString& name, XQCommand::CmdType commandType, bool enabled)
{ {
addAction(XQAppData::typeIcon( iconKey), name, commandType, enabled ); addAction(XQAppData::typeIcon( iconKey), name, commandType, enabled );
} }
//! firz
void XQContextMenu::addAction(const QIcon& icon, const QString& text, XQCommand::CmdType commandType, bool enabled) void XQContextMenu::addAction(const QIcon& icon, const QString& text, XQCommand::CmdType commandType, bool enabled)
{ {
QAction* newAction = new QAction(icon, text, this); QAction* newAction = new QAction(icon, text, this);
@@ -61,6 +69,8 @@ void XQContextMenu::addAction(const QIcon& icon, const QString& text, XQCommand:
} }
//! firz
void XQContextMenu::setActionEnabled(XQCommand::CmdType commandType, bool enabled) void XQContextMenu::setActionEnabled(XQCommand::CmdType commandType, bool enabled)
{ {
if( _actionMap.contains(commandType) ) if( _actionMap.contains(commandType) )

View File

@@ -20,6 +20,8 @@
#define DB_TIMESTAMP QTime::currentTime().toString(" -- HH:mm:ss.zzz") #define DB_TIMESTAMP QTime::currentTime().toString(" -- HH:mm:ss.zzz")
//! firz
XQTreeTable::XQTreeTable(QWidget* parent) XQTreeTable::XQTreeTable(QWidget* parent)
: QTreeView(parent) : QTreeView(parent)
{ {
@@ -34,10 +36,7 @@ XQTreeTable::XQTreeTable(QWidget* parent)
} }
XQTreeTable::~XQTreeTable() //! firz
{
}
XQViewModel* XQTreeTable::modelView() XQViewModel* XQTreeTable::modelView()
{ {
@@ -45,12 +44,16 @@ XQViewModel* XQTreeTable::modelView()
} }
// __fixme: necessary? // __fixme: necessary?
//! firz
XQItem& XQTreeTable::xqItemFromIndex(const QModelIndex& index ) XQItem& XQTreeTable::xqItemFromIndex(const QModelIndex& index )
{ {
return modelView()->xqItemFromIndex( index ); return modelView()->xqItemFromIndex( index );
} }
//! firz
void XQTreeTable::currentChanged(const QModelIndex& current, const QModelIndex& previous) void XQTreeTable::currentChanged(const QModelIndex& current, const QModelIndex& previous)
{ {
@@ -68,6 +71,8 @@ void XQTreeTable::currentChanged(const QModelIndex& current, const QModelIndex&
} }
//! firz
void XQTreeTable::mouseResizeHeaderEntry(int xpos) void XQTreeTable::mouseResizeHeaderEntry(int xpos)
{ {
// resize colummn: minimal vertical margin in pixels // resize colummn: minimal vertical margin in pixels
@@ -90,6 +95,9 @@ void XQTreeTable::mouseResizeHeaderEntry(int xpos)
} }
} }
//! firz
void XQTreeTable::mouseMoveEvent(QMouseEvent* event) void XQTreeTable::mouseMoveEvent(QMouseEvent* event)
{ {
// pixel Grenzwert zur Anzeige des Splitcursors // pixel Grenzwert zur Anzeige des Splitcursors
@@ -128,6 +136,9 @@ void XQTreeTable::mouseMoveEvent(QMouseEvent* event)
QTreeView::mouseMoveEvent(event); QTreeView::mouseMoveEvent(event);
} }
//! firz
void XQTreeTable::mouseDoubleClickEvent(QMouseEvent* event) void XQTreeTable::mouseDoubleClickEvent(QMouseEvent* event)
{ {
/* /*
@@ -144,6 +155,8 @@ void XQTreeTable::mouseDoubleClickEvent(QMouseEvent* event)
} }
//! firz
void XQTreeTable::mousePressEvent(QMouseEvent* event) void XQTreeTable::mousePressEvent(QMouseEvent* event)
{ {
@@ -161,6 +174,8 @@ void XQTreeTable::mousePressEvent(QMouseEvent* event)
} }
//! firz
void XQTreeTable::mouseReleaseEvent(QMouseEvent* event) void XQTreeTable::mouseReleaseEvent(QMouseEvent* event)
{ {
// reset index for resize column // reset index for resize column
@@ -170,6 +185,8 @@ void XQTreeTable::mouseReleaseEvent(QMouseEvent* event)
} }
//! firz
void XQTreeTable::wheelEvent(QWheelEvent* event) void XQTreeTable::wheelEvent(QWheelEvent* event)
{ {
// Ctrl-key down? // Ctrl-key down?

View File

@@ -30,12 +30,13 @@ class XQViewModel;
class XQTreeTable : public QTreeView class XQTreeTable : public QTreeView
{ {
Q_OBJECT Q_OBJECT
Q_DECLARE_PRIVATE(QTreeView) // wird hier lieber ncht benutzt
//Q_DECLARE_PRIVATE(QTreeView)
public: public:
XQTreeTable(QWidget* parent = nullptr ); XQTreeTable(QWidget* parent = nullptr );
virtual ~XQTreeTable(); virtual ~XQTreeTable() = default;
XQViewModel* modelView(); XQViewModel* modelView();
XQItem& xqItemFromIndex(const QModelIndex& index ); XQItem& xqItemFromIndex(const QModelIndex& index );
@@ -45,14 +46,10 @@ protected:
void currentChanged(const QModelIndex& current, const QModelIndex& previous) override; void currentChanged(const QModelIndex& current, const QModelIndex& previous) override;
void mouseMoveEvent(QMouseEvent* event) override; void mouseMoveEvent(QMouseEvent* event) override;
//! Mouse press event.used to emulate the behavior of a QHeaderView in the first line of the view
void mouseDoubleClickEvent(QMouseEvent* event) override; void mouseDoubleClickEvent(QMouseEvent* event) override;
//! Mouse release event.used to emulate the behavior of a QHeaderView in the first line of the view
void mouseReleaseEvent(QMouseEvent* event) override; void mouseReleaseEvent(QMouseEvent* event) override;
//! Mouse press event.used to emulate the behavior of a QHeaderView in the first line of the view
void mousePressEvent(QMouseEvent* event) override; void mousePressEvent(QMouseEvent* event) override;
void mouseResizeHeaderEntry(int xpos); void mouseResizeHeaderEntry(int xpos);
//! Mouse wheel event.
void wheelEvent(QWheelEvent* event) override; void wheelEvent(QWheelEvent* event) override;
//! used by the mouse events //! used by the mouse events