printing: only load *.html files in the UI

The function find_all_templates() thus far handled
all files in the user template directory.

This patch makes it so that only files with the .html
extension are loaded.

Also remove brackets for single lined `if` statement.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
This commit is contained in:
Lubomir I. Ivanov 2017-11-24 20:55:16 +02:00
parent 712697e0c2
commit fc48cde77c

View file

@ -20,23 +20,22 @@ int getTotalWork(print_options *printOptions)
void find_all_templates()
{
const QString ext(".html");
grantlee_templates.clear();
grantlee_statistics_templates.clear();
QDir dir(getPrintingTemplatePathUser());
QStringList list = dir.entryList(QDir::Files | QDir::NoDotAndDotDot);
foreach (const QString& filename, list) {
if (filename.at(filename.size() - 1) != '~') {
if (filename.at(filename.size() - 1) != '~' && filename.endsWith(ext))
grantlee_templates.append(filename);
}
}
// find statistics templates
dir.setPath(getPrintingTemplatePathUser() + QDir::separator() + "statistics");
list = dir.entryList(QDir::Files | QDir::NoDotAndDotDot);
foreach (const QString& filename, list) {
if (filename.at(filename.size() - 1) != '~') {
if (filename.at(filename.size() - 1) != '~' && filename.endsWith(ext))
grantlee_statistics_templates.append(filename);
}
}
}