15#ifndef QGSCOLORSCHEMELIST_H
16#define QGSCOLORSCHEMELIST_H
22#include <QAbstractItemModel>
24#include <QItemDelegate>
42 void paint( QPainter *painter,
const QStyleOptionViewItem &option,
const QModelIndex &index )
const override;
43 QSize
sizeHint(
const QStyleOptionViewItem &option,
const QModelIndex &index )
const override;
44 bool editorEvent( QEvent *event, QAbstractItemModel *model,
const QStyleOptionViewItem &option,
const QModelIndex &index )
override;
51 QWidget *mParent =
nullptr;
57 QPixmap transparentBackground()
const;
82 QModelIndex
index(
int row,
int column,
const QModelIndex &
parent = QModelIndex() )
const override;
83 QModelIndex
parent(
const QModelIndex &
index )
const override;
84 int rowCount(
const QModelIndex &
parent = QModelIndex() )
const override;
86 QVariant
data(
const QModelIndex &
index,
int role = Qt::DisplayRole )
const override;
87 Qt::ItemFlags
flags(
const QModelIndex &
index )
const override;
88 bool setData(
const QModelIndex &
index,
const QVariant &value,
int role = Qt::EditRole )
override;
89 QVariant
headerData(
int section, Qt::Orientation orientation,
int role = Qt::DisplayRole )
const override;
92 bool removeRows(
int row,
int count,
const QModelIndex &
parent = QModelIndex() )
override;
93 bool insertRows(
int row,
int count,
const QModelIndex &
parent = QModelIndex() )
override;
94 QMimeData *
mimeData(
const QModelIndexList &indexes )
const override;
95 bool dropMimeData(
const QMimeData *
data, Qt::DropAction action,
int row,
int column,
const QModelIndex &
parent )
override;
109 void setScheme(
QgsColorScheme *scheme,
const QString &context = QString(),
const QColor &baseColor = QColor() );
131 void addColor(
const QColor &color,
const QString &label = QString(),
bool allowDuplicate =
false );
147 QgsColorScheme *mScheme =
nullptr;
150 bool mIsDirty =
false;
228 void addColor(
const QColor &color,
const QString &label = QString(),
bool allowDuplicate =
false );
274 QPoint mDragStartPosition;
bool exportColorsToGpl(QFile &file)
Export colors to a GPL palette file from the list.
void setScheme(QgsColorScheme *scheme, const QString &context=QString(), const QColor &baseColor=QColor())
Sets the color scheme to show in the list.
void pasteColors()
Pastes colors from clipboard to the list.
void removeSelection()
Removes any selected colors from the list.
bool importColorsFromGpl(QFile &file)
Import colors from a GPL palette file to the list.
void copyColors()
Copies colors from the list to the clipboard.
bool isDirty() const
Returns whether the color scheme list has been modified.
void mouseReleaseEvent(QMouseEvent *event) override
void mousePressEvent(QMouseEvent *event) override
QgsColorScheme * scheme()
Returns the scheme currently selected in the list.
void addColor(const QColor &color, const QString &label=QString(), bool allowDuplicate=false)
Adds a color to the list.
void showExportColorsDialog()
Displays a file picker dialog allowing users to export colors from the list into a file.
void colorSelected(const QColor &color)
Emitted when a color is selected from the list.
void keyPressEvent(QKeyEvent *event) override
QgsColorSchemeList(QWidget *parent=nullptr, QgsColorScheme *scheme=nullptr, const QString &context=QString(), const QColor &baseColor=QColor())
Construct a new color swatch grid.
bool saveColorsToScheme()
Saves the current colors shown in the list back to a color scheme, if supported by the color scheme.
void showImportColorsDialog()
Displays a file picker dialog allowing users to import colors into the list from a file.
A model for colors in a color scheme.
QgsNamedColorList colors() const
Returns a list of colors shown in the widget.
bool removeRows(int row, int count, const QModelIndex &parent=QModelIndex()) override
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
QColor baseColor() const
Gets the base color for the color scheme used by the model.
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Qt::DropActions supportedDropActions() const override
QModelIndex parent(const QModelIndex &index) const override
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Qt::ItemFlags flags(const QModelIndex &index) const override
bool insertRows(int row, int count, const QModelIndex &parent=QModelIndex()) override
QMimeData * mimeData(const QModelIndexList &indexes) const override
bool isDirty() const
Returns whether the color scheme model has been modified.
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
QgsColorSchemeModel(QgsColorScheme *scheme, const QString &context=QString(), const QColor &baseColor=QColor(), QObject *parent=nullptr)
Constructor.
QStringList mimeTypes() const override
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override
QString context() const
Gets the current color scheme context for the model.
int columnCount(const QModelIndex &parent=QModelIndex()) const override
Abstract base class for color schemes.
A delegate for showing a color swatch in a list.
QgsColorSwatchDelegate(QWidget *parent=nullptr)
bool editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index) override
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override
QList< QPair< QColor, QString > > QgsNamedColorList
List of colors paired with a friendly display name identifying the color.