1st version of sorting interface. Needs polishing

This commit is contained in:
dockes 2005-12-02 16:18:20 +00:00
parent f208fe9cc8
commit 868527893c
8 changed files with 388 additions and 220 deletions

View File

@ -333,6 +333,7 @@ class LoadThread : public QThread {
{} {}
virtual void run() virtual void run()
{ {
DebugLog::getdbl()->setloglevel(DEBDEB1);
FileInterner interner(filename, rclconfig, tmpdir, mtype); FileInterner interner(filename, rclconfig, tmpdir, mtype);
if (interner.internfile(*out, ipath) != FileInterner::FIDone) { if (interner.internfile(*out, ipath) != FileInterner::FIDone) {
*statusp = -1; *statusp = -1;
@ -355,6 +356,7 @@ class ToRichThread : public QThread {
{} {}
virtual void run() virtual void run()
{ {
DebugLog::getdbl()->setloglevel(DEBDEB1);
string rich = plaintorich(in, terms, termoffsets); string rich = plaintorich(in, terms, termoffsets);
out = QString::fromUtf8(rich.c_str(), rich.length()); out = QString::fromUtf8(rich.c_str(), rich.length());
} }
@ -416,7 +418,6 @@ void Preview::loadFileInCurrentTab(string fn, size_t sz, const Rcl::Doc &idoc)
doc.mimetype.c_str()); doc.mimetype.c_str());
return; return;
} }
LOGDEB(("Load file done\n"));
// Highlight search terms: // Highlight search terms:
progress.setLabelText(tr("Creating preview text")); progress.setLabelText(tr("Creating preview text"));

View File

@ -8,7 +8,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>631</width> <width>678</width>
<height>212</height> <height>212</height>
</rect> </rect>
</property> </property>
@ -22,7 +22,7 @@
</property> </property>
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>590</width> <width>678</width>
<height>160</height> <height>160</height>
</size> </size>
</property> </property>
@ -99,6 +99,20 @@
<string>Ctrl+S</string> <string>Ctrl+S</string>
</property> </property>
</widget> </widget>
<widget class="Line">
<property name="name">
<cstring>line4</cstring>
</property>
<property name="frameShape">
<enum>VLine</enum>
</property>
<property name="frameShadow">
<enum>Sunken</enum>
</property>
<property name="orientation">
<enum>Vertical</enum>
</property>
</widget>
<widget class="QPushButton"> <widget class="QPushButton">
<property name="name"> <property name="name">
<cstring>listPrevPB</cstring> <cstring>listPrevPB</cstring>
@ -121,6 +135,17 @@
<string>Next page</string> <string>Next page</string>
</property> </property>
</widget> </widget>
<widget class="QPushButton">
<property name="name">
<cstring>sortPB</cstring>
</property>
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Sorting</string>
</property>
</widget>
<spacer> <spacer>
<property name="name"> <property name="name">
<cstring>spacer1</cstring> <cstring>spacer1</cstring>
@ -317,7 +342,7 @@
<sender>advSearchPB</sender> <sender>advSearchPB</sender>
<signal>clicked()</signal> <signal>clicked()</signal>
<receiver>RecollMain</receiver> <receiver>RecollMain</receiver>
<slot>advSearchPB_clicked()</slot> <slot>showAdvSearchDialog()</slot>
</connection> </connection>
<connection> <connection>
<sender>helpAbout_RecollAction</sender> <sender>helpAbout_RecollAction</sender>
@ -343,11 +368,19 @@
<receiver>queryText</receiver> <receiver>queryText</receiver>
<slot>clear()</slot> <slot>clear()</slot>
</connection> </connection>
<connection>
<sender>sortPB</sender>
<signal>clicked()</signal>
<receiver>RecollMain</receiver>
<slot>showSortDialog()</slot>
</connection>
</connections> </connections>
<includes> <includes>
<include location="local" impldecl="in declaration">sortseq.h</include>
<include location="local" impldecl="in declaration">preview.h</include> <include location="local" impldecl="in declaration">preview.h</include>
<include location="local" impldecl="in declaration">recoll.h</include> <include location="local" impldecl="in declaration">recoll.h</include>
<include location="local" impldecl="in declaration">advsearch.h</include> <include location="local" impldecl="in declaration">advsearch.h</include>
<include location="local" impldecl="in declaration">sort.h</include>
<include location="local" impldecl="in implementation">recollmain.ui.h</include> <include location="local" impldecl="in implementation">recollmain.ui.h</include>
</includes> </includes>
<variables> <variables>
@ -363,6 +396,9 @@
<variable>std::string stemlang;</variable> <variable>std::string stemlang;</variable>
<variable>Preview *curPreview;</variable> <variable>Preview *curPreview;</variable>
<variable>advsearch *asearchform;</variable> <variable>advsearch *asearchform;</variable>
<variable>SortForm *sortform;</variable>
<variable>int sortwidth;</variable>
<variable>RclSortSpec sortspecs;</variable>
<variable>DocSequence *docsource;</variable> <variable>DocSequence *docsource;</variable>
</variables> </variables>
<slots> <slots>
@ -378,11 +414,13 @@
<slot>listPrevPB_clicked()</slot> <slot>listPrevPB_clicked()</slot>
<slot>listNextPB_clicked()</slot> <slot>listNextPB_clicked()</slot>
<slot>previewClosed( Preview * w )</slot> <slot>previewClosed( Preview * w )</slot>
<slot>advSearchPB_clicked()</slot> <slot>showAdvSearchDialog()</slot>
<slot>showSortDialog()</slot>
<slot>startAdvSearch( Rcl::AdvSearchData sdata )</slot> <slot>startAdvSearch( Rcl::AdvSearchData sdata )</slot>
<slot>showAboutDialog()</slot> <slot>showAboutDialog()</slot>
<slot>showDocHistory()</slot> <slot>showDocHistory()</slot>
<slot>searchTextChanged( const QString &amp; text )</slot> <slot>searchTextChanged( const QString &amp; text )</slot>
<slot>sortDataChanged(int cnt, RclSortSpec spec)</slot>
</slots> </slots>
<functions> <functions>
<function access="private">init()</function> <function access="private">init()</function>

View File

@ -62,7 +62,9 @@ void RecollMain::init()
dostem = false; dostem = false;
curPreview = 0; curPreview = 0;
asearchform = 0; asearchform = 0;
sortform = 0;
docsource = 0; docsource = 0;
sortwidth = 0;
reslistTE->viewport()->installEventFilter(this); reslistTE->viewport()->installEventFilter(this);
} }
@ -386,14 +388,13 @@ void RecollMain::queryText_returnPressed()
if (docsource) if (docsource)
delete docsource; delete docsource;
#if TRYSORT
DocSequenceDb myseq(rcldb); if (sortwidth > 0) {
RclSortSpec ss; DocSequenceDb myseq(rcldb);
ss.addCrit(RclSortSpec::RCLFLD_MTIME, false); docsource = new DocSeqSorted(myseq, sortwidth, sortspecs);
docsource = new DocSeqSorted(myseq, 10000, ss); } else {
#else docsource = new DocSequenceDb(rcldb);
docsource = new DocSequenceDb(rcldb); }
#endif
listNextPB_clicked(); listNextPB_clicked();
} }
@ -570,7 +571,7 @@ void RecollMain::previewClosed(Preview *w)
} }
// Open advanced search dialog. // Open advanced search dialog.
void RecollMain::advSearchPB_clicked() void RecollMain::showAdvSearchDialog()
{ {
if (asearchform == 0) { if (asearchform == 0) {
asearchform = new advsearch(0, tr("Advanced search"), FALSE, asearchform = new advsearch(0, tr("Advanced search"), FALSE,
@ -585,6 +586,22 @@ void RecollMain::advSearchPB_clicked()
} }
} }
void RecollMain::showSortDialog()
{
if (sortform == 0) {
sortform = new SortForm(0, tr("Sort criteria"), FALSE,
WStyle_Customize | WStyle_NormalBorder |
WStyle_Title | WStyle_SysMenu);
sortform->setSizeGripEnabled(FALSE);
connect(sortform, SIGNAL(sortDataChanged(int, RclSortSpec)),
this, SLOT(sortDataChanged(int, RclSortSpec)));
sortform->show();
} else {
sortform->show();
}
}
// Execute an advanced search query. The parameters normally come from // Execute an advanced search query. The parameters normally come from
// the advanced search dialog // the advanced search dialog
void RecollMain::startAdvSearch(Rcl::AdvSearchData sdata) void RecollMain::startAdvSearch(Rcl::AdvSearchData sdata)
@ -608,14 +625,14 @@ void RecollMain::startAdvSearch(Rcl::AdvSearchData sdata)
curPreview = 0; curPreview = 0;
if (docsource) if (docsource)
delete docsource; delete docsource;
#if TRYSORT
DocSequenceDb myseq(rcldb); if (sortwidth > 0) {
RclSortSpec ss; DocSequenceDb myseq(rcldb);
ss.addCrit(RclSortSpec::RCLFLD_MTIME, true); docsource = new DocSeqSorted(myseq, sortwidth, sortspecs);
docsource = new DocSeqSorted(myseq, 10000, ss); } else {
#else docsource = new DocSequenceDb(rcldb);
docsource = new DocSequenceDb(rcldb); }
#endif
listNextPB_clicked(); listNextPB_clicked();
} }
@ -705,3 +722,10 @@ void RecollMain::searchTextChanged(const QString & text)
} }
} }
void RecollMain::sortDataChanged(int cnt, RclSortSpec spec)
{
LOGDEB(("RecollMain::sortDataChanged\n"));
sortwidth = cnt;
sortspecs = spec;
}

View File

@ -1,197 +1,227 @@
<!DOCTYPE UI><UI version="3.3" stdsetdef="1"> <!DOCTYPE UI><UI version="3.3" stdsetdef="1">
<class>sort</class> <class>SortForm</class>
<widget class="QDialog"> <widget class="QDialog">
<property name="name"> <property name="name">
<cstring>sort</cstring> <cstring>SortForm</cstring>
</property> </property>
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>360</width> <width>351</width>
<height>163</height> <height>154</height>
</rect> </rect>
</property> </property>
<property name="caption"> <property name="caption">
<string>Form1</string> <string>Sort Criteria</string>
</property> </property>
<widget class="QLayoutWidget"> <vbox>
<property name="name"> <property name="name">
<cstring>layout2</cstring> <cstring>unnamed</cstring>
</property> </property>
<property name="geometry"> <widget class="QLayoutWidget">
<rect>
<x>12</x>
<y>12</y>
<width>336</width>
<height>23</height>
</rect>
</property>
<hbox>
<property name="name"> <property name="name">
<cstring>unnamed</cstring> <cstring>layout10</cstring>
</property> </property>
<widget class="QLabel"> <vbox>
<property name="name"> <property name="name">
<cstring>textLabel1</cstring> <cstring>unnamed</cstring>
</property> </property>
<property name="frameShape"> <widget class="QLayoutWidget">
<enum>NoFrame</enum> <property name="name">
</property> <cstring>layout9</cstring>
<property name="frameShadow"> </property>
<enum>Plain</enum> <hbox>
</property> <property name="name">
<property name="text"> <cstring>unnamed</cstring>
<string>Sort at most the </string> </property>
</property> <widget class="QCheckBox">
</widget> <property name="name">
<widget class="QSpinBox"> <cstring>sortCB</cstring>
<property name="name"> </property>
<cstring>mcntSB</cstring> <property name="text">
</property> <string>Sort the</string>
<property name="maxValue"> </property>
<number>10000</number> </widget>
</property> <widget class="QSpinBox">
<property name="value"> <property name="name">
<number>100</number> <cstring>mcntSB</cstring>
</property> </property>
</widget> <property name="enabled">
<widget class="QLabel"> <bool>false</bool>
<property name="name"> </property>
<cstring>textLabel2</cstring> <property name="maxValue">
</property> <number>10000</number>
<property name="text"> </property>
<string>most relevant results by:</string> <property name="value">
</property> <number>100</number>
</widget> </property>
</hbox> </widget>
</widget> <widget class="QLabel">
<widget class="QLayoutWidget"> <property name="name">
<property name="name"> <cstring>textLabel2</cstring>
<cstring>layout3</cstring> </property>
</property> <property name="text">
<property name="geometry"> <string>most relevant results by:</string>
<rect> </property>
<x>12</x> </widget>
<y>41</y> </hbox>
<width>336</width> </widget>
<height>23</height> <widget class="QLayoutWidget">
</rect> <property name="name">
</property> <cstring>layout3</cstring>
<hbox> </property>
<property name="name"> <hbox>
<cstring>unnamed</cstring> <property name="name">
</property> <cstring>unnamed</cstring>
<widget class="QComboBox"> </property>
<property name="name"> <widget class="QComboBox">
<cstring>fldCMB1</cstring> <property name="name">
</property> <cstring>fldCMB1</cstring>
</widget> </property>
<widget class="QCheckBox"> <property name="enabled">
<property name="name"> <bool>false</bool>
<cstring>descCB1</cstring> </property>
</property> </widget>
<property name="text"> <widget class="QCheckBox">
<string>Descending</string> <property name="name">
</property> <cstring>descCB1</cstring>
</widget> </property>
</hbox> <property name="enabled">
</widget> <bool>false</bool>
<widget class="QLayoutWidget"> </property>
<property name="name"> <property name="text">
<cstring>layout6</cstring> <string>Descending</string>
</property> </property>
<property name="geometry"> </widget>
<rect> </hbox>
<x>12</x> </widget>
<y>70</y> <widget class="QLayoutWidget">
<width>336</width> <property name="name">
<height>23</height> <cstring>layout6</cstring>
</rect> </property>
</property> <hbox>
<hbox> <property name="name">
<property name="name"> <cstring>unnamed</cstring>
<cstring>unnamed</cstring> </property>
</property> <widget class="QComboBox">
<widget class="QComboBox"> <property name="name">
<property name="name"> <cstring>fldCMB2</cstring>
<cstring>fldCMB2</cstring> </property>
</property> <property name="enabled">
</widget> <bool>false</bool>
<widget class="QCheckBox"> </property>
<property name="name"> </widget>
<cstring>descCB2</cstring> <widget class="QCheckBox">
</property> <property name="name">
<property name="text"> <cstring>descCB2</cstring>
<string>Descending</string> </property>
</property> <property name="enabled">
</widget> <bool>false</bool>
</hbox> </property>
</widget> <property name="text">
<widget class="QLayoutWidget"> <string>Descending</string>
<property name="name"> </property>
<cstring>layout10</cstring> </widget>
</property> </hbox>
<property name="geometry"> </widget>
<rect> <widget class="QLayoutWidget">
<x>12</x> <property name="name">
<y>99</y> <cstring>layout7</cstring>
<width>336</width> </property>
<height>23</height> <hbox>
</rect> <property name="name">
</property> <cstring>unnamed</cstring>
<hbox> </property>
<property name="name"> <widget class="QPushButton">
<cstring>unnamed</cstring> <property name="name">
</property> <cstring>resetPB</cstring>
<widget class="QComboBox"> </property>
<property name="name"> <property name="enabled">
<cstring>fldCMB3</cstring> <bool>true</bool>
</property> </property>
</widget> <property name="text">
<widget class="QCheckBox"> <string>Reset</string>
<property name="name"> </property>
<cstring>descCB3</cstring> </widget>
</property> <widget class="QPushButton">
<property name="text"> <property name="name">
<string>Descending</string> <cstring>closePB</cstring>
</property> </property>
</widget> <property name="enabled">
</hbox> <bool>true</bool>
</widget> </property>
<widget class="QCheckBox"> <property name="text">
<property name="name"> <string>Close</string>
<cstring>descCB4</cstring> </property>
</property> </widget>
<property name="geometry"> </hbox>
<rect> </widget>
<x>183</x> </vbox>
<y>130</y> </widget>
<width>164</width> </vbox>
<height>18</height>
</rect>
</property>
<property name="text">
<string>Descending</string>
</property>
</widget>
<widget class="QComboBox">
<property name="name">
<cstring>fldCMB4</cstring>
</property>
<property name="geometry">
<rect>
<x>13</x>
<y>129</y>
<width>164</width>
<height>21</height>
</rect>
</property>
</widget>
</widget> </widget>
<connections>
<connection>
<sender>resetPB</sender>
<signal>clicked()</signal>
<receiver>SortForm</receiver>
<slot>reset()</slot>
</connection>
<connection>
<sender>closePB</sender>
<signal>clicked()</signal>
<receiver>SortForm</receiver>
<slot>close()</slot>
</connection>
<connection>
<sender>mcntSB</sender>
<signal>valueChanged(int)</signal>
<receiver>SortForm</receiver>
<slot>setData()</slot>
</connection>
<connection>
<sender>fldCMB1</sender>
<signal>activated(const QString&amp;)</signal>
<receiver>SortForm</receiver>
<slot>setData()</slot>
</connection>
<connection>
<sender>fldCMB2</sender>
<signal>activated(const QString&amp;)</signal>
<receiver>SortForm</receiver>
<slot>setData()</slot>
</connection>
<connection>
<sender>descCB1</sender>
<signal>stateChanged(int)</signal>
<receiver>SortForm</receiver>
<slot>setData()</slot>
</connection>
<connection>
<sender>descCB2</sender>
<signal>stateChanged(int)</signal>
<receiver>SortForm</receiver>
<slot>setData()</slot>
</connection>
<connection>
<sender>sortCB</sender>
<signal>toggled(bool)</signal>
<receiver>SortForm</receiver>
<slot>setData()</slot>
</connection>
</connections>
<includes> <includes>
<include location="local" impldecl="in declaration">sortseq.h</include>
<include location="local" impldecl="in implementation">sort.ui.h</include> <include location="local" impldecl="in implementation">sort.ui.h</include>
</includes> </includes>
<signals>
<signal>sortDataChanged(int, RclSortSpec)</signal>
</signals>
<slots>
<slot>reset()</slot>
<slot>setData()</slot>
</slots>
<functions> <functions>
<function>init()</function> <function>init()</function>
</functions> </functions>

View File

@ -10,10 +10,66 @@
** destructor. ** destructor.
*****************************************************************************/ *****************************************************************************/
#include "sortseq.h"
#include "debuglog.h"
void sort::init() void SortForm::init()
{ {
const char *labels[5];
labels[0] = "";
labels[1] = "Date";
labels[2] = "Mime type";
labels[3] = 0;
fldCMB1->insertStrList(labels, 3);
fldCMB1->setCurrentItem(0);
fldCMB2->insertStrList(labels, 3);
fldCMB2->setCurrentItem(0);
} }
void SortForm::reset()
{
mcntSB->setValue(100);
fldCMB1->setCurrentItem(0);
fldCMB2->setCurrentItem(0);
descCB1->setChecked(false);
descCB1->setChecked(false);
}
void SortForm::setData()
{
LOGDEB(("SortForm::setData\n"));
RclSortSpec spec;
int width;
mcntSB->setEnabled(sortCB->isChecked());
fldCMB1->setEnabled(sortCB->isChecked());
descCB1->setEnabled(sortCB->isChecked());
fldCMB2->setEnabled(sortCB->isChecked());
descCB2->setEnabled(sortCB->isChecked());
if (!sortCB->isChecked()) {
width = 0;
} else {
bool desc = descCB1->isChecked();
switch (fldCMB1->currentItem()) {
case 1:
spec.addCrit(RclSortSpec::RCLFLD_MTIME, desc?true:false);
break;
case 2:
spec.addCrit(RclSortSpec::RCLFLD_MIMETYPE, desc?true:false);
break;
}
desc = descCB2->isChecked();
switch (fldCMB2->currentItem()) {
case 1:
spec.addCrit(RclSortSpec::RCLFLD_MTIME, desc?true:false);
break;
case 2:
spec.addCrit(RclSortSpec::RCLFLD_MIMETYPE, desc?true:false);
break;
}
width = mcntSB->value();
}
emit sortDataChanged(width, spec);
}

View File

@ -1,5 +1,5 @@
#ifndef lint #ifndef lint
static char rcsid[] = "@(#$Id: sortseq.cpp,v 1.2 2005-12-02 14:18:44 dockes Exp $ (C) 2005 J.F.Dockes"; static char rcsid[] = "@(#$Id: sortseq.cpp,v 1.3 2005-12-02 16:18:20 dockes Exp $ (C) 2005 J.F.Dockes";
#endif #endif
#include <algorithm> #include <algorithm>
@ -13,38 +13,51 @@ class CompareDocs {
public: public:
CompareDocs(const RclSortSpec &sortspec) : ss(sortspec) {} CompareDocs(const RclSortSpec &sortspec) : ss(sortspec) {}
int operator()(const Rcl::Doc &x, const Rcl::Doc &y) // It's not too clear in the std::sort doc what this should do. This
// behaves as operator<
int operator()(const Rcl::Doc *x, const Rcl::Doc *y)
{ {
LOGDEB(("Comparing .. \n")); LOGDEB1(("Comparing .. \n"));
// Compare using each criterion in term. Further comparisons must only
// be made if previous order ones are equal.
for (unsigned int i = 0; i < ss.crits.size(); i++) { for (unsigned int i = 0; i < ss.crits.size(); i++) {
switch (ss.crits[i]) { switch (ss.crits[i]) {
case RclSortSpec::RCLFLD_MTIME: case RclSortSpec::RCLFLD_MTIME:
{ {
LOGDEB((" MTIME\n")); long xmtime = x->dmtime.empty() ? atol(x->fmtime.c_str()) :
long xmtime = x.dmtime.empty() ? atol(x.fmtime.c_str()) : atol(x->dmtime.c_str());
atol(x.dmtime.c_str()); long ymtime = y->dmtime.empty() ? atol(y->fmtime.c_str()) :
long ymtime = y.dmtime.empty() ? atol(y.fmtime.c_str()) : atol(y->dmtime.c_str());
atol(y.dmtime.c_str());
LOGDEB1((" MTIME %ld %ld\n", xmtime, ymtime));
if (ss.dirs[i] ? xmtime > ymtime : xmtime < ymtime) if (ss.dirs[i] ? xmtime > ymtime : xmtime < ymtime)
return 1; return 1;
else if (xmtime != ymtime)
return 0;
} }
break; break;
case RclSortSpec::RCLFLD_URL: case RclSortSpec::RCLFLD_URL:
LOGDEB((" URL\n")); LOGDEB1((" URL\n"));
if (ss.dirs[i] ? x.url > y.url : x.url < y.url) if (ss.dirs[i] ? x->url > y->url : x->url < y->url)
return 1; return 1;
else if (x->url != y->url)
return 0;
break; break;
case RclSortSpec::RCLFLD_IPATH: case RclSortSpec::RCLFLD_IPATH:
LOGDEB((" IPATH\n")); LOGDEB1((" IPATH\n"));
if (ss.dirs[i] ? x.ipath > y.ipath : x.ipath < y.ipath) if (ss.dirs[i] ? x->ipath > y->ipath : x->ipath < y->ipath)
return 1; return 1;
else if (x->ipath != y->ipath)
return 0;
break; break;
case RclSortSpec::RCLFLD_MIMETYPE: case RclSortSpec::RCLFLD_MIMETYPE:
LOGDEB((" MIMETYPE\n")); LOGDEB1((" MIMETYPE\n"));
if (ss.dirs[i] ? x.mimetype > y.mimetype : if (ss.dirs[i] ? x->mimetype > y->mimetype :
x.mimetype < y.mimetype) x->mimetype < y->mimetype)
return 1; return 1;
else if (x->mimetype != y->mimetype)
return 0;
break; break;
} }
} }
@ -58,21 +71,25 @@ DocSeqSorted::DocSeqSorted(DocSequence &iseq, int cnt, RclSortSpec &sortspec)
LOGDEB(("DocSeqSorted:: count %d\n", cnt)); LOGDEB(("DocSeqSorted:: count %d\n", cnt));
m_docs.resize(cnt); m_docs.resize(cnt);
m_pcs.resize(cnt);
int i; int i;
for (i = 0; i < cnt; i++) { for (i = 0; i < cnt; i++) {
if (!iseq.getDoc(i, m_docs[i], &m_pcs[i])) { int 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));
break; break;
} }
m_docs[i].pc = percent;
} }
m_count = i; m_count = i;
LOGDEB(("DocSeqSorted:: m_count %d\n", m_count)); LOGDEB(("DocSeqSorted:: m_count %d\n", m_count));
m_docs.resize(m_count); m_docs.resize(m_count);
m_pcs.resize(m_count); m_docsp.resize(m_count);
for (i = 0; i < m_count; i++)
m_docsp[i] = &m_docs[i];
m_title = string("Sorted ") + iseq.title(); m_title = string("Sorted ") + iseq.title();
CompareDocs cmp(sortspec); CompareDocs cmp(sortspec);
sort(m_docs.begin(), m_docs.end(), cmp); sort(m_docsp.begin(), m_docsp.end(), cmp);
} }
bool DocSeqSorted::getDoc(int num, Rcl::Doc &doc, int *percent, string *) bool DocSeqSorted::getDoc(int num, Rcl::Doc &doc, int *percent, string *)
@ -82,7 +99,7 @@ bool DocSeqSorted::getDoc(int num, Rcl::Doc &doc, int *percent, string *)
if (num >= m_count) if (num >= m_count)
return false; return false;
if (percent) if (percent)
*percent = m_pcs[num]; *percent = (*m_docsp[num]).pc;
doc = m_docs[num]; doc = *m_docsp[num];
return true; return true;
} }

View File

@ -1,6 +1,6 @@
#ifndef _SORTSEQ_H_INCLUDED_ #ifndef _SORTSEQ_H_INCLUDED_
#define _SORTSEQ_H_INCLUDED_ #define _SORTSEQ_H_INCLUDED_
/* @(#$Id: sortseq.h,v 1.1 2005-12-01 16:23:09 dockes Exp $ (C) 2004 J.F.Dockes */ /* @(#$Id: sortseq.h,v 1.2 2005-12-02 16:18:20 dockes Exp $ (C) 2004 J.F.Dockes */
#include <vector> #include <vector>
#include <string> #include <string>
@ -33,7 +33,7 @@ class DocSeqSorted : public DocSequence {
std::string m_title; std::string m_title;
int m_count; int m_count;
std::vector<Rcl::Doc> m_docs; std::vector<Rcl::Doc> m_docs;
std::vector<int> m_pcs; std::vector<Rcl::Doc *> m_docsp;
}; };
#endif /* _SORTSEQ_H_INCLUDED_ */ #endif /* _SORTSEQ_H_INCLUDED_ */

View File

@ -1,6 +1,6 @@
#ifndef _DB_H_INCLUDED_ #ifndef _DB_H_INCLUDED_
#define _DB_H_INCLUDED_ #define _DB_H_INCLUDED_
/* @(#$Id: rcldb.h,v 1.19 2005-11-25 09:12:26 dockes Exp $ (C) 2004 J.F.Dockes */ /* @(#$Id: rcldb.h,v 1.20 2005-12-02 16:18:20 dockes Exp $ (C) 2004 J.F.Dockes */
#include <string> #include <string>
#include <list> #include <list>
@ -48,6 +48,8 @@ class Doc {
string text; string text;
int pc; // used by sortseq, convenience
void erase() { void erase() {
url.erase(); url.erase();
ipath.erase(); ipath.erase();