QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
qgsexternalresourcewidget.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsexternalresourcewidget.h
3 
4  ---------------------
5  begin : 16.12.2015
6  copyright : (C) 2015 by Denis Rouzaud
7  email : [email protected]
8  ***************************************************************************
9  * *
10  * This program is free software; you can redistribute it and/or modify *
11  * it under the terms of the GNU General Public License as published by *
12  * the Free Software Foundation; either version 2 of the License, or *
13  * (at your option) any later version. *
14  * *
15  ***************************************************************************/
16 
17 #ifndef QGSEXTERNALRESOURCEWIDGET_H
18 #define QGSEXTERNALRESOURCEWIDGET_H
19 
20 class QWebView;
21 class QgsPixmapLabel;
22 
23 #include <QWidget>
24 #include <QVariant>
25 
26 #include "qgsfilewidget.h"
27 
28 
29 
30 
35 class GUI_EXPORT QgsExternalResourceWidget : public QWidget
36 {
37 
38  Q_OBJECT
39  Q_PROPERTY( bool fileWidgetVisible READ fileWidgetVisible WRITE setFileWidgetVisible )
40  Q_PROPERTY( DocumentViewerContent documentViewerContent READ documentViewerContent WRITE setDocumentViewerContent )
41  Q_PROPERTY( int documentViewerHeight READ documentViewerHeight WRITE setDocumentViewerHeight )
42  Q_PROPERTY( int documentViewerWidth READ documentViewerWidth WRITE setDocumentViewerWidth )
43  Q_PROPERTY( QgsFileWidget::RelativeStorage relativeStorage READ relativeStorage WRITE setRelativeStorage )
44  Q_PROPERTY( QString defaultRoot READ defaultRoot WRITE setDefaultRoot )
45 
46  public:
48  {
51  Web
52  };
53 
59  explicit QgsExternalResourceWidget( QWidget *parent = 0 );
60 
65  QVariant documentPath( QVariant::Type type = QVariant::String ) const;
66  void setDocumentPath( const QVariant& documentPath );
67 
69  QgsFileWidget* fileWidget();
70 
72  bool fileWidgetVisible() const;
74  void setFileWidgetVisible( bool visible );
75 
77  QgsExternalResourceWidget::DocumentViewerContent documentViewerContent() const;
79  void setDocumentViewerContent( QgsExternalResourceWidget::DocumentViewerContent content );
80 
82  int documentViewerHeight() const;
87  void setDocumentViewerHeight( int height );
89  int documentViewerWidth() const ;
94  void setDocumentViewerWidth( int width );
95 
97  void setReadOnly( bool readOnly );
98 
103  QgsFileWidget::RelativeStorage relativeStorage() const;
104 
109  void setRelativeStorage( const QgsFileWidget::RelativeStorage& relativeStorage );
110 
111 
116  QString defaultRoot() const;
117 
122  void setDefaultRoot( const QString& defaultRoot );
123 
124  signals:
126  void valueChanged( const QString& );
127 
128  private slots:
129  void loadDocument( const QString& path );
130 
131  private:
132  void updateDocumentViewer();
133 
134  QString resolvePath( const QString& path );
135 
137  bool mFileWidgetVisible;
138  DocumentViewerContent mDocumentViewerContent;
139  int mDocumentViewerHeight;
140  int mDocumentViewerWidth;
141  QgsFileWidget::RelativeStorage mRelativeStorage;
142  QString mDefaultRoot; // configured default root path for QgsFileWidget::RelativeStorage::RelativeDefaultPath
143 
145  QgsFileWidget* mFileWidget;
146  QgsPixmapLabel* mPixmapLabel;
147 #ifdef WITH_QTWEBKIT
148  QWebView* mWebView;
150 #endif
151 
152 };
153 
154 #endif // QGSEXTERNALRESOURCEWIDGET_H
The QgsFileWidget class creates a widget for selecting a file or a folder.
Definition: qgsfilewidget.h:31
Widget to display file path with a push button for an "open file" dialog It can also be used to displ...
RelativeStorage
The RelativeStorage enum determines if path is absolute, relative to the current project path or rela...
Definition: qgsfilewidget.h:56
The QgsPixmapLabel class shows a pixmap and adjusts its size to the space given to the widget by the ...