Skip to content

Commit

Permalink
fix of various runtime/compilation warnings from qml
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterPetrik authored and nyalldawson committed Nov 25, 2020
1 parent 0da839f commit e6c8a14
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 10 deletions.
14 changes: 9 additions & 5 deletions src/quickgui/plugin/editor/qgsquickvaluemap.qml
Expand Up @@ -48,24 +48,27 @@ Item {
}

Component.onCompleted: {
var currentMap;
var currentKey;

if( config['map'] )
{
if( config['map'].length )
{
//it's a list (>=QGIS3.0)
for(var i=0; i<config['map'].length; i++)
{
var currentMap = config['map'][i]
var currentKey = Object.keys(currentMap)[0]
currentMap = config['map'][i]
currentKey = Object.keys(currentMap)[0]
listModel.append( { display: currentKey } )
reverseConfig[currentMap[currentKey]] = currentKey;
}
}
else
{
//it's a map (<=QGIS2.18)
var currentMap = config['map'].length ? config['map'][currentIndex] : config['map']
var currentKey = Object.keys(currentMap)[0]
currentMap = config['map'].length ? config['map'][currentIndex] : config['map']
currentKey = Object.keys(currentMap)[0]
for(var key in config['map']) {
listModel.append( { display: key } )
reverseConfig[config['map'][key]] = key;
Expand All @@ -77,7 +80,8 @@ Item {

onCurrentTextChanged: {
var currentMap = config['map'].length ? config['map'][currentIndex] : config['map']
valueChanged(currentMap[currentText], false)
if (currentMap)
valueChanged(currentMap[currentText], false)
}

// Workaround to get a signal when the value has changed
Expand Down
1 change: 1 addition & 0 deletions src/quickgui/plugin/editor/qgsquickvaluerelation.qml
Expand Up @@ -189,6 +189,7 @@ Item {
width: 15
anchors.right: parent.right
anchors.rightMargin: 10
anchors.verticalCenter: parent.verticalCenter
height: 30
smooth: true
visible: false
Expand Down
12 changes: 7 additions & 5 deletions src/quickgui/plugin/qgsquickfeatureform.qml
Expand Up @@ -262,12 +262,14 @@ Item {
rightPadding: 8 * QgsQuick.Utils.dp
anchors.bottom: parent.bottom

width: contentItem.width + leftPadding + rightPadding
width: leftPadding + rightPadding
height: form.style.tabs.buttonHeight

contentItem: Text {
// Make sure the width is derived from the text so we can get wider
// than the parent item and the Flickable is useful
Component.onCompleted: tabButton.width = tabButton.width + paintedWidth

width: paintedWidth
text: tabButton.text
color: !tabButton.enabled ? form.style.tabs.disabledColor : tabButton.down ||
Expand Down Expand Up @@ -360,7 +362,7 @@ Item {
model: QgsQuick.SubModel {
id: contentModel
model: form.model
rootIndex: form.model.hasTabs ? form.model.index(currentIndex, 0) : undefined
rootIndex: form.model.hasTabs ? form.model.index(currentIndex, 0) : QgsQuick.Utils.invalidIndex()
}

delegate: fieldItem
Expand Down Expand Up @@ -442,7 +444,7 @@ Item {
active: widget !== 'Hidden'

source: {
if ( widget )
if ( widget !== undefined )
return form.loadWidgetFn(widget.toLowerCase())
else return ''
}
Expand Down Expand Up @@ -479,7 +481,7 @@ Item {
target: form
ignoreUnknownSignals: true
onCanceled: {
if (typeof attributeEditorLoader.item.callbackOnCancel === "function") {
if (attributeEditorLoader.item && typeof attributeEditorLoader.item.callbackOnCancel === "function") {
attributeEditorLoader.item.callbackOnCancel()
}
}
Expand Down Expand Up @@ -595,7 +597,7 @@ Item {

ToolButton {
id: closeButton
anchors.right: parent.right
Layout.alignment: Qt.AlignRight

Layout.preferredWidth: form.style.toolbutton.size
Layout.preferredHeight: form.style.toolbutton.size
Expand Down
5 changes: 5 additions & 0 deletions src/quickgui/qgsquickutils.cpp
Expand Up @@ -409,6 +409,11 @@ QString QgsQuickUtils::dateTimeFieldFormat( const QString &fieldFormat )
}
}

QModelIndex QgsQuickUtils::invalidIndex()
{
return QModelIndex();
}

qreal QgsQuickUtils::screenDensity() const
{
return mScreenDensity;
Expand Down
5 changes: 5 additions & 0 deletions src/quickgui/qgsquickutils.h
Expand Up @@ -279,6 +279,11 @@ class QUICK_EXPORT QgsQuickUtils: public QObject
*/
Q_INVOKABLE static QString dateTimeFieldFormat( const QString &fieldFormat );

/**
* \brief invalidIndex returns invalid index
*/
Q_INVOKABLE static QModelIndex invalidIndex();

private:
static void formatToMetricDistance( double srcDistance,
QgsUnitTypes::DistanceUnit srcUnits,
Expand Down

0 comments on commit e6c8a14

Please sign in to comment.