2009-02-05 14:21:47 +00:00
|
|
|
/* This file is (c) 2008-2009 Konstantin Isakov <ikm@users.berlios.de>
|
2009-01-28 20:55:45 +00:00
|
|
|
* Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */
|
|
|
|
|
|
|
|
#include "articleview.hh"
|
|
|
|
#include "externalviewer.hh"
|
|
|
|
#include <QMessageBox>
|
|
|
|
#include <QWebHitTestResult>
|
|
|
|
#include <QMenu>
|
2009-02-01 00:08:08 +00:00
|
|
|
#include <QDesktopServices>
|
2009-01-28 20:55:45 +00:00
|
|
|
|
2009-02-06 15:37:37 +00:00
|
|
|
#ifdef Q_OS_WIN32
|
|
|
|
#include <windows.h>
|
|
|
|
#include <mmsystem.h> // For PlaySound
|
|
|
|
#endif
|
2009-01-28 20:55:45 +00:00
|
|
|
|
2009-03-26 19:00:08 +00:00
|
|
|
using std::list;
|
|
|
|
|
2009-01-28 20:55:45 +00:00
|
|
|
ArticleView::ArticleView( QWidget * parent, ArticleNetworkAccessManager & nm,
|
|
|
|
Instances::Groups const & groups_, bool popupView_ ):
|
|
|
|
QFrame( parent ),
|
|
|
|
articleNetMgr( nm ),
|
|
|
|
groups( groups_ ),
|
|
|
|
popupView( popupView_ )
|
|
|
|
{
|
|
|
|
ui.setupUi( this );
|
|
|
|
|
2009-04-03 21:57:23 +00:00
|
|
|
ui.definition->pageAction( QWebPage::Copy )->setShortcut( QKeySequence::Copy );
|
|
|
|
ui.definition->addAction( ui.definition->pageAction( QWebPage::Copy ) );
|
|
|
|
|
2009-01-28 20:55:45 +00:00
|
|
|
ui.definition->setContextMenuPolicy( Qt::CustomContextMenu );
|
|
|
|
|
|
|
|
ui.definition->page()->setLinkDelegationPolicy( QWebPage::DelegateAllLinks );
|
|
|
|
|
|
|
|
ui.definition->page()->setNetworkAccessManager( &articleNetMgr );
|
|
|
|
|
2009-02-08 16:50:18 +00:00
|
|
|
connect( ui.definition, SIGNAL( loadFinished( bool ) ),
|
|
|
|
this, SLOT( loadFinished( bool ) ) );
|
|
|
|
|
2009-01-28 20:55:45 +00:00
|
|
|
connect( ui.definition, SIGNAL( titleChanged( QString const & ) ),
|
|
|
|
this, SLOT( handleTitleChanged( QString const & ) ) );
|
|
|
|
|
|
|
|
connect( ui.definition, SIGNAL( urlChanged( QUrl const & ) ),
|
|
|
|
this, SLOT( handleUrlChanged( QUrl const & ) ) );
|
|
|
|
|
|
|
|
connect( ui.definition, SIGNAL( customContextMenuRequested( QPoint const & ) ),
|
|
|
|
this, SLOT( contextMenuRequested( QPoint const & ) ) );
|
|
|
|
|
|
|
|
connect( ui.definition, SIGNAL( linkClicked( QUrl const & ) ),
|
|
|
|
this, SLOT( linkClicked( QUrl const & ) ) );
|
|
|
|
}
|
|
|
|
|
2009-02-06 15:37:37 +00:00
|
|
|
ArticleView::~ArticleView()
|
|
|
|
{
|
2009-02-08 21:54:19 +00:00
|
|
|
cleanupTemp();
|
|
|
|
|
2009-02-06 15:37:37 +00:00
|
|
|
#ifdef Q_OS_WIN32
|
|
|
|
if ( winWavData.size() )
|
|
|
|
{
|
|
|
|
// If we were playing some sound some time ago, make sure it stopped
|
|
|
|
// playing before freeing the waveform memory.
|
|
|
|
PlaySoundA( 0, 0, 0 );
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2009-01-28 20:55:45 +00:00
|
|
|
void ArticleView::showDefinition( QString const & word, QString const & group )
|
|
|
|
{
|
|
|
|
QUrl req;
|
|
|
|
|
|
|
|
req.setScheme( "gdlookup" );
|
|
|
|
req.setHost( "localhost" );
|
|
|
|
req.addQueryItem( "word", word );
|
|
|
|
req.addQueryItem( "group", group );
|
|
|
|
|
2009-03-26 19:00:08 +00:00
|
|
|
ui.definition->setUrl( req );
|
|
|
|
//QApplication::setOverrideCursor( Qt::WaitCursor );
|
|
|
|
ui.definition->setCursor( Qt::WaitCursor );
|
2009-01-28 20:55:45 +00:00
|
|
|
}
|
|
|
|
|
2009-02-01 00:08:08 +00:00
|
|
|
void ArticleView::showNotFound( QString const & word, QString const & group )
|
|
|
|
{
|
|
|
|
QUrl req;
|
|
|
|
|
|
|
|
req.setScheme( "gdlookup" );
|
|
|
|
req.setHost( "localhost" );
|
|
|
|
req.addQueryItem( "word", word );
|
|
|
|
req.addQueryItem( "group", group );
|
|
|
|
req.addQueryItem( "notfound", "1" );
|
|
|
|
|
2009-03-26 19:00:08 +00:00
|
|
|
ui.definition->setUrl( req );
|
2009-02-01 00:08:08 +00:00
|
|
|
}
|
|
|
|
|
2009-02-08 16:50:18 +00:00
|
|
|
void ArticleView::showAnticipation()
|
|
|
|
{
|
|
|
|
ui.definition->setHtml( "" );
|
2009-03-26 19:00:08 +00:00
|
|
|
ui.definition->setCursor( Qt::WaitCursor );
|
|
|
|
//QApplication::setOverrideCursor( Qt::WaitCursor );
|
2009-02-08 16:50:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ArticleView::loadFinished( bool )
|
|
|
|
{
|
2009-03-26 19:00:08 +00:00
|
|
|
ui.definition->unsetCursor();
|
|
|
|
//QApplication::restoreOverrideCursor();
|
2009-02-08 16:50:18 +00:00
|
|
|
}
|
|
|
|
|
2009-01-28 20:55:45 +00:00
|
|
|
void ArticleView::handleTitleChanged( QString const & title )
|
|
|
|
{
|
|
|
|
emit titleChanged( this, title );
|
|
|
|
}
|
|
|
|
|
|
|
|
void ArticleView::handleUrlChanged( QUrl const & url )
|
|
|
|
{
|
|
|
|
QIcon icon;
|
|
|
|
|
|
|
|
QString group = getGroup( url );
|
|
|
|
|
|
|
|
if ( group.size() )
|
|
|
|
{
|
|
|
|
// Find the group's instance corresponding to the fragment value
|
|
|
|
for( unsigned x = 0; x < groups.size(); ++x )
|
|
|
|
if ( groups[ x ].name == group )
|
|
|
|
{
|
|
|
|
// Found it
|
|
|
|
|
|
|
|
if ( groups[ x ].icon.size() )
|
|
|
|
icon = QIcon( ":/flags/" + groups[ x ].icon );
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
emit iconChanged( this, icon );
|
|
|
|
}
|
|
|
|
|
|
|
|
QString ArticleView::getGroup( QUrl const & url )
|
|
|
|
{
|
|
|
|
if ( url.scheme() == "gdlookup" && url.hasQueryItem( "group" ) )
|
|
|
|
return url.queryItemValue( "group" );
|
|
|
|
|
|
|
|
return QString();
|
|
|
|
}
|
|
|
|
|
2009-02-08 21:54:19 +00:00
|
|
|
void ArticleView::cleanupTemp()
|
|
|
|
{
|
|
|
|
if ( desktopOpenedTempFile.size() )
|
|
|
|
{
|
|
|
|
QFile( desktopOpenedTempFile ).remove();
|
|
|
|
desktopOpenedTempFile.clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-28 20:55:45 +00:00
|
|
|
|
|
|
|
void ArticleView::linkClicked( QUrl const & url )
|
2009-02-08 15:49:17 +00:00
|
|
|
{
|
|
|
|
openLink( url, ui.definition->url() );
|
|
|
|
}
|
|
|
|
|
|
|
|
void ArticleView::openLink( QUrl const & url, QUrl const & ref )
|
2009-01-28 20:55:45 +00:00
|
|
|
{
|
|
|
|
printf( "clicked %s\n", url.toString().toLocal8Bit().data() );
|
|
|
|
|
|
|
|
if ( url.scheme() == "bword" )
|
|
|
|
showDefinition( url.host().startsWith( "xn--" ) ?
|
|
|
|
QUrl::fromPunycode( url.host().toLatin1() ) :
|
|
|
|
url.host(),
|
2009-02-08 15:49:17 +00:00
|
|
|
getGroup( ref ) );
|
2009-01-28 20:55:45 +00:00
|
|
|
else
|
|
|
|
if ( url.scheme() == "gdlookup" ) // Plain html links inherit gdlookup scheme
|
2009-03-26 19:00:08 +00:00
|
|
|
{
|
|
|
|
if ( url.hasFragment() )
|
|
|
|
{
|
|
|
|
ui.definition->page()->currentFrame()->evaluateJavaScript(
|
|
|
|
QString( "window.location = \"%1\"" ).arg( QString::fromUtf8( url.toEncoded() ) ) );
|
|
|
|
}
|
|
|
|
else
|
2009-01-28 20:55:45 +00:00
|
|
|
showDefinition( url.path().mid( 1 ),
|
2009-02-08 15:49:17 +00:00
|
|
|
getGroup( ref ) );
|
2009-03-26 19:00:08 +00:00
|
|
|
}
|
2009-01-28 20:55:45 +00:00
|
|
|
else
|
|
|
|
if ( url.scheme() == "bres" || url.scheme() == "gdau" )
|
|
|
|
{
|
2009-02-06 16:19:05 +00:00
|
|
|
// Download it
|
|
|
|
|
2009-03-26 19:00:08 +00:00
|
|
|
// Clear any pending ones
|
|
|
|
|
|
|
|
resourceDownloadRequests.clear();
|
2009-02-06 16:19:05 +00:00
|
|
|
|
2009-03-26 19:00:08 +00:00
|
|
|
resourceDownloadUrl = url;
|
2009-02-06 16:19:05 +00:00
|
|
|
|
|
|
|
if ( url.scheme() == "gdau" && url.host() == "search" && groups.size() )
|
|
|
|
{
|
|
|
|
// Since searches should be limited to current group, we just do them
|
|
|
|
// here ourselves since otherwise we'd need to pass group id to netmgr
|
|
|
|
// and it should've been having knowledge of the current groups, too.
|
|
|
|
|
2009-02-08 15:49:17 +00:00
|
|
|
QString currentGroup = getGroup( ref );
|
2009-02-06 16:19:05 +00:00
|
|
|
|
|
|
|
for( unsigned x = 0; x < groups.size(); ++x )
|
|
|
|
if ( groups[ x ].name == currentGroup )
|
|
|
|
{
|
|
|
|
for( unsigned y = 0; y < groups[ x ].dictionaries.size(); ++y )
|
|
|
|
{
|
2009-03-26 19:00:08 +00:00
|
|
|
sptr< Dictionary::DataRequest > req =
|
2009-02-06 16:19:05 +00:00
|
|
|
groups[ x ].dictionaries[ y ]->getResource(
|
2009-03-26 19:00:08 +00:00
|
|
|
url.path().mid( 1 ).toUtf8().data() );
|
|
|
|
|
|
|
|
if ( req->isFinished() && req->dataSize() >= 0 )
|
|
|
|
{
|
|
|
|
// A request was instantly finished with success.
|
|
|
|
// If we've managed to spawn some lingering requests alrady,
|
|
|
|
// erase them.
|
|
|
|
resourceDownloadRequests.clear();
|
|
|
|
|
|
|
|
// Handle the result
|
|
|
|
resourceDownloadRequests.push_back( req );
|
|
|
|
resourceDownloadFinished();
|
2009-02-06 16:19:05 +00:00
|
|
|
|
2009-03-26 19:00:08 +00:00
|
|
|
return;
|
2009-02-06 16:19:05 +00:00
|
|
|
}
|
2009-03-26 19:00:08 +00:00
|
|
|
else
|
|
|
|
if ( !req->isFinished() )
|
2009-02-06 16:19:05 +00:00
|
|
|
{
|
2009-03-26 19:00:08 +00:00
|
|
|
resourceDownloadRequests.push_back( req );
|
|
|
|
|
|
|
|
connect( req.get(), SIGNAL( finished() ),
|
|
|
|
this, SLOT( resourceDownloadFinished() ) );
|
2009-02-06 16:19:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-03-26 19:00:08 +00:00
|
|
|
else
|
2009-01-28 20:55:45 +00:00
|
|
|
{
|
2009-03-26 19:00:08 +00:00
|
|
|
// Normal resource download
|
|
|
|
QString contentType;
|
2009-02-08 14:40:26 +00:00
|
|
|
|
2009-03-26 19:00:08 +00:00
|
|
|
sptr< Dictionary::DataRequest > req =
|
|
|
|
articleNetMgr.getResource( url, contentType );
|
2009-01-28 20:55:45 +00:00
|
|
|
|
2009-03-26 19:00:08 +00:00
|
|
|
if ( req->isFinished() && req->dataSize() >= 0 )
|
2009-01-28 20:55:45 +00:00
|
|
|
{
|
2009-03-26 19:00:08 +00:00
|
|
|
// Have data ready, handle it
|
|
|
|
resourceDownloadRequests.push_back( req );
|
|
|
|
resourceDownloadFinished();
|
2009-02-08 14:40:26 +00:00
|
|
|
|
2009-03-26 19:00:08 +00:00
|
|
|
return;
|
2009-01-28 20:55:45 +00:00
|
|
|
}
|
2009-03-26 19:00:08 +00:00
|
|
|
else
|
|
|
|
if ( !req->isFinished() )
|
2009-01-28 20:55:45 +00:00
|
|
|
{
|
2009-03-26 19:00:08 +00:00
|
|
|
// Queue to be handled when done
|
2009-02-08 14:40:26 +00:00
|
|
|
|
2009-03-26 19:00:08 +00:00
|
|
|
resourceDownloadRequests.push_back( req );
|
|
|
|
|
|
|
|
connect( req.get(), SIGNAL( finished() ),
|
|
|
|
this, SLOT( resourceDownloadFinished() ) );
|
|
|
|
}
|
2009-01-28 20:55:45 +00:00
|
|
|
}
|
2009-02-08 14:40:26 +00:00
|
|
|
|
2009-03-26 19:00:08 +00:00
|
|
|
QString contentType;
|
2009-02-08 14:40:26 +00:00
|
|
|
|
2009-03-26 19:00:08 +00:00
|
|
|
if ( resourceDownloadRequests.empty() ) // No requests were queued
|
2009-01-28 20:55:45 +00:00
|
|
|
{
|
2009-03-26 19:00:08 +00:00
|
|
|
QMessageBox::critical( this, tr( "GoldenDict" ), tr( "The referenced resource doesn't exist." ) );
|
|
|
|
return;
|
2009-02-08 21:54:19 +00:00
|
|
|
}
|
2009-01-28 20:55:45 +00:00
|
|
|
}
|
2009-02-01 00:08:08 +00:00
|
|
|
else
|
|
|
|
if ( url.scheme() == "http" || url.scheme() == "https" ||
|
|
|
|
url.scheme() == "ftp" || url.scheme() == "mailto" )
|
|
|
|
{
|
|
|
|
// Use the system handler for the conventional internet links
|
|
|
|
QDesktopServices::openUrl( url );
|
|
|
|
}
|
2009-01-28 20:55:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ArticleView::contextMenuRequested( QPoint const & pos )
|
|
|
|
{
|
|
|
|
// Is that a link? Is there a selection?
|
|
|
|
|
|
|
|
QWebHitTestResult r = ui.definition->page()->currentFrame()->
|
|
|
|
hitTestContent( pos );
|
|
|
|
|
|
|
|
QMenu menu( this );
|
|
|
|
|
|
|
|
|
|
|
|
QAction * followLink = 0;
|
2009-02-08 15:49:17 +00:00
|
|
|
QAction * followLinkNewTab = 0;
|
2009-01-28 20:55:45 +00:00
|
|
|
QAction * lookupSelection = 0;
|
2009-02-08 15:49:17 +00:00
|
|
|
QAction * lookupSelectionNewTab = 0;
|
2009-01-28 20:55:45 +00:00
|
|
|
|
|
|
|
if ( !r.linkUrl().isEmpty() )
|
|
|
|
{
|
2009-02-08 15:49:17 +00:00
|
|
|
followLink = new QAction( tr( "&Open Link" ), &menu );
|
2009-01-28 20:55:45 +00:00
|
|
|
menu.addAction( followLink );
|
2009-02-08 15:49:17 +00:00
|
|
|
|
|
|
|
if ( !popupView )
|
|
|
|
{
|
|
|
|
followLinkNewTab = new QAction( tr( "Open Link in New &Tab" ), &menu );
|
|
|
|
menu.addAction( followLinkNewTab );
|
|
|
|
}
|
2009-04-03 21:57:23 +00:00
|
|
|
|
|
|
|
QString scheme = r.linkUrl().scheme();
|
|
|
|
|
|
|
|
if ( scheme == "http" || scheme == "https" || scheme == "ftp" || scheme == "mailto" )
|
|
|
|
menu.addAction( ui.definition->pageAction( QWebPage::QWebPage::CopyLinkToClipboard ) );
|
2009-01-28 20:55:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QString selectedText = ui.definition->selectedText();
|
2009-02-08 15:49:17 +00:00
|
|
|
|
2009-01-28 20:55:45 +00:00
|
|
|
if ( selectedText.size() )
|
|
|
|
{
|
2009-02-08 15:49:17 +00:00
|
|
|
lookupSelection = new QAction( tr( "&Look up \"%1\"" ).arg( ui.definition->selectedText() ), &menu );
|
2009-01-28 20:55:45 +00:00
|
|
|
menu.addAction( lookupSelection );
|
2009-02-08 15:49:17 +00:00
|
|
|
|
|
|
|
if ( !popupView )
|
|
|
|
{
|
|
|
|
lookupSelectionNewTab = new QAction( tr( "Look up \"%1\" in &New Tab" ).arg( ui.definition->selectedText() ), &menu );
|
|
|
|
menu.addAction( lookupSelectionNewTab );
|
|
|
|
}
|
2009-04-03 21:57:23 +00:00
|
|
|
|
|
|
|
menu.addAction( ui.definition->pageAction( QWebPage::QWebPage::Copy ) );
|
2009-01-28 20:55:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( !menu.isEmpty() )
|
|
|
|
{
|
|
|
|
QAction * result = menu.exec( ui.definition->mapToGlobal( pos ) );
|
|
|
|
|
|
|
|
if ( result == followLink )
|
|
|
|
linkClicked( r.linkUrl() );
|
|
|
|
else
|
|
|
|
if ( result == lookupSelection )
|
|
|
|
showDefinition( selectedText, getGroup( ui.definition->url() ) );
|
2009-02-08 15:49:17 +00:00
|
|
|
else
|
|
|
|
if ( !popupView )
|
|
|
|
{
|
|
|
|
if (result == followLinkNewTab )
|
|
|
|
emit openLinkInNewTab( r.linkUrl(), ui.definition->url() );
|
|
|
|
else
|
|
|
|
if ( result == lookupSelectionNewTab )
|
|
|
|
emit showDefinitionInNewTab( selectedText, getGroup( ui.definition->url() ) );
|
|
|
|
}
|
2009-01-28 20:55:45 +00:00
|
|
|
}
|
|
|
|
#if 0
|
|
|
|
printf( "%s\n", r.linkUrl().isEmpty() ? "null" : "not null" );
|
|
|
|
|
|
|
|
printf( "url = %s\n", r.linkUrl().toString().toLocal8Bit().data() );
|
|
|
|
printf( "title = %s\n", r.title().toLocal8Bit().data() );
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2009-03-26 19:00:08 +00:00
|
|
|
void ArticleView::resourceDownloadFinished()
|
|
|
|
{
|
|
|
|
if ( resourceDownloadRequests.empty() )
|
|
|
|
return; // Stray signal
|
|
|
|
|
|
|
|
// Find any finished resources
|
|
|
|
for( list< sptr< Dictionary::DataRequest > >::iterator i =
|
|
|
|
resourceDownloadRequests.begin(); i != resourceDownloadRequests.end(); )
|
|
|
|
{
|
|
|
|
if ( (*i)->isFinished() )
|
|
|
|
{
|
|
|
|
if ( (*i)->dataSize() >= 0 )
|
|
|
|
{
|
|
|
|
// Ok, got one finished, all others are irrelevant now
|
|
|
|
|
|
|
|
vector< char > const & data = (*i)->getFullData();
|
|
|
|
|
|
|
|
if ( resourceDownloadUrl.scheme() == "gdau" )
|
|
|
|
{
|
|
|
|
#ifdef Q_OS_WIN32
|
|
|
|
// Windows-only: use system PlaySound function
|
|
|
|
|
|
|
|
if ( winWavData.size() )
|
|
|
|
PlaySoundA( 0, 0, 0 ); // Stop any currently playing sound to make sure
|
|
|
|
// previous data isn't used anymore
|
|
|
|
//
|
|
|
|
winWavData = data;
|
|
|
|
|
|
|
|
PlaySoundA( &winWavData.front(), 0,
|
|
|
|
SND_ASYNC | SND_MEMORY | SND_NODEFAULT | SND_NOWAIT );
|
|
|
|
#else
|
|
|
|
|
|
|
|
// Use external viewer to play the file
|
|
|
|
try
|
|
|
|
{
|
|
|
|
ExternalViewer * viewer = new ExternalViewer( this, data, ".wav", "mplayer" );
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
viewer->start();
|
|
|
|
|
|
|
|
// Once started, it will erase itself
|
|
|
|
}
|
|
|
|
catch( ... )
|
|
|
|
{
|
|
|
|
delete viewer;
|
|
|
|
throw;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch( ExternalViewer::Ex & e )
|
|
|
|
{
|
|
|
|
QMessageBox::critical( this, tr( "GoldenDict" ), tr( "Failed to run a player to play sound file: %1" ).arg( e.what() ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Create a temporary file
|
|
|
|
|
|
|
|
|
|
|
|
// Remove the one previously used, if any
|
|
|
|
cleanupTemp();
|
|
|
|
|
|
|
|
{
|
|
|
|
QTemporaryFile tmp(
|
|
|
|
QDir::temp().filePath( "XXXXXX-" + resourceDownloadUrl.path().section( '/', -1 ) ), this );
|
|
|
|
|
|
|
|
if ( !tmp.open() || tmp.write( &data.front(), data.size() ) != data.size() )
|
|
|
|
{
|
|
|
|
QMessageBox::critical( this, tr( "GoldenDict" ), tr( "Failed to create temporary file." ) );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
tmp.setAutoRemove( false );
|
|
|
|
|
|
|
|
desktopOpenedTempFile = tmp.fileName();
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( !QDesktopServices::openUrl( QUrl::fromLocalFile( desktopOpenedTempFile ) ) )
|
|
|
|
QMessageBox::critical( this, tr( "GoldenDict" ), tr( "Failed to auto-open resource file, try opening manually: %1." ).arg( desktopOpenedTempFile ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Ok, whatever it was, it's finished. Remove this and any other
|
|
|
|
// requests and finish.
|
|
|
|
|
|
|
|
resourceDownloadRequests.clear();
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// This one had no data. Erase it.
|
|
|
|
resourceDownloadRequests.erase( i++ );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else // Unfinished, try the next one.
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( resourceDownloadRequests.empty() )
|
|
|
|
{
|
|
|
|
// No requests suceeded.
|
|
|
|
QMessageBox::critical( this, tr( "GoldenDict" ), tr( "The referenced resource failed to download." ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-28 20:55:45 +00:00
|
|
|
void ArticleView::showEvent( QShowEvent * ev )
|
|
|
|
{
|
|
|
|
QFrame::showEvent( ev );
|
|
|
|
|
|
|
|
ui.searchFrame->hide();
|
|
|
|
}
|