fix work wit arrays

This commit is contained in:
arcan1s 2014-02-26 03:48:29 +04:00
parent 0c219544b2
commit 9184aa78f4
3 changed files with 40 additions and 7 deletions

View File

@ -21,7 +21,6 @@
#include <QProcess> #include <QProcess>
#include "mainwindow.h" #include "mainwindow.h"
#include "cstdio"
Netctl::Netctl(MainWindow *wid, QString netctlPath, QString profileDir, QString sudoPath) Netctl::Netctl(MainWindow *wid, QString netctlPath, QString profileDir, QString sudoPath)

View File

@ -23,6 +23,7 @@
#include <QTextStream> #include <QTextStream>
#include "mainwindow.h" #include "mainwindow.h"
#include <cstdio>
NetctlProfile::NetctlProfile(MainWindow *wid, QString profileDir, QString sudoPath) NetctlProfile::NetctlProfile(MainWindow *wid, QString profileDir, QString sudoPath)
@ -104,11 +105,45 @@ QHash<QString, QString> NetctlProfile::getSettingsFromProfile(QString profile)
if (profileFile.atEnd()) if (profileFile.atEnd())
break; break;
else if (fileStr[0] != '#') { else if (fileStr[0] != '#') {
if (fileStr.split(QString("="), QString::SkipEmptyParts).count() == 2) if (fileStr.split(QString("="), QString::SkipEmptyParts).count() == 2) {
if ((fileStr.split(QString("="))[1][0] == QChar('(')) &&
(fileStr.split(QString("="))[1][fileStr.split(QString("="))[1].size()-2] == QChar(')')))
settings[fileStr.split(QString("="))[0]] = fileStr.split(QString("="))[1] settings[fileStr.split(QString("="))[0]] = fileStr.split(QString("="))[1]
.remove(QString("(")) .remove(QString("("))
.remove(QString(")")) .remove(QString(")"))
.trimmed(); .trimmed();
else if (fileStr.split(QString("="))[1][0] == QChar('(')) {
QString parameterName = fileStr.split(QString("="))[0];
QStringList parameter;
if (!fileStr.split(QString("="))[1]
.remove(QString("("))
.remove(QString(")"))
.trimmed()
.isEmpty())
parameter.append(fileStr.split(QString("="))[1]
.remove(QString("("))
.remove(QString(")"))
.trimmed());
while(true) {
fileStr = QString(profileFile.readLine());
if ((profileFile.atEnd()) ||
(fileStr[fileStr.size()-2] == QChar(')')))
break;
if (!fileStr.remove(QString("("))
.remove(QString(")"))
.trimmed()
.isEmpty())
parameter.append(fileStr.remove(QString("("))
.remove(QString(")"))
.trimmed());
}
settings[parameterName] = parameter.join(QString("\n"));
}
else
settings[fileStr.split(QString("="))[0]] = fileStr.split(QString("="))[1]
.trimmed();
}
} }
} }

View File

@ -22,7 +22,6 @@
#include "mainwindow.h" #include "mainwindow.h"
#include "netctlinteract.h" #include "netctlinteract.h"
#include "sleepthread.h" #include "sleepthread.h"
#include <cstdio>
WpaSup::WpaSup(MainWindow *wid, QStringList wpaConfig, QString sudoPath, QString ifaceDir, QString preferedInterface) WpaSup::WpaSup(MainWindow *wid, QStringList wpaConfig, QString sudoPath, QString ifaceDir, QString preferedInterface)