src/dialogs/colortoolbareditor.h

changeset 1432
4cc687851fbb
equal deleted inserted replaced
1431:2e0e2c696605 1432:4cc687851fbb
1 /*
2 * LDForge: LDraw parts authoring CAD
3 * Copyright (C) 2013 - 2018 Teemu Piippo
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 3 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, see <http://www.gnu.org/licenses/>.
17 */
18
19 #pragma once
20 #include <QWidget>
21 #include <QAbstractListModel>
22 #include "colors.h"
23
24 class ColorToolbarModel : public QAbstractListModel
25 {
26 Q_OBJECT
27
28 public:
29 ColorToolbarModel(QVector<LDColor>& colorToolbar);
30 int rowCount(QModelIndex const& = {}) const override;
31 QVariant data(QModelIndex const& index, int role) const override;
32 LDColor colorAt(QModelIndex const& index) const;
33 void setColorAt(QModelIndex const& index, LDColor newColor);
34 bool isValidIndex(QModelIndex const& index) const;
35 void moveColor(const QModelIndex &index, const bool up);
36 bool insertRows(int row, int count, QModelIndex const& = {}) override;
37 bool removeRows(int row, int count, QModelIndex const& = {}) override;
38
39 bool isValidRow(int row) const;
40 private:
41 QVector<LDColor>& colorToolbar;
42 };
43
44 class ColorToolbarEditor : public QWidget
45 {
46 Q_OBJECT
47
48 public:
49 explicit ColorToolbarEditor(QWidget *parent = nullptr);
50 ~ColorToolbarEditor();
51
52 public slots:
53 void addColor();
54 void editColor();
55 void removeColor();
56 void moveColor();
57 void addSeparator();
58 void clearColors();
59 void saveChanges();
60
61 private:
62 QVector<LDColor> colorToolbar;
63 ColorToolbarModel model;
64 class Ui_ColorToolbarEditor &ui;
65 int newItemPosition();
66 };

mercurial