@ -23,7 +23,7 @@
*
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
# define K QT_OVERLOAD_NON_STATIC_FILEDIALOGS
# define K T QT_OVERLOAD_NON_STATIC_FILEDIALOGS
# define _GNU_SOURCE
# define _GNU_SOURCE
# include <dlfcn.h>
# include <dlfcn.h>
@ -39,20 +39,20 @@
# include <errno.h>
# include <errno.h>
# include <string.h>
# include <string.h>
# include <sys/types.h>
# include <sys/types.h>
# include < qstring.h>
# include < t qstring.h>
# include < qstringlist.h>
# include < t qstringlist.h>
# include < qwidget.h>
# include < t qwidget.h>
# include < qapplication.h>
# include < t qapplication.h>
# ifdef K QT_OVERLOAD_NON_STATIC_FILEDIALOGS
# ifdef K T QT_OVERLOAD_NON_STATIC_FILEDIALOGS
# include < qcombobox.h>
# include < t qcombobox.h>
# include < qlineedit.h>
# include < t qlineedit.h>
# include < qobjectlist.h>
# include < t qobjectlist.h>
# define private public // HACK HACK HACK!!!
# define private public // HACK HACK HACK!!!
# endif
# endif
# include < qfiledialog.h>
# include < t qfiledialog.h>
# include < qthread.h>
# include < t qthread.h>
# include < qnamespace.h>
# include < t qnamespace.h>
# include < qeventloop.h>
# include < t qeventloop.h>
# include "connect.h"
# include "connect.h"
# include "config.h"
# include "config.h"
# include "mangled.h"
# include "mangled.h"
@ -93,16 +93,16 @@ static char * getAppNameFromPid(int pid)
return appName ;
return appName ;
}
}
static const char * getAppName ( bool use Qt= true )
static const char * getAppName ( bool use T Qt= true )
{
{
static const char * appName = NULL ;
static const char * appName = NULL ;
if ( ! appName )
if ( ! appName )
{
{
const char * a = use Qt & & qApp ? qApp- > argv ( ) [ 0 ] : getAppNameFromPid ( getpid ( ) ) ;
const char * a = use T Qt & & t qApp ? t qApp- > argv ( ) [ 0 ] : getAppNameFromPid ( getpid ( ) ) ;
const char * slash ;
const char * slash ;
// Was the cmdline app java? if so, try to use its parent name - just in case
// Was the cmdline app java? if so, try to use its tq parent name - just in case
// its run from a shell script, etc. - e.g. as eclipse does
// its run from a shell script, etc. - e.g. as eclipse does
if ( a & & 0 = = strcmp ( a , " java " ) )
if ( a & & 0 = = strcmp ( a , " java " ) )
a = getAppNameFromPid ( getppid ( ) ) ;
a = getAppNameFromPid ( getppid ( ) ) ;
@ -112,13 +112,13 @@ static const char * getAppName(bool useQt=true)
appName = a & & ( slash = strrchr ( a , ' / ' ) ) & & ' \0 ' ! = slash [ 1 ]
appName = a & & ( slash = strrchr ( a , ' / ' ) ) & & ' \0 ' ! = slash [ 1 ]
? & ( slash [ 1 ] )
? & ( slash [ 1 ] )
: a ? a : " QtApp" ;
: a ? a : " T QtApp" ;
}
}
return appName ;
return appName ;
}
}
int QApplication: : exec ( )
int T QApplication: : exec ( )
{
{
static bool init = false ;
static bool init = false ;
@ -135,19 +135,19 @@ int QApplication::exec()
return ( int ) realFunction ( this ) ;
return ( int ) realFunction ( this ) ;
} ;
} ;
static QString qt2KdeFilter ( const QString & f )
static T QString qt2KdeFilter ( const T QString & f )
{
{
QString filter ;
T QString filter ;
QTextOStream str ( & filter ) ;
T QTextOStream str ( & filter ) ;
QStringList list ( QStringList: : split ( " ;; " , f ) ) ;
T QStringList list ( T QStringList: : split ( " ;; " , f ) ) ;
QStringList: : Iterator it ( list . begin ( ) ) ,
T QStringList: : Iterator it ( list . begin ( ) ) ,
end ( list . end ( ) ) ;
end ( list . end ( ) ) ;
bool first = true ;
bool first = true ;
for ( ; it ! = end ; + + it )
for ( ; it ! = end ; + + it )
{
{
int ob = ( * it ) . findRev( ' ( ' ) ,
int ob = ( * it ) . tq findRev( ' ( ' ) ,
cb = ( * it ) . findRev( ' ) ' ) ;
cb = ( * it ) . tq findRev( ' ) ' ) ;
if ( - 1 ! = cb & & ob < cb )
if ( - 1 ! = cb & & ob < cb )
{
{
@ -162,17 +162,17 @@ static QString qt2KdeFilter(const QString &f)
return filter ;
return filter ;
}
}
static void kde2 QtFilter( const QString & orig , QString * sel )
static void kde2 T QtFilter( const T QString & orig , T QString * sel )
{
{
if ( sel )
if ( sel )
{
{
QStringList list ( QStringList: : split ( " ;; " , orig ) ) ;
T QStringList list ( T QStringList: : split ( " ;; " , orig ) ) ;
QStringList: : Iterator it ( list . begin ( ) ) ,
T QStringList: : Iterator it ( list . begin ( ) ) ,
end ( list . end ( ) ) ;
end ( list . end ( ) ) ;
int pos ;
int pos ;
for ( ; it ! = end ; + + it )
for ( ; it ! = end ; + + it )
if ( - 1 ! = ( pos = ( * it ) . find( * sel ) ) & & pos > 0 & &
if ( - 1 ! = ( pos = ( * it ) . tq find( * sel ) ) & & pos > 0 & &
( ' ( ' = = ( * it ) [ pos - 1 ] | | ' ' = = ( * it ) [ pos - 1 ] ) & &
( ' ( ' = = ( * it ) [ pos - 1 ] | | ' ' = = ( * it ) [ pos - 1 ] ) & &
( * it ) . length ( ) > = sel - > length ( ) + pos & &
( * it ) . length ( ) > = sel - > length ( ) + pos & &
( ' ) ' = = ( * it ) [ pos + sel - > length ( ) ] | | ' ' = = ( * it ) [ pos + sel - > length ( ) ] ) )
( ' ) ' = = ( * it ) [ pos + sel - > length ( ) ] | | ' ' = = ( * it ) [ pos + sel - > length ( ) ] ) )
@ -183,39 +183,39 @@ static void kde2QtFilter(const QString &orig, QString *sel)
}
}
}
}
# ifdef K QT_OVERLOAD_NON_STATIC_FILEDIALOGS
# ifdef K T QT_OVERLOAD_NON_STATIC_FILEDIALOGS
# ifdef K QT_USE_QFILEDIALOG_PRIVATE
# ifdef K T QT_USE_T QFILEDIALOG_PRIVATE
// HACK HACK HACK!!!
// HACK HACK HACK!!!
// KGtk versions <=0.9.1 used this copied QFileDialogPrivate to access the file filters
// KGtk versions <=0.9.1 used this copied T QFileDialogPrivate to access the file filters
// newer versions walk the file dialogs children...
// newer versions walk the file dialogs tq children...
class QFileDialogPrivate {
class T QFileDialogPrivate {
public :
public :
~ QFileDialogPrivate( ) ;
~ T QFileDialogPrivate( ) ;
QStringList history ;
T QStringList history ;
bool geometryDirty;
bool tq geometryDirty;
QComboBox * paths ;
T QComboBox * paths ;
QComboBox * types ;
T QComboBox * types ;
} ;
} ;
# endif
# endif
static const QString getFilters ( QFileDialog * dlg , bool scribusSave = false )
static const T QString getFilters ( T QFileDialog * dlg , bool scribusSave = false )
{
{
QString filter ;
T QString filter ;
# if K QT_USE_QFILEDIALOG_PRIVATE
# if K T QT_USE_T QFILEDIALOG_PRIVATE
if ( dlg & & dlg - > d & & dlg - > d - > types )
if ( dlg & & dlg - > d & & dlg - > d - > types )
{
{
QTextOStream str ( & filter ) ;
T QTextOStream str ( & filter ) ;
for ( int i = 0 ; i < dlg - > d - > types - > count ( ) ; + + i )
for ( int i = 0 ; i < dlg - > d - > types - > count ( ) ; + + i )
{
{
if ( i )
if ( i )
str < < " ;; " ;
str < < " ;; " ;
if ( scribusSave & & - 1 ! = dlg - > d - > types - > text ( i ) . find( " (*.sla *.sla.gz *.scd *scd.gz) " ) )
if ( scribusSave & & - 1 ! = dlg - > d - > types - > text ( i ) . tq find( " (*.sla *.sla.gz *.scd *scd.gz) " ) )
str < < " Compressed Documents (*.sla.gz *scd.gz);;Documents (*.sla *.scd) " ;
str < < " Compressed Documents (*.sla.gz *scd.gz);;Documents (*.sla *.scd) " ;
else
else
str < < dlg - > d - > types - > text ( i ) ;
str < < dlg - > d - > types - > text ( i ) ;
@ -224,25 +224,25 @@ static const QString getFilters(QFileDialog *dlg, bool scribusSave=false)
# else
# else
if ( dlg )
if ( dlg )
{
{
const QObjectList * children= ( ( QObject * ) dlg ) - > children ( ) ;
const T QObjectList tq children= ( ( T QObject * ) dlg ) - > children ListObject ( ) ;
if ( children)
if ( ! tq children. isEmpty ( ) )
{
{
QObjectList: : ConstIterator it ( children- > begin ( ) ) ,
T QObjectList: : ConstIterator it ( tqchildren. begin ( ) ) ,
end ( children- > end ( ) ) ;
end ( tqchildren. end ( ) ) ;
for ( ; it ! = end ; + + it )
for ( ; it ! = end ; + + it )
if ( : : qt_cast< QComboBox * > ( * it ) & & 0 = = qstrcmp ( ( * it ) - > name ( ) , " file types " ) )
if ( : : tq qt_cast< T QComboBox * > ( * it ) & & 0 = = qstrcmp ( ( * it ) - > name ( ) , " file types " ) )
{
{
QComboBox * types = ( QComboBox * ) ( * it ) ;
T QComboBox * types = ( T QComboBox * ) ( * it ) ;
QTextOStream str ( & filter ) ;
T QTextOStream str ( & filter ) ;
for ( int i = 0 ; i < types - > count ( ) ; + + i )
for ( int i = 0 ; i < types - > count ( ) ; + + i )
{
{
if ( i )
if ( i )
str < < " ;; " ;
str < < " ;; " ;
if ( scribusSave & & - 1 ! = types - > text ( i ) . find( " (*.sla *.sla.gz *.scd *scd.gz) " ) )
if ( scribusSave & & - 1 ! = types - > text ( i ) . tq find( " (*.sla *.sla.gz *.scd *scd.gz) " ) )
str < < " Compressed Documents (*.sla.gz *scd.gz);;Documents (*.sla *.scd) " ;
str < < " Compressed Documents (*.sla.gz *scd.gz);;Documents (*.sla *.scd) " ;
else
else
str < < types - > text ( i ) ;
str < < types - > text ( i ) ;
@ -257,31 +257,31 @@ static const QString getFilters(QFileDialog *dlg, bool scribusSave=false)
return filter ;
return filter ;
}
}
static QString getCurrentFileName ( QFileDialog * dlg )
static T QString getCurrentFileName ( T QFileDialog * dlg )
{
{
if ( dlg )
if ( dlg )
{
{
const QObjectList * children= ( ( QObject * ) dlg ) - > children ( ) ;
const T QObjectList tq children= ( ( T QObject * ) dlg ) - > children ListObject ( ) ;
if ( children)
if ( ! tq children. isEmpty ( ) )
{
{
QObjectList: : ConstIterator it ( children- > begin ( ) ) ,
T QObjectList: : ConstIterator it ( tqchildren. begin ( ) ) ,
end ( children- > end ( ) ) ;
end ( tqchildren. end ( ) ) ;
for ( ; it ! = end ; + + it )
for ( ; it ! = end ; + + it )
if ( : : qt_cast< QLineEdit * > ( * it ) ) // && 0==qstrcmp((*it)->name(), "name/filter editor"))
if ( : : tq qt_cast< T QLineEdit * > ( * it ) ) // && 0==qstrcmp((*it)->name(), "name/filter editor"))
return ( ( QLineEdit * ) ( * it ) ) - > text ( ) ;
return ( ( T QLineEdit * ) ( * it ) ) - > text ( ) ;
}
}
}
}
return QString( ) ;
return T QString( ) ;
}
}
static QString getDir ( const QString & f )
static T QString getDir ( const T QString & f )
{
{
QString d ( f ) ;
T QString d ( f ) ;
int slashPos = d . findRev( ' / ' ) ;
int slashPos = d . tq findRev( ' / ' ) ;
if ( slashPos ! = - 1 )
if ( slashPos ! = - 1 )
d . remove ( slashPos + 1 , d . length ( ) ) ;
d . remove ( slashPos + 1 , d . length ( ) ) ;
@ -290,9 +290,9 @@ static QString getDir(const QString &f)
}
}
# endif
# endif
static bool writeString ( int fd , const QString & str )
static bool writeString ( int fd , const T QString & str )
{
{
QCString utf8 ( str . utf8 ( ) ) ;
T QCString utf8 ( str . utf8 ( ) ) ;
int size = utf8 . length ( ) + 1 ;
int size = utf8 . length ( ) + 1 ;
return writeBlock ( fd , ( char * ) & size , 4 ) & & writeBlock ( fd , utf8 . data ( ) , size ) ;
return writeBlock ( fd , ( char * ) & size , 4 ) & & writeBlock ( fd , utf8 . data ( ) , size ) ;
@ -305,11 +305,11 @@ static bool writeBool(int fd, bool b)
return writeBlock ( fd , ( char * ) & bv , 1 ) ;
return writeBlock ( fd , ( char * ) & bv , 1 ) ;
}
}
class K QtDialog : public QDialog
class K T QtDialog : public T QDialog
{
{
public :
public :
K QtDialog( QWidget * parent) : QDialog( parent, " kqt " , true , WStyle_NoBorder | WX11BypassWM )
K T QtDialog( T QWidget * tq parent) : T QDialog( tq parent, " kqt " , true , WStyle_NoBorder | WX11BypassWM )
{
{
resize ( 1 , 1 ) ;
resize ( 1 , 1 ) ;
setWindowOpacity ( 0.0 ) ;
setWindowOpacity ( 0.0 ) ;
@ -317,37 +317,37 @@ class KQtDialog : public QDialog
move ( 32768 , 32768 ) ;
move ( 32768 , 32768 ) ;
}
}
/* void r() { QDialog::reject(); }*/
/* void r() { T QDialog::reject(); }*/
} ;
} ;
class K QtThread : public QThread
class K T QtThread : public T QThread
{
{
public :
public :
K QtThread( QStringList & l , QString & s , int f , K QtDialog * dlg ) : dialog ( dlg ) , kdialogdError ( false ) , res ( l ) , selFilter ( s ) , fd ( f )
K T QtThread( T QStringList & l , T QString & s , int f , K T QtDialog * dlg ) : dialog ( dlg ) , kdialogdError ( false ) , res ( l ) , selFilter ( s ) , fd ( f )
{ }
{ }
bool readData ( QCString & buffer , int size )
bool readData ( T QCString & buffer , int size )
{
{
buffer . resize ( size ) ;
buffer . resize ( size ) ;
return : : readBlock ( fd , buffer . data ( ) , size ) ;
return : : readBlock ( fd , buffer . data ( ) , size ) ;
}
}
bool readString ( QString & str , int size )
bool readString ( T QString & str , int size )
{
{
QCString buffer ;
T QCString buffer ;
buffer . resize ( size ) ;
buffer . resize ( size ) ;
if ( ! readBlock ( fd , buffer . data ( ) , size ) )
if ( ! readBlock ( fd , buffer . data ( ) , size ) )
return false ;
return false ;
str = QString: : fromUtf8 ( buffer . data ( ) ) ;
str = T QString: : fromUtf8 ( buffer . data ( ) ) ;
return true ;
return true ;
}
}
void run ( )
void run ( )
{
{
QString buffer ;
T QString buffer ;
int num = 0 ;
int num = 0 ;
if ( readBlock ( fd , ( char * ) & num , 4 ) )
if ( readBlock ( fd , ( char * ) & num , 4 ) )
@ -381,23 +381,23 @@ class KQtThread : public QThread
else
else
kdialogdError = true ;
kdialogdError = true ;
QApplication: : postEvent ( dialog , new QCloseEvent) ;
T QApplication: : postEvent ( dialog , new T QCloseEvent) ;
}
}
K QtDialog * dialog ;
K T QtDialog * dialog ;
bool kdialogdError ;
bool kdialogdError ;
QStringList & res ;
T QStringList & res ;
QString & selFilter ;
T QString & selFilter ;
int fd ;
int fd ;
} ;
} ;
static bool sendMessage ( QWidget * parent, Operation op , QStringList & res , QString & selFilter ,
static bool sendMessage ( T QWidget * tq parent, Operation op , T QStringList & res , T QString & selFilter ,
const QString & title , const QString & p1 , const QString * p2 , bool ow )
const T QString & title , const T QString & p1 , const T QString * p2 , bool ow )
{
{
if ( connectToKDialogD ( getAppName ( ) ) )
if ( connectToKDialogD ( getAppName ( ) ) )
{
{
char o = ( char ) op ;
char o = ( char ) op ;
int xid = parent ? parent- > topLevelWidget( ) - > winId ( ) : qApp- > activeWindow ( ) - > winId ( ) ;
int xid = tq parent ? tq parent- > tq topLevelWidget( ) - > winId ( ) : t qApp- > activeWindow ( ) - > winId ( ) ;
if ( writeBlock ( kdialogdSocket , & o , 1 ) & &
if ( writeBlock ( kdialogdSocket , & o , 1 ) & &
writeBlock ( kdialogdSocket , ( char * ) & xid , 4 ) & &
writeBlock ( kdialogdSocket , ( char * ) & xid , 4 ) & &
@ -406,8 +406,8 @@ static bool sendMessage(QWidget *parent, Operation op, QStringList &res, QString
( p2 ? writeString ( kdialogdSocket , * p2 ) : true ) & &
( p2 ? writeString ( kdialogdSocket , * p2 ) : true ) & &
( OP_FILE_SAVE = = op ? writeBool ( kdialogdSocket , ow ) : true ) )
( OP_FILE_SAVE = = op ? writeBool ( kdialogdSocket , ow ) : true ) )
{
{
K QtDialog dlg ( parent) ;
K T QtDialog dlg ( tq parent) ;
K QtThread thread ( res , selFilter , kdialogdSocket , & dlg ) ;
K T QtThread thread ( res , selFilter , kdialogdSocket , & dlg ) ;
thread . start ( ) ;
thread . start ( ) ;
dlg . exec ( ) ;
dlg . exec ( ) ;
@ -424,7 +424,7 @@ static bool sendMessage(QWidget *parent, Operation op, QStringList &res, QString
return false ;
return false ;
}
}
static QString getTitle ( const QString & title , Operation op )
static T QString getTitle ( const T QString & title , Operation op )
{
{
if ( ! title . isEmpty ( ) )
if ( ! title . isEmpty ( ) )
return title ;
return title ;
@ -432,13 +432,13 @@ static QString getTitle(const QString &title, Operation op)
return " . " ;
return " . " ;
}
}
static bool openKdeDialog ( QWidget * widget , const QString & title , const QString & p1 , const QString * p2 ,
static bool openKdeDialog ( T QWidget * widget , const T QString & title , const T QString & p1 , const T QString * p2 ,
Operation op , QStringList & res , QString * selFilter , bool ow = false )
Operation op , T QStringList & res , T QString * selFilter , bool ow = false )
{
{
QString filter ;
T QString filter ;
bool rv = sendMessage ( widget , op , res , filter , getTitle ( title , op ) , p1 , p2 , ow ) ;
bool rv = sendMessage ( widget , op , res , filter , getTitle ( title , op ) , p1 , p2 , ow ) ;
// If we failed to talk to, or start kdialogd, then dont keep trying - just fall back to Qt
// If we failed to talk to, or start kdialogd, then dont keep trying - just fall back to T Qt
if ( ! rv )
if ( ! rv )
/*useKde=false*/ ;
/*useKde=false*/ ;
else if ( selFilter )
else if ( selFilter )
@ -468,98 +468,98 @@ static bool kqtInit()
return useKde ;
return useKde ;
}
}
static QString lastDir ;
static T QString lastDir ;
static void storeLastDir ( const QString & f )
static void storeLastDir ( const T QString & f )
{
{
lastDir = f ;
lastDir = f ;
int slashPos ( lastDir . findRev( ' / ' ) ) ;
int slashPos ( lastDir . tq findRev( ' / ' ) ) ;
if ( slashPos ! = - 1 )
if ( slashPos ! = - 1 )
lastDir . remove ( slashPos + 1 , lastDir . length ( ) ) ;
lastDir . remove ( slashPos + 1 , lastDir . length ( ) ) ;
}
}
static const QString & startDir ( const QString & d )
static const T QString & startDir ( const T QString & d )
{
{
return d . isEmpty ( ) ? lastDir : d ;
return d . isEmpty ( ) ? lastDir : d ;
}
}
QString QFileDialog: : getOpenFileName ( const QString & initially , const QString & filter ,
T QString T QFileDialog: : getOpenFileName ( const T QString & initially , const T QString & filter ,
QWidget * parent, const char * name , const QString & caption ,
T QWidget * tq parent, const char * name , const T QString & caption ,
QString * selectedFilter , bool resolveSymlinks )
T QString * selectedFilter , bool resolveSymlinks )
{
{
QStringList res ;
T QStringList res ;
QString f ( qt2KdeFilter ( filter ) ) ;
T QString f ( qt2KdeFilter ( filter ) ) ;
kqtInit ( ) ;
kqtInit ( ) ;
if ( openKdeDialog ( parent, caption , startDir ( initially ) , & f , OP_FILE_OPEN , res , selectedFilter ) )
if ( openKdeDialog ( tq parent, caption , startDir ( initially ) , & f , OP_FILE_OPEN , res , selectedFilter ) )
{
{
kde2 QtFilter( filter , selectedFilter ) ;
kde2 T QtFilter( filter , selectedFilter ) ;
QString fn ( res . first ( ) ) ;
T QString fn ( res . first ( ) ) ;
storeLastDir ( fn ) ;
storeLastDir ( fn ) ;
return fn ;
return fn ;
}
}
return QString : : null ;
return TQString ( ) ;
}
}
QString QFileDialog: : getSaveFileName ( const QString & initially , const QString & filter , QWidget * parent,
T QString T QFileDialog: : getSaveFileName ( const T QString & initially , const T QString & filter , T QWidget * tq parent,
const char * name , const QString & caption ,
const char * name , const T QString & caption ,
QString * selectedFilter , bool resolveSymlinks )
T QString * selectedFilter , bool resolveSymlinks )
{
{
QStringList res ;
T QStringList res ;
QString f ( qt2KdeFilter ( filter ) ) ;
T QString f ( qt2KdeFilter ( filter ) ) ;
kqtInit ( ) ;
kqtInit ( ) ;
if ( openKdeDialog ( parent, caption , startDir ( initially ) , & f , OP_FILE_SAVE , res , selectedFilter ) )
if ( openKdeDialog ( tq parent, caption , startDir ( initially ) , & f , OP_FILE_SAVE , res , selectedFilter ) )
{
{
kde2 QtFilter( filter , selectedFilter ) ;
kde2 T QtFilter( filter , selectedFilter ) ;
QString fn ( res . first ( ) ) ;
T QString fn ( res . first ( ) ) ;
storeLastDir ( fn ) ;
storeLastDir ( fn ) ;
return fn ;
return fn ;
}
}
return QString : : null ;
return TQString ( ) ;
}
}
QString QFileDialog: : getExistingDirectory ( const QString & dir , QWidget * parent, const char * name ,
T QString T QFileDialog: : getExistingDirectory ( const T QString & dir , T QWidget * tq parent, const char * name ,
const QString & caption , bool dirOnly , bool resolveSymlinks )
const T QString & caption , bool dirOnly , bool resolveSymlinks )
{
{
QStringList res ;
T QStringList res ;
QString dummy ;
T QString dummy ;
kqtInit ( ) ;
kqtInit ( ) ;
return openKdeDialog ( parent, caption , dir , NULL , OP_FOLDER , res , & dummy )
return openKdeDialog ( tq parent, caption , dir , NULL , OP_FOLDER , res , & dummy )
? res . first ( )
? res . first ( )
: QString: : null ;
: TQString( ) ;
}
}
QStringList QFileDialog: : getOpenFileNames ( const QString & filter , const QString & dir , QWidget * parent,
T QStringList T QFileDialog: : getOpenFileNames ( const T QString & filter , const T QString & dir , T QWidget * tq parent,
const char * name , const QString & caption ,
const char * name , const T QString & caption ,
QString * selectedFilter , bool resolveSymlinks )
T QString * selectedFilter , bool resolveSymlinks )
{
{
QStringList res ;
T QStringList res ;
QString f ( qt2KdeFilter ( filter ) ) ;
T QString f ( qt2KdeFilter ( filter ) ) ;
kqtInit ( ) ;
kqtInit ( ) ;
openKdeDialog ( parent, caption , startDir ( dir ) , & f , OP_FILE_OPEN_MULTIPLE , res , selectedFilter ) ;
openKdeDialog ( tq parent, caption , startDir ( dir ) , & f , OP_FILE_OPEN_MULTIPLE , res , selectedFilter ) ;
if ( res . count ( ) )
if ( res . count ( ) )
{
{
kde2 QtFilter( filter , selectedFilter ) ;
kde2 T QtFilter( filter , selectedFilter ) ;
storeLastDir ( res . first ( ) ) ;
storeLastDir ( res . first ( ) ) ;
}
}
return res ;
return res ;
}
}
# ifdef K QT_OVERLOAD_NON_STATIC_FILEDIALOGS
# ifdef K T QT_OVERLOAD_NON_STATIC_FILEDIALOGS
static QString getFile ( const QString & f )
static T QString getFile ( const T QString & f )
{
{
QString d ( f ) ;
T QString d ( f ) ;
int slashPos = d . findRev( ' / ' ) ;
int slashPos = d . tq findRev( ' / ' ) ;
if ( slashPos ! = - 1 )
if ( slashPos ! = - 1 )
d . remove ( 0 , slashPos + 1 ) ;
d . remove ( 0 , slashPos + 1 ) ;
@ -567,70 +567,70 @@ static QString getFile(const QString &f)
return d ;
return d ;
}
}
int QDialog: : exec ( )
int T QDialog: : exec ( )
{
{
int res = QDialog: : Rejected ;
int res = T QDialog: : Rejected ;
if ( inherits ( " QFileDialog" ) )
if ( inherits ( " T QFileDialog" ) )
{
{
QFileDialog * that = ( QFileDialog * ) this ;
T QFileDialog * that = ( T QFileDialog * ) this ;
const QDir * dirp = that - > dir ( ) ;
const T QDir * dirp = that - > dir ( ) ;
QString dir ,
T QString dir ,
selectedFilter ,
selectedFilter ,
file ,
file ,
initialDir ( dirp ? dirp - > absPath ( ) : QDir: : homeDirPath ( ) ) ;
initialDir ( dirp ? dirp - > absPath ( ) : T QDir: : homeDirPath ( ) ) ;
QStringList files ;
T QStringList files ;
if ( dirp )
if ( dirp )
delete dirp ;
delete dirp ;
QApplication: : eventLoop ( ) - > processEvents ( QEventLoop: : ExcludeUserInput , 1 ) ;
T QApplication: : eventLoop ( ) - > processEvents ( T QEventLoop: : ExcludeUserInput , 1 ) ;
switch ( that - > mode ( ) )
switch ( that - > mode ( ) )
{
{
case QFileDialog: : Directory :
case T QFileDialog: : Directory :
case QFileDialog: : DirectoryOnly :
case T QFileDialog: : DirectoryOnly :
dir = QFileDialog: : getExistingDirectory ( initialDir , parentWidget( ) , NULL ,
dir = T QFileDialog: : getExistingDirectory ( initialDir , tq parentWidget( ) , NULL ,
caption ( ) , true , true ) ;
caption ( ) , true , true ) ;
if ( ! dir . isEmpty ( ) )
if ( ! dir . isEmpty ( ) )
res = QDialog: : Accepted ;
res = T QDialog: : Accepted ;
break ;
break ;
case QFileDialog: : AnyFile :
case T QFileDialog: : AnyFile :
{
{
QString app ( getFile ( qApp- > argv ( ) [ 0 ] ) ) ,
T QString app ( getFile ( t qApp- > argv ( ) [ 0 ] ) ) ,
initialFile ( getCurrentFileName ( that ) ) ;
initialFile ( getCurrentFileName ( that ) ) ;
if ( ! initialFile . isEmpty ( ) )
if ( ! initialFile . isEmpty ( ) )
initialDir = initialDir + QChar( ' / ' ) + initialFile ;
initialDir = initialDir + T QChar( ' / ' ) + initialFile ;
file = QFileDialog: : getSaveFileName ( initialDir ,
file = T QFileDialog: : getSaveFileName ( initialDir ,
getFilters ( that , " scribus " = = app | |
getFilters ( that , " scribus " = = app | |
" scribus-ng " = = app ) ,
" scribus-ng " = = app ) ,
parentWidget( ) , NULL , caption ( ) , & selectedFilter ,
tq parentWidget( ) , NULL , caption ( ) , & selectedFilter ,
true ) ;
true ) ;
if ( ! file . isEmpty ( ) )
if ( ! file . isEmpty ( ) )
res = QDialog: : Accepted ;
res = T QDialog: : Accepted ;
break ;
break ;
}
}
case QFileDialog: : ExistingFile :
case T QFileDialog: : ExistingFile :
file = QFileDialog: : getOpenFileName ( initialDir , getFilters ( that ) , parentWidget( ) ,
file = T QFileDialog: : getOpenFileName ( initialDir , getFilters ( that ) , tq parentWidget( ) ,
NULL , caption ( ) , & selectedFilter , true ) ;
NULL , caption ( ) , & selectedFilter , true ) ;
if ( ! file . isEmpty ( ) )
if ( ! file . isEmpty ( ) )
res = QDialog: : Accepted ;
res = T QDialog: : Accepted ;
break ;
break ;
case QFileDialog: : ExistingFiles :
case T QFileDialog: : ExistingFiles :
files = QFileDialog: : getOpenFileNames ( getFilters ( that ) , initialDir , parentWidget( ) ,
files = T QFileDialog: : getOpenFileNames ( getFilters ( that ) , initialDir , tq parentWidget( ) ,
NULL , caption ( ) , & selectedFilter , true ) ;
NULL , caption ( ) , & selectedFilter , true ) ;
if ( files . count ( ) )
if ( files . count ( ) )
res = QDialog: : Accepted ;
res = T QDialog: : Accepted ;
break ;
break ;
}
}
if ( QDialog: : Accepted = = res )
if ( T QDialog: : Accepted = = res )
{
{
if ( file . isEmpty ( ) & & files . count ( ) )
if ( file . isEmpty ( ) & & files . count ( ) )
file = files . first ( ) ;
file = files . first ( ) ;
@ -645,16 +645,16 @@ int QDialog::exec()
if ( files . count ( ) & & that - > nameEdit )
if ( files . count ( ) & & that - > nameEdit )
{
{
QStringList: : Iterator it ( files . begin ( ) ) ,
T QStringList: : Iterator it ( files . begin ( ) ) ,
end ( files . end ( ) ) ;
end ( files . end ( ) ) ;
QString filesStr ;
T QString filesStr ;
QTextOStream str ( & filesStr ) ;
T QTextOStream str ( & filesStr ) ;
for ( ; it ! = end ; + + it )
for ( ; it ! = end ; + + it )
str < < " \" " < < ( * it ) < < " \" " ;
str < < " \" " < < ( * it ) < < " \" " ;
that - > nameEdit - > setText ( filesStr ) ;
that - > nameEdit - > setText ( filesStr ) ;
}
}
QApplication: : eventLoop ( ) - > processEvents ( QEventLoop: : ExcludeUserInput , 1 ) ;
T QApplication: : eventLoop ( ) - > processEvents ( T QEventLoop: : ExcludeUserInput , 1 ) ;
}
}
}
}
else
else