-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add class QgsSourceSelectProvider and tests
This is the first step for QEP 101
- Loading branch information
Showing
8 changed files
with
206 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -405,3 +405,4 @@ | |
%Include symbology/qgsarrowsymbollayer.sip | ||
%Include composer/qgscomposerutils.sip | ||
%Include qgsuserprofile.sip | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/gui/qgssourceselectprovider.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ | ||
|
||
|
||
|
||
|
||
class QgsSourceSelectProvider | ||
{ | ||
%Docstring | ||
.. seealso:: QgsDataSourceManagerDialog | ||
|
||
.. versionadded:: 3.0 | ||
%End | ||
|
||
%TypeHeaderCode | ||
#include "qgssourceselectprovider.h" | ||
%End | ||
public: | ||
virtual ~QgsSourceSelectProvider(); | ||
|
||
virtual QString providerKey() const = 0; | ||
%Docstring | ||
Provider key | ||
:rtype: str | ||
%End | ||
|
||
virtual QString text() const = 0; | ||
%Docstring | ||
Text for the menu item entry | ||
:rtype: str | ||
%End | ||
|
||
virtual QIcon icon() const = 0 /Factory/; | ||
%Docstring | ||
Caller takes responsibility of deleting created. | ||
:rtype: QIcon | ||
%End | ||
|
||
virtual QgsAbstractDataSourceWidget *createDataSourceWidget( ) = 0 /Factory/; | ||
%Docstring | ||
Caller takes responsibility of deleting created. | ||
:rtype: QgsAbstractDataSourceWidget | ||
%End | ||
|
||
}; | ||
|
||
|
||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/gui/qgssourceselectprovider.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/*************************************************************************** | ||
qgssourceselectprovider.cpp - QgsSourceSelectProvider | ||
--------------------- | ||
begin : 1.9.2017 | ||
copyright : (C) 2017 by Alessandro Pasotti | ||
email : apasotti at boundlessgeo dot com | ||
*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
#include "qgssourceselectprovider.h" | ||
|
||
|
||
// no implementation currently | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/*************************************************************************** | ||
qgssourceselectprovider.h - QgsSourceSelectProvider | ||
--------------------- | ||
begin : 1.9.2017 | ||
copyright : (C) 2017 by Alessandro Pasotti | ||
email : apasotti at boundlessgeo dot com | ||
*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
#ifndef QGSSOURCESELECTPROVIDER_H | ||
#define QGSSOURCESELECTPROVIDER_H | ||
|
||
|
||
#include "qgis_gui.h" | ||
#include "qgis.h" | ||
#include "qgsabstractdatasourcewidget.h" | ||
|
||
class QString; | ||
|
||
/** \ingroup gui | ||
* This is the interface for those who want to add entries to the \see QgsDataSourceManagerDialog | ||
* | ||
* \since QGIS 3.0 | ||
*/ | ||
class GUI_EXPORT QgsSourceSelectProvider | ||
{ | ||
public: | ||
virtual ~QgsSourceSelectProvider() = default; | ||
|
||
//! Provider key | ||
virtual QString providerKey() const = 0; | ||
|
||
//! Text for the menu item entry | ||
virtual QString text() const = 0; | ||
|
||
//! Creates a new instance of an QIcon for the menu item entry | ||
//! Caller takes responsibility of deleting created. | ||
virtual QIcon icon() const = 0 SIP_FACTORY; | ||
|
||
//! Create a new instance of QgsAbstractDataSourceWidget (or null). | ||
//! Caller takes responsibility of deleting created. | ||
virtual QgsAbstractDataSourceWidget *createDataSourceWidget( ) = 0 SIP_FACTORY; | ||
|
||
}; | ||
|
||
|
||
#endif // QGSSOURCESELECTPROVIDER_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
Test the QgsSourceSelectProvider class | ||
Run with: ctest -V -R PyQgsSourceSelectProvider | ||
.. note:: This program is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation; either version 2 of the License, or | ||
(at your option) any later version. | ||
""" | ||
|
||
import os | ||
import tempfile | ||
from qgis.gui import (QgsSourceSelectProvider, QgsAbstractDataSourceWidget) | ||
from qgis.testing import start_app, unittest | ||
from qgis.PyQt.QtGui import QIcon | ||
|
||
__author__ = 'Alessandro Pasotti' | ||
__date__ = '01/09/2017' | ||
__copyright__ = 'Copyright 2017, The QGIS Project' | ||
# This will get replaced with a git SHA1 when you do a git archive | ||
__revision__ = '$Format:%H$' | ||
|
||
|
||
start_app() | ||
|
||
|
||
class ConcreteDataSourceWidget(QgsAbstractDataSourceWidget): | ||
pass | ||
|
||
|
||
class ConcreteSourceSelectProvider(QgsSourceSelectProvider): | ||
|
||
def providerKey(self): | ||
return "MyTestProviderKey" | ||
|
||
def text(self): | ||
return "MyTestProviderText" | ||
|
||
def icon(self): | ||
return QIcon() | ||
|
||
def createDataSourceWidget(self): | ||
return ConcreteDataSourceWidget() | ||
|
||
|
||
class TestQgsSourceSelectProvider(unittest.TestCase): | ||
|
||
def setUp(self): | ||
pass | ||
|
||
def tearDown(self): | ||
pass | ||
|
||
def testConcreteClass(self): | ||
|
||
provider = ConcreteSourceSelectProvider() | ||
self.assertTrue(isinstance(provider, ConcreteSourceSelectProvider)) | ||
widget = provider.createDataSourceWidget() | ||
self.assertTrue(isinstance(widget, ConcreteDataSourceWidget)) | ||
self.assertEqual(provider.providerKey(), "MyTestProviderKey") | ||
self.assertEqual(provider.text(), "MyTestProviderText") | ||
self.assertTrue(isinstance(provider.icon(), QIcon)) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |