QGIS API Documentation  3.6.0-Noosa (5873452)
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 #include "qgis_gui.h"
28 #include "qgis_sip.h"
29 
30 
31 #ifdef SIP_RUN
32 % ModuleHeaderCode
33 // fix to allow compilation with sip that for some reason
34 // doesn't add this include to the file where the code from
35 // ConvertToSubClassCode goes.
37 % End
38 #endif
39 
40 
46 class GUI_EXPORT QgsExternalResourceWidget : public QWidget
47 {
48 
49 #ifdef SIP_RUN
51  if ( qobject_cast<QgsExternalResourceWidget *>( sipCpp ) )
52  sipType = sipType_QgsExternalResourceWidget;
53  else
54  sipType = NULL;
55  SIP_END
56 #endif
57 
58  Q_OBJECT
59  Q_PROPERTY( bool fileWidgetVisible READ fileWidgetVisible WRITE setFileWidgetVisible )
60  Q_PROPERTY( DocumentViewerContent documentViewerContent READ documentViewerContent WRITE setDocumentViewerContent )
61  Q_PROPERTY( int documentViewerHeight READ documentViewerHeight WRITE setDocumentViewerHeight )
62  Q_PROPERTY( int documentViewerWidth READ documentViewerWidth WRITE setDocumentViewerWidth )
63  Q_PROPERTY( QgsFileWidget::RelativeStorage relativeStorage READ relativeStorage WRITE setRelativeStorage )
64  Q_PROPERTY( QString defaultRoot READ defaultRoot WRITE setDefaultRoot )
65 
66  public:
68  {
71  Web
72  };
73 
79  explicit QgsExternalResourceWidget( QWidget *parent SIP_TRANSFERTHIS = nullptr );
80 
85  QVariant documentPath( QVariant::Type type = QVariant::String ) const;
86  void setDocumentPath( const QVariant &documentPath );
87 
89  QgsFileWidget *fileWidget();
90 
92  bool fileWidgetVisible() const;
94  void setFileWidgetVisible( bool visible );
95 
97  QgsExternalResourceWidget::DocumentViewerContent documentViewerContent() const;
99  void setDocumentViewerContent( QgsExternalResourceWidget::DocumentViewerContent content );
100 
102  int documentViewerHeight() const;
103 
108  void setDocumentViewerHeight( int height );
110  int documentViewerWidth() const;
111 
116  void setDocumentViewerWidth( int width );
117 
119  void setReadOnly( bool readOnly );
120 
125  QgsFileWidget::RelativeStorage relativeStorage() const;
126 
131  void setRelativeStorage( QgsFileWidget::RelativeStorage relativeStorage );
132 
133 
138  QString defaultRoot() const;
139 
144  void setDefaultRoot( const QString &defaultRoot );
145 
146  signals:
148  void valueChanged( const QString & );
149 
150  private slots:
151  void loadDocument( const QString &path );
152 
153  private:
154  void updateDocumentViewer();
155 
156  QString resolvePath( const QString &path );
157 
159  bool mFileWidgetVisible = true;
160  DocumentViewerContent mDocumentViewerContent = NoContent;
161  int mDocumentViewerHeight = 0;
162  int mDocumentViewerWidth = 0;
164  QString mDefaultRoot; // configured default root path for QgsFileWidget::RelativeStorage::RelativeDefaultPath
165 
167  QgsFileWidget *mFileWidget = nullptr;
168  QgsPixmapLabel *mPixmapLabel = nullptr;
169 #ifdef WITH_QTWEBKIT
170  QWebView *mWebView = nullptr;
172 #endif
173 
174 };
175 
176 #endif // QGSEXTERNALRESOURCEWIDGET_H
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:46
The QgsFileWidget class creates a widget for selecting a file or a folder.
Definition: qgsfilewidget.h:35
#define SIP_END
Definition: qgis_sip.h:182
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition: qgis_sip.h:165
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:74
The QgsPixmapLabel class shows a pixmap and adjusts its size to the space given to the widget by the ...