1 #include "XGUI_Tools.h"
5 //******************************************************************
6 QString library(const QString& str)
8 QString path = dir(str, false);
9 QString name = file(str, false);
10 QString ext = extension(str);
13 if ( !name.startsWith( "lib" ) )
14 name = QString( "lib" ) + name;
18 QString libExt("dll");
20 QString libExt( "so" );
23 if (ext.toLower() != QString("so") && ext.toLower() != QString("dll")) {
24 if (!name.isEmpty() && !ext.isEmpty())
31 QString fileName = addSlash(path) + name + QString(".") + ext;
36 //******************************************************************
37 QString dir(const QString& path, bool isAbs)
39 QDir aDir = QFileInfo(path).dir();
40 QString dirPath = isAbs ? aDir.absolutePath() : aDir.path();
41 if (dirPath == QString("."))
46 //******************************************************************
47 QString file(const QString& path, bool withExt)
50 while(!fPath.isEmpty() && (fPath[fPath.length() - 1] == '\\' || fPath[fPath.length() - 1] == '/'))
51 fPath.remove(fPath.length() - 1, 1);
54 return QFileInfo(fPath).fileName();
56 return QFileInfo(fPath).completeBaseName();
59 //******************************************************************
60 QString extension(const QString& path, bool full)
62 return full ? QFileInfo(path).completeSuffix() : QFileInfo(path).suffix();
65 //******************************************************************
66 QString addSlash(const QString& path)
69 if (!res.isEmpty() && res.at(res.length() - 1) != QChar('/')
70 && res.at(res.length() - 1) != QChar('\\'))
71 res += QDir::separator();
75 //******************************************************************
76 QRect makeRect(const int x1, const int y1, const int x2, const int y2)
78 return QRect(qMin(x1, x2), qMin(y1, y2), qAbs(x2 - x1), qAbs(y2 - y1));