1 /*************************************************************************** 2 qgsmodelinputreorderwidget.h 3 ---------------------------------- 4 Date : April 2020 5 Copyright : (C) 2020 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 QGSMODELINPUTREORDERWIDGET_H 17 #define QGSMODELINPUTREORDERWIDGET_H 18 19 #define SIP_NO_FILE 20 21 #include "qgis.h" 22 #include "qgis_gui.h" 23 #include "ui_qgsmodelinputreorderwidgetbase.h" 24 #include "processing/models/qgsprocessingmodelparameter.h" 25 #include <QDialog> 26 27 class QStandardItemModel; 28 class QgsProcessingModelAlgorithm; 29 30 ///@cond PRIVATE 31 32 /** 33 * A widget for reordering inputs for Processing models. 34 * \ingroup gui 35 * \note Not stable API 36 * \since QGIS 3.14 37 */ 38 class GUI_EXPORT QgsModelInputReorderWidget : public QWidget, private Ui::QgsModelInputReorderWidgetBase 39 { 40 Q_OBJECT 41 42 public: 43 44 /** 45 * Constructor for QgsModelInputReorderWidget. 46 */ 47 QgsModelInputReorderWidget( QWidget *parent = nullptr ); 48 49 /** 50 * Sets the source \a model from which to obtain the list of inputs. 51 */ 52 void setModel( QgsProcessingModelAlgorithm *model ); 53 54 /** 55 * Returns the ordered list of inputs (by name). 56 */ 57 QStringList inputOrder() const; 58 59 private: 60 61 QgsProcessingModelAlgorithm *mModel; 62 QList< QgsProcessingModelParameter > mParameters; 63 QStandardItemModel *mItemModel = nullptr; 64 }; 65 66 67 /** 68 * A dialog for reordering inputs for Processing models. 69 * \ingroup gui 70 * \note Not stable API 71 * \since QGIS 3.14 72 */ 73 class GUI_EXPORT QgsModelInputReorderDialog : public QDialog 74 { 75 76 public: 77 78 /** 79 * Constructor for QgsModelInputReorderDialog. 80 */ 81 QgsModelInputReorderDialog( QWidget *parent = nullptr ); 82 83 /** 84 * Sets the source \a model from which to obtain the list of inputs. 85 */ 86 void setModel( QgsProcessingModelAlgorithm *model ); 87 88 /** 89 * Returns the ordered list of inputs (by name). 90 */ 91 QStringList inputOrder() const; 92 93 private: 94 95 QgsModelInputReorderWidget *mWidget = nullptr; 96 }; 97 98 ///@endcond 99 100 #endif // QGSMODELINPUTREORDERWIDGET_H 101