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
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
/*
* 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.pvheight = height();
emit previewExposed(m_searchId, -1);
emit previewClosed((QWidget *)this);
emit previewExposed(this, m_searchId, -1);
emit previewClosed(this);
QWidget::closeEvent(e);
}
@ -135,14 +135,14 @@ bool Preview::eventFilter(QObject *target, QEvent *event)
// LOGDEB(("Preview::eventFilter: got Shift-Up\n"));
TabData *d = tabDataForCurrent();
if (d)
emit(showNext(m_searchId, d->docnum));
emit(showNext(this, m_searchId, d->docnum));
return true;
} else if (keyEvent->key() == Qt::Key_Up &&
(keyEvent->state() & Qt::ShiftButton)) {
// LOGDEB(("Preview::eventFilter: got Shift-Down\n"));
TabData *d = tabDataForCurrent();
if (d)
emit(showPrev(m_searchId, d->docnum));
emit(showPrev(this, m_searchId, d->docnum));
return true;
} else if (keyEvent->key() == Qt::Key_W &&
(keyEvent->state() & Qt::ControlButton)) {
@ -319,7 +319,7 @@ void Preview::currentChanged(QWidget * tw)
edit->installEventFilter(this);
TabData *d = tabDataForCurrent();
if (d)
emit(previewExposed(m_searchId, d->docnum));
emit(previewExposed(this, m_searchId, d->docnum));
}
#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);
editor->setFocus();
emit(previewExposed(m_searchId, docnum));
emit(previewExposed(this, m_searchId, docnum));
LOGDEB(("LoadFileInCurrentTab: returning true\n"));
return true;
}

View File

@ -1,6 +1,6 @@
#ifndef _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
* it under the terms of the GNU General Public License as published by
@ -94,11 +94,11 @@ public slots:
virtual void selecChanged();
signals:
void previewClosed(QWidget *);
void previewClosed(Preview *);
void wordSelect(QString);
void showNext(int sid, int docnum);
void showPrev(int sid, int docnum);
void previewExposed(int sid, int docnum);
void showNext(Preview *w, int sid, int docnum);
void showPrev(Preview *w, int sid, int docnum);
void previewExposed(Preview *w, int sid, int docnum);
private:
// Identifier of search in main window. This is used to check that

View File

@ -1,5 +1,5 @@
#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
/*
* 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
// clean up because there is no way to reopen it. And check the case
// where the current one is closed
void RclMain::previewClosed(QWidget *w)
void RclMain::previewClosed(Preview *w)
{
LOGDEB(("RclMain::previewClosed(%p)\n", w));
if (w == (QWidget *)curPreview) {
if (w == curPreview) {
LOGDEB(("Active preview closed\n"));
curPreview = 0;
} else {
@ -468,16 +468,16 @@ void RclMain::startPreview(int docnum, int mod)
QMessageBox::NoButton);
return;
}
connect(curPreview, SIGNAL(previewClosed(QWidget *)),
this, SLOT(previewClosed(QWidget *)));
connect(curPreview, SIGNAL(previewClosed(Preview *)),
this, SLOT(previewClosed(Preview *)));
connect(curPreview, SIGNAL(wordSelect(QString)),
this, SLOT(ssearchAddTerm(QString)));
connect(curPreview, SIGNAL(showNext(int, int)),
this, SLOT(previewNextInTab(int, int)));
connect(curPreview, SIGNAL(showPrev(int, int)),
this, SLOT(previewPrevInTab(int, int)));
connect(curPreview, SIGNAL(previewExposed(int, int)),
this, SLOT(previewExposed(int, int)));
connect(curPreview, SIGNAL(showNext(Preview *, int, int)),
this, SLOT(previewNextInTab(Preview *, int, int)));
connect(curPreview, SIGNAL(showPrev(Preview *, int, int)),
this, SLOT(previewPrevInTab(Preview *, int, int)));
connect(curPreview, SIGNAL(previewExposed(Preview *, int, int)),
this, SLOT(previewExposed(Preview *, int, int)));
curPreview->setCaption(resList->getDescription());
curPreview->show();
}
@ -516,16 +516,12 @@ void RclMain::startPreview(Rcl::Doc doc)
}
// 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",
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)
if (w == 0) // ??
return;
if (sid != m_searchId) {
@ -544,7 +540,7 @@ void RclMain::previewNextInTab(int sid, int docnum)
if (!resList->getDoc(docnum, doc)) {
QMessageBox::warning(0, "Recoll",
tr("Cannot retrieve document info"
" from database"));
" from database"));
return;
}
@ -557,20 +553,16 @@ void RclMain::previewNextInTab(int sid, int docnum)
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
void RclMain::previewPrevInTab(int sid, int docnum)
// Show previous document from result list in preview tab
void RclMain::previewPrevInTab(Preview *w, int sid, int docnum)
{
LOGDEB(("RclMain::previewPrevInTab sid %d docnum %d, m_sid %d\n",
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)
if (w == 0) // ??
return;
if (sid != m_searchId) {
@ -599,11 +591,11 @@ void RclMain::previewPrevInTab(int sid, int docnum)
fn.c_str());
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)
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",
sid, docnum, m_searchId));

View File

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