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
+2 -1
View File
@@ -333,6 +333,7 @@ class LoadThread : public QThread {
{}
virtual void run()
{
DebugLog::getdbl()->setloglevel(DEBDEB1);
FileInterner interner(filename, rclconfig, tmpdir, mtype);
if (interner.internfile(*out, ipath) != FileInterner::FIDone) {
*statusp = -1;
@@ -355,6 +356,7 @@ class ToRichThread : public QThread {
{}
virtual void run()
{
DebugLog::getdbl()->setloglevel(DEBDEB1);
string rich = plaintorich(in, terms, termoffsets);
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());
return;
}
LOGDEB(("Load file done\n"));
// Highlight search terms:
progress.setLabelText(tr("Creating preview text"));
+42 -4
View File
@@ -8,7 +8,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>631</width>
<width>678</width>
<height>212</height>
</rect>
</property>
@@ -22,7 +22,7 @@
</property>
<property name="minimumSize">
<size>
<width>590</width>
<width>678</width>
<height>160</height>
</size>
</property>
@@ -99,6 +99,20 @@
<string>Ctrl+S</string>
</property>
</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">
<property name="name">
<cstring>listPrevPB</cstring>
@@ -121,6 +135,17 @@
<string>Next page</string>
</property>
</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>
<property name="name">
<cstring>spacer1</cstring>
@@ -317,7 +342,7 @@
<sender>advSearchPB</sender>
<signal>clicked()</signal>
<receiver>RecollMain</receiver>
<slot>advSearchPB_clicked()</slot>
<slot>showAdvSearchDialog()</slot>
</connection>
<connection>
<sender>helpAbout_RecollAction</sender>
@@ -343,11 +368,19 @@
<receiver>queryText</receiver>
<slot>clear()</slot>
</connection>
<connection>
<sender>sortPB</sender>
<signal>clicked()</signal>
<receiver>RecollMain</receiver>
<slot>showSortDialog()</slot>
</connection>
</connections>
<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">recoll.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>
</includes>
<variables>
@@ -363,6 +396,9 @@
<variable>std::string stemlang;</variable>
<variable>Preview *curPreview;</variable>
<variable>advsearch *asearchform;</variable>
<variable>SortForm *sortform;</variable>
<variable>int sortwidth;</variable>
<variable>RclSortSpec sortspecs;</variable>
<variable>DocSequence *docsource;</variable>
</variables>
<slots>
@@ -378,11 +414,13 @@
<slot>listPrevPB_clicked()</slot>
<slot>listNextPB_clicked()</slot>
<slot>previewClosed( Preview * w )</slot>
<slot>advSearchPB_clicked()</slot>
<slot>showAdvSearchDialog()</slot>
<slot>showSortDialog()</slot>
<slot>startAdvSearch( Rcl::AdvSearchData sdata )</slot>
<slot>showAboutDialog()</slot>
<slot>showDocHistory()</slot>
<slot>searchTextChanged( const QString &amp; text )</slot>
<slot>sortDataChanged(int cnt, RclSortSpec spec)</slot>
</slots>
<functions>
<function access="private">init()</function>
+41 -17
View File
@@ -62,7 +62,9 @@ void RecollMain::init()
dostem = false;
curPreview = 0;
asearchform = 0;
sortform = 0;
docsource = 0;
sortwidth = 0;
reslistTE->viewport()->installEventFilter(this);
}
@@ -386,14 +388,13 @@ void RecollMain::queryText_returnPressed()
if (docsource)
delete docsource;
#if TRYSORT
DocSequenceDb myseq(rcldb);
RclSortSpec ss;
ss.addCrit(RclSortSpec::RCLFLD_MTIME, false);
docsource = new DocSeqSorted(myseq, 10000, ss);
#else
docsource = new DocSequenceDb(rcldb);
#endif
if (sortwidth > 0) {
DocSequenceDb myseq(rcldb);
docsource = new DocSeqSorted(myseq, sortwidth, sortspecs);
} else {
docsource = new DocSequenceDb(rcldb);
}
listNextPB_clicked();
}
@@ -570,7 +571,7 @@ void RecollMain::previewClosed(Preview *w)
}
// Open advanced search dialog.
void RecollMain::advSearchPB_clicked()
void RecollMain::showAdvSearchDialog()
{
if (asearchform == 0) {
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
// the advanced search dialog
void RecollMain::startAdvSearch(Rcl::AdvSearchData sdata)
@@ -608,14 +625,14 @@ void RecollMain::startAdvSearch(Rcl::AdvSearchData sdata)
curPreview = 0;
if (docsource)
delete docsource;
#if TRYSORT
DocSequenceDb myseq(rcldb);
RclSortSpec ss;
ss.addCrit(RclSortSpec::RCLFLD_MTIME, true);
docsource = new DocSeqSorted(myseq, 10000, ss);
#else
docsource = new DocSequenceDb(rcldb);
#endif
if (sortwidth > 0) {
DocSequenceDb myseq(rcldb);
docsource = new DocSeqSorted(myseq, sortwidth, sortspecs);
} else {
docsource = new DocSequenceDb(rcldb);
}
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;
}
+202 -172
View File
@@ -1,197 +1,227 @@
<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
<class>sort</class>
<class>SortForm</class>
<widget class="QDialog">
<property name="name">
<cstring>sort</cstring>
<cstring>SortForm</cstring>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>360</width>
<height>163</height>
<width>351</width>
<height>154</height>
</rect>
</property>
<property name="caption">
<string>Form1</string>
<string>Sort Criteria</string>
</property>
<widget class="QLayoutWidget">
<vbox>
<property name="name">
<cstring>layout2</cstring>
<cstring>unnamed</cstring>
</property>
<property name="geometry">
<rect>
<x>12</x>
<y>12</y>
<width>336</width>
<height>23</height>
</rect>
</property>
<hbox>
<widget class="QLayoutWidget">
<property name="name">
<cstring>unnamed</cstring>
<cstring>layout10</cstring>
</property>
<widget class="QLabel">
<vbox>
<property name="name">
<cstring>textLabel1</cstring>
<cstring>unnamed</cstring>
</property>
<property name="frameShape">
<enum>NoFrame</enum>
</property>
<property name="frameShadow">
<enum>Plain</enum>
</property>
<property name="text">
<string>Sort at most the </string>
</property>
</widget>
<widget class="QSpinBox">
<property name="name">
<cstring>mcntSB</cstring>
</property>
<property name="maxValue">
<number>10000</number>
</property>
<property name="value">
<number>100</number>
</property>
</widget>
<widget class="QLabel">
<property name="name">
<cstring>textLabel2</cstring>
</property>
<property name="text">
<string>most relevant results by:</string>
</property>
</widget>
</hbox>
</widget>
<widget class="QLayoutWidget">
<property name="name">
<cstring>layout3</cstring>
</property>
<property name="geometry">
<rect>
<x>12</x>
<y>41</y>
<width>336</width>
<height>23</height>
</rect>
</property>
<hbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="QComboBox">
<property name="name">
<cstring>fldCMB1</cstring>
</property>
</widget>
<widget class="QCheckBox">
<property name="name">
<cstring>descCB1</cstring>
</property>
<property name="text">
<string>Descending</string>
</property>
</widget>
</hbox>
</widget>
<widget class="QLayoutWidget">
<property name="name">
<cstring>layout6</cstring>
</property>
<property name="geometry">
<rect>
<x>12</x>
<y>70</y>
<width>336</width>
<height>23</height>
</rect>
</property>
<hbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="QComboBox">
<property name="name">
<cstring>fldCMB2</cstring>
</property>
</widget>
<widget class="QCheckBox">
<property name="name">
<cstring>descCB2</cstring>
</property>
<property name="text">
<string>Descending</string>
</property>
</widget>
</hbox>
</widget>
<widget class="QLayoutWidget">
<property name="name">
<cstring>layout10</cstring>
</property>
<property name="geometry">
<rect>
<x>12</x>
<y>99</y>
<width>336</width>
<height>23</height>
</rect>
</property>
<hbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="QComboBox">
<property name="name">
<cstring>fldCMB3</cstring>
</property>
</widget>
<widget class="QCheckBox">
<property name="name">
<cstring>descCB3</cstring>
</property>
<property name="text">
<string>Descending</string>
</property>
</widget>
</hbox>
</widget>
<widget class="QCheckBox">
<property name="name">
<cstring>descCB4</cstring>
</property>
<property name="geometry">
<rect>
<x>183</x>
<y>130</y>
<width>164</width>
<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 class="QLayoutWidget">
<property name="name">
<cstring>layout9</cstring>
</property>
<hbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="QCheckBox">
<property name="name">
<cstring>sortCB</cstring>
</property>
<property name="text">
<string>Sort the</string>
</property>
</widget>
<widget class="QSpinBox">
<property name="name">
<cstring>mcntSB</cstring>
</property>
<property name="enabled">
<bool>false</bool>
</property>
<property name="maxValue">
<number>10000</number>
</property>
<property name="value">
<number>100</number>
</property>
</widget>
<widget class="QLabel">
<property name="name">
<cstring>textLabel2</cstring>
</property>
<property name="text">
<string>most relevant results by:</string>
</property>
</widget>
</hbox>
</widget>
<widget class="QLayoutWidget">
<property name="name">
<cstring>layout3</cstring>
</property>
<hbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="QComboBox">
<property name="name">
<cstring>fldCMB1</cstring>
</property>
<property name="enabled">
<bool>false</bool>
</property>
</widget>
<widget class="QCheckBox">
<property name="name">
<cstring>descCB1</cstring>
</property>
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Descending</string>
</property>
</widget>
</hbox>
</widget>
<widget class="QLayoutWidget">
<property name="name">
<cstring>layout6</cstring>
</property>
<hbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="QComboBox">
<property name="name">
<cstring>fldCMB2</cstring>
</property>
<property name="enabled">
<bool>false</bool>
</property>
</widget>
<widget class="QCheckBox">
<property name="name">
<cstring>descCB2</cstring>
</property>
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Descending</string>
</property>
</widget>
</hbox>
</widget>
<widget class="QLayoutWidget">
<property name="name">
<cstring>layout7</cstring>
</property>
<hbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="QPushButton">
<property name="name">
<cstring>resetPB</cstring>
</property>
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Reset</string>
</property>
</widget>
<widget class="QPushButton">
<property name="name">
<cstring>closePB</cstring>
</property>
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Close</string>
</property>
</widget>
</hbox>
</widget>
</vbox>
</widget>
</vbox>
</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>
<include location="local" impldecl="in declaration">sortseq.h</include>
<include location="local" impldecl="in implementation">sort.ui.h</include>
</includes>
<signals>
<signal>sortDataChanged(int, RclSortSpec)</signal>
</signals>
<slots>
<slot>reset()</slot>
<slot>setData()</slot>
</slots>
<functions>
<function>init()</function>
</functions>
+58 -2
View File
@@ -10,10 +10,66 @@
** 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);
}