summaryrefslogtreecommitdiffstats
path: root/src/preferences/colorpaletteeditormodel.h
blob: d57f7ace10ef4c0e96a377618b29077edc632457 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#pragma once
#include <QStandardItem>
#include <QStandardItemModel>
#include <QVariant>

#include "util/color/colorpalette.h"

// Model that is used by the QTableView of the ColorPaletteEditor.
// Takes care of displaying palette colors and provides a getter/setter for
// ColorPalette instances.
class ColorPaletteEditorModel : public QStandardItemModel {
    Q_OBJECT
  public:
    ColorPaletteEditorModel(QObject* parent = nullptr);

    bool dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent) override;
    bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override;

    void setColor(int row, const QColor& color);
    void appendRow(const QColor& color, const QList<int>& hotcueIndicies);

    void setDirty(bool bDirty) {
        if (m_bDirty == bDirty) {
            return;
        }
        m_bDirty = bDirty;
        emit dirtyChanged(m_bDirty);
    }

    bool isDirty() const {
        return m_bDirty;
    }

    bool isEmpty() const {
        return m_bEmpty;
    }

    void setColorPalette(const ColorPalette& palette);
    ColorPalette getColorPalette(const QString& name) const;

  signals:
    void emptyChanged(bool bIsEmpty);
    void dirtyChanged(bool bIsDirty);

  private:
    bool m_bEmpty;
    bool m_bDirty;
};

class HotcueIndexListItem : public QStandardItem {
  public:
    HotcueIndexListItem(const QList<int>& hotcueList = {});

    void setData(const QVariant& value, int role = Qt::UserRole + 1) override;
    QVariant data(int role = Qt::UserRole + 1) const override;

    int type() const override {
        return QStandardItem::UserType;
    };

    const QList<int>& getHotcueIndexList() const {
        return m_hotcueIndexList;
    }
    void setHotcueIndexList(const QList<int>& list) {
        m_hotcueIndexList = QList(list);
    }

    void removeIndicies(const QList<int>& otherIndicies);

  private:
    QList<int> m_hotcueIndexList;
};