aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/plugins/Ui/qsui/actionmanager.cpp3
-rw-r--r--src/plugins/Ui/qsui/actionmanager.h3
-rw-r--r--src/plugins/Ui/qsui/mainwindow.cpp2
-rw-r--r--src/plugins/Ui/skinned/actionmanager.cpp3
-rw-r--r--src/plugins/Ui/skinned/actionmanager.h3
-rw-r--r--src/plugins/Ui/skinned/mainwindow.cpp2
-rw-r--r--src/plugins/Ui/skinned/playlist.cpp2
-rw-r--r--src/qmmpui/playlistmodel.cpp5
-rw-r--r--src/qmmpui/playlistmodel.h2
-rw-r--r--src/qmmpui/playlisttask.cpp62
-rw-r--r--src/qmmpui/playlisttask_p.h3
11 files changed, 77 insertions, 13 deletions
diff --git a/src/plugins/Ui/qsui/actionmanager.cpp b/src/plugins/Ui/qsui/actionmanager.cpp
index 97d153206..2e63a0faa 100644
--- a/src/plugins/Ui/qsui/actionmanager.cpp
+++ b/src/plugins/Ui/qsui/actionmanager.cpp
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2010-2015 by Ilya Kotov *
+ * Copyright (C) 2010-2016 by Ilya Kotov *
* forkotov02@hotmail.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -79,6 +79,7 @@ ActionManager::ActionManager(QObject *parent) :
m_actions[PL_REMOVE_INVALID] = createAction(tr("Remove unavailable files"), "remove_invalid",
"", "dialog-error");
m_actions[PL_REMOVE_DUPLICATES] = createAction(tr("Remove duplicates"), "remove_duplicates", "");
+ m_actions[PL_REFRESH] = createAction(tr("Refresh"), "refresh", "F5", "view-refresh");
m_actions[PL_ENQUEUE] = createAction(tr("&Queue Toggle"), "enqueue", tr("Q"));
m_actions[PL_INVERT_SELECTION] = createAction(tr("Invert Selection"), "invert_selection", "");
m_actions[PL_CLEAR_SELECTION] = createAction(tr("&Select None"), "clear_selection", "");
diff --git a/src/plugins/Ui/qsui/actionmanager.h b/src/plugins/Ui/qsui/actionmanager.h
index e863c5788..1a1980e41 100644
--- a/src/plugins/Ui/qsui/actionmanager.h
+++ b/src/plugins/Ui/qsui/actionmanager.h
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2010-2015 by Ilya Kotov *
+ * Copyright (C) 2010-2016 by Ilya Kotov *
* forkotov02@hotmail.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -81,6 +81,7 @@ public:
PL_REMOVE_UNSELECTED,
PL_REMOVE_INVALID,
PL_REMOVE_DUPLICATES,
+ PL_REFRESH,
PL_ENQUEUE,
PL_INVERT_SELECTION,
PL_CLEAR_SELECTION,
diff --git a/src/plugins/Ui/qsui/mainwindow.cpp b/src/plugins/Ui/qsui/mainwindow.cpp
index b7c44e363..ab784f1af 100644
--- a/src/plugins/Ui/qsui/mainwindow.cpp
+++ b/src/plugins/Ui/qsui/mainwindow.cpp
@@ -473,6 +473,8 @@ void MainWindow::createActions()
SLOT(removeInvalidTracks())));
m_ui.menuEdit->addAction(SET_ACTION(ActionManager::PL_REMOVE_DUPLICATES, m_pl_manager,
SLOT(removeDuplicates())));
+ m_ui.menuEdit->addAction(SET_ACTION(ActionManager::PL_REFRESH, m_pl_manager,
+ SLOT(refresh())));
m_ui.menuEdit->addSeparator();
//view menu
m_ui.menuView->addAction(SET_ACTION(ActionManager::WM_ALLWAYS_ON_TOP, this, SLOT(readSettings())));
diff --git a/src/plugins/Ui/skinned/actionmanager.cpp b/src/plugins/Ui/skinned/actionmanager.cpp
index c1b0607af..52b655593 100644
--- a/src/plugins/Ui/skinned/actionmanager.cpp
+++ b/src/plugins/Ui/skinned/actionmanager.cpp
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2010-2015 by Ilya Kotov *
+ * Copyright (C) 2010-2016 by Ilya Kotov *
* forkotov02@hotmail.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -75,6 +75,7 @@ ActionManager::ActionManager(QObject *parent) :
m_actions[PL_REMOVE_INVALID] = createAction(tr("Remove unavailable files"), "remove_invalid",
"", "dialog-error");
m_actions[PL_REMOVE_DUPLICATES] = createAction(tr("Remove duplicates"), "remove_duplicates", "");
+ m_actions[PL_REFRESH] = createAction(tr("Refresh"), "refresh", "F5", "view-refresh");
m_actions[PL_ENQUEUE] = createAction(tr("&Queue Toggle"), "enqueue", tr("Q"));
m_actions[PL_INVERT_SELECTION] = createAction(tr("Invert Selection"), "invert_selection", "");
m_actions[PL_CLEAR_SELECTION] = createAction(tr("&Select None"), "clear_selection", "");
diff --git a/src/plugins/Ui/skinned/actionmanager.h b/src/plugins/Ui/skinned/actionmanager.h
index 193273b1e..3723f5970 100644
--- a/src/plugins/Ui/skinned/actionmanager.h
+++ b/src/plugins/Ui/skinned/actionmanager.h
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2010-2015 by Ilya Kotov *
+ * Copyright (C) 2010-2016 by Ilya Kotov *
* forkotov02@hotmail.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -78,6 +78,7 @@ public:
PL_REMOVE_UNSELECTED,
PL_REMOVE_INVALID,
PL_REMOVE_DUPLICATES,
+ PL_REFRESH,
PL_ENQUEUE,
PL_INVERT_SELECTION,
PL_CLEAR_SELECTION,
diff --git a/src/plugins/Ui/skinned/mainwindow.cpp b/src/plugins/Ui/skinned/mainwindow.cpp
index cab91a4f9..f50de5466 100644
--- a/src/plugins/Ui/skinned/mainwindow.cpp
+++ b/src/plugins/Ui/skinned/mainwindow.cpp
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2006-2015 by Ilya Kotov *
+ * Copyright (C) 2006-2016 by Ilya Kotov *
* forkotov02@hotmail.ru *
* *
* This program is free software; you can redistribute it and/or modify *
diff --git a/src/plugins/Ui/skinned/playlist.cpp b/src/plugins/Ui/skinned/playlist.cpp
index cc7412281..6cdc8b9e8 100644
--- a/src/plugins/Ui/skinned/playlist.cpp
+++ b/src/plugins/Ui/skinned/playlist.cpp
@@ -207,6 +207,8 @@ void PlayList::createActions()
SLOT(removeInvalidTracks())));
m_subMenu->addAction(SET_ACTION(ActionManager::PL_REMOVE_DUPLICATES, m_pl_manager,
SLOT(removeDuplicates())));
+ m_subMenu->addAction(SET_ACTION(ActionManager::PL_REFRESH, m_pl_manager,
+ SLOT(refresh())));
//sort menu
m_sortMenu->addAction(SET_ACTION(ActionManager::PL_SHOW_INFO, m_pl_manager, SLOT (showDetails ())));
m_sortMenu->addSeparator();
diff --git a/src/qmmpui/playlistmodel.cpp b/src/qmmpui/playlistmodel.cpp
index fc8824fe4..bc0d057a8 100644
--- a/src/qmmpui/playlistmodel.cpp
+++ b/src/qmmpui/playlistmodel.cpp
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright(C) 2006-2015 by Ilya Kotov *
+ * Copyright(C) 2006-2016 by Ilya Kotov *
* forkotov02@hotmail.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -900,7 +900,8 @@ void PlayListModel::onTaskFinished()
emit sortingByColumnFinished(m_task->column(), m_task->isReverted());
}
else if(m_task->type() == PlayListTask::REMOVE_INVALID
- || m_task->type() == PlayListTask::REMOVE_DUPLICATES)
+ || m_task->type() == PlayListTask::REMOVE_DUPLICATES
+ || m_task->type() == PlayListTask::REFRESH)
{
PlayListTrack *prev_current_track = m_current_track;
bool prev_count = m_container->count();
diff --git a/src/qmmpui/playlistmodel.h b/src/qmmpui/playlistmodel.h
index f0f7f71da..7fa6753c9 100644
--- a/src/qmmpui/playlistmodel.h
+++ b/src/qmmpui/playlistmodel.h
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2006-2015 by Ilya Kotov *
+ * Copyright (C) 2006-2016 by Ilya Kotov *
* forkotov02@hotmail.ru *
* *
* This program is free software; you can redistribute it and/or modify *
diff --git a/src/qmmpui/playlisttask.cpp b/src/qmmpui/playlisttask.cpp
index 9f92a1462..9ce36f153 100644
--- a/src/qmmpui/playlisttask.cpp
+++ b/src/qmmpui/playlisttask.cpp
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2014-2015 by Ilya Kotov *
+ * Copyright (C) 2014-2016 by Ilya Kotov *
* forkotov02@hotmail.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -384,19 +384,65 @@ void PlayListTask::run()
else if(m_task == REFRESH)
{
TrackField *f = 0;
+ MetaDataManager *mm = MetaDataManager::instance();
bool ok = false;
+ //find invalid files
for(int i = 0; i < m_fields.count(); ++i)
{
f = m_fields.at(i);
if(f->value.contains("://"))
- ok = MetaDataManager::instance()->protocols().contains(f->value.section("://",0,0)); //url
+ ok = mm->protocols().contains(f->value.section("://",0,0)); //url
else
- ok = MetaDataManager::instance()->supports(f->value); //local file
+ ok = mm->supports(f->value); //local file
if(!ok)
m_indexes << i;
}
+ //find new files
+ QStringList dirs; QString path;
+ for(int i = 0; i < m_fields.count(); ++i)
+ {
+ f = m_fields.at(i);
+
+ if(f->value.contains("://")) //skip urls
+ continue;
+
+ path = QFileInfo(f->value).canonicalPath();
+
+ if(!dirs.contains(path))
+ dirs << path;
+ }
+
+ QFileInfoList l;
+ foreach (QString p, dirs)
+ {
+ QDir dir(p);
+ dir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks);
+ dir.setSorting(QDir::Name);
+ l << dir.entryInfoList(mm->nameFilters());
+ }
+
+ foreach (QFileInfo f, l)
+ {
+ bool contains = false;
+ foreach (TrackField *t, m_fields)
+ {
+ if(f.canonicalFilePath() == t->value)
+ {
+ contains = true;
+ break;
+ }
+ }
+
+ if(!contains)
+ {
+ foreach (FileInfo *info, mm->createPlayList(f.canonicalFilePath()))
+ {
+ m_new_tracks << new PlayListTrack(info);
+ }
+ }
+ }
}
qDebug("PlayListTask: finished");
}
@@ -426,7 +472,7 @@ QList<PlayListTrack *> PlayListTask::takeResults(PlayListTrack **current_track)
for (int i = 0; i < m_indexes.count(); i++)
m_tracks.replace(m_indexes[i], m_fields[i]->track);
}
- else if(m_task == REMOVE_INVALID || m_task == REMOVE_DUPLICATES)
+ else if(m_task == REMOVE_INVALID || m_task == REMOVE_DUPLICATES || m_task == REFRESH)
{
int index = 0;
PlayListTrack *t = 0;
@@ -449,6 +495,12 @@ QList<PlayListTrack *> PlayListTask::takeResults(PlayListTrack **current_track)
else
delete t;
}
+
+ if(m_task == REFRESH)
+ {
+ m_tracks.append(m_new_tracks);
+ m_new_tracks.clear();
+ }
}
return m_tracks;
}
@@ -467,6 +519,8 @@ void PlayListTask::clear()
{
qDeleteAll(m_fields);
m_fields.clear();
+ qDeleteAll(m_new_tracks);
+ m_new_tracks.clear();
m_align_groups = false;
m_indexes.clear();
m_input_tracks.clear();
diff --git a/src/qmmpui/playlisttask_p.h b/src/qmmpui/playlisttask_p.h
index ea5c214d0..6799d635e 100644
--- a/src/qmmpui/playlisttask_p.h
+++ b/src/qmmpui/playlisttask_p.h
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2014-2015 by Ilya Kotov *
+ * Copyright (C) 2014-2016 by Ilya Kotov *
* forkotov02@hotmail.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -74,6 +74,7 @@ private:
QList <PlayListTrack *> m_tracks;
QList <PlayListTrack *> m_input_tracks;
QList<int> m_indexes;
+ QList <PlayListTrack *> m_new_tracks;
PlayListTrack *m_current_track;
int m_sort_mode;
TaskType m_task;