OSDN Git Service

Improved file analyzer to retain the original ordering of files imported from a playlist.
authorLoRd_MuldeR <mulder2@gmx.de>
Thu, 24 Oct 2013 22:48:18 +0000 (00:48 +0200)
committerLoRd_MuldeR <mulder2@gmx.de>
Thu, 24 Oct 2013 22:48:18 +0000 (00:48 +0200)
doc/Changelog.html
src/Config.h
src/Dialog_WorkingBanner.cpp
src/Thread_FileAnalyzer.cpp

index 9a56e98..58f3b7c 100644 (file)
@@ -19,9 +19,10 @@ a:visited { color: #0000EE; }
 
 <a name="4.09"></a>Changes between v4.08 and v4.09 [<font color="darkred">unreleased</font>]:<br><ul>
 <li>Upgraded build environment to Microsoft Visual Studio 2013 RTM
-<li>Improved internal encoder API, so each encoder can define its own configuration options
 <li>Complete overhaul of the file analyzer, resulting in up to 2.5x faster file import speed
 <li>Reworked the application initialization code, resulting in notably faster startup speed
+<li>Improved file analyzer to retain the original ordering of files imported from a playlist
+<li>Improved internal encoder API, so each encoder can define its own configuration options
 <li>Updated mpg123 decoder to v1.16.0 (2013-10-06), compiled with GCC 4.8.1
 <li>Updated GnuPG to v1.4.15 (2013-10-05), compiled with GCC 4.8.1
 <li>Various bugfixes and code improvements
index 086317e..35cee53 100644 (file)
@@ -34,8 +34,8 @@
 #define VER_LAMEXP_MINOR_HI                                    0
 #define VER_LAMEXP_MINOR_LO                                    9
 #define VER_LAMEXP_TYPE                                                Alpha
-#define VER_LAMEXP_PATCH                                       3
-#define VER_LAMEXP_BUILD                                       1418
+#define VER_LAMEXP_PATCH                                       4
+#define VER_LAMEXP_BUILD                                       1420
 #define VER_LAMEXP_CONFG                                       1348
 
 ///////////////////////////////////////////////////////////////////////////////
index a278d66..99f3415 100644 (file)
@@ -35,7 +35,7 @@
 /* It can happen that the QThread has just terminated and already emitted the 'terminated' signal, but did NOT change the 'isRunning' flag to FALSE yet. */
 /* For this reason the macro will first check the 'isRunning' flag. If (and only if) the flag still returns TRUE, then we will wait() for at most 50 ms. */
 /* If, after 50 ms, the wait() function returns with FALSE, then the thread probably is still running and we return TRUE. Otherwise we can return FALSE. */
-#define THREAD_RUNNING(THRD) (((THRD)->isRunning()) ? (!((THRD)->wait(50))) : false)
+#define THREAD_RUNNING(THRD) (((THRD)->isRunning()) ? (!((THRD)->wait(1))) : false)
 
 ////////////////////////////////////////////////////////////
 // Constructor
@@ -73,6 +73,9 @@ WorkingBanner::WorkingBanner(QWidget *parent)
        color.setColor(QPalette::WindowText, QColor::fromRgb(0x33, 0x33, 0x33));
        m_progress->setPalette(color);
 
+       //Set Opacity
+       this->setWindowOpacity(0.85);
+
        //Set wait cursor
        setCursor(Qt::WaitCursor);
 }
index 0ba3654..1da0529 100644 (file)
 #include <QTime>
 #include <QElapsedTimer>
 #include <QTimer>
+#include <QQueue>
+
+//Insert into QStringList *without* duplicates
+static inline void SAFE_APPEND_STRING(QStringList &list, const QString &str)
+{
+       if(!list.contains(str, Qt::CaseInsensitive))
+       {
+               list << str;
+       }
+}
 
 ////////////////////////////////////////////////////////////
 // Constructor
@@ -161,12 +171,18 @@ void FileAnalyzer::run()
                }
        }
 
-       //Handle playlist files
+       //Sort files
        lamexp_natural_string_sort(m_inputFiles, true);
+
+       //Handle playlist files first!
        handlePlaylistFiles();
-       lamexp_natural_string_sort(m_inputFiles, true);
 
        const unsigned int nFiles = m_inputFiles.count();
+       if(nFiles < 1)
+       {
+               qWarning("File list is empty, nothing to do!");
+               return;
+       }
 
        //Update progress
        emit progressMaxChanged(nFiles);
@@ -245,22 +261,51 @@ bool FileAnalyzer::analyzeNextFile(void)
 
 void FileAnalyzer::handlePlaylistFiles(void)
 {
-       QStringList importedFiles;
+       QQueue<QVariant> queue;
+       QStringList importedFromPlaylist;
+       
+       //Import playlist files into "hierarchical" list
        while(!m_inputFiles.isEmpty())
        {
                const QString currentFile = m_inputFiles.takeFirst();
-               if(!PlaylistImporter::importPlaylist(importedFiles, currentFile))
+               QStringList importedFiles;
+               if(PlaylistImporter::importPlaylist(importedFiles, currentFile))
                {
-                       importedFiles << currentFile;
+                       queue.enqueue(importedFiles);
+                       importedFromPlaylist << importedFiles;
+               }
+               else
+               {
+                       queue.enqueue(currentFile);
                }
        }
 
-       while(!importedFiles.isEmpty())
+       //Reduce temporary list
+       importedFromPlaylist.removeDuplicates();
+
+       //Now build the complete "flat" file list (files imported from playlist take precedence!)
+       while(!queue.isEmpty())
        {
-               const QString currentFile = importedFiles.takeFirst();
-               if(!m_inputFiles.contains(currentFile, Qt::CaseInsensitive))
+               const QVariant current = queue.dequeue();
+               if(current.type() == QVariant::String)
+               {
+                       const QString temp = current.toString();
+                       if(!importedFromPlaylist.contains(temp, Qt::CaseInsensitive))
+                       {
+                               SAFE_APPEND_STRING(m_inputFiles, temp);
+                       }
+               }
+               else if(current.type() == QVariant::StringList)
+               {
+                       const QStringList temp = current.toStringList();
+                       for(QStringList::ConstIterator iter = temp.constBegin(); iter != temp.constEnd(); iter++)
+                       {
+                               SAFE_APPEND_STRING(m_inputFiles, (*iter));
+                       }
+               }
+               else
                {
-                       m_inputFiles << currentFile;
+                       qWarning("Encountered an unexpected variant type!");
                }
        }
 }