QGIS API Documentation
3.14.0-Pi (9f7028fd23)
|
Go to the documentation of this file.
21 #include <QTextStream>
32 return mProfileFolder;
38 if ( !QDir( mProfileFolder ).exists() )
40 error.
append( QObject::tr(
"Profile folder doesn't exist" ) );
47 QDir dir( mProfileFolder );
54 QSettings::setDefaultFormat( QSettings::IniFormat );
55 QSettings::setPath( QSettings::IniFormat, QSettings::UserScope,
folder() );
60 const QString dbFile = qgisDB();
61 QString profileAlias =
name();
65 if ( !QFile::exists( dbFile ) )
73 int result = database.
open( dbFile );
74 if ( result != SQLITE_OK )
80 if ( result == SQLITE_OK )
82 if ( preparedStatement.
step() == SQLITE_ROW )
85 if ( !
alias.isEmpty() )
95 const QString dbFile = qgisDB();
99 if ( !QFile::exists( dbFile ) )
101 error.
append( QObject::tr(
"qgis.db doesn't exist in the user's profile folder" ) );
108 int result = database.
open( dbFile );
109 if ( result != SQLITE_OK )
111 error.
append( QObject::tr(
"Unable to open qgis.db for update." ) );
115 const QString sql = QStringLiteral(
"INSERT OR REPLACE INTO tbl_config_variables VALUES ('ALIAS', %1);" ).arg(
119 if ( result != SQLITE_OK || preparedStatement.
step() != SQLITE_DONE )
121 error.
append( QObject::tr(
"Could not save alias to database: %1" ).arg( database.
errorMessage() ) );
129 QString path = mProfileFolder + QDir::separator() +
"icon.svg";
130 if ( !QDir( path ).exists() )
134 return QIcon( path );
137 QString QgsUserProfile::qgisDB()
const
139 return mProfileFolder + QDir::separator() +
"qgis.db";
const QString name() const
The name for the user profile.
int open(const QString &path)
Opens the database at the specified file path.
static QIcon getThemeIcon(const QString &name)
Helper to get a theme icon.
const QString folder() const
The base folder for the user profile.
sqlite3_statement_unique_ptr prepare(const QString &sql, int &resultCode) const
Prepares a sql statement, returning the result.
static QString quotedString(const QString &value)
Returns a quoted string value, surround by ' characters and with special characters correctly escaped...
QgsError setAlias(const QString &alias)
Set the alias of the profile.
void append(const QString &message, const QString &tag)
Append new error message.
QString errorMessage() const
Returns the most recent error message encountered by the database.
int step()
Steps to the next record in the statement, returning the sqlite3 result code.
const QIcon icon() const
The icon for the user profile.
void initSettings() const
Init the settings from the user folder.
QString columnAsText(int column) const
Returns the column value from the current statement row as a string.
QgsUserProfile(const QString &folder)
Reference to a existing user profile folder.
const QString alias() const
Returns the alias for the user profile.
QgsError validate() const
Check of the profile is in a valid state.