gui: synchronize result list and table when feasible
This commit is contained in:
parent
b2515b5048
commit
cd2fe8049f
@ -955,6 +955,21 @@ void RclMain::on_actionShowResultsAsTable_toggled(bool on)
|
|||||||
prefs.showResultsAsTable = on;
|
prefs.showResultsAsTable = on;
|
||||||
restable->setVisible(on);
|
restable->setVisible(on);
|
||||||
reslist->setVisible(!on);
|
reslist->setVisible(!on);
|
||||||
|
if (!on) {
|
||||||
|
displayingTable = false;
|
||||||
|
int docnum = restable->getDetailDocNumOrTopRow();
|
||||||
|
if (docnum >= 0)
|
||||||
|
reslist->resultPageFor(docnum);
|
||||||
|
} else {
|
||||||
|
displayingTable = true;
|
||||||
|
int docnum = reslist->pageFirstDocNum();
|
||||||
|
if (docnum >= 0) {
|
||||||
|
restable->makeRowVisible(docnum);
|
||||||
|
}
|
||||||
|
nextPageAction->setEnabled(false);
|
||||||
|
prevPageAction->setEnabled(false);
|
||||||
|
firstPageAction->setEnabled(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RclMain::on_actionSortByDateAsc_toggled(bool on)
|
void RclMain::on_actionSortByDateAsc_toggled(bool on)
|
||||||
@ -1313,7 +1328,6 @@ void RclMain::eraseDocHistory()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void RclMain::eraseSearchHistory()
|
void RclMain::eraseSearchHistory()
|
||||||
{
|
{
|
||||||
prefs.ssearchHistory.clear();
|
prefs.ssearchHistory.clear();
|
||||||
@ -1336,13 +1350,16 @@ void RclMain::setUIPrefs()
|
|||||||
|
|
||||||
void RclMain::enableNextPage(bool yesno)
|
void RclMain::enableNextPage(bool yesno)
|
||||||
{
|
{
|
||||||
nextPageAction->setEnabled(yesno);
|
if (!displayingTable)
|
||||||
|
nextPageAction->setEnabled(yesno);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RclMain::enablePrevPage(bool yesno)
|
void RclMain::enablePrevPage(bool yesno)
|
||||||
{
|
{
|
||||||
prevPageAction->setEnabled(yesno);
|
if (!displayingTable) {
|
||||||
firstPageAction->setEnabled(yesno);
|
prevPageAction->setEnabled(yesno);
|
||||||
|
firstPageAction->setEnabled(yesno);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString RclMain::getQueryDescription()
|
QString RclMain::getQueryDescription()
|
||||||
|
|||||||
@ -122,6 +122,7 @@ private:
|
|||||||
SpellW *spellform;
|
SpellW *spellform;
|
||||||
QTimer *periodictimer;
|
QTimer *periodictimer;
|
||||||
ResTable *restable;
|
ResTable *restable;
|
||||||
|
bool displayingTable;
|
||||||
|
|
||||||
vector<ExecCmd*> m_viewers;
|
vector<ExecCmd*> m_viewers;
|
||||||
map<QString, QAction*> m_stemLangToId;
|
map<QString, QAction*> m_stemLangToId;
|
||||||
|
|||||||
@ -493,6 +493,24 @@ void ResTable::init()
|
|||||||
splitter->setOrientation(Qt::Vertical);
|
splitter->setOrientation(Qt::Vertical);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ResTable::getDetailDocNumOrTopRow()
|
||||||
|
{
|
||||||
|
if (m_detaildocnum >= 0)
|
||||||
|
return m_detaildocnum;
|
||||||
|
QModelIndex modelIndex = tableView->indexAt(QPoint(0, 0));
|
||||||
|
return modelIndex.row();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ResTable::makeRowVisible(int row)
|
||||||
|
{
|
||||||
|
LOGDEB(("ResTable::showRow(%d)\n", row));
|
||||||
|
QModelIndex modelIndex = m_model->index(row, 0);
|
||||||
|
tableView->scrollTo(modelIndex, QAbstractItemView::PositionAtTop);
|
||||||
|
tableView->selectionModel()->clear();
|
||||||
|
m_detail->clear();
|
||||||
|
m_detaildocnum = -1;
|
||||||
|
}
|
||||||
|
|
||||||
// This is called by rclmain_w prior to exiting
|
// This is called by rclmain_w prior to exiting
|
||||||
void ResTable::saveColState()
|
void ResTable::saveColState()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -113,6 +113,8 @@ public:
|
|||||||
virtual ~ResTable() {}
|
virtual ~ResTable() {}
|
||||||
virtual RecollModel *getModel() {return m_model;}
|
virtual RecollModel *getModel() {return m_model;}
|
||||||
virtual ResTableDetailArea* getDetailArea() {return m_detail;}
|
virtual ResTableDetailArea* getDetailArea() {return m_detail;}
|
||||||
|
virtual int getDetailDocNumOrTopRow();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
virtual void onTableView_currentChanged(const QModelIndex&);
|
virtual void onTableView_currentChanged(const QModelIndex&);
|
||||||
virtual void on_tableView_entered(const QModelIndex& index);
|
virtual void on_tableView_entered(const QModelIndex& index);
|
||||||
@ -135,6 +137,7 @@ public slots:
|
|||||||
virtual void addColumn();
|
virtual void addColumn();
|
||||||
virtual void resetSort(); // Revert to natural (relevance) order
|
virtual void resetSort(); // Revert to natural (relevance) order
|
||||||
virtual void linkWasClicked(const QUrl&);
|
virtual void linkWasClicked(const QUrl&);
|
||||||
|
virtual void makeRowVisible(int row);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void docPreviewClicked(int, Rcl::Doc, int);
|
void docPreviewClicked(int, Rcl::Doc, int);
|
||||||
|
|||||||
@ -91,6 +91,32 @@ void ResListPager::resultPageNext()
|
|||||||
m_respage = npage;
|
m_respage = npage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ResListPager::resultPageFor(int docnum)
|
||||||
|
{
|
||||||
|
if (m_docSource.isNull()) {
|
||||||
|
LOGDEB(("ResListPager::resultPageFor: null source\n"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int resCnt = m_docSource->getResCnt();
|
||||||
|
LOGDEB(("ResListPager::resultPageFor(%d): rescnt %d, winfirst %d\n",
|
||||||
|
docnum, resCnt, m_winfirst));
|
||||||
|
m_winfirst = (docnum / m_pagesize) * m_pagesize;
|
||||||
|
|
||||||
|
// Get the next page of results.
|
||||||
|
vector<ResListEntry> npage;
|
||||||
|
int pagelen = m_docSource->getSeqSlice(m_winfirst, m_pagesize, npage);
|
||||||
|
|
||||||
|
// If page was truncated, there is no next
|
||||||
|
m_hasNext = (pagelen == m_pagesize);
|
||||||
|
|
||||||
|
if (pagelen <= 0) {
|
||||||
|
m_winfirst = -1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_respage = npage;
|
||||||
|
}
|
||||||
|
|
||||||
void ResListPager::displayDoc(RclConfig *config,
|
void ResListPager::displayDoc(RclConfig *config,
|
||||||
int i, Rcl::Doc& doc, const HiliteData& hdata,
|
int i, Rcl::Doc& doc, const HiliteData& hdata,
|
||||||
const string& sh)
|
const string& sh)
|
||||||
|
|||||||
@ -82,6 +82,7 @@ public:
|
|||||||
resultPageNext();
|
resultPageNext();
|
||||||
}
|
}
|
||||||
void resultPageNext();
|
void resultPageNext();
|
||||||
|
void resultPageFor(int docnum);
|
||||||
void displayPage(RclConfig *);
|
void displayPage(RclConfig *);
|
||||||
void displayDoc(RclConfig *, int idx, Rcl::Doc& doc,
|
void displayDoc(RclConfig *, int idx, Rcl::Doc& doc,
|
||||||
const HiliteData& hdata, const string& sh = "");
|
const HiliteData& hdata, const string& sh = "");
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user