QGIS API Documentation  3.4.3-Madeira (2f64a3c)
qgscptcitycolorrampdialog.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgscptcitycolorrampdialog.h
3  ---------------------
4  begin : July 2012
5  copyright : (C) 2012 by Etienne Tourigny
6  email : etourigny dot dev at gmail.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 QGSCPTCITYCOLORRAMPV2DIALOG_H
17 #define QGSCPTCITYCOLORRAMPV2DIALOG_H
18 
19 
20 #include "ui_qgscptcitycolorrampv2dialogbase.h"
21 #include "qgis.h"
22 #include <QDialog>
23 
24 #include "qgscptcityarchive.h"
25 
26 #include <QAbstractProxyModel>
27 #include <QSortFilterProxyModel>
28 #include <QFileInfo>
29 #include "qgis_gui.h"
30 
32 class TreeFilterProxyModel;
33 class ListFilterProxyModel;
34 class UngroupProxyModel;
35 
42 class GUI_EXPORT QgsCptCityColorRampDialog : public QDialog, private Ui::QgsCptCityColorRampDialogBase
43 {
44  Q_OBJECT
45  Q_PROPERTY( QgsCptCityColorRamp ramp READ ramp WRITE setRamp )
46 
47  public:
48 
54  QgsCptCityColorRampDialog( const QgsCptCityColorRamp &ramp, QWidget *parent SIP_TRANSFERTHIS = nullptr );
55 
60  QgsCptCityColorRamp ramp() const { return mRamp; }
61 
67  void setRamp( const QgsCptCityColorRamp &ramp );
68 
72  QString selectedName() const
73  {
74  return QFileInfo( mRamp.schemeName() ).baseName() + mRamp.variantName();
75  }
76 
80  bool saveAsGradientRamp() const;
81 
82  bool eventFilter( QObject *obj, QEvent *event ) override;
83 
84  signals:
85 
87  void changed();
88 
89  private slots:
90  void populateVariants();
91 
92  void mTreeView_clicked( const QModelIndex & );
93  void mListWidget_itemClicked( QListWidgetItem *item );
94  void mListWidget_itemSelectionChanged();
95  void tabBar_currentChanged( int index );
96  void pbtnLicenseDetails_pressed();
97  void cboVariantName_currentIndexChanged( int index );
98  void onFinished();
99  void showHelp();
100  /* void refresh(); */
101 
102  private:
103 
104  void updateUi();
105  void updatePreview( bool clear = false );
106  void clearCopyingInfo();
107  void updateCopyingInfo( const QMap< QString, QString > &copyingMap );
108  void updateTreeView( QgsCptCityDataItem *item, bool resetRamp = true );
109  void updateListWidget( QgsCptCityDataItem *item );
110 
111  QgsCptCityColorRamp mRamp;
112  QgsCptCityArchive *mArchive = nullptr;
113  QgsCptCityBrowserModel::ViewType mArchiveViewType;
114 
115  /* void refreshModel( const QModelIndex& index ); */
116  bool updateRamp();
117  void showAll();
118  void setTreeModel( QgsCptCityBrowserModel *model );
119 
120  QgsCptCityBrowserModel *mModel = nullptr;
121  QgsCptCityBrowserModel *mAuthorsModel = nullptr;
122  QgsCptCityBrowserModel *mSelectionsModel = nullptr;
123  TreeFilterProxyModel *mTreeFilter = nullptr;
124  QVector<QgsCptCityColorRampItem *> mListRamps;
125 
126 };
127 
128 #ifndef SIP_RUN
129 
135 class TreeFilterProxyModel : public QSortFilterProxyModel
136 {
137  Q_OBJECT
138 
139  public:
140  TreeFilterProxyModel( QObject *parent, QgsCptCityBrowserModel *model );
141 
142  protected:
143  bool filterAcceptsRow( int sourceRow, const QModelIndex &sourceParent ) const override;
144  // bool lessThan(const QModelIndex &left, const QModelIndex &right) const;
145 
146  private:
147  QgsCptCityBrowserModel *mModel = nullptr;
148 };
149 
151 #endif
152 
153 #endif
QgsCptCityColorRamp ramp() const
Returns a color ramp representing the current settings from the dialog.
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:46
QString selectedName() const
Returns the name of the ramp currently selected in the dialog.
Base class for all items in the model.
A dialog which allows users to modify the properties of a QgsCptCityColorRamp.