GUI: extend sort state persistence to non-date fields
This commit is contained in:
parent
87dadc42bd
commit
21aa44b39e
@ -146,12 +146,21 @@ void rwSettings(bool writing)
|
|||||||
"english");
|
"english");
|
||||||
SETTING_RW(prefs.useDesktopOpen,
|
SETTING_RW(prefs.useDesktopOpen,
|
||||||
"/Recoll/prefs/useDesktopOpen", Bool, true);
|
"/Recoll/prefs/useDesktopOpen", Bool, true);
|
||||||
|
|
||||||
SETTING_RW(prefs.keepSort,
|
SETTING_RW(prefs.keepSort,
|
||||||
"/Recoll/prefs/keepSort", Bool, false);
|
"/Recoll/prefs/keepSort", Bool, false);
|
||||||
|
SETTING_RW(prefs.sortField, "/Recoll/prefs/sortField", String, "");
|
||||||
SETTING_RW(prefs.sortActive,
|
SETTING_RW(prefs.sortActive,
|
||||||
"/Recoll/prefs/sortActive", Bool, false);
|
"/Recoll/prefs/sortActive", Bool, false);
|
||||||
SETTING_RW(prefs.sortDesc,
|
SETTING_RW(prefs.sortDesc,
|
||||||
"/Recoll/prefs/query/sortDesc", Bool, 0);
|
"/Recoll/prefs/query/sortDesc", Bool, 0);
|
||||||
|
if (!writing) {
|
||||||
|
// Handle transition from older prefs which did not store sortColumn
|
||||||
|
// (Active always meant sort by date).
|
||||||
|
if (prefs.sortActive && prefs.sortField.isNull())
|
||||||
|
prefs.sortField = "mtime";
|
||||||
|
}
|
||||||
|
|
||||||
SETTING_RW(prefs.queryBuildAbstract,
|
SETTING_RW(prefs.queryBuildAbstract,
|
||||||
"/Recoll/prefs/query/buildAbstract", Bool, true);
|
"/Recoll/prefs/query/buildAbstract", Bool, true);
|
||||||
SETTING_RW(prefs.queryReplaceAbstract,
|
SETTING_RW(prefs.queryReplaceAbstract,
|
||||||
|
|||||||
@ -58,6 +58,7 @@ class PrefsPack {
|
|||||||
bool useDesktopOpen;
|
bool useDesktopOpen;
|
||||||
// Remember sort state between invocations ?
|
// Remember sort state between invocations ?
|
||||||
bool keepSort;
|
bool keepSort;
|
||||||
|
QString sortField;
|
||||||
bool sortActive;
|
bool sortActive;
|
||||||
bool sortDesc;
|
bool sortDesc;
|
||||||
// Abstract preferences. Building abstracts can slow result display
|
// Abstract preferences. Building abstracts can slow result display
|
||||||
|
|||||||
@ -260,8 +260,8 @@ void RclMain::init()
|
|||||||
connect(this, SIGNAL(sortDataChanged(DocSeqSortSpec)),
|
connect(this, SIGNAL(sortDataChanged(DocSeqSortSpec)),
|
||||||
restable, SLOT(onSortDataChanged(DocSeqSortSpec)));
|
restable, SLOT(onSortDataChanged(DocSeqSortSpec)));
|
||||||
|
|
||||||
connect(restable->getModel(), SIGNAL(sortColumnChanged(DocSeqSortSpec)),
|
connect(restable->getModel(), SIGNAL(sortDataChanged(DocSeqSortSpec)),
|
||||||
this, SLOT(onResTableSortBy(DocSeqSortSpec)));
|
this, SLOT(onSortDataChanged(DocSeqSortSpec)));
|
||||||
connect(restable, SIGNAL(docEditClicked(Rcl::Doc)),
|
connect(restable, SIGNAL(docEditClicked(Rcl::Doc)),
|
||||||
this, SLOT(startNativeViewer(Rcl::Doc)));
|
this, SLOT(startNativeViewer(Rcl::Doc)));
|
||||||
connect(restable, SIGNAL(docPreviewClicked(int, Rcl::Doc, int)),
|
connect(restable, SIGNAL(docPreviewClicked(int, Rcl::Doc, int)),
|
||||||
@ -320,11 +320,10 @@ void RclMain::init()
|
|||||||
this, SLOT(showQueryDetails()));
|
this, SLOT(showQueryDetails()));
|
||||||
|
|
||||||
if (prefs.keepSort && prefs.sortActive) {
|
if (prefs.keepSort && prefs.sortActive) {
|
||||||
if (prefs.sortDesc)
|
m_sortspec.field = (const char *)prefs.sortField.toUtf8();
|
||||||
actionSortByDateDesc->setChecked(true);
|
m_sortspec.desc = prefs.sortDesc;
|
||||||
else
|
onSortDataChanged(m_sortspec);
|
||||||
actionSortByDateAsc->setChecked(true);
|
emit sortDataChanged(m_sortspec);
|
||||||
onSortCtlChanged();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start timer on a slow period (used for checking ^C). Will be
|
// Start timer on a slow period (used for checking ^C). Will be
|
||||||
@ -915,23 +914,26 @@ void RclMain::onSortCtlChanged()
|
|||||||
m_sortspec.desc = false;
|
m_sortspec.desc = false;
|
||||||
prefs.sortActive = true;
|
prefs.sortActive = true;
|
||||||
prefs.sortDesc = false;
|
prefs.sortDesc = false;
|
||||||
|
prefs.sortField = "mtime";
|
||||||
} else if (actionSortByDateDesc->isChecked()) {
|
} else if (actionSortByDateDesc->isChecked()) {
|
||||||
m_sortspec.field = "mtime";
|
m_sortspec.field = "mtime";
|
||||||
m_sortspec.desc = true;
|
m_sortspec.desc = true;
|
||||||
prefs.sortActive = true;
|
prefs.sortActive = true;
|
||||||
prefs.sortDesc = true;
|
prefs.sortDesc = true;
|
||||||
|
prefs.sortField = "mtime";
|
||||||
} else {
|
} else {
|
||||||
prefs.sortActive = prefs.sortDesc = false;
|
prefs.sortActive = prefs.sortDesc = false;
|
||||||
|
prefs.sortField = "";
|
||||||
}
|
}
|
||||||
LOGDEB(("RclMain::onCtlDataChanged(): emitting change signals\n"));
|
|
||||||
if (m_source.isNotNull())
|
if (m_source.isNotNull())
|
||||||
m_source->setSortSpec(m_sortspec);
|
m_source->setSortSpec(m_sortspec);
|
||||||
emit sortDataChanged(m_sortspec);
|
emit sortDataChanged(m_sortspec);
|
||||||
emit applyFiltSortData();
|
emit applyFiltSortData();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RclMain::onResTableSortBy(DocSeqSortSpec spec)
|
void RclMain::onSortDataChanged(DocSeqSortSpec spec)
|
||||||
{
|
{
|
||||||
|
LOGDEB(("RclMain::onSortDataChanged\n"));
|
||||||
m_sortspecnochange = true;
|
m_sortspecnochange = true;
|
||||||
if (spec.field.compare("mtime")) {
|
if (spec.field.compare("mtime")) {
|
||||||
actionSortByDateDesc->setChecked(false);
|
actionSortByDateDesc->setChecked(false);
|
||||||
@ -944,6 +946,11 @@ void RclMain::onResTableSortBy(DocSeqSortSpec spec)
|
|||||||
if (m_source.isNotNull())
|
if (m_source.isNotNull())
|
||||||
m_source->setSortSpec(spec);
|
m_source->setSortSpec(spec);
|
||||||
m_sortspec = spec;
|
m_sortspec = spec;
|
||||||
|
|
||||||
|
prefs.sortField = QString::fromUtf8(spec.field.c_str());
|
||||||
|
prefs.sortDesc = spec.desc;
|
||||||
|
prefs.sortActive = !spec.field.empty();
|
||||||
|
|
||||||
emit applyFiltSortData();
|
emit applyFiltSortData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -97,7 +97,7 @@ public slots:
|
|||||||
virtual void on_actionSortByDateAsc_toggled(bool on);
|
virtual void on_actionSortByDateAsc_toggled(bool on);
|
||||||
virtual void on_actionSortByDateDesc_toggled(bool on);
|
virtual void on_actionSortByDateDesc_toggled(bool on);
|
||||||
virtual void on_actionShowResultsAsTable_toggled(bool on);
|
virtual void on_actionShowResultsAsTable_toggled(bool on);
|
||||||
virtual void onResTableSortBy(DocSeqSortSpec);
|
virtual void onSortDataChanged(DocSeqSortSpec);
|
||||||
virtual void resultCount(int);
|
virtual void resultCount(int);
|
||||||
virtual void showQueryDetails();
|
virtual void showQueryDetails();
|
||||||
virtual void onResultsChanged();
|
virtual void onResultsChanged();
|
||||||
|
|||||||
@ -368,7 +368,7 @@ void RecollModel::sort(int column, Qt::SortOrder order)
|
|||||||
spec.field = "mtime";
|
spec.field = "mtime";
|
||||||
spec.desc = order == Qt::AscendingOrder ? false : true;
|
spec.desc = order == Qt::AscendingOrder ? false : true;
|
||||||
}
|
}
|
||||||
emit sortColumnChanged(spec);
|
emit sortDataChanged(spec);
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////
|
///////////////////////////
|
||||||
|
|||||||
@ -65,7 +65,7 @@ public:
|
|||||||
friend class ResTable;
|
friend class ResTable;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void sortColumnChanged(DocSeqSortSpec);
|
void sortDataChanged(DocSeqSortSpec);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
mutable RefCntr<DocSequence> m_source;
|
mutable RefCntr<DocSequence> m_source;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user