Companion enhancements for checklist editor, model print and compare (2 3 branch) (#6434)
* Model print and compare include GFs enhancement * Model print and compare include checklist contents * Add missing brackets and code tidy up * Print message if cannot open or read checklist file * Missing GV label translation Move some checklist code to helpers * Refactor to use helpers and add cursor position * Move improved version of removeAccents to helpers and apply to checklist * Force fixed width font for edit window
This commit is contained in:
committed by
Bertrand Songis
parent
0544846dc3
commit
b4175eade3
@@ -36,6 +36,7 @@
|
||||
#include <QFileDialog>
|
||||
#include <QLabel>
|
||||
#include <QMessageBox>
|
||||
#include <QDir>
|
||||
|
||||
using namespace Helpers;
|
||||
|
||||
@@ -809,3 +810,50 @@ void TableLayout::pushRowsUp(int row)
|
||||
// addDoubleSpring(gridLayout, 5, num_fsw+1);
|
||||
|
||||
}
|
||||
|
||||
QString Helpers::getChecklistsPath()
|
||||
{
|
||||
return QDir::toNativeSeparators(g.profile[g.id()].sdPath() + "/MODELS/"); // TODO : add sub folder to constants
|
||||
}
|
||||
|
||||
QString Helpers::getChecklistFilename(const ModelData * model)
|
||||
{
|
||||
QString name = model->name;
|
||||
name.replace(" ", "_");
|
||||
name.append(".txt"); // TODO : add to constants
|
||||
return name;
|
||||
}
|
||||
|
||||
QString Helpers::getChecklistFilePath(const ModelData * model)
|
||||
{
|
||||
return getChecklistsPath() + getChecklistFilename(model);
|
||||
}
|
||||
|
||||
QString Helpers::removeAccents(const QString & str)
|
||||
{
|
||||
// UTF-8 ASCII Table
|
||||
static const QHash<QString, QVariant> map = {
|
||||
{"a", QRegularExpression("[áâãàä]")},
|
||||
{"A", QRegularExpression("[ÁÂÃÀÄ]")},
|
||||
{"e", QRegularExpression("[éèêě]")},
|
||||
{"E", QRegularExpression("[ÉÈÊĚ]")},
|
||||
{"o", QRegularExpression("[óôõö]")},
|
||||
{"O", QRegularExpression("[ÓÔÕÖ]")},
|
||||
{"u", QRegularExpression("[úü]")},
|
||||
{"U", QRegularExpression("[ÚÜ]")},
|
||||
{"i", "í"}, {"I", "Í"},
|
||||
{"c", "ç"}, {"C", "Ç"},
|
||||
{"y", "ý"}, {"Y", "Ý"},
|
||||
{"s", "š"}, {"S", "Š"},
|
||||
{"r", "ř"}, {"R", "Ř"}
|
||||
};
|
||||
|
||||
QString result(str);
|
||||
for (QHash<QString, QVariant>::const_iterator it = map.cbegin(), en = map.cend(); it != en; ++it) {
|
||||
if (it.value().canConvert<QRegularExpression>())
|
||||
result.replace(it.value().toRegularExpression(), it.key());
|
||||
else
|
||||
result.replace(it.value().toString(), it.key());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user