diff options
author | Slávek Banko <[email protected]> | 2013-06-29 12:56:53 +0200 |
---|---|---|
committer | Slávek Banko <[email protected]> | 2013-07-04 03:11:35 +0200 |
commit | 5f5e7c5455d52826b0bd50f64fcffb7695ce970d (patch) | |
tree | c8ee8792d3fb139365abbf70c2255f1e69d2aa34 /src/webquerygooglescholar.cpp | |
parent | 251c9a439759c830d34c70683d0fc9454d703010 (diff) | |
download | kbibtex-5f5e7c5455d52826b0bd50f64fcffb7695ce970d.tar.gz kbibtex-5f5e7c5455d52826b0bd50f64fcffb7695ce970d.zip |
Initial TQt conversion
Diffstat (limited to 'src/webquerygooglescholar.cpp')
-rw-r--r-- | src/webquerygooglescholar.cpp | 118 |
1 files changed, 59 insertions, 59 deletions
diff --git a/src/webquerygooglescholar.cpp b/src/webquerygooglescholar.cpp index a1c2d52..b8fdc04 100644 --- a/src/webquerygooglescholar.cpp +++ b/src/webquerygooglescholar.cpp @@ -17,12 +17,12 @@ * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#include <qfile.h> -#include <qapplication.h> -#include <qregexp.h> -#include <qtimer.h> -#include <qmap.h> -#include <qspinbox.h> +#include <ntqfile.h> +#include <ntqapplication.h> +#include <ntqregexp.h> +#include <ntqtimer.h> +#include <ntqmap.h> +#include <ntqspinbox.h> #include <kconfig.h> #include <klineedit.h> @@ -38,19 +38,19 @@ namespace KBibTeX { - WebQueryGoogleScholarWidget::WebQueryGoogleScholarWidget( QWidget *parent, const char *name ) + WebQueryGoogleScholarWidget::WebQueryGoogleScholarWidget( TQWidget *parent, const char *name ) : WebQueryWidget( parent, name ) { init(); Settings *settings = Settings::self(); - QString value = settings->getWebQueryDefault( "GoogleScholar" ); - value = value == QString::null ? "" : value; + TQString value = settings->getWebQueryDefault( "GoogleScholar" ); + value = value == TQString::null ? "" : value; lineEditQuery->setText( value ); slotTextChanged( value, true ); } - WebQueryGoogleScholar::WebQueryGoogleScholar( QWidget* parent ) + WebQueryGoogleScholar::WebQueryGoogleScholar( TQWidget* parent ) : WebQuery( parent ), m_transferJob( NULL ), m_transferJobBuffer( NULL ) { m_importer = new BibTeX::FileImporterBibTeX( FALSE ); @@ -64,17 +64,17 @@ namespace KBibTeX delete m_importer; } - QString WebQueryGoogleScholar::title() + TQString WebQueryGoogleScholar::title() { return i18n( "Google Scholar" ); } - QString WebQueryGoogleScholar::disclaimer() + TQString WebQueryGoogleScholar::disclaimer() { return i18n( "About Google Scholar" ); } - QString WebQueryGoogleScholar::disclaimerURL() + TQString WebQueryGoogleScholar::disclaimerURL() { return "http://scholar.google.com/intl/en/scholar/about.html"; } @@ -110,10 +110,10 @@ namespace KBibTeX readAndChangeConfig(); /** prepare HTTP request (buffer, signals, job) */ - m_transferJobBuffer = new QBuffer(); + m_transferJobBuffer = new TQBuffer(); m_transferJobBuffer->open( IO_WriteOnly ); KIO::TransferJob* m_transferJob = KIO::get( KURL( "http://scholar.google.com/scholar_ncr" ), false, false ); - connect( m_transferJob, SIGNAL( data( KIO::Job *, const QByteArray & ) ), this, SLOT( slotData( KIO::Job *, const QByteArray & ) ) ); + connect( m_transferJob, SIGNAL( data( KIO::Job *, const TQByteArray & ) ), this, SLOT( slotData( KIO::Job *, const TQByteArray & ) ) ); connect( m_transferJob, SIGNAL( result( KIO::Job * ) ), this, SLOT( slotFinishedStartpage( KIO::Job * ) ) ); } @@ -151,10 +151,10 @@ namespace KBibTeX enterNextStage(); /** prepare next HTTP request for preferences page (buffer, signals, job) */ - m_transferJobBuffer = new QBuffer(); + m_transferJobBuffer = new TQBuffer(); m_transferJobBuffer->open( IO_WriteOnly ); KIO::TransferJob* m_transferJob = KIO::get( KURL( "http://scholar.google.com/scholar_preferences?hl=en" ), false, false ); - connect( m_transferJob, SIGNAL( data( KIO::Job *, const QByteArray & ) ), this, SLOT( slotData( KIO::Job *, const QByteArray & ) ) ); + connect( m_transferJob, SIGNAL( data( KIO::Job *, const TQByteArray & ) ), this, SLOT( slotData( KIO::Job *, const TQByteArray & ) ) ); connect( m_transferJob, SIGNAL( result( KIO::Job * ) ), this, SLOT( slotFinishedLoadingSettings( KIO::Job * ) ) ); } @@ -163,7 +163,7 @@ namespace KBibTeX { /** close and delete buffer (content does not matter) */ m_transferJobBuffer->close(); - QString htmlCode = textFromBuffer( m_transferJobBuffer ); + TQString htmlCode = textFromBuffer( m_transferJobBuffer ); delete m_transferJobBuffer; /** if aborted in the mean time, clean up everything */ @@ -186,19 +186,19 @@ namespace KBibTeX enterNextStage(); /** parse html code to get form values */ - QMap<QString, QString> keyValues = evalFormFields( htmlCode ); + TQMap<TQString, TQString> keyValues = evalFormFields( htmlCode ); /** set form values for BibTeX search */ keyValues["scis"] = "yes"; keyValues["scisf"] = "4"; keyValues["submit"] = "Save+Preferences"; - keyValues["num"] = QString::number( m_numberOfResults ); + keyValues["num"] = TQString::number( m_numberOfResults ); /** prepare next HTTP request to submit preferences (buffer, signals, job) */ KURL nextUrl( formFieldsToUrl( "http://scholar.google.com/scholar_setprefs", keyValues ) ); - m_transferJobBuffer = new QBuffer(); + m_transferJobBuffer = new TQBuffer(); m_transferJobBuffer->open( IO_WriteOnly ); KIO::TransferJob* m_transferJob = KIO::get( nextUrl, false, false ); - connect( m_transferJob, SIGNAL( data( KIO::Job *, const QByteArray & ) ), this, SLOT( slotData( KIO::Job *, const QByteArray & ) ) ); + connect( m_transferJob, SIGNAL( data( KIO::Job *, const TQByteArray & ) ), this, SLOT( slotData( KIO::Job *, const TQByteArray & ) ) ); connect( m_transferJob, SIGNAL( result( KIO::Job * ) ), this, SLOT( slotFinishedSavingSettings( KIO::Job * ) ) ); } @@ -206,7 +206,7 @@ namespace KBibTeX { /** close and delete buffer (content does not matter) */ m_transferJobBuffer->close(); - QString htmlCode = textFromBuffer( m_transferJobBuffer ); + TQString htmlCode = textFromBuffer( m_transferJobBuffer ); delete m_transferJobBuffer; /** if aborted in the mean time, clean up everything */ @@ -229,17 +229,17 @@ namespace KBibTeX enterNextStage(); /** parse html code to get form values */ - QMap<QString, QString> keyValues = evalFormFields( htmlCode ); + TQMap<TQString, TQString> keyValues = evalFormFields( htmlCode ); /** set form values for search */ keyValues["q"] = m_searchTerm; - keyValues["num"] = QString::number( m_numberOfResults ); + keyValues["num"] = TQString::number( m_numberOfResults ); /** prepare next HTTP request for actual search (buffer, signals, job) */ KURL nextUrl( formFieldsToUrl( "http://scholar.google.com/scholar", keyValues ) ); - m_transferJobBuffer = new QBuffer(); + m_transferJobBuffer = new TQBuffer(); m_transferJobBuffer->open( IO_WriteOnly ); KIO::TransferJob* m_transferJob = KIO::get( nextUrl, false, false ); - connect( m_transferJob, SIGNAL( data( KIO::Job *, const QByteArray & ) ), this, SLOT( slotData( KIO::Job *, const QByteArray & ) ) ); + connect( m_transferJob, SIGNAL( data( KIO::Job *, const TQByteArray & ) ), this, SLOT( slotData( KIO::Job *, const TQByteArray & ) ) ); connect( m_transferJob, SIGNAL( result( KIO::Job * ) ), this, SLOT( slotFinishedReceivingResultOverview( KIO::Job * ) ) ); } @@ -247,7 +247,7 @@ namespace KBibTeX { /** close and delete buffer (content does not matter) */ m_transferJobBuffer->close(); - QString htmlCode = textFromBuffer( m_transferJobBuffer ); + TQString htmlCode = textFromBuffer( m_transferJobBuffer ); delete m_transferJobBuffer; /** if aborted in the mean time, clean up everything */ @@ -270,7 +270,7 @@ namespace KBibTeX enterNextStage(); /** find all links to BibTeX files in result page */ - QRegExp reBibUrl( "/scholar.bib[^ \">]+" ); + TQRegExp reBibUrl( "/scholar.bib[^ \">]+" ); int pos = 0; while ( !m_aborted && ( pos = htmlCode.find( reBibUrl, pos + 1 ) ) > 0 ) { @@ -311,12 +311,12 @@ namespace KBibTeX cfg.setGroup( "Cookie Policy" ); m_originalEnableCookies = cfg.readBoolEntry( "Cookies", true ); m_originalSessionCookies = cfg.readBoolEntry( "AcceptSessionCookies", true ); - QStringList cookieSettingsList = QStringList::split( ',', cfg.readEntry( "CookieDomainAdvice", "" ) ); + TQStringList cookieSettingsList = TQStringList::split( ',', cfg.readEntry( "CookieDomainAdvice", "" ) ); m_originalCookieGlobalAdvice = cfg.readEntry( "CookieGlobalAdvice", "Accept" ); - for ( QStringList::Iterator it = cookieSettingsList.begin(); it != cookieSettingsList.end(); ++it ) + for ( TQStringList::Iterator it = cookieSettingsList.begin(); it != cookieSettingsList.end(); ++it ) { - QStringList keyValue = QStringList::split( ':', *it ); + TQStringList keyValue = TQStringList::split( ':', *it ); if ( keyValue.size() == 2 ) { m_originalCookieMap[keyValue[0]] = keyValue[1]; @@ -327,9 +327,9 @@ namespace KBibTeX cfg.writeEntry( "CookieGlobalAdvice", "Accept" ); cfg.writeEntry( "AcceptSessionCookies", true ); cookieSettingsList.clear(); - for ( QMap<QString, QString>::Iterator it = m_originalCookieMap.begin(); it != m_originalCookieMap.end(); ++it ) + for ( TQMap<TQString, TQString>::Iterator it = m_originalCookieMap.begin(); it != m_originalCookieMap.end(); ++it ) { - QString value = it.key().contains( ".google." ) ? "Accept" : it.data(); + TQString value = it.key().contains( ".google." ) ? "Accept" : it.data(); cookieSettingsList << it.key() + ":" + value; } cfg.writeEntry( "CookieDomainAdvice", cookieSettingsList.join( "," ) ); @@ -345,8 +345,8 @@ namespace KBibTeX cfg.writeEntry( "CookieGlobalAdvice", m_originalCookieGlobalAdvice ); cfg.writeEntry( "Cookies", m_originalEnableCookies ); cfg.writeEntry( "AcceptSessionCookies", m_originalSessionCookies ); - QStringList cookieSettingsList; - for ( QMap<QString, QString>::Iterator it = m_originalCookieMap.begin(); it != m_originalCookieMap.end(); ++it ) + TQStringList cookieSettingsList; + for ( TQMap<TQString, TQString>::Iterator it = m_originalCookieMap.begin(); it != m_originalCookieMap.end(); ++it ) cookieSettingsList << it.key() + ":" + it.data(); cfg.writeEntry( "CookieDomainAdvice", cookieSettingsList.join( "," ) ); cfg.sync(); @@ -357,33 +357,33 @@ namespace KBibTeX ( void )DCOPRef( "kded", "kcookiejar" ).send( "reloadPolicy" ); } - QString WebQueryGoogleScholar::textFromBuffer( QBuffer *buffer ) + TQString WebQueryGoogleScholar::textFromBuffer( TQBuffer *buffer ) { - QString htmlCode = ""; + TQString htmlCode = ""; buffer->open( IO_ReadOnly ); - QTextStream ts( buffer ); + TQTextStream ts( buffer ); while ( !ts.atEnd() ) htmlCode.append( ts.readLine() ); buffer->close(); return htmlCode; } - QMap <QString, QString> WebQueryGoogleScholar::evalFormFields( const QString &htmlCode ) + TQMap <TQString, TQString> WebQueryGoogleScholar::evalFormFields( const TQString &htmlCode ) { - QMap<QString, QString> keyValues; + TQMap<TQString, TQString> keyValues; - QRegExp reInput( "<input[^>]+>" ); - QRegExp reSplit( "[<>=\" ]+" ); + TQRegExp reInput( "<input[^>]+>" ); + TQRegExp reSplit( "[<>=\" ]+" ); int pos = 0; while (( pos = htmlCode.find( reInput, pos + 1 ) ) > 5 ) { - QStringList elements = QStringList::split( reSplit, reInput.cap( 0 ) ); + TQStringList elements = TQStringList::split( reSplit, reInput.cap( 0 ) ); bool checked = false; bool isCheckable = false; bool isSubmit = false; - QString key = QString::null; - QString value = QString::null; - for ( QStringList::Iterator it = elements.begin(); it != elements.end(); ++it ) + TQString key = TQString::null; + TQString value = TQString::null; + for ( TQStringList::Iterator it = elements.begin(); it != elements.end(); ++it ) { if ( *it == "name" ) { @@ -406,27 +406,27 @@ namespace KBibTeX isSubmit = *it == "submit"; } } - if (( !isCheckable || checked ) && ( !isSubmit || value == "submit" ) && value != QString::null && key != QString::null ) + if (( !isCheckable || checked ) && ( !isSubmit || value == "submit" ) && value != TQString::null && key != TQString::null ) { keyValues[key] = value; } } - QRegExp reSelect( "<select name=([^ >\"]+).*</select>" ); + TQRegExp reSelect( "<select name=([^ >\"]+).*</select>" ); reSelect.setMinimal( true ); - QRegExp reOption( "<option[^>]+>" ); + TQRegExp reOption( "<option[^>]+>" ); int pos3 = 0; while (( pos3 = htmlCode.find( reSelect, pos3 + 1 ) ) > 5 ) { - QString key = reSelect.cap( 1 ); - QString sub = reSelect.cap( 0 ); + TQString key = reSelect.cap( 1 ); + TQString sub = reSelect.cap( 0 ); int pos2 = 0; while (( pos2 = sub.find( reOption, pos2 + 1 ) ) > 5 ) { - QStringList elements = QStringList::split( reSplit, reOption.cap( 0 ) ); + TQStringList elements = TQStringList::split( reSplit, reOption.cap( 0 ) ); bool selected = false; - QString value = QString::null; - for ( QStringList::Iterator it = elements.begin(); it != elements.end(); ++it ) + TQString value = TQString::null; + for ( TQStringList::Iterator it = elements.begin(); it != elements.end(); ++it ) { if ( *it == "value" ) { @@ -438,7 +438,7 @@ namespace KBibTeX if ( *it == "selected" ) selected = true; } - if ( selected && value != QString::null && key != QString::null ) + if ( selected && value != TQString::null && key != TQString::null ) { keyValues[key] = value; } @@ -448,11 +448,11 @@ namespace KBibTeX return keyValues; } - QString WebQueryGoogleScholar::formFieldsToUrl( const QString &prefix, const QMap<QString, QString> &keyValues ) + TQString WebQueryGoogleScholar::formFieldsToUrl( const TQString &prefix, const TQMap<TQString, TQString> &keyValues ) { bool first = true; - QString nextUrl = prefix; - for ( QMap<QString, QString>::ConstIterator it = keyValues.begin(); it != keyValues.end(); ++it ) + TQString nextUrl = prefix; + for ( TQMap<TQString, TQString>::ConstIterator it = keyValues.begin(); it != keyValues.end(); ++it ) { if ( first ) nextUrl.append( "?" ); |