Files
xtree.old.ng/model/xqsimpleclipboard.cpp

50 lines
1.5 KiB
C++
Raw Normal View History

2025-08-05 22:39:41 +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.
***************************************************************************/
#include <xqsimpleclipboard.h>
#include <xqmodel.h>
bool XQSimpleClipBoard::canPaste( const QModelIndex& curIdx ) const
{
bool pasteOk = false;
if( !isEmpty() )
{
XQItem& item = XQItem::xqItemFromIndex(curIdx);
// __fixme! header items haben keinen ZNode!
qDebug() << " --- can paste: " << item.contentNode()->tag_name() << " nodelist: " << front().contentNode->tag_name();
// paste is only allowed for the same component.type, which
// is coded in the tag_type
pasteOk = item.contentNode()->tag_name() == front().contentNode->tag_name();
}
else
{
qDebug() << " -- ClipBoard: nodelist empty!";
}
return pasteOk;
}
void XQSimpleClipBoard::saveNodes( const QModelIndexList& list )
{
clear();
for( auto entry : list )
{
XQNodePtr contentNode = XQItem::xqItemFromIndex( entry ).contentNode();
// im clipboard brauchen wir eine eltern-lose kopie des knotens
push_back( {entry.row(), contentNode->own_pos(), contentNode->clone() } );
}
}