GUI: snippets: dont recreate the window each time, allow displaying data for multiple documents. restable: update snippets when changing current row
This commit is contained in:
parent
b79332580a
commit
75759ed481
@ -31,6 +31,7 @@
|
||||
#include "specialindex.h"
|
||||
#include "rclmain_w.h"
|
||||
#include "webcache.h"
|
||||
#include "restable.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@ -453,9 +454,7 @@ void RclMain::newDupsW(const Rcl::Doc, const vector<Rcl::Doc> dups)
|
||||
|
||||
void RclMain::showSnippets(Rcl::Doc doc)
|
||||
{
|
||||
if (m_snippets) {
|
||||
deleteZ(m_snippets);
|
||||
}
|
||||
if (!m_snippets) {
|
||||
m_snippets = new SnippetsW(doc, m_source);
|
||||
connect(m_snippets, SIGNAL(startNativeViewer(Rcl::Doc, int, QString)),
|
||||
this, SLOT(startNativeViewer(Rcl::Doc, int, QString)));
|
||||
@ -463,6 +462,15 @@ void RclMain::showSnippets(Rcl::Doc doc)
|
||||
this, SLOT (fileExit()));
|
||||
connect(new QShortcut(closeKeySeq, m_snippets), SIGNAL (activated()),
|
||||
m_snippets, SLOT (close()));
|
||||
if (restable) {
|
||||
connect(
|
||||
restable,
|
||||
SIGNAL(detailDocChanged(Rcl::Doc, std::shared_ptr<DocSequence>)),
|
||||
m_snippets,
|
||||
SLOT(onSetDoc(Rcl::Doc, std::shared_ptr<DocSequence>)));
|
||||
}
|
||||
} else {
|
||||
m_snippets->onSetDoc(doc, m_source);
|
||||
}
|
||||
m_snippets->show();
|
||||
}
|
||||
|
||||
|
||||
@ -670,6 +670,7 @@ void ResTable::onTableView_currentChanged(const QModelIndex& index)
|
||||
m_detaildoc = doc;
|
||||
m_pager->displayDoc(theconfig, index.row(), m_detaildoc,
|
||||
m_model->m_hdata);
|
||||
emit(detailDocChanged(doc, m_model->getDocSource()));
|
||||
} else {
|
||||
m_detaildocnum = -1;
|
||||
}
|
||||
|
||||
@ -167,6 +167,7 @@ signals:
|
||||
void docExpand(Rcl::Doc);
|
||||
void showSubDocs(Rcl::Doc);
|
||||
void showSnippets(Rcl::Doc);
|
||||
void detailDocChanged(Rcl::Doc, std::shared_ptr<DocSequence>);
|
||||
|
||||
friend class ResTablePager;
|
||||
friend class ResTableDetailArea;
|
||||
|
||||
@ -65,13 +65,11 @@ using namespace std;
|
||||
|
||||
class PlainToRichQtSnippets : public PlainToRich {
|
||||
public:
|
||||
virtual string startMatch(unsigned int)
|
||||
{
|
||||
virtual string startMatch(unsigned int) {
|
||||
return string("<span class='rclmatch' style='")
|
||||
+ qs2utf8s(prefs.qtermstyle) + string("'>");
|
||||
}
|
||||
virtual string endMatch()
|
||||
{
|
||||
virtual string endMatch() {
|
||||
return string("</span>");
|
||||
}
|
||||
};
|
||||
@ -79,9 +77,6 @@ static PlainToRichQtSnippets g_hiliter;
|
||||
|
||||
void SnippetsW::init()
|
||||
{
|
||||
if (!m_source)
|
||||
return;
|
||||
|
||||
QPushButton *searchButton = new QPushButton(tr("Search"));
|
||||
searchButton->setAutoDefault(false);
|
||||
buttonBox->addButton(searchButton, QDialogButtonBox::ActionRole);
|
||||
@ -150,6 +145,13 @@ void SnippetsW::init()
|
||||
browser->setFont(QFont());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void SnippetsW::onSetDoc(Rcl::Doc doc, std::shared_ptr<DocSequence> source)
|
||||
{
|
||||
m_doc = doc;
|
||||
if (!source)
|
||||
return;
|
||||
|
||||
// Make title out of file name if none yet
|
||||
string titleOrFilename;
|
||||
@ -166,11 +168,11 @@ void SnippetsW::init()
|
||||
setWindowTitle(title);
|
||||
|
||||
vector<Rcl::Snippet> vpabs;
|
||||
m_source->getAbstract(m_doc, vpabs,
|
||||
source->getAbstract(m_doc, vpabs,
|
||||
prefs.snipwMaxLength, prefs.snipwSortByPage);
|
||||
|
||||
HighlightData hdata;
|
||||
m_source->getTerms(hdata);
|
||||
source->getTerms(hdata);
|
||||
|
||||
ostringstream oss;
|
||||
oss <<
|
||||
|
||||
@ -35,13 +35,15 @@ class SnippetsW : public QWidget, public Ui::Snippets
|
||||
public:
|
||||
SnippetsW(Rcl::Doc doc, std::shared_ptr<DocSequence> source,
|
||||
QWidget* parent = 0)
|
||||
: QWidget(parent), m_doc(doc), m_source(source) {
|
||||
: QWidget(parent) {
|
||||
setupUi((QDialog*)this);
|
||||
init();
|
||||
onSetDoc(doc, source);
|
||||
}
|
||||
|
||||
public slots:
|
||||
virtual void onLinkClicked(const QUrl &);
|
||||
virtual void onSetDoc(Rcl::Doc doc, std::shared_ptr<DocSequence> source);
|
||||
|
||||
protected slots:
|
||||
virtual void slotEditFind();
|
||||
@ -54,7 +56,6 @@ signals:
|
||||
private:
|
||||
void init();
|
||||
Rcl::Doc m_doc;
|
||||
std::shared_ptr<DocSequence> m_source;
|
||||
};
|
||||
|
||||
#ifdef USING_WEBENGINE
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user