Switch to unified view

a/HelperStructs/PlaylistMode.h b/HelperStructs/PlaylistMode.h
...
...
16
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
 */
17
 */
18
#ifndef PLAYLISTMODE_H_
18
#ifndef PLAYLISTMODE_H_
19
#define PLAYLISTMODE_H_
19
#define PLAYLISTMODE_H_
20
20
21
#include <QDebug>
22
#include <QString>
23
#include <QStringList>
24
25
struct Playlist_Mode {
21
struct Playlist_Mode {
26
22
27
    bool rep1;
23
    // Modes for playing the track sequence: both can be set
24
25
    // Restart when done.
28
    bool repAll;
26
    bool repAll;
29
    bool repNone;
27
    // Play in random order.
30
    bool append;
31
    bool shuffle;
28
    bool shuffle;
32
    bool dynamic;
33
29
30
    // Modes for adding tracks
31
32
    // Add at end of list, else after current track
33
    bool append; 
34
    // Replace current list. This implies append of course, so
35
    // grey-out append when this is set
36
    bool replace; 
37
    // Begin playing the first track added.
38
    bool playAdded; 
39
34
    Playlist_Mode() {
40
    Playlist_Mode() { 
35
        rep1 = false;
41
        fromInt(0);
36
        repAll = false;
37
        repNone = true;
38
        append = false;
39
        shuffle = false;
40
    }
42
    }
43
    Playlist_Mode(int val) {
44
        fromInt(val);
45
    }
46
    int toInt() const {
47
        int ret = 0;
41
48
42
    void print() const {
49
        if (repAll)     ret |= 1;
43
        qDebug() << "rep1 = " << rep1 << ", "
50
        if (shuffle)    ret |= 2;
44
             << "repAll = " << repAll << ", "
51
        if (append)     ret |= 4;
45
             << "repNone = " << repNone << ", "
52
        if (replace)    ret |= 8;
46
             << "append = " << append <<", "
53
        if (playAdded)  ret |= 16;
47
             << "dynamic = " << dynamic << ","
54
48
             << endl;
55
        return ret;
49
    }
56
    }
50
57
    void fromInt(int val) {
51
    QString toString() {
58
        repAll =      (val & 1) != 0;
52
        QString str;
59
        shuffle =     (val & 2) != 0;
53
        str += (append ? "1" : "0")  + QString(",");
60
        append =      (val & 4) != 0;
54
        str += (repAll ? "1" : "0")  + QString(",");
61
        replace =     (val & 8) != 0;
55
        str += (rep1 ? "1" : "0")  + QString(",");
62
        playAdded =   (val & 16) != 0;
56
        str += (repNone ? "1" : "0")  + QString(",");
57
        str += (shuffle ? "1" : "0")  + QString(",");
58
        str += (dynamic ? "1" : "0");
59
60
        return str;
61
    }
63
    }
62
63
    void fromString(QString str) {
64
        QStringList list = str.split(',');
65
        if(list.size() != 6) return;
66
67
        append = list[0].toInt() == 1;
68
        repAll = list[1].toInt() == 1;
69
        rep1 = list[2].toInt() == 1;
70
        repNone = list[3].toInt() == 1;
71
        shuffle = list[4].toInt() == 1;
72
        dynamic = list[5].toInt() == 1;
73
    }
74
75
};
64
};
76
65
77
#endif
66
#endif