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
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
/*
* 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");
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 &&
mkdir(m_confdir.c_str(), 0755) < 0) {
mkdir(m_confdir.c_str(), 0700) < 0) {
m_reason += string("mkdir(") + m_confdir + ") failed: " +
strerror(errno);
return false;

View File

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

View File

@ -1,5 +1,5 @@
#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
/*
* This program is free software; you can redistribute it and/or modify
@ -81,7 +81,6 @@ void RclMain::init()
curPreview = 0;
asearchform = 0;
sortform = 0;
sortwidth = 0;
uiprefs = 0;
// Set the focus to the search terms entry:
@ -297,15 +296,14 @@ void RclMain::startAdvSearch(Rcl::AdvSearchData sdata)
curPreview = 0;
DocSequence *docsource;
if (sortwidth > 0) {
if (sortspecs.sortwidth > 0) {
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()));
} else {
docsource = new DocSequenceDb(rcldb, string(tr("Query results").utf8()));
}
currentQueryData = sdata;
resList->setDocSource(docsource);
resList->setDocSource(docsource, sdata);
}
// Open advanced search dialog.
@ -333,8 +331,8 @@ void RclMain::showSortDialog()
WStyle_Customize | WStyle_NormalBorder |
WStyle_Title | WStyle_SysMenu);
sortform->setSizeGripEnabled(FALSE);
connect(sortform, SIGNAL(sortDataChanged(int, RclSortSpec)),
this, SLOT(sortDataChanged(int, RclSortSpec)));
connect(sortform, SIGNAL(sortDataChanged(RclSortSpec)),
this, SLOT(sortDataChanged(RclSortSpec)));
sortform->show();
} else {
// Close and reopen, in hope that makes us visible...
@ -408,8 +406,7 @@ void RclMain::startPreview(int docnum)
QMessageBox::NoButton);
return;
}
curPreview->setCaption(QString::fromUtf8(currentQueryData.description.c_str()));
curPreview->setCaption(resList->getDescription());
connect(curPreview, SIGNAL(previewClosed(QWidget *)),
this, SLOT(previewClosed(QWidget *)));
curPreview->show();
@ -511,24 +508,23 @@ void RclMain::showDocHistory()
}
DocSequence *docsource;
if (sortwidth > 0) {
if (sortspecs.sortwidth > 0) {
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()));
} else {
docsource = new DocSequenceHistory(rcldb, m_history,
string(tr("Document history").utf8()));
}
currentQueryData.erase();
currentQueryData.description = tr("History data").utf8();
resList->setDocSource(docsource);
Rcl::AdvSearchData sdata;
sdata.description = tr("History data").utf8();
resList->setDocSource(docsource, sdata);
}
void RclMain::sortDataChanged(int cnt, RclSortSpec spec)
void RclMain::sortDataChanged(RclSortSpec spec)
{
LOGDEB(("RclMain::sortDataChanged\n"));
sortwidth = cnt;
sortspecs = spec;
}
@ -556,47 +552,3 @@ void RclMain::enablePrevPage(bool 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) {
init();
}
~RclMain() {}
~RclMain() {}
virtual bool close( bool );
@ -48,26 +48,23 @@ public slots:
virtual void fileExit();
virtual void periodic100();
virtual void fileStart_IndexingAction_activated();
virtual void startAdvSearch( Rcl::AdvSearchData sdata );
virtual void previewClosed( QWidget * w );
virtual void startAdvSearch(Rcl::AdvSearchData sdata);
virtual void previewClosed(QWidget * w);
virtual void showAdvSearchDialog();
virtual void showSortDialog();
virtual void showAboutDialog();
virtual void startManual();
virtual void showDocHistory();
virtual void sortDataChanged( int cnt, RclSortSpec spec );
virtual void sortDataChanged(RclSortSpec spec);
virtual void showUIPrefs();
virtual void setUIPrefs();
virtual void enableNextPage(bool);
virtual void enablePrevPage(bool);
virtual void showQueryDetails();
protected:
Preview *curPreview;
advsearch *asearchform;
Rcl::AdvSearchData currentQueryData;
SortForm *sortform;
UIPrefsDialog *uiprefs;
int sortwidth;
RclSortSpec sortspecs;
RclDHistory *m_history;
private:

View File

@ -1,5 +1,5 @@
#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
#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(linkClicked(const QString &)),
this, SLOT(linkWasClicked(const QString &)));
connect(this, SIGNAL(headerClicked()), this, SLOT(showQueryDetails()));
m_winfirst = -1;
m_docsource = 0;
}
@ -64,11 +64,12 @@ void RclResList::languageChange()
}
// Acquire new docsource
void RclResList::setDocSource(DocSequence *docsource)
void RclResList::setDocSource(DocSequence *docsource, Rcl::AdvSearchData& sdt)
{
if (m_docsource)
delete m_docsource;
m_docsource = docsource;
m_queryData = sdt;
showResultPage();
}
@ -466,3 +467,53 @@ void RclResList::menuCopyURL()
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_
#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 <qpopupmenu.h>
#include "rcldb.h"
#include "docseq.h"
#include "searchdata.h"
class RclResList : public QTextBrowser
{
@ -17,8 +18,9 @@ class RclResList : public QTextBrowser
virtual ~RclResList();
virtual bool getDoc( int, Rcl::Doc & );
virtual void setDocSource(DocSequence *);
virtual void setDocSource(DocSequence *, Rcl::AdvSearchData& qdata);
virtual QPopupMenu *createPopupMenu(const QPoint& pos);
virtual QString getDescription();
public slots:
virtual void resetSearch() {m_winfirst = -1;clear();}
@ -45,15 +47,17 @@ class RclResList : public QTextBrowser
protected slots:
virtual void languageChange();
virtual void linkWasClicked(const QString &);
virtual void showQueryDetails();
private:
std::map<int,int> m_pageParaToReldocnums;
virtual int docnumfromparnum(int);
DocSequence *m_docsource;
std::map<int,int> m_pageParaToReldocnums;
Rcl::AdvSearchData m_queryData;
DocSequence *m_docsource;
std::vector<Rcl::Doc> m_curDocs;
int m_winfirst;
int m_docnum; // Docnum matching the
int m_winfirst;
int m_docnum; // Docnum matching the
virtual int docnumfromparnum(int);
void emitLinkClicked(const QString &s) {
emit linkClicked(s);
};

View File

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

View File

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

View File

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

View File

@ -57,7 +57,6 @@ void SortForm::setData()
{
LOGDEB(("SortForm::setData\n"));
RclSortSpec spec;
int width;
mcntSB->setEnabled(sortCB->isChecked());
fldCMB1->setEnabled(sortCB->isChecked());
@ -66,7 +65,7 @@ void SortForm::setData()
descCB2->setEnabled(sortCB->isChecked());
if (!sortCB->isChecked()) {
width = 0;
spec.sortwidth = 0;
} else {
bool desc = descCB1->isChecked();
switch (fldCMB1->currentItem()) {
@ -87,7 +86,7 @@ void SortForm::setData()
spec.addCrit(RclSortSpec::RCLFLD_MIMETYPE, desc?true:false);
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)
return;
if (searchTypCMB->currentItem() == 2) {
// Filename: no completion
QApplication::beep();
return;
}
// Extract last word in text
string txt = (const char *)queryText->text().utf8();
string::size_type cs = txt.find_last_of(" ");

View File

@ -1,5 +1,5 @@
#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
/*
* 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)
: DocSequence(t)
{
LOGDEB(("DocSeqSorted:: count %d\n", cnt));
m_docs.resize(cnt);
m_spec = sortspec;
LOGDEB(("DocSeqSorted:: count %d\n", m_spec.sortwidth));
m_docs.resize(m_spec.sortwidth);
int i;
for (i = 0; i < cnt; i++) {
for (i = 0; i < m_spec.sortwidth; i++) {
int percent;
if (!iseq.getDoc(i, m_docs[i], &percent)) {
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_count = i;
LOGDEB(("DocSeqSorted:: m_count %d\n", m_count));
m_docs.resize(m_count);
m_docsp.resize(m_count);
for (i = 0; i < m_count; i++)
m_spec.sortwidth = i;
LOGDEB(("DocSeqSorted:: m_count %d\n", m_spec.sortwidth));
m_docs.resize(m_spec.sortwidth);
m_docsp.resize(m_spec.sortwidth);
for (i = 0; i < m_spec.sortwidth; i++)
m_docsp[i] = &m_docs[i];
CompareDocs cmp(sortspec);
@ -113,7 +113,7 @@ bool DocSeqSorted::getDoc(int num, Rcl::Doc &doc, int *percent, string *)
{
LOGDEB1(("DocSeqSorted: fetching %d\n", num));
if (num >= m_count)
if (num >= m_spec.sortwidth)
return false;
if (percent)
*percent = (*m_docsp[num]).pc;

View File

@ -16,7 +16,7 @@
*/
#ifndef _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 <string>
@ -25,6 +25,8 @@
class RclSortSpec {
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};
void addCrit(Field fld, bool desc = false) {
crits.push_back(fld);
@ -40,14 +42,14 @@ class RclSortSpec {
*/
class DocSeqSorted : public DocSequence {
public:
DocSeqSorted(DocSequence &iseq, int cnt, RclSortSpec &sortspec,
DocSeqSorted(DocSequence &iseq, RclSortSpec &sortspec,
const std::string &t);
virtual ~DocSeqSorted() {}
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:
int m_count;
RclSortSpec m_spec;
std::vector<Rcl::Doc> m_docs;
std::vector<Rcl::Doc *> m_docsp;
};