QGIS API Documentation  2.11.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
qgssvgselectorwidget.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgssvgselectorwidget.h - group and preview selector for SVG files
3  built off of work in qgssymbollayerv2widget
4 
5  ---------------------
6  begin : April 2, 2013
7  copyright : (C) 2013 by Larry Shaffer
8  email : larrys at dakcarto dot com
9  ***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 #ifndef QGSSVGSELECTORWIDGET_H
18 #define QGSSVGSELECTORWIDGET_H
19 
20 #include "ui_widget_svgselector.h"
21 
22 #include "qgisgui.h"
23 
24 #include <QAbstractListModel>
25 #include <QDialog>
26 #include <QDialogButtonBox>
27 #include <QLayout>
28 #include <QStandardItemModel>
29 #include <QWidget>
30 
31 class QCheckBox;
32 class QLayout;
33 class QLineEdit;
34 class QListView;
35 class QPushButton;
36 class QTreeView;
37 
39 {
40  Q_OBJECT
41 
42  public:
44 
45  // Constructor to create model for icons in a specific path
46  QgsSvgSelectorListModel( QObject* parent, QString path );
47 
48  int rowCount( const QModelIndex & parent = QModelIndex() ) const override;
49 
50  QVariant data( const QModelIndex & index, int role = Qt::DisplayRole ) const override;
51 
52  protected:
54 };
55 
57 {
58  Q_OBJECT
59 
60  public:
62 
63  private:
64  void createTree( QStandardItem* &parentGroup );
65 };
66 
67 
68 class GUI_EXPORT QgsSvgSelectorWidget : public QWidget, private Ui::WidgetSvgSelector
69 {
70  Q_OBJECT
71 
72  public:
73  QgsSvgSelectorWidget( QWidget* parent = 0 );
75 
76  static QgsSvgSelectorWidget* create( QWidget* parent = 0 ) { return new QgsSvgSelectorWidget( parent ); }
77 
78  QString currentSvgPath() const;
79  QString currentSvgPathToName() const;
80 
81  QTreeView* groupsTreeView() { return mGroupsTreeView; }
82  QListView* imagesListView() { return mImagesListView; }
83  QLineEdit* filePathLineEdit() { return mFileLineEdit; }
84  QPushButton* filePathButton() { return mFilePushButton; }
85  QCheckBox* relativePathCheckbox() { return mRelativePathChkBx; }
86  QLayout* selectorLayout() { return this->layout(); }
87 
88  public slots:
90  void setSvgPath( const QString& svgPath );
91 
92  signals:
93  void svgSelected( const QString& path );
94 
95  protected:
96  void populateList();
97 
98  private slots:
99  void populateIcons( const QModelIndex& idx );
100  void svgSelectionChanged( const QModelIndex& idx );
101  void updateCurrentSvgPath( const QString& svgPath );
102 
103  void on_mFilePushButton_clicked();
104  void updateLineEditFeedback( bool ok, QString tip = QString( "" ) );
105  void on_mFileLineEdit_textChanged( const QString& text );
106 
107  private:
108  QString mCurrentSvgPath; // always stored as absolute path
109 };
110 
111 class GUI_EXPORT QgsSvgSelectorDialog : public QDialog
112 {
113  Q_OBJECT
114  public:
116  QDialogButtonBox::StandardButtons buttons = QDialogButtonBox::Close | QDialogButtonBox::Ok,
117  Qt::Orientation orientation = Qt::Horizontal );
119 
121  QVBoxLayout* layout() { return mLayout; }
122 
124  QDialogButtonBox* buttonBox() { return mButtonBox; }
125 
127  QgsSvgSelectorWidget* svgSelector() { return mSvgSelector; }
128 
129  protected:
133 };
134 
135 #endif // QGSSVGSELECTORWIDGET_H
QLayout * layout() const
QgsSvgSelectorWidget * mSvgSelector
static const Qt::WindowFlags ModalDialogFlags
Definition: qgisgui.h:48
static unsigned index
virtual int rowCount(const QModelIndex &parent) const =0
QDialogButtonBox * buttonBox()
Returns the button box.
static QgsSvgSelectorWidget * create(QWidget *parent=0)
QPushButton * filePathButton()
QVBoxLayout * layout()
Returns the central layout. Widgets added to it must have this dialog as parent.
QDialogButtonBox * mButtonBox
virtual QVariant data(const QModelIndex &index, int role) const =0
QgsSvgSelectorWidget * svgSelector()
Returns pointer to the embedded SVG selector widget.
typedef StandardButtons
QCheckBox * relativePathCheckbox()
QLineEdit * filePathLineEdit()
typedef WindowFlags