suppressed a number of gratuitous unistd inclusions + clean up preview progress dialog code
This commit is contained in:
parent
0cc5bb82d5
commit
f000aaa792
6 changed files with 471 additions and 489 deletions
|
@ -14,7 +14,6 @@
|
|||
* Free Software Foundation, Inc.,
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#include <unistd.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdio>
|
||||
|
|
|
@ -14,11 +14,8 @@
|
|||
* Free Software Foundation, Inc.,
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
|
||||
#include "autoconfig.h"
|
||||
|
||||
#include <unistd.h>
|
||||
#include <cstdlib>
|
||||
|
||||
#include <qapplication.h>
|
||||
|
|
|
@ -16,8 +16,6 @@
|
|||
*/
|
||||
#include "autoconfig.h"
|
||||
|
||||
#include "safeunistd.h"
|
||||
|
||||
#include <list>
|
||||
#include <utility>
|
||||
|
||||
|
@ -45,6 +43,7 @@
|
|||
#include <qimage.h>
|
||||
#include <qurl.h>
|
||||
#include <QShortcut>
|
||||
#include <QTimer>
|
||||
|
||||
#include "debuglog.h"
|
||||
#include "pathut.h"
|
||||
|
@ -70,8 +69,7 @@ class PlainToRichQtPreview : public PlainToRich {
|
|||
public:
|
||||
|
||||
PlainToRichQtPreview()
|
||||
: m_curanchor(1), m_lastanchor(0)
|
||||
{
|
||||
: m_curanchor(1), m_lastanchor(0) {
|
||||
}
|
||||
void clear() {
|
||||
m_curanchor = 1;
|
||||
|
@ -80,13 +78,11 @@ public:
|
|||
m_groupcuranchors.clear();
|
||||
}
|
||||
|
||||
bool haveAnchors()
|
||||
{
|
||||
bool haveAnchors() {
|
||||
return m_lastanchor != 0;
|
||||
}
|
||||
|
||||
virtual string header()
|
||||
{
|
||||
virtual string header() {
|
||||
if (!m_inputhtml) {
|
||||
switch (prefs.previewPlainPre) {
|
||||
case PrefsPack::PP_BR:
|
||||
|
@ -104,8 +100,7 @@ public:
|
|||
return cstr_null;
|
||||
}
|
||||
|
||||
virtual string startMatch(unsigned int grpidx)
|
||||
{
|
||||
virtual string startMatch(unsigned int grpidx) {
|
||||
LOGDEB2(("startMatch, grpidx %u\n", grpidx));
|
||||
grpidx = m_hdata->grpsugidx[grpidx];
|
||||
LOGDEB2(("startMatch, ugrpidx %u\n", grpidx));
|
||||
|
@ -120,26 +115,22 @@ public:
|
|||
append("\">");
|
||||
}
|
||||
|
||||
virtual string endMatch()
|
||||
{
|
||||
virtual string endMatch() {
|
||||
return string("</a></span>");
|
||||
}
|
||||
|
||||
virtual string termAnchorName(int i) const
|
||||
{
|
||||
virtual string termAnchorName(int i) const {
|
||||
static const char *termAnchorNameBase = "TRM";
|
||||
char acname[sizeof(termAnchorNameBase) + 20];
|
||||
sprintf(acname, "%s%d", termAnchorNameBase, i);
|
||||
return string(acname);
|
||||
}
|
||||
|
||||
virtual string startChunk()
|
||||
{
|
||||
virtual string startChunk() {
|
||||
return "<pre>";
|
||||
}
|
||||
|
||||
int nextAnchorNum(int grpidx)
|
||||
{
|
||||
int nextAnchorNum(int grpidx) {
|
||||
LOGDEB2(("nextAnchorNum: group %d\n", grpidx));
|
||||
map<unsigned int, unsigned int>::iterator curit =
|
||||
m_groupcuranchors.find(grpidx);
|
||||
|
@ -162,8 +153,7 @@ public:
|
|||
return m_curanchor;
|
||||
}
|
||||
|
||||
int prevAnchorNum(int grpidx)
|
||||
{
|
||||
int prevAnchorNum(int grpidx) {
|
||||
map<unsigned int, unsigned int>::iterator curit =
|
||||
m_groupcuranchors.find(grpidx);
|
||||
map<unsigned int, vector<int> >::iterator vecit =
|
||||
|
@ -184,8 +174,7 @@ public:
|
|||
return m_curanchor;
|
||||
}
|
||||
|
||||
QString curAnchorName() const
|
||||
{
|
||||
QString curAnchorName() const {
|
||||
return QString::fromUtf8(termAnchorName(m_curanchor).c_str());
|
||||
}
|
||||
|
||||
|
@ -742,7 +731,6 @@ class LoadThread : public QThread {
|
|||
}
|
||||
virtual void run() {
|
||||
DebugLog::getdbl()->setloglevel(loglevel);
|
||||
|
||||
FileInterner interner(idoc, theconfig, FileInterner::FIF_forPreview);
|
||||
FIMissingStore mst;
|
||||
interner.setMissingStore(&mst);
|
||||
|
@ -829,10 +817,12 @@ bool Preview::loadDocInCurrentTab(const Rcl::Doc &idoc, int docnum)
|
|||
.arg(QString::fromLocal8Bit(idoc.url.c_str()))
|
||||
.arg(QString::fromUtf8(idoc.fbytes.c_str()));
|
||||
|
||||
// Create progress dialog and aux objects
|
||||
const int nsteps = 20;
|
||||
QProgressDialog progress(msg, tr("Cancel"), 0, nsteps, this);
|
||||
QProgressDialog progress(msg, tr("Cancel"), 0, 0, this);
|
||||
progress.setMinimumDuration(2000);
|
||||
QEventLoop loop;
|
||||
QTimer tT;
|
||||
tT.setSingleShot(true);
|
||||
connect(&tT, SIGNAL(timeout()), &loop, SLOT(quit()));
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Load and convert document
|
||||
|
@ -841,18 +831,19 @@ bool Preview::loadDocInCurrentTab(const Rcl::Doc &idoc, int docnum)
|
|||
Rcl::Doc fdoc;
|
||||
int status = 1;
|
||||
LoadThread lthr(&status, fdoc, idoc);
|
||||
connect(<hr, SIGNAL(finished()), &loop, SLOT(quit()));
|
||||
|
||||
lthr.start();
|
||||
int prog;
|
||||
for (prog = 1;;prog++) {
|
||||
if (lthr.wait(100))
|
||||
for (int i = 0;;i++) {
|
||||
tT.start(1000);
|
||||
loop.exec();
|
||||
if (lthr.isFinished())
|
||||
break;
|
||||
progress.setValue(prog);
|
||||
qApp->processEvents();
|
||||
if (progress.wasCanceled()) {
|
||||
CancelCheck::instance().setCancel();
|
||||
}
|
||||
if (prog >= 5)
|
||||
sleep(1);
|
||||
if (i == 2)
|
||||
progress.show();
|
||||
}
|
||||
|
||||
LOGDEB(("loadDocInCurrentTab: after file load: cancel %d status %d"
|
||||
|
@ -862,6 +853,7 @@ bool Preview::loadDocInCurrentTab(const Rcl::Doc &idoc, int docnum)
|
|||
if (CancelCheck::instance().cancelState())
|
||||
return false;
|
||||
if (status != 0) {
|
||||
progress.close();
|
||||
QString explain;
|
||||
if (!lthr.missing.empty()) {
|
||||
explain = QString::fromUtf8("<br>") +
|
||||
|
@ -940,18 +932,17 @@ bool Preview::loadDocInCurrentTab(const Rcl::Doc &idoc, int docnum)
|
|||
}
|
||||
list<string> richlst;
|
||||
ToRichThread rthr(fdoc.text, m_hData, richlst, editor->m_plaintorich);
|
||||
connect(&rthr, SIGNAL(finished()), &loop, SLOT(quit()));
|
||||
rthr.start();
|
||||
|
||||
for (;;prog++) {
|
||||
if (rthr.wait(100))
|
||||
for (;;) {
|
||||
tT.start(1000);
|
||||
loop.exec();
|
||||
if (rthr.isFinished())
|
||||
break;
|
||||
progress.setValue(nsteps);
|
||||
qApp->processEvents();
|
||||
if (progress.wasCanceled()) {
|
||||
CancelCheck::instance().setCancel();
|
||||
}
|
||||
if (prog >= 5)
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
// Conversion to rich text done
|
||||
|
@ -995,16 +986,12 @@ bool Preview::loadDocInCurrentTab(const Rcl::Doc &idoc, int docnum)
|
|||
#endif
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// Load text into editor window.
|
||||
prog = 2 * nsteps / 3;
|
||||
progress.setLabelText(tr("Loading preview text into editor"));
|
||||
qApp->processEvents();
|
||||
int instep = 0;
|
||||
for (list<QString>::iterator it = qrichlst.begin();
|
||||
it != qrichlst.end(); it++, prog++, instep++) {
|
||||
progress.setValue(prog);
|
||||
it != qrichlst.end(); it++) {
|
||||
qApp->processEvents();
|
||||
|
||||
editor->append(*it);
|
||||
|
|
|
@ -16,9 +16,6 @@
|
|||
*/
|
||||
#include "autoconfig.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
#include "safeunistd.h"
|
||||
|
||||
#include <utility>
|
||||
#include MEMORY_INCLUDE
|
||||
|
||||
|
@ -138,10 +135,14 @@ void RclMain::init()
|
|||
|
||||
// idxstatus file. Make sure it exists before trying to watch it
|
||||
// (case where we're started on an older index, or if the status
|
||||
// file was deleted since indexing
|
||||
::close(::open(theconfig->getIdxStatusFile().c_str(), O_CREAT, 0600));
|
||||
m_watcher.addPath(QString::fromLocal8Bit(
|
||||
theconfig->getIdxStatusFile().c_str()));
|
||||
// file was deleted since indexing)
|
||||
QString idxfn =
|
||||
QString::fromLocal8Bit(theconfig->getIdxStatusFile().c_str());
|
||||
QFile qf(idxfn);
|
||||
qf.open(QIODevice::ReadWrite);
|
||||
qf.setPermissions(QFile::ReadOwner|QFile::WriteOwner);
|
||||
qf.close();
|
||||
m_watcher.addPath(idxfn);
|
||||
// At least some versions of qt4 don't display the status bar if
|
||||
// it's not created here.
|
||||
(void)statusBar();
|
||||
|
@ -728,7 +729,7 @@ void RclMain::initiateQuery()
|
|||
qApp->processEvents();
|
||||
if (progress.wasCanceled()) {
|
||||
// Just get out of there asap.
|
||||
_exit(1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
qApp->processEvents();
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
*/
|
||||
#include "autoconfig.h"
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <string>
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
#include "autoconfig.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <list>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue