GUI: use common methods for translating to/from qstring/fspath

This commit is contained in:
Jean-Francois Dockes 2020-04-15 10:39:59 +01:00
parent 71368b3134
commit c1ee5f0af5
16 changed files with 108 additions and 110 deletions

View File

@ -439,9 +439,8 @@ void AdvSearch::runSearch()
if (!subtreeCMB->currentText().isEmpty()) {
QString current = subtreeCMB->currentText();
Rcl::SearchDataClausePath *pathclause =
new Rcl::SearchDataClausePath((const char*)current.toLocal8Bit(),
direxclCB->isChecked());
Rcl::SearchDataClausePath *pathclause = new Rcl::SearchDataClausePath(
qs2path(current), direxclCB->isChecked());
if (sdata->getTp() == SCLT_AND) {
sdata->addClause(pathclause);
} else {
@ -506,7 +505,7 @@ void AdvSearch::fromSearch(std::shared_ptr<SearchData> sdata)
dynamic_cast<SearchDataClausePath*>(sdata->m_query[i]);
// We can only use one such clause. There should be only one too
// if this is sfrom aved search data.
QString qdir = QString::fromLocal8Bit(cs->gettext().c_str());
QString qdir = path2qs(cs->gettext());
subtreeCMB->setEditText(qdir);
direxclCB->setChecked(cs->getexclude());
continue;

View File

@ -173,7 +173,7 @@ void ConfIndexW::showPrefs(bool modal)
if (nullptr == m_w) {
QString title = u8s2qs("Recoll - Index Settings: ");
title += QString::fromLocal8Bit(m_rclconf->getConfDir().c_str());
title += path2qs(m_rclconf->getConfDir());
conflinkfactory = MyConfLinkFactRCL(&m_conf, &sknull);
if (nullptr == (m_w = new ConfTabsW(this, title, &conflinkfactory))) {
return;

View File

@ -155,10 +155,9 @@ FragButs::FragButs(QWidget* parent)
copyfile(src.c_str(), m_fn.c_str(), reason);
}
if (!file_to_string(m_fn, data, &reason)) {
QMessageBox::warning(0, "Recoll",
tr("%1 not found.").arg(
QString::fromLocal8Bit(m_fn.c_str())));
LOGERR("Fragbuts:: can't read [" << (m_fn) << "]\n" );
QMessageBox::warning(
0, "Recoll", tr("%1 not found.").arg(path2qs(m_fn)));
LOGERR("Fragbuts:: can't read [" << m_fn << "]\n");
return;
}
FragButsParser parser(this, m_buttons);
@ -169,8 +168,7 @@ FragButs::FragButs(QWidget* parent)
xmlInputSource.setData(QString::fromUtf8(data.c_str()));
if (!reader.parse(xmlInputSource)) {
QMessageBox::warning(0, "Recoll", tr("%1:\n %2")
.arg(QString::fromLocal8Bit(m_fn.c_str()))
.arg(parser.errorMessage));
.arg(path2qs(m_fn)).arg(parser.errorMessage));
return;
}
for (vector<ButFrag>::iterator it = m_buttons.begin();

View File

@ -159,9 +159,9 @@ static void recollCleanup()
void applyStyleSheet(const QString& ssfname)
{
const char *cfname = (const char *)ssfname.toLocal8Bit();
LOGDEB0("Applying style sheet: [" << (cfname) << "]\n" );
if (cfname && *cfname) {
const char *cfname = qs2path(ssfname).c_str();
LOGDEB0("Applying style sheet: [" << cfname << "]\n");
if (*cfname) {
string stylesheet;
file_to_string(cfname, stylesheet);
qApp->setStyleSheet(QString::fromUtf8(stylesheet.c_str()));
@ -356,7 +356,7 @@ int main(int argc, char **argv)
QString msg = app.translate
("Main",
"\"history\" file is damaged, please check "
"or remove it: ") + QString::fromLocal8Bit(historyfile.c_str());
"or remove it: ") + path2qs(historyfile);
QMessageBox::critical(0, "Recoll", msg);
exit(1);
}

View File

@ -51,8 +51,8 @@ void multiSave(QWidget *p, vector<Rcl::Doc>& docs)
QWidget::tr("Choose exactly one directory"));
return;
}
string dir((const char *)dirl[0].toLocal8Bit());
LOGDEB2("multiSave: got dir " << (dir) << "\n" );
string dir(qs2path(dirl[0]));
LOGDEB2("multiSave: got dir " << dir << "\n");
/* Save doc to files in target directory. Issues:
- It is quite common to have docs in the array with the same
@ -80,7 +80,7 @@ void multiSave(QWidget *p, vector<Rcl::Doc>& docs)
if (!listdir(dir, reason, existingNames)) {
QMessageBox::warning(0, "Recoll",
QWidget::tr("Could not read directory: ") +
QString::fromLocal8Bit(reason.c_str()));
path2qs(reason));
return;
}
@ -110,8 +110,7 @@ void multiSave(QWidget *p, vector<Rcl::Doc>& docs)
if (!suffix.empty())
ss << "." << suffix;
string fn =
(const char *)QString::fromUtf8(ss.str().c_str()).toLocal8Bit();
string fn = qs2path(u8s2qs(ss.str()));
if (existingNames.find(fn) == existingNames.end() &&
toBeCreated.find(fn) == toBeCreated.end()) {
toBeCreated.insert(fn);
@ -132,12 +131,9 @@ void multiSave(QWidget *p, vector<Rcl::Doc>& docs)
// There is still a race condition here, should we care ?
TempFile temp;// not used
if (!FileInterner::idocToFile(temp, fn, theconfig, docs[i], false)) {
QMessageBox::warning(0, "Recoll",
QWidget::tr("Cannot extract document: ") +
QString::fromLocal8Bit(docs[i].url.c_str()) +
" | " +
QString::fromLocal8Bit(docs[i].ipath.c_str())
);
QMessageBox::warning(
0, "Recoll", QWidget::tr("Cannot extract document: ") +
path2qs(docs[i].url) + " | " + u8s2qs(docs[i].ipath));
}
}
}

View File

@ -483,7 +483,7 @@ void Preview::setCurTabProps(const Rcl::Doc &doc, int docnum)
if (doc.getmeta(Rcl::Doc::keytt, &ctitle) && !ctitle.empty()) {
title = QString::fromUtf8(ctitle.c_str(), ctitle.length());
} else {
title = QString::fromLocal8Bit(path_getsimple(doc.url).c_str());
title = path2qs(path_getsimple(doc.url));
}
if (title.length() > 20) {
title = title.left(10) + "..." + title.right(10);
@ -641,7 +641,7 @@ bool Preview::runLoadThread(LoadThread& lthr, QTimer& tT, QEventLoop& loop,
if (!lthr.missing.empty()) {
explain = QString::fromUtf8("<br>") +
tr("Missing helper program: ") +
QString::fromLocal8Bit(lthr.missing.c_str());
path2qs(lthr.missing);
QMessageBox::warning(0, "Recoll",
tr("Can't turn doc into internal "
"representation for ") +
@ -700,8 +700,7 @@ bool Preview::loadDocInCurrentTab(const Rcl::Doc &idoc, int docnum)
setCurTabProps(idoc, docnum);
QString msg = QString("Loading: %1 (size %2 bytes)")
.arg(QString::fromLocal8Bit(idoc.url.c_str()))
.arg(QString::fromUtf8(idoc.fbytes.c_str()));
.arg(path2qs(idoc.url)).arg(u8s2qs(idoc.fbytes));
QProgressDialog progress(msg, tr("Cancel"), 0, 0, this);
progress.setMinimumDuration(2000);
@ -774,7 +773,7 @@ bool Preview::loadDocInCurrentTab(const Rcl::Doc &idoc, int docnum)
string path = fileurltolocalpath(idoc.url);
if (!path.empty()) {
path = path_getfather(path);
QStringList paths(QString::fromLocal8Bit(path.c_str()));
QStringList paths(path2qs(path));
editor->setSearchPaths(paths);
}
#endif
@ -1034,16 +1033,16 @@ void PreviewTextEdit::displayFields()
LOGDEB1("PreviewTextEdit::displayFields()\n");
QString txt = "<html><head></head><body>\n";
txt += "<b>" + QString::fromLocal8Bit(m_url.c_str());
txt += "<b>" + path2qs(m_url);
if (!m_ipath.empty())
txt += "|" + QString::fromUtf8(m_ipath.c_str());
txt += "|" + u8s2qs(m_ipath);
txt += "</b><br><br>";
txt += "<dl>\n";
for (const auto& entry: m_fdoc.meta) {
if (!entry.second.empty())
txt += "<dt>" + QString::fromUtf8(entry.first.c_str()) + "</dt> "
+ "<dd>" + QString::fromUtf8(escapeHtml(entry.second).c_str())
+ "</dd>\n";
if (!entry.second.empty()) {
txt += "<dt>" + u8s2qs(entry.first) + "</dt> "
+ "<dd>" + u8s2qs(escapeHtml(entry.second)) + "</dd>\n";
}
}
txt += "</dl></body></html>";
setHtml(txt);

View File

@ -48,7 +48,7 @@ void EditTrans::init(const string& dbdir)
connect(cancelPB, SIGNAL(clicked()), this, SLOT(close()));
QString lab = whatIdxLA->text();
lab.append(QString::fromLocal8Bit(m_dbdir.c_str()));
lab.append(path2qs(m_dbdir));
whatIdxLA->setText(lab);
QStringList labels(tr("Source path"));
@ -64,12 +64,10 @@ void EditTrans::init(const string& dbdir)
for (vector<string>::const_iterator it = opaths.begin();
it != opaths.end(); it++) {
transTW->setRowCount(row+1);
transTW->setItem(row, 0, new QTableWidgetItem(
QString::fromLocal8Bit(it->c_str())));
transTW->setItem(row, 0, new QTableWidgetItem(path2qs(*it)));
string npath;
conftrans->get(*it, npath, m_dbdir);
transTW->setItem(row, 1, new QTableWidgetItem(
QString::fromLocal8Bit(npath.c_str())));
transTW->setItem(row, 1, new QTableWidgetItem(path2qs(npath)));
row++;
}
@ -93,9 +91,9 @@ void EditTrans::on_savePB_clicked()
for (int row = 0; row < transTW->rowCount(); row++) {
QTableWidgetItem *item0 = transTW->item(row, 0);
string from = path_canon((const char *)item0->text().toLocal8Bit());
string from = path_canon(qs2path(item0->text()));
QTableWidgetItem *item1 = transTW->item(row, 1);
string to = path_canon((const char*)item1->text().toLocal8Bit());
string to = path_canon(qs2path(item1->text()));
conftrans->set(from, to, m_dbdir);
}
conftrans->holdWrites(false);

View File

@ -68,7 +68,7 @@ bool RclMain::containerUpToDate(Rcl::Doc& doc)
string sig;
if (!FileInterner::makesig(theconfig, doc, sig)) {
QMessageBox::warning(0, "Recoll", tr("Can't access file: ") +
QString::fromLocal8Bit(doc.url.c_str()));
path2qs(doc.url));
// Let's try the preview anyway...
return true;
}

View File

@ -30,6 +30,7 @@
#include "xmltosd.h"
#include "searchdata.h"
#include "copyfile.h"
#include "pathut.h"
using namespace std;
using namespace Rcl;
@ -42,9 +43,9 @@ static QString prevDir()
string defpath = path_cat(theconfig->getConfDir(), "saved_queries");
if (prevdir.isEmpty()) {
if (!path_exists(defpath)) {
mkdir(defpath.c_str(), 0700);
path_makepath(defpath, 0700);
}
return QString::fromLocal8Bit(defpath.c_str());
return path2qs(defpath);
} else {
return prevdir;
}
@ -86,7 +87,7 @@ void RclMain::saveLastQuery()
return;
}
string tofile((const char *)s.toLocal8Bit());
string tofile(qs2path(s));
// Work around qt 5.9-11 bug (linux at least): defaultSuffix is
// not added to saved file name
@ -113,7 +114,7 @@ void RclMain::loadSavedQuery()
if (s.isEmpty())
return;
string fromfile((const char *)s.toLocal8Bit());
string fromfile(qs2path(s));
string xml, reason;
if (!file_to_string(fromfile, xml, &reason)) {
QMessageBox::warning(this, tr("Read failed"),

View File

@ -126,11 +126,10 @@ void RclMain::openWith(Rcl::Doc doc, string cmdspec)
// Split the command line
vector<string> lcmd;
if (!stringToStrings(cmdspec, lcmd)) {
QMessageBox::warning(0, "Recoll",
tr("Bad desktop app spec for %1: [%2]\n"
"Please check the desktop file")
.arg(QString::fromUtf8(doc.mimetype.c_str()))
.arg(QString::fromLocal8Bit(cmdspec.c_str())));
QMessageBox::warning(
0, "Recoll", tr("Bad desktop app spec for %1: [%2]\n"
"Please check the desktop file")
.arg(u8s2qs(doc.mimetype)).arg(path2qs(cmdspec)));
return;
}
@ -192,11 +191,10 @@ void RclMain::startNativeViewer(Rcl::Doc doc, int pagenum, QString term)
// Split the command line
vector<string> lcmd;
if (!stringToStrings(cmd, lcmd)) {
QMessageBox::warning(0, "Recoll",
tr("Bad viewer command line for %1: [%2]\n"
"Please check the mimeview file")
.arg(QString::fromUtf8(doc.mimetype.c_str()))
.arg(QString::fromLocal8Bit(cmd.c_str())));
QMessageBox::warning(
0, "Recoll", tr("Bad viewer command line for %1: [%2]\n"
"Please check the mimeview file")
.arg(u8s2qs(doc.mimetype)).arg(path2qs(cmd)));
return;
}
@ -231,7 +229,7 @@ void RclMain::startNativeViewer(Rcl::Doc doc, int pagenum, QString term)
QString message = tr("The viewer specified in mimeview for %1: %2"
" is not found.\nDo you want to start the "
" preferences dialog ?")
.arg(mt).arg(QString::fromLocal8Bit(lcmd.front().c_str()));
.arg(mt).arg(path2qs(lcmd.front()));
switch(QMessageBox::warning(0, "Recoll", message,
"Yes", "No", 0, 0, 1)) {
@ -348,11 +346,9 @@ void RclMain::startNativeViewer(Rcl::Doc doc, int pagenum, QString term)
}
TempFile temp;
if (FileInterner::isCompressed(fn, theconfig)) {
if (!FileInterner::maybeUncompressToTemp(temp, fn, theconfig,
doc)) {
QMessageBox::warning(0, "Recoll",
tr("Can't uncompress file: ") +
QString::fromLocal8Bit(fn.c_str()));
if (!FileInterner::maybeUncompressToTemp(temp, fn, theconfig,doc)) {
QMessageBox::warning(
0, "Recoll", tr("Can't uncompress file: ") + path2qs(fn));
return;
}
}

View File

@ -345,7 +345,7 @@ void RclMain::showMissingHelpers()
tr("External applications/commands needed for your file types "
"and not found, as stored by the last indexing pass in ");
msg += "<i>";
msg += QString::fromLocal8Bit(theconfig->getConfDir().c_str());
msg += path2qs(theconfig->getConfDir());
msg += "/missing</i>:<pre>\n";
if (!miss.empty()) {
msg += QString::fromUtf8(miss.c_str());
@ -451,10 +451,9 @@ void RclMain::newDupsW(const Rcl::Doc, const vector<Rcl::Doc> dups)
for (vector<Rcl::Doc>::const_iterator it = dups.begin();
it != dups.end(); it++) {
if (it->ipath.empty())
editor->append(QString::fromLocal8Bit(it->url.c_str()));
editor->append(path2qs(it->url));
else
editor->append(QString::fromLocal8Bit(it->url.c_str()) + " | " +
QString::fromUtf8(it->ipath.c_str()));
editor->append(path2qs(it->url) + " | " + u8s2qs(it->ipath));
}
editor->moveCursor(QTextCursor::Start);
editor->ensureCursorVisible();

View File

@ -138,8 +138,7 @@ void RclMain::init()
// idxstatus file. Make sure it exists before trying to watch it
// (case where we're started on an older index, or if the status
// file was deleted since indexing)
QString idxfn =
QString::fromLocal8Bit(theconfig->getIdxStatusFile().c_str());
QString idxfn = path2qs(theconfig->getIdxStatusFile());
QFile qf(idxfn);
qf.open(QIODevice::ReadWrite);
qf.setPermissions(QFile::ReadOwner|QFile::WriteOwner);
@ -719,8 +718,7 @@ void RclMain::startSearch(std::shared_ptr<Rcl::SearchData> sdata, bool issimple)
}
if (prefs.synFileEnable && !prefs.synFile.isEmpty()) {
string sf = (const char *)prefs.synFile.toLocal8Bit();
if (!rcldb->setSynGroupsFile(sf)) {
if (!rcldb->setSynGroupsFile(qs2path(prefs.synFile))) {
QMessageBox::warning(0, "Recoll",
tr("Can't set synonyms file (parse error?)"));
return;
@ -932,12 +930,9 @@ void RclMain::on_actionSortByDateDesc_toggled(bool on)
void RclMain::saveDocToFile(Rcl::Doc doc)
{
QString s =
QFileDialog::getSaveFileName(this, //parent
tr("Save file"),
QString::fromLocal8Bit(path_home().c_str())
);
string tofile((const char *)s.toLocal8Bit());
QString s = QFileDialog::getSaveFileName(
this, tr("Save file"), path2qs(path_home()));
string tofile = qs2path(s);
TempFile temp; // not used because tofile is set.
if (!FileInterner::idocToFile(temp, tofile, theconfig, doc)) {
QMessageBox::warning(0, "Recoll",

View File

@ -59,6 +59,22 @@ inline QString u8s2qs(const std::string us)
{
return QString::fromUtf8(us.c_str());
}
inline QString path2qs(const std::string& us)
{
#ifdef _WIN32
return QString::fromUtf8(us.c_str());
#else
return QString::fromLocal8Bit(us.c_str());
#endif
}
inline std::string qs2path(const QString& qs)
{
#ifdef _WIN32
return qs2utf8s(qs);
#else
return (const char*)qs.toLocal8Bit();
#endif
}
/** Specialized version of the qt file dialog. Can't use getOpenFile()
etc. cause they hide dot files... */

View File

@ -29,12 +29,16 @@
namespace ResultPopup {
QMenu *create(QWidget *me, int opts, std::shared_ptr<DocSequence> source, Rcl::Doc& doc)
QMenu *create(QWidget *me, int opts, std::shared_ptr<DocSequence> source,
Rcl::Doc& doc)
{
QMenu *popup = new QMenu(me);
LOGDEB("ResultPopup::create: opts " << (opts) << " haspages " << (doc.haspages) << " " << (source ? "Source not null" : "Source is Null") << " " << (source ? (source->snippetsCapable() ?
"snippetsCapable" : "not snippetsCapable") : "") << "\n" );
LOGDEB("ResultPopup::create: opts " << opts << " haspages " <<
doc.haspages << " " <<(source ? "Source not null" : "Source is Null")
<< " " << (source ? (source->snippetsCapable() ?
"snippetsCapable" : "not snippetsCapable") : "")
<< "\n");
string apptag;
doc.getmeta(Rcl::Doc::keyapptg, &apptag);
@ -158,7 +162,7 @@ void copyFN(const Rcl::Doc &doc)
// conversion, but it's probably better (less worse...) to
// make a "best effort" tentative and try to convert from the
// locale's charset than accept the default conversion.
QString qfn = QString::fromLocal8Bit(doc.url.c_str()+7);
QString qfn = path2qs(doc.url.c_str()+7);
QApplication::clipboard()->setText(qfn, QClipboard::Selection);
QApplication::clipboard()->setText(qfn, QClipboard::Clipboard);
}

View File

@ -312,7 +312,7 @@ void SpellW::showStats()
resTW->setItem(row++, 1,
new QTableWidgetItem(QString::number(st.fileerrors)));
baseWordLE->setText(QString::fromLocal8Bit(theconfig->getDbDir().c_str()));
baseWordLE->setText(path2qs(theconfig->getDbDir()));
int64_t dbkbytes = fsTreeBytes(theconfig->getDbDir()) / 1024;
if (dbkbytes < 0) {

View File

@ -187,16 +187,16 @@ void UIPrefsDialog::setFromPrefs()
if (qssFile.isEmpty()) {
stylesheetPB->setText(tr("Choose"));
} else {
string nm = path_getsimple((const char *)qssFile.toLocal8Bit());
stylesheetPB->setText(QString::fromLocal8Bit(nm.c_str()));
string nm = path_getsimple(qs2path(qssFile));
stylesheetPB->setText(path2qs(nm));
}
snipCssFile = prefs.snipCssFile;
if (snipCssFile.isEmpty()) {
snipCssPB->setText(tr("Choose"));
} else {
string nm = path_getsimple((const char *)snipCssFile.toLocal8Bit());
snipCssPB->setText(QString::fromLocal8Bit(nm.c_str()));
string nm = path_getsimple(qs2path(snipCssFile));
snipCssPB->setText(path2qs(nm));
}
snipwMaxLenSB->setValue(prefs.snipwMaxLength);
snipwByPageCB->setChecked(prefs.snipwSortByPage);
@ -240,21 +240,21 @@ void UIPrefsDialog::setFromPrefs()
if (synFile.isEmpty()) {
synFilePB->setText(tr("Choose"));
} else {
string nm = path_getsimple((const char *)synFile.toLocal8Bit());
synFilePB->setText(QString::fromLocal8Bit(nm.c_str()));
string nm = path_getsimple(qs2path(synFile));
synFilePB->setText(path2qs(nm));
}
// Initialize the extra indexes listboxes
idxLV->clear();
for (const auto& dbdir : prefs.allExtraDbs) {
QListWidgetItem *item =
new QListWidgetItem(QString::fromLocal8Bit(dbdir.c_str()), idxLV);
new QListWidgetItem(path2qs(dbdir), idxLV);
if (item)
item->setCheckState(Qt::Unchecked);
}
for (const auto& dbdir : prefs.activeExtraDbs) {
auto items =
idxLV->findItems (QString::fromLocal8Bit(dbdir.c_str()),
idxLV->findItems(path2qs(dbdir),
Qt::MatchFixedString|Qt::MatchCaseSensitive);
for (auto& entry : items) {
entry->setCheckState(Qt::Checked);
@ -377,10 +377,9 @@ void UIPrefsDialog::accept()
for (int i = 0; i < idxLV->count(); i++) {
QListWidgetItem *item = idxLV->item(i);
if (item) {
prefs.allExtraDbs.push_back((const char *)item->text().toLocal8Bit());
prefs.allExtraDbs.push_back(qs2path(item->text()));
if (item->checkState() == Qt::Checked) {
prefs.activeExtraDbs.push_back((const char *)
item->text().toLocal8Bit());
prefs.activeExtraDbs.push_back(qs2path(item->text()));
}
}
}
@ -463,9 +462,9 @@ void UIPrefsDialog::showFontDialog()
void UIPrefsDialog::showStylesheetDialog()
{
qssFile = myGetFileName(false, "Select stylesheet file", true);
string nm = path_getsimple((const char *)qssFile.toLocal8Bit());
string nm = path_getsimple(qs2path(qssFile));
if (!nm.empty()) {
stylesheetPB->setText(QString::fromLocal8Bit(nm.c_str()));
stylesheetPB->setText(path2qs(nm));
} else {
stylesheetPB->setText(tr("Choose"));
}
@ -479,8 +478,8 @@ void UIPrefsDialog::resetStylesheet()
void UIPrefsDialog::showSnipCssDialog()
{
snipCssFile = myGetFileName(false, "Select snippets window CSS file", true);
string nm = path_getsimple((const char *)snipCssFile.toLocal8Bit());
snipCssPB->setText(QString::fromLocal8Bit(nm.c_str()));
string nm = path_getsimple(qs2path(snipCssFile));
snipCssPB->setText(path2qs(nm));
}
void UIPrefsDialog::resetSnipCss()
{
@ -493,8 +492,8 @@ void UIPrefsDialog::showSynFileDialog()
synFile = myGetFileName(false, "Select synonyms file", true);
if (synFile.isEmpty())
return;
string nm = path_getsimple((const char *)synFile.toLocal8Bit());
synFilePB->setText(QString::fromLocal8Bit(nm.c_str()));
string nm = path_getsimple(qs2path(synFile));
synFilePB->setText(path2qs(nm));
}
void UIPrefsDialog::resetReslistFont()
@ -539,7 +538,7 @@ void UIPrefsDialog::extraDbEditPtrans()
} else if (idxLV->selectedItems().size() == 1) {
QListWidgetItem *item = idxLV->selectedItems()[0];
QString qd = item->data(Qt::DisplayRole).toString();
dbdir = (const char *)qd.toLocal8Bit();
dbdir = qs2path(qd);
} else {
QMessageBox::warning(
0, "Recoll", tr("At most one index should be selected"));
@ -629,7 +628,7 @@ void UIPrefsDialog::addExtraDbPB_clicked()
if (input.isEmpty())
return;
string dbdir = (const char *)input.toLocal8Bit();
string dbdir = qs2path(input);
if (path_exists(path_cat(dbdir, "recoll.conf"))) {
// Chosen dir is config dir.
RclConfig conf(&dbdir);
@ -646,8 +645,8 @@ void UIPrefsDialog::addExtraDbPB_clicked()
LOGDEB("ExtraDbDial: got: [" << (dbdir) << "]\n" );
bool stripped;
if (!Rcl::Db::testDbDir(dbdir, &stripped)) {
QMessageBox::warning(0, "Recoll",
tr("The selected directory does not appear to be a Xapian index"));
QMessageBox::warning(0, "Recoll", tr("The selected directory does not "
"appear to be a Xapian index"));
return;
}
if (o_index_stripchars != stripped) {
@ -657,14 +656,13 @@ void UIPrefsDialog::addExtraDbPB_clicked()
return;
}
if (samedir(dbdir, theconfig->getDbDir())) {
QMessageBox::warning(0, "Recoll",
tr("This is the main/local index!"));
QMessageBox::warning(0, "Recoll", tr("This is the main/local index!"));
return;
}
for (int i = 0; i < idxLV->count(); i++) {
QListWidgetItem *item = idxLV->item(i);
string existingdir = (const char *)item->text().toLocal8Bit();
string existingdir = qs2path(item->text());
if (samedir(dbdir, existingdir)) {
QMessageBox::warning(
0, "Recoll", tr("The selected directory is already in the "
@ -673,8 +671,7 @@ void UIPrefsDialog::addExtraDbPB_clicked()
}
}
QListWidgetItem *item =
new QListWidgetItem(QString::fromLocal8Bit(dbdir.c_str()), idxLV);
QListWidgetItem *item = new QListWidgetItem(path2qs(dbdir), idxLV);
item->setCheckState(Qt::Checked);
idxLV->sortItems();
}