diff --git a/src/qtgui/rclm_wins.cpp b/src/qtgui/rclm_wins.cpp index a917383e..a1195238 100644 --- a/src/qtgui/rclm_wins.cpp +++ b/src/qtgui/rclm_wins.cpp @@ -37,6 +37,7 @@ #include "webcache.h" #include "restable.h" #include "actsearch_w.h" +#include "docseqdocs.h" using namespace std; @@ -443,27 +444,16 @@ void RclMain::showActiveTypes() void RclMain::newDupsW(const Rcl::Doc, const vector dups) { - ListDialog dialog; - dialog.setWindowTitle(tr("Duplicate documents")); - - dialog.groupBox->setTitle(tr("These Urls ( | ipath) share the same" - " content:")); - // We replace the list with an editor so that the user can copy/paste - deleteZ(dialog.listWidget); - QTextEdit *editor = new QTextEdit(dialog.groupBox); - editor->setReadOnly(true); - dialog.horizontalLayout->addWidget(editor); - - for (vector::const_iterator it = dups.begin(); - it != dups.end(); it++) { - if (it->ipath.empty()) - editor->append(path2qs(it->url)); - else - editor->append(path2qs(it->url) + " | " + u8s2qs(it->ipath)); + if (nullptr == m_dupsw) { + m_dupsw = new ResTable(nullptr, {"ipath", "url"}); + m_dupsw->setRclMain(this, false); } - editor->moveCursor(QTextCursor::Start); - editor->ensureCursorVisible(); - dialog.exec(); + auto src = std::make_shared(rcldb, dups, qs2utf8s(tr("Duplicates"))); + src->setDescription(qs2utf8s(tr("Duplicates"))); + auto source = std::make_shared(theconfig, src); + m_dupsw->setDocSource(source); + m_dupsw->readDocSource(); + m_dupsw->show(); } void RclMain::showSnippets(Rcl::Doc doc) diff --git a/src/qtgui/rclmain_w.h b/src/qtgui/rclmain_w.h index 6ebc11e5..6939c48c 100644 --- a/src/qtgui/rclmain_w.h +++ b/src/qtgui/rclmain_w.h @@ -213,6 +213,7 @@ private: QTimer *periodictimer{0}; WebcacheEdit *webcache{0}; ResTable *restable{0}; + ResTable *m_dupsw{0}; bool displayingTable{false}; ActSearchW *actsearchw{0}; QAction *m_idNoStem{0}; diff --git a/src/qtgui/restable.cpp b/src/qtgui/restable.cpp index 7438e652..536e71db 100644 --- a/src/qtgui/restable.cpp +++ b/src/qtgui/restable.cpp @@ -250,8 +250,7 @@ string RecollModel::baseField(const string& field) return field; } -RecollModel::RecollModel(const QStringList fields, ResTable *tb, - QObject *parent) +RecollModel::RecollModel(const QStringList fields, ResTable *tb, QObject *parent) : QAbstractTableModel(parent), m_table(tb), m_ignoreSort(false) { // Initialize the translated map for column headers @@ -286,8 +285,7 @@ RecollModel::RecollModel(const QStringList fields, ResTable *tb, } // Construct the actual list of column names - for (QStringList::const_iterator it = fields.begin(); - it != fields.end(); it++) { + for (QStringList::const_iterator it = fields.begin(); it != fields.end(); it++) { m_fields.push_back((const char *)(it->toUtf8())); m_getters.push_back(chooseGetter(m_fields.back())); } @@ -593,16 +591,21 @@ void ResTable::setDefRowHeight() } } -void ResTable::init() +void ResTable::init(QStringList _ifields) { QSettings settings; - auto restableFields = settings.value(settingskey_fieldlist).toStringList(); - if (restableFields.empty()) { - restableFields.push_back("date"); - restableFields.push_back("title"); - restableFields.push_back("filename"); - restableFields.push_back("author"); - restableFields.push_back("url"); + QStringList restableFields; + if (_ifields.empty()) { + restableFields = settings.value(settingskey_fieldlist).toStringList(); + if (restableFields.empty()) { + restableFields.push_back("date"); + restableFields.push_back("title"); + restableFields.push_back("filename"); + restableFields.push_back("author"); + restableFields.push_back("url"); + } + } else { + restableFields = _ifields; } if (!(m_model = new RecollModel(restableFields, this))) return; @@ -626,26 +629,29 @@ void ResTable::init() QHeaderView *header = tableView->horizontalHeader(); if (header) { - QString qw = settings.value(settingskey_fieldwiths).toString(); - vector vw; - stringToStrings(qs2utf8s(qw), vw); - vector restableColWidths; - for (const auto& w : vw) { - restableColWidths.push_back(atoi(w.c_str())); - } - if (int(restableColWidths.size()) == header->count()) { - for (int i = 0; i < header->count(); i++) { - header->resizeSection(i, restableColWidths[i]); + if (_ifields.empty()) { + QString qw = settings.value(settingskey_fieldwiths).toString(); + vector vw; + stringToStrings(qs2utf8s(qw), vw); + vector restableColWidths; + for (const auto& w : vw) { + restableColWidths.push_back(atoi(w.c_str())); } + if (int(restableColWidths.size()) == header->count()) { + for (int i = 0; i < header->count(); i++) { + header->resizeSection(i, restableColWidths[i]); + } + } + header->setSortIndicatorShown(true); + header->setSortIndicator(-1, Qt::AscendingOrder); + header->setContextMenuPolicy(Qt::CustomContextMenu); + connect(header, SIGNAL(sectionResized(int,int,int)), this, SLOT(saveColState())); + connect(header, SIGNAL(customContextMenuRequested(const QPoint&)), + this, SLOT(createHeaderPopupMenu(const QPoint&))); + } else { + header->setSortIndicatorShown(false); } - header->setSortIndicatorShown(true); - header->setSortIndicator(-1, Qt::AscendingOrder); - header->setContextMenuPolicy(Qt::CustomContextMenu); header->setStretchLastSection(1); - connect(header, SIGNAL(sectionResized(int,int,int)), - this, SLOT(saveColState())); - connect(header, SIGNAL(customContextMenuRequested(const QPoint&)), - this, SLOT(createHeaderPopupMenu(const QPoint&))); } #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) header->setSectionsMovable(true); diff --git a/src/qtgui/restable.h b/src/qtgui/restable.h index 59fcda28..f7530c58 100644 --- a/src/qtgui/restable.h +++ b/src/qtgui/restable.h @@ -137,10 +137,10 @@ class ResTable : public QWidget, public Ui::ResTable Q_OBJECT; public: - ResTable(QWidget* parent = 0) + ResTable(QWidget* parent = 0, QStringList fields = QStringList()) : QWidget(parent) { setupUi(this); - init(); + init(fields); } virtual ~ResTable() {} @@ -214,7 +214,7 @@ protected: bool eventFilter(QObject* obj, QEvent* event); private: - void init(); + void init(QStringList fields); RecollModel *m_model{nullptr}; ResTablePager *m_pager{nullptr};