Many improvements

PermGen can be tweaked from the settings menu
Groups are saved on change/exit
Install target is no longer completely broken
All the deplibs are now static
Added notes dialog
Fixed ini file format support (can save strings with newlines, tabs. UTF-8 is explicitly used!)
Rename button now uses line breaks so it doesn't grow ever wider (Added a custom tool button subclass)
There is now a CAT button. Meow.
This commit is contained in:
Petr Mrázek
2013-08-25 22:48:41 +02:00
parent d884f849d6
commit f0990fae4b
26 changed files with 512 additions and 96 deletions

View File

@@ -19,21 +19,40 @@
#include <QTextStream>
#include <QStringList>
INIFile::INIFile()
{
}
QString INIFile::unescape(QString orig)
{
orig.replace("\\n", "\n");
orig.replace("\\t", "\t");
orig.replace("\\\\", "\\");
return orig;
}
QString INIFile::escape(QString orig)
{
orig.replace("\\", "\\\\");
orig.replace("\n", "\\n");
orig.replace("\t", "\\t");
return orig;
}
bool INIFile::saveFile(QString fileName)
{
// TODO Handle errors.
QFile file(fileName);
file.open(QIODevice::WriteOnly);
QTextStream out(&file);
out.setCodec("UTF-8");
for (Iterator iter = begin(); iter != end(); iter++)
{
out << iter.key() << "=" << iter.value().toString() << "\n";
QString value = iter.value().toString();
value = escape(value);
out << iter.key() << "=" << value << "\n";
}
return true;
@@ -45,6 +64,7 @@ bool INIFile::loadFile(QString fileName)
QFile file(fileName);
file.open(QIODevice::ReadOnly);
QTextStream in(&file);
in.setCodec("UTF-8");
QStringList lines = in.readAll().split('\n');
for (int i = 0; i < lines.count(); i++)
@@ -59,13 +79,9 @@ bool INIFile::loadFile(QString fileName)
QString key = line.left(eqPos).trimmed();
QString valueStr = line.right(line.length() - eqPos - 1).trimmed();
valueStr = unescape(valueStr);
QVariant value(valueStr);
/*
QString dbg = key;
dbg += " = ";
dbg += valueStr;
qDebug(dbg.toLocal8Bit());
*/
this->operator [](key) = value;
}