gui: synchronize result list and table when feasible

This commit is contained in:
Jean-Francois Dockes
2011-06-29 18:40:04 +02:00
parent b2515b5048
commit cd2fe8049f
6 changed files with 70 additions and 4 deletions
+21 -4
View File
@@ -955,6 +955,21 @@ void RclMain::on_actionShowResultsAsTable_toggled(bool on)
prefs.showResultsAsTable = on;
restable->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)
@@ -1313,7 +1328,6 @@ void RclMain::eraseDocHistory()
}
}
void RclMain::eraseSearchHistory()
{
prefs.ssearchHistory.clear();
@@ -1336,13 +1350,16 @@ void RclMain::setUIPrefs()
void RclMain::enableNextPage(bool yesno)
{
nextPageAction->setEnabled(yesno);
if (!displayingTable)
nextPageAction->setEnabled(yesno);
}
void RclMain::enablePrevPage(bool yesno)
{
prevPageAction->setEnabled(yesno);
firstPageAction->setEnabled(yesno);
if (!displayingTable) {
prevPageAction->setEnabled(yesno);
firstPageAction->setEnabled(yesno);
}
}
QString RclMain::getQueryDescription()
+1
View File
@@ -122,6 +122,7 @@ private:
SpellW *spellform;
QTimer *periodictimer;
ResTable *restable;
bool displayingTable;
vector<ExecCmd*> m_viewers;
map<QString, QAction*> m_stemLangToId;
+18
View File
@@ -493,6 +493,24 @@ void ResTable::init()
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
void ResTable::saveColState()
{
+3
View File
@@ -113,6 +113,8 @@ public:
virtual ~ResTable() {}
virtual RecollModel *getModel() {return m_model;}
virtual ResTableDetailArea* getDetailArea() {return m_detail;}
virtual int getDetailDocNumOrTopRow();
public slots:
virtual void onTableView_currentChanged(const QModelIndex&);
virtual void on_tableView_entered(const QModelIndex& index);
@@ -135,6 +137,7 @@ public slots:
virtual void addColumn();
virtual void resetSort(); // Revert to natural (relevance) order
virtual void linkWasClicked(const QUrl&);
virtual void makeRowVisible(int row);
signals:
void docPreviewClicked(int, Rcl::Doc, int);