summaryrefslogtreecommitdiffstats
path: root/src/fileimporterbibutils.cpp
diff options
context:
space:
mode:
authorSlávek Banko <slavek.banko@axis.cz>2013-06-29 12:56:53 +0200
committerSlávek Banko <slavek.banko@axis.cz>2013-07-04 03:11:35 +0200
commit5f5e7c5455d52826b0bd50f64fcffb7695ce970d (patch)
treec8ee8792d3fb139365abbf70c2255f1e69d2aa34 /src/fileimporterbibutils.cpp
parent251c9a439759c830d34c70683d0fc9454d703010 (diff)
downloadkbibtex-5f5e7c5455d52826b0bd50f64fcffb7695ce970d.tar.gz
kbibtex-5f5e7c5455d52826b0bd50f64fcffb7695ce970d.zip
Initial TQt conversion
Diffstat (limited to 'src/fileimporterbibutils.cpp')
-rw-r--r--src/fileimporterbibutils.cpp104
1 files changed, 52 insertions, 52 deletions
diff --git a/src/fileimporterbibutils.cpp b/src/fileimporterbibutils.cpp
index bd2b622..52195b3 100644
--- a/src/fileimporterbibutils.cpp
+++ b/src/fileimporterbibutils.cpp
@@ -19,13 +19,13 @@
***************************************************************************/
#include <stdio.h>
-#include <qfile.h>
-#include <qdir.h>
-#include <qprocess.h>
-#include <qstringlist.h>
-#include <qbuffer.h>
-#include <qwaitcondition.h>
-#include <qapplication.h>
+#include <ntqfile.h>
+#include <ntqdir.h>
+#include <ntqprocess.h>
+#include <ntqstringlist.h>
+#include <ntqbuffer.h>
+#include <ntqwaitcondition.h>
+#include <ntqapplication.h>
#include <file.h>
#include <encoderlatex.h>
@@ -37,7 +37,7 @@ namespace BibTeX
FileImporterBibUtils::FileImporterBibUtils( BibTeX::File::FileFormat inputFormat )
: FileImporter(), m_workingDir( createTempDir() ), m_inputFormat( inputFormat ), m_bibTeXImporter( new FileImporterBibTeX( false, "utf-8" ) )
{
- m_processBuffer = new QBuffer();
+ m_processBuffer = new TQBuffer();
}
FileImporterBibUtils::~FileImporterBibUtils()
@@ -47,17 +47,17 @@ namespace BibTeX
delete m_bibTeXImporter;
}
- File* FileImporterBibUtils::load( QIODevice *iodevice )
+ File* FileImporterBibUtils::load( TQIODevice *iodevice )
{
m_cancelFlag = false;
if ( !iodevice->isReadable() )
{
- qDebug( "iodevice is not readable" );
+ tqDebug( "iodevice is not readable" );
return NULL;
}
if ( !iodevice->isOpen() )
{
- qDebug( "iodevice is not open" );
+ tqDebug( "iodevice is not open" );
return NULL;
}
@@ -67,12 +67,12 @@ namespace BibTeX
return xmlBufferToBibTeXFile();
}
- bool FileImporterBibUtils::guessCanDecode( const QString & text )
+ bool FileImporterBibUtils::guessCanDecode( const TQString & text )
{
return guessInputFormat( text ) != BibTeX::File::formatUndefined;
}
- File::FileFormat FileImporterBibUtils::guessInputFormat( const QString &text )
+ File::FileFormat FileImporterBibUtils::guessInputFormat( const TQString &text )
{
if ( text.find( "TY - " ) >= 0 )
return BibTeX::File::formatRIS;
@@ -90,37 +90,37 @@ namespace BibTeX
m_cancelFlag = true;
}
- bool FileImporterBibUtils::iodeviceToXMLbuffer( QIODevice *iodevice )
+ bool FileImporterBibUtils::iodeviceToXMLbuffer( TQIODevice *iodevice )
{
- QWaitCondition wc;
+ TQWaitCondition wc;
m_processBuffer->open( IO_WriteOnly );
m_process = NULL;
switch ( m_inputFormat )
{
case BibTeX::File::formatISI:
- m_process = new QProcess( QStringList::split( ' ', "isi2xml -i utf8 -u" ) );
+ m_process = new TQProcess( TQStringList::split( ' ', "isi2xml -i utf8 -u" ) );
break;
case BibTeX::File::formatWordBib:
- m_process = new QProcess( QStringList::split( ' ', "wordbib2xml -i utf8 -u" ) );
+ m_process = new TQProcess( TQStringList::split( ' ', "wordbib2xml -i utf8 -u" ) );
break;
case BibTeX::File::formatAds:
- m_process = new QProcess( QStringList::split( ' ', "ads2xml -i utf8 -u" ) );
+ m_process = new TQProcess( TQStringList::split( ' ', "ads2xml -i utf8 -u" ) );
break;
case BibTeX::File::formatEndNote:
- m_process = new QProcess( QStringList::split( ' ', "end2xml -i utf8 -u" ) );
+ m_process = new TQProcess( TQStringList::split( ' ', "end2xml -i utf8 -u" ) );
break;
case BibTeX::File::formatEndNoteXML:
- m_process = new QProcess( QStringList::split( ' ', "endx2xml -i utf8 -u" ) );
+ m_process = new TQProcess( TQStringList::split( ' ', "endx2xml -i utf8 -u" ) );
break;
case BibTeX::File::formatRIS:
- m_process = new QProcess( QStringList::split( ' ', "ris2xml -i utf8 -u" ) );
+ m_process = new TQProcess( TQStringList::split( ' ', "ris2xml -i utf8 -u" ) );
break;
case BibTeX::File::formatMODS:
/* m_process = NULL; */
break;
default:
- qDebug( "Cannot handle input format %i", m_inputFormat );
+ tqDebug( "Cannot handle input format %i", m_inputFormat );
return false;
}
@@ -134,16 +134,16 @@ namespace BibTeX
m_process->start();
if ( m_process->isRunning() )
{
- QByteArray inData = iodevice->readAll();
+ TQByteArray inData = iodevice->readAll();
m_process->writeToStdin( inData );
- qApp->processEvents();
+ tqApp->processEvents();
m_process->closeStdin();
int nothingHappens = 20;
while ( m_waiting )
{
wc.wait( 250 );
- qApp->processEvents();
+ tqApp->processEvents();
--nothingHappens;
}
@@ -152,14 +152,14 @@ namespace BibTeX
if ( !m_process->normalExit() )
{
- qDebug( "%s did not exit in a clean fashion", m_process->arguments()[0].latin1() );
+ tqDebug( "%s did not exit in a clean fashion", m_process->arguments()[0].latin1() );
delete m_process;
return false;
}
}
else
{
- qDebug( "%s did not start", m_process->arguments()[0].latin1() );
+ tqDebug( "%s did not start", m_process->arguments()[0].latin1() );
delete m_process;
return false;
}
@@ -177,22 +177,22 @@ namespace BibTeX
BibTeX::File* FileImporterBibUtils::xmlBufferToBibTeXFile()
{
- QWaitCondition wc;
+ TQWaitCondition wc;
m_waiting = true;
- m_process = new QProcess( QStringList::split( ' ', "xml2bib -i utf8 -o utf8 -sk" ) );
+ m_process = new TQProcess( TQStringList::split( ' ', "xml2bib -i utf8 -o utf8 -sk" ) );
connect( m_process, SIGNAL( processExited() ), this, SLOT( wakeUp() ) );
connect( m_process, SIGNAL( readyReadStdout() ), this, SLOT( slotReadyStdout() ) );
connect( m_process, SIGNAL( readyReadStderr() ), this, SLOT( slotReadyStderr() ) );
if ( m_process->start() )
{
- QBuffer *tempBuffer = m_processBuffer;
- m_processBuffer = new QBuffer();
+ TQBuffer *tempBuffer = m_processBuffer;
+ m_processBuffer = new TQBuffer();
tempBuffer->open( IO_ReadOnly );
m_process->writeToStdin( tempBuffer->readAll() );
- qApp->processEvents();
+ tqApp->processEvents();
m_process->closeStdin();
tempBuffer->close();
@@ -201,7 +201,7 @@ namespace BibTeX
while ( m_waiting )
{
wc.wait( 250 );
- qApp->processEvents();
+ tqApp->processEvents();
--nothingHappens;
}
m_processBuffer->close();
@@ -234,20 +234,20 @@ namespace BibTeX
return NULL;
}
- QString FileImporterBibUtils::createTempDir()
+ TQString FileImporterBibUtils::createTempDir()
{
- QString result = QString::null;
- QFile *devrandom = new QFile( "/dev/random" );
+ TQString result = TQString::null;
+ TQFile *devrandom = new TQFile( "/dev/random" );
if ( devrandom->open( IO_ReadOnly ) )
{
- Q_UINT32 randomNumber;
+ TQ_UINT32 randomNumber;
if ( devrandom->readBlock(( char* ) & randomNumber, sizeof( randomNumber ) ) > 0 )
{
randomNumber |= 0x10000000;
- result = QString( "/tmp/bibtex-%1" ).arg( randomNumber, sizeof( randomNumber ) * 2, 16 );
- if ( !QDir().mkdir( result ) )
- result = QString::null;
+ result = TQString( "/tmp/bibtex-%1" ).arg( randomNumber, sizeof( randomNumber ) * 2, 16 );
+ if ( !TQDir().mkdir( result ) )
+ result = TQString::null;
}
devrandom->close();
}
@@ -257,20 +257,20 @@ namespace BibTeX
return result;
}
- void FileImporterBibUtils::deleteTempDir( const QString& directory )
+ void FileImporterBibUtils::deleteTempDir( const TQString& directory )
{
- QDir dir = QDir( directory );
- QStringList subDirs = dir.entryList( QDir::Dirs );
- for ( QStringList::Iterator it = subDirs.begin(); it != subDirs.end(); it++ )
+ TQDir dir = TQDir( directory );
+ TQStringList subDirs = dir.entryList( TQDir::Dirs );
+ for ( TQStringList::Iterator it = subDirs.begin(); it != subDirs.end(); it++ )
{
- if (( QString::compare( *it, "." ) != 0 ) && ( QString::compare( *it, ".." ) != 0 ) )
+ if (( TQString::compare( *it, "." ) != 0 ) && ( TQString::compare( *it, ".." ) != 0 ) )
deleteTempDir( *it );
}
- QStringList allEntries = dir.entryList( QDir::All );
- for ( QStringList::Iterator it = allEntries.begin(); it != allEntries.end(); it++ )
+ TQStringList allEntries = dir.entryList( TQDir::All );
+ for ( TQStringList::Iterator it = allEntries.begin(); it != allEntries.end(); it++ )
dir.remove( *it );
- QDir().rmdir( directory );
+ TQDir().rmdir( directory );
}
void FileImporterBibUtils::wakeUp()
@@ -285,10 +285,10 @@ namespace BibTeX
void FileImporterBibUtils::slotReadyStderr()
{
- QByteArray ba = m_process->readStderr();
- QTextStream bats( ba, IO_ReadOnly );
- bats.setEncoding( QTextStream::UnicodeUTF8 );
- qDebug( "%s", bats.read().latin1() );
+ TQByteArray ba = m_process->readStderr();
+ TQTextStream bats( ba, IO_ReadOnly );
+ bats.setEncoding( TQTextStream::UnicodeUTF8 );
+ tqDebug( "%s", bats.read().latin1() );
}
}