fragbuts: more file format checks and diags

This commit is contained in:
Jean-Francois Dockes 2020-04-19 11:10:45 +02:00
parent 2287c9d0ca
commit 058cec8466

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2005 J.F.Dockes /* Copyright (C) 2005-2020 J.F.Dockes
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
@ -45,8 +45,7 @@ public:
FragButsParser(FragButs *_parent, vector<FragButs::ButFrag>& _buttons) FragButsParser(FragButs *_parent, vector<FragButs::ButFrag>& _buttons)
: parent(_parent), vlw(new QVBoxLayout(parent)), : parent(_parent), vlw(new QVBoxLayout(parent)),
vl(new QVBoxLayout()), buttons(_buttons), vl(new QVBoxLayout()), buttons(_buttons),
hl(0), bg(0), radio(false) hl(0), bg(0), radio(false) {
{
} }
bool startElement(const QString & /* namespaceURI */, bool startElement(const QString & /* namespaceURI */,
@ -56,8 +55,7 @@ public:
bool endElement(const QString & /* namespaceURI */, bool endElement(const QString & /* namespaceURI */,
const QString & /* localName */, const QString & /* localName */,
const QString &qName); const QString &qName);
bool characters(const QString &str) bool characters(const QString &str) {
{
currentText += str; currentText += str;
return true; return true;
} }
@ -103,6 +101,12 @@ bool FragButsParser::startElement(const QString & /* namespaceURI */,
radio = true; radio = true;
bg = new QButtonGroup(parent); bg = new QButtonGroup(parent);
hl = new QHBoxLayout(); hl = new QHBoxLayout();
} else if (qName == "label" || qName == "frag" || qName == "fragbuts" ||
qName == "fragbut") {
} else {
QMessageBox::warning(0, "Recoll",
QString("Bad element name: [%1]").arg(qName));
return false;
} }
return true; return true;
} }
@ -138,6 +142,10 @@ bool FragButsParser::endElement(const QString & /* namespaceURI */,
hl = 0; hl = 0;
} else if (qName == "fragbuts") { } else if (qName == "fragbuts") {
vlw->addLayout(vl); vlw->addLayout(vl);
} else {
QMessageBox::warning(0, "Recoll",
QString("Bad element name: [%1]").arg(qName));
return false;
} }
return true; return true;
} }