3static bool isLineHidden(
const QString &line) {
4 return line.startsWith(
"otpauth://", Qt::CaseInsensitive);
8 const QStringList &templateFields,
10 QStringList lines = fileContent.split(
"\n");
11 QString password = lines.takeFirst();
12 QStringList remainingData, remainingDataDisplay;
14 for (
const QString &line : qAsConst(lines)) {
15 if (line.contains(
":")) {
16 int colon = line.indexOf(
':');
17 QString name = line.left(colon);
18 QString value = line.right(line.length() - colon - 1);
22 || templateFields.contains(name)) {
23 namedValues.append({name.trimmed(), value.trimmed()});
28 remainingData.append(line);
29 if (!isLineHidden(line))
30 remainingDataDisplay.append(line);
32 return FileContent(password, namedValues, remainingData.join(
"\n"),
33 remainingDataDisplay.join(
"\n"));
43 return this->remainingDataDisplay;
46FileContent::FileContent(
const QString &password,
48 const QString &remainingData,
49 const QString &remainingDataDisplay)
50 : password(password), namedValues(namedValues),
51 remainingData(remainingData), remainingDataDisplay(remainingDataDisplay) {
60 for (
int i = 0; i < length(); ++i) {
61 if (at(i).name == name) {
62 return takeAt(i).value;
QString getRemainingData() const
QString getRemainingDataForDisplay() const
QString getPassword() const
NamedValues getNamedValues() const
static FileContent parse(const QString &fileContent, const QStringList &templateFields, bool allFields)
parse parses the given fileContent in a FileContent object. The password is accessible through getPas...
The NamedValues class is mostly a list of NamedValue but also has a method to take a specific NamedVa...
QString takeValue(const QString &name)