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