mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-07 00:15:48 -04:00
IdentiyResults dialog show JSON data as a tree view
This commit is contained in:
parent
a57a8dcbb6
commit
a570a10bd9
@ -64,6 +64,11 @@ Set the ``view`` mode.
|
||||
Set the ``formatJson`` mode.
|
||||
|
||||
.. seealso:: FormatJson
|
||||
%End
|
||||
|
||||
void setControlsVisible( bool visible );
|
||||
%Docstring
|
||||
Set the visibility of controls to ``visible``.
|
||||
%End
|
||||
|
||||
};
|
||||
|
@ -87,6 +87,7 @@
|
||||
#include "qgsexpressioncontextutils.h"
|
||||
#include "qgsidentifymenu.h"
|
||||
#include "qgsjsonutils.h"
|
||||
#include "qgsjsoneditwidget.h"
|
||||
#include "qgspointcloudlayer.h"
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
@ -697,7 +698,7 @@ QgsIdentifyResultsFeatureItem *QgsIdentifyResultsDialog::createFeatureItem( QgsV
|
||||
break;
|
||||
|
||||
const QgsEditorWidgetSetup setup = QgsGui::editorWidgetRegistry()->findBest( vlayer, fields[i].name() );
|
||||
if ( setup.type() == QLatin1String( "Hidden" ) )
|
||||
if ( setup.type() == QStringLiteral( "Hidden" ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -720,21 +721,36 @@ QgsIdentifyResultsFeatureItem *QgsIdentifyResultsDialog::createFeatureItem( QgsV
|
||||
value = representValue( vlayer, setup, fields.at( i ).name(), attrs.at( i ) );
|
||||
attrItem->setSortData( 1, value );
|
||||
attrItem->setToolTip( 1, value );
|
||||
bool foundLinks = false;
|
||||
QString links = QgsStringUtils::insertLinks( value, &foundLinks );
|
||||
if ( foundLinks )
|
||||
|
||||
if ( setup.type() == QStringLiteral( "JsonEdit" ) )
|
||||
{
|
||||
QLabel *valueLabel = new QLabel( links );
|
||||
valueLabel->setOpenExternalLinks( true );
|
||||
QgsJsonEditWidget *jsonEditWidget = new QgsJsonEditWidget();
|
||||
jsonEditWidget->setJsonText( value );
|
||||
jsonEditWidget->setView( QgsJsonEditWidget::View::Tree );
|
||||
jsonEditWidget->setFormatJsonMode( QgsJsonEditWidget::FormatJson::Indented );
|
||||
jsonEditWidget->setControlsVisible( false );
|
||||
attrItem->setData( 1, Qt::DisplayRole, QString() );
|
||||
QTreeWidget *tw = attrItem->treeWidget();
|
||||
tw->setItemWidget( attrItem, 1, valueLabel );
|
||||
QTreeWidget *treeWidget = attrItem->treeWidget();
|
||||
treeWidget->setItemWidget( attrItem, 1, jsonEditWidget );
|
||||
}
|
||||
else
|
||||
{
|
||||
attrItem->setData( 1, Qt::DisplayRole, value );
|
||||
QTreeWidget *tw = attrItem->treeWidget();
|
||||
tw->setItemWidget( attrItem, 1, nullptr );
|
||||
bool foundLinks = false;
|
||||
QString links = QgsStringUtils::insertLinks( value, &foundLinks );
|
||||
if ( foundLinks )
|
||||
{
|
||||
QLabel *valueLabel = new QLabel( links );
|
||||
valueLabel->setOpenExternalLinks( true );
|
||||
attrItem->setData( 1, Qt::DisplayRole, QString() );
|
||||
QTreeWidget *tw = attrItem->treeWidget();
|
||||
tw->setItemWidget( attrItem, 1, valueLabel );
|
||||
}
|
||||
else
|
||||
{
|
||||
attrItem->setData( 1, Qt::DisplayRole, value );
|
||||
QTreeWidget *tw = attrItem->treeWidget();
|
||||
tw->setItemWidget( attrItem, 1, nullptr );
|
||||
}
|
||||
}
|
||||
|
||||
if ( fields.at( i ).name() == vlayer->displayField() )
|
||||
|
@ -112,6 +112,11 @@ void QgsJsonEditWidget::setFormatJsonMode( QgsJsonEditWidget::FormatJson formatJ
|
||||
mFormatJsonMode = formatJson;
|
||||
}
|
||||
|
||||
void QgsJsonEditWidget::setControlsVisible( bool visible )
|
||||
{
|
||||
mControlsWidget->setVisible( visible );
|
||||
}
|
||||
|
||||
void QgsJsonEditWidget::textToolButtonClicked( bool checked )
|
||||
{
|
||||
if ( checked )
|
||||
|
@ -77,6 +77,11 @@ class GUI_EXPORT QgsJsonEditWidget : public QWidget, private Ui::QgsJsonEditWidg
|
||||
*/
|
||||
void setFormatJsonMode( FormatJson formatJson );
|
||||
|
||||
/**
|
||||
* \brief Set the visibility of controls to \a visible.
|
||||
*/
|
||||
void setControlsVisible( bool visible );
|
||||
|
||||
private slots:
|
||||
|
||||
void textToolButtonClicked( bool checked );
|
||||
|
@ -14,6 +14,71 @@
|
||||
<string notr="true">Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QWidget" name="mControlsWidget" native="true">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="mTextToolButton">
|
||||
<property name="toolTip">
|
||||
<string>Show text</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../images/images.qrc">
|
||||
<normaloff>:/images/themes/default/mIconFieldText.svg</normaloff>:/images/themes/default/mIconFieldText.svg</iconset>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="mTreeToolButton">
|
||||
<property name="toolTip">
|
||||
<string>Show tree</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../images/images.qrc">
|
||||
<normaloff>:/images/themes/default/mIconTreeView.svg</normaloff>:/images/themes/default/mIconTreeView.svg</iconset>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QStackedWidget" name="mStackedWidget">
|
||||
<property name="currentIndex">
|
||||
@ -49,57 +114,6 @@
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="mTextToolButton">
|
||||
<property name="toolTip">
|
||||
<string>Show text</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../images/images.qrc">
|
||||
<normaloff>:/images/themes/default/mIconFieldText.svg</normaloff>:/images/themes/default/mIconFieldText.svg</iconset>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="mTreeToolButton">
|
||||
<property name="toolTip">
|
||||
<string>Show tree</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../images/images.qrc">
|
||||
<normaloff>:/images/themes/default/mIconTreeView.svg</normaloff>:/images/themes/default/mIconTreeView.svg</iconset>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
|
Loading…
x
Reference in New Issue
Block a user