diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/plugins/General/General.pro | 6 | ||||
| -rw-r--r-- | src/plugins/General/hal/halplugin.cpp | 20 | ||||
| -rw-r--r-- | src/plugins/General/udisks/udisksplugin.cpp | 20 | ||||
| -rw-r--r-- | src/plugins/General/udisks2/udisks2plugin.cpp | 12 | ||||
| -rw-r--r-- | src/qmmpui/playlistmodel.cpp | 9 |
5 files changed, 41 insertions, 26 deletions
diff --git a/src/plugins/General/General.pro b/src/plugins/General/General.pro index f24c01ff0..85a7bca6b 100644 --- a/src/plugins/General/General.pro +++ b/src/plugins/General/General.pro @@ -15,15 +15,15 @@ unix:SUBDIRS += mpris \ converter contains(CONFIG, UDISKS_PLUGIN){ -# unix:SUBDIRS += udisks + unix:SUBDIRS += udisks } contains(CONFIG, UDISKS2_PLUGIN){ -# unix:SUBDIRS += udisks2 + unix:SUBDIRS += udisks2 } contains(CONFIG, HAL_PLUGIN){ -# unix:SUBDIRS += hal + unix:SUBDIRS += hal } TEMPLATE = subdirs diff --git a/src/plugins/General/hal/halplugin.cpp b/src/plugins/General/hal/halplugin.cpp index 2f1dfd067..936d3d291 100644 --- a/src/plugins/General/hal/halplugin.cpp +++ b/src/plugins/General/hal/halplugin.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2009-2012 by Ilya Kotov * + * Copyright (C) 2009-2013 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -237,19 +237,23 @@ HalDevice *HalPlugin::findDevice(QAction *action) void HalPlugin::addPath(const QString &path) { - foreach(PlayListTrack *item, MediaPlayer::instance()->playListManager()->selectedPlayList()->items()) // Is it already exist? + PlayListModel *model = PlayListManager::instance()->selectedPlayList(); + + foreach(PlayListItem *item, model->items()) // Is it already exist? { - if (item->url().startsWith(path)) + if(item->isGroup()) + continue; + if (dynamic_cast<PlayListTrack *>(item)->url().startsWith(path)) return; } if (path.startsWith("cdda://") && m_addTracks) { - MediaPlayer::instance()->playListManager()->selectedPlayList()->add(path); + PlayListManager::instance()->selectedPlayList()->add(path); return; } else if (!path.startsWith("cdda://") && m_addFiles) - MediaPlayer::instance()->playListManager()->selectedPlayList()->add(path); + PlayListManager::instance()->selectedPlayList()->add(path); } void HalPlugin::removePath(const QString &path) @@ -258,13 +262,13 @@ void HalPlugin::removePath(const QString &path) (!path.startsWith("cdda://") && !m_removeFiles)) //process settings return; - PlayListModel *model = MediaPlayer::instance()->playListManager()->selectedPlayList(); + PlayListModel *model = PlayListManager::instance()->selectedPlayList(); int i = 0; while (model->count() > 0 && i < model->count()) { - if (model->item(i)->url().startsWith(path)) - model->removeAt (i); + if (model->isTrack(i) && model->track(i)->url().startsWith(path)) + model->removeTrack(i); else ++i; } diff --git a/src/plugins/General/udisks/udisksplugin.cpp b/src/plugins/General/udisks/udisksplugin.cpp index 220bf2c03..5034c992e 100644 --- a/src/plugins/General/udisks/udisksplugin.cpp +++ b/src/plugins/General/udisks/udisksplugin.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2010 by Ilya Kotov * + * Copyright (C) 2010-2013 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -231,19 +231,23 @@ UDisksDevice *UDisksPlugin::findDevice(QAction *action) void UDisksPlugin::addPath(const QString &path) { - foreach(PlayListTrack *item, MediaPlayer::instance()->playListManager()->selectedPlayList()->items()) // Is it already exist? + PlayListModel *model = PlayListManager::instance()->selectedPlayList(); + + foreach(PlayListItem *item, model->items()) // Is it already exist? { - if (item->url().startsWith(path)) + if(item->isGroup()) + continue; + if (dynamic_cast<PlayListTrack *>(item)->url().startsWith(path)) return; } if (path.startsWith("cdda://") && m_addTracks) { - MediaPlayer::instance()->playListManager()->selectedPlayList()->add(path); + PlayListManager::instance()->selectedPlayList()->add(path); return; } else if (!path.startsWith("cdda://") && m_addFiles) - MediaPlayer::instance()->playListManager()->selectedPlayList()->add(path); + PlayListManager::instance()->selectedPlayList()->add(path); } void UDisksPlugin::removePath(const QString &path) @@ -252,13 +256,13 @@ void UDisksPlugin::removePath(const QString &path) (!path.startsWith("cdda://") && !m_removeFiles)) //process settings return; - PlayListModel *model = MediaPlayer::instance()->playListManager()->selectedPlayList(); + PlayListModel *model = PlayListManager::instance()->selectedPlayList(); int i = 0; while (model->count() > 0 && i < model->count()) { - if (model->item(i)->url().startsWith(path)) - model->removeAt (i); + if (model->isTrack(i) && model->track(i)->url().startsWith(path)) + model->removeTrack(i); else ++i; } diff --git a/src/plugins/General/udisks2/udisks2plugin.cpp b/src/plugins/General/udisks2/udisks2plugin.cpp index bfee228d8..9024161bb 100644 --- a/src/plugins/General/udisks2/udisks2plugin.cpp +++ b/src/plugins/General/udisks2/udisks2plugin.cpp @@ -211,9 +211,13 @@ UDisks2Device *UDisks2Plugin::findDevice(QAction *action) void UDisks2Plugin::addPath(const QString &path) { - foreach(PlayListTrack *item, PlayListManager::instance()->selectedPlayList()->items()) // Is it already exist? + PlayListModel *model = PlayListManager::instance()->selectedPlayList(); + + foreach(PlayListItem *item, model->items()) // Is it already exist? { - if (item->url().startsWith(path)) + if(item->isGroup()) + continue; + if (dynamic_cast<PlayListTrack *>(item)->url().startsWith(path)) return; } @@ -237,8 +241,8 @@ void UDisks2Plugin::removePath(const QString &path) int i = 0; while (model->count() > 0 && i < model->count()) { - if (model->item(i)->url().startsWith(path)) - model->removeAt (i); + if (model->isTrack(i) && model->track(i)->url().startsWith(path)) + model->removeTrack(i); else ++i; } diff --git a/src/qmmpui/playlistmodel.cpp b/src/qmmpui/playlistmodel.cpp index a1b6fe68d..e325484f1 100644 --- a/src/qmmpui/playlistmodel.cpp +++ b/src/qmmpui/playlistmodel.cpp @@ -278,11 +278,14 @@ bool PlayListModel::isSelected(int index) const bool PlayListModel::contains(const QString &url) { - /*foreach (PlayListItem *item, m_items) + for(int i = 0; i < m_container->count(); ++i) { - if(item->url() == url) + PlayListTrack *t = track(i); + if(!t) + continue; + if(t->url() == url) return true; - }*/ + } return false; } |
