mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-15 00:02:52 -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.
|
Set the ``formatJson`` mode.
|
||||||
|
|
||||||
.. seealso:: FormatJson
|
.. seealso:: FormatJson
|
||||||
|
%End
|
||||||
|
|
||||||
|
void setControlsVisible( bool visible );
|
||||||
|
%Docstring
|
||||||
|
Set the visibility of controls to ``visible``.
|
||||||
%End
|
%End
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -87,6 +87,7 @@
|
|||||||
#include "qgsexpressioncontextutils.h"
|
#include "qgsexpressioncontextutils.h"
|
||||||
#include "qgsidentifymenu.h"
|
#include "qgsidentifymenu.h"
|
||||||
#include "qgsjsonutils.h"
|
#include "qgsjsonutils.h"
|
||||||
|
#include "qgsjsoneditwidget.h"
|
||||||
#include "qgspointcloudlayer.h"
|
#include "qgspointcloudlayer.h"
|
||||||
|
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
@ -697,7 +698,7 @@ QgsIdentifyResultsFeatureItem *QgsIdentifyResultsDialog::createFeatureItem( QgsV
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
const QgsEditorWidgetSetup setup = QgsGui::editorWidgetRegistry()->findBest( vlayer, fields[i].name() );
|
const QgsEditorWidgetSetup setup = QgsGui::editorWidgetRegistry()->findBest( vlayer, fields[i].name() );
|
||||||
if ( setup.type() == QLatin1String( "Hidden" ) )
|
if ( setup.type() == QStringLiteral( "Hidden" ) )
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -720,21 +721,36 @@ QgsIdentifyResultsFeatureItem *QgsIdentifyResultsDialog::createFeatureItem( QgsV
|
|||||||
value = representValue( vlayer, setup, fields.at( i ).name(), attrs.at( i ) );
|
value = representValue( vlayer, setup, fields.at( i ).name(), attrs.at( i ) );
|
||||||
attrItem->setSortData( 1, value );
|
attrItem->setSortData( 1, value );
|
||||||
attrItem->setToolTip( 1, value );
|
attrItem->setToolTip( 1, value );
|
||||||
bool foundLinks = false;
|
|
||||||
QString links = QgsStringUtils::insertLinks( value, &foundLinks );
|
if ( setup.type() == QStringLiteral( "JsonEdit" ) )
|
||||||
if ( foundLinks )
|
|
||||||
{
|
{
|
||||||
QLabel *valueLabel = new QLabel( links );
|
QgsJsonEditWidget *jsonEditWidget = new QgsJsonEditWidget();
|
||||||
valueLabel->setOpenExternalLinks( true );
|
jsonEditWidget->setJsonText( value );
|
||||||
|
jsonEditWidget->setView( QgsJsonEditWidget::View::Tree );
|
||||||
|
jsonEditWidget->setFormatJsonMode( QgsJsonEditWidget::FormatJson::Indented );
|
||||||
|
jsonEditWidget->setControlsVisible( false );
|
||||||
attrItem->setData( 1, Qt::DisplayRole, QString() );
|
attrItem->setData( 1, Qt::DisplayRole, QString() );
|
||||||
QTreeWidget *tw = attrItem->treeWidget();
|
QTreeWidget *treeWidget = attrItem->treeWidget();
|
||||||
tw->setItemWidget( attrItem, 1, valueLabel );
|
treeWidget->setItemWidget( attrItem, 1, jsonEditWidget );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
attrItem->setData( 1, Qt::DisplayRole, value );
|
bool foundLinks = false;
|
||||||
QTreeWidget *tw = attrItem->treeWidget();
|
QString links = QgsStringUtils::insertLinks( value, &foundLinks );
|
||||||
tw->setItemWidget( attrItem, 1, nullptr );
|
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() )
|
if ( fields.at( i ).name() == vlayer->displayField() )
|
||||||
|
@ -112,6 +112,11 @@ void QgsJsonEditWidget::setFormatJsonMode( QgsJsonEditWidget::FormatJson formatJ
|
|||||||
mFormatJsonMode = formatJson;
|
mFormatJsonMode = formatJson;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QgsJsonEditWidget::setControlsVisible( bool visible )
|
||||||
|
{
|
||||||
|
mControlsWidget->setVisible( visible );
|
||||||
|
}
|
||||||
|
|
||||||
void QgsJsonEditWidget::textToolButtonClicked( bool checked )
|
void QgsJsonEditWidget::textToolButtonClicked( bool checked )
|
||||||
{
|
{
|
||||||
if ( checked )
|
if ( checked )
|
||||||
|
@ -77,6 +77,11 @@ class GUI_EXPORT QgsJsonEditWidget : public QWidget, private Ui::QgsJsonEditWidg
|
|||||||
*/
|
*/
|
||||||
void setFormatJsonMode( FormatJson formatJson );
|
void setFormatJsonMode( FormatJson formatJson );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Set the visibility of controls to \a visible.
|
||||||
|
*/
|
||||||
|
void setControlsVisible( bool visible );
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void textToolButtonClicked( bool checked );
|
void textToolButtonClicked( bool checked );
|
||||||
|
@ -14,6 +14,71 @@
|
|||||||
<string notr="true">Form</string>
|
<string notr="true">Form</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<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">
|
<item row="1" column="0">
|
||||||
<widget class="QStackedWidget" name="mStackedWidget">
|
<widget class="QStackedWidget" name="mStackedWidget">
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
@ -49,57 +114,6 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</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>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user