add pref to display Snippets link even if doc has no pages

This commit is contained in:
Jean-Francois Dockes 2020-03-11 10:44:49 +01:00
parent b00f7127a9
commit f141e35279
8 changed files with 185 additions and 168 deletions

View File

@ -243,6 +243,8 @@ void rwSettings(bool writing)
prefs.abssep = "…"; prefs.abssep = "…";
SETTING_RW(prefs.snipwMaxLength, "/Recoll/prefs/snipwin/maxlen", Int, 1000); SETTING_RW(prefs.snipwMaxLength, "/Recoll/prefs/snipwin/maxlen", Int, 1000);
SETTING_RW(prefs.snipwSortByPage,"/Recoll/prefs/snipwin/bypage", Bool,false); SETTING_RW(prefs.snipwSortByPage,"/Recoll/prefs/snipwin/bypage", Bool,false);
SETTING_RW(prefs.alwaysSnippets, "/Recoll/prefs/reslist/alwaysSnippets",
Bool,false);
SETTING_RW(prefs.autoSuffs, "/Recoll/prefs/query/autoSuffs", String, ""); SETTING_RW(prefs.autoSuffs, "/Recoll/prefs/query/autoSuffs", String, "");
SETTING_RW(prefs.autoSuffsEnable, SETTING_RW(prefs.autoSuffsEnable,

View File

@ -92,6 +92,8 @@ class PrefsPack {
int snipwMaxLength; int snipwMaxLength;
// Snippets window sort by page (dflt: by weight) // Snippets window sort by page (dflt: by weight)
bool snipwSortByPage; bool snipwSortByPage;
// Display Snippets links even for un-paged documents
bool alwaysSnippets;
bool startWithAdvSearchOpen{false}; bool startWithAdvSearchOpen{false};
// Try to display html if it exists in the internfile stack. // Try to display html if it exists in the internfile stack.
bool previewHtml; bool previewHtml;

View File

@ -128,8 +128,8 @@ bool RclWebPage::acceptNavigationRequest(const QUrl& url,
class QtGuiResListPager : public ResListPager { class QtGuiResListPager : public ResListPager {
public: public:
QtGuiResListPager(ResList *p, int ps) QtGuiResListPager(ResList *p, int ps, bool alwayssnip)
: ResListPager(ps), m_reslist(p) : ResListPager(ps, alwayssnip), m_reslist(p)
{} {}
virtual bool append(const string& data); virtual bool append(const string& data);
virtual bool append(const string& data, int idx, const Rcl::Doc& doc); virtual bool append(const string& data, int idx, const Rcl::Doc& doc);
@ -391,7 +391,7 @@ ResList::ResList(QWidget* parent, const char* name)
connect(this, SIGNAL(customContextMenuRequested(const QPoint&)), connect(this, SIGNAL(customContextMenuRequested(const QPoint&)),
this, SLOT(createPopupMenu(const QPoint&))); this, SLOT(createPopupMenu(const QPoint&)));
m_pager = new QtGuiResListPager(this, prefs.respagesize); m_pager = new QtGuiResListPager(this, prefs.respagesize, prefs.alwaysSnippets);
m_pager->setHighLighter(&g_hiliter); m_pager->setHighLighter(&g_hiliter);
} }

View File

@ -76,7 +76,7 @@ static PlainToRichQtReslist g_hiliter;
class ResTablePager : public ResListPager { class ResTablePager : public ResListPager {
public: public:
ResTablePager(ResTable *p) ResTablePager(ResTable *p)
: ResListPager(1), m_parent(p) : ResListPager(1, prefs.alwaysSnippets), m_parent(p)
{} {}
virtual bool append(const string& data, int idx, const Rcl::Doc& doc); virtual bool append(const string& data, int idx, const Rcl::Doc& doc);
virtual string trans(const string& in); virtual string trans(const string& in);

View File

@ -624,6 +624,16 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QCheckBox" name="alwaysSnippetsCB">
<property name="text">
<string>Display a Snippets link even if the document has no pages (needs restart).</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
<item> <item>

View File

@ -77,27 +77,27 @@ void UIPrefsDialog::init()
connect(resetSnipCssPB, SIGNAL(clicked()), this, SLOT(resetSnipCss())); connect(resetSnipCssPB, SIGNAL(clicked()), this, SLOT(resetSnipCss()));
connect(idxLV, SIGNAL(itemSelectionChanged()), connect(idxLV, SIGNAL(itemSelectionChanged()),
this, SLOT(extradDbSelectChanged())); this, SLOT(extradDbSelectChanged()));
connect(ptransPB, SIGNAL(clicked()), connect(ptransPB, SIGNAL(clicked()),
this, SLOT(extraDbEditPtrans())); this, SLOT(extraDbEditPtrans()));
connect(addExtraDbPB, SIGNAL(clicked()), connect(addExtraDbPB, SIGNAL(clicked()),
this, SLOT(addExtraDbPB_clicked())); this, SLOT(addExtraDbPB_clicked()));
connect(delExtraDbPB, SIGNAL(clicked()), connect(delExtraDbPB, SIGNAL(clicked()),
this, SLOT(delExtraDbPB_clicked())); this, SLOT(delExtraDbPB_clicked()));
connect(togExtraDbPB, SIGNAL(clicked()), connect(togExtraDbPB, SIGNAL(clicked()),
this, SLOT(togExtraDbPB_clicked())); this, SLOT(togExtraDbPB_clicked()));
connect(actAllExtraDbPB, SIGNAL(clicked()), connect(actAllExtraDbPB, SIGNAL(clicked()),
this, SLOT(actAllExtraDbPB_clicked())); this, SLOT(actAllExtraDbPB_clicked()));
connect(unacAllExtraDbPB, SIGNAL(clicked()), connect(unacAllExtraDbPB, SIGNAL(clicked()),
this, SLOT(unacAllExtraDbPB_clicked())); this, SLOT(unacAllExtraDbPB_clicked()));
connect(CLEditPara, SIGNAL(clicked()), this, SLOT(editParaFormat())); connect(CLEditPara, SIGNAL(clicked()), this, SLOT(editParaFormat()));
connect(CLEditHeader, SIGNAL(clicked()), this, SLOT(editHeaderText())); connect(CLEditHeader, SIGNAL(clicked()), this, SLOT(editHeaderText()));
connect(buttonOk, SIGNAL(clicked()), this, SLOT(accept())); connect(buttonOk, SIGNAL(clicked()), this, SLOT(accept()));
connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject())); connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject()));
connect(buildAbsCB, SIGNAL(toggled(bool)), connect(buildAbsCB, SIGNAL(toggled(bool)),
replAbsCB, SLOT(setEnabled(bool))); replAbsCB, SLOT(setEnabled(bool)));
connect(ssNoCompleteCB, SIGNAL(toggled(bool)), connect(ssNoCompleteCB, SIGNAL(toggled(bool)),
ssSearchOnCompleteCB, SLOT(setDisabled(bool))); ssSearchOnCompleteCB, SLOT(setDisabled(bool)));
setFromPrefs(); setFromPrefs();
} }
@ -115,22 +115,22 @@ void UIPrefsDialog::setFromPrefs()
maxHLTSB->setValue(prefs.maxhltextmbs); maxHLTSB->setValue(prefs.maxhltextmbs);
if (prefs.ssearchTypSav) { if (prefs.ssearchTypSav) {
ssearchTypCMB->setCurrentIndex(4); ssearchTypCMB->setCurrentIndex(4);
} else { } else {
ssearchTypCMB->setCurrentIndex(prefs.ssearchTyp); ssearchTypCMB->setCurrentIndex(prefs.ssearchTyp);
} }
switch (prefs.filterCtlStyle) { switch (prefs.filterCtlStyle) {
case PrefsPack::FCS_MN: case PrefsPack::FCS_MN:
filterMN_RB->setChecked(1); filterMN_RB->setChecked(1);
break; break;
case PrefsPack::FCS_CMB: case PrefsPack::FCS_CMB:
filterCMB_RB->setChecked(1); filterCMB_RB->setChecked(1);
break; break;
case PrefsPack::FCS_BT: case PrefsPack::FCS_BT:
default: default:
filterBT_RB->setChecked(1); filterBT_RB->setChecked(1);
break; break;
} }
noBeepsCB->setChecked(prefs.noBeeps); noBeepsCB->setChecked(prefs.noBeeps);
ssNoCompleteCB->setChecked(prefs.ssearchNoComplete); ssNoCompleteCB->setChecked(prefs.ssearchNoComplete);
@ -161,15 +161,15 @@ void UIPrefsDialog::setFromPrefs()
previewActiveLinksCB->setChecked(prefs.previewActiveLinks); previewActiveLinksCB->setChecked(prefs.previewActiveLinks);
switch (prefs.previewPlainPre) { switch (prefs.previewPlainPre) {
case PrefsPack::PP_BR: case PrefsPack::PP_BR:
plainBRRB->setChecked(1); plainBRRB->setChecked(1);
break; break;
case PrefsPack::PP_PRE: case PrefsPack::PP_PRE:
plainPRERB->setChecked(1); plainPRERB->setChecked(1);
break; break;
case PrefsPack::PP_PREWRAP: case PrefsPack::PP_PREWRAP:
default: default:
plainPREWRAPRB->setChecked(1); plainPREWRAPRB->setChecked(1);
break; break;
} }
// Query terms color // Query terms color
qtermStyleLE->setText(prefs.qtermstyle); qtermStyleLE->setText(prefs.qtermstyle);
@ -185,21 +185,22 @@ void UIPrefsDialog::setFromPrefs()
// Style sheet // Style sheet
qssFile = prefs.qssFile; qssFile = prefs.qssFile;
if (qssFile.isEmpty()) { if (qssFile.isEmpty()) {
stylesheetPB->setText(tr("Choose")); stylesheetPB->setText(tr("Choose"));
} else { } else {
string nm = path_getsimple((const char *)qssFile.toLocal8Bit()); string nm = path_getsimple((const char *)qssFile.toLocal8Bit());
stylesheetPB->setText(QString::fromLocal8Bit(nm.c_str())); stylesheetPB->setText(QString::fromLocal8Bit(nm.c_str()));
} }
snipCssFile = prefs.snipCssFile; snipCssFile = prefs.snipCssFile;
if (snipCssFile.isEmpty()) { if (snipCssFile.isEmpty()) {
snipCssPB->setText(tr("Choose")); snipCssPB->setText(tr("Choose"));
} else { } else {
string nm = path_getsimple((const char *)snipCssFile.toLocal8Bit()); string nm = path_getsimple((const char *)snipCssFile.toLocal8Bit());
snipCssPB->setText(QString::fromLocal8Bit(nm.c_str())); snipCssPB->setText(QString::fromLocal8Bit(nm.c_str()));
} }
snipwMaxLenSB->setValue(prefs.snipwMaxLength); snipwMaxLenSB->setValue(prefs.snipwMaxLength);
snipwByPageCB->setChecked(prefs.snipwSortByPage); snipwByPageCB->setChecked(prefs.snipwSortByPage);
alwaysSnippetsCB->setChecked(prefs.alwaysSnippets);
paraFormat = prefs.reslistformat; paraFormat = prefs.reslistformat;
headerText = prefs.reslistheadertext; headerText = prefs.reslistheadertext;
@ -209,18 +210,18 @@ void UIPrefsDialog::setFromPrefs()
stemLangCMB->addItem(g_stringAllStem); stemLangCMB->addItem(g_stringAllStem);
vector<string> langs; vector<string> langs;
if (!getStemLangs(langs)) { if (!getStemLangs(langs)) {
QMessageBox::warning(0, "Recoll", QMessageBox::warning(0, "Recoll",
tr("error retrieving stemming languages")); tr("error retrieving stemming languages"));
} }
int cur = prefs.queryStemLang == "" ? 0 : 1; int cur = prefs.queryStemLang == "" ? 0 : 1;
for (vector<string>::const_iterator it = langs.begin(); for (vector<string>::const_iterator it = langs.begin();
it != langs.end(); it++) { it != langs.end(); it++) {
stemLangCMB-> stemLangCMB->
addItem(QString::fromUtf8(it->c_str(), it->length())); addItem(QString::fromUtf8(it->c_str(), it->length()));
if (cur == 0 && !strcmp((const char*)prefs.queryStemLang.toUtf8(), if (cur == 0 && !strcmp((const char*)prefs.queryStemLang.toUtf8(),
it->c_str())) { it->c_str())) {
cur = stemLangCMB->count(); cur = stemLangCMB->count();
} }
} }
stemLangCMB->setCurrentIndex(cur); stemLangCMB->setCurrentIndex(cur);
@ -237,27 +238,27 @@ void UIPrefsDialog::setFromPrefs()
synFileCB->setChecked(prefs.synFileEnable); synFileCB->setChecked(prefs.synFileEnable);
synFile = prefs.synFile; synFile = prefs.synFile;
if (synFile.isEmpty()) { if (synFile.isEmpty()) {
synFilePB->setText(tr("Choose")); synFilePB->setText(tr("Choose"));
} else { } else {
string nm = path_getsimple((const char *)synFile.toLocal8Bit()); string nm = path_getsimple((const char *)synFile.toLocal8Bit());
synFilePB->setText(QString::fromLocal8Bit(nm.c_str())); synFilePB->setText(QString::fromLocal8Bit(nm.c_str()));
} }
// Initialize the extra indexes listboxes // Initialize the extra indexes listboxes
idxLV->clear(); idxLV->clear();
for (const auto& dbdir : prefs.allExtraDbs) { for (const auto& dbdir : prefs.allExtraDbs) {
QListWidgetItem *item = QListWidgetItem *item =
new QListWidgetItem(QString::fromLocal8Bit(dbdir.c_str()), idxLV); new QListWidgetItem(QString::fromLocal8Bit(dbdir.c_str()), idxLV);
if (item) if (item)
item->setCheckState(Qt::Unchecked); item->setCheckState(Qt::Unchecked);
} }
for (const auto& dbdir : prefs.activeExtraDbs) { for (const auto& dbdir : prefs.activeExtraDbs) {
auto items = auto items =
idxLV->findItems (QString::fromLocal8Bit(dbdir.c_str()), idxLV->findItems (QString::fromLocal8Bit(dbdir.c_str()),
Qt::MatchFixedString|Qt::MatchCaseSensitive); Qt::MatchFixedString|Qt::MatchCaseSensitive);
for (auto& entry : items) { for (auto& entry : items) {
entry->setCheckState(Qt::Checked); entry->setCheckState(Qt::Checked);
} }
} }
idxLV->sortItems(); idxLV->sortItems();
} }
@ -266,10 +267,10 @@ void UIPrefsDialog::setupReslistFontPB()
{ {
QString s; QString s;
if (reslistFontFamily.length() == 0) { if (reslistFontFamily.length() == 0) {
reslistFontPB->setText(tr("Default QtWebkit font")); reslistFontPB->setText(tr("Default QtWebkit font"));
} else { } else {
reslistFontPB->setText(reslistFontFamily + "-" + reslistFontPB->setText(reslistFontFamily + "-" +
s.setNum(reslistFontSize)); s.setNum(reslistFontSize));
} }
} }
@ -283,20 +284,20 @@ void UIPrefsDialog::accept()
prefs.ssearchStartOnComplete = ssSearchOnCompleteCB->isChecked(); prefs.ssearchStartOnComplete = ssSearchOnCompleteCB->isChecked();
if (ssearchTypCMB->currentIndex() == 4) { if (ssearchTypCMB->currentIndex() == 4) {
prefs.ssearchTypSav = true; prefs.ssearchTypSav = true;
// prefs.ssearchTyp will be set from the current value when // prefs.ssearchTyp will be set from the current value when
// exiting the program // exiting the program
} else { } else {
prefs.ssearchTypSav = false; prefs.ssearchTypSav = false;
prefs.ssearchTyp = ssearchTypCMB->currentIndex(); prefs.ssearchTyp = ssearchTypCMB->currentIndex();
} }
if (filterMN_RB->isChecked()) { if (filterMN_RB->isChecked()) {
prefs.filterCtlStyle = PrefsPack::FCS_MN; prefs.filterCtlStyle = PrefsPack::FCS_MN;
} else if (filterCMB_RB->isChecked()) { } else if (filterCMB_RB->isChecked()) {
prefs.filterCtlStyle = PrefsPack::FCS_CMB; prefs.filterCtlStyle = PrefsPack::FCS_CMB;
} else { } else {
prefs.filterCtlStyle = PrefsPack::FCS_BT; prefs.filterCtlStyle = PrefsPack::FCS_BT;
} }
m_mainWindow->setFilterCtlStyle(prefs.filterCtlStyle); m_mainWindow->setFilterCtlStyle(prefs.filterCtlStyle);
@ -318,26 +319,27 @@ void UIPrefsDialog::accept()
prefs.reslistformat = paraFormat; prefs.reslistformat = paraFormat;
prefs.reslistheadertext = headerText; prefs.reslistheadertext = headerText;
if (prefs.reslistformat.trimmed().isEmpty()) { if (prefs.reslistformat.trimmed().isEmpty()) {
prefs.reslistformat = prefs.dfltResListFormat; prefs.reslistformat = prefs.dfltResListFormat;
paraFormat = prefs.reslistformat; paraFormat = prefs.reslistformat;
} }
prefs.snipwMaxLength = snipwMaxLenSB->value(); prefs.snipwMaxLength = snipwMaxLenSB->value();
prefs.snipwSortByPage = snipwByPageCB->isChecked(); prefs.snipwSortByPage = snipwByPageCB->isChecked();
prefs.alwaysSnippets = alwaysSnippetsCB->isChecked();
prefs.creslistformat = (const char*)prefs.reslistformat.toUtf8(); prefs.creslistformat = (const char*)prefs.reslistformat.toUtf8();
if (stemLangCMB->currentIndex() == 0) { if (stemLangCMB->currentIndex() == 0) {
prefs.queryStemLang = ""; prefs.queryStemLang = "";
} else if (stemLangCMB->currentIndex() == 1) { } else if (stemLangCMB->currentIndex() == 1) {
prefs.queryStemLang = "ALL"; prefs.queryStemLang = "ALL";
} else { } else {
prefs.queryStemLang = stemLangCMB->currentText(); prefs.queryStemLang = stemLangCMB->currentText();
} }
prefs.ssearchAutoPhrase = autoPhraseCB->isChecked(); prefs.ssearchAutoPhrase = autoPhraseCB->isChecked();
prefs.ssearchAutoPhraseThreshPC = autoPThreshSB->value(); prefs.ssearchAutoPhraseThreshPC = autoPThreshSB->value();
prefs.queryBuildAbstract = buildAbsCB->isChecked(); prefs.queryBuildAbstract = buildAbsCB->isChecked();
prefs.queryReplaceAbstract = buildAbsCB->isChecked() && prefs.queryReplaceAbstract = buildAbsCB->isChecked() &&
replAbsCB->isChecked(); replAbsCB->isChecked();
prefs.startWithAdvSearchOpen = initStartAdvCB->isChecked(); prefs.startWithAdvSearchOpen = initStartAdvCB->isChecked();
@ -354,11 +356,11 @@ void UIPrefsDialog::accept()
prefs.previewActiveLinks = previewActiveLinksCB->isChecked(); prefs.previewActiveLinks = previewActiveLinksCB->isChecked();
if (plainBRRB->isChecked()) { if (plainBRRB->isChecked()) {
prefs.previewPlainPre = PrefsPack::PP_BR; prefs.previewPlainPre = PrefsPack::PP_BR;
} else if (plainPRERB->isChecked()) { } else if (plainPRERB->isChecked()) {
prefs.previewPlainPre = PrefsPack::PP_PRE; prefs.previewPlainPre = PrefsPack::PP_PRE;
} else { } else {
prefs.previewPlainPre = PrefsPack::PP_PREWRAP; prefs.previewPlainPre = PrefsPack::PP_PREWRAP;
} }
prefs.syntAbsLen = syntlenSB->value(); prefs.syntAbsLen = syntlenSB->value();
@ -373,14 +375,14 @@ void UIPrefsDialog::accept()
prefs.allExtraDbs.clear(); prefs.allExtraDbs.clear();
prefs.activeExtraDbs.clear(); prefs.activeExtraDbs.clear();
for (int i = 0; i < idxLV->count(); i++) { for (int i = 0; i < idxLV->count(); i++) {
QListWidgetItem *item = idxLV->item(i); QListWidgetItem *item = idxLV->item(i);
if (item) { if (item) {
prefs.allExtraDbs.push_back((const char *)item->text().toLocal8Bit()); prefs.allExtraDbs.push_back((const char *)item->text().toLocal8Bit());
if (item->checkState() == Qt::Checked) { if (item->checkState() == Qt::Checked) {
prefs.activeExtraDbs.push_back((const char *) prefs.activeExtraDbs.push_back((const char *)
item->text().toLocal8Bit()); item->text().toLocal8Bit());
} }
} }
} }
rwSettings(true); rwSettings(true);
@ -394,11 +396,11 @@ void UIPrefsDialog::editParaFormat()
{ {
EditDialog dialog(this); EditDialog dialog(this);
dialog.setWindowTitle(tr("Result list paragraph format " dialog.setWindowTitle(tr("Result list paragraph format "
"(erase all to reset to default)")); "(erase all to reset to default)"));
dialog.plainTextEdit->setPlainText(paraFormat); dialog.plainTextEdit->setPlainText(paraFormat);
int result = dialog.exec(); int result = dialog.exec();
if (result == QDialog::Accepted) if (result == QDialog::Accepted)
paraFormat = dialog.plainTextEdit->toPlainText(); paraFormat = dialog.plainTextEdit->toPlainText();
} }
void UIPrefsDialog::editHeaderText() void UIPrefsDialog::editHeaderText()
@ -408,7 +410,7 @@ void UIPrefsDialog::editHeaderText()
dialog.plainTextEdit->setPlainText(headerText); dialog.plainTextEdit->setPlainText(headerText);
int result = dialog.exec(); int result = dialog.exec();
if (result == QDialog::Accepted) if (result == QDialog::Accepted)
headerText = dialog.plainTextEdit->toPlainText(); headerText = dialog.plainTextEdit->toPlainText();
} }
void UIPrefsDialog::reject() void UIPrefsDialog::reject()
@ -421,16 +423,16 @@ void UIPrefsDialog::setStemLang(const QString& lang)
{ {
int cur = 0; int cur = 0;
if (lang == "") { if (lang == "") {
cur = 0; cur = 0;
} else if (lang == "ALL") { } else if (lang == "ALL") {
cur = 1; cur = 1;
} else { } else {
for (int i = 1; i < stemLangCMB->count(); i++) { for (int i = 1; i < stemLangCMB->count(); i++) {
if (lang == stemLangCMB->itemText(i)) { if (lang == stemLangCMB->itemText(i)) {
cur = i; cur = i;
break; break;
} }
} }
} }
stemLangCMB->setCurrentIndex(cur); stemLangCMB->setCurrentIndex(cur);
} }
@ -440,18 +442,18 @@ void UIPrefsDialog::showFontDialog()
bool ok; bool ok;
QFont font; QFont font;
if (prefs.reslistfontfamily.length()) { if (prefs.reslistfontfamily.length()) {
font.setFamily(prefs.reslistfontfamily); font.setFamily(prefs.reslistfontfamily);
font.setPointSize(prefs.reslistfontsize); font.setPointSize(prefs.reslistfontsize);
} }
font = QFontDialog::getFont(&ok, font, this); font = QFontDialog::getFont(&ok, font, this);
if (ok) { if (ok) {
// We used to check if the default font was set, in which case // We used to check if the default font was set, in which case
// we erased the preference, but this would result in letting // we erased the preference, but this would result in letting
// webkit make a choice of default font which it usually seems // webkit make a choice of default font which it usually seems
// to do wrong. So now always set the font. There is still a // to do wrong. So now always set the font. There is still a
// way for the user to let webkit choose the default though: // way for the user to let webkit choose the default though:
// click reset, then the font name and size will be empty. // click reset, then the font name and size will be empty.
reslistFontFamily = font.family(); reslistFontFamily = font.family();
reslistFontSize = font.pointSize(); reslistFontSize = font.pointSize();
setupReslistFontPB(); setupReslistFontPB();
@ -505,10 +507,10 @@ void UIPrefsDialog::resetReslistFont()
void UIPrefsDialog::showViewAction() void UIPrefsDialog::showViewAction()
{ {
if (m_viewAction== 0) { if (m_viewAction== 0) {
m_viewAction = new ViewAction(0); m_viewAction = new ViewAction(0);
} else { } else {
// Close and reopen, in hope that makes us visible... // Close and reopen, in hope that makes us visible...
m_viewAction->close(); m_viewAction->close();
} }
m_viewAction->show(); m_viewAction->show();
} }
@ -524,24 +526,24 @@ void UIPrefsDialog::showViewAction(const QString& mt)
void UIPrefsDialog::extradDbSelectChanged() void UIPrefsDialog::extradDbSelectChanged()
{ {
if (idxLV->selectedItems().size() <= 1) if (idxLV->selectedItems().size() <= 1)
ptransPB->setEnabled(true); ptransPB->setEnabled(true);
else else
ptransPB->setEnabled(false); ptransPB->setEnabled(false);
} }
void UIPrefsDialog::extraDbEditPtrans() void UIPrefsDialog::extraDbEditPtrans()
{ {
string dbdir; string dbdir;
if (idxLV->selectedItems().size() == 0) { if (idxLV->selectedItems().size() == 0) {
dbdir = theconfig->getDbDir(); dbdir = theconfig->getDbDir();
} else if (idxLV->selectedItems().size() == 1) { } else if (idxLV->selectedItems().size() == 1) {
QListWidgetItem *item = idxLV->selectedItems()[0]; QListWidgetItem *item = idxLV->selectedItems()[0];
QString qd = item->data(Qt::DisplayRole).toString(); QString qd = item->data(Qt::DisplayRole).toString();
dbdir = (const char *)qd.toLocal8Bit(); dbdir = (const char *)qd.toLocal8Bit();
} else { } else {
QMessageBox::warning( QMessageBox::warning(
0, "Recoll", tr("At most one index should be selected")); 0, "Recoll", tr("At most one index should be selected"));
return; return;
} }
dbdir = path_canon(dbdir); dbdir = path_canon(dbdir);
EditTrans *etrans = new EditTrans(dbdir, this); EditTrans *etrans = new EditTrans(dbdir, this);
@ -551,28 +553,28 @@ void UIPrefsDialog::extraDbEditPtrans()
void UIPrefsDialog::togExtraDbPB_clicked() void UIPrefsDialog::togExtraDbPB_clicked()
{ {
for (int i = 0; i < idxLV->count(); i++) { for (int i = 0; i < idxLV->count(); i++) {
QListWidgetItem *item = idxLV->item(i); QListWidgetItem *item = idxLV->item(i);
if (item->isSelected()) { if (item->isSelected()) {
if (item->checkState() == Qt::Checked) { if (item->checkState() == Qt::Checked) {
item->setCheckState(Qt::Unchecked); item->setCheckState(Qt::Unchecked);
} else { } else {
item->setCheckState(Qt::Checked); item->setCheckState(Qt::Checked);
} }
} }
} }
} }
void UIPrefsDialog::actAllExtraDbPB_clicked() void UIPrefsDialog::actAllExtraDbPB_clicked()
{ {
for (int i = 0; i < idxLV->count(); i++) { for (int i = 0; i < idxLV->count(); i++) {
QListWidgetItem *item = idxLV->item(i); QListWidgetItem *item = idxLV->item(i);
item->setCheckState(Qt::Checked); item->setCheckState(Qt::Checked);
} }
} }
void UIPrefsDialog::unacAllExtraDbPB_clicked() void UIPrefsDialog::unacAllExtraDbPB_clicked()
{ {
for (int i = 0; i < idxLV->count(); i++) { for (int i = 0; i < idxLV->count(); i++) {
QListWidgetItem *item = idxLV->item(i); QListWidgetItem *item = idxLV->item(i);
item->setCheckState(Qt::Unchecked); item->setCheckState(Qt::Unchecked);
} }
} }
@ -580,8 +582,8 @@ void UIPrefsDialog::delExtraDbPB_clicked()
{ {
QList<QListWidgetItem *> items = idxLV->selectedItems(); QList<QListWidgetItem *> items = idxLV->selectedItems();
for (QList<QListWidgetItem *>::iterator it = items.begin(); for (QList<QListWidgetItem *>::iterator it = items.begin();
it != items.end(); it++) { it != items.end(); it++) {
delete *it; delete *it;
} }
} }
@ -592,11 +594,11 @@ static bool samedir(const string& dir1, const string& dir2)
#else #else
struct stat st1, st2; struct stat st1, st2;
if (stat(dir1.c_str(), &st1)) if (stat(dir1.c_str(), &st1))
return false; return false;
if (stat(dir2.c_str(), &st2)) if (stat(dir2.c_str(), &st2))
return false; return false;
if (st1.st_dev == st2.st_dev && st1.st_ino == st2.st_ino) { if (st1.st_dev == st2.st_dev && st1.st_ino == st2.st_ino) {
return true; return true;
} }
return false; return false;
#endif #endif
@ -620,60 +622,59 @@ void UIPrefsDialog::on_showTrayIconCB_clicked()
void UIPrefsDialog::addExtraDbPB_clicked() void UIPrefsDialog::addExtraDbPB_clicked()
{ {
QString input = myGetFileName(true, QString input = myGetFileName(true,
tr("Select recoll config directory or " tr("Select recoll config directory or "
"xapian index directory " "xapian index directory "
"(e.g.: /home/me/.recoll or " "(e.g.: /home/me/.recoll or "
"/home/me/.recoll/xapiandb)")); "/home/me/.recoll/xapiandb)"));
if (input.isEmpty()) if (input.isEmpty())
return; return;
string dbdir = (const char *)input.toLocal8Bit(); string dbdir = (const char *)input.toLocal8Bit();
if (path_exists(path_cat(dbdir, "recoll.conf"))) { if (path_exists(path_cat(dbdir, "recoll.conf"))) {
// Chosen dir is config dir. // Chosen dir is config dir.
RclConfig conf(&dbdir); RclConfig conf(&dbdir);
dbdir = conf.getDbDir(); dbdir = conf.getDbDir();
if (dbdir.empty()) { if (dbdir.empty()) {
QMessageBox::warning( QMessageBox::warning(
0, "Recoll", tr("The selected directory looks like a Recoll " 0, "Recoll", tr("The selected directory looks like a Recoll "
"configuration directory but the configuration " "configuration directory but the configuration "
"could not be read")); "could not be read"));
return; return;
} }
} }
LOGDEB("ExtraDbDial: got: [" << (dbdir) << "]\n" ); LOGDEB("ExtraDbDial: got: [" << (dbdir) << "]\n" );
bool stripped; bool stripped;
if (!Rcl::Db::testDbDir(dbdir, &stripped)) { if (!Rcl::Db::testDbDir(dbdir, &stripped)) {
QMessageBox::warning(0, "Recoll", QMessageBox::warning(0, "Recoll",
tr("The selected directory does not appear to be a Xapian index")); tr("The selected directory does not appear to be a Xapian index"));
return; return;
} }
if (o_index_stripchars != stripped) { if (o_index_stripchars != stripped) {
QMessageBox::warning(0, "Recoll", QMessageBox::warning(0, "Recoll",
tr("Cant add index with different case/diacritics" tr("Cant add index with different case/diacritics"
" stripping option")); " stripping option"));
return; return;
} }
if (samedir(dbdir, theconfig->getDbDir())) { if (samedir(dbdir, theconfig->getDbDir())) {
QMessageBox::warning(0, "Recoll", QMessageBox::warning(0, "Recoll",
tr("This is the main/local index!")); tr("This is the main/local index!"));
return; return;
} }
for (int i = 0; i < idxLV->count(); i++) { for (int i = 0; i < idxLV->count(); i++) {
QListWidgetItem *item = idxLV->item(i); QListWidgetItem *item = idxLV->item(i);
string existingdir = (const char *)item->text().toLocal8Bit(); string existingdir = (const char *)item->text().toLocal8Bit();
if (samedir(dbdir, existingdir)) { if (samedir(dbdir, existingdir)) {
QMessageBox::warning( QMessageBox::warning(
0, "Recoll", tr("The selected directory is already in the " 0, "Recoll", tr("The selected directory is already in the "
"index list")); "index list"));
return; return;
} }
} }
QListWidgetItem *item = QListWidgetItem *item =
new QListWidgetItem(QString::fromLocal8Bit(dbdir.c_str()), idxLV); new QListWidgetItem(QString::fromLocal8Bit(dbdir.c_str()), idxLV);
item->setCheckState(Qt::Checked); item->setCheckState(Qt::Checked);
idxLV->sortItems(); idxLV->sortItems();
} }

View File

@ -53,8 +53,9 @@ public:
}; };
static PlainToRichHtReslist g_hiliter; static PlainToRichHtReslist g_hiliter;
ResListPager::ResListPager(int pagesize) ResListPager::ResListPager(int pagesize, bool alwaysSnippets)
: m_pagesize(pagesize), : m_pagesize(pagesize),
m_alwaysSnippets(alwaysSnippets),
m_newpagesize(pagesize), m_newpagesize(pagesize),
m_resultsInCurrentPage(0), m_resultsInCurrentPage(0),
m_winfirst(-1), m_winfirst(-1),
@ -257,7 +258,7 @@ void ResListPager::displayDoc(RclConfig *config, int i, Rcl::Doc& doc,
<< trans("Open") << "</a>"; << trans("Open") << "</a>";
} }
ostringstream snipsbuf; ostringstream snipsbuf;
if (doc.haspages) { if (m_alwaysSnippets || doc.haspages) {
snipsbuf << "<a href=\"" <<linkPrefix()<<"A" << docnumforlinks << "\">" snipsbuf << "<a href=\"" <<linkPrefix()<<"A" << docnumforlinks << "\">"
<< trans("Snippets") << "</a>&nbsp;&nbsp;"; << trans("Snippets") << "</a>&nbsp;&nbsp;";
linksbuf << "&nbsp;&nbsp;" << snipsbuf.str(); linksbuf << "&nbsp;&nbsp;" << snipsbuf.str();

View File

@ -33,7 +33,7 @@ class PlainToRich;
*/ */
class ResListPager { class ResListPager {
public: public:
ResListPager(int pagesize=10); ResListPager(int pagesize=10, bool alwaysSnippets = false);
virtual ~ResListPager() {} virtual ~ResListPager() {}
void setHighLighter(PlainToRich *ptr) { void setHighLighter(PlainToRich *ptr) {
@ -118,6 +118,7 @@ public:
virtual string linkPrefix() {return "";} virtual string linkPrefix() {return "";}
private: private:
int m_pagesize; int m_pagesize;
bool m_alwaysSnippets;
int m_newpagesize; int m_newpagesize;
int m_resultsInCurrentPage; int m_resultsInCurrentPage;
// First docnum (from docseq) in current page // First docnum (from docseq) in current page