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)
|
||||
{
|
||||
QString data;
|
||||
if (!SystemController::readFile(fileName, &data)) {
|
||||
if (!SystemController::readFile(fileName, data)) {
|
||||
emit importErrorOccurred(ErrorCode::ImportOpenConfigError, false);
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ void SettingsController::backupAppConfig(const QString &fileName)
|
|||
void SettingsController::restoreAppConfig(const QString &fileName)
|
||||
{
|
||||
QByteArray data;
|
||||
SystemController::readFile(fileName, &data);
|
||||
SystemController::readFile(fileName, data);
|
||||
restoreAppConfigFromData(data);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ void SitesController::removeSite(int index)
|
|||
void SitesController::importSites(const QString &fileName, bool replaceExisting)
|
||||
{
|
||||
QByteArray jsonData;
|
||||
if (!SystemController::readFile(fileName, &jsonData)) {
|
||||
if (!SystemController::readFile(fileName, jsonData)) {
|
||||
emit errorOccurred(tr("Can't open file: %1").arg(fileName));
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,28 +62,28 @@ void SystemController::saveFile(const QString &fileName, const QString &data)
|
|||
#endif
|
||||
}
|
||||
|
||||
bool SystemController::readFile(const QString &fileName, QByteArray *data)
|
||||
bool SystemController::readFile(const QString &fileName, QByteArray &data)
|
||||
{
|
||||
#ifdef Q_OS_ANDROID
|
||||
int fd = AndroidController::instance()->getFd(fileName);
|
||||
if (fd == -1) return false;
|
||||
QFile file;
|
||||
if(!file.open(fd, QIODevice::ReadOnly)) return false;
|
||||
data->assign(file.readAll());
|
||||
data = file.readAll();
|
||||
AndroidController::instance()->closeFd();
|
||||
#else
|
||||
QFile file(fileName);
|
||||
if (!file.open(QIODevice::ReadOnly)) return false;
|
||||
data->assign(file.readAll());
|
||||
data = file.readAll();
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SystemController::readFile(const QString &fileName, QString *data)
|
||||
bool SystemController::readFile(const QString &fileName, QString &data)
|
||||
{
|
||||
QByteArray byteArray;
|
||||
if(!readFile(fileName, &byteArray)) return false;
|
||||
data->assign(byteArray);
|
||||
if(!readFile(fileName, byteArray)) return false;
|
||||
data = byteArray;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@ public:
|
|||
explicit SystemController(const std::shared_ptr<Settings> &setting, QObject *parent = nullptr);
|
||||
|
||||
static void saveFile(const QString &fileName, const QString &data);
|
||||
static bool readFile(const QString &fileName, QByteArray *data);
|
||||
static bool readFile(const QString &fileName, QString *data);
|
||||
static bool readFile(const QString &fileName, QByteArray &data);
|
||||
static bool readFile(const QString &fileName, QString &data);
|
||||
|
||||
public slots:
|
||||
QString getFileName(const QString &acceptLabel, const QString &nameFilter, const QString &selectedFile = "",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue