QGIS API Documentation  3.22.4-Białowieża (ce8e65e95e)
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 class QgsMessageBar;
25 
26 #include <QWidget>
27 #include <QVariant>
28 #include <QPointer>
29 
30 #include "qgsfilewidget.h"
31 #include "qgis_gui.h"
32 #include "qgis_sip.h"
33 
34 
35 #ifdef SIP_RUN
36 % ModuleHeaderCode
37 // fix to allow compilation with sip that for some reason
38 // doesn't add this include to the file where the code from
39 // ConvertToSubClassCode goes.
41 
43 % End
44 #endif
45 
46 
52 class GUI_EXPORT QgsExternalResourceWidget : public QWidget
53 {
54 
55 #ifdef SIP_RUN
57  if ( qobject_cast<QgsExternalResourceWidget *>( sipCpp ) )
58  sipType = sipType_QgsExternalResourceWidget;
59  else
60  sipType = NULL;
61  SIP_END
62 #endif
63 
64  Q_OBJECT
65  Q_PROPERTY( bool fileWidgetVisible READ fileWidgetVisible WRITE setFileWidgetVisible )
66  Q_PROPERTY( DocumentViewerContent documentViewerContent READ documentViewerContent WRITE setDocumentViewerContent )
67  Q_PROPERTY( int documentViewerHeight READ documentViewerHeight WRITE setDocumentViewerHeight )
68  Q_PROPERTY( int documentViewerWidth READ documentViewerWidth WRITE setDocumentViewerWidth )
69  Q_PROPERTY( QgsFileWidget::RelativeStorage relativeStorage READ relativeStorage WRITE setRelativeStorage )
70  Q_PROPERTY( QString defaultRoot READ defaultRoot WRITE setDefaultRoot )
71 
72  public:
74  {
77  Web
78  };
79 
85  explicit QgsExternalResourceWidget( QWidget *parent SIP_TRANSFERTHIS = nullptr );
86 
91  QVariant documentPath( QVariant::Type type = QVariant::String ) const;
92  void setDocumentPath( const QVariant &documentPath );
93 
97  QgsExternalStorageFileWidget *fileWidget();
98 
100  bool fileWidgetVisible() const;
102  void setFileWidgetVisible( bool visible );
103 
105  QgsExternalResourceWidget::DocumentViewerContent documentViewerContent() const;
107  void setDocumentViewerContent( QgsExternalResourceWidget::DocumentViewerContent content );
108 
110  int documentViewerHeight() const;
111 
116  void setDocumentViewerHeight( int height );
118  int documentViewerWidth() const;
119 
124  void setDocumentViewerWidth( int width );
125 
127  void setReadOnly( bool readOnly );
128 
133  QgsFileWidget::RelativeStorage relativeStorage() const;
134 
139  void setRelativeStorage( QgsFileWidget::RelativeStorage relativeStorage );
140 
141 
146  QString defaultRoot() const;
147 
152  void setDefaultRoot( const QString &defaultRoot );
153 
160  void setStorageType( const QString &storageType );
161 
168  QString storageType() const;
169 
175  void setStorageAuthConfigId( const QString &authCfg );
176 
181  QString storageAuthConfigId() const;
182 
187  void setMessageBar( QgsMessageBar *messageBar );
188 
193  QgsMessageBar *messageBar() const;
194 
195  signals:
197  void valueChanged( const QString & );
198 
199  private slots:
200  void loadDocument( const QString &path );
201  void onFetchFinished();
202 
203  private:
204  void updateDocumentViewer();
205 
209  void updateDocumentContent( const QString &filePath );
210 
214  void clearContent();
215 
216  QString resolvePath( const QString &path );
217 
219  bool mFileWidgetVisible = true;
220  DocumentViewerContent mDocumentViewerContent = NoContent;
221  int mDocumentViewerHeight = 0;
222  int mDocumentViewerWidth = 0;
224  QString mDefaultRoot; // configured default root path for QgsFileWidget::RelativeStorage::RelativeDefaultPath
225 
227  QgsExternalStorageFileWidget *mFileWidget = nullptr;
228  QgsPixmapLabel *mPixmapLabel = nullptr;
229 #ifdef WITH_QTWEBKIT
231  QWebView *mWebView = nullptr;
232 #endif
233  QLabel *mLoadingLabel = nullptr;
234  QLabel *mErrorLabel = nullptr;
235  QMovie *mLoadingMovie = nullptr;
236  QPointer<QgsExternalStorageFetchedContent> mContent;
237 
238  friend class TestQgsExternalResourceWidgetWrapper;
239 };
240 
241 #endif // QGSEXTERNALRESOURCEWIDGET_H
Widget to display file path with a push button for an "open file" dialog It can also be used to displ...
void valueChanged(const QString &)
emitteed as soon as the current document changes
Class for QgsExternalStorage fetched content.
The QgsExternalStorageFileWidget class creates a widget for selecting a file or a folder and stores i...
RelativeStorage
The RelativeStorage enum determines if path is absolute, relative to the current project path or rela...
Definition: qgsfilewidget.h:79
A bar for displaying non-blocking messages to the user.
Definition: qgsmessagebar.h:61
The QgsPixmapLabel class shows a pixmap and adjusts its size to the space given to the widget by the ...
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition: qgis_sip.h:177
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
#define SIP_END
Definition: qgis_sip.h:194