18#include <nlohmann/json.hpp>
23#include <QApplication>
27#include <QDesktopServices>
45 return QList<QAction *>();
54 : mGroupTitle( title )
65 Q_ASSERT( !child->mParent );
66 child->mParent =
this;
68 return mChildren.emplace_back( std::move( child ) ).get();
73 Q_ASSERT( child->mParent ==
this );
74 auto it = std::find_if(
mChildren.begin(),
mChildren.end(), [&](
const std::unique_ptr<QgsDevToolsModelNode> &p ) {
75 return p.get() == child;
78 return std::distance(
mChildren.begin(), it );
84 Q_ASSERT(
static_cast<std::size_t
>( index ) <
mChildren.size() );
109 for (
const std::unique_ptr<QgsDevToolsModelNode> &child :
mChildren )
113 res.insert( valueNode->key(), valueNode->value() );
134 case Qt::DisplayRole:
135 case Qt::ToolTipRole:
137 return QStringLiteral(
"%1: %2" ).arg( mKey.leftJustified( 30,
' ' ), mValue );
140 case Qt::ForegroundRole:
142 if ( mColor.isValid() )
143 return QBrush( mColor );
154 QList<QAction *> res;
156 QAction *copyAction =
new QAction( QObject::tr(
"Copy" ),
parent );
157 QObject::connect( copyAction, &QAction::triggered, copyAction, [
this] {
158 QApplication::clipboard()->setText( QStringLiteral(
"%1: %2" ).arg( mKey, mValue ) );
172 addChild( std::make_unique<QgsDevToolsModelValueNode>( key, value, color ) );