Sat, 24 Mar 2018 13:48:50 +0200
replaced remaining DIRSLASH, Dirname and Basename uses with Qt file info stuff
src/basics.h | file | annotate | diff | comparison | revisions | |
src/documentmanager.cpp | file | annotate | diff | comparison | revisions | |
src/documentmanager.h | file | annotate | diff | comparison | revisions | |
src/glcompiler.cpp | file | annotate | diff | comparison | revisions | |
src/partdownloader.cpp | file | annotate | diff | comparison | revisions | |
src/primitives.cpp | file | annotate | diff | comparison | revisions | |
src/toolsets/viewtoolset.cpp | file | annotate | diff | comparison | revisions |
--- 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;
--- 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("\\", "/");
--- 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);
--- 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); } }
--- 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
--- 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"); }
--- 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);