GUI restable and reslist link clicking: cleanup, simplify, comments
This commit is contained in:
parent
0db8844fa3
commit
5bf4596d1f
@ -466,6 +466,8 @@ 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_source)
|
||||||
|
return;
|
||||||
if (!m_snippets) {
|
if (!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)),
|
||||||
|
|||||||
@ -66,9 +66,10 @@ static const QKeySequence closeKeySeq("Ctrl+w");
|
|||||||
# include <QWebSettings>
|
# include <QWebSettings>
|
||||||
# define QWEBSETTINGS QWebSettings
|
# define QWEBSETTINGS QWebSettings
|
||||||
#elif defined(USING_WEBENGINE)
|
#elif defined(USING_WEBENGINE)
|
||||||
// Notes for WebEngine
|
// Notes for WebEngine:
|
||||||
// - All links must begin with http:// for acceptNavigationRequest to be
|
// - All links must begin with http:// for acceptNavigationRequest to
|
||||||
// called.
|
// be called. Actually not any more since we set baseURL see
|
||||||
|
// comments in linkClicked().
|
||||||
// - The links passed to acceptNav.. have the host part
|
// - The links passed to acceptNav.. have the host part
|
||||||
// lowercased -> we change S0 to http://localhost/S0, not http://S0
|
// lowercased -> we change S0 to http://localhost/S0, not http://S0
|
||||||
# include <QWebEnginePage>
|
# include <QWebEnginePage>
|
||||||
@ -943,24 +944,42 @@ void ResList::onLinkClicked(const QUrl &qurl)
|
|||||||
// receive as Sterm%7CSpelling
|
// receive as Sterm%7CSpelling
|
||||||
string strurl = url_decode(qs2utf8s(qurl.toString()));
|
string strurl = url_decode(qs2utf8s(qurl.toString()));
|
||||||
|
|
||||||
|
// Link prefix remark: it used to be that webengine refused to
|
||||||
|
// acknowledge link clicks on links like "%P1", it needed an
|
||||||
|
// absolute URL like http://localhost/P1. This does not seem to be
|
||||||
|
// the case any more, probably because we now set baseUrl (to fix
|
||||||
|
// icons display which had stopped working). So the linkprefix
|
||||||
|
// thing could probably go away. OTOH, we'd have to substract the
|
||||||
|
// baseUrl because we receive links like baseUrl+P1 instead.
|
||||||
LOGDEB1("ResList::onLinkClicked: [" << strurl << "] prefix " <<
|
LOGDEB1("ResList::onLinkClicked: [" << strurl << "] prefix " <<
|
||||||
m_pager->linkPrefix() << "\n");
|
m_pager->linkPrefix() << "\n");
|
||||||
|
if (m_pager->linkPrefix().size() > 0 &&
|
||||||
|
(strurl.size() <= m_pager->linkPrefix().size() ||
|
||||||
|
!beginswith(strurl, m_pager->linkPrefix()))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
strurl = strurl.substr(m_pager->linkPrefix().size());
|
strurl = strurl.substr(m_pager->linkPrefix().size());
|
||||||
|
|
||||||
|
int docnum{-1};
|
||||||
|
bool havedoc{false};
|
||||||
|
Rcl::Doc doc;
|
||||||
|
if (strurl.size() > 1 && (docnum = atoi(strurl.c_str()+1) - 1) >= 0) {
|
||||||
|
if (getDoc(docnum, doc)) {
|
||||||
|
havedoc = true;
|
||||||
|
} else {
|
||||||
|
LOGERR("ResList::onLinkClicked: can't get doc for "<<
|
||||||
|
docnum << "\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int what = strurl[0];
|
int what = strurl[0];
|
||||||
switch (what) {
|
switch (what) {
|
||||||
|
|
||||||
// Open abstract/snippets window
|
// Open abstract/snippets window
|
||||||
case 'A':
|
case 'A':
|
||||||
{
|
{
|
||||||
if (!m_source)
|
if (!havedoc)
|
||||||
return;
|
return;
|
||||||
int i = atoi(strurl.c_str()+1) - 1;
|
|
||||||
Rcl::Doc doc;
|
|
||||||
if (!getDoc(i, doc)) {
|
|
||||||
LOGERR("ResList::onLinkClicked: can't get doc for " << i << "\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
emit(showSnippets(doc));
|
emit(showSnippets(doc));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -968,14 +987,8 @@ void ResList::onLinkClicked(const QUrl &qurl)
|
|||||||
// Show duplicates
|
// Show duplicates
|
||||||
case 'D':
|
case 'D':
|
||||||
{
|
{
|
||||||
if (!m_source)
|
if (!m_source || !havedoc)
|
||||||
return;
|
return;
|
||||||
int i = atoi(strurl.c_str()+1) - 1;
|
|
||||||
Rcl::Doc doc;
|
|
||||||
if (!getDoc(i, doc)) {
|
|
||||||
LOGERR("ResList::onLinkClicked: can't get doc for " << i << "\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
vector<Rcl::Doc> dups;
|
vector<Rcl::Doc> dups;
|
||||||
if (m_source->docDups(doc, dups) && m_rclmain) {
|
if (m_source->docDups(doc, dups) && m_rclmain) {
|
||||||
m_rclmain->newDupsW(doc, dups);
|
m_rclmain->newDupsW(doc, dups);
|
||||||
@ -986,14 +999,9 @@ void ResList::onLinkClicked(const QUrl &qurl)
|
|||||||
// Open parent folder
|
// Open parent folder
|
||||||
case 'F':
|
case 'F':
|
||||||
{
|
{
|
||||||
int i = atoi(strurl.c_str()+1) - 1;
|
if (!havedoc)
|
||||||
Rcl::Doc doc;
|
|
||||||
if (!getDoc(i, doc)) {
|
|
||||||
LOGERR("ResList::onLinkClicked: can't get doc for " << i << "\n");
|
|
||||||
return;
|
return;
|
||||||
}
|
emit editRequested(ResultPopup::getFolder(doc));
|
||||||
emit editRequested(ResultPopup::getParent(std::shared_ptr<DocSequence>(),
|
|
||||||
doc));
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -1009,15 +1017,11 @@ void ResList::onLinkClicked(const QUrl &qurl)
|
|||||||
case 'P':
|
case 'P':
|
||||||
case 'E':
|
case 'E':
|
||||||
{
|
{
|
||||||
int i = atoi(strurl.c_str()+1) - 1;
|
if (!havedoc)
|
||||||
Rcl::Doc doc;
|
|
||||||
if (!getDoc(i, doc)) {
|
|
||||||
LOGERR("ResList::onLinkClicked: can't get doc for " << i << "\n");
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
if (what == 'P') {
|
if (what == 'P') {
|
||||||
if (m_ismainres) {
|
if (m_ismainres) {
|
||||||
emit docPreviewClicked(i, doc, m_lstClckMod);
|
emit docPreviewClicked(docnum, doc, m_lstClckMod);
|
||||||
} else {
|
} else {
|
||||||
emit previewRequested(doc);
|
emit previewRequested(doc);
|
||||||
}
|
}
|
||||||
@ -1038,7 +1042,8 @@ void ResList::onLinkClicked(const QUrl &qurl)
|
|||||||
// Run script. Link format Rnn|Script Name
|
// Run script. Link format Rnn|Script Name
|
||||||
case 'R':
|
case 'R':
|
||||||
{
|
{
|
||||||
int i = atoi(strurl.c_str() + 1) - 1;
|
if (!havedoc)
|
||||||
|
return;
|
||||||
QString s = qurl.toString();
|
QString s = qurl.toString();
|
||||||
int bar = s.indexOf("|");
|
int bar = s.indexOf("|");
|
||||||
if (bar == -1 || bar >= s.size()-1)
|
if (bar == -1 || bar >= s.size()-1)
|
||||||
@ -1050,7 +1055,7 @@ void ResList::onLinkClicked(const QUrl &qurl)
|
|||||||
QAction act(QString::fromUtf8(app.name.c_str()), this);
|
QAction act(QString::fromUtf8(app.name.c_str()), this);
|
||||||
QVariant v(QString::fromUtf8(app.command.c_str()));
|
QVariant v(QString::fromUtf8(app.command.c_str()));
|
||||||
act.setData(v);
|
act.setData(v);
|
||||||
m_popDoc = i;
|
m_popDoc = docnum;
|
||||||
menuOpenWith(&act);
|
menuOpenWith(&act);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1073,8 +1078,9 @@ void ResList::onLinkClicked(const QUrl &qurl)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
LOGERR("ResList::onLinkClicked: bad link [" << strurl.substr(0,20) << "]\n");
|
LOGERR("ResList::onLinkClicked: bad link [" << strurl.substr(0,20) <<
|
||||||
break;// ??
|
"]\n");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1194,7 +1200,7 @@ void ResList::menuOpenFolder()
|
|||||||
{
|
{
|
||||||
Rcl::Doc doc;
|
Rcl::Doc doc;
|
||||||
if (getDoc(m_popDoc, doc) && m_source) {
|
if (getDoc(m_popDoc, doc) && m_source) {
|
||||||
Rcl::Doc pdoc = ResultPopup::getFolder(m_source, doc);
|
Rcl::Doc pdoc = ResultPopup::getFolder(doc);
|
||||||
if (!pdoc.url.empty()) {
|
if (!pdoc.url.empty()) {
|
||||||
emit editRequested(pdoc);
|
emit editRequested(pdoc);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -144,7 +144,7 @@ Rcl::Doc getParent(std::shared_ptr<DocSequence> source, Rcl::Doc& doc)
|
|||||||
return pdoc;
|
return pdoc;
|
||||||
}
|
}
|
||||||
|
|
||||||
Rcl::Doc getFolder(std::shared_ptr<DocSequence>, Rcl::Doc& doc)
|
Rcl::Doc getFolder(Rcl::Doc& doc)
|
||||||
{
|
{
|
||||||
Rcl::Doc pdoc;
|
Rcl::Doc pdoc;
|
||||||
pdoc.url = url_parentfolder(doc.url);
|
pdoc.url = url_parentfolder(doc.url);
|
||||||
|
|||||||
@ -26,8 +26,7 @@ extern QMenu *create(QWidget *me, int opts,
|
|||||||
Rcl::Doc& doc);
|
Rcl::Doc& doc);
|
||||||
extern Rcl::Doc getParent(std::shared_ptr<DocSequence> source,
|
extern Rcl::Doc getParent(std::shared_ptr<DocSequence> source,
|
||||||
Rcl::Doc& doc);
|
Rcl::Doc& doc);
|
||||||
extern Rcl::Doc getFolder(std::shared_ptr<DocSequence> source,
|
extern Rcl::Doc getFolder(Rcl::Doc& doc);
|
||||||
Rcl::Doc& doc);
|
|
||||||
extern void copyFN(const Rcl::Doc &doc);
|
extern void copyFN(const Rcl::Doc &doc);
|
||||||
extern void copyURL(const Rcl::Doc &doc);
|
extern void copyURL(const Rcl::Doc &doc);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -718,7 +718,7 @@ void ResTable::onTableView_currentChanged(const QModelIndex& index)
|
|||||||
m_detail->clear();
|
m_detail->clear();
|
||||||
m_detaildocnum = index.row();
|
m_detaildocnum = index.row();
|
||||||
m_detaildoc = doc;
|
m_detaildoc = doc;
|
||||||
m_pager->displayDoc(theconfig, index.row(), m_detaildoc,
|
m_pager->displayDoc(theconfig, m_detaildocnum, m_detaildoc,
|
||||||
m_model->m_hdata);
|
m_model->m_hdata);
|
||||||
emit(detailDocChanged(doc, m_model->getDocSource()));
|
emit(detailDocChanged(doc, m_model->getDocSource()));
|
||||||
} else {
|
} else {
|
||||||
@ -841,19 +841,23 @@ void ResTable::linkWasClicked(const QUrl &url)
|
|||||||
const char *ascurl = s.toUtf8();
|
const char *ascurl = s.toUtf8();
|
||||||
LOGDEB("ResTable::linkWasClicked: [" << ascurl << "]\n");
|
LOGDEB("ResTable::linkWasClicked: [" << ascurl << "]\n");
|
||||||
|
|
||||||
int i = atoi(ascurl+1) -1;
|
int docseqnum = atoi(ascurl+1) -1;
|
||||||
|
if (m_detaildocnum != docseqnum) {
|
||||||
|
//? Really we should abort...
|
||||||
|
LOGERR("ResTable::linkWasClicked: m_detaildocnum != docseqnum !\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int what = ascurl[0];
|
int what = ascurl[0];
|
||||||
switch (what) {
|
switch (what) {
|
||||||
// Open abstract/snippets window
|
// Open abstract/snippets window
|
||||||
case 'A':
|
case 'A':
|
||||||
if (m_detaildocnum >= 0)
|
emit(showSnippets(m_detaildoc));
|
||||||
emit(showSnippets(m_detaildoc));
|
|
||||||
break;
|
break;
|
||||||
case 'D':
|
case 'D':
|
||||||
{
|
{
|
||||||
vector<Rcl::Doc> dups;
|
vector<Rcl::Doc> dups;
|
||||||
if (m_detaildocnum >= 0 && m_rclmain &&
|
if (m_rclmain && m_model->getDocSource()->docDups(m_detaildoc, dups)) {
|
||||||
m_model->getDocSource()->docDups(m_detaildoc, dups)) {
|
|
||||||
m_rclmain->newDupsW(m_detaildoc, dups);
|
m_rclmain->newDupsW(m_detaildoc, dups);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -862,8 +866,7 @@ void ResTable::linkWasClicked(const QUrl &url)
|
|||||||
// Open parent folder
|
// Open parent folder
|
||||||
case 'F':
|
case 'F':
|
||||||
{
|
{
|
||||||
emit editRequested(ResultPopup::getParent(
|
emit editRequested(ResultPopup::getFolder(m_detaildoc));
|
||||||
std::shared_ptr<DocSequence>(), m_detaildoc));
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -872,7 +875,7 @@ void ResTable::linkWasClicked(const QUrl &url)
|
|||||||
{
|
{
|
||||||
if (what == 'P') {
|
if (what == 'P') {
|
||||||
if (m_ismainres) {
|
if (m_ismainres) {
|
||||||
emit docPreviewClicked(i, m_detaildoc, 0);
|
emit docPreviewClicked(docseqnum, m_detaildoc, 0);
|
||||||
} else {
|
} else {
|
||||||
emit previewRequested(m_detaildoc);
|
emit previewRequested(m_detaildoc);
|
||||||
}
|
}
|
||||||
@ -1013,9 +1016,8 @@ void ResTable::menuOpenParent()
|
|||||||
|
|
||||||
void ResTable::menuOpenFolder()
|
void ResTable::menuOpenFolder()
|
||||||
{
|
{
|
||||||
if (m_detaildocnum >= 0 && m_model && m_model->getDocSource()) {
|
if (m_detaildocnum >= 0) {
|
||||||
Rcl::Doc pdoc =
|
Rcl::Doc pdoc = ResultPopup::getFolder(m_detaildoc);
|
||||||
ResultPopup::getFolder(m_model->getDocSource(), m_detaildoc);
|
|
||||||
if (!pdoc.url.empty()) {
|
if (!pdoc.url.empty()) {
|
||||||
emit editRequested(pdoc);
|
emit editRequested(pdoc);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user