Skip to content

Commit ae3176f

Browse files
committedSep 5, 2018
docstrings and beautification
1 parent 4ad7067 commit ae3176f

File tree

6 files changed

+47
-85
lines changed

6 files changed

+47
-85
lines changed
 

‎python/gui/auto_generated/editorwidgets/qgsqmlwidgetwrapper.sip.in

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ the Free Software Foundation; either version 2 of the License, or *
3131
#include "qgsqmlwidgetwrapper.h"
3232
%End
3333
public:
34+
3435
QgsQmlWidgetWrapper( QgsVectorLayer *layer, QWidget *editor, QWidget *parent );
3536

3637
virtual bool valid() const;
@@ -43,13 +44,22 @@ the Free Software Foundation; either version 2 of the License, or *
4344

4445

4546
void reinitWidget();
47+
%Docstring
48+
Clears the content and makes new intialisaton
49+
%End
4650

4751
void setQmlCode( const QString &qmlCode );
52+
%Docstring
53+
writes the ``qmlCode`` into a temporary file
54+
%End
4855

4956
public slots:
5057

5158
virtual void setFeature( const QgsFeature &feature );
5259

60+
%Docstring
61+
passes the ``feature`` into the context property of the widget
62+
%End
5363

5464
};
5565

@@ -64,6 +74,9 @@ class QmlExpression : QObject
6474
void setExpressionContext( const QgsExpressionContext &context );
6575

6676
QVariant evaluate( const QString &expression ) const;
77+
%Docstring
78+
evaluates the value regarding the /a expression and the context
79+
%End
6780

6881
};
6982

‎src/app/qgsattributesformproperties.cpp

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,8 @@ void QgsAttributesFormProperties::onAttributeSelectionChanged()
507507
}
508508
case DnDTreeItemData::QmlWidget:
509509
{
510-
510+
mAttributeRelationEdit->setVisible( false );
511+
mAttributeTypeDialog->setVisible( false );
511512
break;
512513
}
513514

@@ -854,7 +855,7 @@ QTreeWidgetItem *DnDTree::addItem( QTreeWidgetItem *parent, QgsAttributesFormPro
854855
break;
855856

856857
case QgsAttributesFormProperties::DnDTreeItemData::QmlWidget:
857-
newItem->setIcon( 0, QgsApplication::getThemeIcon( "/mQmlWidgetIcon.svg" ) );
858+
//no icon for QmlWidget
858859
break;
859860
}
860861
}
@@ -1124,24 +1125,23 @@ void DnDTree::onItemDoubleClicked( QTreeWidgetItem *item, int column )
11241125

11251126
QgsQmlWidgetWrapper *qmlWrapper = new QgsQmlWidgetWrapper( mLayer, nullptr, this );
11261127
qmlWrapper->setQmlCode( qmlCode->toPlainText() );
1128+
//update preview on text change
11271129
QgsFeature previewFeature;
11281130
mLayer->getFeatures().nextFeature( previewFeature );
11291131
qmlWrapper->setFeature( previewFeature );
1130-
//update preview on text change
11311132
connect( qmlCode, &QPlainTextEdit::textChanged, this, [ = ]
11321133
{
11331134
qmlWrapper->setQmlCode( qmlCode->toPlainText() );
11341135
qmlWrapper->reinitWidget();
1135-
QgsFeature previewFeature;
1136-
mLayer->getFeatures().nextFeature( previewFeature );
11371136
qmlWrapper->setFeature( previewFeature );
11381137
} );
11391138

11401139
//templates
11411140
QComboBox *qmlObjectTemplate = new QComboBox();
11421141
qmlObjectTemplate->addItem( tr( "Free text..." ) );
11431142
qmlObjectTemplate->addItem( tr( "Rectangle" ) );
1144-
qmlObjectTemplate->addItem( tr( "Pie Chart" ) );
1143+
qmlObjectTemplate->addItem( tr( "Pie chart" ) );
1144+
qmlObjectTemplate->addItem( tr( "Bar chart" ) );
11451145
connect( qmlObjectTemplate, QOverload<int>::of( &QComboBox::currentIndexChanged ), qmlCode, [ = ]( int index )
11461146
{
11471147
qmlCode->clear();
@@ -1182,6 +1182,27 @@ void DnDTree::onItemDoubleClicked( QTreeWidgetItem *item, int column )
11821182
"}\n" ) );
11831183
break;
11841184
}
1185+
case 3:
1186+
{
1187+
qmlCode->insertPlainText( QStringLiteral( "import QtQuick 2.0\n"
1188+
"import QtCharts 2.0\n"
1189+
"\n"
1190+
"ChartView {\n"
1191+
"title: \"Bar series\"\n"
1192+
"width: 600\n"
1193+
"height:400\n"
1194+
"legend.alignment: Qt.AlignBottom\n"
1195+
"antialiasing: true\n"
1196+
"\n"
1197+
"BarSeries {\n"
1198+
"id: mySeries\n"
1199+
"axisX: BarCategoryAxis { categories: [\"2007\", \"2008\", \"2009\", \"2010\", \"2011\", \"2012\" ] }\n"
1200+
"BarSet { label: \"Bob\"; values: [2, 2, 3, 4, 5, 6] }\n"
1201+
"BarSet { label: \"Susan\"; values: [5, 1, 2, 4, 1, 7] }\n"
1202+
"BarSet { label: \"James\"; values: [3, 5, 8, 13, 5, 8] }\n"
1203+
"}\n" ) );
1204+
break;
1205+
}
11851206
default:
11861207
break;
11871208
}

‎src/app/qgsqmlwidgetconfig.ui

Lines changed: 0 additions & 71 deletions
This file was deleted.

‎src/core/qgsfeature.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ class CORE_EXPORT QgsFeature
443443
* \see setFields
444444
*/
445445
#ifndef SIP_RUN
446-
Q_INVOKABLE QVariant attribute( const QString &name ) const;
446+
QVariant attribute( const QString &name ) const;
447447
#else
448448
SIP_PYOBJECT attribute( const QString &name ) const;
449449
% MethodCode

‎src/gui/editorwidgets/qgsqmlwidgetwrapper.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class GUI_EXPORT QgsQmlWidgetWrapper : public QgsWidgetWrapper
2626
Q_OBJECT
2727

2828
public:
29+
2930
QgsQmlWidgetWrapper( QgsVectorLayer *layer, QWidget *editor, QWidget *parent );
3031

3132
bool valid() const override;
@@ -34,17 +35,19 @@ class GUI_EXPORT QgsQmlWidgetWrapper : public QgsWidgetWrapper
3435

3536
void initWidget( QWidget *editor ) override;
3637

38+
//! Clears the content and makes new intialisaton
3739
void reinitWidget();
3840

41+
//! writes the \a qmlCode into a temporary file
3942
void setQmlCode( const QString &qmlCode );
4043

4144
public slots:
4245

46+
//! passes the \a feature into the context property of the widget
4347
void setFeature( const QgsFeature &feature ) override;
4448

4549
private:
4650
QTemporaryFile mQmlFile;
47-
4851
QQuickWidget *mWidget = nullptr;
4952
};
5053

@@ -56,6 +59,7 @@ class GUI_EXPORT QmlExpression : public QObject
5659
public:
5760
void setExpressionContext( const QgsExpressionContext &context );
5861

62+
//! evaluates the value regarding the /a expression and the context
5963
Q_INVOKABLE QVariant evaluate( const QString &expression ) const;
6064

6165
private:

‎src/gui/qgsattributeform.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1775,16 +1775,11 @@ QgsAttributeForm::WidgetInfo QgsAttributeForm::createWidgetFromDef( const QgsAtt
17751775
const QgsAttributeEditorQmlElement *elementDef = static_cast<const QgsAttributeEditorQmlElement *>( widgetDef );
17761776

17771777
QgsQmlWidgetWrapper *qmlWrapper = new QgsQmlWidgetWrapper( mLayer, nullptr, this );
1778-
17791778
qmlWrapper->setQmlCode( elementDef->qmlCode() );
1780-
1781-
//qmlWrapper->setConfig( mLayer->editFormConfig().widgetConfig( elementDef->name()) );
1779+
qmlWrapper->setConfig( mLayer->editFormConfig().widgetConfig( elementDef->name() ) );
17821780
qmlWrapper->setContext( context );
17831781

1784-
// QgsAttributeFormRelationEditorWidget *formWidget = new QgsAttributeFormRelationEditorWidget( rww, this );
1785-
17861782
mWidgets.append( qmlWrapper );
1787-
// mFormWidgets.append( formWidget );
17881783

17891784
newWidgetInfo.widget = qmlWrapper->widget();
17901785
newWidgetInfo.labelText = elementDef->name();

0 commit comments

Comments
 (0)
Please sign in to comment.