make shift-arrow in preview work with qt4 and avoid reentrancy while loading a file

This commit is contained in:
dockes 2007-02-19 18:15:14 +00:00
parent 5d1931610f
commit 686b891f21
2 changed files with 21 additions and 3 deletions

View File

@ -1,5 +1,5 @@
#ifndef lint
static char rcsid[] = "@(#$Id: preview_w.cpp,v 1.16 2007-02-08 17:05:12 dockes Exp $ (C) 2005 J.F.Dockes";
static char rcsid[] = "@(#$Id: preview_w.cpp,v 1.17 2007-02-19 18:15:14 dockes Exp $ (C) 2005 J.F.Dockes";
#endif
/*
* This program is free software; you can redistribute it and/or modify
@ -89,6 +89,7 @@ void Preview::init()
connect(bt, SIGNAL(clicked()), this, SLOT(closeCurrentTab()));
searchTextLine->installEventFilter(this);
pvEdit->installEventFilter(this);
dynSearchActive = false;
canBeep = true;
tabData.push_back(TabData(pvTab->currentPage()));
@ -96,6 +97,7 @@ void Preview::init()
if (prefs.pvwidth > 100) {
resize(prefs.pvwidth, prefs.pvheight);
}
m_loading = false;
}
void Preview::destroy()
@ -116,7 +118,7 @@ bool Preview::eventFilter(QObject *target, QEvent *event)
if (event->type() != QEvent::KeyPress)
return QWidget::eventFilter(target, event);
LOGDEB1(("Preview::eventFilter: keyEvent\n"));
LOGDEB(("Preview::eventFilter: keyEvent\n"));
QKeyEvent *keyEvent = (QKeyEvent *)event;
if (keyEvent->key() == Qt::Key_Q &&
(keyEvent->state() & Qt::ControlButton)) {
@ -311,6 +313,8 @@ void Preview::textDoubleClicked(int, int)
void Preview::closeCurrentTab()
{
if (m_loading)
return;
if (pvTab->count() > 1) {
QWidget *tw = pvTab->currentPage();
if (!tw)
@ -534,10 +538,23 @@ class WaiterThread : public QThread {
#ifndef MIN
#define MIN(A,B) ((A)<(B)?(A):(B))
#endif
class LoadGuard {
bool *m_bp;
public:
LoadGuard(bool *bp) {m_bp = bp ; *m_bp = true;}
~LoadGuard() {*m_bp = false;}
};
bool Preview::loadFileInCurrentTab(string fn, size_t sz, const Rcl::Doc &idoc,
int docnum)
{
if (m_loading) {
LOGERR(("ALready loading\n"));
return false;
}
LoadGuard guard(&m_loading);
Rcl::Doc doc = idoc;
bool cancel = false;

View File

@ -1,6 +1,6 @@
#ifndef _PREVIEW_W_H_INCLUDED_
#define _PREVIEW_W_H_INCLUDED_
/* @(#$Id: preview_w.h,v 1.8 2007-01-19 15:22:50 dockes Exp $ (C) 2006 J.F.Dockes */
/* @(#$Id: preview_w.h,v 1.9 2007-02-19 18:15:14 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
@ -109,6 +109,7 @@ private:
int matchPara;
bool dynSearchActive;
bool canBeep;
bool m_loading;
list<TabData> tabData;
QWidget *currentW;
HiliteData m_hData;