18#include <nlohmann/json.hpp>
23#include <QApplication>
27#include <QDesktopServices>
32using namespace Qt::StringLiterals;
48 return QList<QAction *>();
57 : mGroupTitle( title )
67 Q_ASSERT( !child->mParent );
68 child->mParent =
this;
70 return mChildren.emplace_back( std::move( child ) ).get();
75 Q_ASSERT( child->mParent ==
this );
76 auto it = std::find_if(
mChildren.begin(),
mChildren.end(), [&](
const std::unique_ptr<QgsDevToolsModelNode> &p ) { 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() );
133 case Qt::DisplayRole:
134 case Qt::ToolTipRole:
136 return u
"%1: %2"_s.arg( mKey.leftJustified( 30,
' ' ), mValue );
139 case Qt::ForegroundRole:
141 if ( mColor.isValid() )
142 return QBrush( mColor );
153 QList<QAction *> res;
155 QAction *copyAction =
new QAction( QObject::tr(
"Copy" ),
parent );
156 QObject::connect( copyAction, &QAction::triggered, copyAction, [
this] { QApplication::clipboard()->setText( u
"%1: %2"_s.arg( mKey, mValue ) ); } );
169 addChild( std::make_unique<QgsDevToolsModelValueNode>( key, value, color ) );