15 #ifndef QGSCOLORSCHEMELIST_H
16 #define QGSCOLORSCHEMELIST_H
20 #include <QAbstractItemModel>
21 #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;
84 QModelIndex index(
int row,
int column,
const QModelIndex &parent = QModelIndex() )
const override;
85 QModelIndex parent(
const QModelIndex &index )
const override;
86 int rowCount(
const QModelIndex &parent = QModelIndex() )
const override;
87 int columnCount(
const QModelIndex &parent = QModelIndex() )
const override;
88 QVariant data(
const QModelIndex &index,
int role = Qt::DisplayRole )
const override;
89 Qt::ItemFlags flags(
const QModelIndex &index )
const override;
90 bool setData(
const QModelIndex &index,
const QVariant &value,
int role = Qt::EditRole )
override;
91 QVariant headerData(
int section, Qt::Orientation orientation,
int role = Qt::DisplayRole )
const override;
92 Qt::DropActions supportedDropActions()
const override;
93 QStringList mimeTypes()
const override;
94 bool removeRows(
int row,
int count,
const QModelIndex &parent = QModelIndex() )
override;
95 bool insertRows(
int row,
int count,
const QModelIndex &parent = QModelIndex() )
override;
96 QMimeData *mimeData(
const QModelIndexList &indexes )
const override;
97 bool dropMimeData(
const QMimeData *data, Qt::DropAction action,
int row,
int column,
const QModelIndex &parent )
override;
111 void setScheme(
QgsColorScheme *scheme,
const QString &context = QString(),
const QColor &baseColor = QColor() );
133 void addColor(
const QColor &color,
const QString &label = QString(),
bool allowDuplicate =
false );
183 bool saveColorsToScheme();
190 bool importColorsFromGpl( QFile &file );
197 bool exportColorsToGpl( QFile &file );
203 bool isDirty()
const;
221 void setScheme(
QgsColorScheme *scheme,
const QString &context = QString(),
const QColor &baseColor = QColor() );
226 void removeSelection();
234 void addColor(
const QColor &color,
const QString &label = QString(),
bool allowDuplicate =
false );
253 void showImportColorsDialog();
260 void showExportColorsDialog();
272 void keyPressEvent( QKeyEvent *event )
override;
274 void mousePressEvent( QMouseEvent *event )
override;
276 void mouseReleaseEvent( QMouseEvent *event )
override;
283 QPoint mDragStartPosition;
An editable list of color swatches, taken from an associated QgsColorScheme.
void colorSelected(const QColor &color)
Emitted when a color is selected from the list.
A model for colors in a color scheme.
QgsNamedColorList colors() const
Returns a list of colors shown in the widget.
QColor baseColor() const
Gets the base color for the color scheme used by the model.
bool isDirty() const
Returns whether the color scheme model has been modified.
QString context() const
Gets the current color scheme context for the model.
Abstract base class for color schemes.
A delegate for showing a color swatch in a list.
QList< QPair< QColor, QString > > QgsNamedColorList
List of colors paired with a friendly display name identifying the color.