QString QgsSettings::prefixedKey( const QString &key, const Section section ) const { QString prefix; switch ( section ) { case Section::Core : prefix = QStringLiteral( "core" ); break; case Section::Server : prefix = QStringLiteral( "server" ); break; case Section::Gui : prefix = QStringLiteral( "gui" ); break; case Section::Plugins : prefix = QStringLiteral( "plugins" ); break; case Section::Misc : prefix = QStringLiteral( "misc" ); break; case Section::Auth : prefix = QStringLiteral( "auth" ); break; case Section::App : prefix = QStringLiteral( "app" ); break; case Section::Providers : prefix = QStringLiteral( "providers" ); break; case Section::NoSection: default: return sanitizeKey( key ); } return prefix + "/" + sanitizeKey( key ); }
void QgsSettings::beginGroup( const QString &prefix ) { mUserSettings->beginGroup( sanitizeKey( prefix ) ); if ( mGlobalSettings ) { mGlobalSettings->beginGroup( sanitizeKey( prefix ) ); } }
int QgsSettings::beginReadArray( const QString &prefix ) { int size = mUserSettings->beginReadArray( sanitizeKey( prefix ) ); if ( 0 == size && mGlobalSettings ) { size = mGlobalSettings->beginReadArray( sanitizeKey( prefix ) ); mUsingGlobalArray = ( size > 0 ); } return size; }
Playfair::Playfair(string key) { validKey = true; if(key.size() < 1 || key.size() > 10) validKey = false; std::transform(key.begin(), key.end(), key.begin(), ::tolower); for(unsigned int i = 0; i < key.size(); i++) if(key[i] < 'a' || key[i] > 'z') validKey = false; if(!validKey) return; string alphabet = "abcdefghiklmnopqrstuvwxyz"; string sanitizedKey = sanitizeKey(key); for(unsigned int i = 0; i < sanitizedKey.size(); i++) for(unsigned int j = 0; j < alphabet.size(); j++) if(sanitizedKey[i] == alphabet[j]) alphabet.erase(j, 1); sanitizedKey.append(alphabet); int index = 0; for(int i = 0; i < 5; i++) for(int j = 0; j < 5; j++) matrix[i][j] = sanitizedKey[index++]; }
void QgsSettings::remove( const QString &key ) { mUserSettings->remove( sanitizeKey( key ) ); }