mode 700 on .recoll. move showquerydetails to rclreslist

This commit is contained in:
dockes 2006-04-20 09:20:10 +00:00
parent 48f415a25c
commit f15b278194
13 changed files with 115 additions and 113 deletions

View File

@ -1,5 +1,5 @@
#ifndef lint #ifndef lint
static char rcsid[] = "@(#$Id: rclconfig.cpp,v 1.27 2006-04-03 11:43:07 dockes Exp $ (C) 2004 J.F.Dockes"; static char rcsid[] = "@(#$Id: rclconfig.cpp,v 1.28 2006-04-20 09:20:09 dockes Exp $ (C) 2004 J.F.Dockes";
#endif #endif
/* /*
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -358,8 +358,10 @@ bool RclConfig::initUserConfig()
string exdir = path_cat(m_datadir, "examples"); string exdir = path_cat(m_datadir, "examples");
sprintf(blurb, blurb0, exdir.c_str()); sprintf(blurb, blurb0, exdir.c_str());
// Use protective 700 mode to create the top configuration
// directory: documents can be reconstructed from index data.
if (access(m_confdir.c_str(), 0) < 0 && if (access(m_confdir.c_str(), 0) < 0 &&
mkdir(m_confdir.c_str(), 0755) < 0) { mkdir(m_confdir.c_str(), 0700) < 0) {
m_reason += string("mkdir(") + m_confdir + ") failed: " + m_reason += string("mkdir(") + m_confdir + ") failed: " +
strerror(errno); strerror(errno);
return false; return false;

View File

@ -1,3 +1,4 @@
# DONT EDIT BY HAND: created by script mkMake
depth = .. depth = ..
include $(depth)/mk/sysconf include $(depth)/mk/sysconf

View File

@ -1,5 +1,5 @@
#ifndef lint #ifndef lint
static char rcsid[] = "@(#$Id: rclmain.cpp,v 1.22 2006-04-18 08:53:28 dockes Exp $ (C) 2005 J.F.Dockes"; static char rcsid[] = "@(#$Id: rclmain.cpp,v 1.23 2006-04-20 09:20:09 dockes Exp $ (C) 2005 J.F.Dockes";
#endif #endif
/* /*
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -81,7 +81,6 @@ void RclMain::init()
curPreview = 0; curPreview = 0;
asearchform = 0; asearchform = 0;
sortform = 0; sortform = 0;
sortwidth = 0;
uiprefs = 0; uiprefs = 0;
// Set the focus to the search terms entry: // Set the focus to the search terms entry:
@ -297,15 +296,14 @@ void RclMain::startAdvSearch(Rcl::AdvSearchData sdata)
curPreview = 0; curPreview = 0;
DocSequence *docsource; DocSequence *docsource;
if (sortwidth > 0) { if (sortspecs.sortwidth > 0) {
DocSequenceDb myseq(rcldb, string(tr("Query results").utf8())); DocSequenceDb myseq(rcldb, string(tr("Query results").utf8()));
docsource = new DocSeqSorted(myseq, sortwidth, sortspecs, docsource = new DocSeqSorted(myseq, sortspecs,
string(tr("Query results (sorted)").utf8())); string(tr("Query results (sorted)").utf8()));
} else { } else {
docsource = new DocSequenceDb(rcldb, string(tr("Query results").utf8())); docsource = new DocSequenceDb(rcldb, string(tr("Query results").utf8()));
} }
currentQueryData = sdata; resList->setDocSource(docsource, sdata);
resList->setDocSource(docsource);
} }
// Open advanced search dialog. // Open advanced search dialog.
@ -333,8 +331,8 @@ void RclMain::showSortDialog()
WStyle_Customize | WStyle_NormalBorder | WStyle_Customize | WStyle_NormalBorder |
WStyle_Title | WStyle_SysMenu); WStyle_Title | WStyle_SysMenu);
sortform->setSizeGripEnabled(FALSE); sortform->setSizeGripEnabled(FALSE);
connect(sortform, SIGNAL(sortDataChanged(int, RclSortSpec)), connect(sortform, SIGNAL(sortDataChanged(RclSortSpec)),
this, SLOT(sortDataChanged(int, RclSortSpec))); this, SLOT(sortDataChanged(RclSortSpec)));
sortform->show(); sortform->show();
} else { } else {
// Close and reopen, in hope that makes us visible... // Close and reopen, in hope that makes us visible...
@ -408,8 +406,7 @@ void RclMain::startPreview(int docnum)
QMessageBox::NoButton); QMessageBox::NoButton);
return; return;
} }
curPreview->setCaption(resList->getDescription());
curPreview->setCaption(QString::fromUtf8(currentQueryData.description.c_str()));
connect(curPreview, SIGNAL(previewClosed(QWidget *)), connect(curPreview, SIGNAL(previewClosed(QWidget *)),
this, SLOT(previewClosed(QWidget *))); this, SLOT(previewClosed(QWidget *)));
curPreview->show(); curPreview->show();
@ -511,24 +508,23 @@ void RclMain::showDocHistory()
} }
DocSequence *docsource; DocSequence *docsource;
if (sortwidth > 0) { if (sortspecs.sortwidth > 0) {
DocSequenceHistory myseq(rcldb, m_history, string(tr("Document history").utf8())); DocSequenceHistory myseq(rcldb, m_history, string(tr("Document history").utf8()));
docsource = new DocSeqSorted(myseq, sortwidth, sortspecs, docsource = new DocSeqSorted(myseq, sortspecs,
string(tr("Document history (sorted)").utf8())); string(tr("Document history (sorted)").utf8()));
} else { } else {
docsource = new DocSequenceHistory(rcldb, m_history, docsource = new DocSequenceHistory(rcldb, m_history,
string(tr("Document history").utf8())); string(tr("Document history").utf8()));
} }
currentQueryData.erase(); Rcl::AdvSearchData sdata;
currentQueryData.description = tr("History data").utf8(); sdata.description = tr("History data").utf8();
resList->setDocSource(docsource); resList->setDocSource(docsource, sdata);
} }
void RclMain::sortDataChanged(int cnt, RclSortSpec spec) void RclMain::sortDataChanged(RclSortSpec spec)
{ {
LOGDEB(("RclMain::sortDataChanged\n")); LOGDEB(("RclMain::sortDataChanged\n"));
sortwidth = cnt;
sortspecs = spec; sortspecs = spec;
} }
@ -556,47 +552,3 @@ void RclMain::enablePrevPage(bool yesno)
prevPageAction->setEnabled(yesno); prevPageAction->setEnabled(yesno);
} }
/** Show detailed expansion of a query */
void RclMain::showQueryDetails()
{
// Break query into lines of reasonable length, avoid cutting words,
// Also limit the total number of lines.
const unsigned int ll = 100;
const unsigned int maxlines = 50;
string query = currentQueryData.description;
string oq;
unsigned int nlines = 0;
while (query.length() > 0) {
string ss = query.substr(0, ll);
if (ss.length() == ll) {
string::size_type pos = ss.find_last_of(" ");
if (pos == string::npos) {
pos = query.find_first_of(" ");
if (pos != string::npos)
ss = query.substr(0, pos+1);
else
ss = query;
} else {
ss = ss.substr(0, pos+1);
}
}
// This cant happen, but anyway. Be very sure to avoid an infinite loop
if (ss.length() == 0) {
LOGDEB(("showQueryDetails: Internal error!\n"));
oq = query;
break;
}
oq += ss + "\n";
if (nlines++ >= maxlines) {
oq += " ... \n";
break;
}
query= query.substr(ss.length());
LOGDEB1(("oq [%s]\n, query [%s]\n, ss [%s]\n",
oq.c_str(), query.c_str(), ss.c_str()));
}
QString desc = tr("Query details") + ": " +
QString::fromUtf8(oq.c_str());
QMessageBox::information(this, tr("Query details"), desc);
}

View File

@ -40,7 +40,7 @@ public:
: RclMainBase(parent,name,fl) { : RclMainBase(parent,name,fl) {
init(); init();
} }
~RclMain() {} ~RclMain() {}
virtual bool close( bool ); virtual bool close( bool );
@ -48,26 +48,23 @@ public slots:
virtual void fileExit(); virtual void fileExit();
virtual void periodic100(); virtual void periodic100();
virtual void fileStart_IndexingAction_activated(); virtual void fileStart_IndexingAction_activated();
virtual void startAdvSearch( Rcl::AdvSearchData sdata ); virtual void startAdvSearch(Rcl::AdvSearchData sdata);
virtual void previewClosed( QWidget * w ); virtual void previewClosed(QWidget * w);
virtual void showAdvSearchDialog(); virtual void showAdvSearchDialog();
virtual void showSortDialog(); virtual void showSortDialog();
virtual void showAboutDialog(); virtual void showAboutDialog();
virtual void startManual(); virtual void startManual();
virtual void showDocHistory(); virtual void showDocHistory();
virtual void sortDataChanged( int cnt, RclSortSpec spec ); virtual void sortDataChanged(RclSortSpec spec);
virtual void showUIPrefs(); virtual void showUIPrefs();
virtual void setUIPrefs(); virtual void setUIPrefs();
virtual void enableNextPage(bool); virtual void enableNextPage(bool);
virtual void enablePrevPage(bool); virtual void enablePrevPage(bool);
virtual void showQueryDetails();
protected: protected:
Preview *curPreview; Preview *curPreview;
advsearch *asearchform; advsearch *asearchform;
Rcl::AdvSearchData currentQueryData;
SortForm *sortform; SortForm *sortform;
UIPrefsDialog *uiprefs; UIPrefsDialog *uiprefs;
int sortwidth;
RclSortSpec sortspecs; RclSortSpec sortspecs;
RclDHistory *m_history; RclDHistory *m_history;
private: private:

View File

@ -1,5 +1,5 @@
#ifndef lint #ifndef lint
static char rcsid[] = "@(#$Id: rclreslist.cpp,v 1.12 2006-04-19 08:26:08 dockes Exp $ (C) 2005 J.F.Dockes"; static char rcsid[] = "@(#$Id: rclreslist.cpp,v 1.13 2006-04-20 09:20:09 dockes Exp $ (C) 2005 J.F.Dockes";
#endif #endif
#include <time.h> #include <time.h>
@ -46,7 +46,7 @@ RclResList::RclResList(QWidget* parent, const char* name)
connect(this, SIGNAL(clicked(int, int)), this, SLOT(clicked(int,int))); connect(this, SIGNAL(clicked(int, int)), this, SLOT(clicked(int,int)));
connect(this, SIGNAL(linkClicked(const QString &)), connect(this, SIGNAL(linkClicked(const QString &)),
this, SLOT(linkWasClicked(const QString &))); this, SLOT(linkWasClicked(const QString &)));
connect(this, SIGNAL(headerClicked()), this, SLOT(showQueryDetails()));
m_winfirst = -1; m_winfirst = -1;
m_docsource = 0; m_docsource = 0;
} }
@ -64,11 +64,12 @@ void RclResList::languageChange()
} }
// Acquire new docsource // Acquire new docsource
void RclResList::setDocSource(DocSequence *docsource) void RclResList::setDocSource(DocSequence *docsource, Rcl::AdvSearchData& sdt)
{ {
if (m_docsource) if (m_docsource)
delete m_docsource; delete m_docsource;
m_docsource = docsource; m_docsource = docsource;
m_queryData = sdt;
showResultPage(); showResultPage();
} }
@ -466,3 +467,53 @@ void RclResList::menuCopyURL()
QClipboard::Selection); QClipboard::Selection);
} }
} }
QString RclResList::getDescription()
{
return QString::fromUtf8(m_queryData.description.c_str());
}
/** Show detailed expansion of a query */
void RclResList::showQueryDetails()
{
// Break query into lines of reasonable length, avoid cutting words,
// Also limit the total number of lines.
const unsigned int ll = 100;
const unsigned int maxlines = 50;
string query = m_queryData.description;
string oq;
unsigned int nlines = 0;
while (query.length() > 0) {
string ss = query.substr(0, ll);
if (ss.length() == ll) {
string::size_type pos = ss.find_last_of(" ");
if (pos == string::npos) {
pos = query.find_first_of(" ");
if (pos != string::npos)
ss = query.substr(0, pos+1);
else
ss = query;
} else {
ss = ss.substr(0, pos+1);
}
}
// This cant happen, but anyway. Be very sure to avoid an infinite loop
if (ss.length() == 0) {
LOGDEB(("showQueryDetails: Internal error!\n"));
oq = query;
break;
}
oq += ss + "\n";
if (nlines++ >= maxlines) {
oq += " ... \n";
break;
}
query= query.substr(ss.length());
LOGDEB1(("oq [%s]\n, query [%s]\n, ss [%s]\n",
oq.c_str(), query.c_str(), ss.c_str()));
}
QString desc = tr("Query details") + ": " +
QString::fromUtf8(oq.c_str());
QMessageBox::information(this, tr("Query details"), desc);
}

View File

@ -1,12 +1,13 @@
#ifndef _RCLRESLIST_H_INCLUDED_ #ifndef _RCLRESLIST_H_INCLUDED_
#define _RCLRESLIST_H_INCLUDED_ #define _RCLRESLIST_H_INCLUDED_
/* @(#$Id: rclreslist.h,v 1.5 2006-04-18 08:53:28 dockes Exp $ (C) 2005 J.F.Dockes */ /* @(#$Id: rclreslist.h,v 1.6 2006-04-20 09:20:10 dockes Exp $ (C) 2005 J.F.Dockes */
#include <qtextbrowser.h> #include <qtextbrowser.h>
#include <qpopupmenu.h> #include <qpopupmenu.h>
#include "rcldb.h" #include "rcldb.h"
#include "docseq.h" #include "docseq.h"
#include "searchdata.h"
class RclResList : public QTextBrowser class RclResList : public QTextBrowser
{ {
@ -17,8 +18,9 @@ class RclResList : public QTextBrowser
virtual ~RclResList(); virtual ~RclResList();
virtual bool getDoc( int, Rcl::Doc & ); virtual bool getDoc( int, Rcl::Doc & );
virtual void setDocSource(DocSequence *); virtual void setDocSource(DocSequence *, Rcl::AdvSearchData& qdata);
virtual QPopupMenu *createPopupMenu(const QPoint& pos); virtual QPopupMenu *createPopupMenu(const QPoint& pos);
virtual QString getDescription();
public slots: public slots:
virtual void resetSearch() {m_winfirst = -1;clear();} virtual void resetSearch() {m_winfirst = -1;clear();}
@ -45,15 +47,17 @@ class RclResList : public QTextBrowser
protected slots: protected slots:
virtual void languageChange(); virtual void languageChange();
virtual void linkWasClicked(const QString &); virtual void linkWasClicked(const QString &);
virtual void showQueryDetails();
private: private:
std::map<int,int> m_pageParaToReldocnums; std::map<int,int> m_pageParaToReldocnums;
virtual int docnumfromparnum(int); Rcl::AdvSearchData m_queryData;
DocSequence *m_docsource;
DocSequence *m_docsource;
std::vector<Rcl::Doc> m_curDocs; std::vector<Rcl::Doc> m_curDocs;
int m_winfirst; int m_winfirst;
int m_docnum; // Docnum matching the int m_docnum; // Docnum matching the
virtual int docnumfromparnum(int);
void emitLinkClicked(const QString &s) { void emitLinkClicked(const QString &s) {
emit linkClicked(s); emit linkClicked(s);
}; };

View File

@ -388,12 +388,6 @@
<receiver>RclMainBase</receiver> <receiver>RclMainBase</receiver>
<slot>startPreview(int)</slot> <slot>startPreview(int)</slot>
</connection> </connection>
<connection>
<sender>resList</sender>
<signal>headerClicked()</signal>
<receiver>RclMainBase</receiver>
<slot>showQueryDetails()</slot>
</connection>
</connections> </connections>
<includes> <includes>
<include location="local" impldecl="in declaration">ssearchb.h</include> <include location="local" impldecl="in declaration">ssearchb.h</include>
@ -415,7 +409,6 @@
<slot>enablePrevPage(bool)</slot> <slot>enablePrevPage(bool)</slot>
<slot>startNativeViewer(int)</slot> <slot>startNativeViewer(int)</slot>
<slot>startPreview(int)</slot> <slot>startPreview(int)</slot>
<slot>showQueryDetails()</slot>
</slots> </slots>
<pixmapinproject/> <pixmapinproject/>
<layoutdefaults spacing="6" margin="11"/> <layoutdefaults spacing="6" margin="11"/>

View File

@ -70,6 +70,3 @@ void RclMainBase::startNativeViewer(int)
void RclMainBase::startPreview(int) void RclMainBase::startPreview(int)
{ {
} }
void RclMainBase::showQueryDetails()
{
}

View File

@ -216,7 +216,7 @@
<include location="local" impldecl="in implementation">sort.ui.h</include> <include location="local" impldecl="in implementation">sort.ui.h</include>
</includes> </includes>
<signals> <signals>
<signal>sortDataChanged(int, RclSortSpec)</signal> <signal>sortDataChanged(RclSortSpec)</signal>
</signals> </signals>
<slots> <slots>
<slot>reset()</slot> <slot>reset()</slot>

View File

@ -57,7 +57,6 @@ void SortForm::setData()
{ {
LOGDEB(("SortForm::setData\n")); LOGDEB(("SortForm::setData\n"));
RclSortSpec spec; RclSortSpec spec;
int width;
mcntSB->setEnabled(sortCB->isChecked()); mcntSB->setEnabled(sortCB->isChecked());
fldCMB1->setEnabled(sortCB->isChecked()); fldCMB1->setEnabled(sortCB->isChecked());
@ -66,7 +65,7 @@ void SortForm::setData()
descCB2->setEnabled(sortCB->isChecked()); descCB2->setEnabled(sortCB->isChecked());
if (!sortCB->isChecked()) { if (!sortCB->isChecked()) {
width = 0; spec.sortwidth = 0;
} else { } else {
bool desc = descCB1->isChecked(); bool desc = descCB1->isChecked();
switch (fldCMB1->currentItem()) { switch (fldCMB1->currentItem()) {
@ -87,7 +86,7 @@ void SortForm::setData()
spec.addCrit(RclSortSpec::RCLFLD_MIMETYPE, desc?true:false); spec.addCrit(RclSortSpec::RCLFLD_MIMETYPE, desc?true:false);
break; break;
} }
width = mcntSB->value(); spec.sortwidth = mcntSB->value();
} }
emit sortDataChanged(width, spec); emit sortDataChanged(spec);
} }

View File

@ -81,7 +81,11 @@ void SSearchBase::completion()
{ {
if (!rcldb) if (!rcldb)
return; return;
if (searchTypCMB->currentItem() == 2) {
// Filename: no completion
QApplication::beep();
return;
}
// Extract last word in text // Extract last word in text
string txt = (const char *)queryText->text().utf8(); string txt = (const char *)queryText->text().utf8();
string::size_type cs = txt.find_last_of(" "); string::size_type cs = txt.find_last_of(" ");

View File

@ -1,5 +1,5 @@
#ifndef lint #ifndef lint
static char rcsid[] = "@(#$Id: sortseq.cpp,v 1.6 2006-01-23 13:32:28 dockes Exp $ (C) 2005 J.F.Dockes"; static char rcsid[] = "@(#$Id: sortseq.cpp,v 1.7 2006-04-20 09:20:10 dockes Exp $ (C) 2005 J.F.Dockes";
#endif #endif
/* /*
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -82,15 +82,15 @@ public:
} }
}; };
DocSeqSorted::DocSeqSorted(DocSequence &iseq, int cnt, RclSortSpec &sortspec, DocSeqSorted::DocSeqSorted(DocSequence &iseq, RclSortSpec &sortspec,
const std::string &t) const std::string &t)
: DocSequence(t) : DocSequence(t)
{ {
LOGDEB(("DocSeqSorted:: count %d\n", cnt)); m_spec = sortspec;
LOGDEB(("DocSeqSorted:: count %d\n", m_spec.sortwidth));
m_docs.resize(cnt); m_docs.resize(m_spec.sortwidth);
int i; int i;
for (i = 0; i < cnt; i++) { for (i = 0; i < m_spec.sortwidth; i++) {
int percent; int percent;
if (!iseq.getDoc(i, m_docs[i], &percent)) { if (!iseq.getDoc(i, m_docs[i], &percent)) {
LOGERR(("DocSeqSorted: getDoc failed for doc %d\n", i)); LOGERR(("DocSeqSorted: getDoc failed for doc %d\n", i));
@ -98,11 +98,11 @@ DocSeqSorted::DocSeqSorted(DocSequence &iseq, int cnt, RclSortSpec &sortspec,
} }
m_docs[i].pc = percent; m_docs[i].pc = percent;
} }
m_count = i; m_spec.sortwidth = i;
LOGDEB(("DocSeqSorted:: m_count %d\n", m_count)); LOGDEB(("DocSeqSorted:: m_count %d\n", m_spec.sortwidth));
m_docs.resize(m_count); m_docs.resize(m_spec.sortwidth);
m_docsp.resize(m_count); m_docsp.resize(m_spec.sortwidth);
for (i = 0; i < m_count; i++) for (i = 0; i < m_spec.sortwidth; i++)
m_docsp[i] = &m_docs[i]; m_docsp[i] = &m_docs[i];
CompareDocs cmp(sortspec); CompareDocs cmp(sortspec);
@ -113,7 +113,7 @@ bool DocSeqSorted::getDoc(int num, Rcl::Doc &doc, int *percent, string *)
{ {
LOGDEB1(("DocSeqSorted: fetching %d\n", num)); LOGDEB1(("DocSeqSorted: fetching %d\n", num));
if (num >= m_count) if (num >= m_spec.sortwidth)
return false; return false;
if (percent) if (percent)
*percent = (*m_docsp[num]).pc; *percent = (*m_docsp[num]).pc;

View File

@ -16,7 +16,7 @@
*/ */
#ifndef _SORTSEQ_H_INCLUDED_ #ifndef _SORTSEQ_H_INCLUDED_
#define _SORTSEQ_H_INCLUDED_ #define _SORTSEQ_H_INCLUDED_
/* @(#$Id: sortseq.h,v 1.5 2006-02-21 12:52:48 dockes Exp $ (C) 2004 J.F.Dockes */ /* @(#$Id: sortseq.h,v 1.6 2006-04-20 09:20:10 dockes Exp $ (C) 2004 J.F.Dockes */
#include <vector> #include <vector>
#include <string> #include <string>
@ -25,6 +25,8 @@
class RclSortSpec { class RclSortSpec {
public: public:
RclSortSpec() : sortwidth(0) {}
int sortwidth; // We only re-sort the first sortwidth most relevant docs
enum Field {RCLFLD_URL, RCLFLD_IPATH, RCLFLD_MIMETYPE, RCLFLD_MTIME}; enum Field {RCLFLD_URL, RCLFLD_IPATH, RCLFLD_MIMETYPE, RCLFLD_MTIME};
void addCrit(Field fld, bool desc = false) { void addCrit(Field fld, bool desc = false) {
crits.push_back(fld); crits.push_back(fld);
@ -40,14 +42,14 @@ class RclSortSpec {
*/ */
class DocSeqSorted : public DocSequence { class DocSeqSorted : public DocSequence {
public: public:
DocSeqSorted(DocSequence &iseq, int cnt, RclSortSpec &sortspec, DocSeqSorted(DocSequence &iseq, RclSortSpec &sortspec,
const std::string &t); const std::string &t);
virtual ~DocSeqSorted() {} virtual ~DocSeqSorted() {}
virtual bool getDoc(int num, Rcl::Doc &doc, int *percent, string *sh = 0); virtual bool getDoc(int num, Rcl::Doc &doc, int *percent, string *sh = 0);
virtual int getResCnt() {return m_count;} virtual int getResCnt() {return m_spec.sortwidth;}
private: private:
int m_count; RclSortSpec m_spec;
std::vector<Rcl::Doc> m_docs; std::vector<Rcl::Doc> m_docs;
std::vector<Rcl::Doc *> m_docsp; std::vector<Rcl::Doc *> m_docsp;
}; };