Skip to content

Commit

Permalink
Merge pull request #1552 from lutraconsulting/1533-bugfixing
Browse files Browse the repository at this point in the history
Bugfixing #1355
  • Loading branch information
tomasMizera authored Jul 21, 2021
2 parents c8c8e23 + 8773a19 commit 5799427
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 16 deletions.
16 changes: 16 additions & 0 deletions app/layersproxymodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,22 @@ QgsVectorLayer *LayersProxyModel::layerFromLayerId( QString layerId ) const
return nullptr;
}

QgsVectorLayer *LayersProxyModel::layerFromLayerName( const QString &layerName ) const
{
QList<QgsMapLayer *> filteredLayers = layers();

for ( int i = 0; i < filteredLayers.count(); i++ )
{
if ( filteredLayers.at( i )->name() == layerName )
{
QgsVectorLayer *layer = qobject_cast<QgsVectorLayer *>( filteredLayers.at( i ) );
if ( layer )
return layer;
}
}
return nullptr;
}

QVariant LayersProxyModel::getData( QModelIndex index, int role ) const
{
return sourceModel()->data( index, role );
Expand Down
2 changes: 2 additions & 0 deletions app/layersproxymodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ class LayersProxyModel : public QgsMapLayerProxyModel
Q_INVOKABLE QModelIndex indexFromLayerId( QString layerId ) const;
Q_INVOKABLE QgsVectorLayer *layerFromLayerId( QString layerId ) const;

QgsVectorLayer *layerFromLayerName( const QString &layerName ) const;

//! Helper method to get data from source model to skip converting indexes
Q_INVOKABLE QVariant getData( QModelIndex index, int role ) const;

Expand Down
19 changes: 13 additions & 6 deletions app/loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,17 @@

const QString Loader::LOADING_FLAG_FILE_PATH = QString( "%1/.input_loading_project" ).arg( QStandardPaths::standardLocations( QStandardPaths::TempLocation ).first() );

Loader::Loader(
MapThemesModel &mapThemeModel
, AppSettings &appSettings
, ActiveLayer &activeLayer
, QObject *parent ) :
Loader::Loader( MapThemesModel &mapThemeModel
, AppSettings &appSettings
, ActiveLayer &activeLayer
, LayersProxyModel &recordingLayerPM
, QObject *parent ) :

QObject( parent )
, mMapThemeModel( mapThemeModel )
, mAppSettings( appSettings )
, mActiveLayer( activeLayer )
, mRecordingLayerPM( recordingLayerPM )
{
// we used to have our own QgsProject instance, but unfortunately few pieces of qgis_core
// still work with QgsProject::instance() singleton hardcoded (e.g. vector layer's feature
Expand Down Expand Up @@ -107,7 +108,13 @@ bool Loader::forceLoad( const QString &filePath, bool force )
res = mProject->read( filePath );
mActiveLayer.resetActiveLayer();
mMapThemeModel.reloadMapThemes( mProject );
setActiveLayerByName( mAppSettings.defaultLayer() );

QgsVectorLayer *defaultLayer = mRecordingLayerPM.layerFromLayerName( mAppSettings.defaultLayer() );
if ( defaultLayer )
setActiveLayer( defaultLayer );
else
setActiveLayer( mRecordingLayerPM.firstUsableLayer() );

setMapSettingsLayers();

emit projectReloaded( mProject );
Expand Down
4 changes: 3 additions & 1 deletion app/loader.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class Loader: public QObject
MapThemesModel &mapThemeModel
, AppSettings &appSettings
, ActiveLayer &activeLayer
, LayersProxyModel &recordingLayerPM
, QObject *parent = nullptr );

QgsProject *project();
Expand Down Expand Up @@ -70,7 +71,7 @@ class Loader: public QObject
/**
* setActiveLayer sets active layer from layer
*/
Q_INVOKABLE void setActiveLayer( QgsMapLayer *layerName ) const;
Q_INVOKABLE void setActiveLayer( QgsMapLayer *layer ) const;

//! A File on this path represents a project is loading and exists only during the process.
static const QString LOADING_FLAG_FILE_PATH;
Expand Down Expand Up @@ -126,6 +127,7 @@ class Loader: public QObject
MapThemesModel &mMapThemeModel;
AppSettings &mAppSettings;
ActiveLayer &mActiveLayer;
LayersProxyModel &mRecordingLayerPM;
QgsQuickMapSettings *mMapSettings = nullptr;

/**
Expand Down
2 changes: 1 addition & 1 deletion app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ int main( int argc, char *argv[] )
LayersProxyModel recordingLpm( &lm, LayerModelTypes::ActiveLayerSelection );

ActiveLayer al;
Loader loader( mtm, as, al );
Loader loader( mtm, as, al, recordingLpm );
std::unique_ptr<Purchasing> purchasing( new Purchasing( ma.get() ) );
std::unique_ptr<VariablesManager> vm( new VariablesManager( ma.get() ) );
vm->registerInputExpressionFunctions();
Expand Down
1 change: 0 additions & 1 deletion app/mapthemesmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ class MapThemesModel : public QAbstractListModel
signals:
void mapThemesReloaded();
void mapThemeChanged( const QString &name );
void reloadLayers();
void activeThemeIndexChanged();

private:
Expand Down
23 changes: 16 additions & 7 deletions app/qml/editor/inputtextedit.qml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Item {
signal importDataRequested()
property var rowHeight: customStyle.fields.height * 0.75
property real iconSize: rowHeight
property bool submitOnEditingFinished: field.isNumeric

id: fieldItem
enabled: !readOnly
Expand Down Expand Up @@ -75,7 +76,15 @@ Item {
}

onEditingFinished: {
valueChanged( text, text === undefined )
if (fieldItem.submitOnEditingFinished) {
valueChanged( text, text === undefined )
}
}

onTextChanged: {
if (!fieldItem.submitOnEditingFinished) {
valueChanged( text, text === undefined )
}
}

//! Commit value if has changed when widget gets out of the FeatureForm (ListView) viewport
Expand Down Expand Up @@ -112,19 +121,19 @@ Item {
}

onEditingFinished: {
if (fieldItem.submitOnEditingFinished) {
valueChanged( text, text === undefined )
}
}

//! Commit value if has changed when widget gets out of the FeatureForm (ListView) viewport
Component.onDestruction: {
if ( textArea.activeFocus ) {
if ( value !== textArea.text ) {
valueChanged( textArea.text, textArea.text === undefined )
}
onTextChanged: {
if (!fieldItem.submitOnEditingFinished) {
valueChanged( text, text === undefined )
}
}

}

// Icon
Item {
id: importDataBtn
Expand Down

9 comments on commit 5799427

@inputapp-bot
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

signed apk: arm64-v8a (SDK: android-22)

@inputapp-bot
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

signed apk: armeabi-v7a (SDK: android-22)

@inputapp-bot
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ios-2.15.210721085704 (SDK: ios-15)

@inputapp-bot
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

signed apk: arm64-v8a (SDK: android-22)

@inputapp-bot
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

signed apk: armeabi-v7a (SDK: android-22)

@inputapp-bot
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ios-1.15.210721103939 (SDK: ios-15)

@inputapp-bot
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

signed apk: armeabi-v7a (SDK: android-22)

@inputapp-bot
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

signed apk: arm64-v8a (SDK: android-22)

@inputapp-bot
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ios-1.15.210721124118 (SDK: ios-15)

Please sign in to comment.