Qmmp
|
00001 /*************************************************************************** 00002 * Copyright (C) 2014-2016 by Ilya Kotov * 00003 * forkotov02@hotmail.ru * 00004 * * 00005 * This program is free software; you can redistribute it and/or modify * 00006 * it under the terms of the GNU General Public License as published by * 00007 * the Free Software Foundation; either version 2 of the License, or * 00008 * (at your option) any later version. * 00009 * * 00010 * This program is distributed in the hope that it will be useful, * 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00013 * GNU General Public License for more details. * 00014 * * 00015 * You should have received a copy of the GNU General Public License * 00016 * along with this program; if not, write to the * 00017 * Free Software Foundation, Inc., * 00018 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * 00019 ***************************************************************************/ 00020 00021 #ifndef PLAYLISTTASK_P_H 00022 #define PLAYLISTTASK_P_H 00023 00024 #include <QThread> 00025 #include <QObject> 00026 #include <QHash> 00027 #include <QList> 00028 #include "playlistmodel.h" 00029 #include "playlistcontainer_p.h" 00030 00031 class PlayListTrack; 00032 struct TrackField; 00033 00034 00035 class PlayListTask : public QThread 00036 { 00037 Q_OBJECT 00038 public: 00039 00040 enum TaskType 00041 { 00042 EMPTY = -1, 00043 SORT = 0, 00044 SORT_SELECTION, 00045 REMOVE_INVALID, 00046 REMOVE_DUPLICATES, 00047 SORT_BY_COLUMN, 00048 REFRESH 00049 }; 00050 explicit PlayListTask(QObject *parent); 00051 00052 ~PlayListTask(); 00053 00054 void sort(QList<PlayListTrack *> tracks, int mode); 00055 void sortSelection(QList<PlayListTrack *> tracks, int mode); 00056 void sortByColumn(QList <PlayListTrack *> tracks, int column); 00057 void removeInvalidTracks(QList<PlayListTrack *> tracks, PlayListTrack *current_track); 00058 void removeDuplicates(QList<PlayListTrack *> tracks, PlayListTrack *current_track); 00059 void refresh(QList<PlayListTrack *> tracks, PlayListTrack *current_track); 00060 00061 void run(); 00062 00063 TaskType type() const; 00064 bool isChanged(PlayListContainer *container); 00065 QList<PlayListTrack *> takeResults(PlayListTrack **current_track); 00066 PlayListTrack *currentTrack() const; 00067 int column() const; 00068 bool isReverted() const; 00069 void clear(); 00070 00071 00072 private: 00073 QList <TrackField *> m_fields; 00074 QList <PlayListTrack *> m_tracks; 00075 QList <PlayListTrack *> m_input_tracks; 00076 QList<int> m_indexes; 00077 QList <PlayListTrack *> m_new_tracks; 00078 PlayListTrack *m_current_track; 00079 int m_sort_mode; 00080 TaskType m_task; 00081 bool m_reverted; 00082 bool m_align_groups; 00083 int m_column; 00084 QHash<int, Qmmp::MetaData> m_sort_keys; 00085 00086 }; 00087 00088 #endif // PLAYLISTTASK_P_H