00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
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