Skip to content

Commit

Permalink
opt: remove gdpicture & maxPictureWidth which has not been used at al…
Browse files Browse the repository at this point in the history
…l. (#1220)

* opt: remove gdpicture protocol which has lost effect for a long time

* opt: remove maxPictureWidth which has no place to configure this variable value

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes (attempt 2/3)

---------

Co-authored-by: YiFang Xiao <[email protected]>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Oct 9, 2023
1 parent 411a53b commit b1781b6
Show file tree
Hide file tree
Showing 10 changed files with 10 additions and 47 deletions.
7 changes: 0 additions & 7 deletions src/article_netmgr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -292,13 +292,6 @@ sptr< Dictionary::DataRequest > ArticleNetworkAccessManager::getResource( QUrl c
}
}

if ( url.scheme() == "gdpicture" ) {
contentType = "text/html";
QUrl imgUrl( url );
imgUrl.setScheme( "bres" );
return articleMaker.makePicturePage( imgUrl.toEncoded().data() );
}

return sptr< Dictionary::DataRequest >();
}

Expand Down
7 changes: 0 additions & 7 deletions src/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1160,9 +1160,6 @@ Class load()
if ( !root.namedItem( "editDictionaryCommandLine" ).isNull() )
c.editDictionaryCommandLine = root.namedItem( "editDictionaryCommandLine" ).toElement().text();

if ( !root.namedItem( "maxPictureWidth" ).isNull() )
c.maxPictureWidth = root.namedItem( "maxPictureWidth" ).toElement().text().toInt();

if ( !root.namedItem( "maxHeadwordSize" ).isNull() ) {
unsigned int value = root.namedItem( "maxHeadwordSize" ).toElement().text().toUInt();
if ( value != 0 ) // 0 is invalid value for our purposes
Expand Down Expand Up @@ -2172,10 +2169,6 @@ void save( Class const & c )
opt.appendChild( dd.createTextNode( c.editDictionaryCommandLine ) );
root.appendChild( opt );

opt = dd.createElement( "maxPictureWidth" );
opt.appendChild( dd.createTextNode( QString::number( c.maxPictureWidth ) ) );
root.appendChild( opt );

opt = dd.createElement( "maxHeadwordSize" );
opt.appendChild( dd.createTextNode( QString::number( c.maxHeadwordSize ) ) );
root.appendChild( opt );
Expand Down
3 changes: 0 additions & 3 deletions src/config.hh
Original file line number Diff line number Diff line change
Expand Up @@ -881,8 +881,6 @@ struct Class

bool usingSmallIconsInToolbars;

int maxPictureWidth; // Maximum picture width

/// Maximum size for the headwords.
/// Bigger headwords won't be indexed. For now, only in DSL.
unsigned int maxHeadwordSize;
Expand All @@ -899,7 +897,6 @@ struct Class
pinPopupWindow( false ),
showingDictBarNames( false ),
usingSmallIconsInToolbars( false ),
maxPictureWidth( 0 ),
maxHeadwordSize( 256U ),
maxHeadwordsToExpand( 0 )
{
Expand Down
23 changes: 6 additions & 17 deletions src/dict/dsl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -163,17 +163,13 @@ class DslDictionary: public BtreeIndexing::BtreeDictionary

int optionalPartNom;
quint8 articleNom;
int maxPictureWidth;

wstring currentHeadword;
string resourceDir1, resourceDir2;

public:

DslDictionary( string const & id,
string const & indexFile,
vector< string > const & dictionaryFiles,
int maxPictureWidth_ );
DslDictionary( string const & id, string const & indexFile, vector< string > const & dictionaryFiles );

void deferredInit() override;

Expand Down Expand Up @@ -285,18 +281,14 @@ class DslDictionary: public BtreeIndexing::BtreeDictionary
friend class DslFTSResultsRequest;
};

DslDictionary::DslDictionary( string const & id,
string const & indexFile,
vector< string > const & dictionaryFiles,
int maxPictureWidth_ ):
DslDictionary::DslDictionary( string const & id, string const & indexFile, vector< string > const & dictionaryFiles ):
BtreeDictionary( id, dictionaryFiles ),
idx( indexFile, "rb" ),
idxHeader( idx.read< IdxHeader >() ),
dz( 0 ),
deferredInitRunnableStarted( false ),
optionalPartNom( 0 ),
articleNom( 0 ),
maxPictureWidth( maxPictureWidth_ )
articleNom( 0 )
{

ftsIdxName = indexFile + Dictionary::getFtsSuffix();
Expand Down Expand Up @@ -842,10 +834,8 @@ string DslDictionary::nodeToHtml( ArticleDom::Node const & node )

string maxWidthStyle = " style=\"max-width:100%;\" ";

string link( url.toEncoded().data() );
link.replace( 0, 4, "gdpicture" );
result += string( "<a href=\"" ) + link + "\">" + "<img src=\"" + url.toEncoded().data() + "\" " + maxWidthStyle
+ " alt=\"" + Html::escape( filename ) + "\"/>" + "</a>";
result += string( "<img src=\"" ) + url.toEncoded().data() + "\" " + maxWidthStyle + " alt=\""
+ Html::escape( filename ) + "\"/>";
}
else if ( Filetype::isNameOfVideo( filename ) ) {
QUrl url;
Expand Down Expand Up @@ -1655,7 +1645,6 @@ sptr< Dictionary::DataRequest > DslDictionary::getSearchResults( QString const &
vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & fileNames,
string const & indicesDir,
Dictionary::Initializing & initializing,
int maxPictureWidth,
unsigned int maxHeadwordSize )

{
Expand Down Expand Up @@ -2115,7 +2104,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f

} // if need to rebuild

dictionaries.push_back( std::make_shared< DslDictionary >( dictId, indexFile, dictFiles, maxPictureWidth ) );
dictionaries.push_back( std::make_shared< DslDictionary >( dictId, indexFile, dictFiles ) );
}
catch ( std::exception & e ) {
gdWarning( "DSL dictionary reading failed: %s:%u, error: %s\n", fileName.c_str(), atLine, e.what() );
Expand Down
1 change: 0 additions & 1 deletion src/dict/dsl.hh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ using std::string;
vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & fileNames,
string const & indicesDir,
Dictionary::Initializing &,
int maxPictureWidth,
unsigned int maxHeadwordSize );

} // namespace Dsl
Expand Down
4 changes: 1 addition & 3 deletions src/dict/loaddictionaries.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ LoadDictionaries::LoadDictionaries( Config::Class const & cfg ):
hunspell( cfg.hunspell ),
transliteration( cfg.transliteration ),
exceptionText( "Load did not finish" ), // Will be cleared upon success
maxPictureWidth( cfg.maxPictureWidth ),
maxHeadwordSize( cfg.maxHeadwordSize ),
maxHeadwordToExpand( cfg.maxHeadwordsToExpand )
{
Expand Down Expand Up @@ -167,8 +166,7 @@ void LoadDictionaries::handlePath( Config::Path const & path )
addDicts( Bgl::makeDictionaries( allFiles, Config::getIndexDir().toStdString(), *this ) );
addDicts( Stardict::makeDictionaries( allFiles, Config::getIndexDir().toStdString(), *this, maxHeadwordToExpand ) );
addDicts( Lsa::makeDictionaries( allFiles, Config::getIndexDir().toStdString(), *this ) );
addDicts(
Dsl::makeDictionaries( allFiles, Config::getIndexDir().toStdString(), *this, maxPictureWidth, maxHeadwordSize ) );
addDicts( Dsl::makeDictionaries( allFiles, Config::getIndexDir().toStdString(), *this, maxHeadwordSize ) );
addDicts( DictdFiles::makeDictionaries( allFiles, Config::getIndexDir().toStdString(), *this ) );
addDicts( Xdxf::makeDictionaries( allFiles, Config::getIndexDir().toStdString(), *this ) );
addDicts( Sdict::makeDictionaries( allFiles, Config::getIndexDir().toStdString(), *this ) );
Expand Down
1 change: 0 additions & 1 deletion src/dict/loaddictionaries.hh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ class LoadDictionaries: public QThread, public Dictionary::Initializing
Config::Transliteration const & transliteration;
std::vector< sptr< Dictionary::Class > > dictionaries;
std::string exceptionText;
int maxPictureWidth;
unsigned int maxHeadwordSize;
unsigned int maxHeadwordToExpand;

Expand Down
2 changes: 1 addition & 1 deletion src/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ int main( int argc, char ** argv )
#endif

const QStringList localSchemes =
{ "gdlookup", "gdau", "gico", "qrcx", "bres", "bword", "gdprg", "gdvideo", "gdpicture", "gdtts", "ifr", "entry" };
{ "gdlookup", "gdau", "gico", "qrcx", "bres", "bword", "gdprg", "gdvideo", "gdtts", "ifr", "entry" };

for ( const auto & localScheme : localSchemes ) {
QWebEngineUrlScheme webUiScheme( localScheme.toLatin1() );
Expand Down
7 changes: 1 addition & 6 deletions src/ui/articleview.cc
Original file line number Diff line number Diff line change
Expand Up @@ -862,9 +862,6 @@ void ArticleView::linkHovered( const QString & link )
else if ( url.scheme() == "gdtts" ) {
msg = tr( "TTS Voice" );
}
else if ( url.scheme() == "gdpicture" ) {
msg = tr( "Picture" );
}
else if ( url.scheme() == "gdvideo" ) {
if ( url.path().isEmpty() ) {
msg = tr( "Video" );
Expand Down Expand Up @@ -967,9 +964,7 @@ void ArticleView::openLink( QUrl const & url, QUrl const & ref, QString const &

Contexts contexts( contexts_ );

if ( url.scheme().compare( "gdpicture" ) == 0 )
load( url );
else if ( url.scheme().compare( "ankisearch" ) == 0 ) {
if ( url.scheme().compare( "ankisearch" ) == 0 ) {
ankiConnector->ankiSearch( url.path() );
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/ui/mainwindow.cc
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
GlobalBroadcaster::instance()->setPreference( &cfg.preferences );

localSchemeHandler = new LocalSchemeHandler( articleNetMgr, this );
QStringList htmlScheme = { "gdlookup", "bword", "entry", "gdpicture" };
QStringList htmlScheme = { "gdlookup", "bword", "entry" };
for ( const auto & localScheme : htmlScheme ) {
QWebEngineProfile::defaultProfile()->installUrlSchemeHandler( localScheme.toLatin1(), localSchemeHandler );
}
Expand Down

0 comments on commit b1781b6

Please sign in to comment.