diff --git a/src/qtgui/guiutils.cpp b/src/qtgui/guiutils.cpp
index e424eb6a..07b8cba0 100644
--- a/src/qtgui/guiutils.cpp
+++ b/src/qtgui/guiutils.cpp
@@ -97,8 +97,6 @@ void rwSettings(bool writing)
SETTING_RW(prefs.ssearchTyp, "/Recoll/prefs/simpleSearchTyp", Int, 3);
SETTING_RW(prefs.startWithAdvSearchOpen,
"/Recoll/prefs/startWithAdvSearchOpen", Bool, false);
- SETTING_RW(prefs.startWithSortToolOpen,
- "/Recoll/prefs/startWithSortToolOpen", Bool, false);
SETTING_RW(prefs.previewHtml,
"/Recoll/prefs/previewHtml", Bool, true);
@@ -160,6 +158,8 @@ void rwSettings(bool writing)
"/Recoll/prefs/keepSort", Bool, false);
SETTING_RW(prefs.sortActive,
"/Recoll/prefs/sortActive", Bool, false);
+ SETTING_RW(prefs.sortDesc,
+ "/Recoll/prefs/query/sortDesc", Bool, 0);
SETTING_RW(prefs.queryBuildAbstract,
"/Recoll/prefs/query/buildAbstract", Bool, true);
SETTING_RW(prefs.queryReplaceAbstract,
@@ -172,10 +172,6 @@ void rwSettings(bool writing)
SETTING_RW(prefs.autoSuffsEnable,
"/Recoll/prefs/query/autoSuffsEnable", Bool, false);
- SETTING_RW(prefs.sortDepth, "/Recoll/prefs/query/sortDepth",
- Int, 100);
- SETTING_RW(prefs.sortSpec, "/Recoll/prefs/query/sortSpec",
- Int, 0);
SETTING_RW(prefs.termMatchType, "/Recoll/prefs/query/termMatchType",
Int, 0);
SETTING_RW(prefs.rclVersion, "/Recoll/prefs/rclVersion",
diff --git a/src/qtgui/guiutils.h b/src/qtgui/guiutils.h
index 15fb5642..f068cbc4 100644
--- a/src/qtgui/guiutils.h
+++ b/src/qtgui/guiutils.h
@@ -78,12 +78,12 @@ class PrefsPack {
int pvheight;
int ssearchTyp;
bool useDesktopOpen; // typically xdg-open, instead of mimeview settings
- bool keepSort; // remember sort status between invocations
+ bool keepSort; // Remember sort status between invocations
bool sortActive; // Remembered sort state.
+ bool sortDesc; // ..
bool queryBuildAbstract;
bool queryReplaceAbstract;
bool startWithAdvSearchOpen;
- bool startWithSortToolOpen;
bool previewHtml;
bool collapseDuplicates;
// Extra query indexes. This are stored in the history file, not qt prefs
@@ -108,14 +108,11 @@ class PrefsPack {
int syntAbsLen;
int syntAbsCtx;
- // Sort specs (sort_w.cpp knows how to deal with the values
- int sortDepth;
- int sortSpec;
-
// Remembered term match mode
int termMatchType;
- // Program version that wrote this
+ // Program version that wrote this. Not used for now, in prevision
+ // of the case where we might need an incompatible change
int rclVersion;
// Advanced search window clause list state
@@ -131,7 +128,6 @@ class PrefsPack {
queryBuildAbstract(true),
queryReplaceAbstract(false),
startWithAdvSearchOpen(false),
- startWithSortToolOpen(false),
termMatchType(0),
rclVersion(1009)
{
diff --git a/src/qtgui/images/d_firstpage.png b/src/qtgui/images/d_firstpage.png
deleted file mode 100644
index ec0dc01e..00000000
Binary files a/src/qtgui/images/d_firstpage.png and /dev/null differ
diff --git a/src/qtgui/images/d_nextpage.png b/src/qtgui/images/d_nextpage.png
deleted file mode 100644
index 5de60770..00000000
Binary files a/src/qtgui/images/d_nextpage.png and /dev/null differ
diff --git a/src/qtgui/images/d_prevpage.png b/src/qtgui/images/d_prevpage.png
deleted file mode 100644
index dafefa47..00000000
Binary files a/src/qtgui/images/d_prevpage.png and /dev/null differ
diff --git a/src/qtgui/images/d_spell.png b/src/qtgui/images/d_spell.png
deleted file mode 100644
index 270a5b33..00000000
Binary files a/src/qtgui/images/d_spell.png and /dev/null differ
diff --git a/src/qtgui/images/down.png b/src/qtgui/images/down.png
new file mode 100755
index 00000000..c5eafbda
Binary files /dev/null and b/src/qtgui/images/down.png differ
diff --git a/src/qtgui/images/up.png b/src/qtgui/images/up.png
new file mode 100755
index 00000000..6116d9c4
Binary files /dev/null and b/src/qtgui/images/up.png differ
diff --git a/src/qtgui/main.cpp b/src/qtgui/main.cpp
index 1325bf91..f7c6b159 100644
--- a/src/qtgui/main.cpp
+++ b/src/qtgui/main.cpp
@@ -65,7 +65,6 @@ RclDynConf *g_dynconf;
int recollNeedsExit;
int startIndexingAfterConfig;
RclMain *mainWindow;
-static string recollsharedir;
void startManual(const string& helpindex)
{
diff --git a/src/qtgui/rclmain.ui b/src/qtgui/rclmain.ui
index dcda3168..eb4a98ee 100644
--- a/src/qtgui/rclmain.ui
+++ b/src/qtgui/rclmain.ui
@@ -84,7 +84,6 @@
false
-
@@ -101,6 +100,9 @@
+
+
+
qPixmapFromMimeSource
@@ -364,6 +425,8 @@
ssearch_w.h
reslist.h
-
+
+
+
diff --git a/src/qtgui/rclmain_w.cpp b/src/qtgui/rclmain_w.cpp
index 83037a75..dfc89c19 100644
--- a/src/qtgui/rclmain_w.cpp
+++ b/src/qtgui/rclmain_w.cpp
@@ -91,7 +91,6 @@ void RclMain::init()
curPreview = 0;
asearchform = 0;
- sortform = 0;
uiprefs = 0;
indexConfig = 0;
spellform = 0;
@@ -247,8 +246,6 @@ void RclMain::init()
this, SLOT(showDocHistory()));
connect(toolsAdvanced_SearchAction, SIGNAL(activated()),
this, SLOT(showAdvSearchDialog()));
- connect(toolsSort_parametersAction, SIGNAL(activated()),
- this, SLOT(showSortDialog()));
connect(toolsSpellAction, SIGNAL(activated()),
this, SLOT(showSpellDialog()));
@@ -264,23 +261,24 @@ void RclMain::init()
// speeded up during indexing
periodictimer->start(1000);
- toolsSpellAction->setIcon(QIcon(":/images/spell.png"));
- nextPageAction->setIcon(QIcon(":/images/nextpage.png"));
- prevPageAction->setIcon(QIcon(":/images/prevpage.png"));
- firstPageAction->setIcon(QIcon(":/images/firstpage.png"));
- toolsDoc_HistoryAction->setIcon(QIcon(":/images/history.png"));
- toolsAdvanced_SearchAction->setIcon(QIcon(":/images/asearch.png"));
- toolsSort_parametersAction->setIcon(QIcon(":/images/sortparms.png"));
-
- // If requested by prefs, restore sort state. The easiest way is to let
- // a SortForm do it for us.
+ connect(this, SIGNAL(sortDataChanged(DocSeqSortSpec)),
+ resList, SLOT(setSortParams(DocSeqSortSpec)));
+ connect(resList, SIGNAL(hasResults(int)), this, SLOT(resultCount(int)));
+ connect(this, SIGNAL(applySortData()), resList, SLOT(setDocSource()));
if (prefs.keepSort && prefs.sortActive) {
- SortForm sf(0);
- connect(&sf, SIGNAL(sortDataChanged(DocSeqSortSpec)),
- resList, SLOT(setSortParams(DocSeqSortSpec)));
- // Have to call setdata again after sig connected...
- sf.setData();
+ if (prefs.sortDesc)
+ actionSortByDateDesc->setChecked(true);
+ else
+ actionSortByDateAsc->setChecked(true);
+ onSortDataChanged();
}
+
+}
+
+void RclMain::resultCount(int n)
+{
+ actionSortByDateAsc->setEnabled(n>0);
+ actionSortByDateDesc->setEnabled(n>0);
}
// This is called by a timer right after we come up. Try to open
@@ -318,8 +316,6 @@ void RclMain::initDbOpen()
} else {
if (prefs.startWithAdvSearchOpen)
showAdvSearchDialog();
- if (prefs.startWithSortToolOpen)
- showSortDialog();
// If we have something in the search entry, it comes from a
// command line argument
if (!nodb && sSearch->hasSearchString())
@@ -590,22 +586,6 @@ void RclMain::showAdvSearchDialog()
}
}
-void RclMain::showSortDialog()
-{
- if (sortform == 0) {
- sortform = new SortForm(0);
- connect(sortform, SIGNAL(sortDataChanged(DocSeqSortSpec)),
- resList, SLOT(setSortParams(DocSeqSortSpec)));
- connect(sortform, SIGNAL(applySortData()),
- resList, SLOT(setDocSource()));
- sortform->show();
- } else {
- // Close and reopen, in hope that makes us visible...
- sortform->close();
- sortform->show();
- }
-}
-
void RclMain::showSpellDialog()
{
if (spellform == 0) {
@@ -824,6 +804,53 @@ void RclMain::previewExposed(Preview *, int sid, int docnum)
resList->previewExposed(docnum);
}
+void RclMain::onSortDataChanged()
+{
+ LOGDEB(("RclMain::onSortDataChanged()\n"));
+ DocSeqSortSpec spec;
+ if (actionSortByDateAsc->isChecked()) {
+ spec.addCrit(DocSeqSortSpec::RCLFLD_MTIME, false);
+ spec.sortdepth = 1000000;
+ prefs.sortActive = true;
+ prefs.sortDesc = false;
+ } else if (actionSortByDateDesc->isChecked()) {
+ spec.addCrit(DocSeqSortSpec::RCLFLD_MTIME, true);
+ spec.sortdepth = 1000000;
+ prefs.sortActive = true;
+ prefs.sortDesc = true;
+ } else {
+ prefs.sortActive = prefs.sortDesc = false;
+ }
+ emit sortDataChanged(spec);
+ emit applySortData();
+}
+
+void RclMain::on_actionSortByDateAsc_toggled(bool on)
+{
+ LOGDEB(("RclMain::on_actionSortByDateAsc_toggled(%d)\n", int(on)));
+ if (on) {
+ if (actionSortByDateDesc->isChecked()) {
+ actionSortByDateDesc->setChecked(false);
+ // Let our buddy work.
+ return;
+ }
+ }
+ onSortDataChanged();
+}
+
+void RclMain::on_actionSortByDateDesc_toggled(bool on)
+{
+ LOGDEB(("RclMain::on_actionSortByDateDesc_toggled(%d)\n", int(on)));
+ if (on) {
+ if (actionSortByDateAsc->isChecked()) {
+ actionSortByDateAsc->setChecked(false);
+ // Let our buddy work.
+ return;
+ }
+ }
+ onSortDataChanged();
+}
+
// Add term to simple search. Term comes out of double-click in
// reslist or preview.
// It would probably be better to cleanup in preview.ui.h and
diff --git a/src/qtgui/rclmain_w.h b/src/qtgui/rclmain_w.h
index 4fdd4291..b6e2ad24 100644
--- a/src/qtgui/rclmain_w.h
+++ b/src/qtgui/rclmain_w.h
@@ -23,7 +23,6 @@
#include "preview_w.h"
#include "recoll.h"
#include "advsearch_w.h"
-#include "sort_w.h"
#include "uiprefs_w.h"
#include "rcldb.h"
#include "searchdata.h"
@@ -64,7 +63,6 @@ public slots:
virtual void startSearch(RefCntr sdata);
virtual void previewClosed(Preview *w);
virtual void showAdvSearchDialog();
- virtual void showSortDialog();
virtual void showSpellDialog();
virtual void showAboutDialog();
virtual void showMissingHelpers();
@@ -97,9 +95,14 @@ public slots:
virtual void initDbOpen();
virtual void toggleFullScreen();
virtual void focusToSearch();
+ virtual void on_actionSortByDateAsc_toggled(bool on);
+ virtual void on_actionSortByDateDesc_toggled(bool on);
+ virtual void resultCount(int);
signals:
void stemLangChanged(const QString& lang);
+ void sortDataChanged(DocSeqSortSpec);
+ void applySortData();
protected:
virtual void closeEvent( QCloseEvent * );
@@ -107,7 +110,6 @@ protected:
private:
Preview *curPreview;
AdvSearch *asearchform;
- SortForm *sortform;
UIPrefsDialog *uiprefs;
ConfIndexW *indexConfig;
SpellW *spellform;
@@ -125,6 +127,7 @@ private:
virtual void previewPrevOrNextInTab(Preview *, int sid, int docnum,
bool next);
virtual void setStemLang(const QString& lang);
+ virtual void onSortDataChanged();
};
#endif // RCLMAIN_W_H
diff --git a/src/qtgui/recoll.pro.in b/src/qtgui/recoll.pro.in
index eebeaff1..ae889862 100644
--- a/src/qtgui/recoll.pro.in
+++ b/src/qtgui/recoll.pro.in
@@ -12,7 +12,6 @@ HEADERS += \
../qtgui/rclmain_w.h \
../qtgui/reslist.h \
../qtgui/searchclause_w.h \
- ../qtgui/sort_w.h \
../qtgui/spell_w.h \
../qtgui/ssearch_w.h \
../qtgui/uiprefs_w.h \
@@ -31,7 +30,6 @@ SOURCES += \
../qtgui/rclmain_w.cpp \
../qtgui/reslist.cpp \
../qtgui/searchclause_w.cpp \
- ../qtgui/sort_w.cpp \
../qtgui/spell_w.cpp \
../qtgui/ssearch_w.cpp \
../qtgui/uiprefs_w.cpp \
@@ -42,13 +40,11 @@ SOURCES += \
FORMS = \
advsearch.ui \
rclmain.ui \
- sort.ui \
spell.ui \
ssearchb.ui \
uiprefs.ui \
viewaction.ui \
-
RESOURCES = recoll.qrc
unix {
diff --git a/src/qtgui/recoll.qrc b/src/qtgui/recoll.qrc
index 8d96d494..0b92ae56 100644
--- a/src/qtgui/recoll.qrc
+++ b/src/qtgui/recoll.qrc
@@ -9,5 +9,7 @@
images/firstpage.png
images/sortparms.png
images/spell.png
+ images/up.png
+ images/down.png
diff --git a/src/qtgui/reslist.cpp b/src/qtgui/reslist.cpp
index 9384e43a..9b130344 100644
--- a/src/qtgui/reslist.cpp
+++ b/src/qtgui/reslist.cpp
@@ -273,6 +273,7 @@ void ResList::setDocSource(RefCntr ndocsource)
// Reapply parameters. Sort params probably changed
void ResList::setDocSource()
{
+ LOGDEB(("ResList::setDocSource\n"));
if (m_baseDocSource.isNull())
return;
resetList();
@@ -292,23 +293,29 @@ void ResList::setDocSource()
title));
}
}
-
- if (m_sortspecs.isNotNull()) {
- string title = m_baseDocSource->title() + " (" +
- string((const char *)tr("sorted").toUtf8()) + ")";
- m_docSource = RefCntr(new DocSeqSorted(m_docSource,
- m_sortspecs,
- title));
+
+ if (m_docSource->canSort()) {
+ m_docSource->setSortSpec(m_sortspecs);
+ } else {
+ if (m_sortspecs.isNotNull()) {
+ LOGDEB(("Reslist: sortspecs not Null\n"));
+ string title = m_baseDocSource->title() + " (" +
+ string((const char *)tr("sorted").toUtf8()) + ")";
+ m_docSource = RefCntr(new DocSeqSorted(m_docSource,
+ m_sortspecs,
+ title));
+ }
}
// Reset the page size in case the preference was changed
m_pager->setPageSize(prefs.respagesize);
m_pager->setDocSource(m_docSource);
resultPageNext();
+ emit hasResults(getResCnt());
}
void ResList::setSortParams(DocSeqSortSpec spec)
{
- LOGDEB(("ResList::setSortParams\n"));
+ LOGDEB(("ResList::setSortParams: %s\n", spec.isNotNull() ? "notnull":"null"));
m_sortspecs = spec;
}
diff --git a/src/qtgui/reslist.h b/src/qtgui/reslist.h
index 7f6f84a9..af025513 100644
--- a/src/qtgui/reslist.h
+++ b/src/qtgui/reslist.h
@@ -91,6 +91,7 @@ class ResList : public QTextBrowser
void docExpand(int);
void wordSelect(QString);
void linkClicked(const QString&, int); // See emitLinkClicked()
+ void hasResults(int);
protected:
void keyPressEvent(QKeyEvent *e);
diff --git a/src/qtgui/sort.ui b/src/qtgui/sort.ui
deleted file mode 100644
index 179c3e3b..00000000
--- a/src/qtgui/sort.ui
+++ /dev/null
@@ -1,128 +0,0 @@
-
-
-
-
-
- SortFormBase
-
-
-
- 0
- 0
- 200
- 100
-
-
-
- Sort Criteria
-
-
- -
-
-
-
-
-
-
-
-
- Sort the
-
-
-
- -
-
-
- false
-
-
- 10000
-
-
- 100
-
-
-
- -
-
-
- most relevant results by:
-
-
- false
-
-
-
-
-
- -
-
-
-
-
-
- false
-
-
-
- -
-
-
- false
-
-
- Descending
-
-
-
-
-
- -
-
-
-
-
-
- false
-
-
-
- -
-
-
- false
-
-
- Descending
-
-
-
-
-
- -
-
-
-
-
-
- true
-
-
- Apply
-
-
-
- -
-
-
- true
-
-
- Close
-
-
-
-
-
-
-
-
-
-
- qPixmapFromMimeSource
-
diff --git a/src/qtgui/sort_w.cpp b/src/qtgui/sort_w.cpp
deleted file mode 100644
index d4e71d58..00000000
--- a/src/qtgui/sort_w.cpp
+++ /dev/null
@@ -1,142 +0,0 @@
-#ifndef lint
-static char rcsid[] = "@(#$Id: sort_w.cpp,v 1.7 2008-09-28 14:20:50 dockes Exp $ (C) 2006 J.F.Dockes";
-#endif
-/*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the
- * Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#include
-#include
-#include
-#include
-
-#include "sortseq.h"
-#include "debuglog.h"
-#include "guiutils.h"
-#include "rclhelp.h"
-#include "sort_w.h"
-
-void SortForm::init()
-{
- QStringList slabs;
- slabs += QString();
- slabs += tr("Date");
- slabs += tr("Mime type");
-
- fldCMB1->addItems(slabs);
- fldCMB2->addItems(slabs);
-
- // Initialize values from prefs:
- mcntSB->setValue(prefs.sortDepth);
- unsigned int spec = (unsigned int)prefs.sortSpec;
-
- // Restore active/inactive state from prefs, only if requested
- if (prefs.keepSort) {
- sortCB->setChecked(prefs.sortActive);
- } else {
- sortCB->setChecked(false);
- }
-
- // We use 4 bits per spec hi is direction, 3 low bits = sort field
- unsigned int v, d;
-
- v = spec & (0xf & ~(1<<3));
- d = spec & (1 << 3);
- spec >>= 4;
- fldCMB1->setCurrentIndex(v < 3 ? v : 0);
- descCB1->setChecked(d != 0 ? true : false);
-
- v = spec & (0xf & ~(1<<3));
- d = spec & (1 << 3);
- spec >>= 4;
- fldCMB2->setCurrentIndex(v < 3 ? v : 0);
- descCB2->setChecked(d !=0 ? true : false);
-
- (void)new HelpClient(this);
- HelpClient::installMap((const char *)this->objectName().toUtf8(),
- "RCL.SEARCH.SORT");
-
- // signals and slots connections
- connect(applyPB, SIGNAL(clicked()), this, SLOT(apply()));
- connect(closePB, SIGNAL(clicked()), this, SLOT(close()));
- connect(mcntSB, SIGNAL(valueChanged(int)), this, SLOT(setData()));
- connect(fldCMB1, SIGNAL(activated(const QString&)), this, SLOT(setData()));
- connect(fldCMB2, SIGNAL(activated(const QString&)), this, SLOT(setData()));
- connect(descCB1, SIGNAL(stateChanged(int)), this, SLOT(setData()));
- connect(descCB2, SIGNAL(stateChanged(int)), this, SLOT(setData()));
- connect(sortCB, SIGNAL(toggled(bool)), this, SLOT(setData()));
-
- // Finalize state
- setData();
-}
-
-// This is called when the 'apply' button is pressed. We
-void SortForm::apply()
-{
- setData();
- emit applySortData();
-}
-
-void SortForm::setData()
-{
- LOGDEB(("SortForm::setData\n"));
- DocSeqSortSpec spec;
-
- mcntSB->setEnabled(sortCB->isChecked());
- fldCMB1->setEnabled(sortCB->isChecked());
- descCB1->setEnabled(sortCB->isChecked());
- fldCMB2->setEnabled(sortCB->isChecked());
- descCB2->setEnabled(sortCB->isChecked());
-
- prefs.sortActive = sortCB->isChecked();
-
- if (!sortCB->isChecked()) {
- spec.sortdepth = 0;
- } else {
- bool desc = descCB1->isChecked();
- switch (fldCMB1->currentIndex()) {
- case 1:
- spec.addCrit(DocSeqSortSpec::RCLFLD_MTIME, desc?true:false);
- break;
- case 2:
- spec.addCrit(DocSeqSortSpec::RCLFLD_MIMETYPE, desc?true:false);
- break;
- }
-
- desc = descCB2->isChecked();
- switch (fldCMB2->currentIndex()) {
- case 1:
- spec.addCrit(DocSeqSortSpec::RCLFLD_MTIME, desc?true:false);
- break;
- case 2:
- spec.addCrit(DocSeqSortSpec::RCLFLD_MIMETYPE, desc?true:false);
- break;
- }
- spec.sortdepth = mcntSB->value();
-
- // Save data to prefs;
- prefs.sortDepth = spec.sortdepth;
- unsigned int spec = 0, v, d;
- v = fldCMB1->currentIndex() & 0x7;
- d = descCB1->isChecked() ? 8 : 0;
- spec |= (d|v);
- v = fldCMB2->currentIndex() & 0x7;
- d = descCB2->isChecked() ? 8 : 0;
- spec |= (d|v) << 4;
- prefs.sortSpec = (int) spec;
- }
- emit sortDataChanged(spec);
-}
diff --git a/src/qtgui/sort_w.h b/src/qtgui/sort_w.h
deleted file mode 100644
index 88dd9c57..00000000
--- a/src/qtgui/sort_w.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/* @(#$Id: sort_w.h,v 1.5 2006-12-05 15:23:50 dockes Exp $ (C) 2005 J.F.Dockes */
-/*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the
- * Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-#ifndef _SORT_W_H_INCLUDED_
-#define _SORT_W_H_INCLUDED_
-
-#include
-#include
-#include "sortseq.h"
-#include "ui_sort.h"
-
-class QDialog;
-
-class SortForm : public QDialog, public Ui::SortFormBase
-{
- Q_OBJECT
-
-public:
- SortForm(QWidget* parent = 0)
- : QDialog(parent)
- {
- setupUi(this);
- init();
- }
- ~SortForm() {}
-
-public slots:
- virtual void apply();
- virtual void setData();
-
-signals:
- void sortDataChanged(DocSeqSortSpec);
- void applySortData();
-private:
- virtual void init();
-};
-
-
-#endif /* _SORT_W_H_INCLUDED_ */
diff --git a/src/qtgui/uiprefs.ui b/src/qtgui/uiprefs.ui
index 703da789..69106d33 100644
--- a/src/qtgui/uiprefs.ui
+++ b/src/qtgui/uiprefs.ui
@@ -254,16 +254,6 @@
- -
-
-
- Start with sort dialog open.
-
-
- false
-
-
-
-
diff --git a/src/qtgui/uiprefs_w.cpp b/src/qtgui/uiprefs_w.cpp
index 4ca2154d..6fa09ace 100644
--- a/src/qtgui/uiprefs_w.cpp
+++ b/src/qtgui/uiprefs_w.cpp
@@ -96,7 +96,6 @@ void UIPrefsDialog::setFromPrefs()
syntctxSB->setValue(prefs.syntAbsCtx);
initStartAdvCB->setChecked(prefs.startWithAdvSearchOpen);
- initStartSortCB->setChecked(prefs.startWithSortToolOpen);
// External editor. Can use desktop prefs or internal
useDesktopOpenCB->setChecked(prefs.useDesktopOpen);
@@ -204,7 +203,6 @@ void UIPrefsDialog::accept()
replAbsCB->isChecked();
prefs.startWithAdvSearchOpen = initStartAdvCB->isChecked();
- prefs.startWithSortToolOpen = initStartSortCB->isChecked();
prefs.useDesktopOpen = useDesktopOpenCB->isChecked();
prefs.keepSort = keepSortCB->isChecked();
prefs.previewHtml = previewHtmlCB->isChecked();
diff --git a/src/query/docseqdb.cpp b/src/query/docseqdb.cpp
index 255b5d57..b6c78479 100644
--- a/src/query/docseqdb.cpp
+++ b/src/query/docseqdb.cpp
@@ -129,8 +129,23 @@ string DocSequenceDb::title()
return m_filt ? DocSequence::title() + " (filtered)" : DocSequence::title();
}
-// TBDone
bool DocSequenceDb::setSortSpec(DocSeqSortSpec &sortspec)
{
- return true;
+ if (sortspec.isNotNull()) {
+ bool ascending = false;
+ for (unsigned int i = 0; i < sortspec.crits.size(); i++) {
+ switch (sortspec.crits[i]) {
+ case DocSeqSortSpec::RCLFLD_MTIME:
+ ascending = !sortspec.dirs[i];
+ break;
+ default:
+ break;
+ }
+ }
+ m_q->setSortBy("mtime", ascending);
+ } else {
+ m_q->setSortBy(string(), true);
+ }
+ return m_q->setQuery(m_fsdata);
}
+
diff --git a/src/query/docseqdb.h b/src/query/docseqdb.h
index bba1628e..d7846a0f 100644
--- a/src/query/docseqdb.h
+++ b/src/query/docseqdb.h
@@ -42,7 +42,7 @@ class DocSequenceDb : public DocSequence {
virtual list expand(Rcl::Doc &doc);
virtual bool canFilter() {return true;}
virtual bool setFiltSpec(DocSeqFiltSpec &filtspec);
- virtual bool canSort() {return false;}
+ virtual bool canSort() {return true;}
virtual bool setSortSpec(DocSeqSortSpec &sortspec);
virtual string title();
virtual void setAbstractParams(bool qba, bool qra)
diff --git a/src/rcldb/rcldb.cpp b/src/rcldb/rcldb.cpp
index 9edaf782..29141732 100644
--- a/src/rcldb/rcldb.cpp
+++ b/src/rcldb/rcldb.cpp
@@ -105,6 +105,12 @@ static inline string make_parentterm(const string& udi)
return pterm;
}
+static inline void leftzeropad(string& s, unsigned len)
+{
+ if (s.length() && s.length() < len)
+ s = s.insert(0, len - s.length(), '0');
+}
+
/* See comment in class declaration: return all subdocuments of a
* document given by its unique id.
*/
@@ -172,6 +178,7 @@ bool Db::Native::dbDataToRclDoc(Xapian::docid docid, std::string &data,
if (doc.meta.find(*it) == doc.meta.end())
parms.get(*it, doc.meta[*it]);
}
+ doc.meta[Doc::keymt] = doc.dmtime.empty() ? doc.fmtime : doc.dmtime;
return true;
}
@@ -861,12 +868,6 @@ void Db::setAbstractParams(int idxtrunc, int syntlen, int syntctxlen)
m_synthAbsWordCtxLen = syntctxlen;
}
-static inline void leftzeropad(string& s, unsigned len)
-{
- if (s.length() && s.length() < len)
- s = s.insert(0, len-s.length(), '0');
-}
-
static const int MB = 1024 * 1024;
static const string nc("\n\r\x0c");
diff --git a/src/rcldb/rclquery.cpp b/src/rcldb/rclquery.cpp
index 3d4edd01..b5a84a76 100644
--- a/src/rcldb/rclquery.cpp
+++ b/src/rcldb/rclquery.cpp
@@ -27,18 +27,34 @@ namespace Rcl {
// Sort helper class
class QSorter : public Xapian::Sorter {
public:
- QSorter(const string& f) : m_fld(docfToDatf(f) + "=") {}
+ QSorter(const string& f)
+ : m_fld(docfToDatf(f) + "=")
+ {
+ m_ismtime = !m_fld.compare("mtime=");
+ if (m_ismtime) {
+ m_fld = "dmtime=";
+ }
+ }
- virtual std::string operator()(const Xapian::Document& xdoc) const {
+ virtual std::string operator()(const Xapian::Document& xdoc) const
+ {
string data = xdoc.get_data();
-
// It would be simpler to do the record->Rcl::Doc thing, but
// hand-doing this will be faster. It makes more assumptions
// about the format than a ConfTree though:
string::size_type i1, i2;
i1 = data.find(m_fld);
- if (i1 == string::npos)
- return string();
+ if (i1 == string::npos) {
+ if (m_ismtime) {
+ // Ugly: specialcase mtime as it's either dmtime or fmtime
+ i1 = data.find("fmtime=");
+ if (i1 == string::npos) {
+ return string();
+ }
+ } else {
+ return string();
+ }
+ }
i1 += m_fld.length();
if (i1 >= data.length())
return string();
@@ -50,6 +66,7 @@ public:
private:
string m_fld;
+ bool m_ismtime;
};
Query::Query(Db *db)
@@ -78,8 +95,12 @@ Db *Query::whatDb()
}
void Query::setSortBy(const string& fld, bool ascending) {
- m_sortField = m_db->getConf()->fieldCanon(fld);
- m_sortAscending = ascending;
+ if (fld.empty()) {
+ m_sortField.erase();
+ } else {
+ m_sortField = m_db->getConf()->fieldCanon(fld);
+ m_sortAscending = ascending;
+ }
LOGDEB0(("RclQuery::setSortBy: [%s] %s\n", m_sortField.c_str(),
m_sortAscending ? "ascending" : "descending"));
}