aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/qmmpui/configdialog.cpp6
-rw-r--r--src/qmmpui/fileloader.cpp94
-rw-r--r--src/qmmpui/fileloader_p.h1
-rw-r--r--src/qmmpui/forms/configdialog.ui82
-rw-r--r--src/qmmpui/qmmpuisettings.cpp23
-rw-r--r--src/qmmpui/qmmpuisettings.h15
6 files changed, 171 insertions, 50 deletions
diff --git a/src/qmmpui/configdialog.cpp b/src/qmmpui/configdialog.cpp
index dc4b24fde..d23ce4768 100644
--- a/src/qmmpui/configdialog.cpp
+++ b/src/qmmpui/configdialog.cpp
@@ -106,7 +106,8 @@ void ConfigDialog::readSettings()
//playlist options
QmmpUiSettings *guis = QmmpUiSettings::instance();
m_ui->groupLineEdit->setText(guis->groupFormat());
- m_ui->metadataCheckBox->setChecked(guis->useMetaData());
+ m_ui->metaDataCheckBox->setChecked(guis->useMetaData());
+ m_ui->plMetaDataCheckBox->setChecked(guis->readMetaDataForPlayLists());
m_ui->underscoresCheckBox->setChecked(guis->convertUnderscore());
m_ui->per20CheckBox->setChecked(guis->convertTwenty());
m_ui->clearPrevPLCheckBox->setChecked(guis->clearPreviousPlayList());
@@ -376,7 +377,8 @@ void ConfigDialog::saveSettings()
if (QmmpUiSettings *guis = QmmpUiSettings::instance())
{
guis->setGroupFormat(m_ui->groupLineEdit->text().trimmed());
- guis->setUseMetaData(m_ui->metadataCheckBox->isChecked());
+ guis->setUseMetaData(m_ui->metaDataCheckBox->isChecked());
+ guis->setReadMetaDataForPlayLists(m_ui->plMetaDataCheckBox->isChecked());
guis->setConvertUnderscore(m_ui->underscoresCheckBox->isChecked());
guis->setConvertTwenty(m_ui->per20CheckBox->isChecked());
guis->setClearPreviousPlayList(m_ui->clearPrevPLCheckBox->isChecked());
diff --git a/src/qmmpui/fileloader.cpp b/src/qmmpui/fileloader.cpp
index 37b6a2b75..ac3a43749 100644
--- a/src/qmmpui/fileloader.cpp
+++ b/src/qmmpui/fileloader.cpp
@@ -34,6 +34,7 @@ FileLoader::FileLoader(QObject *parent) : QThread(parent)
qRegisterMetaType<QList<PlayListTrack*> >("QList<PlayListTrack*>");
m_settings = QmmpUiSettings::instance();
m_finished = false;
+ m_readMetaDataForPlayLists = true;
m_parts = TrackInfo::NoParts;
connect(qApp, SIGNAL(aboutToQuit()), SLOT(finish()));
}
@@ -86,24 +87,89 @@ void FileLoader::insertPlayList(const QString &path, PlayListItem *before)
{
QList<PlayListTrack *> tracks = PlayListParser::loadPlaylist(path);
- while (!tracks.isEmpty() && !m_finished)
+ if(m_readMetaDataForPlayLists)
{
- PlayListTrack *t = tracks.takeFirst();
- QList <TrackInfo *> infoList = MetaDataManager::instance()->createPlayList(t->path(), m_parts);
- if(infoList.count() != 1) //invalid or unsupported track
+ QList<PlayListTrack *> tmp;
+ while(!tracks.isEmpty() && !m_finished)
{
- qDeleteAll(infoList);
- infoList.clear();
- delete t;
- continue;
+ PlayListTrack *t = tracks.takeFirst();
+ QList <TrackInfo *> infoList = MetaDataManager::instance()->createPlayList(t->path(), m_parts);
+ if(infoList.count() != 1) //invalid or unsupported track
+ {
+ qDeleteAll(infoList);
+ infoList.clear();
+ delete t;
+ continue;
+ }
+
+ if(!infoList.first()->value(Qmmp::ALBUM).isEmpty() && !infoList.first()->value(Qmmp::ARTIST).isEmpty())
+ t->updateMetaData(infoList.first());
+ delete infoList.takeFirst();
+ tmp << t;
+ if(tmp.count() > 30)
+ {
+ emit newTracksToInsert(before, tmp);
+ tmp.clear();
+ }
+ }
+ if(!tmp.isEmpty() && !m_finished)
+ {
+ emit newTracksToInsert(before, tmp);
+ tmp.clear();
}
- TrackInfo *info = infoList.takeFirst();
- if(!info->value(Qmmp::ALBUM).isEmpty() && !info->value(Qmmp::ARTIST).isEmpty())
- t->updateMetaData(info);
+ if(!tmp.isEmpty())
+ {
+ qDeleteAll(tmp);
+ tmp.clear();
+ }
+ }
+ else
+ {
+ QStringList protocols = MetaDataManager::instance()->protocols();
+ QList<QRegExp> filters;
+ foreach(const QString &pattern, MetaDataManager::instance()->nameFilters())
+ filters << QRegExp(pattern, Qt::CaseInsensitive, QRegExp::Wildcard);
- emit newTracksToInsert(before, QList<PlayListTrack *>() << t); //TODO optimization
- delete info;
+
+ foreach(PlayListTrack *t, tracks)
+ {
+ if(t->path().contains("://"))
+ {
+ if(!protocols.contains(t->path().section("://",0,0)))
+ {
+ tracks.removeAll(t);
+ delete t;
+ }
+ }
+ else if(!QFile::exists(t->path()))
+ {
+ tracks.removeAll(t);
+ delete t;
+ }
+ else
+ {
+ bool found = false;
+ foreach(const QRegExp &filter, filters)
+ {
+ if(filter.exactMatch(t->path()))
+ {
+ found = true;
+ break;
+ }
+ }
+ if(!found)
+ {
+ tracks.removeAll(t);
+ delete t;
+ }
+ }
+ }
+ if(!m_finished && !tracks.isEmpty())
+ {
+ emit newTracksToInsert(before, tracks);
+ tracks.clear();
+ }
}
//clear remaining tracks
qDeleteAll(tracks);
@@ -246,6 +312,7 @@ void FileLoader::addPlayList(const QString &fmt, const QByteArray &data)
PlayListParser::loadFormats();
m_filters = MetaDataManager::instance()->nameFilters();
m_parts = m_settings->useMetaData() ? TrackInfo::AllParts : TrackInfo::NoParts;
+ m_readMetaDataForPlayLists = m_settings->readMetaDataForPlayLists();
}
start(QThread::IdlePriority);
}
@@ -272,6 +339,7 @@ void FileLoader::insert(PlayListItem *before, const QStringList &paths)
MetaDataManager::instance()->prepareForAnotherThread();
m_filters = MetaDataManager::instance()->nameFilters();
m_parts = m_settings->useMetaData() ? TrackInfo::AllParts : TrackInfo::NoParts;
+ m_readMetaDataForPlayLists = m_settings->readMetaDataForPlayLists();
}
start(QThread::IdlePriority);
}
diff --git a/src/qmmpui/fileloader_p.h b/src/qmmpui/fileloader_p.h
index d479ef786..f6b68f7c1 100644
--- a/src/qmmpui/fileloader_p.h
+++ b/src/qmmpui/fileloader_p.h
@@ -101,6 +101,7 @@ private:
QStringList m_filters;
QmmpUiSettings *m_settings;
bool m_finished;
+ bool m_readMetaDataForPlayLists;
TrackInfo::Parts m_parts;
QMutex m_mutex;
diff --git a/src/qmmpui/forms/configdialog.ui b/src/qmmpui/forms/configdialog.ui
index dc7dde824..40d49f705 100644
--- a/src/qmmpui/forms/configdialog.ui
+++ b/src/qmmpui/forms/configdialog.ui
@@ -124,43 +124,53 @@
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="2">
- <widget class="QCheckBox" name="metadataCheckBox">
+ <widget class="QCheckBox" name="metaDataCheckBox">
<property name="text">
<string>Load metadata from files</string>
</property>
</widget>
</item>
- <item row="1" column="0" colspan="2">
+ <item row="2" column="0" colspan="2">
<widget class="QCheckBox" name="underscoresCheckBox">
<property name="text">
<string>Convert underscores to blanks</string>
</property>
</widget>
</item>
- <item row="2" column="0" colspan="2">
+ <item row="3" column="0" colspan="2">
<widget class="QCheckBox" name="per20CheckBox">
<property name="text">
<string>Convert %20 to blanks</string>
</property>
</widget>
</item>
- <item row="3" column="0">
+ <item row="4" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Group format:</string>
</property>
</widget>
</item>
- <item row="3" column="1">
+ <item row="4" column="1">
<widget class="QLineEdit" name="groupLineEdit"/>
</item>
- <item row="3" column="2">
+ <item row="4" column="2">
<widget class="QToolButton" name="groupButton">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
+ <item row="1" column="0" colspan="3">
+ <widget class="QCheckBox" name="plMetaDataCheckBox">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Read tags while loading a playlist</string>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
</item>
@@ -891,12 +901,12 @@
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
- <x>348</x>
- <y>38</y>
+ <x>275</x>
+ <y>37</y>
</hint>
<hint type="destinationlabel">
- <x>348</x>
- <y>38</y>
+ <x>275</x>
+ <y>37</y>
</hint>
</hints>
</connection>
@@ -907,12 +917,12 @@
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
- <x>348</x>
- <y>38</y>
+ <x>275</x>
+ <y>37</y>
</hint>
<hint type="destinationlabel">
- <x>348</x>
- <y>38</y>
+ <x>275</x>
+ <y>37</y>
</hint>
</hints>
</connection>
@@ -923,12 +933,12 @@
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
- <x>272</x>
- <y>38</y>
+ <x>275</x>
+ <y>37</y>
</hint>
<hint type="destinationlabel">
- <x>272</x>
- <y>38</y>
+ <x>275</x>
+ <y>37</y>
</hint>
</hints>
</connection>
@@ -939,8 +949,8 @@
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
- <x>272</x>
- <y>38</y>
+ <x>275</x>
+ <y>37</y>
</hint>
<hint type="destinationlabel">
<x>272</x>
@@ -955,8 +965,8 @@
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
- <x>657</x>
- <y>448</y>
+ <x>633</x>
+ <y>482</y>
</hint>
<hint type="destinationlabel">
<x>225</x>
@@ -971,8 +981,8 @@
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
- <x>657</x>
- <y>448</y>
+ <x>633</x>
+ <y>482</y>
</hint>
<hint type="destinationlabel">
<x>141</x>
@@ -987,12 +997,28 @@
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
- <x>457</x>
- <y>226</y>
+ <x>275</x>
+ <y>37</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>275</x>
+ <y>37</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>metaDataCheckBox</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>plMetaDataCheckBox</receiver>
+ <slot>setEnabled(bool)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>257</x>
+ <y>50</y>
</hint>
<hint type="destinationlabel">
- <x>580</x>
- <y>227</y>
+ <x>261</x>
+ <y>80</y>
</hint>
</hints>
</connection>
diff --git a/src/qmmpui/qmmpuisettings.cpp b/src/qmmpui/qmmpuisettings.cpp
index bb52472b1..561e6c496 100644
--- a/src/qmmpui/qmmpuisettings.cpp
+++ b/src/qmmpui/qmmpuisettings.cpp
@@ -41,12 +41,13 @@ QmmpUiSettings::QmmpUiSettings(QObject *parent) : QObject(parent)
m_convertTwenty = s.value ("convert_twenty", true).toBool();
m_useMetaData = s.value ("load_metadata", true).toBool();
m_autosave_playlist = s.value("autosave", true).toBool();
- m_repeate_list = s.value("repeate_list",false).toBool();
- m_shuffle = s.value("shuffle",false).toBool();
- m_groups_enabled = s.value("groups",false).toBool();
- m_repeat_track = s.value("repeate_track",false).toBool();
- m_no_pl_advance = s.value("no_advance",false).toBool();
+ m_repeate_list = s.value("repeate_list", false).toBool();
+ m_shuffle = s.value("shuffle", false).toBool();
+ m_groups_enabled = s.value("groups", false).toBool();
+ m_repeat_track = s.value("repeate_track", false).toBool();
+ m_no_pl_advance = s.value("no_advance", false).toBool();
m_clear_prev_playlist = s.value("clear_previous", false).toBool();
+ m_read_metadata_for_playlist = s.value("read_metadata_for_playlist", true).toBool();
s.endGroup();
s.beginGroup("General");
m_resume_on_startup = s.value("resume_on_startup", false).toBool();
@@ -179,6 +180,7 @@ void QmmpUiSettings::sync()
s.setValue("PlayList/repeate_track", m_repeat_track);
s.setValue("PlayList/no_advance", m_no_pl_advance);
s.setValue("PlayList/clear_previous", m_clear_prev_playlist);
+ s.setValue("PlayList/read_metadata_for_playlist", m_read_metadata_for_playlist);
s.setValue("General/resume_on_startup", m_resume_on_startup);
s.setValue("General/restrict_filters", m_restrict_filters);
s.setValue("General/exclude_filters", m_exclude_filters);
@@ -299,3 +301,14 @@ bool QmmpUiSettings::clearPreviousPlayList() const
{
return m_clear_prev_playlist;
}
+
+bool QmmpUiSettings::readMetaDataForPlayLists() const
+{
+ return m_read_metadata_for_playlist;
+}
+
+void QmmpUiSettings::setReadMetaDataForPlayLists(bool enabled)
+{
+ m_read_metadata_for_playlist = enabled;
+ m_timer->start();
+}
diff --git a/src/qmmpui/qmmpuisettings.h b/src/qmmpui/qmmpuisettings.h
index 685122ccb..36e0f930a 100644
--- a/src/qmmpui/qmmpuisettings.h
+++ b/src/qmmpui/qmmpuisettings.h
@@ -159,7 +159,7 @@ public:
*/
void setAutoSavePlayList(bool enabled);
/*!
- * Return the current setting for the playlist auto-save option.
+ * Returns the current setting for the playlist auto-save option.
* @return \b true if the playlist should be saved automatically, \b false
* otherwise.
*/
@@ -170,12 +170,22 @@ public:
*/
void setClearPreviousPlayList(bool enabled);
/*!
- * Return the current setting for the option to clear playlist when opening new one.
+ * Returns the current setting for the option to clear playlist when opening new one.
* @return \b true if the playlist should be saved automatically, \b false
* otherwise.
*/
bool clearPreviousPlayList() const;
/*!
+ * Returns the current setting for the option to read tags when loading a playlist.
+ * \return \b true if tag reading is enabled, \b false otherwise.
+ */
+ bool readMetaDataForPlayLists() const;
+ /*!
+ * Enable/disable tag reading when loading a playlist.
+ * @param enabled New setting for this option (\b true to enable)
+ */
+ void setReadMetaDataForPlayLists(bool enabled);
+ /*!
* Returns a pointer to the QmmpUiSettings instance.
*/
static QmmpUiSettings* instance();
@@ -256,6 +266,7 @@ private:
bool m_repeat_track;
bool m_no_pl_advance;
bool m_clear_prev_playlist;
+ bool m_read_metadata_for_playlist;
//general
bool m_resume_on_startup;
QStringList m_exclude_filters, m_restrict_filters;