QGIS API Documentation 3.38.0-Grenoble (exported)
Loading...
Searching...
No Matches
qgsjsoneditwidget.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsjsoneditwidget.h
3 --------------------------------------
4 Date : 3.5.2021
5 Copyright : (C) 2021 Damiano Lombardi
6 Email : damiano at opengis dot ch
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16#ifndef QGSJSONEDITWIDGET_H
17#define QGSJSONEDITWIDGET_H
18
19#include "ui_qgsjsoneditwidget.h"
20
22#include "qgis_sip.h"
23#include "qgis_gui.h"
24
31class GUI_EXPORT QgsJsonEditWidget : public QWidget, private Ui::QgsJsonEditWidget
32{
33 Q_OBJECT
34
35 public:
36
38 enum class View : int
39 {
40 Text = 0,
41 Tree = 1
42 };
43
45 enum class FormatJson : int
46 {
47 Indented = 0,
48 Compact = 1,
49 Disabled = 2
50 };
51
56 explicit QgsJsonEditWidget( QWidget *parent SIP_TRANSFERTHIS = nullptr );
57
63 QgsCodeEditorJson *jsonEditor();
64
68 void setJsonText( const QString &jsonText );
69
73 QString jsonText() const;
74
79 void setView( View view ) const;
80
85 void setFormatJsonMode( FormatJson formatJson );
86
90 void setControlsVisible( bool visible );
91
92 private slots:
93
94 void textToolButtonClicked( bool checked );
95 void treeToolButtonClicked( bool checked );
96
97 void copyValueActionTriggered();
98 void copyKeyActionTriggered();
99
100 void codeEditorJsonTextChanged();
101 void codeEditorJsonIndicatorClicked( int line, int index, Qt::KeyboardModifiers state );
102 void codeEditorJsonDwellStart( int position, int x, int y );
103 void codeEditorJsonDwellEnd( int position, int x, int y );
104
105 private:
106
107 enum class TreeWidgetColumn : int
108 {
109 Key = 0,
110 Value = 1
111 };
112
113 const int SCINTILLA_UNDERLINE_INDICATOR_INDEX = 15;
114
115 void refreshTreeView( const QJsonDocument &jsonDocument );
116 void refreshTreeViewItem( QTreeWidgetItem *treeWidgetItemParent, const QJsonValue &jsonValue );
117 void refreshTreeViewItemValue( QTreeWidgetItem *treeWidgetItem, const QString &jsonValueString, const QColor &textColor );
118
119 QFont monospaceFont() const;
120
121 QString mJsonText;
122
123 FormatJson mFormatJsonMode = FormatJson::Indented;
124
125 QStringList mClickableLinkList;
126
127 QAction *mCopyValueAction;
128 QAction *mCopyKeyAction;
129
130 bool mEnableUrlHighlighting = true;
131};
132
133#endif // QGSJSONEDITWIDGET_H
A JSON editor based on QScintilla2.
The QgsJsonEditWidget is a widget to display JSON data in a code highlighted text or tree form.
View
View mode, text or tree.
FormatJson
Format mode in the text view.
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53