1 #include "XGUI_Tools.h"
5 //******************************************************************
6 QString dir(const QString& path, bool isAbs)
8 QDir aDir = QFileInfo(path).dir();
9 QString dirPath = isAbs ? aDir.absolutePath() : aDir.path();
10 if (dirPath == QString("."))
15 //******************************************************************
16 QString file(const QString& path, bool withExt)
19 while(!fPath.isEmpty() && (fPath[fPath.length() - 1] == '\\' || fPath[fPath.length() - 1] == '/'))
20 fPath.remove(fPath.length() - 1, 1);
23 return QFileInfo(fPath).fileName();
25 return QFileInfo(fPath).completeBaseName();
28 //******************************************************************
29 QString extension(const QString& path, bool full)
31 return full ? QFileInfo(path).completeSuffix() : QFileInfo(path).suffix();
34 //******************************************************************
35 QString addSlash(const QString& path)
38 if (!res.isEmpty() && res.at(res.length() - 1) != QChar('/')
39 && res.at(res.length() - 1) != QChar('\\'))
40 res += QDir::separator();
44 //******************************************************************
45 QRect makeRect(const int x1, const int y1, const int x2, const int y2)
47 return QRect(qMin(x1, x2), qMin(y1, y2), qAbs(x2 - x1), qAbs(y2 - y1));