OSDN Git Service

Updated changelog.
[lamexp/LameXP.git] / src / Global_Utils.cpp
index b75ec82..727401f 100644 (file)
@@ -1,12 +1,12 @@
 ///////////////////////////////////////////////////////////////////////////////
 // LameXP - Audio Encoder Front-End
-// Copyright (C) 2004-2014 LoRd_MuldeR <MuldeR2@GMX.de>
+// Copyright (C) 2004-2023 LoRd_MuldeR <MuldeR2@GMX.de>
 //
 // This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
+// it under the terms of the GNU GENERAL PUBLIC LICENSE as published by
 // the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version, but always including the *additional*
-// restrictions defined in the "License.txt" file.
+// (at your option) any later version; always including the non-optional
+// LAMEXP GNU GENERAL PUBLIC LICENSE ADDENDUM. See "License.txt" file!
 //
 // This program is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -151,3 +151,41 @@ const QIcon &lamexp_app_icon(void)
 
        return *g_lamexp_icon_data;
 }
+
+/*
+ * Version number to human-readable string
+ */
+const QString lamexp_version2string(const QString &pattern, unsigned int version, const QString &defaultText, const QString &tag)
+{
+       if(version == UINT_MAX)
+       {
+               return defaultText;
+       }
+       
+       QString result = pattern;
+       const int digits = result.count(QChar(L'?'), Qt::CaseInsensitive);
+       
+       if(digits < 1)
+       {
+               return result;
+       }
+       
+       int pos = 0, index = -1;
+       const QString versionStr = QString().sprintf("%0*u", digits, version);
+       Q_ASSERT(versionStr.length() == digits);
+       
+       while((index = result.indexOf(QChar(L'?'), Qt::CaseInsensitive)) >= 0)
+       {
+               result[index] = versionStr[pos++];
+       }
+
+       if(!tag.isEmpty())
+       {
+               if((index = result.indexOf(QChar(L'#'), Qt::CaseInsensitive)) >= 0)
+               {
+                       result.remove(index, 1).insert(index, tag);
+               }
+       }
+
+       return result;
+}