- refactor

Mon, 01 Sep 2014 10:00:29 +0300

author
Teemu Piippo <crimsondusk64@gmail.com>
date
Mon, 01 Sep 2014 10:00:29 +0300
changeset 872
977099f224d0
parent 871
a860edb4210b
child 873
201083693300

- refactor

src/ldDocument.cc file | annotate | diff | comparison | revisions
src/miscallenous.cc file | annotate | diff | comparison | revisions
--- a/src/ldDocument.cc	Sun Aug 31 20:54:56 2014 +0300
+++ b/src/ldDocument.cc	Mon Sep 01 10:00:29 2014 +0300
@@ -525,14 +525,16 @@
 //
 LDDocumentPtr OpenDocument (QString path, bool search, bool implicit, LDDocumentPtr fileToOverride)
 {
-	// Convert the file name to lowercase since some parts contain uppercase
-	// file names. I'll assume here that the library will always use lowercase
-	// file names for the actual parts..
+	// Convert the file name to lowercase when searching because some parts contain subfile
+	// subfile references with uppercase file names. I'll assume here that the library will always
+	// use lowercase file names for the part files.
 	QFile* fp;
 	QString fullpath;
 
 	if (search)
+	{
 		fp = OpenLDrawFile (path.toLower(), true, &fullpath);
+	}
 	else
 	{
 		fp = new QFile (path);
@@ -665,24 +667,23 @@
 //
 void AddRecentFile (QString path)
 {
-	auto& rfiles = cfg::RecentFiles;
-	int idx = rfiles.indexOf (path);
+	int idx = cfg::RecentFiles.indexOf (path);
 
 	// If this file already is in the list, pop it out.
 	if (idx != -1)
 	{
-		if (idx == rfiles.size() - 1)
+		if (idx == cfg::RecentFiles.size() - 1)
 			return; // first recent file - abort and do nothing
 
-		rfiles.removeAt (idx);
+		cfg::RecentFiles.removeAt (idx);
 	}
 
 	// If there's too many recent files, drop one out.
-	while (rfiles.size() > (g_maxRecentFiles - 1))
-		rfiles.removeAt (0);
+	while (cfg::RecentFiles.size() > (g_maxRecentFiles - 1))
+		cfg::RecentFiles.removeAt (0);
 
 	// Add the file
-	rfiles << path;
+	cfg::RecentFiles << path;
 
 	Config::Save();
 	g_win->updateRecentFilesMenu();
--- a/src/miscallenous.cc	Sun Aug 31 20:54:56 2014 +0300
+++ b/src/miscallenous.cc	Mon Sep 01 10:00:29 2014 +0300
@@ -295,14 +295,12 @@
 //
 QString MakePrettyFileSize (qint64 size)
 {
-	QString result;
-
-	if (size < 1024)
+	if (size < 1024LL)
 		return QString::number (size) + " bytes";
-	else if (size < (1024 * 1024))
-		return QString::number ((double) size / 1024, 'f', 1) + " Kb";
-	else if (size < (1024 * 1024 * 1024))
-		return QString::number ((double) size / (1024 * 1024), 'f', 1) + " Mb";
+	else if (size < (1024LL * 1024LL))
+		return QString::number (double (size) / 1024LL, 'f', 1) + " Kb";
+	else if (size < (1024LL * 1024LL * 1024LL))
+		return QString::number (double (size) / (1024LL * 1024LL), 'f', 1) + " Mb";
 	else
-		return QString::number ((double) size / (1024 * 1024 * 1024), 'f', 1) + " Gb";
+		return QString::number (double (size) / (1024LL * 1024LL * 1024LL), 'f', 1) + " Gb";
 }

mercurial