loading globalMap into RAM

This commit is contained in:
Rafael 2016-04-23 21:01:00 +02:00
parent d60d9b8b72
commit 40eb28b65d
4 changed files with 23 additions and 1 deletions

View file

@ -28,6 +28,19 @@ GlobalString::GlobalString()
}
QMap<QString, QString> GlobalString::getGlobalMap()
{
QMap<QString, QString> globalMap;
QSettings globalFile(getLanguageFile(), QSettings::IniFormat);
globalFile.beginGroup("Global");
QStringList globalStrList = globalFile.childKeys();
foreach(const QString &globalStr, globalStrList)
{
globalMap[globalStr] = globalFile.value(globalStr, globalStr).toString();
}
globalFile.endGroup();
return globalMap;
}
QString GlobalString::getString(QString valueStr, bool *ok)
{

View file

@ -20,6 +20,7 @@
#define GLOBALSTRING_H
#include <QString>
#include <QMap>
class GlobalString
{
@ -28,6 +29,7 @@ public:
static QString getString(QString valueStr, bool *ok = 0);
static QString getLanguageFile();
static QString getLanguage();
static QMap<QString, QString> getGlobalMap();
};
#endif // GLOBALSTRING_H

View file

@ -68,6 +68,9 @@ PictureDialog::PictureDialog(ProfileDatabase *profileDB, QWidget *parent) :
exportMenu->addAction(tr("Export as &GTA Snapmatic..."), this, SLOT(copySnapmaticPicture()));
ui->cmdExport->setMenu(exportMenu);
// Global map
globalMap = GlobalString::getGlobalMap();
installEventFilter(this);
installEventFilter(ui->labPicture);
ui->labPicture->setFocusPolicy(Qt::StrongFocus);
@ -158,7 +161,10 @@ void PictureDialog::setSnapmaticPicture(SnapmaticPicture *picture, QString pictu
plyrsList = picture->getPlayers();
picTitl = picture->getPictureTitl();
picArea = picture->getArea();
picAreaStr = GlobalString::getString(picArea);
if (globalMap.contains(picArea))
{
picAreaStr = globalMap[picArea];
}
QString plyrsStr;
if (plyrsList.length() >= 1)

View file

@ -68,6 +68,7 @@ protected:
private:
ProfileDatabase *profileDB;
Ui::PictureDialog *ui;
QMap<QString, QString> globalMap;
SnapmaticPicture *smpic;
QImage snapmaticPicture;
QString jsonDrawString;