diff --git a/src/qtgui/restable.cpp b/src/qtgui/restable.cpp
index 44a58f36..289b81c7 100644
--- a/src/qtgui/restable.cpp
+++ b/src/qtgui/restable.cpp
@@ -79,22 +79,28 @@ public:
ResTablePager(ResTable *p)
: ResListPager(1, prefs.alwaysSnippets), m_parent(p)
{}
- virtual bool append(const string& data, int idx, const Rcl::Doc& doc);
- virtual string trans(const string& in);
- virtual const string &parFormat();
- virtual string absSep() {return (const char *)(prefs.abssep.toUtf8());}
+ virtual bool append(const string& data) override;
+ virtual bool flush() override;
+ virtual string trans(const string& in) override;
+ virtual const string &parFormat() override;
+ virtual string absSep() override {
+ return (const char *)(prefs.abssep.toUtf8());}
+ virtual string headerContent() override {
+ return qs2utf8s(prefs.reslistheadertext);}
private:
ResTable *m_parent;
+ string m_data;
};
-bool ResTablePager::append(const string& data, int, const Rcl::Doc&)
+bool ResTablePager::append(const string& data)
{
- m_parent->m_detail->moveCursor(QTextCursor::End, QTextCursor::MoveAnchor);
- m_parent->m_detail->textCursor().insertBlock();
- m_parent->m_detail->insertHtml(u8s2qs(data));
-
-// LOGDEB("RESTABLEPAGER::APPEND: data : " << data << std::endl);
-// m_parent->m_detail->setHtml(u8s2qs(data));
+ m_data += data;
+ return true;
+}
+bool ResTablePager::flush()
+{
+ m_parent->m_detail->setHtml(u8s2qs(m_data));
+ m_data = "";
return true;
}
@@ -147,6 +153,12 @@ void ResTableDetailArea::setFont()
}
}
+void ResTableDetailArea::init()
+{
+ setFont();
+ QTextBrowser::setHtml("");
+}
+
//////////////////////////////////////////////////////////////////////////////
//// Data model methods
////
@@ -474,51 +486,54 @@ public:
QStyleOptionViewItem opt = option;
initStyleOption(&opt, index);
QVariant value = index.data(Qt::DisplayRole);
+ QString text;
if (value.isValid() && !value.isNull()) {
- QString text = value.toString();
- if (!text.isEmpty()) {
- QTextDocument document;
- painter->save();
- QString fstyle;
- if (prefs.reslistfontsize > 0) {
- int fs = prefs.reslistfontsize <= fsadjusttable ?
- prefs.reslistfontsize :
- prefs.reslistfontsize - fsadjusttable;
- fstyle = QString("font-size: %1pt").arg(fs);
- }
- if (opt.state & QStyle::State_Selected) {
- painter->fillRect(opt.rect, opt.palette.highlight());
- // Set the foreground color. Tried with pen
- // approach did not seem to work, probably it's
- // reset by the textdocument. Couldn't use
- // setdefaultstylesheet() either. the div thing is
- // an ugly hack. Works for now
- QString ntxt("
";
- ntxt += text + QString::fromUtf8("
");
- text.swap(ntxt);
- } else {
- if (!fstyle.isEmpty()) {
- QString ntxt("") + text + QString("
");
- text.swap(ntxt);
- }
- }
- painter->setClipRect(option.rect);
- QPoint where = option.rect.topLeft();
- where.ry() += TEXTINCELLVTRANS;
- painter->translate(where);
- document.setHtml(text);
- document.drawContents(painter);
- painter->restore();
- return;
- }
+ text = value.toString();
}
- QStyledItemDelegate::paint(painter, option, index);
+ if (text.isEmpty()) {
+ QStyledItemDelegate::paint(painter, option, index);
+ return;
+ }
+
+ painter->save();
+
+ QTextDocument document;
+ QString fstyle;
+ if (prefs.reslistfontsize > 0) {
+ int fs = prefs.reslistfontsize <= fsadjusttable ?
+ prefs.reslistfontsize :
+ prefs.reslistfontsize - fsadjusttable;
+ fstyle = QString("font-size: %1pt").arg(fs);
+ }
+ if (opt.state & QStyle::State_Selected) {
+ painter->fillRect(opt.rect, opt.palette.highlight());
+ // Set the foreground color. Tried with pen
+ // approach did not seem to work, probably it's
+ // reset by the textdocument. Couldn't use
+ // setdefaultstylesheet() either. the div thing is
+ // an ugly hack. Works for now
+ QString ntxt("";
+ ntxt += text + QString::fromUtf8("
");
+ text.swap(ntxt);
+ } else {
+ if (!fstyle.isEmpty()) {
+ QString ntxt("") + text + QString("
");
+ text.swap(ntxt);
+ }
+ }
+ painter->setClipRect(option.rect);
+ QPoint where = option.rect.topLeft();
+ where.ry() += TEXTINCELLVTRANS;
+ painter->translate(where);
+ document.setHtml(text);
+ document.drawContents(painter);
+ painter->restore();
}
};
@@ -594,7 +609,7 @@ void ResTable::init()
m_detail->setReadOnly(true);
m_detail->setUndoRedoEnabled(false);
m_detail->setOpenLinks(false);
- m_detail->setFont();
+ m_detail->init();
// signals and slots connections
connect(m_detail, SIGNAL(anchorClicked(const QUrl &)),
this, SLOT(linkWasClicked(const QUrl &)));
@@ -652,8 +667,9 @@ void ResTable::setRclMain(RclMain *m, bool ismain)
void ResTable::onUiPrefsChanged()
{
- if (m_detail)
- m_detail->setFont();
+ if (m_detail) {
+ m_detail->init();
+ }
}
int ResTable::getDetailDocNumOrTopRow()
@@ -670,7 +686,7 @@ void ResTable::makeRowVisible(int row)
QModelIndex modelIndex = m_model->index(row, 0);
tableView->scrollTo(modelIndex, QAbstractItemView::PositionAtTop);
tableView->selectionModel()->clear();
- m_detail->clear();
+ m_detail->init();
m_detaildocnum = -1;
}
@@ -715,11 +731,11 @@ void ResTable::onTableView_currentChanged(const QModelIndex& index)
return;
Rcl::Doc doc;
if (m_model->getDocSource()->getDoc(index.row(), doc)) {
- m_detail->clear();
+ m_detail->init();
m_detaildocnum = index.row();
m_detaildoc = doc;
- m_pager->displayDoc(theconfig, m_detaildocnum, m_detaildoc,
- m_model->m_hdata);
+ m_pager->displaySingleDoc(theconfig, m_detaildocnum, m_detaildoc,
+ m_model->m_hdata);
emit(detailDocChanged(doc, m_model->getDocSource()));
} else {
m_detaildocnum = -1;
@@ -748,7 +764,7 @@ void ResTable::setDocSource(std::shared_ptr nsource)
if (m_pager)
m_pager->setDocSource(nsource, 0);
if (m_detail)
- m_detail->clear();
+ m_detail->init();
m_detaildocnum = -1;
}
@@ -828,7 +844,7 @@ void ResTable::readDocSource(bool resetPos)
m_model->m_hdata.clear();
}
m_model->readDocSource();
- m_detail->clear();
+ m_detail->init();
m_detaildocnum = -1;
}
@@ -916,7 +932,7 @@ void ResTable::onDoubleClick(const QModelIndex& index)
Rcl::Doc doc;
if (m_model->getDocSource()->getDoc(index.row(), doc)) {
if (m_detaildocnum != index.row()) {
- m_detail->clear();
+ m_detail->init();
m_detaildocnum = index.row();
m_pager->displayDoc(theconfig, index.row(), m_detaildoc,
m_model->m_hdata);
diff --git a/src/qtgui/restable.h b/src/qtgui/restable.h
index 2623bff8..087e5dc4 100644
--- a/src/qtgui/restable.h
+++ b/src/qtgui/restable.h
@@ -96,7 +96,8 @@ class ResTableDetailArea : public QTextBrowser {
public slots:
virtual void createPopupMenu(const QPoint& pos);
virtual void setFont();
-
+ virtual void init();
+
private:
ResTable *m_table;
};
diff --git a/src/query/reslistpager.cpp b/src/query/reslistpager.cpp
index ce0f18d7..1c63d625 100644
--- a/src/query/reslistpager.cpp
+++ b/src/query/reslistpager.cpp
@@ -462,8 +462,37 @@ void ResListPager::displayPage(RclConfig *config)
chunk << "" << endl;
chunk << "