synchronize preview tab and colored paragraph in result list

This commit is contained in:
dockes 2006-09-21 12:56:57 +00:00
parent 34341eae24
commit 739fc085b3
6 changed files with 53 additions and 15 deletions

View File

@ -1,5 +1,5 @@
#ifndef lint
static char rcsid[] = "@(#$Id: preview_w.cpp,v 1.2 2006-09-12 10:11:36 dockes Exp $ (C) 2005 J.F.Dockes";
static char rcsid[] = "@(#$Id: preview_w.cpp,v 1.3 2006-09-21 12:56:57 dockes Exp $ (C) 2005 J.F.Dockes";
#endif
/*
* This program is free software; you can redistribute it and/or modify
@ -79,6 +79,7 @@ void Preview::destroy()
void Preview::closeEvent(QCloseEvent *e)
{
emit previewExposed(m_searchId, -1);
emit previewClosed((QWidget *)this);
QWidget::closeEvent(e);
}
@ -251,6 +252,9 @@ void Preview::currentChanged(QWidget * tw)
edit->setFocus();
connect(edit, SIGNAL(doubleClicked(int, int)),
this, SLOT(textDoubleClicked(int, int)));
TabData *d = tabDataForCurrent();
if (d)
emit(previewExposed(m_searchId, d->docnum));
}
}
@ -619,6 +623,7 @@ bool Preview::loadFileInCurrentTab(string fn, size_t sz, const Rcl::Doc &idoc,
matchCheck->setChecked(wasC);
}
}
emit(previewExposed(m_searchId, docnum));
return true;
}

View File

@ -1,6 +1,6 @@
#ifndef _PREVIEW_W_H_INCLUDED_
#define _PREVIEW_W_H_INCLUDED_
/* @(#$Id: preview_w.h,v 1.2 2006-09-12 10:11:36 dockes Exp $ (C) 2006 J.F.Dockes */
/* @(#$Id: preview_w.h,v 1.3 2006-09-21 12:56:57 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
@ -70,6 +70,7 @@ signals:
void wordSelect(QString);
void showNext(int sid, int docnum);
void showPrev(int sid, int docnum);
void previewExposed(int sid, int docnum);
protected:
int m_searchId; // Identifier of search in main window. This is so that

View File

@ -1,5 +1,5 @@
#ifndef lint
static char rcsid[] = "@(#$Id: rclmain.cpp,v 1.33 2006-09-21 09:37:28 dockes Exp $ (C) 2005 J.F.Dockes";
static char rcsid[] = "@(#$Id: rclmain.cpp,v 1.34 2006-09-21 12:56:57 dockes Exp $ (C) 2005 J.F.Dockes";
#endif
/*
* This program is free software; you can redistribute it and/or modify
@ -452,6 +452,8 @@ void RclMain::startPreview(int docnum)
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)));
curPreview->show();
} else {
if (curPreview->makeDocCurrent(fn, doc)) {
@ -541,6 +543,18 @@ void RclMain::previewPrevInTab(int sid, int docnum)
curPreview->closeCurrentTab();
}
// Preview tab exposed: possibly tell reslist (to color the paragraph)
void RclMain::previewExposed(int sid, int docnum)
{
LOGDEB2(("RclMain::previewExposed: sid %d docnum %d, m_sid %d\n",
sid, docnum, m_searchId));
if (sid != m_searchId) {
return;
}
resList->previewExposed(docnum);
}
// Add term to simple search. Term comes out of double-click in
// reslist or preview. The cleanup code is really horrible. Selection
// out of the reslist will typically look like

View File

@ -66,6 +66,7 @@ public slots:
virtual void startNativeViewer(int docnum);
virtual void previewNextInTab(int sid, int docnum);
virtual void previewPrevInTab(int sid, int docnum);
virtual void previewExposed(int sid, int docnum);
private:
Preview *curPreview;

View File

@ -1,5 +1,5 @@
#ifndef lint
static char rcsid[] = "@(#$Id: rclreslist.cpp,v 1.19 2006-09-13 14:57:56 dockes Exp $ (C) 2005 J.F.Dockes";
static char rcsid[] = "@(#$Id: rclreslist.cpp,v 1.20 2006-09-21 12:56:57 dockes Exp $ (C) 2005 J.F.Dockes";
#endif
#include <time.h>
@ -52,6 +52,7 @@ RclResList::RclResList(QWidget* parent, const char* name)
this, SLOT(doubleClicked(int, int)));
m_winfirst = -1;
m_docsource = 0;
m_curPvDoc = -1;
}
@ -454,24 +455,36 @@ void RclResList::resultPageNext()
m_winfirst = -1;
hasNext = false;
}
// Possibly color paragraph of current preview if any
previewExposed(m_curPvDoc);
emit nextPageAvailable(hasNext);
}
// Single click in result list: color active paragraph
void RclResList::clicked(int par, int car)
// Single click in result list:
void RclResList::clicked(int, int)
{
LOGDEB(("RclResList::clicked:wfirst %d par %d char %d\n",
m_winfirst, par, car));
// Erase everything back to white
{
}
// Color paragraph (if any) of currently visible preview
void RclResList::previewExposed(int docnum)
{
LOGDEB(("RclResList::previewExposed: doc %d\n", docnum));
// Possibly erase old one to white
int par;
if (m_curPvDoc != -1 && (par = parnumfromdocnum(m_curPvDoc)) != -1) {
QColor color("white");
for (int i = 0; i < paragraphs(); i++)
setParagraphBackgroundColor(i, color);
setParagraphBackgroundColor(par, color);
m_curPvDoc = -1;
}
m_curPvDoc = docnum;
par = parnumfromdocnum(docnum);
// Maybe docnum is -1 or not in this window,
if (par < 0)
return;
// Color the new active paragraph
QColor color("lightblue");
QColor color("LightBlue");
setParagraphBackgroundColor(par, color);
}

View File

@ -1,6 +1,6 @@
#ifndef _RCLRESLIST_H_INCLUDED_
#define _RCLRESLIST_H_INCLUDED_
/* @(#$Id: rclreslist.h,v 1.9 2006-09-12 10:11:36 dockes Exp $ (C) 2005 J.F.Dockes */
/* @(#$Id: rclreslist.h,v 1.10 2006-09-21 12:56:57 dockes Exp $ (C) 2005 J.F.Dockes */
#include <qtextbrowser.h>
#include <qpopupmenu.h>
@ -41,6 +41,7 @@ class RclResList : public QTextBrowser
virtual void menuCopyFN();
virtual void menuCopyURL();
virtual void menuExpand();
virtual void previewExposed(int);
signals:
void nextPageAvailable(bool);
@ -66,9 +67,12 @@ class RclResList : public QTextBrowser
std::vector<Rcl::Doc> m_curDocs;
int m_winfirst;
int m_docnum; // Docnum matching the currently active para
int m_curPvDoc;// Docnum for current preview
virtual int docnumfromparnum(int);
virtual int parnumfromdocnum(int);
// Don't know why this is necessary but it is
void emitLinkClicked(const QString &s) {
emit linkClicked(s);
};