GUI: popup in reslist header would segfault + direct respage access
This commit is contained in:
parent
5292a97de3
commit
877f4c90c2
@ -349,28 +349,21 @@ void ResList::languageChange()
|
|||||||
setWindowTitle(tr("Result list"));
|
setWindowTitle(tr("Result list"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get document number from paragraph number
|
// Get document number from text block number
|
||||||
int ResList::docnumfromparnum(int par)
|
int ResList::docnumfromparnum(int block)
|
||||||
{
|
{
|
||||||
if (m_pager->pageNumber() < 0)
|
if (m_pager->pageNumber() < 0)
|
||||||
return -1;
|
return -1;
|
||||||
std::map<int,int>::iterator it;
|
|
||||||
|
|
||||||
// Try to find the first number < input and actually in the map
|
// Try to find the first number < input and actually in the map
|
||||||
// (result blocks can be made of several text blocks)
|
// (result blocks can be made of several text blocks)
|
||||||
while (par > 0) {
|
std::map<int,int>::iterator it;
|
||||||
it = m_pageParaToReldocnums.find(par);
|
do {
|
||||||
|
it = m_pageParaToReldocnums.find(block);
|
||||||
if (it != m_pageParaToReldocnums.end())
|
if (it != m_pageParaToReldocnums.end())
|
||||||
break;
|
return pageFirstDocNum() + it->second;
|
||||||
par--;
|
} while (--block >= 0);
|
||||||
}
|
return -1;
|
||||||
int dn;
|
|
||||||
if (it != m_pageParaToReldocnums.end()) {
|
|
||||||
dn = m_pager->pageNumber() * prefs.respagesize + it->second;
|
|
||||||
} else {
|
|
||||||
dn = -1;
|
|
||||||
}
|
|
||||||
return dn;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get paragraph number from document number
|
// Get paragraph number from document number
|
||||||
@ -381,9 +374,10 @@ pair<int,int> ResList::parnumfromdocnum(int docnum)
|
|||||||
LOGDEB(("parnumfromdocnum: no page return -1,-1\n"));
|
LOGDEB(("parnumfromdocnum: no page return -1,-1\n"));
|
||||||
return pair<int,int>(-1,-1);
|
return pair<int,int>(-1,-1);
|
||||||
}
|
}
|
||||||
int winfirst = m_pager->pageNumber() * prefs.respagesize;
|
int winfirst = pageFirstDocNum();
|
||||||
if (docnum - winfirst < 0) {
|
if (docnum - winfirst < 0) {
|
||||||
LOGDEB(("parnumfromdocnum: not in win return -1,-1\n"));
|
LOGDEB(("parnumfromdocnum: docnum %d < winfirst %d return -1,-1\n",
|
||||||
|
docnum, winfirst));
|
||||||
return pair<int,int>(-1,-1);
|
return pair<int,int>(-1,-1);
|
||||||
}
|
}
|
||||||
docnum -= winfirst;
|
docnum -= winfirst;
|
||||||
@ -412,8 +406,8 @@ pair<int,int> ResList::parnumfromdocnum(int docnum)
|
|||||||
bool ResList::getDoc(int docnum, Rcl::Doc &doc)
|
bool ResList::getDoc(int docnum, Rcl::Doc &doc)
|
||||||
{
|
{
|
||||||
LOGDEB(("ResList::getDoc: docnum %d winfirst %d\n", docnum,
|
LOGDEB(("ResList::getDoc: docnum %d winfirst %d\n", docnum,
|
||||||
m_pager->pageNumber() * prefs.respagesize));
|
pageFirstDocNum()));
|
||||||
int winfirst = m_pager->pageFirstDocNum();
|
int winfirst = pageFirstDocNum();
|
||||||
int winlast = m_pager->pageLastDocNum();
|
int winlast = m_pager->pageLastDocNum();
|
||||||
if (docnum < 0 || winfirst < 0 || winlast < 0)
|
if (docnum < 0 || winfirst < 0 || winlast < 0)
|
||||||
return false;
|
return false;
|
||||||
@ -429,7 +423,7 @@ bool ResList::getDoc(int docnum, Rcl::Doc &doc)
|
|||||||
} else if (docnum < winlast + 1 + prefs.respagesize) {
|
} else if (docnum < winlast + 1 + prefs.respagesize) {
|
||||||
resultPageNext();
|
resultPageNext();
|
||||||
}
|
}
|
||||||
winfirst = m_pager->pageFirstDocNum();
|
winfirst = pageFirstDocNum();
|
||||||
winlast = m_pager->pageLastDocNum();
|
winlast = m_pager->pageLastDocNum();
|
||||||
if (docnum >= winfirst && docnum <= winlast) {
|
if (docnum >= winfirst && docnum <= winlast) {
|
||||||
return m_source->getDoc(docnum, doc);
|
return m_source->getDoc(docnum, doc);
|
||||||
@ -520,6 +514,12 @@ void ResList::resultPageNext()
|
|||||||
displayPage();
|
displayPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ResList::resultPageFor(int docnum)
|
||||||
|
{
|
||||||
|
m_pager->resultPageFor(docnum);
|
||||||
|
displayPage();
|
||||||
|
}
|
||||||
|
|
||||||
void ResList::displayPage()
|
void ResList::displayPage()
|
||||||
{
|
{
|
||||||
m_pageParaToReldocnums.clear();
|
m_pageParaToReldocnums.clear();
|
||||||
@ -745,3 +745,7 @@ void ResList::menuExpand()
|
|||||||
if (getDoc(m_popDoc, doc))
|
if (getDoc(m_popDoc, doc))
|
||||||
emit docExpand(doc);
|
emit docExpand(doc);
|
||||||
}
|
}
|
||||||
|
int ResList::pageFirstDocNum()
|
||||||
|
{
|
||||||
|
return m_pager->pageFirstDocNum();
|
||||||
|
}
|
||||||
|
|||||||
@ -66,6 +66,7 @@ class ResList : public QTextBrowser
|
|||||||
bool getDoc(int docnum, Rcl::Doc &);
|
bool getDoc(int docnum, Rcl::Doc &);
|
||||||
bool displayingHistory();
|
bool displayingHistory();
|
||||||
int listId() const {return m_listId;}
|
int listId() const {return m_listId;}
|
||||||
|
int pageFirstDocNum();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
virtual void setDocSource(RefCntr<DocSequence> nsource);
|
virtual void setDocSource(RefCntr<DocSequence> nsource);
|
||||||
@ -75,6 +76,7 @@ class ResList : public QTextBrowser
|
|||||||
virtual void resultPageBack(); // Previous page of results
|
virtual void resultPageBack(); // Previous page of results
|
||||||
virtual void resultPageFirst(); // First page of results
|
virtual void resultPageFirst(); // First page of results
|
||||||
virtual void resultPageNext(); // Next (or first) page of results
|
virtual void resultPageNext(); // Next (or first) page of results
|
||||||
|
virtual void resultPageFor(int docnum); // Page containing docnum
|
||||||
virtual void displayPage(); // Display current page
|
virtual void displayPage(); // Display current page
|
||||||
virtual void menuPreview();
|
virtual void menuPreview();
|
||||||
virtual void menuSaveToFile();
|
virtual void menuSaveToFile();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user