Skip to content

Commit

Permalink
make all QgsHelp methods static
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbruy committed Jan 10, 2017
1 parent 1882aea commit 212406c
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 71 deletions.
7 changes: 0 additions & 7 deletions python/core/qgsapplication.sip
Expand Up @@ -437,13 +437,6 @@ static void qtgui_UpdatePyArgv(PyObject *argvlist, int argc, char **argv)
*/
static QgsMessageLog* messageLog();

/**
* Returns the application's help viewer, used for displaying
* help topic for the given key
* @note added in QGIS 3.0
*/
static QgsHelp* helpViewer();

%If(ANDROID)
//dummy method to workaround sip generation issue issue
bool x11EventFilter ( XEvent * event );
Expand Down
16 changes: 3 additions & 13 deletions python/core/qgshelp.sip
Expand Up @@ -14,37 +14,27 @@
* If no help found, default error page with information how to setup
* help system will be shown.
*
* This class can be created directly, or accessed via
* QgsApplication::helpViewer().
*
* @note added in QGIS 3.0
*/
class QgsHelp : QObject
class QgsHelp
{
%TypeHeaderCode
#include <qgshelp.h>
%End

public:

/** Constructor for QgsHelp.
* @param parent parent QObject
*/
QgsHelp( QObject* parent = nullptr );

virtual ~QgsHelp();

/** Opens help topic for the given help key using default system
* web browser. If help topic not found, builtin error page shown.
* @param key key which identified help topic
* @note added in QGIS 3.0
*/
void openHelp( const QString& key ) const;
static void openHelp( const QString& key );

/** Returns URI of the help topic for the given key. If help topic
* not found, URI of the builtin error page returned.
* @param key key which identified help topic
* @note added in QGIS 3.0
*/
QUrl helpUrl( const QString& key ) const;
static QUrl helpUrl( const QString& key );
};
2 changes: 1 addition & 1 deletion src/core/CMakeLists.txt
Expand Up @@ -482,7 +482,6 @@ SET(QGIS_CORE_MOC_HDRS
qgsgeometryvalidator.h
qgsgml.h
qgsgmlschema.h
qgshelp.h
qgsmaplayer.h
qgsmaplayerlegend.h
qgsmaplayermodel.h
Expand Down Expand Up @@ -675,6 +674,7 @@ SET(QGIS_CORE_HDRS
qgsfields.h
qgsfontutils.h
qgsgeometrycache.h
qgshelp.h
qgshistogram.h
qgsindexedfeature.h
qgsinterval.h
Expand Down
8 changes: 0 additions & 8 deletions src/core/qgsapplication.cpp
Expand Up @@ -36,7 +36,6 @@
#include "gps/qgsgpsconnectionregistry.h"
#include "qgspluginlayerregistry.h"
#include "qgsmessagelog.h"
#include "qgshelp.h"

#include <QDir>
#include <QFile>
Expand Down Expand Up @@ -147,7 +146,6 @@ QgsApplication::QgsApplication( int & argc, char ** argv, bool GUIenabled, const
mRasterRendererRegistry = new QgsRasterRendererRegistry();
mGpsConnectionRegistry = new QgsGPSConnectionRegistry();
mPluginLayerRegistry = new QgsPluginLayerRegistry();
mHelpViewer = new QgsHelp();

init( customConfigPath ); // init can also be called directly by e.g. unit tests that don't inherit QApplication.
}
Expand Down Expand Up @@ -293,7 +291,6 @@ QgsApplication::~QgsApplication()
delete mDataItemProviderRegistry;
delete mProfiler;
delete mMessageLog;
delete mHelpViewer;
}

QgsApplication* QgsApplication::instance()
Expand Down Expand Up @@ -1600,8 +1597,3 @@ QgsFieldFormatterRegistry* QgsApplication::fieldFormatterRegistry()
{
return instance()->mFieldFormatterRegistry;
}

QgsHelp* QgsApplication::helpViewer()
{
return instance()->mHelpViewer;
}
11 changes: 0 additions & 11 deletions src/core/qgsapplication.h
Expand Up @@ -37,7 +37,6 @@ class QgsGPSConnectionRegistry;
class QgsDataItemProviderRegistry;
class QgsPluginLayerRegistry;
class QgsMessageLog;
class QgsHelp;

/** \ingroup core
* Extends QApplication to provide access to QGIS specific resources such
Expand Down Expand Up @@ -450,15 +449,6 @@ class CORE_EXPORT QgsApplication : public QApplication
*/
static QgsMessageLog* messageLog();

/**
* Returns the application's help viewer, used for displaying
* help topic for the given key
* @note added in QGIS 3.0
*/
static QgsHelp* helpViewer();



#ifdef ANDROID
//dummy method to workaround sip generation issue issue
bool x11EventFilter( XEvent * event )
Expand Down Expand Up @@ -592,7 +582,6 @@ class CORE_EXPORT QgsApplication : public QApplication
QgsActionScopeRegistry* mActionScopeRegistry;
QgsRuntimeProfiler* mProfiler;
QgsTaskManager* mTaskManager;
QgsHelp* mHelpViewer;
QgsFieldFormatterRegistry* mFieldFormatterRegistry;
QgsColorSchemeRegistry* mColorSchemeRegistry;
QgsPaintEffectRegistry* mPaintEffectRegistry;
Expand Down
19 changes: 5 additions & 14 deletions src/core/qgshelp.cpp
Expand Up @@ -25,21 +25,12 @@
#include "qgis.h"
#include "qgsapplication.h"

QgsHelp::QgsHelp( QObject* parent )
: QObject( parent )
void QgsHelp::openHelp( const QString& key )
{
QDesktopServices::openUrl( QgsHelp::helpUrl( key ) );
}

QgsHelp::~QgsHelp()
{
}

void QgsHelp::openHelp( const QString& key ) const
{
QDesktopServices::openUrl( helpUrl( key ) );
}

QUrl QgsHelp::helpUrl( const QString& key ) const
QUrl QgsHelp::helpUrl( const QString& key )
{
QUrl helpNotFound = QUrl::fromLocalFile( QgsApplication::pkgDataPath() + "/doc/nohelp.html" );

Expand Down Expand Up @@ -84,7 +75,7 @@ QUrl QgsHelp::helpUrl( const QString& key ) const

if ( path.startsWith( QStringLiteral( "http://" ) ) )
{
if ( !urlExists( helpPath ) )
if ( !QgsHelp::urlExists( helpPath ) )
{
continue;
}
Expand All @@ -108,7 +99,7 @@ QUrl QgsHelp::helpUrl( const QString& key ) const
return helpFound ? helpUrl : helpNotFound;
}

bool QgsHelp::urlExists( const QString& url ) const
bool QgsHelp::urlExists( const QString& url )
{
QUrl helpUrl( url );
QTcpSocket socket;
Expand Down
22 changes: 5 additions & 17 deletions src/core/qgshelp.h
Expand Up @@ -16,7 +16,7 @@
#ifndef QGSHELP_H
#define QGSHELP_H

#include <QObject>
#include <QtCore>

/** \ingroup core
* \class QgsHelp
Expand All @@ -34,37 +34,25 @@
* If no help found, default error page with information how to setup
* help system will be shown.
*
* This class can be created directly, or accessed via
* QgsApplication::helpViewer().
*
* @note added in QGIS 3.0
*/
class CORE_EXPORT QgsHelp : public QObject
class CORE_EXPORT QgsHelp
{
Q_OBJECT

public:

/** Constructor for QgsHelp.
* @param parent parent QObject
*/
QgsHelp( QObject* parent = nullptr );

virtual ~QgsHelp();

/** Opens help topic for the given help key using default system
* web browser. If help topic not found, builtin error page shown.
* @param key key which identified help topic
* @note added in QGIS 3.0
*/
void openHelp( const QString& key ) const;
static void openHelp( const QString& key );

/** Returns URI of the help topic for the given key. If help topic
* not found, URI of the builtin error page returned.
* @param key key which identified help topic
* @note added in QGIS 3.0
*/
QUrl helpUrl( const QString& key ) const;
static QUrl helpUrl( const QString& key );

private:

Expand All @@ -73,7 +61,7 @@ class CORE_EXPORT QgsHelp : public QObject
* @param url URL to check
* @note added in QGIS 3.0
*/
bool urlExists( const QString& url ) const;
static bool urlExists( const QString& url );
};

#endif // QGSHELP_H

0 comments on commit 212406c

Please sign in to comment.