more preview window interface cleanup

This commit is contained in:
dockes 2007-07-20 11:38:18 +00:00
parent 7d007bcb8f
commit 90e4962c6d
4 changed files with 38 additions and 44 deletions

View File

@ -1,5 +1,5 @@
#ifndef lint #ifndef lint
static char rcsid[] = "@(#$Id: preview_w.cpp,v 1.24 2007-07-20 10:55:04 dockes Exp $ (C) 2005 J.F.Dockes"; static char rcsid[] = "@(#$Id: preview_w.cpp,v 1.25 2007-07-20 11:38:18 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
@ -111,8 +111,8 @@ void Preview::closeEvent(QCloseEvent *e)
} }
prefs.pvwidth = width(); prefs.pvwidth = width();
prefs.pvheight = height(); prefs.pvheight = height();
emit previewExposed(m_searchId, -1); emit previewExposed(this, m_searchId, -1);
emit previewClosed((QWidget *)this); emit previewClosed(this);
QWidget::closeEvent(e); QWidget::closeEvent(e);
} }
@ -135,14 +135,14 @@ bool Preview::eventFilter(QObject *target, QEvent *event)
// LOGDEB(("Preview::eventFilter: got Shift-Up\n")); // LOGDEB(("Preview::eventFilter: got Shift-Up\n"));
TabData *d = tabDataForCurrent(); TabData *d = tabDataForCurrent();
if (d) if (d)
emit(showNext(m_searchId, d->docnum)); emit(showNext(this, m_searchId, d->docnum));
return true; return true;
} else if (keyEvent->key() == Qt::Key_Up && } else if (keyEvent->key() == Qt::Key_Up &&
(keyEvent->state() & Qt::ShiftButton)) { (keyEvent->state() & Qt::ShiftButton)) {
// LOGDEB(("Preview::eventFilter: got Shift-Down\n")); // LOGDEB(("Preview::eventFilter: got Shift-Down\n"));
TabData *d = tabDataForCurrent(); TabData *d = tabDataForCurrent();
if (d) if (d)
emit(showPrev(m_searchId, d->docnum)); emit(showPrev(this, m_searchId, d->docnum));
return true; return true;
} else if (keyEvent->key() == Qt::Key_W && } else if (keyEvent->key() == Qt::Key_W &&
(keyEvent->state() & Qt::ControlButton)) { (keyEvent->state() & Qt::ControlButton)) {
@ -319,7 +319,7 @@ void Preview::currentChanged(QWidget * tw)
edit->installEventFilter(this); edit->installEventFilter(this);
TabData *d = tabDataForCurrent(); TabData *d = tabDataForCurrent();
if (d) if (d)
emit(previewExposed(m_searchId, d->docnum)); emit(previewExposed(this, m_searchId, d->docnum));
} }
#if (QT_VERSION >= 0x040000) #if (QT_VERSION >= 0x040000)
@ -814,7 +814,7 @@ bool Preview::loadFileInCurrentTab(string fn, size_t sz, const Rcl::Doc &idoc,
g_dynconf->enterDoc(fn, doc.ipath); g_dynconf->enterDoc(fn, doc.ipath);
editor->setFocus(); editor->setFocus();
emit(previewExposed(m_searchId, docnum)); emit(previewExposed(this, m_searchId, docnum));
LOGDEB(("LoadFileInCurrentTab: returning true\n")); LOGDEB(("LoadFileInCurrentTab: returning true\n"));
return true; return true;
} }

View File

@ -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.13 2007-07-20 10:55:05 dockes Exp $ (C) 2006 J.F.Dockes */ /* @(#$Id: preview_w.h,v 1.14 2007-07-20 11:38:18 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
@ -94,11 +94,11 @@ public slots:
virtual void selecChanged(); virtual void selecChanged();
signals: signals:
void previewClosed(QWidget *); void previewClosed(Preview *);
void wordSelect(QString); void wordSelect(QString);
void showNext(int sid, int docnum); void showNext(Preview *w, int sid, int docnum);
void showPrev(int sid, int docnum); void showPrev(Preview *w, int sid, int docnum);
void previewExposed(int sid, int docnum); void previewExposed(Preview *w, int sid, int docnum);
private: private:
// Identifier of search in main window. This is used to check that // Identifier of search in main window. This is used to check that

View File

@ -1,5 +1,5 @@
#ifndef lint #ifndef lint
static char rcsid[] = "@(#$Id: rclmain_w.cpp,v 1.33 2007-07-20 10:55:05 dockes Exp $ (C) 2005 J.F.Dockes"; static char rcsid[] = "@(#$Id: rclmain_w.cpp,v 1.34 2007-07-20 11:38:18 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
@ -416,10 +416,10 @@ void RclMain::showExtIdxDialog()
// If a preview (toplevel) window gets closed by the user, we need to // If a preview (toplevel) window gets closed by the user, we need to
// clean up because there is no way to reopen it. And check the case // clean up because there is no way to reopen it. And check the case
// where the current one is closed // where the current one is closed
void RclMain::previewClosed(QWidget *w) void RclMain::previewClosed(Preview *w)
{ {
LOGDEB(("RclMain::previewClosed(%p)\n", w)); LOGDEB(("RclMain::previewClosed(%p)\n", w));
if (w == (QWidget *)curPreview) { if (w == curPreview) {
LOGDEB(("Active preview closed\n")); LOGDEB(("Active preview closed\n"));
curPreview = 0; curPreview = 0;
} else { } else {
@ -468,16 +468,16 @@ void RclMain::startPreview(int docnum, int mod)
QMessageBox::NoButton); QMessageBox::NoButton);
return; return;
} }
connect(curPreview, SIGNAL(previewClosed(QWidget *)), connect(curPreview, SIGNAL(previewClosed(Preview *)),
this, SLOT(previewClosed(QWidget *))); this, SLOT(previewClosed(Preview *)));
connect(curPreview, SIGNAL(wordSelect(QString)), connect(curPreview, SIGNAL(wordSelect(QString)),
this, SLOT(ssearchAddTerm(QString))); this, SLOT(ssearchAddTerm(QString)));
connect(curPreview, SIGNAL(showNext(int, int)), connect(curPreview, SIGNAL(showNext(Preview *, int, int)),
this, SLOT(previewNextInTab(int, int))); this, SLOT(previewNextInTab(Preview *, int, int)));
connect(curPreview, SIGNAL(showPrev(int, int)), connect(curPreview, SIGNAL(showPrev(Preview *, int, int)),
this, SLOT(previewPrevInTab(int, int))); this, SLOT(previewPrevInTab(Preview *, int, int)));
connect(curPreview, SIGNAL(previewExposed(int, int)), connect(curPreview, SIGNAL(previewExposed(Preview *, int, int)),
this, SLOT(previewExposed(int, int))); this, SLOT(previewExposed(Preview *, int, int)));
curPreview->setCaption(resList->getDescription()); curPreview->setCaption(resList->getDescription());
curPreview->show(); curPreview->show();
} }
@ -516,16 +516,12 @@ void RclMain::startPreview(Rcl::Doc doc)
} }
// Show next document from result list in current preview tab // Show next document from result list in current preview tab
void RclMain::previewNextInTab(int sid, int docnum) void RclMain::previewNextInTab(Preview * w, 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 if (w == 0) // ??
// 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; return;
if (sid != m_searchId) { if (sid != m_searchId) {
@ -544,7 +540,7 @@ void RclMain::previewNextInTab(int sid, int docnum)
if (!resList->getDoc(docnum, doc)) { if (!resList->getDoc(docnum, doc)) {
QMessageBox::warning(0, "Recoll", QMessageBox::warning(0, "Recoll",
tr("Cannot retrieve document info" tr("Cannot retrieve document info"
" from database")); " from database"));
return; return;
} }
@ -557,20 +553,16 @@ void RclMain::previewNextInTab(int sid, int docnum)
return; return;
} }
curPreview->makeDocCurrent(fn, st.st_size, doc, docnum, true); w->makeDocCurrent(fn, st.st_size, doc, docnum, true);
} }
// Show previous document from result list in current preview tab // Show previous document from result list in preview tab
void RclMain::previewPrevInTab(int sid, int docnum) void RclMain::previewPrevInTab(Preview *w, 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 if (w == 0) // ??
// 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; return;
if (sid != m_searchId) { if (sid != m_searchId) {
@ -599,11 +591,11 @@ void RclMain::previewPrevInTab(int sid, int docnum)
fn.c_str()); fn.c_str());
return; return;
} }
curPreview->makeDocCurrent(fn, st.st_size, doc, docnum, true); w->makeDocCurrent(fn, st.st_size, doc, docnum, true);
} }
// Preview tab exposed: possibly tell reslist (to color the paragraph) // Preview tab exposed: possibly tell reslist (to color the paragraph)
void RclMain::previewExposed(int sid, int docnum) void RclMain::previewExposed(Preview *, int sid, int docnum)
{ {
LOGDEB2(("RclMain::previewExposed: sid %d docnum %d, m_sid %d\n", LOGDEB2(("RclMain::previewExposed: sid %d docnum %d, m_sid %d\n",
sid, docnum, m_searchId)); sid, docnum, m_searchId));

View File

@ -53,6 +53,8 @@ public: DummyRclMainBase(QWidget *parent) :Q3MainWindow(parent){setupUi(this);}
#endif #endif
//MOC_SKIP_END //MOC_SKIP_END
class Preview;
class RclMain : public DummyRclMainBase class RclMain : public DummyRclMainBase
{ {
Q_OBJECT Q_OBJECT
@ -73,7 +75,7 @@ public slots:
virtual void startIndexing(); virtual void startIndexing();
virtual void startSearch(RefCntr<Rcl::SearchData> sdata); virtual void startSearch(RefCntr<Rcl::SearchData> sdata);
virtual void setDocSequence(); virtual void setDocSequence();
virtual void previewClosed(QWidget * w); virtual void previewClosed(Preview *w);
virtual void showAdvSearchDialog(); virtual void showAdvSearchDialog();
virtual void showSortDialog(); virtual void showSortDialog();
virtual void showSpellDialog(); virtual void showSpellDialog();
@ -92,9 +94,9 @@ public slots:
virtual void startPreview(Rcl::Doc doc); virtual void startPreview(Rcl::Doc doc);
virtual void startNativeViewer(int docnum); virtual void startNativeViewer(int docnum);
virtual void startNativeViewer(Rcl::Doc doc); virtual void startNativeViewer(Rcl::Doc doc);
virtual void previewNextInTab(int sid, int docnum); virtual void previewNextInTab(Preview *, int sid, int docnum);
virtual void previewPrevInTab(int sid, int docnum); virtual void previewPrevInTab(Preview *, int sid, int docnum);
virtual void previewExposed(int sid, int docnum); virtual void previewExposed(Preview *, int sid, int docnum);
virtual void resetSearch(); virtual void resetSearch();
virtual void eraseDocHistory(); virtual void eraseDocHistory();
protected: protected: