Skip to content
Permalink
Browse files

small const tweak

  • Loading branch information
PeterPetrik committed Jul 13, 2018
1 parent be90339 commit 660ce876a2123cd6800d7f048238865c5cab7160
@@ -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
@@ -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 );
@@ -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 )
@@ -201,6 +204,7 @@ bool QgsQuickAttributeModel::deleteFeature()
QgsMessageLog::logMessage( tr( "Cannot delete feature" ),
QStringLiteral( "QgsQuick" ),
Qgis::Warning );

rv = commit();

return rv;
@@ -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() );
@@ -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" ) ) );
}
}

@@ -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

0 comments on commit 660ce87

Please sign in to comment.
You can’t perform that action at this time.