Added controlled conversions to char* instead of automatic ascii conversions.

The definition of -UTQT_NO_ASCII_CAST is no longer needed.
Fix unnecessary use of TQString() over i18n().
Resolved use of deprecated NetAccess methods.

Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
pull/2/head
Slávek Banko 6 years ago
parent ededcc28b4
commit e023691c15
No known key found for this signature in database
GPG Key ID: 608F5293A04BE668

@ -58,7 +58,7 @@ include( ConfigureChecks.cmake )
###### global compiler settings
add_definitions( -DHAVE_CONFIG_H -UTQT_NO_ASCII_CAST )
add_definitions( -DHAVE_CONFIG_H )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TQT_CXX_FLAGS}" )
set( CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined" )

@ -157,7 +157,7 @@ void ProgressDialog::error( TQString text )
}
//TODO: simplify this (breaks i18n)
TDEListViewItem* item = new TDEListViewItem( display, TQString( i18n("Error: %1") ).arg( TQString() ) + simplify( text ), count() );
TDEListViewItem* item = new TDEListViewItem( display, i18n("Error: %1").arg( TQString() ) + simplify( text ), count() );
item->setPixmap( 0, SmallIcon("cancel") );
display->insertItem( item );
}
@ -170,7 +170,7 @@ void ProgressDialog::warning( TQString text )
m_timer->start( TIMER_INTERVAL );
}
TDEListViewItem* item = new TDEListViewItem( display, TQString( i18n("Warning: %1") ).arg( TQString() ) + simplify( text ), count() );
TDEListViewItem* item = new TDEListViewItem( display, i18n("Warning: %1").arg( TQString() ) + simplify( text ), count() );
item->setPixmap( 0, SmallIcon("idea") );
display->insertItem( item );
}

@ -125,7 +125,7 @@ void BatchRenamer::processFiles( ProgressDialog* p, TQObject* object )
}
}
p->print( TQString( i18n("Filenames Processed after %1 seconds.")).arg(t.elapsed()/1000) );
p->print(i18n("Filenames Processed after %1 seconds.").arg(t.elapsed()/1000));
work( p );
}
@ -258,13 +258,13 @@ void BatchRenamer::work( ProgressDialog* p )
* Give the user some information...
*/
if( m_mode == COPY)
p->print( TQString( i18n("Files will be copied to: %1") ).arg(m_files[0].dst.directory) );
p->print(i18n("Files will be copied to: %1").arg(m_files[0].dst.directory));
else if( m_mode == MOVE )
p->print( TQString( i18n("Files will be moved to: %1") ).arg(m_files[0].dst.directory) );
p->print(i18n("Files will be moved to: %1").arg(m_files[0].dst.directory));
else if( m_mode == LINK )
p->print( TQString( i18n("Symbolic links will be created in: %1") ).arg(m_files[0].dst.directory) );
p->print(i18n("Symbolic links will be created in: %1").arg(m_files[0].dst.directory));
else if( m_mode == RENAME )
p->print( i18n("Input files will be renamed.") );
p->print(i18n("Input files will be renamed."));
unsigned int i;
for( i = 0; i < m_files.count(); i++) {
@ -317,7 +317,7 @@ 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( TQString( i18n("Undo is not possible for remote file: %1") ).arg( dst.prettyURL() ) );
p->warning(i18n("Undo is not possible for remote file: %1").arg(dst.prettyURL()));
}
@ -329,15 +329,15 @@ void BatchRenamer::work( ProgressDialog* p )
}
}
const TQString m = TQString( i18n("Renamed %1 files successfully.") ).arg(i-error);
const TQString m = i18n("Renamed %1 files successfully.").arg(i-error);
( i - error ) ? p->print( m ) : p->warning( m );
if( error > 0 )
p->warning( TQString( i18n("%2 errors occurred!") ).arg(error));
p->warning(i18n("%2 errors occurred!").arg(error));
p->print( TQString( i18n("Elapsed time: %1 seconds") ).arg( t.elapsed()/1000 ), "kalarm" );
p->print( i18n("KRename finished the renaming process."), "krename" );
p->print( i18n("Press close to quit!") );
p->print(i18n("Elapsed time: %1 seconds").arg( 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() );
if( undo ) {
@ -346,7 +346,7 @@ void BatchRenamer::work( ProgressDialog* p )
fundo->close();
// Make fundo exuteable
if( chmod( (const char*)m_undoScript, (unsigned int) S_IRUSR | S_IWUSR | S_IXUSR ) )
if (chmod(m_undoScript.local8Bit(), (unsigned int) S_IRUSR | S_IWUSR | S_IXUSR))
p->error( i18n("Can't set executable bit on undo script.") );
delete fundo;
}
@ -361,7 +361,7 @@ void BatchRenamer::escape( TQString & text, const TQString & token, const TQStri
text.replace( token, sequence );
}
TQString & BatchRenamer::doEscape( TQString text, bool filename )
TQString & BatchRenamer::doEscape( TQString& text, bool filename )
{
if( filename ) {
BatchRenamer::escape( text, "&", TQChar( 60000 ) );
@ -840,13 +840,13 @@ void BatchRenamer::parseSubdirs( data* f )
// create the missing subdir now
int i = 0;
TQString d = "";
while( (d = dirs.section( "/", i, i, TQString::SectionSkipEmpty )) && ! d.isEmpty() ) { // asignment here!
while (!(d = dirs.section("/", i, i, TQString::SectionSkipEmpty)).isEmpty()) { // asignment here!
KURL url = f->dst.url;
// it is important to unescape here
// to support dirnames containing "&" or
// similar tokens
url.addPath( unEscape( d ) );
if( !NetAccess::exists( url ) && !NetAccess::mkdir( url ) )
if (!NetAccess::exists(url, false, 0) && !NetAccess::mkdir(url, 0, -1))
// TODO: GUI bug report
tqDebug("Can't create %s", url.prettyURL().latin1() );

@ -131,7 +131,7 @@ class BatchRenamer {
TQString processString( TQString text, TQString oldname, int i );
static TQString & doEscape( TQString text, bool filename = true );
static TQString & doEscape( TQString & text, bool filename = true );
static TQString & unEscape( TQString & text );
static void escape( TQString & text, const TQString & token, const TQString & sequence );

@ -137,7 +137,7 @@ TQString CommandPlugin::processFile( BatchRenamer* b, int i, TQString, int )
proc.resume();
if( !noblock && proc.exitStatus() )
return command.arg( filename ) + TQString( i18n(" exited with error: %1") ).arg( proc.exitStatus() );
return command.arg( filename ) + i18n(" exited with error: %1").arg( proc.exitStatus() );
return TQString();
}

@ -88,7 +88,7 @@ TQString DatePlugin::processFile(BatchRenamer* b, int i, TQString token, int )
return tmp.sprintf("%0*i", 2, t.second() );
else {
TDEIO::UDSEntry entry;
TDEIO::NetAccess::stat( b->files()[i].src.url, entry );
TDEIO::NetAccess::stat(b->files()[i].src.url, entry, 0);
KFileItem item( entry, b->files()[i].src.url );
if( token == "user" )
return item.user();

@ -126,7 +126,7 @@ void MyDatePlugin::drawInterface( TQWidget* w, TQVBoxLayout* l )
void MyDatePlugin::fillStructure()
{
#ifndef BENNY
dvals.date = kDate->getDate();
dvals.date = kDate->date();
dvals.changeModification = checkModification->isChecked();
dvals.changeAccess = checkAccess->isChecked();
dvals.hour = spinHour->value();
@ -149,7 +149,7 @@ TQString MyDatePlugin::processFile( BatchRenamer* b, int i, TQString, int )
f = fopen((const char *)filename, "r");
if( f == NULL )
return TQString( i18n("Can't change date of file %1.") ).arg(filename);
return i18n("Can't change date of file %1.").arg(filename);
fclose( f );
@ -165,16 +165,16 @@ TQString MyDatePlugin::processFile( BatchRenamer* b, int i, TQString, int )
ti = mktime( &tmp );
if( ti == -1 )
return TQString( i18n("Can't change date of file %1.") ).arg(filename);
return i18n("Can't change date of file %1.").arg(filename);
if( stat( (const char *)filename, &st ) == -1 )
return TQString( i18n("Can't change date of file %1.") ).arg(filename);
return i18n("Can't change date of file %1.").arg(filename);
t->actime = st.st_atime;
t->modtime = ti;
if(utime( (const char *)filename, t ) != 0)
return TQString( i18n("Can't change date of file %1.") ).arg(filename);
return i18n("Can't change date of file %1.").arg(filename);
return TQString();
#else
@ -187,9 +187,9 @@ TQString MyDatePlugin::processFile( BatchRenamer* b, int i, TQString, int )
time_t ti;
f = fopen((const char *)filename, "r");
f = fopen(filename.local8Bit(), "r");
if( f == NULL )
return TQString( i18n("Can't change date of file %1.") ).arg(filename);
return i18n("Can't change date of file %1.").arg(filename);
fclose( f );
@ -204,10 +204,10 @@ TQString MyDatePlugin::processFile( BatchRenamer* b, int i, TQString, int )
ti = mktime( &tmp );
if( ti == -1 )
return TQString( i18n("Can't change date of file %1.") ).arg(filename);
return i18n("Can't change date of file %1.").arg(filename);
if( stat( (const char *)filename, &st ) == -1 )
return TQString( i18n("Can't change date of file %1.") ).arg(filename);
if (stat(filename.local8Bit(), &st) == -1)
return i18n("Can't change date of file %1.").arg(filename);
if(dvals.changeAccess)
t->actime = ti;
@ -219,8 +219,8 @@ TQString MyDatePlugin::processFile( BatchRenamer* b, int i, TQString, int )
else
t->modtime = st.st_mtime;
if(utime( (const char *)filename, t ) != 0)
return TQString( i18n("Can't change date of file %1.") ).arg(filename);
if (utime(filename.local8Bit(), t) != 0)
return i18n("Can't change date of file %1.").arg(filename);
return TQString();
#endif

@ -108,11 +108,11 @@ TQString EncodingPlugin::processFile( BatchRenamer*, int, TQString token, int )
TQString input = token;
TQString unicode = TQString();
TQTextCodec* toUnicode = TQTextCodec::codecForName(m_input_codec); // get the codec for KOI8-R
TQTextCodec* fromUnicode = TQTextCodec::codecForName(m_output_codec);
TQTextCodec* toUnicode = TQTextCodec::codecForName(m_input_codec.ascii()); // get the codec for KOI8-R
TQTextCodec* fromUnicode = TQTextCodec::codecForName(m_output_codec.ascii());
unicode = toUnicode->toUnicode( input );
return fromUnicode->fromUnicode( unicode );
unicode = toUnicode->toUnicode( input.ascii() );
return fromUnicode->fromUnicode( unicode.ascii() );
}
void EncodingPlugin::finished()

@ -50,7 +50,7 @@ bool FileOperation::start( const KURL & src, const KURL & dest, int mode, bool o
result = 0;
if( src == dest && !overwrite ) {
m_error = TQString( i18n( "File %1 exists already!") ).arg( dest.prettyURL() );
m_error = i18n( "File %1 exists already!").arg( dest.prettyURL() );
return false;
}

@ -117,7 +117,7 @@ bool KMyListBox::isFile( const KURL & f, bool autoadd )
{
UDSEntry entry;
NetAccess::stat( f, entry );
NetAccess::stat(f, entry, 0);
KFileItem file( entry, f );
if( !file.isReadable() )
return false;

@ -76,7 +76,7 @@
#define ID_WIZARD 2905
#define ID_TAB 2904
TQString pageTitle[] = {
TQCString pageTitle[] = {
I18N_NOOP( "F&iles" ),
I18N_NOOP( "Des&tination" ),
I18N_NOOP( "P&lugins" ),
@ -1004,7 +1004,7 @@ void KRenameImpl::start()
}
ProgressDialog* p = new ProgressDialog( 0, "p" );
p->print(TQString( i18n("Starting conversion of %1 files.") ).arg(fileList->count()));
p->print(i18n("Starting conversion of %1 files.").arg(fileList->count()));
// Save History
dirname->saveSettings();
@ -1065,7 +1065,7 @@ bool KRenameImpl::checkErrors()
void KRenameImpl::updateCount()
{
labelCount->setText( TQString( i18n("Files: <b>%1</b>") ).arg(fileList->count()));
labelCount->setText(i18n("Files: <b>%1</b>").arg(fileList->count()));
buttonCoord->setEnabled( (bool)fileList->count() );
buttonReplace->setEnabled( (bool)fileList->count() );
@ -1162,7 +1162,7 @@ bool KRenameImpl::setupBatchRenamer( BatchRenamer* b, bool preview )
if( url.right(1) != "/" )
url.append( "/" );
if( !TDEIO::NetAccess::exists( KURL( url ) ) )
if (!TDEIO::NetAccess::exists(KURL(url), true, parent))
{
int m = KMessageBox::warningContinueCancel( parent, i18n("The directory %1 does not exist. "
"KRename will create it for you.").arg( url ) );
@ -1171,8 +1171,8 @@ bool KRenameImpl::setupBatchRenamer( BatchRenamer* b, bool preview )
int i = 0;
TQString d = "/";
while( (d += url.section( "/", i, i, TQString::SectionSkipEmpty )) && ! d.isEmpty() ) { // asignment here!
if( !TDEIO::NetAccess::exists( d ) && !TDEIO::NetAccess::mkdir( d ) )
while (!(d += url.section( "/", i, i, TQString::SectionSkipEmpty)).isEmpty()) { // asignment here!
if (!TDEIO::NetAccess::exists(d, false, parent) && !TDEIO::NetAccess::mkdir(d, parent, -1))
{
tqDebug( "Can't create %s", d.latin1() );
break;

@ -244,12 +244,12 @@ TQString MyPermPlugin::processFile( BatchRenamer* b, int i, TQString, int )
{
TQString filename = b->files()[i].dst.name;
if( perm.changePermissions )
if( chmod( (const char *)filename, (mode_t)perm.newPermission ) == -1 )
return TQString( i18n("Can't chmod %1.") ).arg(filename);
if (chmod(filename.local8Bit(), (mode_t)perm.newPermission) == -1)
return i18n("Can't chmod %1.").arg(filename);
if( perm.changeOwner )
if( chown( (const char*)filename, getUid( perm.owner), getGid( perm.group )))
return TQString( i18n("Can't chown %1.") ).arg(filename);
if (chown(filename.local8Bit(), getUid(perm.owner), getGid(perm.group)))
return i18n("Can't chown %1.").arg(filename);
return TQString();
}
@ -295,7 +295,7 @@ int MyPermPlugin::getGid( TQString group )
struct group *ge;
setgrent();
for (i=0; ((ge = getgrent()) != 0L) && (i < MAXENTRIES); i++)
if( !strcmp( ge->gr_name, (const char *)group ) )
if (!strcmp(ge->gr_name, group.local8Bit()))
break;
r = ge->gr_gid;
endgrent();
@ -308,7 +308,7 @@ int MyPermPlugin::getUid( TQString owner )
struct passwd *user;
setpwent();
for (i=0; ((user = getpwent()) != 0L) && (i < MAXENTRIES); i++)
if( !strcmp(user->pw_name, (const char *)owner) )
if (!strcmp(user->pw_name, owner.local8Bit()))
break;
r = user->pw_uid;
endpwent();

@ -500,7 +500,7 @@ void ProfileDlg::slotSetDefault()
void ProfileDlg::slotLoadProfile()
{
TQString profile = profiles->currentText();
TQString msg = TQString( i18n("Do you really want to load the profile and overwrite the current settings: %1") ).arg( profile );
TQString msg = i18n("Do you really want to load the profile and overwrite the current settings: %1").arg( profile );
TQString path = getProfilePath( profile );
@ -554,7 +554,7 @@ void ProfileDlg::slotDeleteProfile()
}
TQString profile = profiles->currentText();
TQString msg = TQString( i18n("Do you really want to delete the profile: %1") ).arg( profile );
TQString msg = i18n("Do you really want to delete the profile: %1").arg( profile );
if( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes )
{

@ -85,7 +85,7 @@ TQString TranslitPlugin::translit(const TQString & unicoded)
for (i=0; i<(int)unicoded.length(); i++) {
TQString charIn = unicoded.mid(i, 1);
if (m_mapFromUTF8[charIn.utf8()]) {
if (!(m_mapFromUTF8[charIn.utf8()].isNull())) {
TQString charTrans = m_mapFromUTF8[charIn.utf8()];
transed.append(charTrans);
} else {

Loading…
Cancel
Save