cleaned up preview window interface
This commit is contained in:
parent
94b6fa9dd5
commit
7d007bcb8f
@ -1,5 +1,5 @@
|
|||||||
#ifndef lint
|
#ifndef lint
|
||||||
static char rcsid[] = "@(#$Id: preview_w.cpp,v 1.23 2007-07-13 06:31:30 dockes Exp $ (C) 2005 J.F.Dockes";
|
static char rcsid[] = "@(#$Id: preview_w.cpp,v 1.24 2007-07-20 10:55:04 dockes Exp $ (C) 2005 J.F.Dockes";
|
||||||
#endif
|
#endif
|
||||||
/*
|
/*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@ -89,15 +89,16 @@ void Preview::init()
|
|||||||
this, SLOT(currentChanged(QWidget *)));
|
this, SLOT(currentChanged(QWidget *)));
|
||||||
connect(bt, SIGNAL(clicked()), this, SLOT(closeCurrentTab()));
|
connect(bt, SIGNAL(clicked()), this, SLOT(closeCurrentTab()));
|
||||||
|
|
||||||
dynSearchActive = false;
|
m_dynSearchActive = false;
|
||||||
canBeep = true;
|
m_canBeep = true;
|
||||||
tabData.push_back(TabData(pvTab->currentPage()));
|
m_tabData.push_back(TabData(pvTab->currentPage()));
|
||||||
currentW = 0;
|
m_currentW = 0;
|
||||||
if (prefs.pvwidth > 100) {
|
if (prefs.pvwidth > 100) {
|
||||||
resize(prefs.pvwidth, prefs.pvheight);
|
resize(prefs.pvwidth, prefs.pvheight);
|
||||||
}
|
}
|
||||||
m_loading = false;
|
m_loading = false;
|
||||||
currentChanged(pvTab->currentPage());
|
currentChanged(pvTab->currentPage());
|
||||||
|
m_justCreated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Preview::closeEvent(QCloseEvent *e)
|
void Preview::closeEvent(QCloseEvent *e)
|
||||||
@ -148,7 +149,7 @@ bool Preview::eventFilter(QObject *target, QEvent *event)
|
|||||||
// LOGDEB(("Preview::eventFilter: got ^W\n"));
|
// LOGDEB(("Preview::eventFilter: got ^W\n"));
|
||||||
closeCurrentTab();
|
closeCurrentTab();
|
||||||
return true;
|
return true;
|
||||||
} else if (dynSearchActive) {
|
} else if (m_dynSearchActive) {
|
||||||
if (keyEvent->key() == Qt::Key_F3) {
|
if (keyEvent->key() == Qt::Key_F3) {
|
||||||
doSearch(searchTextLine->text(), true, false);
|
doSearch(searchTextLine->text(), true, false);
|
||||||
return true;
|
return true;
|
||||||
@ -164,7 +165,7 @@ bool Preview::eventFilter(QObject *target, QEvent *event)
|
|||||||
if (e && target == e) {
|
if (e && target == e) {
|
||||||
if (keyEvent->key() == Qt::Key_Slash) {
|
if (keyEvent->key() == Qt::Key_Slash) {
|
||||||
searchTextLine->setFocus();
|
searchTextLine->setFocus();
|
||||||
dynSearchActive = true;
|
m_dynSearchActive = true;
|
||||||
return true;
|
return true;
|
||||||
} else if (keyEvent->key() == Qt::Key_Space) {
|
} else if (keyEvent->key() == Qt::Key_Space) {
|
||||||
e->scrollBy(0, e->visibleHeight());
|
e->scrollBy(0, e->visibleHeight());
|
||||||
@ -183,12 +184,12 @@ void Preview::searchTextLine_textChanged(const QString & text)
|
|||||||
{
|
{
|
||||||
LOGDEB1(("search line text changed. text: '%s'\n", text.ascii()));
|
LOGDEB1(("search line text changed. text: '%s'\n", text.ascii()));
|
||||||
if (text.isEmpty()) {
|
if (text.isEmpty()) {
|
||||||
dynSearchActive = false;
|
m_dynSearchActive = false;
|
||||||
// nextButton->setEnabled(false);
|
// nextButton->setEnabled(false);
|
||||||
// prevButton->setEnabled(false);
|
// prevButton->setEnabled(false);
|
||||||
clearPB->setEnabled(false);
|
clearPB->setEnabled(false);
|
||||||
} else {
|
} else {
|
||||||
dynSearchActive = true;
|
m_dynSearchActive = true;
|
||||||
// nextButton->setEnabled(true);
|
// nextButton->setEnabled(true);
|
||||||
// prevButton->setEnabled(true);
|
// prevButton->setEnabled(true);
|
||||||
clearPB->setEnabled(true);
|
clearPB->setEnabled(true);
|
||||||
@ -275,11 +276,11 @@ void Preview::doSearch(const QString &_text, bool next, bool reverse,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (found) {
|
if (found) {
|
||||||
canBeep = true;
|
m_canBeep = true;
|
||||||
} else {
|
} else {
|
||||||
if (canBeep)
|
if (m_canBeep)
|
||||||
QApplication::beep();
|
QApplication::beep();
|
||||||
canBeep = false;
|
m_canBeep = false;
|
||||||
}
|
}
|
||||||
LOGDEB(("Preview::doSearch: return\n"));
|
LOGDEB(("Preview::doSearch: return\n"));
|
||||||
}
|
}
|
||||||
@ -298,7 +299,7 @@ void Preview::prevPressed()
|
|||||||
void Preview::currentChanged(QWidget * tw)
|
void Preview::currentChanged(QWidget * tw)
|
||||||
{
|
{
|
||||||
QWidget *edit = (QWidget *)tw->child("pvEdit");
|
QWidget *edit = (QWidget *)tw->child("pvEdit");
|
||||||
currentW = tw;
|
m_currentW = tw;
|
||||||
LOGDEB1(("Preview::currentChanged(). Editor: %p\n", edit));
|
LOGDEB1(("Preview::currentChanged(). Editor: %p\n", edit));
|
||||||
|
|
||||||
if (edit == 0) {
|
if (edit == 0) {
|
||||||
@ -331,9 +332,9 @@ void Preview::currentChanged(QWidget * tw)
|
|||||||
void Preview::selecChanged()
|
void Preview::selecChanged()
|
||||||
{
|
{
|
||||||
LOGDEB1(("Selection changed\n"));
|
LOGDEB1(("Selection changed\n"));
|
||||||
if (!currentW)
|
if (!m_currentW)
|
||||||
return;
|
return;
|
||||||
QTextEdit *edit = (QTextEdit *)currentW->child("pvEdit");
|
QTextEdit *edit = (QTextEdit *)m_currentW->child("pvEdit");
|
||||||
if (edit == 0) {
|
if (edit == 0) {
|
||||||
LOGERR(("Editor child not found\n"));
|
LOGERR(("Editor child not found\n"));
|
||||||
return;
|
return;
|
||||||
@ -357,9 +358,9 @@ void Preview::selecChanged(){}
|
|||||||
void Preview::textDoubleClicked(int, int)
|
void Preview::textDoubleClicked(int, int)
|
||||||
{
|
{
|
||||||
LOGDEB2(("Preview::textDoubleClicked\n"));
|
LOGDEB2(("Preview::textDoubleClicked\n"));
|
||||||
if (!currentW)
|
if (!m_currentW)
|
||||||
return;
|
return;
|
||||||
QTextEdit *edit = (QTextEdit *)currentW->child("pvEdit");
|
QTextEdit *edit = (QTextEdit *)m_currentW->child("pvEdit");
|
||||||
if (edit == 0) {
|
if (edit == 0) {
|
||||||
LOGERR(("Editor child not found\n"));
|
LOGERR(("Editor child not found\n"));
|
||||||
return;
|
return;
|
||||||
@ -381,10 +382,10 @@ void Preview::closeCurrentTab()
|
|||||||
return;
|
return;
|
||||||
pvTab->removePage(tw);
|
pvTab->removePage(tw);
|
||||||
// Have to remove from tab data list
|
// Have to remove from tab data list
|
||||||
for (list<TabData>::iterator it = tabData.begin();
|
for (list<TabData>::iterator it = m_tabData.begin();
|
||||||
it != tabData.end(); it++) {
|
it != m_tabData.end(); it++) {
|
||||||
if (it->w == tw) {
|
if (it->w == tw) {
|
||||||
tabData.erase(it);
|
m_tabData.erase(it);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -393,7 +394,6 @@ void Preview::closeCurrentTab()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QTextEdit *Preview::addEditorTab()
|
QTextEdit *Preview::addEditorTab()
|
||||||
{
|
{
|
||||||
QWidget *anon = new QWidget((QWidget *)pvTab);
|
QWidget *anon = new QWidget((QWidget *)pvTab);
|
||||||
@ -404,7 +404,7 @@ QTextEdit *Preview::addEditorTab()
|
|||||||
anonLayout->addWidget(editor);
|
anonLayout->addWidget(editor);
|
||||||
pvTab->addTab(anon, "Tab");
|
pvTab->addTab(anon, "Tab");
|
||||||
pvTab->showPage(anon);
|
pvTab->showPage(anon);
|
||||||
tabData.push_back(TabData(anon));
|
m_tabData.push_back(TabData(anon));
|
||||||
return editor;
|
return editor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -440,8 +440,8 @@ void Preview::setCurTabProps(const string &fn, const Rcl::Doc &doc,
|
|||||||
tiptxt += meta_it->second + "\n";
|
tiptxt += meta_it->second + "\n";
|
||||||
pvTab->setTabToolTip(w,QString::fromUtf8(tiptxt.c_str(), tiptxt.length()));
|
pvTab->setTabToolTip(w,QString::fromUtf8(tiptxt.c_str(), tiptxt.length()));
|
||||||
|
|
||||||
for (list<TabData>::iterator it = tabData.begin();
|
for (list<TabData>::iterator it = m_tabData.begin();
|
||||||
it != tabData.end(); it++) {
|
it != m_tabData.end(); it++) {
|
||||||
if (it->w == w) {
|
if (it->w == w) {
|
||||||
it->fn = fn;
|
it->fn = fn;
|
||||||
it->ipath = doc.ipath;
|
it->ipath = doc.ipath;
|
||||||
@ -456,8 +456,8 @@ TabData *Preview::tabDataForCurrent()
|
|||||||
QWidget *w = pvTab->currentPage();
|
QWidget *w = pvTab->currentPage();
|
||||||
if (w == 0)
|
if (w == 0)
|
||||||
return 0;
|
return 0;
|
||||||
for (list<TabData>::iterator it = tabData.begin();
|
for (list<TabData>::iterator it = m_tabData.begin();
|
||||||
it != tabData.end(); it++) {
|
it != m_tabData.end(); it++) {
|
||||||
if (it->w == w) {
|
if (it->w == w) {
|
||||||
return &(*it);
|
return &(*it);
|
||||||
}
|
}
|
||||||
@ -465,11 +465,12 @@ TabData *Preview::tabDataForCurrent()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Preview::makeDocCurrent(const string &fn, const Rcl::Doc &doc)
|
bool Preview::makeDocCurrent(const string &fn, size_t sz,
|
||||||
|
const Rcl::Doc& doc, int docnum, bool sametab)
|
||||||
{
|
{
|
||||||
LOGDEB(("Preview::makeFileCurrent: %s\n", fn.c_str()));
|
LOGDEB(("Preview::makeDocCurrent: %s\n", fn.c_str()));
|
||||||
for (list<TabData>::iterator it = tabData.begin();
|
for (list<TabData>::iterator it = m_tabData.begin();
|
||||||
it != tabData.end(); it++) {
|
it != m_tabData.end(); it++) {
|
||||||
LOGDEB2(("Preview::makeFileCurrent: compare to w %p, file %s\n",
|
LOGDEB2(("Preview::makeFileCurrent: compare to w %p, file %s\n",
|
||||||
it->w, it->fn.c_str()));
|
it->w, it->fn.c_str()));
|
||||||
if (!it->fn.compare(fn) && !it->ipath.compare(doc.ipath)) {
|
if (!it->fn.compare(fn) && !it->ipath.compare(doc.ipath)) {
|
||||||
@ -477,7 +478,16 @@ bool Preview::makeDocCurrent(const string &fn, const Rcl::Doc &doc)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
// if just created the first tab was created during init
|
||||||
|
if (!sametab && !m_justCreated && !addEditorTab()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
m_justCreated = false;
|
||||||
|
if (!loadFileInCurrentTab(fn, sz, doc, docnum)) {
|
||||||
|
closeCurrentTab();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -779,7 +789,7 @@ bool Preview::loadFileInCurrentTab(string fn, size_t sz, const Rcl::Doc &idoc,
|
|||||||
progress.close();
|
progress.close();
|
||||||
|
|
||||||
if (searchTextLine->text().length() != 0) {
|
if (searchTextLine->text().length() != 0) {
|
||||||
canBeep = true;
|
m_canBeep = true;
|
||||||
doSearch(searchTextLine->text(), true, false);
|
doSearch(searchTextLine->text(), true, false);
|
||||||
} else {
|
} else {
|
||||||
if (hasAnchors) {
|
if (hasAnchors) {
|
||||||
@ -790,12 +800,12 @@ bool Preview::loadFileInCurrentTab(string fn, size_t sz, const Rcl::Doc &idoc,
|
|||||||
// unusable (plus it does not always work)
|
// unusable (plus it does not always work)
|
||||||
#if (QT_VERSION < 0x040000)
|
#if (QT_VERSION < 0x040000)
|
||||||
#ifdef QT_SCROLL_TO_ANCHOR_BUG
|
#ifdef QT_SCROLL_TO_ANCHOR_BUG
|
||||||
bool ocanbeep = canBeep;
|
bool ocanbeep = m_canBeep;
|
||||||
canBeep = false;
|
m_canBeep = false;
|
||||||
QString empty;
|
QString empty;
|
||||||
// doSearch(_text, next, reverse, wordOnly)
|
// doSearch(_text, next, reverse, wordOnly)
|
||||||
doSearch(empty, true, false, false);
|
doSearch(empty, true, false, false);
|
||||||
canBeep = ocanbeep;
|
m_canBeep = ocanbeep;
|
||||||
#endif
|
#endif
|
||||||
#endif // (QT_VERSION < 0x040000)
|
#endif // (QT_VERSION < 0x040000)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
#ifndef _PREVIEW_W_H_INCLUDED_
|
#ifndef _PREVIEW_W_H_INCLUDED_
|
||||||
#define _PREVIEW_W_H_INCLUDED_
|
#define _PREVIEW_W_H_INCLUDED_
|
||||||
/* @(#$Id: preview_w.h,v 1.12 2007-07-13 06:31:30 dockes Exp $ (C) 2006 J.F.Dockes */
|
/* @(#$Id: preview_w.h,v 1.13 2007-07-20 10:55:05 dockes Exp $ (C) 2006 J.F.Dockes */
|
||||||
/*
|
/*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -65,39 +65,34 @@ class Preview : public DummyPreviewBase
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Preview(QWidget* parent = 0)
|
Preview(int sid, // Search Id
|
||||||
: DummyPreviewBase(parent) {init();}
|
const HiliteData& hdata) // Search terms etc. for highlighting
|
||||||
|
: DummyPreviewBase(0)
|
||||||
~Preview(){}
|
|
||||||
|
|
||||||
virtual void setSId(int sid, const HiliteData& hdata)
|
|
||||||
{
|
{
|
||||||
|
init();
|
||||||
m_searchId = sid;
|
m_searchId = sid;
|
||||||
m_hData = hdata;
|
m_hData = hdata;
|
||||||
}
|
}
|
||||||
virtual void closeEvent( QCloseEvent *e );
|
|
||||||
virtual bool eventFilter( QObject *target, QEvent *event );
|
~Preview(){}
|
||||||
virtual bool makeDocCurrent( const string & fn, const Rcl::Doc & doc );
|
|
||||||
virtual QTextEdit *getCurrentEditor();
|
virtual void closeEvent(QCloseEvent *e );
|
||||||
virtual QTextEdit *addEditorTab();
|
virtual bool eventFilter(QObject *target, QEvent *event );
|
||||||
virtual bool loadFileInCurrentTab(string fn, size_t sz,
|
virtual bool makeDocCurrent(const string &fn, size_t sz,
|
||||||
const Rcl::Doc& idoc, int dnm);
|
const Rcl::Doc& idoc, int docnum,
|
||||||
|
bool sametab = false);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
virtual void searchTextLine_textChanged( const QString & text );
|
virtual void searchTextLine_textChanged(const QString& text);
|
||||||
virtual void doSearch(const QString &str, bool next, bool reverse,
|
virtual void doSearch(const QString& str, bool next, bool reverse,
|
||||||
bool wo = false);
|
bool wo = false);
|
||||||
virtual void nextPressed();
|
virtual void nextPressed();
|
||||||
virtual void prevPressed();
|
virtual void prevPressed();
|
||||||
virtual void currentChanged( QWidget * tw );
|
virtual void currentChanged(QWidget *tw);
|
||||||
virtual void closeCurrentTab();
|
virtual void closeCurrentTab();
|
||||||
virtual void setCurTabProps(const string & fn, const Rcl::Doc & doc,
|
|
||||||
int docnum);
|
|
||||||
virtual void textDoubleClicked(int, int);
|
virtual void textDoubleClicked(int, int);
|
||||||
|
|
||||||
virtual void selecChanged();
|
virtual void selecChanged();
|
||||||
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void previewClosed(QWidget *);
|
void previewClosed(QWidget *);
|
||||||
void wordSelect(QString);
|
void wordSelect(QString);
|
||||||
@ -106,18 +101,26 @@ signals:
|
|||||||
void previewExposed(int sid, int docnum);
|
void previewExposed(int sid, int docnum);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int m_searchId; // Identifier of search in main window. This is so that
|
// Identifier of search in main window. This is used to check that
|
||||||
// we make sense when requesting the next document when
|
// we make sense when requesting the next document when browsing
|
||||||
// browsing successive search results in a tab.
|
// successive search results in a tab.
|
||||||
int matchIndex;
|
int m_searchId;
|
||||||
int matchPara;
|
|
||||||
bool dynSearchActive;
|
bool m_dynSearchActive;
|
||||||
bool canBeep;
|
bool m_canBeep;
|
||||||
bool m_loading;
|
bool m_loading;
|
||||||
list<TabData> tabData;
|
list<TabData> m_tabData;
|
||||||
QWidget *currentW;
|
QWidget *m_currentW;
|
||||||
HiliteData m_hData;
|
HiliteData m_hData;
|
||||||
|
bool m_justCreated; // First tab create is different
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
|
virtual void setCurTabProps(const string& fn, const Rcl::Doc& doc,
|
||||||
|
int docnum);
|
||||||
|
virtual QTextEdit *getCurrentEditor();
|
||||||
|
virtual QTextEdit *addEditorTab();
|
||||||
|
virtual bool loadFileInCurrentTab(string fn, size_t sz,
|
||||||
|
const Rcl::Doc& idoc, int dnm);
|
||||||
TabData *tabDataForCurrent(); // Return auxiliary data pointer for cur tab
|
TabData *tabDataForCurrent(); // Return auxiliary data pointer for cur tab
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
#ifndef lint
|
#ifndef lint
|
||||||
static char rcsid[] = "@(#$Id: rclmain_w.cpp,v 1.32 2007-07-13 06:31:30 dockes Exp $ (C) 2005 J.F.Dockes";
|
static char rcsid[] = "@(#$Id: rclmain_w.cpp,v 1.33 2007-07-20 10:55:05 dockes Exp $ (C) 2005 J.F.Dockes";
|
||||||
#endif
|
#endif
|
||||||
/*
|
/*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@ -458,7 +458,9 @@ void RclMain::startPreview(int docnum, int mod)
|
|||||||
curPreview = 0;
|
curPreview = 0;
|
||||||
}
|
}
|
||||||
if (curPreview == 0) {
|
if (curPreview == 0) {
|
||||||
curPreview = new Preview(0);
|
HiliteData hdata;
|
||||||
|
m_searchData->getTerms(hdata.terms, hdata.groups, hdata.gslks);
|
||||||
|
curPreview = new Preview(m_searchId, hdata);
|
||||||
if (curPreview == 0) {
|
if (curPreview == 0) {
|
||||||
QMessageBox::warning(0, tr("Warning"),
|
QMessageBox::warning(0, tr("Warning"),
|
||||||
tr("Can't create preview window"),
|
tr("Can't create preview window"),
|
||||||
@ -466,10 +468,6 @@ void RclMain::startPreview(int docnum, int mod)
|
|||||||
QMessageBox::NoButton);
|
QMessageBox::NoButton);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
HiliteData hdata;
|
|
||||||
m_searchData->getTerms(hdata.terms, hdata.groups, hdata.gslks);
|
|
||||||
curPreview->setSId(m_searchId, hdata);
|
|
||||||
curPreview->setCaption(resList->getDescription());
|
|
||||||
connect(curPreview, SIGNAL(previewClosed(QWidget *)),
|
connect(curPreview, SIGNAL(previewClosed(QWidget *)),
|
||||||
this, SLOT(previewClosed(QWidget *)));
|
this, SLOT(previewClosed(QWidget *)));
|
||||||
connect(curPreview, SIGNAL(wordSelect(QString)),
|
connect(curPreview, SIGNAL(wordSelect(QString)),
|
||||||
@ -480,16 +478,10 @@ void RclMain::startPreview(int docnum, int mod)
|
|||||||
this, SLOT(previewPrevInTab(int, int)));
|
this, SLOT(previewPrevInTab(int, int)));
|
||||||
connect(curPreview, SIGNAL(previewExposed(int, int)),
|
connect(curPreview, SIGNAL(previewExposed(int, int)),
|
||||||
this, SLOT(previewExposed(int, int)));
|
this, SLOT(previewExposed(int, int)));
|
||||||
|
curPreview->setCaption(resList->getDescription());
|
||||||
curPreview->show();
|
curPreview->show();
|
||||||
} else {
|
}
|
||||||
if (curPreview->makeDocCurrent(fn, doc)) {
|
curPreview->makeDocCurrent(fn, st.st_size, doc, docnum);
|
||||||
// Already there
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
(void)curPreview->addEditorTab();
|
|
||||||
}
|
|
||||||
if (!curPreview->loadFileInCurrentTab(fn, st.st_size, doc, docnum))
|
|
||||||
curPreview->closeCurrentTab();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -509,7 +501,7 @@ void RclMain::startPreview(Rcl::Doc doc)
|
|||||||
fn.c_str());
|
fn.c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Preview *preview = new Preview(0);
|
Preview *preview = new Preview(0, HiliteData());
|
||||||
if (preview == 0) {
|
if (preview == 0) {
|
||||||
QMessageBox::warning(0, tr("Warning"),
|
QMessageBox::warning(0, tr("Warning"),
|
||||||
tr("Can't create preview window"),
|
tr("Can't create preview window"),
|
||||||
@ -517,12 +509,10 @@ void RclMain::startPreview(Rcl::Doc doc)
|
|||||||
QMessageBox::NoButton);
|
QMessageBox::NoButton);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
preview->setSId(0, HiliteData());
|
|
||||||
connect(preview, SIGNAL(wordSelect(QString)),
|
connect(preview, SIGNAL(wordSelect(QString)),
|
||||||
this, SLOT(ssearchAddTerm(QString)));
|
this, SLOT(ssearchAddTerm(QString)));
|
||||||
preview->show();
|
preview->show();
|
||||||
if (!preview->loadFileInCurrentTab(fn, st.st_size, doc, 0))
|
preview->makeDocCurrent(fn, st.st_size, doc, 0);
|
||||||
preview->closeCurrentTab();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show next document from result list in current preview tab
|
// Show next document from result list in current preview tab
|
||||||
@ -531,6 +521,13 @@ void RclMain::previewNextInTab(int sid, int docnum)
|
|||||||
LOGDEB(("RclMain::previewNextInTab sid %d docnum %d, m_sid %d\n",
|
LOGDEB(("RclMain::previewNextInTab sid %d docnum %d, m_sid %d\n",
|
||||||
sid, docnum, m_searchId));
|
sid, docnum, m_searchId));
|
||||||
|
|
||||||
|
// We should handle this case better: this happens when the latest
|
||||||
|
// preview was closed and the user asks for the next document in
|
||||||
|
// an older one. The whole situation with multiple previews and
|
||||||
|
// showNext/showPrev is a mess, just avoid crashing for now.
|
||||||
|
if (curPreview == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
if (sid != m_searchId) {
|
if (sid != m_searchId) {
|
||||||
QMessageBox::warning(0, "Recoll",
|
QMessageBox::warning(0, "Recoll",
|
||||||
tr("This search is not active any more"));
|
tr("This search is not active any more"));
|
||||||
@ -560,8 +557,7 @@ void RclMain::previewNextInTab(int sid, int docnum)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!curPreview->loadFileInCurrentTab(fn, st.st_size, doc, docnum))
|
curPreview->makeDocCurrent(fn, st.st_size, doc, docnum, true);
|
||||||
curPreview->closeCurrentTab();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show previous document from result list in current preview tab
|
// Show previous document from result list in current preview tab
|
||||||
@ -570,6 +566,13 @@ void RclMain::previewPrevInTab(int sid, int docnum)
|
|||||||
LOGDEB(("RclMain::previewPrevInTab sid %d docnum %d, m_sid %d\n",
|
LOGDEB(("RclMain::previewPrevInTab sid %d docnum %d, m_sid %d\n",
|
||||||
sid, docnum, m_searchId));
|
sid, docnum, m_searchId));
|
||||||
|
|
||||||
|
// We should handle this case better: this happens when the latest
|
||||||
|
// preview was closed and the user asks for the next document in
|
||||||
|
// an older one. The whole situation with multiple previews and
|
||||||
|
// showNext/showPrev is a mess, just avoid crashing for now.
|
||||||
|
if (curPreview == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
if (sid != m_searchId) {
|
if (sid != m_searchId) {
|
||||||
QMessageBox::warning(0, "Recoll",
|
QMessageBox::warning(0, "Recoll",
|
||||||
tr("This search is not active any more"));
|
tr("This search is not active any more"));
|
||||||
@ -596,8 +599,7 @@ void RclMain::previewPrevInTab(int sid, int docnum)
|
|||||||
fn.c_str());
|
fn.c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!curPreview->loadFileInCurrentTab(fn, st.st_size, doc, docnum))
|
curPreview->makeDocCurrent(fn, st.st_size, doc, docnum, true);
|
||||||
curPreview->closeCurrentTab();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Preview tab exposed: possibly tell reslist (to color the paragraph)
|
// Preview tab exposed: possibly tell reslist (to color the paragraph)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user