2 #include "XGUI_Tools.h"
7 //******************************************************************
8 QString library( const QString& str )
10 QString path = dir( str, false );
11 QString name = file( str, false );
12 QString ext = extension( str );
15 if ( !name.startsWith( "lib" ) )
16 name = QString( "lib" ) + name;
20 QString libExt( "dll" );
22 QString libExt( "so" );
25 if ( ext.toLower() != QString( "so" ) && ext.toLower() != QString( "dll" ) )
27 if ( !name.isEmpty() && !ext.isEmpty() )
28 name += QString( "." );
34 QString fileName = addSlash( path ) + name + QString( "." ) + ext;
39 //******************************************************************
40 QString dir( const QString& path, bool isAbs )
42 QDir aDir = QFileInfo( path ).dir();
43 QString dirPath = isAbs ? aDir.absolutePath() : aDir.path();
44 if ( dirPath == QString( "." ) )
50 //******************************************************************
51 QString file( const QString& path, bool withExt )
54 while ( !fPath.isEmpty() && ( fPath[fPath.length() - 1] =='\\' || fPath[fPath.length() - 1] == '/' ) )
55 fPath.remove( fPath.length() - 1, 1 );
58 return QFileInfo( fPath ).fileName();
60 return QFileInfo( fPath ).completeBaseName();
63 //******************************************************************
64 QString extension( const QString& path, bool full )
66 return full ? QFileInfo( path ).completeSuffix() : QFileInfo( path ).suffix();
69 //******************************************************************
70 QString addSlash( const QString& path )
73 if ( !res.isEmpty() && res.at( res.length() - 1 ) != QChar( '/' ) &&
74 res.at( res.length() - 1 ) != QChar( '\\' ) )
75 res += QDir::separator();
79 //******************************************************************
80 QRect makeRect( const int x1, const int y1, const int x2, const int y2 )
82 return QRect( qMin( x1, x2 ), qMin( y1, y2 ), qAbs( x2 - x1 ), qAbs( y2 - y1 ) );