Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
small const tweak
  • Loading branch information
PeterPetrik committed Jul 13, 2018
1 parent be90339 commit 660ce87
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/quickgui/attributes/qgsquickattributeformmodel.h
Expand Up @@ -55,7 +55,7 @@ class QUICK_EXPORT QgsQuickAttributeFormModel : public QSortFilterProxyModel
public:

//! Feature fields's roles
enum FeatureRoles
enum FeatureFieldRoles
{
ElementType = Qt::UserRole + 1, //!< User role used to identify either "field" or "container" type of item
Name, //!< Field Name
Expand All @@ -73,7 +73,7 @@ class QUICK_EXPORT QgsQuickAttributeFormModel : public QSortFilterProxyModel
ConstraintDescription //!< Contraint description
};

Q_ENUM( FeatureRoles )
Q_ENUM( FeatureFieldRoles )

//! Create new attribute form model
QgsQuickAttributeFormModel( QObject *parent = nullptr );
Expand Down
4 changes: 4 additions & 0 deletions src/quickgui/attributes/qgsquickattributemodel.cpp
Expand Up @@ -170,6 +170,9 @@ bool QgsQuickAttributeModel::save()
QgsMessageLog::logMessage( tr( "Cannot update feature" ),
QStringLiteral( "QgsQuick" ),
Qgis::Warning );

// This calls lower-level I/O functions which shouldn't be used
// in a Q_INVOKABLE because they can make the UI unresponsive.
rv = commit();

if ( rv )
Expand Down Expand Up @@ -201,6 +204,7 @@ bool QgsQuickAttributeModel::deleteFeature()
QgsMessageLog::logMessage( tr( "Cannot delete feature" ),
QStringLiteral( "QgsQuick" ),
Qgis::Warning );

rv = commit();

return rv;
Expand Down
16 changes: 8 additions & 8 deletions src/quickgui/qgsquickutils.cpp
Expand Up @@ -85,14 +85,14 @@ double QgsQuickUtils::screenUnitsToMeters( QgsQuickMapSettings *mapSettings, int
return mDistanceArea.measureLine( p1, p2 );
}

bool QgsQuickUtils::fileExists( QString path )
bool QgsQuickUtils::fileExists( const QString &path ) const
{
QFileInfo check_file( path );
// check if file exists and if yes: Is it really a file and no directory?
return ( check_file.exists() && check_file.isFile() );
}

QString QgsQuickUtils::getFileName( QString path )
QString QgsQuickUtils::getFileName( const QString &path ) const
{
QFileInfo fileInfo( path );
QString filename( fileInfo.fileName() );
Expand All @@ -119,19 +119,19 @@ const QUrl QgsQuickUtils::getThemeIcon( const QString &name ) const
const QUrl QgsQuickUtils::getEditorComponentSource( const QString &widgetName )
{
QString path( "qgsquick%1.qml" );
QStringList supportedWidgets = { "textedit",
"valuemap",
"checkbox",
"externalresource",
"datetime"
QStringList supportedWidgets = { QStringLiteral( "textedit" ),
QStringLiteral( "valuemap" ),
QStringLiteral( "checkbox" ),
QStringLiteral( "externalresource" ),
QStringLiteral( "datetime" )
};
if ( supportedWidgets.contains( widgetName ) )
{
return QUrl( path.arg( widgetName ) );
}
else
{
return QUrl( path.arg( "textedit" ) );
return QUrl( path.arg( QStringLiteral( "textedit" ) ) );
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/quickgui/qgsquickutils.h
Expand Up @@ -121,13 +121,13 @@ class QUICK_EXPORT QgsQuickUtils: public QObject
* Returns whether file on path exists
* \since QGIS 3.4
*/
Q_INVOKABLE bool fileExists( QString path );
Q_INVOKABLE bool fileExists( const QString &path ) const;

/**
* Extracts filename from path
* \since QGIS 3.4
*/
Q_INVOKABLE QString getFileName( QString path );
Q_INVOKABLE QString getFileName( const QString &path ) const;

/**
* Log message in QgsMessageLog
Expand Down

0 comments on commit 660ce87

Please sign in to comment.