Query Fragments: handle config file errors + doc

This commit is contained in:
Jean-Francois Dockes
2014-12-17 15:35:14 +01:00
parent 51b7f63c00
commit bc6e025a0c
7 changed files with 160 additions and 6 deletions
+11 -1
View File
@@ -25,6 +25,7 @@
#include <QtGui/QCheckBox>
#include <QtGui/QRadioButton>
#include <QtGui/QButtonGroup>
#include <QtGui/QMessageBox>
#include <QtXml/QXmlDefaultHandler>
#include "fragbuts.h"
@@ -113,6 +114,7 @@ bool FragButsParser::endElement(const QString & /* namespaceURI */,
QCheckBox *but = new QCheckBox(label, parent);
abut = but;
}
abut->setToolTip(currentText);
buttons.push_back(FragButs::ButFrag(abut, frag));
hl->addWidget(abut);
} else if (qName == "buttons" || qName == "radiobuttons") {
@@ -125,12 +127,15 @@ bool FragButsParser::endElement(const QString & /* namespaceURI */,
}
FragButs::FragButs(QWidget* parent)
: QWidget(parent)
: QWidget(parent), m_ok(false)
{
string conf = path_cat(theconfig->getConfDir(), "fragbuts.xml");
string data, reason;
if (!file_to_string(conf, data, &reason)) {
QMessageBox::warning(0, "Recoll",
tr("%1 not found.").arg(
QString::fromLocal8Bit(conf.c_str())));
LOGERR(("Fragbuts:: can't read [%s]\n", conf.c_str()));
return;
}
@@ -142,6 +147,9 @@ FragButs::FragButs(QWidget* parent)
QXmlInputSource xmlInputSource;
xmlInputSource.setData(QString::fromUtf8(data.c_str()));
if (!reader.parse(xmlInputSource)) {
QMessageBox::warning(0, "Recoll",
tr("%1 could not be parsed.").arg(
QString::fromLocal8Bit(conf.c_str())));
LOGERR(("FragButs:: parse failed for [%s]\n", conf.c_str()));
return;
}
@@ -150,6 +158,8 @@ FragButs::FragButs(QWidget* parent)
connect(it->button, SIGNAL(clicked(bool)),
this, SLOT(onButtonClicked(bool)));
}
setWindowTitle(tr("Fragment Buttons"));
m_ok = true;
}
FragButs::~FragButs()
+2 -1
View File
@@ -46,7 +46,7 @@ public:
};
void getfrags(std::vector<std::string>&);
bool ok() {return m_ok;}
private slots:
void onButtonClicked(bool);
@@ -57,6 +57,7 @@ private:
// Detect source file change
time_t m_reftime;
std::vector<ButFrag> m_buttons;
bool m_ok;
};
+8 -3
View File
@@ -1058,9 +1058,14 @@ void RclMain::showFragButs()
{
if (fragbuts == 0) {
fragbuts = new FragButs(0);
fragbuts->show();
connect(fragbuts, SIGNAL(fragmentsChanged()),
this, SLOT(onFragmentsChanged()));
if (fragbuts->ok()) {
fragbuts->show();
connect(fragbuts, SIGNAL(fragmentsChanged()),
this, SLOT(onFragmentsChanged()));
} else {
delete fragbuts;
fragbuts = 0;
}
} else {
// Close and reopen, in hope that makes us visible...
fragbuts->close();
+1 -1
View File
@@ -488,7 +488,7 @@ void ResTable::init()
tableView->setContextMenuPolicy(Qt::CustomContextMenu);
new QShortcut(QKeySequence("Ctrl+o"), this, SLOT(menuEdit()));
new QShortcut(QKeySequence("Ctrl+Shift+o"), this, SLOT(menuEditAndQuit()));
new QShortcut(QKeySequence("Ctrl+p"), this, SLOT(menuPreview()));
new QShortcut(QKeySequence("Ctrl+d"), this, SLOT(menuPreview()));
connect(tableView, SIGNAL(customContextMenuRequested(const QPoint&)),
this, SLOT(createPopupMenu(const QPoint&)));