From fcd05ca2f6b7a76063c98e2720be758be1f67980 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Tue, 27 Aug 2013 22:32:41 +0200 Subject: Read mod files to get versions... and stuff. --- depends/settings/include/inifile.h | 3 ++- depends/settings/src/inifile.cpp | 12 +++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) (limited to 'depends') diff --git a/depends/settings/include/inifile.h b/depends/settings/include/inifile.h index e3ff6b64..8d30a258 100644 --- a/depends/settings/include/inifile.h +++ b/depends/settings/include/inifile.h @@ -16,7 +16,7 @@ #pragma once #include #include - +#include #include "libsettings_config.h" @@ -26,6 +26,7 @@ class LIBSETTINGS_EXPORT INIFile : public QMap public: explicit INIFile(); + bool loadFile(QByteArray file); bool loadFile(QString fileName); bool saveFile(QString fileName); diff --git a/depends/settings/src/inifile.cpp b/depends/settings/src/inifile.cpp index b3ee3a90..1eae5609 100644 --- a/depends/settings/src/inifile.cpp +++ b/depends/settings/src/inifile.cpp @@ -60,10 +60,16 @@ bool INIFile::saveFile(QString fileName) bool INIFile::loadFile(QString fileName) { - // TODO Handle errors. QFile file(fileName); - file.open(QIODevice::ReadOnly); - QTextStream in(&file); + if(!file.open(QIODevice::ReadOnly)) + return false; + bool success = loadFile(file.readAll()); + file.close(); + return success; +} +bool INIFile::loadFile( QByteArray file ) +{ + QTextStream in(file); in.setCodec("UTF-8"); QStringList lines = in.readAll().split('\n'); -- cgit v1.2.3