Fix sort state not correctly activated when set from saved state
This commit is contained in:
parent
8fd9d02900
commit
01aa85fd1c
@ -403,7 +403,6 @@ int main(int argc, char **argv)
|
|||||||
QTimer::singleShot(0, mainWindow, SLOT(initDbOpen()));
|
QTimer::singleShot(0, mainWindow, SLOT(initDbOpen()));
|
||||||
|
|
||||||
mainWindow->sSearch->searchTypCMB->setCurrentIndex(prefs.ssearchTyp);
|
mainWindow->sSearch->searchTypCMB->setCurrentIndex(prefs.ssearchTyp);
|
||||||
mainWindow->sSearch->searchTypeChanged(prefs.ssearchTyp);
|
|
||||||
if (op_flags & OPT_q) {
|
if (op_flags & OPT_q) {
|
||||||
SSearch::SSearchType stype;
|
SSearch::SSearchType stype;
|
||||||
if (op_flags & OPT_o) {
|
if (op_flags & OPT_o) {
|
||||||
|
|||||||
@ -70,8 +70,6 @@
|
|||||||
#include "readfile.h"
|
#include "readfile.h"
|
||||||
#include "moc_rclmain_w.cpp"
|
#include "moc_rclmain_w.cpp"
|
||||||
|
|
||||||
using std::pair;
|
|
||||||
|
|
||||||
QString g_stringAllStem, g_stringNoStem;
|
QString g_stringAllStem, g_stringNoStem;
|
||||||
static const char *settingskey_toolarea="/Recoll/geometry/toolArea";
|
static const char *settingskey_toolarea="/Recoll/geometry/toolArea";
|
||||||
static const char *settingskey_resarea="/Recoll/geometry/resArea";
|
static const char *settingskey_resarea="/Recoll/geometry/resArea";
|
||||||
@ -125,9 +123,6 @@ void RclMain::init()
|
|||||||
{
|
{
|
||||||
setWindowTitle(configToTitle());
|
setWindowTitle(configToTitle());
|
||||||
|
|
||||||
DocSequence::set_translations(
|
|
||||||
qs2utf8s(tr("sorted")), qs2utf8s(tr("filtered")));
|
|
||||||
|
|
||||||
buildMenus();
|
buildMenus();
|
||||||
|
|
||||||
// A shortcut to get the focus back to the search entry, in table
|
// A shortcut to get the focus back to the search entry, in table
|
||||||
@ -183,8 +178,6 @@ void RclMain::init()
|
|||||||
connect(sSearch,
|
connect(sSearch,
|
||||||
SIGNAL(startSearch(std::shared_ptr<Rcl::SearchData>, bool)),
|
SIGNAL(startSearch(std::shared_ptr<Rcl::SearchData>, bool)),
|
||||||
this, SLOT(startSearch(std::shared_ptr<Rcl::SearchData>, bool)));
|
this, SLOT(startSearch(std::shared_ptr<Rcl::SearchData>, bool)));
|
||||||
connect(sSearch, SIGNAL(searchTypeChanged(int)),
|
|
||||||
this, SLOT(onSearchTypeChanged(int)));
|
|
||||||
connect(sSearch, SIGNAL(setDescription(QString)),
|
connect(sSearch, SIGNAL(setDescription(QString)),
|
||||||
this, SLOT(onSetDescription(QString)));
|
this, SLOT(onSetDescription(QString)));
|
||||||
connect(sSearch, SIGNAL(clearSearch()),
|
connect(sSearch, SIGNAL(clearSearch()),
|
||||||
@ -268,6 +261,8 @@ void RclMain::init()
|
|||||||
restable, SLOT(readDocSource()));
|
restable, SLOT(readDocSource()));
|
||||||
connect(this, SIGNAL(sortDataChanged(DocSeqSortSpec)),
|
connect(this, SIGNAL(sortDataChanged(DocSeqSortSpec)),
|
||||||
restable, SLOT(onSortDataChanged(DocSeqSortSpec)));
|
restable, SLOT(onSortDataChanged(DocSeqSortSpec)));
|
||||||
|
connect(this, SIGNAL(sortDataChanged(DocSeqSortSpec)),
|
||||||
|
this, SLOT(onSortDataChanged(DocSeqSortSpec)));
|
||||||
connect(this, SIGNAL(uiPrefsChanged()), restable, SLOT(onUiPrefsChanged()));
|
connect(this, SIGNAL(uiPrefsChanged()), restable, SLOT(onUiPrefsChanged()));
|
||||||
|
|
||||||
connect(restable->getModel(), SIGNAL(sortDataChanged(DocSeqSortSpec)),
|
connect(restable->getModel(), SIGNAL(sortDataChanged(DocSeqSortSpec)),
|
||||||
@ -330,7 +325,6 @@ void RclMain::init()
|
|||||||
if (prefs.keepSort && prefs.sortActive) {
|
if (prefs.keepSort && prefs.sortActive) {
|
||||||
m_sortspec.field = (const char *)prefs.sortField.toUtf8();
|
m_sortspec.field = (const char *)prefs.sortField.toUtf8();
|
||||||
m_sortspec.desc = prefs.sortDesc;
|
m_sortspec.desc = prefs.sortDesc;
|
||||||
onSortDataChanged(m_sortspec);
|
|
||||||
emit sortDataChanged(m_sortspec);
|
emit sortDataChanged(m_sortspec);
|
||||||
}
|
}
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
@ -775,21 +769,6 @@ void RclMain::fileExit()
|
|||||||
qApp->exit(0);
|
qApp->exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset sort order when search type changes.
|
|
||||||
void RclMain::onSearchTypeChanged(int stp)
|
|
||||||
{
|
|
||||||
SSearch::SSearchType tp = (SSearch::SSearchType)stp;
|
|
||||||
switch (tp) {
|
|
||||||
case SSearch::SST_FNM:
|
|
||||||
m_sortspec.desc = false;
|
|
||||||
m_sortspec.field = "mtype";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
m_sortspec.reset();
|
|
||||||
break;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// Start a db query and set the reslist docsource
|
// Start a db query and set the reslist docsource
|
||||||
void RclMain::startSearch(std::shared_ptr<Rcl::SearchData> sdata, bool issimple)
|
void RclMain::startSearch(std::shared_ptr<Rcl::SearchData> sdata, bool issimple)
|
||||||
{
|
{
|
||||||
@ -831,7 +810,7 @@ void RclMain::startSearch(std::shared_ptr<Rcl::SearchData> sdata, bool issimple)
|
|||||||
curPreview = 0;
|
curPreview = 0;
|
||||||
DocSequenceDb *src =
|
DocSequenceDb *src =
|
||||||
new DocSequenceDb(rcldb, std::shared_ptr<Rcl::Query>(query),
|
new DocSequenceDb(rcldb, std::shared_ptr<Rcl::Query>(query),
|
||||||
string(tr("Query results").toUtf8()), sdata);
|
qs2utf8s(tr("Query results")), sdata);
|
||||||
src->setAbstractParams(prefs.queryBuildAbstract,
|
src->setAbstractParams(prefs.queryBuildAbstract,
|
||||||
prefs.queryReplaceAbstract);
|
prefs.queryReplaceAbstract);
|
||||||
m_source = std::shared_ptr<DocSequence>(src);
|
m_source = std::shared_ptr<DocSequence>(src);
|
||||||
@ -981,6 +960,14 @@ void RclMain::onSortDataChanged(DocSeqSortSpec spec)
|
|||||||
prefs.sortDesc = spec.desc;
|
prefs.sortDesc = spec.desc;
|
||||||
prefs.sortActive = !spec.field.empty();
|
prefs.sortActive = !spec.field.empty();
|
||||||
|
|
||||||
|
std::string fld;
|
||||||
|
if (!m_sortspec.field.empty()) {
|
||||||
|
fld = qs2utf8s(RecollModel::displayableField(m_sortspec.field));
|
||||||
|
}
|
||||||
|
DocSequence::set_translations(
|
||||||
|
qs2utf8s(tr("sorted")) + ": " + fld +
|
||||||
|
(m_sortspec.desc?" ↓":" ↑"),
|
||||||
|
qs2utf8s(tr("filtered")));
|
||||||
initiateQuery();
|
initiateQuery();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -146,7 +146,6 @@ public slots:
|
|||||||
virtual void previewPrevInTab(Preview *, int sid, int docnum);
|
virtual void previewPrevInTab(Preview *, int sid, int docnum);
|
||||||
virtual void previewExposed(Preview *, int sid, int docnum);
|
virtual void previewExposed(Preview *, int sid, int docnum);
|
||||||
virtual void resetSearch();
|
virtual void resetSearch();
|
||||||
virtual void onSearchTypeChanged(int);
|
|
||||||
virtual void eraseDocHistory();
|
virtual void eraseDocHistory();
|
||||||
virtual void eraseSearchHistory();
|
virtual void eraseSearchHistory();
|
||||||
virtual void exportSimpleSearchHistory();
|
virtual void exportSimpleSearchHistory();
|
||||||
|
|||||||
@ -255,7 +255,7 @@ RecollModel::RecollModel(const QStringList fields, ResTable *tb,
|
|||||||
o_displayableFields["relevancyrating"] = tr("Relevancy rating");
|
o_displayableFields["relevancyrating"] = tr("Relevancy rating");
|
||||||
o_displayableFields["title"] = tr("Title");
|
o_displayableFields["title"] = tr("Title");
|
||||||
o_displayableFields["url"] = tr("URL");
|
o_displayableFields["url"] = tr("URL");
|
||||||
o_displayableFields["mtime"] = tr("Mtime");
|
o_displayableFields["mtime"] = tr("Date");
|
||||||
o_displayableFields["date"] = tr("Date");
|
o_displayableFields["date"] = tr("Date");
|
||||||
o_displayableFields["datetime"] = tr("Date and time");
|
o_displayableFields["datetime"] = tr("Date and time");
|
||||||
|
|
||||||
@ -346,6 +346,12 @@ void RecollModel::addColumn(int col, const string& field)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString RecollModel::displayableField(const std::string& in)
|
||||||
|
{
|
||||||
|
const auto it = o_displayableFields.find(in);
|
||||||
|
return (it == o_displayableFields.end()) ? u8s2qs(in) : it->second;
|
||||||
|
}
|
||||||
|
|
||||||
QVariant RecollModel::headerData(int idx, Qt::Orientation orientation,
|
QVariant RecollModel::headerData(int idx, Qt::Orientation orientation,
|
||||||
int role) const
|
int role) const
|
||||||
{
|
{
|
||||||
@ -357,12 +363,7 @@ QVariant RecollModel::headerData(int idx, Qt::Orientation orientation,
|
|||||||
}
|
}
|
||||||
if (orientation == Qt::Horizontal && role == Qt::DisplayRole &&
|
if (orientation == Qt::Horizontal && role == Qt::DisplayRole &&
|
||||||
idx < int(m_fields.size())) {
|
idx < int(m_fields.size())) {
|
||||||
map<string, QString>::const_iterator it =
|
return displayableField(m_fields[idx]);
|
||||||
o_displayableFields.find(m_fields[idx]);
|
|
||||||
if (it == o_displayableFields.end())
|
|
||||||
return QString::fromUtf8(m_fields[idx].c_str());
|
|
||||||
else
|
|
||||||
return it->second;
|
|
||||||
}
|
}
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -56,10 +56,10 @@ public:
|
|||||||
virtual std::shared_ptr<DocSequence> getDocSource() {return m_source;}
|
virtual std::shared_ptr<DocSequence> getDocSource() {return m_source;}
|
||||||
virtual void deleteColumn(int);
|
virtual void deleteColumn(int);
|
||||||
virtual const std::vector<std::string>& getFields() {return m_fields;}
|
virtual const std::vector<std::string>& getFields() {return m_fields;}
|
||||||
virtual const std::map<std::string, QString>& getAllFields()
|
static const std::map<std::string, QString>& getAllFields() {
|
||||||
{
|
return o_displayableFields;
|
||||||
return o_displayableFields;
|
|
||||||
}
|
}
|
||||||
|
static QString displayableField(const std::string& in);
|
||||||
virtual void addColumn(int, const std::string&);
|
virtual void addColumn(int, const std::string&);
|
||||||
// Some column name are aliases/translator for base document field
|
// Some column name are aliases/translator for base document field
|
||||||
// (ie: date, datetime->mtime). Help deal with this:
|
// (ie: date, datetime->mtime). Help deal with this:
|
||||||
|
|||||||
@ -441,7 +441,6 @@ void SSearch::onSearchTypeChanged(int typ)
|
|||||||
default:
|
default:
|
||||||
queryText->setToolTip(tr("Enter search terms here."));
|
queryText->setToolTip(tr("Enter search terms here."));
|
||||||
}
|
}
|
||||||
emit searchTypeChanged((int)typ);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SSearch::startSimpleSearch()
|
void SSearch::startSimpleSearch()
|
||||||
|
|||||||
@ -106,7 +106,6 @@ private slots:
|
|||||||
virtual void onCompleterShown();
|
virtual void onCompleterShown();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void searchTypeChanged(int);
|
|
||||||
void startSearch(std::shared_ptr<Rcl::SearchData>, bool);
|
void startSearch(std::shared_ptr<Rcl::SearchData>, bool);
|
||||||
void setDescription(QString);
|
void setDescription(QString);
|
||||||
void clearSearch();
|
void clearSearch();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user