|
a/src/qtgui/restable.cpp |
|
b/src/qtgui/restable.cpp |
|
... |
|
... |
33 |
#include <QSplitter>
|
33 |
#include <QSplitter>
|
34 |
#include <QFileDialog>
|
34 |
#include <QFileDialog>
|
35 |
#include <QMessageBox>
|
35 |
#include <QMessageBox>
|
36 |
|
36 |
|
37 |
#include "recoll.h"
|
37 |
#include "recoll.h"
|
38 |
#include "refcntr.h"
|
38 |
#include MEMORY_INCLUDE
|
39 |
#include "docseq.h"
|
39 |
#include "docseq.h"
|
40 |
#include "debuglog.h"
|
40 |
#include "debuglog.h"
|
41 |
#include "restable.h"
|
41 |
#include "restable.h"
|
42 |
#include "guiutils.h"
|
42 |
#include "guiutils.h"
|
43 |
#include "reslistpager.h"
|
43 |
#include "reslistpager.h"
|
|
... |
|
... |
270 |
}
|
270 |
}
|
271 |
|
271 |
|
272 |
int RecollModel::rowCount(const QModelIndex&) const
|
272 |
int RecollModel::rowCount(const QModelIndex&) const
|
273 |
{
|
273 |
{
|
274 |
LOGDEB2(("RecollModel::rowCount\n"));
|
274 |
LOGDEB2(("RecollModel::rowCount\n"));
|
275 |
if (m_source.isNull())
|
275 |
if (!m_source)
|
276 |
return 0;
|
276 |
return 0;
|
277 |
return m_source->getResCnt();
|
277 |
return m_source->getResCnt();
|
278 |
}
|
278 |
}
|
279 |
|
279 |
|
280 |
int RecollModel::columnCount(const QModelIndex&) const
|
280 |
int RecollModel::columnCount(const QModelIndex&) const
|
|
... |
|
... |
288 |
LOGDEB(("RecollModel::readDocSource()\n"));
|
288 |
LOGDEB(("RecollModel::readDocSource()\n"));
|
289 |
beginResetModel();
|
289 |
beginResetModel();
|
290 |
endResetModel();
|
290 |
endResetModel();
|
291 |
}
|
291 |
}
|
292 |
|
292 |
|
293 |
void RecollModel::setDocSource(RefCntr<DocSequence> nsource)
|
293 |
void RecollModel::setDocSource(STD_SHARED_PTR<DocSequence> nsource)
|
294 |
{
|
294 |
{
|
295 |
LOGDEB(("RecollModel::setDocSource\n"));
|
295 |
LOGDEB(("RecollModel::setDocSource\n"));
|
296 |
if (nsource.isNull()) {
|
296 |
if (!nsource) {
|
297 |
m_source = RefCntr<DocSequence>();
|
297 |
m_source = STD_SHARED_PTR<DocSequence>();
|
298 |
} else {
|
298 |
} else {
|
299 |
m_source = RefCntr<DocSequence>(new DocSource(theconfig, nsource));
|
299 |
m_source = STD_SHARED_PTR<DocSequence>(new DocSource(theconfig, nsource));
|
300 |
m_hdata.clear();
|
300 |
m_hdata.clear();
|
301 |
m_source->getTerms(m_hdata);
|
301 |
m_source->getTerms(m_hdata);
|
302 |
}
|
302 |
}
|
303 |
}
|
303 |
}
|
304 |
|
304 |
|
|
... |
|
... |
354 |
|
354 |
|
355 |
QVariant RecollModel::data(const QModelIndex& index, int role) const
|
355 |
QVariant RecollModel::data(const QModelIndex& index, int role) const
|
356 |
{
|
356 |
{
|
357 |
LOGDEB2(("RecollModel::data: row %d col %d role %d\n", index.row(),
|
357 |
LOGDEB2(("RecollModel::data: row %d col %d role %d\n", index.row(),
|
358 |
index.column(), role));
|
358 |
index.column(), role));
|
359 |
if (m_source.isNull() || role != Qt::DisplayRole || !index.isValid() ||
|
359 |
if (!m_source || role != Qt::DisplayRole || !index.isValid() ||
|
360 |
index.column() >= int(m_fields.size())) {
|
360 |
index.column() >= int(m_fields.size())) {
|
361 |
return QVariant();
|
361 |
return QVariant();
|
362 |
}
|
362 |
}
|
363 |
|
363 |
|
364 |
Rcl::Doc doc;
|
364 |
Rcl::Doc doc;
|
|
... |
|
... |
373 |
return QString::fromUtf8(lr.front().c_str());
|
373 |
return QString::fromUtf8(lr.front().c_str());
|
374 |
}
|
374 |
}
|
375 |
|
375 |
|
376 |
void RecollModel::saveAsCSV(FILE *fp)
|
376 |
void RecollModel::saveAsCSV(FILE *fp)
|
377 |
{
|
377 |
{
|
378 |
if (m_source.isNull())
|
378 |
if (!m_source)
|
379 |
return;
|
379 |
return;
|
380 |
|
380 |
|
381 |
int cols = columnCount();
|
381 |
int cols = columnCount();
|
382 |
int rows = rowCount();
|
382 |
int rows = rowCount();
|
383 |
vector<string> tokens;
|
383 |
vector<string> tokens;
|
|
... |
|
... |
635 |
void ResTable::onTableView_currentChanged(const QModelIndex& index)
|
635 |
void ResTable::onTableView_currentChanged(const QModelIndex& index)
|
636 |
{
|
636 |
{
|
637 |
LOGDEB2(("ResTable::onTableView_currentChanged(%d, %d)\n",
|
637 |
LOGDEB2(("ResTable::onTableView_currentChanged(%d, %d)\n",
|
638 |
index.row(), index.column()));
|
638 |
index.row(), index.column()));
|
639 |
|
639 |
|
640 |
if (!m_model || m_model->getDocSource().isNull())
|
640 |
if (!m_model || !m_model->getDocSource())
|
641 |
return;
|
641 |
return;
|
642 |
Rcl::Doc doc;
|
642 |
Rcl::Doc doc;
|
643 |
if (m_model->getDocSource()->getDoc(index.row(), doc)) {
|
643 |
if (m_model->getDocSource()->getDoc(index.row(), doc)) {
|
644 |
m_detail->clear();
|
644 |
m_detail->clear();
|
645 |
m_detaildocnum = index.row();
|
645 |
m_detaildocnum = index.row();
|
|
... |
|
... |
663 |
{
|
663 |
{
|
664 |
// LOGDEB(("resTable: take focus\n"));
|
664 |
// LOGDEB(("resTable: take focus\n"));
|
665 |
tableView->setFocus(Qt::ShortcutFocusReason);
|
665 |
tableView->setFocus(Qt::ShortcutFocusReason);
|
666 |
}
|
666 |
}
|
667 |
|
667 |
|
668 |
void ResTable::setDocSource(RefCntr<DocSequence> nsource)
|
668 |
void ResTable::setDocSource(STD_SHARED_PTR<DocSequence> nsource)
|
669 |
{
|
669 |
{
|
670 |
LOGDEB(("ResTable::setDocSource\n"));
|
670 |
LOGDEB(("ResTable::setDocSource\n"));
|
671 |
if (m_model)
|
671 |
if (m_model)
|
672 |
m_model->setDocSource(nsource);
|
672 |
m_model->setDocSource(nsource);
|
673 |
if (m_pager)
|
673 |
if (m_pager)
|
|
... |
|
... |
678 |
}
|
678 |
}
|
679 |
|
679 |
|
680 |
void ResTable::resetSource()
|
680 |
void ResTable::resetSource()
|
681 |
{
|
681 |
{
|
682 |
LOGDEB(("ResTable::resetSource\n"));
|
682 |
LOGDEB(("ResTable::resetSource\n"));
|
683 |
setDocSource(RefCntr<DocSequence>());
|
683 |
setDocSource(STD_SHARED_PTR<DocSequence>());
|
684 |
}
|
684 |
}
|
685 |
|
685 |
|
686 |
void ResTable::saveAsCSV()
|
686 |
void ResTable::saveAsCSV()
|
687 |
{
|
687 |
{
|
688 |
LOGDEB(("ResTable::saveAsCSV\n"));
|
688 |
LOGDEB(("ResTable::saveAsCSV\n"));
|
|
... |
|
... |
780 |
}
|
780 |
}
|
781 |
}
|
781 |
}
|
782 |
// Open parent folder
|
782 |
// Open parent folder
|
783 |
case 'F':
|
783 |
case 'F':
|
784 |
{
|
784 |
{
|
785 |
emit editRequested(ResultPopup::getParent(RefCntr<DocSequence>(),
|
785 |
emit editRequested(ResultPopup::getParent(STD_SHARED_PTR<DocSequence>(),
|
786 |
m_detaildoc));
|
786 |
m_detaildoc));
|
787 |
}
|
787 |
}
|
788 |
break;
|
788 |
break;
|
789 |
|
789 |
|
790 |
case 'P':
|
790 |
case 'P':
|
|
... |
|
... |
821 |
}
|
821 |
}
|
822 |
}
|
822 |
}
|
823 |
|
823 |
|
824 |
void ResTable::onDoubleClick(const QModelIndex& index)
|
824 |
void ResTable::onDoubleClick(const QModelIndex& index)
|
825 |
{
|
825 |
{
|
826 |
if (!m_model || m_model->getDocSource().isNull())
|
826 |
if (!m_model || !m_model->getDocSource())
|
827 |
return;
|
827 |
return;
|
828 |
Rcl::Doc doc;
|
828 |
Rcl::Doc doc;
|
829 |
if (m_model->getDocSource()->getDoc(index.row(), doc)) {
|
829 |
if (m_model->getDocSource()->getDoc(index.row(), doc)) {
|
830 |
m_detail->clear();
|
830 |
m_detail->clear();
|
831 |
m_detaildocnum = index.row();
|
831 |
m_detaildocnum = index.row();
|
|
... |
|
... |
875 |
emit docSaveToFileClicked(m_detaildoc);
|
875 |
emit docSaveToFileClicked(m_detaildoc);
|
876 |
}
|
876 |
}
|
877 |
|
877 |
|
878 |
void ResTable::menuSaveSelection()
|
878 |
void ResTable::menuSaveSelection()
|
879 |
{
|
879 |
{
|
880 |
if (m_model == 0 || m_model->getDocSource().isNull())
|
880 |
if (m_model == 0 || !m_model->getDocSource())
|
881 |
return;
|
881 |
return;
|
882 |
|
882 |
|
883 |
QModelIndexList indexl = tableView->selectionModel()->selectedRows();
|
883 |
QModelIndexList indexl = tableView->selectionModel()->selectedRows();
|
884 |
vector<Rcl::Doc> v;
|
884 |
vector<Rcl::Doc> v;
|
885 |
for (int i = 0; i < indexl.size(); i++) {
|
885 |
for (int i = 0; i < indexl.size(); i++) {
|
|
... |
|
... |
897 |
}
|
897 |
}
|
898 |
|
898 |
|
899 |
void ResTable::menuPreviewParent()
|
899 |
void ResTable::menuPreviewParent()
|
900 |
{
|
900 |
{
|
901 |
if (m_detaildocnum >= 0 && m_model &&
|
901 |
if (m_detaildocnum >= 0 && m_model &&
|
902 |
m_model->getDocSource().isNotNull()) {
|
902 |
m_model->getDocSource()) {
|
903 |
Rcl::Doc pdoc = ResultPopup::getParent(m_model->getDocSource(),
|
903 |
Rcl::Doc pdoc = ResultPopup::getParent(m_model->getDocSource(),
|
904 |
m_detaildoc);
|
904 |
m_detaildoc);
|
905 |
if (pdoc.mimetype == "inode/directory") {
|
905 |
if (pdoc.mimetype == "inode/directory") {
|
906 |
emit editRequested(pdoc);
|
906 |
emit editRequested(pdoc);
|
907 |
} else {
|
907 |
} else {
|
|
... |
|
... |
910 |
}
|
910 |
}
|
911 |
}
|
911 |
}
|
912 |
|
912 |
|
913 |
void ResTable::menuOpenParent()
|
913 |
void ResTable::menuOpenParent()
|
914 |
{
|
914 |
{
|
915 |
if (m_detaildocnum >= 0 && m_model && m_model->getDocSource().isNotNull())
|
915 |
if (m_detaildocnum >= 0 && m_model && m_model->getDocSource())
|
916 |
emit editRequested(
|
916 |
emit editRequested(
|
917 |
ResultPopup::getParent(m_model->getDocSource(), m_detaildoc));
|
917 |
ResultPopup::getParent(m_model->getDocSource(), m_detaildoc));
|
918 |
}
|
918 |
}
|
919 |
|
919 |
|
920 |
void ResTable::menuEdit()
|
920 |
void ResTable::menuEdit()
|