# HG changeset patch # User Teemu Piippo # Date 1521889877 -7200 # Node ID 025578d6e4911742f9274727e9225408cf5a3cbe # Parent d68d1ce89d05e2fe6c84415a7fc06c3a79af87ae rewrote LDDocument::shortenName using Qt stuff diff -r d68d1ce89d05 -r 025578d6e491 src/documentmanager.cpp --- a/src/documentmanager.cpp Sat Mar 24 13:03:02 2018 +0200 +++ b/src/documentmanager.cpp Sat Mar 24 13:11:17 2018 +0200 @@ -26,8 +26,6 @@ #include "parser.h" #include "editHistory.h" -const QStringList DocumentManager::specialSubdirectories {"s", "48", "8"}; - enum { MaxRecentFiles = 10 diff -r d68d1ce89d05 -r 025578d6e491 src/documentmanager.h --- a/src/documentmanager.h Sat Mar 24 13:03:02 2018 +0200 +++ b/src/documentmanager.h Sat Mar 24 13:11:17 2018 +0200 @@ -51,8 +51,6 @@ void openMainModel (QString path); bool preInline (LDDocument* doc, Model& model, bool deep, bool renderinline); - static const QStringList specialSubdirectories; - signals: void documentClosed(LDDocument* document); diff -r d68d1ce89d05 -r 025578d6e491 src/lddocument.cpp --- a/src/lddocument.cpp Sat Mar 24 13:03:02 2018 +0200 +++ b/src/lddocument.cpp Sat Mar 24 13:11:17 2018 +0200 @@ -548,15 +548,15 @@ // ============================================================================= // -QString LDDocument::shortenName (QString a) // [static] +QString LDDocument::shortenName(const QFileInfo& path) // [static] { - QString shortname = Basename (a); - QString topdirname = Basename (Dirname (a)); + QString shortname = path.fileName(); + QString topdirname = QFileInfo {path.absoluteFilePath()}.dir().dirName(); - if (DocumentManager::specialSubdirectories.contains (topdirname)) - shortname.prepend (topdirname + "\\"); - - return shortname; + if (isOneOf(topdirname, "s", "48", "8")) + return topdirname + "\\" + shortname; + else + return shortname; } // ============================================================================= diff -r d68d1ce89d05 -r 025578d6e491 src/lddocument.h --- a/src/lddocument.h Sat Mar 24 13:03:02 2018 +0200 +++ b/src/lddocument.h Sat Mar 24 13:11:17 2018 +0200 @@ -121,7 +121,7 @@ void undo(); void vertexChanged (const Vertex& a, const Vertex& b); - static QString shortenName (QString a); // Turns a full path into a relative path + static QString shortenName(const class QFileInfo& path); // Turns a full path into a relative path protected: LDObject* withdrawAt(int position);