mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 19:24:08 +00:00
Merge branch 'Original' into Qt4x5
This commit is contained in:
commit
2ab4eeaf60
|
@ -494,11 +494,13 @@ void ArticleView::loadFinished( bool )
|
|||
QString anchor = QUrl::fromPercentEncoding( Qt4x5::Url::encodedQueryItemValue( url, "gdanchor" ) );
|
||||
|
||||
// Find GD anchor on page
|
||||
// Pattern: (dictionary ID (32 chars))_(articleID(quint64, hex))_(original anchor)
|
||||
|
||||
int n = anchor.indexOf( '_' );
|
||||
if( n > 0 )
|
||||
if( n == 32 )
|
||||
// MDict pattern: (dictionary ID (32 chars))_(articleID(quint64, hex))_(original anchor)
|
||||
n = anchor.indexOf( '_', n + 1 );
|
||||
else
|
||||
n = 0;
|
||||
|
||||
if( n > 0 )
|
||||
{
|
||||
|
@ -526,6 +528,12 @@ void ArticleView::loadFinished( bool )
|
|||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
url.setFragment( anchor );
|
||||
ui.definition->page()->mainFrame()->evaluateJavaScript(
|
||||
QString( "window.location = \"%1\"" ).arg( QString::fromUtf8( url.toEncoded() ) ) );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
22
mdx.cc
22
mdx.cc
|
@ -989,19 +989,15 @@ QString & MdxDictionary::filterResource( QString const & articleId, QString & ar
|
|||
if( pos < 0 )
|
||||
break;
|
||||
|
||||
if( wordCrossLink.cap( 3 ).isEmpty() )
|
||||
pos += wordCrossLink.cap( 0 ).size();
|
||||
else
|
||||
{
|
||||
QString newLink = wordCrossLink.cap( 1 )
|
||||
+ "gdlookup://localhost/"
|
||||
+ wordCrossLink.cap( 2 )
|
||||
+ ( wordCrossLink.cap( 3 ).isEmpty() ? "" : QString( "?gdanchor=" )
|
||||
+ uniquePrefix + wordCrossLink.cap( 3 ).mid( 1 )
|
||||
);
|
||||
article.replace( pos, wordCrossLink.cap( 0 ).size(), newLink );
|
||||
pos += newLink.size();
|
||||
}
|
||||
QString newLink = wordCrossLink.cap( 1 )
|
||||
+ "gdlookup://localhost/"
|
||||
+ wordCrossLink.cap( 2 );
|
||||
|
||||
if( !wordCrossLink.cap( 3 ).isEmpty() )
|
||||
newLink += QString( "?gdanchor=" ) + uniquePrefix + wordCrossLink.cap( 3 ).mid( 1 );
|
||||
|
||||
article.replace( pos, wordCrossLink.cap( 0 ).size(), newLink );
|
||||
pos += newLink.size();
|
||||
}
|
||||
|
||||
return article;
|
||||
|
|
12
slob.cc
12
slob.cc
|
@ -758,6 +758,9 @@ string SlobDictionary::convert( const string & in, RefEntry const & entry )
|
|||
QRegExp rxLink( "<\\s*a\\s+([^>]*)href=\"(?!(\\w+://|#|mailto:|tel:))(/|)([^\"]*)\"\\s*(title=\"[^\"]*\")?[^>]*>",
|
||||
Qt::CaseSensitive,
|
||||
QRegExp::RegExp2 );
|
||||
|
||||
QString anchor;
|
||||
|
||||
int pos = 0;
|
||||
while( (pos = rxLink.indexIn( text, pos )) >= 0 )
|
||||
{
|
||||
|
@ -766,11 +769,18 @@ string SlobDictionary::convert( const string & in, RefEntry const & entry )
|
|||
if ( !list[4].isEmpty() )
|
||||
tag = list[4].split("\"")[1];
|
||||
|
||||
// Find anchor
|
||||
int n = list[ 3 ].indexOf( '#' );
|
||||
if( n > 0 )
|
||||
anchor = QString( "?gdanchor=" ) + list[ 3 ].mid( n + 1 );
|
||||
else
|
||||
anchor.clear();
|
||||
|
||||
tag.remove( QRegExp(".*/") ).
|
||||
remove( QRegExp( "\\.(s|)htm(l|)$", Qt::CaseInsensitive ) ).
|
||||
replace( "_", "%20" ).
|
||||
prepend( "<a href=\"gdlookup://localhost/" ).
|
||||
append( "\" " + list[4] + ">" );
|
||||
append( anchor + "\" " + list[4] + ">" );
|
||||
|
||||
text.replace( pos, list[0].length(), tag );
|
||||
pos += tag.length() + 1;
|
||||
|
|
Loading…
Reference in a new issue