Qmmp
playlisttask_p.h
1 /***************************************************************************
2  * Copyright (C) 2014-2016 by Ilya Kotov *
3  * forkotov02@ya.ru *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19  ***************************************************************************/
20 
21 #ifndef PLAYLISTTASK_P_H
22 #define PLAYLISTTASK_P_H
23 
24 #include <QThread>
25 #include <QObject>
26 #include <QHash>
27 #include <QList>
28 #include "playlistmodel.h"
29 #include "playlistcontainer_p.h"
30 
31 class PlayListTrack;
32 struct TrackField;
33 
34 
35 class PlayListTask : public QThread
36 {
37  Q_OBJECT
38 public:
39 
40  enum TaskType
41  {
42  EMPTY = -1,
43  SORT = 0,
44  SORT_SELECTION,
45  REMOVE_INVALID,
46  REMOVE_DUPLICATES,
47  SORT_BY_COLUMN,
48  REFRESH
49  };
50  explicit PlayListTask(QObject *parent);
51 
52  ~PlayListTask();
53 
54  void sort(QList<PlayListTrack *> tracks, PlayListModel::SortMode mode);
55  void sortSelection(QList<PlayListTrack *> tracks, PlayListModel::SortMode mode);
56  void sortByColumn(QList <PlayListTrack *> tracks, int column);
57  void removeInvalidTracks(QList<PlayListTrack *> tracks, PlayListTrack *current_track);
58  void removeDuplicates(QList<PlayListTrack *> tracks, PlayListTrack *current_track);
59  void refresh(QList<PlayListTrack *> tracks, PlayListTrack *current_track);
60 
61  void run() override;
62 
63  TaskType type() const;
64  bool isChanged(PlayListContainer *container);
65  QList<PlayListTrack *> takeResults(PlayListTrack **current_track);
66  PlayListTrack *currentTrack() const;
67  int column() const;
68  bool isReverted() const;
69  void clear();
70 
71 
72 private:
73  QList <TrackField *> m_fields;
74  QList <PlayListTrack *> m_tracks;
75  QList <PlayListTrack *> m_input_tracks;
76  QList<int> m_indexes;
77  QList <PlayListTrack *> m_new_tracks;
78  PlayListTrack *m_current_track;
79  int m_sort_mode;
80  TaskType m_task;
81  bool m_reverted;
82  bool m_align_groups;
83  int m_column;
84  QHash<int, Qmmp::MetaData> m_sort_keys;
85 
86 };
87 
88 #endif // PLAYLISTTASK_P_H
The PlayListTrack class provides a track for use with the PlayListModel class.
Definition: playlisttrack.h:36
SortMode
Definition: playlistmodel.h:319