| 114 | } |
| 115 | |
| 116 | bool parseOldFileFormat(QIODevice& device, QSettings::SettingsMap& map) |
| 117 | { |
| 118 | QTextStream in(device.readAll()); |
| 119 | #if QT_VERSION <= QT_VERSION_CHECK(6, 0, 0) |
| 120 | in.setCodec("UTF-8"); |
| 121 | #endif |
| 122 | |
| 123 | QStringList lines = in.readAll().split('\n'); |
| 124 | for (int i = 0; i < lines.count(); i++) { |
| 125 | QString& lineRaw = lines[i]; |
| 126 | // Ignore comments. |
| 127 | int commentIndex = 0; |
| 128 | QString line = lineRaw; |
| 129 | // Search for comments until no more escaped # are available |
| 130 | while ((commentIndex = line.indexOf('#', commentIndex + 1)) != -1) { |
| 131 | if (commentIndex > 0 && line.at(commentIndex - 1) == '\\') { |
| 132 | continue; |
| 133 | } |
| 134 | line = line.left(lineRaw.indexOf('#')).trimmed(); |
| 135 | } |
| 136 | |
| 137 | int eqPos = line.indexOf('='); |
| 138 | if (eqPos == -1) |
| 139 | continue; |
| 140 | QString key = line.left(eqPos).trimmed(); |
| 141 | QString valueStr = line.right(line.length() - eqPos - 1).trimmed(); |
| 142 | |
| 143 | valueStr = unquote(unescape(valueStr)); |
| 144 | |
| 145 | QVariant value(valueStr); |
| 146 | map.insert(key, value); |
| 147 | } |
| 148 | |
| 149 | return true; |
| 150 | } |
| 151 | |
| 152 | bool INIFile::loadFile(QString fileName) |
| 153 | { |