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 
37 class PlayListTask : public QThread
38 {
39  Q_OBJECT
40 public:
41 
42  enum TaskType
43  {
44  EMPTY = -1,
45  SORT = 0,
46  SORT_SELECTION,
47  REMOVE_INVALID,
48  REMOVE_DUPLICATES,
49  SORT_BY_COLUMN,
50  REFRESH
51  };
52  explicit PlayListTask(QObject *parent);
53 
54  ~PlayListTask();
55 
56  void sort(QList<PlayListTrack *> tracks, PlayListModel::SortMode mode);
57  void sortSelection(QList<PlayListTrack *> tracks, PlayListModel::SortMode mode);
58  void sortByColumn(QList <PlayListTrack *> tracks, int column);
59  void removeInvalidTracks(QList<PlayListTrack *> tracks, PlayListTrack *current_track);
60  void removeDuplicates(QList<PlayListTrack *> tracks, PlayListTrack *current_track);
61  void refresh(QList<PlayListTrack *> tracks, PlayListTrack *current_track);
62 
63  void run() override;
64 
65  TaskType type() const;
66  bool isChanged(PlayListContainer *container);
67  QList<PlayListTrack *> takeResults(PlayListTrack **current_track);
68  PlayListTrack *currentTrack() const;
69  int column() const;
70  bool isReverted() const;
71  void clear();
72 
73 
74 private:
75  QList <TrackField *> m_fields;
76  QList <PlayListTrack *> m_tracks;
77  QList <PlayListTrack *> m_input_tracks;
78  QList<int> m_indexes;
79  QList <PlayListTrack *> m_new_tracks;
80  PlayListTrack *m_current_track;
81  int m_sort_mode = PlayListModel::TITLE;
82  TaskType m_task = EMPTY;
83  bool m_reverted = true;
84  bool m_align_groups = false;
85  int m_column = 0;
86  QHash<int, Qmmp::MetaData> m_sort_keys;
87 
88 };
89 
90 #endif // PLAYLISTTASK_P_H
SortMode
Definition: playlistmodel.h:309
@ TITLE
Definition: playlistmodel.h:310
The PlayListTrack class provides a track for use with the PlayListModel class.
Definition: playlisttrack.h:37