# HG changeset patch # User Teemu Piippo # Date 1521892130 -7200 # Node ID 1fffb24d4ffe85ec0f93e641d9b92ff5befaa810 # Parent f10b0c32a85dbbd8e7f7ad9f7ca31fecd302bbed replaced remaining DIRSLASH, Dirname and Basename uses with Qt file info stuff diff -r f10b0c32a85d -r 1fffb24d4ffe src/basics.h --- a/src/basics.h Sat Mar 24 13:42:34 2018 +0200 +++ b/src/basics.h Sat Mar 24 13:48:50 2018 +0200 @@ -41,15 +41,6 @@ using Self = SELF; \ using Super = SUPER; -// TODO: get rid of this -#ifdef WIN32 -# define DIRSLASH "\\" -# define DIRSLASH_CHAR '\\' -#else // WIN32 -# define DIRSLASH "/" -# define DIRSLASH_CHAR '/' -#endif // WIN32 - class LDObject; using GLRotationMatrix = QMatrix4x4; diff -r f10b0c32a85d -r 1fffb24d4ffe src/documentmanager.cpp --- a/src/documentmanager.cpp Sat Mar 24 13:42:34 2018 +0200 +++ b/src/documentmanager.cpp Sat Mar 24 13:48:50 2018 +0200 @@ -170,31 +170,6 @@ return nullptr; } -QString Dirname (QString path) -{ - int lastpos = path.lastIndexOf (DIRSLASH); - - if (lastpos > 0) - return path.left (lastpos); - -#ifndef _WIN32 - if (path[0] == DIRSLASH_CHAR) - return DIRSLASH; -#endif // _WIN32 - - return ""; -} - -QString Basename (QString path) -{ - int lastpos = path.lastIndexOf (DIRSLASH); - - if (lastpos != -1) - return path.mid (lastpos + 1); - - return path; -} - QString DocumentManager::findDocument(QString name) const { name = name.replace("\\", "/"); diff -r f10b0c32a85d -r 1fffb24d4ffe src/documentmanager.h --- a/src/documentmanager.h Sat Mar 24 13:42:34 2018 +0200 +++ b/src/documentmanager.h Sat Mar 24 13:48:50 2018 +0200 @@ -63,6 +63,3 @@ LDDocument* m_logoedStud; LDDocument* m_logoedStud2; }; - -QString Basename (QString path); -QString Dirname (QString path); diff -r f10b0c32a85d -r 1fffb24d4ffe src/glcompiler.cpp --- a/src/glcompiler.cpp Sat Mar 24 13:42:34 2018 +0200 +++ b/src/glcompiler.cpp Sat Mar 24 13:48:50 2018 +0200 @@ -61,7 +61,7 @@ } } - element->print("OpenGL ERROR: at %1:%2: %3", Basename(file), line, errorMessage); + element->print("OpenGL ERROR: at %1:%2: %3", file, line, errorMessage); } } diff -r f10b0c32a85d -r 1fffb24d4ffe src/partdownloader.cpp --- a/src/partdownloader.cpp Sat Mar 24 13:42:34 2018 +0200 +++ b/src/partdownloader.cpp Sat Mar 24 13:48:50 2018 +0200 @@ -191,11 +191,11 @@ _isAborted = false; if (sourceType() == CustomURL) - destination = Basename(url()); + destination = QUrl {url()}.fileName(); modifyDestination(destination); - if (QFile::exists(downloadPath() + DIRSLASH + destination)) + if (QDir {downloadPath()}.exists(destination)) { QString message = format(tr("%1 already exists in download directory. Overwrite?"), destination); int answer = QMessageBox::question(this, tr("Overwrite"), message, (QMessageBox::Yes | QMessageBox::No), QMessageBox::No); @@ -313,12 +313,7 @@ QString PartDownloader::downloadPath() { - QString path = config::downloadFilePath(); - - if (DIRSLASH[0] != '/') - path.replace(DIRSLASH, "/"); - - return path; + return config::downloadFilePath(); } QTableWidget* PartDownloader::progressTable() const diff -r f10b0c32a85d -r 1fffb24d4ffe src/primitives.cpp --- a/src/primitives.cpp Sat Mar 24 13:42:34 2018 +0200 +++ b/src/primitives.cpp Sat Mar 24 13:48:50 2018 +0200 @@ -47,7 +47,7 @@ QString PrimitiveManager::getPrimitivesCfgPath() const { - return qApp->applicationDirPath() + DIRSLASH "prims.cfg"; + return QDir {qApp->applicationDirPath()}.filePath("prims.cfg"); } diff -r f10b0c32a85d -r 1fffb24d4ffe src/toolsets/viewtoolset.cpp --- a/src/toolsets/viewtoolset.cpp Sat Mar 24 13:42:34 2018 +0200 +++ b/src/toolsets/viewtoolset.cpp Sat Mar 24 13:48:50 2018 +0200 @@ -116,7 +116,7 @@ const char* imageFormats = "PNG images (*.png);;JPG images (*.jpg);;BMP images (*.bmp);;" "PPM images (*.ppm);;X11 Bitmaps (*.xbm);;X11 Pixmaps (*.xpm);;All Files (*.*)"; QImage image = m_window->renderer()->screenCapture(); - QString root = Basename (currentDocument()->name()); + QString root = QFileInfo {currentDocument()->name()}.fileName(); if (root.right (4) == ".dat") root.chop (4);