diff --git a/src/common/rclconfig.cpp b/src/common/rclconfig.cpp index 50f9ab92..bbfc4922 100644 --- a/src/common/rclconfig.cpp +++ b/src/common/rclconfig.cpp @@ -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; diff --git a/src/lib/Makefile b/src/lib/Makefile index aeb25306..22900b44 100644 --- a/src/lib/Makefile +++ b/src/lib/Makefile @@ -1,3 +1,4 @@ +# DONT EDIT BY HAND: created by script mkMake depth = .. include $(depth)/mk/sysconf diff --git a/src/qtgui/rclmain.cpp b/src/qtgui/rclmain.cpp index 258d860f..5d65f27a 100644 --- a/src/qtgui/rclmain.cpp +++ b/src/qtgui/rclmain.cpp @@ -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); -} diff --git a/src/qtgui/rclmain.h b/src/qtgui/rclmain.h index 6a09ed56..aec4e138 100644 --- a/src/qtgui/rclmain.h +++ b/src/qtgui/rclmain.h @@ -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: diff --git a/src/qtgui/rclreslist.cpp b/src/qtgui/rclreslist.cpp index a2893913..101de7a5 100644 --- a/src/qtgui/rclreslist.cpp +++ b/src/qtgui/rclreslist.cpp @@ -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 @@ -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); +} diff --git a/src/qtgui/rclreslist.h b/src/qtgui/rclreslist.h index 052aa5c2..9c4c60ea 100644 --- a/src/qtgui/rclreslist.h +++ b/src/qtgui/rclreslist.h @@ -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 #include #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 m_pageParaToReldocnums; - virtual int docnumfromparnum(int); - - DocSequence *m_docsource; + std::map m_pageParaToReldocnums; + Rcl::AdvSearchData m_queryData; + DocSequence *m_docsource; std::vector 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); }; diff --git a/src/qtgui/recollmain.ui b/src/qtgui/recollmain.ui index 287936e3..d25837c5 100644 --- a/src/qtgui/recollmain.ui +++ b/src/qtgui/recollmain.ui @@ -388,12 +388,6 @@ RclMainBase startPreview(int) - - resList - headerClicked() - RclMainBase - showQueryDetails() - ssearchb.h @@ -415,7 +409,6 @@ enablePrevPage(bool) startNativeViewer(int) startPreview(int) - showQueryDetails() diff --git a/src/qtgui/recollmain.ui.h b/src/qtgui/recollmain.ui.h index c19f82c4..4371d43b 100644 --- a/src/qtgui/recollmain.ui.h +++ b/src/qtgui/recollmain.ui.h @@ -70,6 +70,3 @@ void RclMainBase::startNativeViewer(int) void RclMainBase::startPreview(int) { } -void RclMainBase::showQueryDetails() -{ -} diff --git a/src/qtgui/sort.ui b/src/qtgui/sort.ui index ef766676..6a737fdd 100644 --- a/src/qtgui/sort.ui +++ b/src/qtgui/sort.ui @@ -216,7 +216,7 @@ sort.ui.h - sortDataChanged(int, RclSortSpec) + sortDataChanged(RclSortSpec) reset() diff --git a/src/qtgui/sort.ui.h b/src/qtgui/sort.ui.h index f8442bfa..95602d40 100644 --- a/src/qtgui/sort.ui.h +++ b/src/qtgui/sort.ui.h @@ -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); } diff --git a/src/qtgui/ssearchb.ui.h b/src/qtgui/ssearchb.ui.h index 5bafc962..04b1884a 100644 --- a/src/qtgui/ssearchb.ui.h +++ b/src/qtgui/ssearchb.ui.h @@ -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(" "); diff --git a/src/query/sortseq.cpp b/src/query/sortseq.cpp index 1bd232c3..82d4837d 100644 --- a/src/query/sortseq.cpp +++ b/src/query/sortseq.cpp @@ -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; diff --git a/src/query/sortseq.h b/src/query/sortseq.h index 83e868be..b66e7c5e 100644 --- a/src/query/sortseq.h +++ b/src/query/sortseq.h @@ -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 #include @@ -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 m_docs; std::vector m_docsp; };