Reopen db before showing indexed MIME types, explain empty list

This commit is contained in:
Jean-Francois Dockes 2017-02-23 11:50:54 +01:00
parent 5c46dbf7da
commit f0d193e53d
2 changed files with 16 additions and 5 deletions

View File

@ -346,9 +346,11 @@ void RclMain::showMissingHelpers()
void RclMain::showActiveTypes()
{
if (rcldb == 0) {
string reason;
bool maindberror;
if (!maybeOpenDb(reason, true, &maindberror)) {
QMessageBox::warning(0, tr("Error"),
tr("Index not open"),
u8s2qs(reason),
QMessageBox::Ok,
QMessageBox::NoButton);
return;
@ -407,9 +409,14 @@ void RclMain::showActiveTypes()
editor->setReadOnly(true);
dialog.horizontalLayout->addWidget(editor);
for (set<string>::const_iterator it = mtypesfromdbconf.begin();
it != mtypesfromdbconf.end(); it++) {
editor->append(QString::fromUtf8(it->c_str()));
if (mtypesfromdbconf.empty()) {
editor->append(tr("Types list empty: maybe wait for indexing to "
"progress?"));
} else {
for (set<string>::const_iterator it = mtypesfromdbconf.begin();
it != mtypesfromdbconf.end(); it++) {
editor->append(QString::fromUtf8(it->c_str()));
}
}
editor->moveCursor(QTextCursor::Start);
editor->ensureCursorVisible();

View File

@ -55,6 +55,10 @@ inline std::string qs2utf8s(const QString& qs)
{
return std::string((const char *)qs.toUtf8());
}
inline QString u8s2qs(const std::string us)
{
return QString::fromUtf8(us.c_str());
}
/** Specialized version of the qt file dialog. Can't use getOpenFile()
etc. cause they hide dot files... */