Changeset View
Changeset View
Standalone View
Standalone View
src/context/applets/wikipedia/plugin/WikipediaEngine.cpp
Show All 16 Lines | |||||
17 | * this program. If not, see <http://www.gnu.org/licenses/>. * | 17 | * this program. If not, see <http://www.gnu.org/licenses/>. * | ||
18 | ****************************************************************************************/ | 18 | ****************************************************************************************/ | ||
19 | 19 | | |||
20 | #define DEBUG_PREFIX "Wikipedia" | 20 | #define DEBUG_PREFIX "Wikipedia" | ||
21 | 21 | | |||
22 | #include "WikipediaEngine.h" | 22 | #include "WikipediaEngine.h" | ||
23 | 23 | | |||
24 | #include "EngineController.h" | 24 | #include "EngineController.h" | ||
25 | #include "PaletteHandler.h" | ||||
25 | #include "core/meta/support/MetaConstants.h" | 26 | #include "core/meta/support/MetaConstants.h" | ||
26 | #include "core/support/Amarok.h" | 27 | #include "core/support/Amarok.h" | ||
27 | #include "core/support/Debug.h" | 28 | #include "core/support/Debug.h" | ||
28 | 29 | | |||
29 | #include <QHashIterator> | 30 | #include <QHashIterator> | ||
31 | #include <QRegularExpression> | ||||
32 | #include <QStandardPaths> | ||||
30 | #include <QUrlQuery> | 33 | #include <QUrlQuery> | ||
31 | #include <QXmlStreamReader> | 34 | #include <QXmlStreamReader> | ||
32 | 35 | | |||
33 | #include <KLocalizedString> | 36 | #include <KLocalizedString> | ||
34 | 37 | | |||
35 | 38 | | |||
36 | WikipediaEngine::WikipediaEngine( QObject* parent ) | 39 | WikipediaEngine::WikipediaEngine( QObject* parent ) | ||
37 | : QObject( parent ) | 40 | : QObject( parent ) | ||
38 | , currentSelection( Artist ) | 41 | , currentSelection( Artist ) | ||
39 | , useMobileVersion( false ) | 42 | , useMobileVersion( false ) | ||
40 | { | 43 | { | ||
41 | preferredLangs = Amarok::config("Wikipedia Applet").readEntry( "PreferredLang", QStringList() << "en" ); | 44 | preferredLangs = Amarok::config("Wikipedia Applet").readEntry( "PreferredLang", QStringList() << "en" ); | ||
42 | 45 | | |||
43 | EngineController *engine = The::engineController(); | 46 | EngineController *engine = The::engineController(); | ||
44 | 47 | | |||
45 | _checkRequireUpdate( engine->currentTrack() ); | 48 | _checkRequireUpdate( engine->currentTrack() ); | ||
49 | _paletteChanged( The::paletteHandler()->palette() ); | ||||
46 | 50 | | |||
47 | connect( engine, &EngineController::trackChanged, | 51 | connect( engine, &EngineController::trackChanged, | ||
48 | this, &WikipediaEngine::_checkRequireUpdate ); | 52 | this, &WikipediaEngine::_checkRequireUpdate ); | ||
49 | connect( engine, &EngineController::trackMetadataChanged, | 53 | connect( engine, &EngineController::trackMetadataChanged, | ||
50 | this, &WikipediaEngine::_checkRequireUpdate ); | 54 | this, &WikipediaEngine::_checkRequireUpdate ); | ||
51 | connect( engine, &EngineController::stopped, | 55 | connect( engine, &EngineController::stopped, | ||
52 | this, &WikipediaEngine::_stopped ); | 56 | this, &WikipediaEngine::_stopped ); | ||
57 | connect( The::paletteHandler(), &PaletteHandler::newPalette, | ||||
58 | this, &WikipediaEngine::_paletteChanged ); | ||||
53 | } | 59 | } | ||
54 | 60 | | |||
55 | WikipediaEngine::~WikipediaEngine() | 61 | WikipediaEngine::~WikipediaEngine() | ||
56 | { | 62 | { | ||
57 | } | 63 | } | ||
58 | 64 | | |||
59 | void | 65 | void | ||
60 | WikipediaEngine::_wikiResult( const QUrl &url, QByteArray result, NetworkAccessManagerProxy::Error e ) | 66 | WikipediaEngine::_wikiResult( const QUrl &url, QByteArray result, NetworkAccessManagerProxy::Error e ) | ||
▲ Show 20 Lines • Show All 314 Lines • ▼ Show 20 Line(s) | 380 | { | |||
375 | DEBUG_BLOCK | 381 | DEBUG_BLOCK | ||
376 | 382 | | |||
377 | clear(); | 383 | clear(); | ||
378 | // dataContainer->setData( "stopped", 1 ); | 384 | // dataContainer->setData( "stopped", 1 ); | ||
379 | m_previousTrackMetadata.clear(); | 385 | m_previousTrackMetadata.clear(); | ||
380 | } | 386 | } | ||
381 | 387 | | |||
382 | void | 388 | void | ||
389 | WikipediaEngine::_paletteChanged( const QPalette &palette ) | ||||
390 | { | ||||
391 | DEBUG_BLOCK | ||||
392 | | ||||
393 | // read css, replace color placeholders, write to file, load into page | ||||
394 | QFile file( QStandardPaths::locate( QStandardPaths::GenericDataLocation, "amarok/data/WikipediaCustomStyle.css" ) ); | ||||
395 | if( file.open(QIODevice::ReadOnly | QIODevice::Text) ) | ||||
396 | { | ||||
397 | QString contents = QString( file.readAll() ); | ||||
398 | contents.replace( "/*{text_color}*/", palette.text().color().name() ); | ||||
399 | contents.replace( "/*{link_color}*/", palette.link().color().name() ); | ||||
400 | contents.replace( "/*{link_hover_color}*/", palette.linkVisited().color().name() ); | ||||
401 | contents.replace( "/*{background_color}*/", palette.base().color().name() ); | ||||
402 | | ||||
403 | const QString abg = palette.window().color().name(); | ||||
404 | contents.replace( "/*{shaded_text_background_color}*/", abg ); | ||||
405 | contents.replace( "/*{table_background_color}*/", abg ); | ||||
406 | contents.replace( "/*{headings_background_color}*/", abg ); | ||||
407 | | ||||
408 | const QString atbg = palette.alternateBase().color().name(); | ||||
409 | contents.replace( "/*{alternate_table_background_color}*/", atbg ); | ||||
410 | | ||||
411 | if( m_css == contents ) | ||||
412 | return; | ||||
413 | | ||||
414 | m_css = contents; | ||||
415 | updateEngine(); | ||||
416 | } | ||||
417 | else | ||||
418 | { | ||||
419 | error() << "Could not load WikipediaCustomStyle.css"; | ||||
420 | } | ||||
421 | } | ||||
422 | | ||||
423 | void | ||||
383 | WikipediaEngine::fetchWikiUrl( const QString &title, const QString &urlPrefix ) | 424 | WikipediaEngine::fetchWikiUrl( const QString &title, const QString &urlPrefix ) | ||
384 | { | 425 | { | ||
385 | QUrl pageUrl; | 426 | QUrl pageUrl; | ||
386 | QString host( ".wikipedia.org" ); | 427 | QString host( ".wikipedia.org" ); | ||
387 | pageUrl.setScheme( QLatin1String( "https" ) ); | 428 | pageUrl.setScheme( QLatin1String( "https" ) ); | ||
388 | 429 | | |||
389 | // if( useMobileVersion ) | 430 | // if( useMobileVersion ) | ||
390 | // { | 431 | // { | ||
Show All 17 Lines | 441 | // } | |||
408 | QUrlQuery query; | 449 | QUrlQuery query; | ||
409 | query.addQueryItem( QLatin1String("title"), title ); | 450 | query.addQueryItem( QLatin1String("title"), title ); | ||
410 | query.addQueryItem( QLatin1String("redirects"), QString::number(1) ); | 451 | query.addQueryItem( QLatin1String("redirects"), QString::number(1) ); | ||
411 | query.addQueryItem( QLatin1String("useskin"), QLatin1String("monobook") ); | 452 | query.addQueryItem( QLatin1String("useskin"), QLatin1String("monobook") ); | ||
412 | pageUrl.setQuery( query ); | 453 | pageUrl.setQuery( query ); | ||
413 | wikiCurrentUrl = pageUrl; | 454 | wikiCurrentUrl = pageUrl; | ||
414 | urls << pageUrl; | 455 | urls << pageUrl; | ||
415 | emit urlChanged(); | 456 | emit urlChanged(); | ||
416 | The::networkAccessManager()->getData( pageUrl, this, | 457 | The::networkAccessManager()->getData( pageUrl, this, &WikipediaEngine::_wikiResult ); | ||
417 | SLOT(_wikiResult(QUrl,QByteArray,NetworkAccessManagerProxy::Error)) ); | | |||
418 | } | 458 | } | ||
419 | 459 | | |||
420 | void | 460 | void | ||
421 | WikipediaEngine::fetchLangLinks( const QString &title, | 461 | WikipediaEngine::fetchLangLinks( const QString &title, | ||
422 | const QString &hostLang, | 462 | const QString &hostLang, | ||
423 | const QString &llcontinue ) | 463 | const QString &llcontinue ) | ||
424 | { | 464 | { | ||
425 | QUrl url; | 465 | QUrl url; | ||
426 | url.setScheme( QLatin1String( "https" ) ); | 466 | url.setScheme( QLatin1String( "https" ) ); | ||
427 | url.setHost( hostLang + QLatin1String(".wikipedia.org") ); | 467 | url.setHost( hostLang + QLatin1String(".wikipedia.org") ); | ||
428 | url.setPath( QLatin1String("/w/api.php") ); | 468 | url.setPath( QLatin1String("/w/api.php") ); | ||
429 | QUrlQuery query; | 469 | QUrlQuery query; | ||
430 | query.addQueryItem( QLatin1String("action"), QLatin1String("query") ); | 470 | query.addQueryItem( QLatin1String("action"), QLatin1String("query") ); | ||
431 | query.addQueryItem( QLatin1String("prop"), QLatin1String("langlinks") ); | 471 | query.addQueryItem( QLatin1String("prop"), QLatin1String("langlinks") ); | ||
432 | query.addQueryItem( QLatin1String("titles"), title ); | 472 | query.addQueryItem( QLatin1String("titles"), title ); | ||
433 | query.addQueryItem( QLatin1String("format"), QLatin1String("xml") ); | 473 | query.addQueryItem( QLatin1String("format"), QLatin1String("xml") ); | ||
434 | query.addQueryItem( QLatin1String("lllimit"), QString::number(100) ); | 474 | query.addQueryItem( QLatin1String("lllimit"), QString::number(100) ); | ||
435 | query.addQueryItem( QLatin1String("redirects"), QString::number(1) ); | 475 | query.addQueryItem( QLatin1String("redirects"), QString::number(1) ); | ||
436 | if( !llcontinue.isEmpty() ) | 476 | if( !llcontinue.isEmpty() ) | ||
437 | query.addQueryItem( QLatin1String("llcontinue"), llcontinue ); | 477 | query.addQueryItem( QLatin1String("llcontinue"), llcontinue ); | ||
438 | url.setQuery( query ); | 478 | url.setQuery( query ); | ||
439 | urls << url; | 479 | urls << url; | ||
440 | debug() << "Fetching langlinks:" << url; | 480 | debug() << "Fetching langlinks:" << url; | ||
441 | The::networkAccessManager()->getData( url, this, | 481 | The::networkAccessManager()->getData( url, this, &WikipediaEngine::_parseLangLinksResult ); | ||
442 | SLOT(_parseLangLinksResult(QUrl,QByteArray,NetworkAccessManagerProxy::Error)) ); | | |||
443 | } | 482 | } | ||
444 | 483 | | |||
445 | void | 484 | void | ||
446 | WikipediaEngine::fetchListing( const QString &title, const QString &hostLang ) | 485 | WikipediaEngine::fetchListing( const QString &title, const QString &hostLang ) | ||
447 | { | 486 | { | ||
448 | QUrl url; | 487 | QUrl url; | ||
449 | url.setScheme( QLatin1String( "https" ) ); | 488 | url.setScheme( QLatin1String( "https" ) ); | ||
450 | url.setHost( hostLang + QLatin1String(".wikipedia.org") ); | 489 | url.setHost( hostLang + QLatin1String(".wikipedia.org") ); | ||
451 | url.setPath( QLatin1String("/w/api.php") ); | 490 | url.setPath( QLatin1String("/w/api.php") ); | ||
452 | QUrlQuery query; | 491 | QUrlQuery query; | ||
453 | query.addQueryItem( QLatin1String("action"), QLatin1String("query") ); | 492 | query.addQueryItem( QLatin1String("action"), QLatin1String("query") ); | ||
454 | query.addQueryItem( QLatin1String("list"), QLatin1String("search") ); | 493 | query.addQueryItem( QLatin1String("list"), QLatin1String("search") ); | ||
455 | query.addQueryItem( QLatin1String("srsearch"), title ); | 494 | query.addQueryItem( QLatin1String("srsearch"), title ); | ||
456 | query.addQueryItem( QLatin1String("srprop"), QLatin1String("size") ); | 495 | query.addQueryItem( QLatin1String("srprop"), QLatin1String("size") ); | ||
457 | query.addQueryItem( QLatin1String("srredirects"), QString::number(1) ); | 496 | query.addQueryItem( QLatin1String("srredirects"), QString::number(1) ); | ||
458 | query.addQueryItem( QLatin1String("srlimit"), QString::number(20) ); | 497 | query.addQueryItem( QLatin1String("srlimit"), QString::number(20) ); | ||
459 | query.addQueryItem( QLatin1String("format"), QLatin1String("xml") ); | 498 | query.addQueryItem( QLatin1String("format"), QLatin1String("xml") ); | ||
460 | url.setQuery( query ); | 499 | url.setQuery( query ); | ||
461 | urls << url; | 500 | urls << url; | ||
462 | debug() << "Fetching listing:" << url; | 501 | debug() << "Fetching listing:" << url; | ||
463 | The::networkAccessManager()->getData( url, this, | 502 | The::networkAccessManager()->getData( url, this, &WikipediaEngine::_parseListingResult ); | ||
464 | SLOT(_parseListingResult(QUrl,QByteArray,NetworkAccessManagerProxy::Error)) ); | | |||
465 | } | 503 | } | ||
466 | 504 | | |||
467 | void | 505 | void | ||
468 | WikipediaEngine::updateEngine() | 506 | WikipediaEngine::updateEngine() | ||
469 | { | 507 | { | ||
470 | static QMap<SelectionType, qint64> typeToFieldMap; | 508 | static QMap<SelectionType, qint64> typeToFieldMap; | ||
471 | if( typeToFieldMap.isEmpty() ) | 509 | if( typeToFieldMap.isEmpty() ) | ||
472 | { | 510 | { | ||
▲ Show 20 Lines • Show All 89 Lines • ▼ Show 20 Line(s) | |||||
562 | 600 | | |||
563 | fetchLangLinks( tmpWikiStr, preferredLangs.first().split( QLatin1Char(':') ).back() ); | 601 | fetchLangLinks( tmpWikiStr, preferredLangs.first().split( QLatin1Char(':') ).back() ); | ||
564 | } | 602 | } | ||
565 | 603 | | |||
566 | void | 604 | void | ||
567 | WikipediaEngine::wikiParse( QString &wiki ) | 605 | WikipediaEngine::wikiParse( QString &wiki ) | ||
568 | { | 606 | { | ||
569 | //remove the new-lines and tabs(replace with spaces IS needed). | 607 | //remove the new-lines and tabs(replace with spaces IS needed). | ||
570 | wiki.replace( '\n', QLatin1Char(' ') ); | 608 | // wiki.replace( '\n', QLatin1Char(' ') ); | ||
571 | wiki.replace( '\t', QLatin1Char(' ') ); | 609 | // wiki.replace( '\t', QLatin1Char(' ') ); | ||
572 | 610 | | |||
573 | // Get the available language list | 611 | // Get the available language list | ||
574 | QString wikiLanguagesSection; | 612 | QString wikiLanguagesSection; | ||
575 | QMap<QString, QString> langMap; | 613 | QMap<QString, QString> langMap; | ||
576 | int langSectionIndex = 0; | 614 | int langSectionIndex = 0; | ||
577 | if( (langSectionIndex = wiki.indexOf( QLatin1String("<div id=\"p-lang\" class=\"portlet\">") )) != -1 ) | 615 | if( (langSectionIndex = wiki.indexOf( QLatin1String("<div id=\"p-lang\" class=\"portlet\">") )) != -1 ) | ||
578 | { | 616 | { | ||
579 | QStringRef sref = wiki.midRef( langSectionIndex ); | 617 | QStringRef sref = wiki.midRef( langSectionIndex ); | ||
▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Line(s) | 664 | { | |||
630 | while( ( matchIndex = tagMatcher.indexIn( wiki, matchIndex ) ) != -1 ) | 668 | while( ( matchIndex = tagMatcher.indexIn( wiki, matchIndex ) ) != -1 ) | ||
631 | { | 669 | { | ||
632 | const int nToTagEnd = wiki.indexOf( tagEnd, matchIndex ) - matchIndex; | 670 | const int nToTagEnd = wiki.indexOf( tagEnd, matchIndex ) - matchIndex; | ||
633 | const QStringRef tagRef = wiki.midRef( matchIndex, nToTagEnd + tagEndSize ); | 671 | const QStringRef tagRef = wiki.midRef( matchIndex, nToTagEnd + tagEndSize ); | ||
634 | wiki.remove( tagRef.toString() ); | 672 | wiki.remove( tagRef.toString() ); | ||
635 | } | 673 | } | ||
636 | }; | 674 | }; | ||
637 | 675 | | |||
676 | QString header = QString( "<html>\n<head>\n<title>%1</title>\n</head>\n<body>\n" ).arg( title ); | ||||
677 | | ||||
678 | // add own stylesheet | ||||
679 | if( !m_css.isEmpty() ) | ||||
680 | { | ||||
681 | removeTag( "<link rel=\"stylesheet\"", "/>" ); | ||||
682 | int index = header.indexOf( QStringLiteral( "</head>" ) ); | ||||
683 | header.insert( index, QString( "\n<style>\n%1\n</style>\n" ).arg( m_css ) ); | ||||
684 | } | ||||
685 | | ||||
686 | wiki.prepend( header ); | ||||
687 | | ||||
638 | // lets remove the warning box | 688 | // lets remove the warning box | ||
639 | removeTag( "<table class=\"metadata plainlinks ambox", "</table>" ); | 689 | removeTag( "<table class=\"metadata plainlinks ambox", "</table>" ); | ||
640 | // remove protection policy (we don't do edits) | 690 | // remove protection policy (we don't do edits) | ||
641 | removeTag( "<div><a href=\"/wiki/Wikipedia:Protection_policy", "</a></div>" ); | 691 | removeTag( "<div><a href=\"/wiki/Wikipedia:Protection_policy", "</a></div>" ); | ||
642 | // lets also remove the "lock" image | 692 | // lets also remove the "lock" image | ||
643 | removeTag( "<div class=\"metadata topicon\" ", "</a></div>" ); | 693 | removeTag( "<div class=\"metadata topicon\" ", "</a></div>" ); | ||
644 | // remove <audio> tags (can lead to crashes in QtWebKit) | 694 | // remove <audio> tags (can lead to crashes in QtWebKit) | ||
645 | removeTag( "<audio", "</audio>" ); | 695 | // removeTag( "<audio", "</audio>" ); | ||
646 | 696 | | |||
647 | // Adding back style and license information | 697 | // Adding back style and license information | ||
648 | wiki = QLatin1String("<div id=\"bodyContent\"") + wiki; | 698 | wiki = QLatin1String("<div id=\"bodyContent\"") + wiki; | ||
649 | wiki += copyright; | 699 | wiki += copyright; | ||
650 | wiki.append( QLatin1String("</div>") ); | 700 | wiki.append( QLatin1String("</div>") ); | ||
651 | wiki.remove( QRegExp( QLatin1String("<h3 id=\"siteSub\">[^<]*</h3>") ) ); | 701 | wiki.remove( QRegExp( QLatin1String("<h3 id=\"siteSub\">[^<]*</h3>") ) ); | ||
652 | 702 | | |||
653 | wiki.remove( QRegExp( QLatin1String("<span class=\"editsection\"[^>]*>[^<]*<[^>]*>[^<]*<[^>]*>[^<]*</span>") ) ); | 703 | wiki.remove( QRegExp( QLatin1String("<span class=\"editsection\"[^>]*>[^<]*<[^>]*>[^<]*<[^>]*>[^<]*</span>") ) ); | ||
654 | wiki.remove( QRegExp( QLatin1String("<p><span[^>]*><[^\"]*\"#_skip_noteTA\">[^<]*<[^<]*</span></p>") ) ); | 704 | wiki.remove( QRegExp( QLatin1String("<p><span[^>]*><[^\"]*\"#_skip_noteTA\">[^<]*<[^<]*</span></p>") ) ); | ||
655 | 705 | | |||
656 | wiki.replace( QRegExp( QLatin1String("<a href=\"[^\"]*\" class=\"new\"[^>]*>([^<]*)</a>") ), QLatin1String("\\1") ); | 706 | wiki.replace( QRegExp( QLatin1String("<a href=\"[^\"]*\" class=\"new\"[^>]*>([^<]*)</a>") ), QLatin1String("\\1") ); | ||
657 | 707 | | |||
658 | // Remove anything inside of a class called urlexpansion, as it's pointless for us | 708 | // Remove anything inside of a class called urlexpansion, as it's pointless for us | ||
659 | wiki.remove( QRegExp( QLatin1String("<span class= *'urlexpansion'>[^(]*[(][^)]*[)]</span>") ) ); | 709 | wiki.remove( QRegExp( QLatin1String("<span class= *'urlexpansion'>[^(]*[(][^)]*[)]</span>") ) ); | ||
660 | 710 | | |||
661 | // Remove hidden table rows as well | 711 | // Remove hidden table rows as well | ||
662 | QRegExp hidden( QLatin1String("<tr *class= *[\"\']hiddenStructure[\"\']>.*</tr>"), Qt::CaseInsensitive ); | 712 | QRegExp hidden( QLatin1String("<tr *class= *[\"\']hiddenStructure[\"\']>.*</tr>"), Qt::CaseInsensitive ); | ||
663 | hidden.setMinimal( true ); //greedy behaviour wouldn't be any good! | 713 | hidden.setMinimal( true ); //greedy behaviour wouldn't be any good! | ||
664 | wiki.remove( hidden ); | 714 | wiki.remove( hidden ); | ||
665 | 715 | | |||
666 | // we want to keep our own style (we need to modify the stylesheet a bit to handle things nicely) | 716 | // we want to keep our own style (we need to modify the stylesheet a bit to handle things nicely) | ||
667 | wiki.remove( QRegExp( QLatin1String("style= *\"[^\"]*\"") ) ); | 717 | wiki.remove( QRegExp( QLatin1String("style= *\"[^\"]*\"") ) ); | ||
668 | // We need to leave the classes behind, otherwise styling it ourselves gets really nasty and tedious and roughly impossible to do in a sane maner | 718 | // We need to leave the classes behind, otherwise styling it ourselves gets really nasty and tedious and roughly impossible to do in a sane manner | ||
669 | //wiki.replace( QRegExp( "class= *\"[^\"]*\"" ), QString() ); | 719 | //wiki.replace( QRegExp( "class= *\"[^\"]*\"" ), QString() ); | ||
670 | // let's remove the form elements, we don't want them. | 720 | // let's remove the form elements, we don't want them. | ||
671 | wiki.remove( QRegExp( QLatin1String("<input[^>]*>") ) ); | 721 | wiki.remove( QRegExp( QLatin1String("<input[^>]*>") ) ); | ||
672 | wiki.remove( QRegExp( QLatin1String("<select[^>]*>") ) ); | 722 | wiki.remove( QRegExp( QLatin1String("<select[^>]*>") ) ); | ||
673 | wiki.remove( QLatin1String("</select>\n") ); | 723 | wiki.remove( QLatin1String("</select>\n") ); | ||
674 | wiki.remove( QRegExp( QLatin1String("<option[^>]*>") ) ); | 724 | wiki.remove( QRegExp( QLatin1String("<option[^>]*>") ) ); | ||
675 | wiki.remove( QLatin1String("</option>\n") ); | 725 | wiki.remove( QLatin1String("</option>\n") ); | ||
676 | wiki.remove( QRegExp( QLatin1String("<textarea[^>]*>") ) ); | 726 | wiki.remove( QRegExp( QLatin1String("<textarea[^>]*>") ) ); | ||
677 | wiki.remove( QLatin1String("</textarea>") ); | 727 | wiki.remove( QLatin1String("</textarea>") ); | ||
678 | 728 | | |||
679 | wiki.prepend( QLatin1String("<html>\n") ); | | |||
680 | wiki.append( QString(QLatin1String("<head><title>%1</title></head>\n")).arg(title) ); | | |||
681 | wiki.append( QLatin1String("<body>\n") ); | | |||
682 | // wiki.append( createLanguageComboBox(langMap) ); // BUG:259075 | 729 | // wiki.append( createLanguageComboBox(langMap) ); // BUG:259075 | ||
683 | wiki.append( QLatin1String("</body></html>\n") ); | 730 | wiki.append( QLatin1String("</body></html>\n") ); | ||
684 | } | 731 | } | ||
685 | 732 | | |||
686 | QString | 733 | QString | ||
687 | WikipediaEngine::createLanguageComboBox( const QMap<QString, QString> &languageMap ) | 734 | WikipediaEngine::createLanguageComboBox( const QMap<QString, QString> &languageMap ) | ||
688 | { | 735 | { | ||
689 | if( languageMap.isEmpty() ) | 736 | if( languageMap.isEmpty() ) | ||
Show All 14 Lines | |||||
704 | 751 | | |||
705 | void | 752 | void | ||
706 | WikipediaEngine::reloadWikipedia() | 753 | WikipediaEngine::reloadWikipedia() | ||
707 | { | 754 | { | ||
708 | if( !wikiCurrentUrl.isValid() ) | 755 | if( !wikiCurrentUrl.isValid() ) | ||
709 | return; | 756 | return; | ||
710 | urls << wikiCurrentUrl; | 757 | urls << wikiCurrentUrl; | ||
711 | setBusy( true ); | 758 | setBusy( true ); | ||
712 | The::networkAccessManager()->getData( wikiCurrentUrl, this, | 759 | The::networkAccessManager()->getData( wikiCurrentUrl, this, &WikipediaEngine::_wikiResult ); | ||
713 | SLOT(_wikiResult(QUrl,QByteArray,NetworkAccessManagerProxy::Error)) ); | | |||
714 | } | 760 | } | ||
715 | 761 | | |||
716 | WikipediaEngine::SelectionType | 762 | WikipediaEngine::SelectionType | ||
717 | WikipediaEngine::selection() const | 763 | WikipediaEngine::selection() const | ||
718 | { | 764 | { | ||
719 | return currentSelection; | 765 | return currentSelection; | ||
720 | } | 766 | } | ||
721 | 767 | | |||
▲ Show 20 Lines • Show All 93 Lines • ▼ Show 20 Line(s) | |||||
815 | { | 861 | { | ||
816 | if( wikiCurrentUrl == url ) | 862 | if( wikiCurrentUrl == url ) | ||
817 | return; | 863 | return; | ||
818 | 864 | | |||
819 | wikiCurrentUrl = url; | 865 | wikiCurrentUrl = url; | ||
820 | urls << url; | 866 | urls << url; | ||
821 | emit urlChanged(); | 867 | emit urlChanged(); | ||
822 | 868 | | |||
823 | The::networkAccessManager()->getData( url, this, SLOT(_wikiResult(QUrl,QByteArray,NetworkAccessManagerProxy::Error)) ); | 869 | The::networkAccessManager()->getData( url, this, &WikipediaEngine::_wikiResult ); | ||
824 | } | 870 | } | ||
825 | 871 | |