From 8e43a81592730b8c44359af95db04c972e909b82 Mon Sep 17 00:00:00 2001 From: Konstantin Isakov Date: Fri, 6 Feb 2009 16:19:05 +0000 Subject: [PATCH] * Make "search" audio links be bound by the current group. --- src/articleview.cc | 39 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/src/articleview.cc b/src/articleview.cc index 67961b59..44a7320a 100644 --- a/src/articleview.cc +++ b/src/articleview.cc @@ -132,13 +132,46 @@ void ArticleView::linkClicked( QUrl const & url ) else if ( url.scheme() == "bres" || url.scheme() == "gdau" ) { - vector< char > data; - // Download it + vector< char > data; + bool found = false; + + + 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. + + QString currentGroup = getGroup( ui.definition->url() ); + + for( unsigned x = 0; x < groups.size(); ++x ) + if ( groups[ x ].name == currentGroup ) + { + for( unsigned y = 0; y < groups[ x ].dictionaries.size(); ++y ) + { + try + { + groups[ x ].dictionaries[ y ]->getResource( + url.path().mid( 1 ).toUtf8().data(), data ); + + found = true; + break; + } + catch( Dictionary::exNoSuchResource & ) + { + continue; + } + } + break; + } + } + + QString contentType; - if ( !articleNetMgr.getResource( url, data, contentType ) ) + if ( !found && !articleNetMgr.getResource( url, data, contentType ) ) { QMessageBox::critical( this, tr( "GoldenDict" ), tr( "The referenced resource doesn't exist." ) ); return;