Files
xtree.ng.zwo/model/xqsimpleclipboard.cpp
2025-08-13 18:30:47 +02:00

108 lines
2.5 KiB
C++

/***************************************************************************
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.
***************************************************************************/
#include <xqsimpleclipboard.h>
#include <xqmodel.h>
/**
* @brief XQSimpleClipBoard::~XQSimpleClipBoard Destroys this object and deletes
* the XQDataNodes stored here.
*/
XQSimpleClipBoard::~XQSimpleClipBoard()
{
// we have clones here, so deletion is needed.
_nodeList.clear();
}
/**
* @brief XQSimpleClipBoard::isEmpty
* @return True for an empty node list.
*/
bool XQSimpleClipBoard::isEmpty() const
{
return _nodeList.empty();
}
/**
* @brief XQSimpleClipBoard::canPaste Test if the clipboard contents can be pasted in the
* given index position.
* @param curIdx The index position
* @return true if pasting is possible
*/
bool XQSimpleClipBoard::canPaste( const QModelIndex& curIdx ) const
{
bool pasteOk = false;
if( !isEmpty() )
{
XQItem& item = XQItem::xqItemFromIndex(curIdx);
// __fixme! header items haben keinen ZNode!
// paste is only allowed for the same component.type, which
// is coded in the tag_type
pasteOk = item.contentNode()->tag_name() == _nodeList.front()->tag_name();
}
return pasteOk;
}
/**
* @brief XQSimpleClipBoard::createContentNodeList Fill the internal list of
* XQDataNodes by cloning the nodes in the given index list. (@see dataNodeList() )
*
* @param indexList The list with QModelIndices.
*
*/
void XQSimpleClipBoard::createContentNodeList( QModelIndexList& indexList )
{
//_nodeList.createContentNodeList( indexList);
}
/*
void XQNodeList::createContentNodeList(QModelIndexList& indexList )
{
Q_ASSERT( !indexList.isEmpty() );
// clean up first
clear();
for( auto& idx : indexList )
{
XQNodePtr node = XQItem::xqItemFromIndex(idx).contentNode();
qDebug() << " -- nodelist add node: "<< node->friendly_name() << " id: " << node->_id << " use count: " << node.use_count();
push_back( node );
}
}*/
/**
* @brief XQSimpleClipBoard::dataNodeList
* @return The internal list XQDataNodes
*/
const XQNodeList& XQSimpleClipBoard::dataNodeList()
{
return _nodeList;
}