fix: get rid of the assign function call
This commit is contained in:
parent
882c288d92
commit
5b9ba8c027
5 changed files with 11 additions and 11 deletions
|
|
@ -78,7 +78,7 @@ ImportController::ImportController(const QSharedPointer<ServersModel> &serversMo
|
||||||
bool ImportController::extractConfigFromFile(const QString &fileName)
|
bool ImportController::extractConfigFromFile(const QString &fileName)
|
||||||
{
|
{
|
||||||
QString data;
|
QString data;
|
||||||
if (!SystemController::readFile(fileName, &data)) {
|
if (!SystemController::readFile(fileName, data)) {
|
||||||
emit importErrorOccurred(ErrorCode::ImportOpenConfigError, false);
|
emit importErrorOccurred(ErrorCode::ImportOpenConfigError, false);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -132,7 +132,7 @@ void SettingsController::backupAppConfig(const QString &fileName)
|
||||||
void SettingsController::restoreAppConfig(const QString &fileName)
|
void SettingsController::restoreAppConfig(const QString &fileName)
|
||||||
{
|
{
|
||||||
QByteArray data;
|
QByteArray data;
|
||||||
SystemController::readFile(fileName, &data);
|
SystemController::readFile(fileName, data);
|
||||||
restoreAppConfigFromData(data);
|
restoreAppConfigFromData(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -83,7 +83,7 @@ void SitesController::removeSite(int index)
|
||||||
void SitesController::importSites(const QString &fileName, bool replaceExisting)
|
void SitesController::importSites(const QString &fileName, bool replaceExisting)
|
||||||
{
|
{
|
||||||
QByteArray jsonData;
|
QByteArray jsonData;
|
||||||
if (!SystemController::readFile(fileName, &jsonData)) {
|
if (!SystemController::readFile(fileName, jsonData)) {
|
||||||
emit errorOccurred(tr("Can't open file: %1").arg(fileName));
|
emit errorOccurred(tr("Can't open file: %1").arg(fileName));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -62,28 +62,28 @@ void SystemController::saveFile(const QString &fileName, const QString &data)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SystemController::readFile(const QString &fileName, QByteArray *data)
|
bool SystemController::readFile(const QString &fileName, QByteArray &data)
|
||||||
{
|
{
|
||||||
#ifdef Q_OS_ANDROID
|
#ifdef Q_OS_ANDROID
|
||||||
int fd = AndroidController::instance()->getFd(fileName);
|
int fd = AndroidController::instance()->getFd(fileName);
|
||||||
if (fd == -1) return false;
|
if (fd == -1) return false;
|
||||||
QFile file;
|
QFile file;
|
||||||
if(!file.open(fd, QIODevice::ReadOnly)) return false;
|
if(!file.open(fd, QIODevice::ReadOnly)) return false;
|
||||||
data->assign(file.readAll());
|
data = file.readAll();
|
||||||
AndroidController::instance()->closeFd();
|
AndroidController::instance()->closeFd();
|
||||||
#else
|
#else
|
||||||
QFile file(fileName);
|
QFile file(fileName);
|
||||||
if (!file.open(QIODevice::ReadOnly)) return false;
|
if (!file.open(QIODevice::ReadOnly)) return false;
|
||||||
data->assign(file.readAll());
|
data = file.readAll();
|
||||||
#endif
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SystemController::readFile(const QString &fileName, QString *data)
|
bool SystemController::readFile(const QString &fileName, QString &data)
|
||||||
{
|
{
|
||||||
QByteArray byteArray;
|
QByteArray byteArray;
|
||||||
if(!readFile(fileName, &byteArray)) return false;
|
if(!readFile(fileName, byteArray)) return false;
|
||||||
data->assign(byteArray);
|
data = byteArray;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,8 @@ public:
|
||||||
explicit SystemController(const std::shared_ptr<Settings> &setting, QObject *parent = nullptr);
|
explicit SystemController(const std::shared_ptr<Settings> &setting, QObject *parent = nullptr);
|
||||||
|
|
||||||
static void saveFile(const QString &fileName, const QString &data);
|
static void saveFile(const QString &fileName, const QString &data);
|
||||||
static bool readFile(const QString &fileName, QByteArray *data);
|
static bool readFile(const QString &fileName, QByteArray &data);
|
||||||
static bool readFile(const QString &fileName, QString *data);
|
static bool readFile(const QString &fileName, QString &data);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
QString getFileName(const QString &acceptLabel, const QString &nameFilter, const QString &selectedFile = "",
|
QString getFileName(const QString &acceptLabel, const QString &nameFilter, const QString &selectedFile = "",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue