18#include <nlohmann/json.hpp>
23#include <QApplication>
27#include <QDesktopServices>
32using namespace Qt::StringLiterals;
48 return QList<QAction *>();
57 : mGroupTitle( title )
68 Q_ASSERT( !child->mParent );
69 child->mParent =
this;
71 return mChildren.emplace_back( std::move( child ) ).get();
76 Q_ASSERT( child->mParent ==
this );
77 auto it = std::find_if(
mChildren.begin(),
mChildren.end(), [&](
const std::unique_ptr<QgsDevToolsModelNode> &p ) {
78 return p.get() == child;
81 return std::distance(
mChildren.begin(), it );
87 Q_ASSERT(
static_cast<std::size_t
>( index ) <
mChildren.size() );
100 case Qt::DisplayRole:
112 for (
const std::unique_ptr<QgsDevToolsModelNode> &child :
mChildren )
116 res.insert( valueNode->key(), valueNode->value() );
137 case Qt::DisplayRole:
138 case Qt::ToolTipRole:
140 return u
"%1: %2"_s.arg( mKey.leftJustified( 30,
' ' ), mValue );
143 case Qt::ForegroundRole:
145 if ( mColor.isValid() )
146 return QBrush( mColor );
157 QList<QAction *> res;
159 QAction *copyAction =
new QAction( QObject::tr(
"Copy" ),
parent );
160 QObject::connect( copyAction, &QAction::triggered, copyAction, [
this] {
161 QApplication::clipboard()->setText( u
"%1: %2"_s.arg( mKey, mValue ) );
175 addChild( std::make_unique<QgsDevToolsModelValueNode>( key, value, color ) );