QGIS API Documentation 4.3.0-Master (16649ce5cc6)
Loading...
Searching...
No Matches
qgsprocessingdefaultstyledialog.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsprocessingdefaultstyledialog.h
3 ----------------------------------
4 Date : September 2026
5 Copyright : (C) 2026 Nyall Dawson
6 Email : nyall dot dawson at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16#ifndef QGSPROCESSINGDEFAULTSTYLEDIALOG_H
17#define QGSPROCESSINGDEFAULTSTYLEDIALOG_H
18
19#include "ui_qgsprocessingdefaultstylesdialogbase.h"
20
21#include "qgis.h"
22#include "qgis_gui.h"
23
24#include <QDialog>
25#include <QStyledItemDelegate>
26
27#define SIP_NO_FILE
28
30
32
33class QgsProcessingDefaultStyleDelegate : public QStyledItemDelegate
34{
35 Q_OBJECT
36
37 public:
38 explicit QgsProcessingDefaultStyleDelegate( QObject *parent = nullptr );
39
40 QWidget *createEditor( QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index ) const override;
41
42 void setEditorData( QWidget *editor, const QModelIndex &index ) const override;
43
44 void setModelData( QWidget *editor, QAbstractItemModel *model, const QModelIndex &index ) const override;
45
46 void updateEditorGeometry( QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index ) const override;
47};
48
49
50class QgsProcessingDefaultStylesModel : public QAbstractTableModel
51{
52 Q_OBJECT
53
54 public:
55 explicit QgsProcessingDefaultStylesModel( const QgsProcessingAlgorithm *algorithm, QObject *parent = nullptr );
56
57 int rowCount( const QModelIndex &parent = QModelIndex() ) const override;
58 int columnCount( const QModelIndex &parent = QModelIndex() ) const override;
59 QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const override;
60 bool setData( const QModelIndex &index, const QVariant &value, int role = Qt::EditRole ) override;
61 Qt::ItemFlags flags( const QModelIndex &index ) const override;
62 QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const override;
63
64 void saveStyles();
65
66 private:
67 enum Column
68 {
69 OutputName = 0,
70 StylePath = 1
71 };
72
73 struct OutputItem
74 {
75 QString name;
76 QString description;
77 QString stylePath;
78 };
79
80 QString mAlgorithmId;
81 QVector<OutputItem> mItems;
82};
84
91class GUI_EXPORT QgsProcessingDefaultStyleDialog : public QDialog, private Ui::QgsProcessingDefaultStylesDialogBase
92{
93 Q_OBJECT
94
95 public:
100
101 void accept() override;
102
103 protected:
104 void showEvent( QShowEvent *event ) override;
105
106 private:
107 const QgsProcessingAlgorithm *mAlgorithm = nullptr;
108 QgsProcessingDefaultStylesModel *mModel = nullptr;
109 QgsProcessingDefaultStyleDelegate *mDelegate = nullptr;
110 bool mInitialWidthsSet = false;
111};
112
113#endif // QGSPROCESSINGDEFAULTSTYLEDIALOG_H
Abstract base class for processing algorithms.
QgsProcessingDefaultStyleDialog(const QgsProcessingAlgorithm *algorithm, QWidget *parent=nullptr)
Constructor for QgsProcessingDefaultStyleDialog.
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into allowing algorithms to be written in pure substantial changes are required in order to port existing x Processing algorithms for QGIS x The most significant changes are outlined not GeoAlgorithm For algorithms which operate on features one by consider subclassing the QgsProcessingFeatureBasedAlgorithm class This class allows much of the boilerplate code for looping over features from a vector layer to be bypassed and instead requires implementation of a processFeature method Ensure that your algorithm(or algorithm 's parent class) implements the new pure virtual createInstance(self) call
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:52