summaryrefslogtreecommitdiffstats
path: root/krename/batchrenamer.cpp
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-07-01 05:51:05 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-07-01 05:51:05 +0000
commitce0c60d7b9a0be4dd17c25bf627d807d9432d953 (patch)
treef04fe60da1d1207732afec16a35d8d32323f20c4 /krename/batchrenamer.cpp
parentf8b5e2400a066271276cf2712aaf9788f5ac5ac1 (diff)
downloadkrename-ce0c60d7b9a0be4dd17c25bf627d807d9432d953.tar.gz
krename-ce0c60d7b9a0be4dd17c25bf627d807d9432d953.zip
TQt4 port krename
This enables compilation under both Qt3 and Qt4 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/krename@1238984 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'krename/batchrenamer.cpp')
-rw-r--r--krename/batchrenamer.cpp306
1 files changed, 128 insertions, 178 deletions
diff --git a/krename/batchrenamer.cpp b/krename/batchrenamer.cpp
index 89721e0..cf2941e 100644
--- a/krename/batchrenamer.cpp
+++ b/krename/batchrenamer.cpp
@@ -33,8 +33,8 @@
#include <sys/stat.h>
// QT includes
-#include <qdir.h>
-#include <qregexp.h>
+#include <tqdir.h>
+#include <tqregexp.h>
// KDE includes
#include <kapplication.h>
@@ -62,7 +62,7 @@ BatchRenamer::~BatchRenamer()
{
}
-void BatchRenamer::processFiles( ProgressDialog* p, QObject* object )
+void BatchRenamer::processFiles( ProgressDialog* p, TQObject* object )
{
delete object;
t.start();
@@ -76,7 +76,7 @@ void BatchRenamer::processFiles( ProgressDialog* p, QObject* object )
if( m_mode == RENAME ) {// final Path = source Path
m_files[i].dst.directory = m_files[i].src.directory;
m_files[i].dst.url = m_files[i].src.url;
- m_files[i].dst.url.setFileName( QString::null );
+ m_files[i].dst.url.setFileName( TQString() );
} else {
m_files[i].dst.directory = dirname.path();
m_files[i].dst.url = dirname;
@@ -118,19 +118,19 @@ void BatchRenamer::processFiles( ProgressDialog* p, QObject* object )
if( m_files[c].src.directory.left( m_files[i].src.name.length() + 1 )
== ( m_files[i].src.name + "/" ) ) {
- m_files[c].src.directory.replace( 0, m_files[i].src.name.length(), m_files[i].dst.name );
+ m_files[c].src.directory.tqreplace( 0, m_files[i].src.name.length(), m_files[i].dst.name );
m_files[c].src.url.setPath( BatchRenamer::buildFilename( &m_files[c].src, true ) );
}
}
}
}
- p->print( QString( i18n("Filenames Processed after %1 seconds.")).arg(t.elapsed()/1000) );
+ p->print( TQString( i18n("Filenames Processed after %1 seconds.")).tqarg(t.elapsed()/1000) );
work( p );
}
-QString BatchRenamer::processString( QString text, QString oldname, int i )
+TQString BatchRenamer::processString( TQString text, TQString oldname, int i )
{
/*
* Come on! Grep for this text and help me!
@@ -140,7 +140,7 @@ QString BatchRenamer::processString( QString text, QString oldname, int i )
*
* Krename will have problems with files
* which contain one of the following
- * unicode characters: 60000, 60001, 60002
+ * tqunicode characters: 60000, 60001, 60002
* 60003, 60004, 60005, 60006.
*
* This is not a good solution, if you have a
@@ -180,10 +180,10 @@ QString BatchRenamer::processString( QString text, QString oldname, int i )
return text;
}
-QString BatchRenamer::parsePlugins( int i, const QString& text, int type )
+TQString BatchRenamer::parsePlugins( int i, const TQString& text, int type )
{
- QPtrListIterator<PluginLoader::PluginLibrary> it( plug->libs );
- QString ret = text;
+ TQPtrListIterator<PluginLoader::PluginLibrary> it( plug->libs );
+ TQString ret = text;
if( type == TYPE_FINAL_FILE )
ret = "";
@@ -198,10 +198,10 @@ QString BatchRenamer::parsePlugins( int i, const QString& text, int type )
return ret;
}
-void BatchRenamer::createPreview( QListView* list )
+void BatchRenamer::createPreview( TQListView* list )
{
KMyListViewItem* item1 = NULL;
- QString tmp;
+ TQString tmp;
m_counters.clear();
for( unsigned int i = 0; i < m_files.count(); i++)
@@ -218,12 +218,12 @@ void BatchRenamer::createPreview( QListView* list )
bool modified = applyManualChanges( i );
- QString sname = BatchRenamer::buildFilename( &m_files[i].src, false );
+ TQString sname = BatchRenamer::buildFilename( &m_files[i].src, false );
// Let's run the plugins that change the final filename,
// i.e the encodingsplugin
m_files[i].dst.name = parsePlugins( i, m_files[i].dst.name, TYPE_FINAL_FILENAME );
- QString dname = BatchRenamer::buildFilename( &m_files[i].dst, false );
+ TQString dname = BatchRenamer::buildFilename( &m_files[i].dst, false );
item1 = new KMyListViewItem( modified, list, item1, sname, dname );
}
@@ -234,14 +234,14 @@ void BatchRenamer::work( ProgressDialog* p )
// TODO: use CopyJob here
FileOperation fop;
- QFile* fundo ( NULL );
- QTextStream* tundo ( NULL );
+ TQFile* fundo ( NULL );
+ TQTextStream* tundo ( NULL );
if( undo ) {
// Create header for undo script
- fundo = new QFile( m_undoScript );
+ fundo = new TQFile( m_undoScript );
if( fundo->open( IO_WriteOnly ) ) {
- tundo = new QTextStream( fundo );
+ tundo = new TQTextStream( fundo );
writeUndoScript( tundo );
} else {
undo = false;
@@ -258,11 +258,11 @@ void BatchRenamer::work( ProgressDialog* p )
* Give the user some information...
*/
if( m_mode == COPY)
- p->print( QString( i18n("Files will be copied to: %1") ).arg(m_files[0].dst.directory) );
+ p->print( TQString( i18n("Files will be copied to: %1") ).tqarg(m_files[0].dst.directory) );
else if( m_mode == MOVE )
- p->print( QString( i18n("Files will be moved to: %1") ).arg(m_files[0].dst.directory) );
+ p->print( TQString( i18n("Files will be moved to: %1") ).tqarg(m_files[0].dst.directory) );
else if( m_mode == LINK )
- p->print( QString( i18n("Symbolic links will be created in: %1") ).arg(m_files[0].dst.directory) );
+ p->print( TQString( i18n("Symbolic links will be created in: %1") ).tqarg(m_files[0].dst.directory) );
else if( m_mode == RENAME )
p->print( i18n("Input files will be renamed.") );
@@ -302,7 +302,7 @@ void BatchRenamer::work( ProgressDialog* p )
* The plugin should return an error message in this case!
*/
- QString eplug = parsePlugins( i, QString::null, TYPE_FINAL_FILE );
+ TQString eplug = parsePlugins( i, TQString(), TYPE_FINAL_FILE );
if( !eplug.isEmpty() ) {
p->error( eplug );
error++;
@@ -317,25 +317,25 @@ void BatchRenamer::work( ProgressDialog* p )
(*tundo) << "mv --force -b --suffix=.krename_ \"" << m_files[i].dst.name
<< "\" \"" << m_files[i].src.name << "\"" << endl;
} else
- p->warning( QString( i18n("Undo is not possible for remote file: %1") ).arg( dst.prettyURL() ) );
+ p->warning( TQString( i18n("Undo is not possible for remote file: %1") ).tqarg( dst.prettyURL() ) );
}
if( !p->wasCancelled() ) {
- QPtrListIterator<PluginLoader::PluginLibrary> it( plug->libs );
+ TQPtrListIterator<PluginLoader::PluginLibrary> it( plug->libs );
for( ; it.current(); ++it ) {
if( (*it)->usePlugin )
(*it)->plugin->finished();
}
}
- const QString m = QString( i18n("Renamed %1 files successfully.") ).arg(i-error);
+ const TQString m = TQString( i18n("Renamed %1 files successfully.") ).tqarg(i-error);
( i - error ) ? p->print( m ) : p->warning( m );
if( error > 0 )
- p->warning( QString( i18n("%2 errors occurred!") ).arg(error));
+ p->warning( TQString( i18n("%2 errors occurred!") ).tqarg(error));
- p->print( QString( i18n("Elapsed time: %1 seconds") ).arg( t.elapsed()/1000 ), "kalarm" );
+ p->print( TQString( i18n("Elapsed time: %1 seconds") ).tqarg( t.elapsed()/1000 ), "kalarm" );
p->print( i18n("KRename finished the renaming process."), "krename" );
p->print( i18n("Press close to quit!") );
p->setRenamedFiles( renamedFiles, m_files.count() );
@@ -356,105 +356,81 @@ void BatchRenamer::work( ProgressDialog* p )
delete this;
}
-void BatchRenamer::escape( QString & text, const QString & token, const QString & sequence )
+void BatchRenamer::escape( TQString & text, const TQString & token, const TQString & sequence )
{
- /*
- * NEVER, ABSOLUTELY NEVER change pos = 0
- * to pos = -1, it won't work !
- * This bug took hours to find and was
- * a serious bug in 1.7.
- */
-#if QT_VERSION >= 0x030100
- text.replace( token, sequence );
-#else
- int pos = 0;
- do {
- pos = text.find( token, pos );
- if( pos >= 0 )
- text.replace( pos, token.length(), sequence );
- } while ( pos >= 0 );
-#endif
+ text.tqreplace( token, sequence );
}
-QString & BatchRenamer::doEscape( QString & text, bool filename )
+TQString & BatchRenamer::doEscape( TQString text, bool filename )
{
if( filename ) {
- BatchRenamer::escape( text, "&", QChar( 60000 ) );
- BatchRenamer::escape( text, "$", QChar( 60001 ) );
- BatchRenamer::escape( text, "%", QChar( 60002 ) );
- BatchRenamer::escape( text, "#", QChar( 60004 ) );
- BatchRenamer::escape( text, "[", QChar( 60005 ) );
- BatchRenamer::escape( text, "]", QChar( 60006 ) );
- BatchRenamer::escape( text, "\\", QChar( 60007 ) );
- BatchRenamer::escape( text, "/", QChar( 60008 ) );
- BatchRenamer::escape( text, "{", QChar( 60009 ) );
- BatchRenamer::escape( text, "}", QChar( 60010 ) );
- BatchRenamer::escape( text, "*", QChar( 60011 ) );
+ BatchRenamer::escape( text, "&", TQChar( 60000 ) );
+ BatchRenamer::escape( text, "$", TQChar( 60001 ) );
+ BatchRenamer::escape( text, "%", TQChar( 60002 ) );
+ BatchRenamer::escape( text, "#", TQChar( 60004 ) );
+ BatchRenamer::escape( text, "[", TQChar( 60005 ) );
+ BatchRenamer::escape( text, "]", TQChar( 60006 ) );
+ BatchRenamer::escape( text, "\\", TQChar( 60007 ) );
+ BatchRenamer::escape( text, "/", TQChar( 60008 ) );
+ BatchRenamer::escape( text, "{", TQChar( 60009 ) );
+ BatchRenamer::escape( text, "}", TQChar( 60010 ) );
+ BatchRenamer::escape( text, "*", TQChar( 60011 ) );
} else {
- BatchRenamer::escape( text, "\\&", QChar( 60000 ) );
- BatchRenamer::escape( text, "\\$", QChar( 60001 ) );
- BatchRenamer::escape( text, "\\%", QChar( 60002 ) );
- BatchRenamer::escape( text, "\\#", QChar( 60004 ) );
- BatchRenamer::escape( text, "\\[", QChar( 60005 ) );
- BatchRenamer::escape( text, "\\]", QChar( 60006 ) );
- BatchRenamer::escape( text, "\\\\", QChar( 60007 ) );
- BatchRenamer::escape( text, "\\/", QChar( 60008 ) );
- BatchRenamer::escape( text, "\\{", QChar( 60009 ) );
- BatchRenamer::escape( text, "\\}", QChar( 60010 ) );
- BatchRenamer::escape( text, "\\*", QChar( 60011 ) );
+ BatchRenamer::escape( text, "\\&", TQChar( 60000 ) );
+ BatchRenamer::escape( text, "\\$", TQChar( 60001 ) );
+ BatchRenamer::escape( text, "\\%", TQChar( 60002 ) );
+ BatchRenamer::escape( text, "\\#", TQChar( 60004 ) );
+ BatchRenamer::escape( text, "\\[", TQChar( 60005 ) );
+ BatchRenamer::escape( text, "\\]", TQChar( 60006 ) );
+ BatchRenamer::escape( text, "\\\\", TQChar( 60007 ) );
+ BatchRenamer::escape( text, "\\/", TQChar( 60008 ) );
+ BatchRenamer::escape( text, "\\{", TQChar( 60009 ) );
+ BatchRenamer::escape( text, "\\}", TQChar( 60010 ) );
+ BatchRenamer::escape( text, "\\*", TQChar( 60011 ) );
}
return text;
}
-QString & BatchRenamer::unEscape( QString & text )
+TQString & BatchRenamer::unEscape( TQString & text )
{
- BatchRenamer::escape( text, QChar( 60000 ), "&" );
- BatchRenamer::escape( text, QChar( 60001 ), "$" );
- BatchRenamer::escape( text, QChar( 60002 ), "%" );
- BatchRenamer::escape( text, QChar( 60004 ), "#" );
- BatchRenamer::escape( text, QChar( 60005 ), "[" );
- BatchRenamer::escape( text, QChar( 60006 ), "]" );
- BatchRenamer::escape( text, QChar( 60007 ), "\\" );
+ BatchRenamer::escape( text, TQChar( 60000 ), "&" );
+ BatchRenamer::escape( text, TQChar( 60001 ), "$" );
+ BatchRenamer::escape( text, TQChar( 60002 ), "%" );
+ BatchRenamer::escape( text, TQChar( 60004 ), "#" );
+ BatchRenamer::escape( text, TQChar( 60005 ), "[" );
+ BatchRenamer::escape( text, TQChar( 60006 ), "]" );
+ BatchRenamer::escape( text, TQChar( 60007 ), "\\" );
// %252f == /, it seems that filenames on unix cannot contain
// a /. So I use %252f, at least konqui displays it correctly
// this was needed, so that plugins that return a slash do not cause errors
- BatchRenamer::escape( text, QChar( 60008 ), "%2f" );
- BatchRenamer::escape( text, QChar( 60009 ), "{" );
- BatchRenamer::escape( text, QChar( 60010 ), "}" );
- BatchRenamer::escape( text, QChar( 60011 ), "*" );
+ BatchRenamer::escape( text, TQChar( 60008 ), "%2f" );
+ BatchRenamer::escape( text, TQChar( 60009 ), "{" );
+ BatchRenamer::escape( text, TQChar( 60010 ), "}" );
+ BatchRenamer::escape( text, TQChar( 60011 ), "*" );
return text;
}
int BatchRenamer::getCharacters( int n )
{
- QString s;
+ TQString s;
s.sprintf( "%i", n );
return s.length();
}
-QString BatchRenamer::findAndProcess( const QString & token, QString text, const QString & replace )
+TQString BatchRenamer::findAndProcess( const TQString & token, TQString text, const TQString & tqreplace )
{
/*
* pos can here be -1 because
- * findRev is called with it as a
+ * tqfindRev is called with it as a
* value !
*/
-#if QT_VERSION >= 0x030100
- text.replace( token, replace );
-#else
- int pos = -1;
- do {
- pos = text.findRev( token, pos );
- if( pos >= 0 )
- text.replace( pos, token.length(), replace );
- } while( pos >= 0 );
-#endif
+ text.tqreplace( token, tqreplace );
return text;
}
-QString BatchRenamer::findNumbers( QString text, int count, int i )
+TQString BatchRenamer::findNumbers( TQString text, int count, int i )
{
// Rewritten in Version 0.8
// Added numbers skipping in 1.3
@@ -464,10 +440,10 @@ QString BatchRenamer::findNumbers( QString text, int count, int i )
countervalues.start = m_index;
countervalues.step = m_step;
- if( text.contains( "#", FALSE ) <= 0 )
+ if( text.tqcontains( "#", FALSE ) <= 0 )
return text;
- pos = text.find("#", pos);
+ pos = text.tqfind("#", pos);
pos++;
while( text[pos] == '#' ) {
text.remove(pos, 1);
@@ -476,7 +452,7 @@ QString BatchRenamer::findNumbers( QString text, int count, int i )
findNumberAppendix( text, pos, &countervalues.start, &countervalues.step );
- pos = text.find("#", 0);
+ pos = text.tqfind("#", 0);
if( (signed int)m_counters.count() <= m_counter_index )
{
@@ -488,7 +464,7 @@ QString BatchRenamer::findNumbers( QString text, int count, int i )
do {
m_counters[m_counter_index].value += m_counters[m_counter_index].step;
- } while( m_skip.contains( m_counters[m_counter_index].value ) );
+ } while( m_skip.tqcontains( m_counters[m_counter_index].value ) );
/*
int v = start + (i*step) + m_skip_add[m_counter_index];
@@ -500,22 +476,22 @@ QString BatchRenamer::findNumbers( QString text, int count, int i )
}
*/
- QString temp;
+ TQString temp;
temp.sprintf("%0*i", counter, m_counters[m_counter_index].value );
- text.replace( pos, 1, temp);
+ text.tqreplace( pos, 1, temp);
++m_counter_index;
return findNumbers( text, count, i );
}
-void BatchRenamer::findNumberAppendix( QString & text, int pos, int* start, int* step )
+void BatchRenamer::findNumberAppendix( TQString & text, int pos, int* start, int* step )
{
- QString appendix = QString::null;
+ TQString appendix = TQString();
int tmp = 0;
int end = 0;
bool ok = false;
- if( text[pos] == '{' && (end = text.find( "}", pos )) > -1)
+ if( text[pos] == '{' && (end = text.tqfind( "}", pos )) > -1)
{
//qDebug("Found an appendix:" + appendix );
appendix = text.mid( pos + 1, end - pos - 1);
@@ -531,13 +507,13 @@ void BatchRenamer::findNumberAppendix( QString & text, int pos, int* start, int*
}
}
-QString BatchRenamer::findStar( const QString & oldname, QString text )
+TQString BatchRenamer::findStar( const TQString & oldname, TQString text )
{
int pos = -1;
do {
- pos = text.findRev("*", pos);
+ pos = text.tqfindRev("*", pos);
if( pos >= 0 ) {
- QString tmp = oldname.lower();
+ TQString tmp = oldname.lower();
if( tmp[0].isLetter() )
tmp[0] = tmp[0].upper();
@@ -546,13 +522,13 @@ QString BatchRenamer::findStar( const QString & oldname, QString text )
tmp[i] != '\'' && tmp[i] != '?' && tmp[i] != '`' )
tmp[i+1] = tmp[i+1].upper();
- text.replace( pos, 1, tmp);
+ text.tqreplace( pos, 1, tmp);
}
} while( pos >= 0 );
return text;
}
-QString BatchRenamer::findBrackets( QString oldname, QString text, int i )
+TQString BatchRenamer::findBrackets( TQString oldname, TQString text, int i )
{
/*
* looks for a statement in brackets [ ]
@@ -560,17 +536,17 @@ QString BatchRenamer::findBrackets( QString oldname, QString text, int i )
*/
int num, pos = -1, a;
- QString token;
+ TQString token;
- if( text.contains("]", FALSE) <= 0 || text.isEmpty() )
+ if( text.tqcontains("]", FALSE) <= 0 || text.isEmpty() )
return text;
- num = text.contains("[", FALSE);
+ num = text.tqcontains("[", FALSE);
if(num <= 0 )
return text;
- pos = text.findRev("[", pos);
- a = text.find("]", pos );
+ pos = text.tqfindRev("[", pos);
+ a = text.tqfind("]", pos );
if( a < 0 && pos >= 0 )
return text;
@@ -589,9 +565,9 @@ QString BatchRenamer::findBrackets( QString oldname, QString text, int i )
return findBrackets( oldname, text, i );
}
-QString BatchRenamer::processToken( QString token, QString oldname, int i )
+TQString BatchRenamer::processToken( TQString token, TQString oldname, int i )
{
- QString tmp;
+ TQString tmp;
/*
* Call here all functions that handle
@@ -625,10 +601,10 @@ QString BatchRenamer::processToken( QString token, QString oldname, int i )
* Krename simply ignores unknown tokens!
* Usefull for the MP3 Plugin!
*/
- return QString::null;
+ return TQString();
}
-QString BatchRenamer::findToken( QString oldname, QString token, int i )
+TQString BatchRenamer::findToken( TQString oldname, TQString token, int i )
{
enum conversion { LOWER, UPPER, MIXED, STAR, STRIP, NONE, EMPTY, NUMBER };
unsigned int numwidth = 0;
@@ -658,7 +634,7 @@ QString BatchRenamer::findToken( QString oldname, QString token, int i )
if( c != EMPTY && c != NUMBER )
token.remove( 0, 1 );
- QString save = token;
+ TQString save = token;
token = processToken( token, oldname, i );
switch( c ) {
@@ -670,7 +646,7 @@ QString BatchRenamer::findToken( QString oldname, QString token, int i )
break;
case MIXED:
token = token.lower();
- token.replace( 0, 1, token[0].upper());
+ token.tqreplace( 0, 1, token[0].upper());
break;
case STAR:
token = findStar( token, "*" );
@@ -694,20 +670,20 @@ QString BatchRenamer::findToken( QString oldname, QString token, int i )
return token;
}
-QString BatchRenamer::findPartStrings( QString oldname, QString token )
+TQString BatchRenamer::findPartStrings( TQString oldname, TQString token )
{
- QString first, second;
+ TQString first, second;
int pos = -1;
// parse things like [2;4{[dirname]}]
- if( token.contains( "{" ) >= 1 && token.contains( "}" ) >= 1 ) {
- int pos = token.find( "{" );
- oldname = token.mid( pos + 1, token.findRev( "}" ) - pos - 1 );
+ if( token.tqcontains( "{" ) >= 1 && token.tqcontains( "}" ) >= 1 ) {
+ int pos = token.tqfind( "{" );
+ oldname = token.mid( pos + 1, token.tqfindRev( "}" ) - pos - 1 );
token = token.left( pos );
}
- if( token.contains("-") ) {
- pos = token.find( "-", 0 );
+ if( token.tqcontains("-") ) {
+ pos = token.tqfind( "-", 0 );
first = token.left( pos );
// ------- Code OK ^ !
@@ -741,8 +717,8 @@ QString BatchRenamer::findPartStrings( QString oldname, QString token )
x++;
return oldname.mid( first.toInt()-1, x );
- } else if( token.contains(";") ) {
- pos = token.find( ";", 0 );
+ } else if( token.tqcontains(";") ) {
+ pos = token.tqfind( ";", 0 );
first = token.left( pos );
second = token.mid( pos+1, token.length() );
@@ -753,13 +729,13 @@ QString BatchRenamer::findPartStrings( QString oldname, QString token )
int number = token.toInt( &ok );
if( ok && (number <= (signed int)oldname.length() && number > 0 ) )
- return QString(oldname[ number -1 ]);
+ return TQString(oldname[ number -1 ]);
else
- return QString::null;
+ return TQString();
}
}
-QString BatchRenamer::findDirName( QString token, QString path )
+TQString BatchRenamer::findDirName( TQString token, TQString path )
{
if( token.left( 7 ).lower() == "dirname" ) {
if( path.right( 1 ) == "/" )
@@ -768,9 +744,9 @@ QString BatchRenamer::findDirName( QString token, QString path )
int recursion = 1;
if( token.length() > 7 ) {
token = token.right( token.length() - 7 );
- recursion = token.contains( "." );
+ recursion = token.tqcontains( "." );
if( recursion != (signed int)token.length() )
- return QString::null;
+ return TQString();
recursion++;
}
@@ -778,10 +754,10 @@ QString BatchRenamer::findDirName( QString token, QString path )
return path.section( "/", recursion * -1, recursion * -1);
}
- return QString::null;
+ return TQString();
}
-QString BatchRenamer::findLength( const QString & token, const QString & name )
+TQString BatchRenamer::findLength( const TQString & token, const TQString & name )
{
if( token.lower().startsWith( "length" ) ) {
int minus = 0;
@@ -792,67 +768,41 @@ QString BatchRenamer::findLength( const QString & token, const QString & name )
minus = 0;
}
- return QString::number( name.length() - minus );
+ return TQString::number( name.length() - minus );
}
- return QString::null;
+ return TQString();
}
-QString BatchRenamer::findReplace( QString text )
+TQString BatchRenamer::findReplace( TQString text )
{
// Call for each element in replace strings doReplace with correct values
- for( unsigned int i = 0; i < m_replace.count(); i++ ) {
- replacestrings s = m_replace[i];
- text = doReplace( text, unEscape( s.find ), s.replace, s.reg );
+ for( unsigned int i = 0; i < m_tqreplace.count(); i++ ) {
+ replacestrings s = m_tqreplace[i];
+ text = doReplace( text, unEscape( s.tqfind ), s.tqreplace, s.reg );
}
return text;
}
-QString BatchRenamer::doReplace( QString text, QString find, QString replace, bool reg )
+TQString BatchRenamer::doReplace( TQString text, TQString tqfind, TQString tqreplace, bool reg )
{
if( !reg )
{
-#if QT_VERSION >= 0x030100
// we use the escaped text here because the user might want
// to find a "&" and replace it
- text.replace( doEscape( find ), replace );
-#else
- int pos = 0;
- QString f = doEscape( find );
- do {
-
- pos = text.find( f, pos );
- if( pos >= 0 ) {
- text.replace( pos, f.length(), replace );
- pos += replace.length();
- }
- } while( pos >= 0 );
-#endif
+ text.tqreplace( doEscape( tqfind ), tqreplace );
}
else
{
-#if QT_VERSION >= 0x030100
// no doEscape() here for the regexp, because it would destroy our regular expression
// other wise we will not find stuff like $, [ in the text
- text = doEscape( unEscape( text ).replace( QRegExp( find ), replace ) );
-#else
- // Test this code more!
- pos = 0;
- do {
- QRegExp exp( find );
- pos = exp.search( text, pos );
- if( pos >= 0 ) {
- text = doEscape( unEscape( text ).replace( pos, exp.matchedLength(), replace ) );
- pos += replace.length();
- }
- } while( pos >= 0 );
-#endif
+ text = doEscape( unEscape( text ).tqreplace( TQRegExp( tqfind ), tqreplace ) );
}
return text;
}
-void BatchRenamer::writeUndoScript( QTextStream* t )
+void BatchRenamer::writeUndoScript( TQTextStream* t )
{
// write header comments
(*t) << "#!/bin/bash" << endl
@@ -882,15 +832,15 @@ void BatchRenamer::writeUndoScript( QTextStream* t )
void BatchRenamer::parseSubdirs( data* f )
{
int pos = 0;
- if( (pos = f->dst.name.findRev( "/", -1 ) ) > 0 ) {
- QString dirs = f->dst.name.left( pos );
+ if( (pos = f->dst.name.tqfindRev( "/", -1 ) ) > 0 ) {
+ TQString dirs = f->dst.name.left( pos );
f->dst.name = f->dst.name.right( f->dst.name.length() - pos - 1 );
f->dst.directory += ( f->dst.directory.right( 1 ) == "/" ) ? "" : "/";
// create the missing subdir now
int i = 0;
- QString d = "";
- while( (d = dirs.section( "/", i, i, QString::SectionSkipEmpty )) && ! d.isEmpty() ) { // asignment here!
+ TQString d = "";
+ while( (d = dirs.section( "/", i, i, TQString::SectionSkipEmpty )) && ! d.isEmpty() ) { // asignment here!
KURL url = f->dst.url;
// it is important to unescape here
// to support dirnames containing "&" or
@@ -907,9 +857,9 @@ void BatchRenamer::parseSubdirs( data* f )
}
}
-QString BatchRenamer::buildFilename( fileentry* entry, bool dir )
+TQString BatchRenamer::buildFilename( fileentry* entry, bool dir )
{
- QString filename = ( dir ? entry->directory : QString::null ) + entry->name + ( entry->extension.isEmpty() ? QString::null : QString(".") ) + entry->extension;
+ TQString filename = ( dir ? entry->directory : TQString() ) + entry->name + ( entry->extension.isEmpty() ? TQString() : TQString(".") ) + entry->extension;
// unescape here as filename is still escaped
unEscape( filename );
return filename;
@@ -929,7 +879,7 @@ bool BatchRenamer::applyManualChanges( int i )
m_files[i].dst.name = m_changes[z].user;
// the file extension is already included
// in the users name
- m_files[i].dst.extension = QString::null;
+ m_files[i].dst.extension = TQString();
return true;
}
}